Index: trunk/synchronize.sh =================================================================== --- trunk/synchronize.sh (revision 8428) +++ trunk/synchronize.sh (revision 8429) @@ -1,58 +1,58 @@ #!/bin/sh ### Consider it safer to explicitly mention all files that contain ### email addresses or copyright tags. OLD_YEAR="Copyright (C) 1999-2019"; NEW_YEAR="Copyright (C) 1999-2020"; OLD_YEAR2="Copyright (C) 2001-2019"; NEW_YEAR2="Copyright (C) 2001-2020"; # OLD_ADDRESS="Soyoung Shim " # NEW_ADDRESS="So Young Shim " OLD_ADDRESS="Soyoung Shim" NEW_ADDRESS="So Young Shim" OLD_DATE="Mar 03 2020" NEW_DATE="Jul 03 2020" OLD_VERSION="3.0.0_alpha" NEW_VERSION="3.0.0_alpha+" #OLD_STATUS="PACKAGE_STATUS=\"alpha\"" #NEW_STATUS="PACKAGE_STATUS=\"beta\"" OLD_STATUS="PACKAGE_STATUS=\"release\"" #NEW_STATUS="PACKAGE_STATUS=\"rc1\"" NEW_STATUS="PACKAGE_STATUS=\"alpha\"" ## We should add an option to add an author here. ## share/doc/manual.tex should be changed manually ## We have to discuss the entries in gamelan/manual ## We have to discuss the entries in src/shower MAIN_FILES="AUTHORS BUGS Makefile.am.in README build_master.sh tests/Makefile.am tests/models/Makefile.am tests/models/UFO/Makefile.am tests/models/UFO/SM/Makefile.am tests/models/UFO/MSSM/Makefile.am tests/functional_tests/Makefile.am tests/ext_tests_mssm/Makefile.am tests/ext_tests_nmssm/Makefile.am tests/ext_tests_ilc/Makefile.am tests/ext_tests_nlo/Makefile.am tests/ext_tests_nlo_add/Makefile.am tests/ext_tests_shower/Makefile.am tests/unit_tests/Makefile.am" CONFIGURE_FILES="configure.ac.in src/noweb-frame/whizard-prelude.nw" VERSION_FILES="NEWS circe2/src/circe2.nw" SCRIPTS_FILES="scripts/Makefile.am scripts/whizard-config.in scripts/whizard-setup.csh.in scripts/whizard-setup.sh.in" -SHARE_FILES="share/Makefile.am share/doc/Makefile.am share/doc/custom.hva share/examples/NLO_eettbar_GoSam.sin share/examples/NLO_eettbar_OpenLoops.sin share/examples/HERA_DIS.sin share/examples/LEP_cc10.sin share/examples/LEP_higgs.sin share/examples/W-endpoint.sin share/examples/Z-lineshape.sin share/examples/Zprime.sin share/examples/casc_dec.sin share/examples/circe1.sin share/examples/eeww_polarized.sin share/examples/DrellYanMatchingP.sin share/examples/DrellYanMatchingW.sin share/examples/DrellYanNoMatchingP.sin share/examples/DrellYanNoMatchingW.sin share/examples/EEMatching2P.sin share/examples/EEMatching2W.sin share/examples/EEMatching3P.sin share/examples/EEMatching3W.sin share/examples/EEMatching4P.sin share/examples/EEMatching4W.sin share/examples/EEMatching5P.sin share/examples/EEMatching5W.sin share/examples/EENoMatchingP.sin share/examples/EENoMatchingW.sin share/examples/LHC_VBS_likesign.sin share/tests/Makefile.am share/interfaces/Makefile.am" -SRC_FILES="src/Makefile.am src/feynmf/Makefile.am src/hepmc/Makefile.am src/hepmc/HepMCWrap_dummy.f90 src/lcio/Makefile.am src/lcio/LCIOWrap_dummy.f90 src/tauola/Makefile.am src/lhapdf/Makefile.am src/lhapdf/lhapdf.f90 src/lhapdf5/Makefile.am src/pdf_builtin/Makefile.am src/pdf_builtin/pdf_builtin.f90 src/qed_pdf/Makefile.am src/qed_pdf/qed_pdf.nw src/fastjet/Makefile.am src/fastjet/cpp_strings.f90 src/fastjet/fastjet.f90 src/fastjet/Makefile.am src/hoppet/Makefile.am src/hoppet/hoppet.f90 pythia6/Makefile.am tauola/Makefile.am mcfio/Makefile.am stdhep/Makefile.am src/noweb-frame/Makefile.am src/noweb-frame/whizard-prelude.nw src/noweb-frame/whizard-postlude.nw src/utilities/Makefile.am src/matrix_elements/Makefile.am src/matrix_elements/matrix_elements.nw src/mci/Makefile.am src/vegas/Makefile.am src/vegas/vegas.nw src/mci/mci.nw src/utilities/utilities.nw src/testing/Makefile.am src/testing/testing.nw src/system/Makefile.am src/system/system.nw src/system/system_dependencies.f90.in src/system/debug_master.f90.in src/combinatorics/Makefile.am src/combinatorics/combinatorics.nw src/parsing/Makefile.am src/parsing/parsing.nw src/particles/Makefile.am src/particles/particles.nw src/phase_space/Makefile.am src/phase_space/phase_space.nw src/physics/Makefile.am src/physics/physics.nw src/beams/Makefile.am src/beams/beams.nw src/qft/Makefile.am src/qft/qft.nw src/rng/Makefile.am src/rng/rng.nw src/types/Makefile.am src/types/types.nw src/whizard-core/Makefile.am src/whizard-core/whizard.nw src/pythia8/Makefile.am src/shower/Makefile.am src/shower/shower.nw src/muli/Makefile.am src/muli/muli.nw src/model_features/model_features.nw src/model_features/Makefile.am src/me_methods/Makefile.am src/me_methods/me_methods.nw src/gosam/Makefile.am src/gosam/gosam.nw src/fks/Makefile.am src/fks/fks.nw src/expr_base/Makefile.am src/expr_base/expr_base.nw src/events/Makefile.am src/events/events.nw src/blha/Makefile.am src/blha/blha.nw src/variables/Makefile.am src/variables/variables.nw src/xdr/Makefile.am src/xdr/xdr_wo_stdhep.f90 src/looptools/Makefile.am src/process_integration/Makefile.am src/process_integration/process_integration.nw src/matching/Makefile.am src/matching/matching.nw src/openloops/Makefile.am src/openloops/openloops.nw src/recola/Makefile.am src/recola/recola.nw src/transforms/Makefile.am src/transforms/transforms.nw src/threshold/Makefile.am src/threshold/threshold.nw" +SHARE_FILES="share/Makefile.am share/doc/Makefile.am share/doc/custom.hva share/examples/NLO_eettbar_GoSam.sin share/examples/NLO_eettbar_OpenLoops.sin share/examples/HERA_DIS.sin share/examples/LEP_cc10.sin share/examples/LEP_higgs.sin share/examples/W-endpoint.sin share/examples/Z-lineshape.sin share/examples/Zprime.sin share/examples/casc_dec.sin share/examples/circe1.sin share/examples/eeww_polarized.sin share/examples/DrellYanMatchingP.sin share/examples/DrellYanMatchingW.sin share/examples/DrellYanNoMatchingP.sin share/examples/DrellYanNoMatchingW.sin share/examples/EEMatching2P.sin share/examples/EEMatching2W.sin share/examples/EEMatching3P.sin share/examples/EEMatching3W.sin share/examples/EEMatching4P.sin share/examples/EEMatching4W.sin share/examples/EEMatching5P.sin share/examples/EEMatching5W.sin share/examples/EENoMatchingP.sin share/examples/EENoMatchingW.sin share/examples/LHC_VBS_likesign.sin share/tests/Makefile.am" +SRC_FILES="src/Makefile.am src/feynmf/Makefile.am src/hepmc/Makefile.am src/hepmc/HepMCWrap_dummy.f90 src/lcio/Makefile.am src/lcio/LCIOWrap_dummy.f90 src/tauola/Makefile.am src/lhapdf/Makefile.am src/lhapdf/lhapdf.f90 src/lhapdf5/Makefile.am src/pdf_builtin/Makefile.am src/pdf_builtin/pdf_builtin.f90 src/qed_pdf/Makefile.am src/qed_pdf/qed_pdf.nw src/fastjet/Makefile.am src/fastjet/cpp_strings.f90 src/fastjet/fastjet.f90 src/fastjet/Makefile.am src/hoppet/Makefile.am src/hoppet/hoppet.f90 pythia6/Makefile.am tauola/Makefile.am mcfio/Makefile.am stdhep/Makefile.am src/noweb-frame/Makefile.am src/noweb-frame/whizard-prelude.nw src/noweb-frame/whizard-postlude.nw src/utilities/Makefile.am src/matrix_elements/Makefile.am src/matrix_elements/matrix_elements.nw src/mci/Makefile.am src/vegas/Makefile.am src/vegas/vegas.nw src/mci/mci.nw src/utilities/utilities.nw src/testing/Makefile.am src/testing/testing.nw src/system/Makefile.am src/system/system.nw src/system/system_dependencies.f90.in src/system/debug_master.f90.in src/combinatorics/Makefile.am src/combinatorics/combinatorics.nw src/parsing/Makefile.am src/parsing/parsing.nw src/particles/Makefile.am src/particles/particles.nw src/phase_space/Makefile.am src/phase_space/phase_space.nw src/physics/Makefile.am src/physics/physics.nw src/beams/Makefile.am src/beams/beams.nw src/qft/Makefile.am src/qft/qft.nw src/rng/Makefile.am src/rng/rng.nw src/types/Makefile.am src/types/types.nw src/whizard-core/Makefile.am src/whizard-core/whizard.nw src/pythia8/Makefile.am src/shower/Makefile.am src/shower/shower.nw src/muli/Makefile.am src/muli/muli.nw src/model_features/model_features.nw src/model_features/Makefile.am src/me_methods/Makefile.am src/me_methods/me_methods.nw src/gosam/Makefile.am src/gosam/gosam.nw src/fks/Makefile.am src/fks/fks.nw src/expr_base/Makefile.am src/expr_base/expr_base.nw src/events/Makefile.am src/events/events.nw src/blha/Makefile.am src/blha/blha.nw src/variables/Makefile.am src/variables/variables.nw src/xdr/Makefile.am src/xdr/xdr_wo_stdhep.f90 src/looptools/Makefile.am src/process_integration/Makefile.am src/process_integration/process_integration.nw src/matching/Makefile.am src/matching/matching.nw src/openloops/Makefile.am src/openloops/openloops.nw src/recola/Makefile.am src/recola/recola.nw src/transforms/Makefile.am src/transforms/transforms.nw src/threshold/Makefile.am src/threshold/threshold.nw src/api/Makefile.am src/api.api.nw" CIRCE1_FILES="circe1/Makefile.am circe1/share/Makefile.am circe1/share/doc/Makefile.am circe1/src/Makefile.am circe1/src/circe1.nw circe1/minuit/Makefile.am circe1/src/minuit.nw circe1/tools/Makefile.am" CIRCE2_FILES="circe2/Makefile.am circe2/share/Makefile.am circe2/share/doc/Makefile.am circe2/src/Makefile.am circe2/src/Makefile.ocaml circe2/src/circe2.nw circe2/src/Makefile.sources circe2/src/postlude.nw circe2/tests/Makefile.am circe2/src/circe2_tool.ml circe2/src/commands.ml circe2/src/commands.mli circe2/src/diffmap.ml circe2/src/diffmap.mli circe2/src/diffmaps.ml circe2/src/diffmaps.mli circe2/src/division.ml circe2/src/division.mli circe2/src/events.ml circe2/src/events.mli circe2/src/filter.ml circe2/src/filter.mli circe2/src/float.ml circe2/src/float.mli circe2/src/grid.ml circe2/src/grid.mli circe2/src/histogram.mli circe2/src/histogram.ml circe2/src/syntax.ml circe2/src/syntax.mli circe2/src/thoArray.ml circe2/src/thoArray.mli circe2/src/thoMatrix.ml circe2/src/thoMatrix.mli circe2/src/bigarray_module.ml circe2/src/bigarray_library.ml circe2/src/bigarray_compat.mli" SRC_GAMELAN_FILES="src/gamelan/Makefile.am src/gamelan/whizard-gml.in" SRC_BASICS_FILES="src/basics/constants.f90 src/basics/io_units.f90 src/basics/Makefile.am" SRC_MODELS_FILES="src/models/threeshl_bundle/Makefile.am src/models/threeshl_bundle/threeshl_bundle.f90 src/models/threeshl_bundle/threeshl_bundle_lt.f90 src/models/external.Test.f90 src/models/external.Threeshl.f90 src/models/Makefile.am src/models/parameters.THDM.f90 src/models/parameters.GravTest.f90 src/models/parameters.Littlest.f90 src/models/parameters.Littlest_Eta.f90 src/models/parameters.Littlest_Tpar.f90 src/models/parameters.MSSM.f90 src/models/parameters.MSSM_4.f90 src/models/parameters.MSSM_CKM.f90 src/models/parameters.MSSM_Grav.f90 src/models/parameters.MSSM_Hgg.f90 src/models/parameters.NMSSM.f90 src/models/parameters.NMSSM_CKM.f90 src/models/parameters.NMSSM_Hgg.f90 src/models/parameters.PSSSM.f90 src/models/parameters.QCD.f90 src/models/parameters.QED.f90 src/models/parameters.SM.f90 src/models/parameters.SM_CKM.f90 src/models/parameters.SM_ac.f90 src/models/parameters.SM_ac_CKM.f90 src/models/parameters.SM_dim6.f90 src/models/parameters.SM_rx.f90 src/models/parameters.SM_ul.f90 src/models/parameters.NoH_rx.f90 src/models/parameters.AltH.f90 src/models/parameters.SSC.f90 src/models/parameters.SSC_2.f90 src/models/parameters.SSC_AltT.f90 src/models/parameters.SM_top.f90 src/models/parameters.SM_top_anom.f90 src/models/parameters.SM_Higgs.f90 src/models/parameters.SM_Higgs_CKM.f90 src/models/parameters.Simplest.f90 src/models/parameters.Simplest_univ.f90 src/models/parameters.Template.f90 src/models/parameters.HSExt.f90 src/models/parameters.Test.f90 src/models/parameters.Threeshl.f90 src/models/parameters.UED.f90 src/models/parameters.Xdim.f90 src/models/parameters.Zprime.f90 src/models/parameters.WZW.f90" OMEGA_FILES="omega/Makefile.am omega/share/Makefile.am omega/share/doc/Makefile.am omega/src/Makefile.am omega/src/Makefile.ocaml omega/src/Makefile.sources omega/bin/Makefile.am omega/extensions/Makefile.am omega/extensions/people/Makefile.am omega/extensions/people/jr/Makefile.am omega/extensions/people/jr/f90_SAGT.ml omega/extensions/people/jr/f90_SQED.ml omega/extensions/people/jr/f90_WZ.ml omega/extensions/people/tho/Makefile.am omega/extensions/people/tho/f90_O2.ml omega/lib/Makefile.am omega/models/Makefile.am omega/scripts/Makefile.am omega/scripts/omega-config.in omega/tools/Makefile.am omega/tests/parameters_QED.f90 omega/tests/parameters_QCD.f90 omega/tests/parameters_SM.f90 omega/tests/parameters_SM_CKM.f90 omega/tests/parameters_SM_Higgs.f90 omega/tests/parameters_SM_from_UFO.f90 omega/tests/parameters_SYM.f90 omega/tests/parameters_SM_top_anom.f90 omega/tests/parameters_HSExt.f90 omega/tests/parameters_THDM.f90 omega/tests/parameters_THDM_CKM.f90 omega/tests/parameters_Zprime.f90 omega/tests/test_openmp.f90 omega/tests/tao_random_numbers.f90 omega/tests/test_qed_eemm.f90 omega/tests/Makefile.am omega/tests/benchmark.f90 omega/tests/color_test_lib.f90 omega/tests/omega_interface.f90 omega/tests/ward_lib.f90 omega/tests/omega_unit.ml omega/tests/compare_lib.f90 omega/tests/compare_lib_recola.f90 omega/tests/keystones_omegalib_generate.ml omega/tests/keystones_UFO_generate.ml omega/tests/keystones_omegalib_bispinors_generate.ml omega/tests/keystones_UFO_bispinors_generate.ml omega/tests/keystones.ml omega/tests/keystones.mli omega/tests/keystones_tools.f90 omega/tests/fermi_lib.f90 omega/tests/parameters_SM_Higgs_recola.f90 omega/tests/parameters_MSSM.f90 omega/tests/keystones.mli" OMEGA_SRC_FILES="omega/src/algebra.ml omega/src/algebra.mli omega/src/bundle.ml omega/src/bundle.mli omega/src/cache.ml omega/src/cache.mli omega/src/cascade.ml omega/src/cascade.mli omega/src/cascade_lexer.mll omega/src/cascade_parser.mly omega/src/cascade_syntax.ml omega/src/cascade_syntax.mli omega/src/charges.ml omega/src/charges.mli omega/src/color.ml omega/src/color.mli omega/src/colorize.ml omega/src/colorize.mli omega/src/combinatorics.ml omega/src/combinatorics.mli omega/src/complex.ml omega/src/complex.mli omega/src/config.ml.in omega/src/config.mli omega/src/count.ml omega/src/coupling.mli omega/src/DAG.ml omega/src/DAG.mli omega/src/fusion.ml omega/src/fusion_vintage.ml omega/src/fusion.mli omega/src/fusion_vintage.mli omega/src/linalg.ml omega/src/linalg.mli omega/src/model.mli omega/src/modellib_BSM.ml omega/src/modellib_NoH.ml omega/src/modellib_NoH.mli omega/src/modellib_BSM.mli omega/src/modellib_MSSM.ml omega/src/modellib_MSSM.mli omega/src/modellib_NMSSM.ml omega/src/modellib_NMSSM.mli omega/src/modellib_PSSSM.ml omega/src/modellib_PSSSM.mli omega/src/modellib_SM.ml omega/src/modellib_SM.mli omega/src/modellib_Zprime.mli omega/src/modellib_Zprime.ml omega/src/modellib_WZW.mli omega/src/modellib_WZW.ml omega/src/UFO.ml omega/src/UFO.mli omega/src/UFO_targets.ml omega/src/UFO_Lorentz.ml omega/src/UFO_syntax.ml omega/src/UFO_syntax.mli omega/src/UFOx.ml omega/src/UFOx.mli omega/src/UFO_lexer.mll omega/src/UFO_parser.mly omega/src/UFOx_syntax.ml omega/src/UFOx_syntax.mli omega/src/UFOx_lexer.mll omega/src/UFOx_parser.mly omega/src/omega_UFO.ml omega/src/modeltools.ml omega/src/modeltools.mli omega/src/momentum.ml omega/src/momentum.mli omega/src/OVM.ml omega/src/OVM.mli omega/src/ogiga.ml omega/src/omega.ml omega/src/omega.mli omega/src/omega_THDM.ml omega/src/omega_THDM_VM.ml omega/src/omega_THDM_CKM.ml omega/src/omega_THDM_CKM_VM.ml omega/src/omega_CQED.ml omega/src/omega_GravTest.ml omega/src/omega_Littlest.ml omega/src/omega_Littlest_Eta.ml omega/src/omega_Littlest_Tpar.ml omega/src/omega_Littlest_Zprime.ml omega/src/omega_MSSM.ml omega/src/omega_MSSM_CKM.ml omega/src/omega_MSSM_Grav.ml omega/src/omega_MSSM_Hgg.ml omega/src/omega_NMSSM.ml omega/src/omega_NMSSM_CKM.ml omega/src/omega_NMSSM_Hgg.ml omega/src/omega_PSSSM.ml omega/src/omega_Phi3.ml omega/src/omega_Phi3h.ml omega/src/omega_Phi4.ml omega/src/omega_Phi4h.ml omega/src/omega_QCD.ml omega/src/omega_QCD_VM.ml omega/src/omega_QED.ml omega/src/omega_QED_VM.ml omega/src/omega_SM.ml omega/src/omega_SM_VM.ml omega/src/omega_SM_CKM.ml omega/src/omega_SM_CKM_VM.ml omega/src/ovm_SM.ml omega/src/process.ml omega/src/process.mli omega/src/thoFilename.ml omega/src/thoFilename.mli omega/src/omega_SM_Higgs.ml omega/src/omega_SM_Higgs_CKM.ml omega/src/omega_SM_Higgs_VM.ml omega/src/omega_SM_Higgs_CKM_VM.ml omega/src/omega_SM_Rxi.ml omega/src/omega_SM_ac.ml omega/src/omega_SM_ac_CKM.ml omega/src/omega_SM_clones.ml omega/src/omega_SM_rx.ml omega/src/omega_SM_ul.ml omega/src/omega_NoH_rx.ml omega/src/omega_AltH.ml omega/src/omega_SSC.ml omega/src/omega_SSC_2.ml omega/src/omega_SM_top.ml omega/src/omega_SM_top_anom.ml omega/src/omega_SMh.ml omega/src/omega_SYM.ml omega/src/omega_Simplest.ml omega/src/omega_Simplest_univ.ml omega/src/omega_Template.ml omega/src/omega_HSExt.ml omega/src/omega_HSExt_VM.ml omega/src/omega_Threeshl.ml omega/src/omega_Threeshl_nohf.ml omega/src/omega_UED.ml omega/src/omega_Xdim.ml omega/src/omega_Zprime.ml omega/src/omega_Zprime_VM.ml omega/src/omega_logo.mp omega/src/omega_parameters_tool.nw omega/src/omegalib.nw omega/src/options.ml omega/src/options.mli omega/src/partition.ml omega/src/partition.mli omega/src/phasespace.ml omega/src/phasespace.mli omega/src/pmap.ml omega/src/pmap.mli omega/src/powSet.ml omega/src/powSet.mli omega/src/product.ml omega/src/product.mli omega/src/progress.ml omega/src/progress.mli omega/src/permutation.ml omega/src/permutation.mli omega/src/target.mli omega/src/targets.ml omega/src/targets.mli omega/src/targets_Kmatrix.ml omega/src/targets_Kmatrix.mli omega/src/test_linalg.ml omega/src/thoArray.ml omega/src/thoFilename.ml omega/src/thoArray.mli omega/src/thoGButton.ml omega/src/thoGButton.mli omega/src/thoGDraw.ml omega/src/thoGDraw.mli omega/src/thoGMenu.ml omega/src/thoGMenu.mli omega/src/thoGWindow.ml omega/src/thoGWindow.mli omega/src/thoList.ml omega/src/thoList.mli omega/src/thoString.ml omega/src/thoString.mli omega/src/topology.ml omega/src/topology.mli omega/src/tree.ml omega/src/tree.mli omega/src/tree2.ml omega/src/tree2.mli omega/src/trie.ml omega/src/trie.mli omega/src/tuple.ml omega/src/tuple.mli omega/src/vertex.ml omega/src/vertex.mli omega/src/vertex_lexer.mll omega/src/vertex_parser.mly omega/src/vertex_syntax.ml omega/src/vertex_syntax.mli omega/src/whizard.ml omega/src/whizard.mli omega/src/whizard_tool.ml omega/src/constants.f90 omega/src/sets.mli omega/src/sets.ml omega/src/UFO_tools.ml omega/src/UFO_tools.mli omega/src/fortran_unit.ml omega/src/format_Fortran.ml omega/src/format_Fortran.mli omega/src/omega_UFO_Majorana.ml omega/src/omega_UFO_Dirac.ml" SRC_PDF_BUILTIN_FILES="src/pdf_builtin/pdf_builtin.f90" VAMP_FILES="vamp/Makefile.am vamp/share/Makefile.am vamp/share/doc/Makefile.am vamp/src/Makefile.am vamp/tests/Makefile.am" FILES="$MAIN_FILES $CONFIGURE_FILES $VERSION_FILES $SHARE_FILES $OMEGA_FILES $SCRIPTS_FILES $SRC_FILES $CIRCE1_FILES $CIRCE2_FILES $SRC_GAMELAN_FILES $SRC_PDF_BUILTIN_FILES $VAMP_FILES $SRC_BASICS_FILES $SRC_MODELS_FILES $OMEGA_SRC_FILES" for f in $FILES; do sed -e "s/$OLD_YEAR/$NEW_YEAR/g" -e "s/$OLD_YEAR2/$NEW_YEAR2/g" $f > $f.tmp; cp -f $f.tmp $f; rm -f $f.tmp; done CHANGE_FILES="$CONFIGURE_FILES $VERSION_FILES" for f in $CHANGE_FILES; do sed -e "s/$OLD_DATE/$NEW_DATE/g" -e "s/$OLD_VERSION/$NEW_VERSION/g" -e "s/$OLD_STATUS/$NEW_STATUS/g" $f > $f.tmp; cp -f $f.tmp $f; rm -f $f.tmp; done Index: trunk/ChangeLog =================================================================== --- trunk/ChangeLog (revision 8428) +++ trunk/ChangeLog (revision 8429) @@ -1,2072 +1,2078 @@ ChangeLog -- Summary of changes to the WHIZARD package Use svn log to see detailed changes. Version 3.0.0_alpha+ +2020-08-07 + New WHIZARD API: WHIZARD can be externally linked as a + library, added examples for Fortran, C, C++ programs + +################################################################## + 2020-07-08 RELEASE: version 2.8.4 2020-07-07 Bug fix: steering of UFO Majorana models from WHIZARD ################################################################## 2020-07-06 Combined integration also for hadron collider processes at NLO 2020-07-05 Bug fix: correctly steer e+e- FastJet clustering algorithms Major revision of NLO differential distributions and events: - Correctly assign quantum numbers to NLO fixed-order events - Correctly assign weights to NLO fixed-order events for combined simulation - Cut all NLO fixed-order subevents in event groups individually - Only allow "sigma" normalization for NLO fixed-order events - Use correct PDF setup for NLO counter events - Several technical fixes and updates of the NLO testsuite ################################################################## 2020-07-03 RELEASE: version 2.8.3 2020-07-02 Feature-complete UFO implementation for Majorana fermions 2020-06-22 Running width scheme supported for O'Mega matrix elements 2020-06-20 Adding H-s-s coupling to SM_Higgs(_CKM) models 2020-06-17 Completion of ILC 2->6 fermion extended test suite 2020-06-15 Bug fix: PYTHIA6/Tauola, correctly assign tau spins for stau decays 2020-06-09 Bug fix: correctly update calls for additional VAMP/2 iterations Bug fix: correct assignment for tau spins from PYTHIA6 interface 2020-06-04 Bug fix: cascades2 tree merge with empty subtree(s) 2020-05-31 Switch $epa_mode for different EPA implementations 2020-05-26 Bug fix: spin information transferred for resonance histories 2020-04-13 HepMC: correct weighted events for non-xsec event normalizations 2020-04-04 Improved HepMC3 interface: HepMC3 Root/RootTree interface 2020-03-24 ISR: Fix on-shell kinematics for events with ?isr_handler=true (set ?isr_handler_keep_mass=false for old behavior) 2020-03-11 Beam masses are correctly passed to hard matrix element for CIRCE2 EPA with polarized beams: double-counting corrected ################################################################## 2020-03-03 RELEASE: version 3.0.0_alpha 2020-02-25 Bug fix: Scale and alphas can be retrieved from internal event format to external formats 2020-02-17 Bug fix: ?keep_failed_events now forces output of actual event data Bug fix: particle-set reconstruction (rescanning events w/o radiation) 2020-01-28 Bug fix for left-over EPA parameter epa_e_max (replaced by epa_q_max) 2020-01-23 Bug fix for real components of NLO QCD 2->1 processes 2020-01-22 Bug fix: correct random number sequencing during parallel MPI event generation with rng_stream 2020-01-21 Consistent distribution of events during parallel MPI event generation 2020-01-20 Bug fix for configure setup for automake v1.16+ 2020-01-18 General SLHA parameter files for UFO models supported 2020-01-08 Bug fix: correctly register RECOLA processes with flavor sums 2019-12-19 Support for UFO customized propagators O'Mega unit tests for fermion-number violating interactions 2019-12-10 For distribution building: check for graphviz/dot version 2.40 or newer 2019-11-21 Bug fix: alternate setups now work correctly Infrastructure for accessing alpha_QED event-by-event Guard against tiny numbers that break ASCII event output Enable inverse hyperbolic functions as SINDARIN observables Remove old compiler bug workarounds 2019-11-20 Allow quoted -e argument, implemented -f option 2019-11-19 Bug fix: resonance histories now work also with UFO models Fix in numerical precision of ASCII VAMP2 grids 2019-11-06 Add squared matrix elements to the LCIO event header 2019-11-05 Do not include RNG state in MD5 sum for CIRCE1/2 2019-11-04 Full CIRCE2 ILC 250 and 500 GeV beam spectra added Minor update on LCIO event header information 2019-10-30 NLO QCD for final states completed When using Openloops, v2.1.1+ mandatory 2019-10-25 Binary grid files for VAMP2 integrator ################################################################## 2019-10-24 RELEASE: version 2.8.2 2019-10-20 Bug fix for HepMC linker flags 2019-10-19 Support for spin-2 particles from UFO files 2019-09-27 LCIO event format allows rescan and alternate weights 2019-09-24 Compatibility fix for OCaml v4.08.0+ ################################################################## 2019-09-21 RELEASE: version 2.8.1 2019-09-19 Carriage return characters in UFO models can be parsed Mathematica symbols in UFO models possible Unused/undefined parameters in UFO models handled 2019-09-13 New extended NLO test suite for ee and pp processes 2019-09-09 Photon isolation (separation of perturbative and fragmentation part a la Frixione) 2019-09-05 Major progress on NLO QCD for hadron collisions: - correctly assign flavor structures for alpha regions - fix crossing of particles for initial state splittings - correct assignment for PDF factors for real subtractions - fix kinematics for collinear splittings - bug fix for integrated virtual subtraction terms 2019-09-03 b and c jet selection in cuts and analysis 2019-08-27 Support for Intel MPI 2019-08-20 Complete (preliminary) HepMC3 support (incl. backwards HepMC2 write/read mode) 2019-08-08 Bug fix: handle carriage returns in UFO files (non-Unix OS) ################################################################## 2019-08-07 RELEASE: version 2.8.0 2019-07-31 Complete WHIZARD UFO interface: - general Lorentz structures - matrix element support for general color factors - missing features: Majorana fermions and SLHA 2019-07-20 Make WHIZARD compatible with OCaml 4.08.0+ 2019-07-19 Fix version testing for LHAPDF 6.2.3 and newer Minimal required OCaml version is now 4.02.3. 2019-04-18 Correctly generate ordered FKS tuples for alpha regions from all possible underlying Born processes 2019-04-08 Extended O'Mega/Recola matrix element test suite 2019-03-29 Correct identical particle symmetry factors for FKS subtraction 2019-03-28 Correct assertion of spin-correlated matrix elements for hadron collisions 2019-03-27 Bug fix for cut-off parameter delta_i for collinear plus/minus regions ################################################################## 2019-03-27 RELEASE: version 2.7.1 2019-02-19 Further infrastructure for HepMC3 interface (v3.01.00) 2019-02-07 Explicit configure option for using debugging options Bug fix for performance by removing unnecessary debug operations 2019-01-29 Bug fix for DGLAP remnants with cut-off parameter delta_i 2019-01-24 Radiative decay neu2 -> neu1 A added to MSSM_Hgg model ################################################################## 2019-01-21 RELEASE: version 2.7.0 2018-12-18 Support RECOLA for integrated und unintegrated subtractions 2018-12-11 FCNC top-up sector in model SM_top_anom 2018-12-05 Use libtirpc instead of SunRPC on Arch Linux etc. 2018-11-30 Display rescaling factor for weighted event samples with cuts 2018-11-29 Reintroduce check against different masses in flavor sums Bug fix for wrong couplings in the Littlest Higgs model(s) 2018-11-22 Bug fix for rescanning events with beam structure 2018-11-09 Major refactoring of internal process data 2018-11-02 PYTHIA8 interface 2018-10-29 Flat phase space parametrization with RAMBO (on diet) implemented 2018-10-17 Revise extended test suite 2018-09-27 Process container for RECOLA processes 2018-09-15 Fixes by M. Berggren for PYTHIA6 interface 2018-09-14 First fixes after HepForge modernization ################################################################## 2018-08-23 RELEASE: version 2.6.4 2018-08-09 Infrastructure to check colored subevents 2018-07-10 Infrastructure for running WHIZARD in batch mode 2018-07-04 MPI available from distribution tarball 2018-06-03 Support Intel Fortran Compiler under MAC OS X 2018-05-07 FKS slicing parameter delta_i (initial state) implementend 2018-05-03 Refactor structure function assignment for NLO 2018-05-02 FKS slicing parameter xi_cut, delta_0 implemented 2018-04-20 Workspace subdirectory for process integration (grid/phs files) Packing/unpacking of files at job end/start Exporting integration results from scan loops 2018-04-13 Extended QCD NLO test suite 2018-04-09 Bug fix for Higgs Singlet Extension model 2018-04-06 Workspace subdirectory for process generation and compilation --job-id option for creating job-specific names 2018-03-20 Bug fix for color flow matching in hadron collisions with identical initial state quarks 2018-03-08 Structure functions quantum numbers correctly assigned for NLO 2018-02-24 Configure setup includes 'pgfortran' and 'flang' 2018-02-21 Include spin-correlated matrix elements in interactions 2018-02-15 Separate module for QED ISR structure functions ################################################################## 2018-02-10 RELEASE: version 2.6.3 2018-02-08 Improvements in memory management for PS generation 2018-01-31 Partial refactoring: quantum number assigment NLO Initial-state QCD splittings for hadron collisions 2018-01-25 Bug fix for weighted events with VAMP2 2018-01-17 Generalized interface for Recola versions 1.3+ and 2.1+ 2018-01-15 Channel equivalences also for VAMP2 integrator 2018-01-12 Fix for OCaml compiler 4.06 (and newer) 2017-12-19 RECOLA matrix elements with flavor sums can be integrated 2017-12-18 Bug fix for segmentation fault in empty resonance histories 2017-12-16 Fixing a bug in PYTHIA6 PYHEPC routine by omitting CMShowers from transferral between PYTHIA and WHIZARD event records 2017-12-15 Event index for multiple processes in event file correct ################################################################## 2017-12-13 RELEASE: version 2.6.2 2017-12-07 User can set offset in event numbers 2017-11-29 Possibility to have more than one RECOLA process in one file 2017-11-23 Transversal/mixed (and unitarized) dim-8 operators 2017-11-16 epa_q_max replaces epa_e_max (trivial factor 2) 2017-11-15 O'Mega matrix element compilation silent now 2017-11-14 Complete expanded P-wave form factor for top threshold 2017-11-10 Incoming particles can be accessed in SINDARIN 2017-11-08 Improved handling of resonance insertion, additional parameters 2017-11-04 Added Higgs-electron coupling (SM_Higgs) ################################################################## 2017-11-03 RELEASE: version 2.6.1 2017-10-20 More than 5 NLO components possible at same time 2017-10-19 Gaussian cutoff for shower resonance matching 2017-10-12 Alternative (more efficient) method to generate phase space file 2017-10-11 Bug fix for shower resonance histories for processes with multiple components 2017-09-25 Bug fix for process libraries in shower resonance histories 2017-09-21 Correctly generate pT distribution for EPA remnants 2017-09-20 Set branching ratios for unstable particles also by hand 2017-09-14 Correctly generate pT distribution for ISR photons ################################################################## 2017-09-08 RELEASE: version 2.6.0 2017-09-05 Bug fix for initial state NLO QCD flavor structures Real and virtual NLO QCD hadron collider processes work with internal interactions 2017-09-04 Fully validated MPI integration and event generation 2017-09-01 Resonance histories for shower: full support Bug fix in O'Mega model constraints O'Mega allows to output a parsable form of the DAG 2017-08-24 Resonance histories in events for transferral to parton shower (e.g. in ee -> jjjj) 2017-08-01 Alpha version of HepMC v3 interface (not yet really functional) 2017-07-31 Beta version for RECOLA OLP support 2017-07-06 Radiation generator fix for LHC processes 2017-06-30 Fix bug for NLO with structure functions and/or polarization 2017-06-23 Collinear limit for QED corrections works 2017-06-17 POWHEG grids generated already during integration 2017-06-12 Soft limit for QED corrections works 2017-05-16 Beta version of full MPI parallelization (VAMP2) Check consistency of POWHEG grid files Logfile config-summary.log for configure summary 2017-05-12 Allow polarization in top threshold 2017-05-09 Minimal demand automake 1.12.2 Silent rules for make procedures 2017-05-07 Major fix for POWHEG damping Correctly initialize FKS ISR phasespace ################################################################## 2017-05-06 RELEASE: version 2.5.0 2017-05-05 Full UFO support (SM-like models) Fixed-beam ISR FKS phase space 2017-04-26 QED splittings in radiation generator 2017-04-10 Retire deprecated O'Mega vertex cache files ################################################################## 2017-03-24 RELEASE: version 2.4.1 2017-03-16 Distinguish resonance charge in phase space channels Keep track of resonance histories in phase space Complex mass scheme default for OpenLoops amplitudes 2017-03-13 Fix helicities for polarized OpenLoops calculations 2017-03-09 Possibility to advance RNG state in rng_stream 2017-03-04 General setup for partitioning real emission phase space 2017-03-06 Bug fix on rescan command for converting event files 2017-02-27 Alternative multi-channel VEGAS implementation VAMP2: serial backbone for MPI setup Smoothstep top threshold matching 2017-02-25 Single-beam structure function with s-channel mapping supported Safeguard against invalid process libraries 2017-02-16 Radiation generator for photon emission 2017-02-10 Fixes for NLO QCD processes (color correlations) 2017-01-16 LCIO variable takes precedence over LCIO_DIR 2017-01-13 Alternative random number generator rng_stream (cf. L'Ecuyer et al.) 2017-01-01 Fix for multi-flavor BLHA tree matrix elements 2016-12-31 Grid path option for VAMP grids 2016-12-28 Alpha version of Recola OLP support 2016-12-27 Dalitz plots for FKS phase space 2016-12-14 NLO multi-flavor events possible 2016-12-09 LCIO event header information added 2016-12-02 Alpha version of RECOLA interface Bug fix for generator status in LCIO ################################################################## 2016-11-28 RELEASE: version 2.4.0 2016-11-24 Bug fix for OpenLoops interface: EW scheme is set by WHIZARD Bug fixes for top threshold implementation 2016-11-11 Refactoring of dispatching 2016-10-18 Bug fix for LCIO output 2016-10-10 First implementation for collinear soft terms 2016-10-06 First full WHIZARD models from UFO files 2016-10-05 WHIZARD does not support legacy gcc 4.7.4 any longer 2016-09-30 Major refactoring of process core and NLO components 2016-09-23 WHIZARD homogeneous entity: discarding subconfigures for CIRCE1/2, O'Mega, VAMP subpackages; these are reconstructable by script projectors 2016-09-06 Introduce main configure summary 2016-08-26 Fix memory leak in event generation ################################################################## 2016-08-25 RELEASE: version 2.3.1 2016-08-19 Bug fix for EW-scheme dependence of gluino propagators 2016-08-01 Beta version of complex mass scheme support 2016-07-26 Fix bug in POWHEG damping for the matching ################################################################## 2016-07-21 RELEASE: version 2.3.0 2016-07-20 UFO file support (alpha version) in O'Mega 2016-07-13 New (more) stable of WHIZARD GUI Support for EW schemes for OpenLoops Factorized NLO top decays for threshold model 2016-06-15 Passing factorization scale to PYTHIA6 Adding charge and neutral observables 2016-06-14 Correcting angular distribution/tweaked kinematics in non-collinear structure functions splittings 2016-05-10 Include (Fortran) TAUOLA/PHOTOS for tau decays via PYTHIA6 (backwards validation of LC CDR/TDR samples) 2016-04-27 Within OpenLoops virtuals: support for Collier library 2016-04-25 O'Mega vertex tables only loaded at first usage 2016-04-21 New CJ15 PDF parameterizations added 2016-04-21 Support for hadron collisions at NLO QCD 2016-04-05 Support for different (parameter) schemes in model files 2016-03-31 Correct transferral of lifetime/vertex from PYTHIA/TAUOLA into the event record 2016-03-21 New internal implementation of polarization via Bloch vectors, remove pointer constructions 2016-03-13 Extension of cascade syntax for processes: exclude propagators/vertices etc. possible 2016-02-24 Full support for OpenLoops QCD NLO matrix elements, inclusion in test suite 2016-02-12 Substantial progress on QCD NLO support 2016-02-02 Automated resonance mapping for FKS subtraction 2015-12-17 New BSM model WZW for diphoton resonances ################################################################## 2015-11-22 RELEASE: version 2.2.8 2015-11-21 Bug fix for fixed-order NLO events 2015-11-20 Anomalous FCNC top-charm vertices 2015-11-19 StdHEP output via HEPEVT/HEPEV4 supported 2015-11-18 Full set of electroweak dim-6 operators included 2015-10-22 Polarized one-loop amplitudes supported 2015-10-21 Fixes for event formats for showered events 2015-10-14 Callback mechanism for event output 2015-09-22 Bypass matrix elements in pure event sample rescans StdHep frozen final version v5.06.01 included internally 2015-09-21 configure option --with-precision to demand 64bit, 80bit, or 128bit Fortran and bind C precision types 2015-09-07 More extensive tests of NLO infrastructure and POWHEG matching 2015-09-01 NLO decay infrastructure User-defined squared matrix elements Inclusive FastJet algorithm plugin Numerical improvement for small boosts ################################################################## 2015-08-11 RELEASE: version 2.2.7 2015-08-10 Infrastructure for damped POWHEG Massive emitters in POWHEG Born matrix elements via BLHA GoSam filters via SINDARIN Minor running coupling bug fixes Fixed-order NLO events 2015-08-06 CT14 PDFs included (LO, NLO, NNLL) 2015-07-07 Revalidation of ILC WHIZARD-PYTHIA event chain Extended test suite for showered events Alpha version of massive FSR for POWHEG 2015-06-09 Fix memory leak in interaction for long cascades Catch mismatch between beam definition and CIRCE2 spectrum 2015-06-08 Automated POWHEG matching: beta version Infrastructure for GKS matching Alpha version of fixed-order NLO events CIRCE2 polarization averaged spectra with explicitly polarized beams 2015-05-12 Abstract matching type: OO structure for matching/merging 2015-05-07 Bug fix in event record WHIZARD-PYTHIA6 transferral Gaussian beam spectra for lepton colliders ################################################################## 2015-05-02 RELEASE: version 2.2.6 2015-05-01 Models for (unitarized) tensor resonances in VBS 2015-04-28 Bug fix in channel weights for event generation. 2015-04-18 Improved event record transfer WHIZARD/PYTHIA6 2015-03-19 POWHEG matching: alpha version ################################################################## 2015-02-27 RELEASE: version 2.2.5 2015-02-26 Abstract types for quantum numbers 2015-02-25 Read-in of StdHEP events, self-tests 2015-02-22 Bug fix for mother-daughter relations in showered/hadronized events 2015-02-20 Projection on polarization in intermediate states 2015-02-13 Correct treatment of beam remnants in event formats (also LC remnants) ################################################################## 2015-02-06 RELEASE: version 2.2.4 2015-02-06 Bug fix in event output 2015-02-05 LCIO event format supported 2015-01-30 Including state matrices in WHIZARD's internal IO Versioning for WHIZARD's internal IO Libtool update from 2.4.3 to 2.4.5 LCIO event output (beta version) 2015-01-27 Progress on NLO integration Fixing a bug for multiple processes in a single event file when using beam event files 2015-01-19 Bug fix for spin correlations evaluated in the rest frame of the mother particle 2015-01-17 Regression fix for statically linked processes from SARAH and FeynRules 2015-01-10 NLO: massive FKS emitters supported (experimental) 2015-01-06 MMHT2014 PDF sets included 2015-01-05 Handling mass degeneracies in auto_decays 2014-12-19 Fixing bug in rescan of event files ################################################################## 2014-11-30 RELEASE: version 2.2.3 2014-11-29 Beta version of LO continuum/NLL-threshold matched top threshold model for e+e- physics 2014-11-28 More internal refactoring: disentanglement of module dependencies 2014-11-21 OVM: O'Mega Virtual Machine, bytecode instructions instead of compiled Fortran code 2014-11-01 Higgs Singlet extension model included 2014-10-18 Internal restructuring of code; half-way WHIZARD main code file disassembled 2014-07-09 Alpha version of NLO infrastructure ################################################################## 2014-07-06 RELEASE: version 2.2.2 2014-07-05 CIRCE2: correlated LC beam spectra and GuineaPig Interface to LC machine parameters 2014-07-01 Reading LHEF for decayed/factorized/showered/ hadronized events 2014-06-25 Configure support for GoSAM/Ninja/Form/QGraf 2014-06-22 LHAPDF6 interface 2014-06-18 Module for automatic generation of radiation and loop infrastructure code 2014-06-11 Improved internal directory structure ################################################################## 2014-06-03 RELEASE: version 2.2.1 2014-05-30 Extensions of internal PDG arrays 2014-05-26 FastJet interface 2014-05-24 CJ12 PDFs included 2014-05-20 Regression fix for external models (via SARAH or FeynRules) ################################################################## 2014-05-18 RELEASE: version 2.2.0 2014-04-11 Multiple components: inclusive process definitions, syntax: process A + B + ... 2014-03-13 Improved PS mappings for e+e- ISR ILC TDR and CLIC spectra included in CIRCE1 2014-02-23 New models: AltH w\ Higgs for exclusion purposes, SM_rx for Dim 6-/Dim-8 operators, SSC for general strong interactions (w/ Higgs), and NoH_rx (w\ Higgs) 2014-02-14 Improved s-channel mapping, new on-shell production mapping (e.g. Drell-Yan) 2014-02-03 PRE-RELEASE: version 2.2.0_beta 2014-01-26 O'Mega: Feynman diagram generation possible (again) 2013-12-16 HOPPET interface for b parton matching 2013-11-15 PRE-RELEASE: version 2.2.0_alpha-4 2013-10-27 LHEF standards 1.0/2.0/3.0 implemented 2013-10-15 PRE-RELEASE: version 2.2.0_alpha-3 2013-10-02 PRE-RELEASE: version 2.2.0_alpha-2 2013-09-25 PRE-RELEASE: version 2.2.0_alpha-1 2013-09-12 PRE-RELEASE: version 2.2.0_alpha 2013-09-03 General 2HDM implemented 2013-08-18 Rescanning/recalculating events 2013-06-07 Reconstruction of complete event from 4-momenta possible 2013-05-06 Process library stacks 2013-05-02 Process stacks 2013-04-29 Single-particle phase space module 2013-04-26 Abstract interface for random number generator 2013-04-24 More object-orientation on modules Midpoint-rule integrator 2013-04-05 Object-oriented integration and event generation 2013-03-12 Processes recasted object-oriented: MEs, scales, structure functions First infrastructure for general Lorentz structures 2013-01-17 Object-orientated reworking of library and process core, more variable internal structure, unit tests 2012-12-14 Update Pythia version to 6.4.27 2012-12-04 Fix the phase in HAZ vertices 2012-11-21 First O'Mega unit tests, some infrastructure 2012-11-13 Bug fix in anom. HVV Lorentz structures ################################################################## 2012-09-18 RELEASE: version 2.1.1 2012-09-11 Model MSSM_Hgg with Hgg and HAA vertices 2012-09-10 First version of implementation of multiple interactions in WHIZARD 2012-09-05 Infrastructure for internal CKKW matching 2012-09-02 C, C++, Python API 2012-07-19 Fixing particle numbering in HepMC format ################################################################## 2012-06-15 RELEASE: version 2.1.0 2012-06-14 Analytical and kT-ordered shower officially released PYTHIA interface officially released 2012-05-09 Intrisince PDFs can be used for showering 2012-05-04 Anomalous Higgs couplings a la hep-ph/9902321 ################################################################## 2012-03-19 RELEASE: version 2.0.7 2012-03-15 Run IDs are available now More event variables in analysis Modified raw event format (compatibility mode exists) 2012-03-12 Bug fix in decay-integration order MLM matching steered completely internally now 2012-03-09 Special phase space mapping for narrow resonances decaying to 4-particle final states with far off-shell intermediate states Running alphas from PDF collaborations with builtin PDFs 2012-02-16 Bug fix in cascades decay infrastructure 2012-02-04 WHIZARD documentation compatible with TeXLive 2011 2012-02-01 Bug fix in FeynRules interface with --prefix flag 2012-01-29 Bug fix with name clash of O'Mega variable names 2012-01-27 Update internal PYTHIA to version 6.4.26 Bug fix in LHEF output 2012-01-21 Catching stricter automake 1.11.2 rules 2011-12-23 Bug fix in decay cascade setup 2011-12-20 Bug fix in helicity selection rules 2011-12-16 Accuracy goal reimplemented 2011-12-14 WHIZARD compatible with TeXLive 2011 2011-12-09 Option --user-target added ################################################################## 2011-12-07 RELEASE: version 2.0.6 2011-12-07 Bug fixes in SM_top_anom Added missing entries to HepMC format 2011-12-06 Allow to pass options to O'Mega Bug fix for HEPEVT block for showered/hadronized events 2011-12-01 Reenabled user plug-in for external code for cuts, structure functions, routines etc. 2011-11-29 Changed model SM_Higgs for Higgs phenomenology 2011-11-25 Supporting a Y, (B-L) Z' model 2011-11-23 Make WHIZARD compatible for MAC OS X Lion/XCode 4 2011-09-25 WHIZARD paper published: Eur.Phys.J. C71 (2011) 1742 2011-08-16 Model SM_QCD: QCD with one EW insertion 2011-07-19 Explicit output channel for dvips avoids printing 2011-07-10 Test suite for WHIZARD unit tests 2011-07-01 Commands for matrix element tests More OpenMP parallelization of kinematics Added unit tests 2011-06-23 Conversion of CIRCE2 from F77 to F90, major clean-up 2011-06-14 Conversion of CIRCE1 from F77 to F90 2011-06-10 OpenMP parallelization of channel kinematics (by Matthias Trudewind) 2011-05-31 RELEASE: version 1.97 2011-05-24 Minor bug fixes: update grids and elsif statement. ################################################################## 2011-05-10 RELEASE: version 2.0.5 2011-05-09 Fixed bug in final state flavor sums Minor improvements on phase-space setup 2011-05-05 Minor bug fixes 2011-04-15 WHIZARD as a precompiled 64-bit binary available 2011-04-06 Wall clock instead of cpu time for time estimates 2011-04-05 Major improvement on the phase space setup 2011-04-02 OpenMP parallelization for helicity loop in O'Mega matrix elements 2011-03-31 Tools for relocating WHIZARD and use in batch environments 2011-03-29 Completely static builds possible, profiling options 2011-03-28 Visualization of integration history 2011-03-27 Fixed broken K-matrix implementation 2011-03-23 Including the GAMELAN manual in the distribution 2011-01-26 WHIZARD analysis can handle hadronized event files 2011-01-17 MSTW2008 and CT10 PDF sets included 2010-12-23 Inclusion of NMSSM with Hgg couplings 2010-12-21 Advanced options for integration passes 2010-11-16 WHIZARD supports CTEQ6 and possibly other PDFs directly; data files included in the distribution ################################################################## 2010-10-26 RELEASE: version 2.0.4 2010-10-06 Bug fix in MSSM implementation 2010-10-01 Update to libtool 2.4 2010-09-29 Support for anomalous top couplings (form factors etc.) Bug fix for running gauge Yukawa SUSY couplings 2010-09-28 RELEASE: version 1.96 2010-09-21 Beam remnants and pT spectra for lepton collider re-enabled Restructuring subevt class 2010-09-16 Shower and matching are disabled by default PYTHIA as a conditional on these two options 2010-09-14 Possibility to read in beam spectra re-enabled (e.g. Guinea Pig) 2010-09-13 Energy scan as (pseudo-) structure functions re-implemented 2010-09-10 CIRCE2 included again in WHIZARD 2 and validated 2010-09-02 Re-implementation of asymmetric beam energies and collision angles, e-p collisions work, inclusion of a HERA DIS test case ################################################################## 2010-10-18 RELEASE: version 2.0.3 2010-08-08 Bug in CP-violating anomalous triple TGCs fixed 2010-08-06 Solving backwards compatibility problem with O'Caml 3.12.0 2010-07-12 Conserved quantum numbers speed up O'Mega code generation 2010-07-07 Attaching full ISR/FSR parton shower and MPI/ISR module Added SM model containing Hgg, HAA, HAZ vertices 2010-07-02 Matching output available as LHEF and STDHEP 2010-06-30 Various bug fixes, missing files, typos 2010-06-26 CIRCE1 completely re-enabled Chaining structure functions supported 2010-06-25 Partial support for conserved quantum numbers in O'Mega 2010-06-21 Major upgrade of the graphics package: error bars, smarter SINDARIN steering, documentation, and all that... 2010-06-17 MLM matching with PYTHIA shower included 2010-06-16 Added full CIRCE1 and CIRCE2 versions including full documentation and miscellanea to the trunk 2010-06-12 User file management supported, improved variable and command structure 2010-05-24 Improved handling of variables in local command lists 2010-05-20 PYTHIA interface re-enabled 2010-05-19 ASCII file formats for interfacing ROOT and gnuplot in data analysis ################################################################## 2010-05-18 RELEASE: version 2.0.2 2010-05-14 Reimplementation of visualization of phase space channels Minor bug fixes 2010-05-12 Improved phase space - elimination of redundancies 2010-05-08 Interface for polarization completed: polarized beams etc. 2010-05-06 Full quantum numbers appear in process log Integration results are usable as user variables Communication with external programs 2010-05-05 Split module commands into commands, integration, simulation modules 2010-05-04 FSR+ISR for the first time connected to the WHIZARD 2 core ################################################################## 2010-04-25 RELEASE: version 2.0.1 2010-04-23 Automatic compile and integrate if simulate is called Minor bug fixes in O'Mega 2010-04-21 Checkpointing for event generation Flush statements to use WHIZARD inside a pipe 2010-04-20 Reimplementation of signal handling in WGIZARD 2.0 2010-04-19 VAMP is now a separately configurable and installable unit of WHIZARD, included VAMP self-checks Support again compilation in quadruple precision 2010-04-06 Allow for logarithmic plots in GAMELAN, reimplement the possibility to set the number of bins 2010-04-15 Improvement on time estimates for event generation ################################################################## 2010-04-12 RELEASE: version 2.0.0 2010-04-09 Per default, the code for the amplitudes is subdivided to allow faster compiler optimization More advanced and unified and straightforward command language syntax Final bug fixes 2010-04-07 Improvement on SINDARIN syntax; printf, sprintf function thorugh a C interface 2010-04-05 Colorizing DAGs instead of model vertices: speed boost in colored code generation 2010-03-31 Generalized options for normalization of weighted and unweighted events Grid and weight histories added again to log files Weights can be used in analyses 2010-03-28 Cascade decays completely implemented including color and spin correlations 2010-03-07 Added new WHIZARD header with logo 2010-03-05 Removed conflict in O'Mega amplitudes between flavour sums and cascades StdHEP interface re-implemented 2010-03-03 RELEASE: version 2.0.0rc3 Several bug fixes for preventing abuse in input files OpenMP support for amplitudes Reimplementation of WHIZARD 1 HEPEVT ASCII event formats FeynRules interface successfully passed MSSM test 2010-02-26 Eliminating ghost gluons from multi-gluon amplitudes 2010-02-25 RELEASE: version 1.95 HEPEVT format from WHIZARD 1 re-implemented in WHIZARD 2 2010-02-23 Running alpha_s implemented in the FeynRules interface 2010-02-19 MSSM (semi-) automatized self-tests finalized 2010-02-17 RELEASE: version 1.94 2010-02-16 Closed memory corruption in WHIZARD 1 Fixed problems of old MadGraph and CompHep drivers with modern compilers Uncolored vertex selection rules for colored amplitudes in O'Mega 2010-02-15 Infrastructure for color correlation computation in O'Mega finished Forbidden processes are warned about, but treated as non-fatal 2010-02-14 Color correlation computation in O'Mega finalized 2010-02-10 Improving phase space mappings for identical particles in initial and final states Introduction of more extended multi-line error message 2010-02-08 First O'Caml code for computation of color correlations in O'Mega 2010-02-07 First MLM matching with e+ e- -> jets ################################################################## 2010-02-06 RELEASE: version 2.0.0rc2 2010-02-05 Reconsidered the Makefile structure and more extended tests Catch a crash between WHIZARD and O'Mega for forbidden processes Tensor products of arbitrary color structures in jet definitions 2010-02-04 Color correlation computation in O'Mega finalized ################################################################## 2010-02-03 RELEASE: version 2.0.0rc1 ################################################################## 2010-01-31 Reimplemented numerical helicity selection rules Phase space functionality of version 1 restored and improved 2009-12-05 NMSSM validated with FeynRules in WHIZARD 1 (Felix Braam) 2009-12-04 RELEASE: version 2.0.0alpha ################################################################## 2009-04-16 RELEASE: version 1.93 2009-04-15 Clean-up of Makefiles and configure scripts Reconfiguration of BSM model implementation extended supersymmetric models 2008-12-23 New model NMSSM (Felix Braam) SLHA2 added Bug in LHAPDF interface fixed 2008-08-16 Bug fixed in K matrix implementation Gravitino option in the MSSM added 2008-03-20 Improved color and flavor sums ################################################################## 2008-03-12 RELEASE: version 1.92 LHEF (Les Houches Event File) format added Fortran 2003 command-line interface (if supported by the compiler) Automated interface to colored models More bug fixes and workarounds for compiler compatibility ################################################################## 2008-03-06 RELEASE: version 1.91 New model K-matrix (resonances and anom. couplings in WW scattering) EWA spectrum Energy-scan pseudo spectrum Preliminary parton shower module (only from final-state quarks) Cleanup and improvements of configure process Improvements for O'Mega parameter files Quadruple precision works again More plotting options: lines, symbols, errors Documentation with PDF bookmarks enabled Various bug fixes 2007-11-29 New model UED ################################################################## 2007-11-23 RELEASE: version 1.90 O'Mega now part of the WHIZARD tree Madgraph/CompHEP disabled by default (but still usable) Support for LHAPDF (preliminary) Added new models: SMZprime, SM_km, Template Improved compiler recognition and compatibility Minor bug fixes ################################################################## 2006-06-15 RELEASE: version 1.51 Support for anomaly-type Higgs couplings (to gluon and photon/Z) Support for spin 3/2 and spin 2 New models: Little Higgs (4 versions), toy models for extra dimensions and gravitinos Fixes to the whizard.nw source documentation to run through LaTeX Intel 9.0 bug workaround (deallocation of some arrays) 2006-05-15 O'Mega RELEASE: version 0.11 merged JRR's O'Mega extensions ################################################################## 2006-02-07 RELEASE: version 1.50 To avoid confusion: Mention outdated manual example in BUGS file O'Mega becomes part of the WHIZARD generator 2006-02-02 [bug fix update] Bug fix: spurious error when writing event files for weighted events Bug fix: 'r' option for omega produced garbage for some particle names Workaround for ifort90 bug (crash when compiling whizard_event) Workaround for ifort90 bug (crash when compiling hepevt_common) 2006-01-27 Added process definition files for MSSM 2->2 processes Included beam recoil for EPA (T.Barklow) Updated STDHEP byte counts (for STDHEP 5.04.02) Fixed STDHEP compatibility (avoid linking of incomplete .so libs) Fixed issue with comphep requiring Xlibs on Opteron Fixed issue with ifort 8.x on Opteron (compiling 'signal' interface) Fixed color-flow code: was broken for omega with option 'c' and 'w' Workaround hacks for g95 compatibility 2005-11-07 O'Mega RELEASE: version 0.10 O'Mega, merged JRR's and WK's color hack for WHiZard O'Mega, EXPERIMENTAL: cache fusion tables (required for colors a la JRR/WK) O'Mega, make JRR's MSSM official ################################################################## 2005-10-25 RELEASE: version 1.43 Minor fixes in MSSM couplings (Higgs/3rd gen squarks). This should be final, since the MSSM results agree now completely with Madgraph and Sherpa User-defined lower and upper limits for split event file count Allow for counters (events, bytes) exceeding $2^{31}$ Revised checksum treatment and implementation (now MD5) Bug fix: missing process energy scale in raw event file ################################################################## 2005-09-30 RELEASE: version 1.42 Graphical display of integration history ('make history') Allow for switching off signals even if supported (configure option) 2005-09-29 Revised phase space generation code, in particular for flavor sums Negative cut and histogram codes use initial beams instead of initial parton momenta. This allows for computing, e.g., E_miss Support constant-width and zero-width options for O'Mega Width options now denoted by w:X (X=f,c,z). f option obsolescent Bug fix: colorized code: flipped indices could screw up result Bug fix: O'Mega with 'c' and 'w:f' option together (still some problem) Bug fix: dvips on systems where dvips defaults to lpr Bug fix: integer overflow if too many events are requested 2005-07-29 Allow for 2 -> 1 processes (if structure functions are on) 2005-07-26 Fixed and expanded the 'test' matrix element: Unit matrix element with option 'u' / default: normalized phase space ################################################################## 2005-07-15 RELEASE: version 1.41 Bug fix: no result for particle decay processes with width=0 Bug fix: line breaks in O'Mega files with color decomposition 2005-06-02 New self-tests (make test-QED / test-QCD / test-SM) check lists of 2->2 processes Bug fix: HELAS calling convention for wwwwxx and jwwwxx (4W-Vertex) 2005-05-25 Revised Makefile structure Eliminated obsolete references to ISAJET/SUSY (superseded by SLHA) 2005-05-19 Support for color in O'Mega (using color flow decomposition) New model QCD Parameter file changes that correspond to replaced SM module in O'Mega Bug fixes in MSSM (O'Mega) parameter file 2005-05-18 New event file formats, useful for LHC applications: ATHENA and Les Houches Accord (external fragmentation) Naive (i.e., leading 1/N) color factor now implemented both for incoming and outgoing partons 2005-01-26 include missing HELAS files for bundle pgf90 compatibility issues [note: still internal error in pgf90] ################################################################## 2004-12-13 RELEASE: version 1.40 compatibility fix: preprocessor marks in helas code now commented out minor bug fix: format string in madgraph source 2004-12-03 support for arbitray beam energies and directions allow for pT kick in structure functions bug fix: rounding error could result in zero cross section (compiler-dependent) 2004-10-07 simulate decay processes list fraction (of total width/cross section) instead of efficiency in process summary new cut/analysis parameters AA, AAD, CTA: absolute polar angle 2004-10-04 Replaced Madgraph I by Madgraph II. Main improvement: model no longer hardcoded introduced parameter reset_seed_each_process (useful for debugging) bug fix: color initialization for some processes was undefined 2004-09-21 don't compile unix_args module if it is not required ################################################################## 2004-09-20 RELEASE: version 1.30 g95 compatibility issues resolved some (irrelevant) memory leaks closed removed obsolete warning in circe1 manual update (essentially) finished 2004-08-03 O'Mega RELEASE: version 0.9 O'Mega, src/trie.mli, src/trie.ml: make interface compatible with the O'Caml 3.08 library (remains compatible with older versions). Implementation of unused functions still incomplete. 2004-07-26 minor fixes and improvements in make process 2004-06-29 workarounds for new Intel compiler bugs ... no rebuild of madgraph/comphep executables after 'make clean' bug fix in phase space routine: wrong energy for massive initial particles bug fix in (new) model interface: name checks for antiparticles pre-run checks for comphep improved ww-strong model file extended Model files particle name fixes, chep SM vertices included 2004-06-22 O'Mega RELEASE: version 0.8 O'Mega MSSM: sign of W+/W-/A and W+/W-/Z couplings 2004-05-05 Fixed bug in PDFLIB interface: p+pbar was initialized as p+p (ThO) NAG compiler: set number of continuation lines to 200 as default Extended format for cross section summary; appears now in whizard.out Fixed 'bundle' feature 2004-04-28 Fixed compatibility with revised O'Mega SM_ac model Fixed problem with x=0 or x=1 when calling PDFLIB (ThO) Fixed bug in comphep module: Vtb was overlooked ################################################################## 2004-04-15 RELEASE: version 1.28 Fixed bug: Color factor was missing for O'Mega processes with four quarks and more Manual partially updated 2004-04-08 Support for grid files in binary format New default value show_histories=F (reduce output file size) Revised phase space switches: removed annihilation_lines, removed s_channel_resonance, changed meaning of extra_off_shell_lines, added show_deleted_channels Bug fixed which lead to omission of some phase space channels Color flow guessed only if requested by guess_color_flow 2004-03-10 New model interface: Only one model name specified in whizard.prc All model-dependent files reside in conf/models (modellib removed) 2004-03-03 Support for input/output in SUSY Les Houches Accord format Split event files if requested Support for overall time limit Support for CIRCE and CIRCE2 generator mode Support for reading beam events from file 2004-02-05 Fixed compiler problems with Intel Fortran 7.1 and 8.0 Support for catching signals ################################################################## 2003-08-06 RELEASE: version 1.27 User-defined PDF libraries as an alternative to the standard PDFLIB 2003-07-23 Revised phase space module: improved mappings for massless particles, equivalences of phase space channels are exploited Improved mapping for PDF (hadron colliders) Madgraph module: increased max number of color flows from 250 to 1000 ################################################################## 2003-06-23 RELEASE: version 1.26 CIRCE2 support Fixed problem with 'TC' integer kind [Intel compiler complained] 2003-05-28 Support for drawing histograms of grids Bug fixes for MSSM definitions ################################################################## 2003-05-22 RELEASE: version 1.25 Experimental MSSM support with ISAJET interface Improved capabilities of generating/analyzing weighted events Optional drawing phase space diagrams using FeynMF ################################################################## 2003-01-31 RELEASE: version 1.24 A few more fixes and workarounds (Intel and Lahey compiler) 2003-01-15 Fixes and workarounds needed for WHIZARD to run with Intel compiler Command-line option interface for the Lahey compiler Bug fix: problem with reading whizard.phs ################################################################## 2002-12-10 RELEASE: version 1.23 Command-line options (on some systems) Allow for initial particles in the event record, ordered: [beams, initials] - [remnants] - outgoing partons Support for PYTHIA 6.2: Les Houches external process interface String pythia_parameters can be up to 1000 characters long Select color flow states in (internal) analysis Bug fix in color flow content of raw event files Support for transversal polarization of fermion beams Cut codes: PHI now for absolute azimuthal angle, DPHI for distance 'Test' matrix elements optionally respect polarization User-defined code can be inserted for spectra, structure functions and fragmentation Time limits can be specified for adaptation and simulation User-defined file names and file directory Initial weights in input file no longer supported Bug fix in MadGraph (wave function counter could overflow) Bug fix: Gamelan (graphical analysis) was not built if noweb absent ################################################################## 2002-03-16 RELEASE: version 1.22 Allow for beam remnants in the event record 2002-03-01 Handling of aliases in whizard.prc fixed (aliases are whole tokens) 2002-02-28 Optimized phase space handling routines (total execution time reduced by 20-60%, depending on process) ################################################################## 2002-02-26 RELEASE: version 1.21 Fixed ISR formula (ISR was underestimated in previous versions). New version includes ISR in leading-log approximation up to third order. Parameter ISR_sqrts renamed to ISR_scale. ################################################################## 2002-02-19 RELEASE: version 1.20 New process-generating method 'test' (dummy matrix element) Compatibility with autoconf 2.50 and current O'Mega version 2002-02-05 Prevent integration channels from being dropped (optionally) New internal mapping for structure functions improves performance Old whizard.phx file deleted after recompiling (could cause trouble) 2002-01-24 Support for user-defined cuts and matrix element reweighting STDHEP output now written by write_events_format=20 (was 3) 2002-01-16 Improved structure function handling; small changes in user interface: new parameter structured_beams in &process_input parameter fixed_energy in &beam_input removed Support for multiple initial states Eta-phi (cone) cut possible (hadron collider applications) Fixed bug: Whizard library was not always recompiled when necessary Fixed bug: Default cuts were insufficient in some cases Fixed bug: Unusable phase space mappings generated in some cases 2001-12-06 Reorganized document source 2001-12-05 Preliminary CIRCE2 support (no functionality yet) 2001-11-27 Intel compiler support (does not yet work because of compiler bugs) New cut and analysis mode cos-theta* and related Fixed circular jetset_interface dependency warning Some broadcast routines removed (parallel support disabled anyway) Minor shifts in cleanup targets (Makefiles) Modified library search, check for pdflib8* 2001-08-06 Fixed bug: I/O unit number could be undefined when reading phase space Fixed bug: Unitialized variable could cause segfault when event generation was disabled Fixed bug: Undefined subroutine in CIRCE replacement module Enabled feature: TGCs in O'Mega (not yet CompHEP!) matrix elements (CompHEP model sm-GF #5, O'Mega model SM_ac) Fixed portability issue: Makefile did rely on PWD environment variable Fixed portability issue: PYTHIA library search ambiguity resolved 2001-08-01 Default whizard.prc and whizard.in depend on activated modules Fixed bug: TEX=latex was not properly enabled when making plots 2001-07-20 Fixed output settings in PERL script calls Cache enabled in various configure checks 2001-07-13 Support for multiple processes in a single WHIZARD run. The integrations are kept separate, but the generated events are mixed The whizard.evx format has changed (incompatible), including now the color flow information for PYTHIA fragmentation Output files are now process-specific, except for the event file Phase space file whizard.phs (if present) is used only as input, program-generated phase space is now in whizard.phx 2001-07-10 Bug fix: Undefined parameters in parameters_SM_ac.f90 removed 2001-07-04 Bug fix: Compiler options for the case OMEGA is disabled Small inconsistencies in whizard.out format fixed 2001-07-01 Workaround for missing PDFLIB dummy routines in PYTHIA library ################################################################## 2001-06-30 RELEASE: version 1.13 Default path /cern/pro/lib in configure script 2001-06-20 New fragmentation option: Interface for PYTHIA with full color flow information, beam remnants etc. 2001-06-18 Severe bug fixed in madgraph interface: 3-gluon coupling was missing Enabled color flow information in madgraph 2001-06-11 VAMP interface module rewritten Revised output format: Multiple VAMP iterations count as one WHIZARD iteration in integration passes 1 and 3 Improved message and error handling Bug fix in VAMP: handle exceptional cases in rebinning_weights 2001-05-31 new parameters for grid adaptation: accuracy_goal and efficiency_goal ################################################################## 2001-05-29 RELEASE: version 1.12 bug fixes (compilation problems): deleted/modified unused functions 2001-05-16 diagram selection improved and documented 2001-05-06 allow for disabling packages during configuration 2001-05-03 slight changes in whizard.out format; manual extended ################################################################## 2001-04-20 RELEASE: version 1.11 fixed some configuration and compilation problems (PDFLIB etc.) 2001-04-18 linked PDFLIB: support for quark/gluon structure functions 2001-04-05 parameter interface written by PERL script SM_ac model file: fixed error in continuation line 2001-03-13 O'Mega, O'Caml 3.01: incompatible changes O'Mega, src/trie.mli: add covariance annotation to T.t This breaks O'Caml 3.00, but is required for O'Caml 3.01. O'Mega, many instances: replace `sig include Module.T end' by `Module.T', since the bug is fixed in O'Caml 3.01 2001-02-28 O'Mega, src/model.mli: new field Model.vertices required for model functors, will retire Model.fuse2, Model.fuse3, Model.fusen soon. ################################################################## 2001-03-27 RELEASE: version 1.10 reorganized the modules as libraries linked PYTHIA: support for parton fragmentation 2000-12-14 fixed some configuration problems (if noweb etc. are absent) ################################################################## 2000-12-01 RELEASE of first public version: version 1.00beta Index: trunk/circe1/src/Makefile.am =================================================================== --- trunk/circe1/src/Makefile.am (revision 8428) +++ trunk/circe1/src/Makefile.am (revision 8429) @@ -1,150 +1,156 @@ # Makefile.am -- ## ## Process this file with automake to produce Makefile.in ## ######################################################################## # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## SOURCE_FILES = \ circe1.f90 MODULE_FILES = \ - kinds.$(FC_MODULE_EXT) \ - circe1.$(FC_MODULE_EXT) + kinds.$(FCMOD) \ + circe1.$(FCMOD) NOWEB_FILES = \ prelude.nw postlude.nw circe1.nw \ minuit.nw interpol.nw taorng.nw EXTRA_DIST = $(NOWEB_FILES) $(SOURCE_FILES) # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: lib_LTLIBRARIES = libcirce1.la libcirce1_la_SOURCES = $(SOURCE_FILES) AM_FFLAGS = AM_FCFLAGS = ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FFLAGS += $(FCFLAGS_PROFILING) AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FFLAGS += $(FCFLAGS_OPENMP) AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ######################################################################## # noweb ######################################################################## BRACKET = prelude.nw postlude.nw TRIPLE = $(srcdir)/prelude.nw $< $(srcdir)/postlude.nw NOTANGLE_IT = \ cat $(TRIPLE) | $(NOTANGLE) -R'[[$@]]' > $@ -SUFFIXES = .nw .lo .$(FC_MODULE_EXT) +SUFFIXES = .nw .lo .$(FCMOD) if NOWEB_AVAILABLE .nw.f90: $(NOTANGLE_IT) endif NOWEB_AVAILABLE +execmodcirce1dir = $(fmoddir)/circe1 +nodist_execmodcirce1_HEADERS = $(MODULE_FILES) + +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = circe1.$(FCMOD) + ######################################################################## # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE ######################################################################## @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: $(SOURCE_FILES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f90//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -e 's/, *only:.*//' \ -e 's/, *&//' \ -e 's/, *.*=>.*//' \ -e 's/ *$$/.lo/' \ $(depend_filter_extra) ; \ done > $@ DISTCLEANFILES = Makefile.depend kinds.f90 ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f $(SOURCE_FILES) endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f $(SOURCE_FILES) || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb - -rm -f *.$(FC_MODULE_EXT) *.g90 + -rm -f *.$(FCMOD) *.g90 if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup dist-hook: -test ! -f libcirce1.la && $(MAKE) libcirce1.la ### module="`basename $$src | sed 's/\.f[90][0358]//'`"; ######################################################################## # MPI ######################################################################## ### ### # The -mismatch_all is for mpi_send() etc. ### MPIFC = mpif90 ### MPIFCFLAGS = # -mismatch_all Index: trunk/circe1/tools/Makefile.am =================================================================== --- trunk/circe1/tools/Makefile.am (revision 8428) +++ trunk/circe1/tools/Makefile.am (revision 8429) @@ -1,204 +1,204 @@ # Makefile.am -- ## ## Process this file with automake to produce Makefile.in ## ######################################################################## # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## bin_PROGRAMS = circe1_plot circe1_fit circe1_sample \ circe1_minuit1 circe1_minuit2 circe1_int bin_SCRIPTS = circe1_fit.run circe1_minuit1.run circe1_minuit2.run \ circe1_int.run KINDS=$(top_builddir)/circe1/src/kinds.lo circe1_plot_SOURCES = circe1_plot.f90 circe1_plot_LDADD = $(KINDS) $(top_builddir)/circe1/src/libcirce1.la circe1_sample_SOURCES = circe1_sample.f90 circe1_sample_LDADD = $(KINDS) $(top_builddir)/circe1/src/libcirce1.la circe1_fit_SOURCES = circe1_fit.f90 circe1_fit_LDADD = $(KINDS) $(top_builddir)/circe1/minuit/libminuit.la \ $(top_builddir)/circe1/src/libcirce1.la circe1_int_SOURCES = circe1_int.f90 circe1_int_LDADD = $(KINDS) $(top_builddir)/circe1/src/libcirce1.la circe1_minuit1_SOURCES = circe1_minuit1.f90 circe1_minuit1_LDADD = $(KINDS) $(top_builddir)/circe1/minuit/libminuit.la \ $(top_builddir)/circe1/src/libcirce1.la circe1_minuit2_SOURCES = circe1_minuit2.f90 circe1_minuit2_LDADD = $(KINDS) $(top_builddir)/circe1/minuit/libminuit.la \ $(top_builddir)/circe1/src/libcirce1.la EXTRA_DIST = $(circe1_plot_SOURCES) $(circe1_fit_SOURCES) \ $(circe1_sample_SOURCES) $(circe1_int_SOURCES) \ $(bin_SCRIPTS:.run=.sh) -SUFFIXES = .nw .lo .$(FC_MODULE_EXT) .sh. .run +SUFFIXES = .nw .lo .$(FCMOD) .sh. .run .sh.run: @rm -f @$ $(SED) 's|@name@|$*|g' $< >$@ chmod +x $@ # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: AM_FFLAGS = AM_FCFLAGS = -I$(top_builddir)/circe1/src ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FFLAGS += $(FCFLAGS_PROFILING) AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FFLAGS += $(FCFLAGS_OPENMP) AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ######################################################################## # noweb ######################################################################## BRACKET = $(top_srcdir)/circe1/src/prelude.nw $(top_srcdir)/circe1/src/postlude.nw TRIPLE = $(top_srcdir)/circe1/src/prelude.nw $< $(top_srcdir)/circe1/src/postlude.nw if NOWEB_AVAILABLE circe1_plot.f90: $(top_srcdir)/circe1/src/circe1.nw $(BRACKET) cat $(TRIPLE) | $(NOTANGLE) -R'[[$@]]' > $@ circe1_sample.f90: $(top_srcdir)/circe1/src/circe1.nw $(BRACKET) cat $(TRIPLE) | $(NOTANGLE) -R'[[$@]]' > $@ endif ######################################################################## if NOWEB_AVAILABLE circe1_fit.f90: $(top_srcdir)/circe1/src/minuit.nw $(BRACKET) cat $(TRIPLE) | $(NOTANGLE) -R'[[$@]]' > $@ circe1_fit.sh: $(top_srcdir)/circe1/src/minuit.nw $(BRACKET) cat $(TRIPLE) | $(NOTANGLE) -R'[[$@]]' > $@ circe1_minuit1.f90: $(top_srcdir)/circe1/src/minuit.nw $(BRACKET) cat $(TRIPLE) | $(NOTANGLE) -R'[[$@]]' > $@ circe1_minuit2.f90: $(top_srcdir)/circe1/src/minuit.nw $(BRACKET) cat $(TRIPLE) | $(NOTANGLE) -R'[[$@]]' > $@ circe1_minuit1.sh: $(top_srcdir)/circe1/src/minuit.nw $(BRACKET) cat $(TRIPLE) | $(NOTANGLE) -R'[[$@]]' > $@ circe1_minuit2.sh: $(top_srcdir)/circe1/src/minuit.nw $(BRACKET) cat $(TRIPLE) | $(NOTANGLE) -R'[[$@]]' > $@ circe1_int.f90: $(top_srcdir)/circe1/src/interpol.nw $(BRACKET) cat $(TRIPLE) | $(NOTANGLE) -R'[[$@]]' > $@ circe1_int.sh: $(top_srcdir)/circe1/src/interpol.nw $(BRACKET) cat $(TRIPLE) | $(NOTANGLE) -R'[[$@]]' > $@ endif ######################################################################## # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE ######################################################################## @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: $(circe1_plot_SOURCES) $(circe1_fit_SOURCES) \ $(circe1_sample_SOURCES) $(circe1_int_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f90//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -e 's/, *only:.*//' \ -e 's/, *&//' \ -e 's/, *.*=>.*//' \ -e 's/ *$$/.lo/' \ $(depend_filter_extra) ; \ done > $@ DISTCLEANFILES = Makefile.depend ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c circe1_fit.sh circe1_minuit1.sh \ circe1_minuit2.sh circe1_int.sh endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c circe1_fit.sh \ circe1_minuit1.sh circe1_minuit2.sh circe1_int.sh || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f *.run - -rm -f *.$(FC_MODULE_EXT) *.g90 circemacs.mp4 + -rm -f *.$(FCMOD) *.g90 circemacs.mp4 if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup dist-hook: -test ! -f circe1_plot && $(MAKE) circe1_plot ### module="`basename $$src | sed 's/\.f[90][0358]//'`"; ######################################################################## # MPI ######################################################################## ### ### # The -mismatch_all is for mpi_send() etc. ### MPIFC = mpif90 ### MPIFCFLAGS = # -mismatch_all Index: trunk/circe1/minuit/Makefile.am =================================================================== --- trunk/circe1/minuit/Makefile.am (revision 8428) +++ trunk/circe1/minuit/Makefile.am (revision 8429) @@ -1,94 +1,94 @@ # Makefile.am -- ## ## Process this file with automake to produce Makefile.in ## ######################################################################## # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## C_SOURCES = intrac.c FC_SOURCES = \ minuit.f mncomd.f mndxdi.f mnexin.f mnhess.f \ mnlims.f mnparm.f mnprin.f mnsave.f mnstat.f \ mnwarn.f mnamin.f mncont.f mneig.f mnfixp.f \ mnimpr.f mnline.f mnpars.f mnpsdf.f mnscan.f \ mnstin.f mnwerr.f mnbins.f mncrck.f mnemat.f \ mnfree.f mninex.f mnmatu.f mnpfit.f mnrazz.f \ mnseek.f mntiny.f stand.f mncalf.f mncros.f \ mnerrs.f mngrad.f mninit.f mnmigr.f mnpint.f \ mnread.f mnset.f mnunpt.f mncler.f mncuve.f \ mneval.f mnhelp.f mninpu.f mnmnos.f mnplot.f \ mnrn15.f mnseti.f mnvers.f mncntr.f mnderi.f \ mnexcm.f mnhes1.f mnintr.f mnmnot.f mnpout.f \ mnrset.f mnsimp.f mnvert.f lib_LTLIBRARIES = libminuit.la libminuit_la_SOURCES = $(FC_SOURCES) $(C_SOURCES) EXTRA_DIST = $(FC_SOURCES) $(C_SOURCES) # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: AM_FFLAGS = AM_FCFLAGS = -I$(top_builddir)/src ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FFLAGS += $(FCFLAGS_PROFILING) AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FFLAGS += $(FCFLAGS_OPENMP) AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## Remove FC module files clean-local: - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-backup ### module="`basename $$src | sed 's/\.f[90][0358]//'`"; ######################################################################## # MPI ######################################################################## ### ### # The -mismatch_all is for mpi_send() etc. ### MPIFC = mpif90 ### MPIFCFLAGS = # -mismatch_all Index: trunk/circe2/src/Makefile.am =================================================================== --- trunk/circe2/src/Makefile.am (revision 8428) +++ trunk/circe2/src/Makefile.am (revision 8429) @@ -1,291 +1,298 @@ # Makefile.am -- ## ## Process this file with automake to produce Makefile.in ## ######################################################################## # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## # backwards compatibility OCAML_BIGARRAY_COMPAT=@OCAML_BIGARRAY_COMPAT@ OCAML_BIGARRAY_CMA=@OCAML_BIGARRAY_CMA@ OCAML_BIGARRAY_CMXA=@OCAML_BIGARRAY_CMXA@ ######################################################################## lib_LTLIBRARIES = SOURCE_FILES = MODULE_FILES = EXTRA_SOURCE_FILES = bigarray_library.ml bigarray_module.ml bigarray_compat.mli NOWEB_FILES = prelude.nw postlude.nw ######################################################################## # The CIRCE2 library proper ######################################################################## lib_LTLIBRARIES += libcirce2.la libcirce2_la_SOURCES = circe2.f90 -MODULE_FILES += circe2.$(FC_MODULE_EXT) +MODULE_FILES += circe2.$(FCMOD) SOURCE_FILES += $(libcirce2_la_SOURCES) NOWEB_FILES += circe2.nw ######################################################################## # Required for standalone compilation, # otherwise provided by VAMP and/or WHIZARD ######################################################################## EXTRA_SOURCE_FILES += -MODULE_FILES += kinds.$(FC_MODULE_EXT) +MODULE_FILES += kinds.$(FCMOD) lib_LTLIBRARIES += libtaorng.la libtaorng_la_SOURCES = tao_random_numbers.f90 -MODULE_FILES += tao_random_numbers.$(FC_MODULE_EXT) +MODULE_FILES += tao_random_numbers.$(FCMOD) SOURCE_FILES += $(libtaorng_la_SOURCES) lib_LTLIBRARIES += libtaorng_objs.la libtaorng_objs_la_SOURCES = tao_random_objects.f90 -MODULE_FILES += tao_random_objects.$(FC_MODULE_EXT) +MODULE_FILES += tao_random_objects.$(FCMOD) SOURCE_FILES += $(libtaorng_objs_la_SOURCES) ######################################################################## +# Install generated .mod files +# once in 'circe2' and once in 'whizard' (main only) +######################################################################## +execmodcircedir = $(fmoddir)/circe2 +nodist_execmodcirce_HEADERS = $(MODULE_FILES) + +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = circe2.$(FCMOD) + +######################################################################## # Testing and tools ######################################################################## bin_PROGRAMS = circe2_moments circe2_ls circe2_generate circe2_moments_SOURCES = circe2_moments.f90 circe2_moments_LDADD = kinds.lo libcirce2.la libtaorng_objs.la libtaorng.la circe2_moments.o: $(MODULE_FILES) circe2_ls_SOURCES = circe2_ls.f90 circe2_ls_LDADD = kinds.lo libcirce2.la libtaorng.la circe2_ls.o: $(MODULE_FILES) circe2_generate_SOURCES = circe2_generate.f90 circe2_generate_LDADD = kinds.lo libcirce2.la libtaorng_objs.la libtaorng.la circe2_generate.o: $(MODULE_FILES) bin_SCRIPTS = if OCAML_AVAILABLE bin_SCRIPTS += $(CIRCE2_NATIVE) endif OCAML_AVAILABLE $(CIRCE2_NATIVE): $(CIRCE2_CMX) $(CIRCE2_BYTECODE): $(CIRCE2_CMO) if OCAML_AVAILABLE all-local: $(CIRCE2_CMX) $(CIRCE2TOOL_CMX) bytecode: $(CIRCE2_CMO) $(CIRCE2TOOL_CMO) else all-local: bytecode: endif include $(top_srcdir)/circe2/src/Makefile.ocaml include $(top_srcdir)/circe2/src/Makefile.sources EXTRA_DIST = $(NOWEB_FILES) $(SOURCE_FILES) $(CIRCE2_CAML) \ $(EXTRA_SOURCE_FILES) $(circe2_moments_SOURCES) \ $(circe2_ls_SOURCES) $(circe2_generate_SOURCES) MYPRECIOUS = $(CIRCE2_DERIVED) # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ -moduleexecincludedir = $(pkgincludedir)/../circe2 -nodist_moduleexecinclude_HEADERS = $(MODULE_FILES) - AM_FFLAGS = AM_FCFLAGS = ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FFLAGS += $(FCFLAGS_PROFILING) AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FFLAGS += $(FCFLAGS_OPENMP) AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ######################################################################## # noweb ######################################################################## TRIPLE = $(srcdir)/prelude.nw $< $(srcdir)/postlude.nw WEBS = $(srcdir)/prelude.nw $(srcdir)/circe2.nw $(srcdir)/postlude.nw NOTANGLE_IT = \ cat $(TRIPLE) | $(NOTANGLE) -R'[[$@]]' > $@ -SUFFIXES += .nw .$(FC_MODULE_EXT) +SUFFIXES += .nw .$(FCMOD) if NOWEB_AVAILABLE .nw.f90: $(NOTANGLE_IT) circe2_ls.f90: circe2.nw cat $(WEBS) | $(NOTANGLE) -R'[[$@]]' > $@ circe2_generate.f90: circe2.nw cat $(WEBS) | $(NOTANGLE) -R'[[$@]]' > $@ circe2_moments.f90: circe2.nw cat $(WEBS) | $(NOTANGLE) -R'[[$@]]' > $@ tao_random_objects.f90: circe2.nw cat $(WEBS) | $(NOTANGLE) -R'[[$@]]' > $@ endif NOWEB_AVAILABLE ######################################################################## # O'Caml ######################################################################## if OCAML_AVAILABLE bigarray_compat.ml: $(OCAML_BIGARRAY_COMPAT).ml cp -f $< $@ events.cmx: bigarray_compat.cmi bigarray_compat.cmx events.cmo: bigarray_compat.cmi bigarray_compat.cmo circe2.top: $(CIRCE2_CMO) $(OCAMLMKTOP) $(OCAMLFLAGS) -o $@ \ unix.cma $(OCAML_BIGARRAY_CMA) $(CIRCE2_CMO) lexer.mli: lexer.ml parser.cmi $(OCAMLC) -i $< | $(GREP) 'val token' >$@ endif OCAML_AVAILABLE ######################################################################## # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE ######################################################################## @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: $(SOURCE_FILES) $(circe2_moments_SOURCES) $(circe2_ls_SOURCES) $(circe2_generate_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f90//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -e 's/, *only:.*//' \ -e 's/, *&//' \ -e 's/, *.*=>.*//' \ -e 's/ *$$/.lo/'; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -e 's/, *only:.*//' \ -e 's/, *&//' \ -e 's/, *.*=>.*//' \ - -e 's/ *$$/.$$(FC_MODULE_EXT)/'; \ + -e 's/ *$$/.$$(FCMOD)/'; \ done > $@ DISTCLEANFILES = Makefile.depend kinds.f90 if OCAML_AVAILABLE @am__include@ @am__quote@Makefile.depend_ocaml@am__quote@ # echo lexer.mli: lexer.ml >>$@ Makefile.depend_ocaml: $(CIRCE2_SRC) $(CIRCE2TOOL_SRC) @if $(AM_V_P); then :; else echo " OCAMLDEP " $@; fi @rm -f $@ $(AM_V_at)$(OCAMLDEP) -I $(srcdir) $^ | sed 's,[^ ]*/,,g' >$@ echo parser.mli: parser.ml >>$@ echo lexer.cmi: parser.cmi >>$@ echo parser.cmi: syntax.cmi >>$@ echo commands.cmi: parser.cmi lexer.cmi >>$@ echo commands.cmo: parser.cmi lexer.cmi >>$@ echo commands.cmx: parser.cmx lexer.cmx >>$@ echo lexer.cmo: lexer.cmi >>$@ echo lexer.cmx: lexer.cmi parser.cmx >>$@ echo parser.cmo: parser.cmi syntax.cmi >>$@ echo parser.cmx: parser.cmi syntax.cmi syntax.cmx >>$@ DISTCLEANFILES += Makefile.depend_ocaml DISTCLEANFILES += $(CIRCE2_DERIVED) DISTCLEANFILES += bigarray_compat.ml endif OCAML_AVAILABLE ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB .PRECIOUS = $(MYPRECIOUS) if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f $(SOURCE_FILES) $(circe2_moments_SOURCES) $(circe2_ls_SOURCES) $(circe2_generate_SOURCES) endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f $(SOURCE_FILES) $(circe2_moments_SOURCES) $(circe2_ls_SOURCES) $(circe2_generate_SOURCES) || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb - -rm -f *.cm[aiox] *.cmxa *.[ao] *.l[oa] *.$(FC_MODULE_EXT) \ + -rm -f *.cm[aiox] *.cmxa *.[ao] *.l[oa] *.$(FCMOD) \ *.g90 $(CIRCE2_NATIVE) $(CIRCE2_BYTECODE) $(CIRCE2_DERIVED) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup ### module="`basename $$src | sed 's/\.f[90][0358]//'`"; ######################################################################## # MPI ######################################################################## ### ### # The -mismatch_all is for mpi_send() etc. ### MPIFC = mpif90 ### MPIFCFLAGS = # -mismatch_all Index: trunk/configure.ac.in =================================================================== --- trunk/configure.ac.in (revision 8428) +++ trunk/configure.ac.in (revision 8429) @@ -1,1200 +1,1219 @@ dnl configure.ac -- Main configuration script for WHIZARD dnl dnl Process this file with autoconf to produce a configure script. dnl ************************************************************************ dnl configure.ac -- Main configuration script for WHIZARD dnl configure.ac -- WHIZARD configuration dnl dnl Copyright (C) 1999-2020 by dnl Wolfgang Kilian dnl Thorsten Ohl dnl Juergen Reuter dnl with contributions from dnl cf. main AUTHORS file dnl dnl WHIZARD is free software; you can redistribute it and/or modify it dnl under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2, or (at your option) dnl any later version. dnl dnl WHIZARD is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. dnl dnl *********************************************************************** dnl Environment variables that can be set by the user: dnl FC Fortran compiler dnl FCFLAGS Fortran compiler flags dnl *********************************************************************** dnl dnl Start configuration AC_INIT([XXXWHIZARDXXX],[3.0.0_alpha+]) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE([1.12.2 color-tests parallel-tests]) AC_PREREQ([2.65]) AM_MAKE_INCLUDE dnl Make make less verbose to improve signal/noise AM_SILENT_RULES([yes]) ######################################################################## ### Package-specific initialization AC_MSG_NOTICE([**************************************************************]) WO_CONFIGURE_SECTION([Start of package configuration]) ### Further version information PACKAGE_DATE="Jul 03 2020" PACKAGE_STATUS="alpha" AC_SUBST(PACKAGE_DATE) AC_SUBST(PACKAGE_STATUS) AC_MSG_NOTICE([**************************************************************]) AC_MSG_NOTICE([Package name: AC_PACKAGE_NAME()]) AC_MSG_NOTICE([Version: AC_PACKAGE_VERSION()]) AC_MSG_NOTICE([Date: $PACKAGE_DATE]) AC_MSG_NOTICE([Status: $PACKAGE_STATUS]) AC_MSG_NOTICE([**************************************************************]) ### Dump Package version and date to file 'VERSION' echo "$PACKAGE_STRING ($PACKAGE_STATUS) $PACKAGE_DATE" \ > VERSION ######################################################################## ###--------------------------------------------------------------------- ### shared library versioning (not the same as the package version!) -LIBRARY_VERSION="-version-info 1:2:0" +LIBRARY_VERSION="-version-info 2:0:0" AC_SUBST([LIBRARY_VERSION]) ######################################################################## ###--------------------------------------------------------------------- ### Define the main package variables ### Source directory, for testing purposes SRCDIR=`cd $srcdir && pwd` AC_SUBST([SRCDIR]) ### Build directory, for testing purposes BUILDDIR=`pwd` AC_SUBST([BUILDDIR]) ### Location of installed libraries and such eval BINDIR=$bindir case $BINDIR in NONE*) eval BINDIR=$prefix/bin ;; esac case $BINDIR in NONE*) BINDIR="\${prefix}/bin" ;; esac AC_SUBST([BINDIR]) eval INCLUDEDIR=$includedir case $INCLUDEDIR in NONE*) eval INCLUDEDIR=$prefix/include ;; esac case $INCLUDEDIR in NONE*) INCLUDEDIR="\${prefix}/include" ;; esac AC_SUBST([INCLUDEDIR]) eval LIBDIR=$libdir case $LIBDIR in NONE*) eval LIBDIR=$prefix/lib ;; esac case $LIBDIR in NONE*) eval LIBDIR=$ac_default_prefix/lib ;; esac AC_SUBST([LIBDIR]) ### Location of installed libraries and such eval PKGLIBDIR=$libdir/$PACKAGE case $PKGLIBDIR in NONE*) eval PKGLIBDIR=$prefix/lib/$PACKAGE ;; esac case $PKGLIBDIR in NONE*) PKGLIBDIR="\${prefix}/lib/$PACKAGE" ;; esac AC_SUBST([PKGLIBDIR]) ### Location of installed system-independent data eval PKGDATADIR=$datarootdir/$PACKAGE case $PKGDATADIR in NONE*) eval PKGDATADIR=$prefix/share/$PACKAGE ;; esac case $PKGDATADIR in NONE*) PKGDATADIR="\${prefix}/share/$PACKAGE" ;; esac AC_SUBST([PKGDATADIR]) ### Location of installed TeX files and such eval PKGTEXDIR=$datarootdir/texmf/$PACKAGE case $PKGTEXDIR in NONE*) eval PKGTEXDIR=$prefix/share/texmf/$PACKAGE ;; esac case $PKGTEXDIR in NONE*) PKGTEXDIR="\${prefix}/share/texmf/$PACKAGE" ;; esac AC_SUBST([PKGTEXDIR]) +### Parent location of installed .mod files +### To be used in Fortran source +FMODDIR=$prefix/lib/mod +AC_SUBST([FMODDIR]) + +### To be used in Makefile.am +### Don't use ${libdir} since lib may be changed to lib64 by configure +fmoddir="\${prefix}/lib/mod" +AC_SUBST([fmoddir]) + ######################################################################## ###--------------------------------------------------------------------- ### Required programs and checks ### GNU Tools WO_CONFIGURE_SECTION([Generic tools]) ### Initialize LIBTOOL LT_INIT(dlopen) LT_PREREQ([2.4.1b]) AX_CHECK_GNU_MAKE() AC_PROG_GREP() AC_MSG_CHECKING([for the suffix of shared libraries]) case $host in *-darwin* | rhapsody*) SHRLIB_EXT="dylib" ;; cygwin* | mingw* | pw32* | cegcc* | os2*) SHRLIB_EXT="dll" ;; hpux9* | hpux10* | hpux11*) SHRLIB_EXT="sl" ;; *) SHRLIB_EXT="so" ;; esac if test "x$SHRLIB_EXT" != "x"; then SHRLIB_EXT=$SHRLIB_EXT else SHRLIB_EXT="so" fi AC_MSG_RESULT([.$SHRLIB_EXT]) AC_SUBST(SHRLIB_EXT) ### Export whether the C compiler is GNU AC_MSG_CHECKING([whether the C compiler is the GNU compiler]) if test "x$ac_cv_c_compiler_gnu" = "xyes"; then CC_IS_GNU=".true." else CC_IS_GNU=".false." fi AC_MSG_RESULT([$ac_cv_c_compiler_gnu]) AC_SUBST([CC_IS_GNU]) AC_CHECK_HEADERS([quadmath.h]) if test "x$ac_cv_header_quadmath_h" = "xyes"; then CC_HAS_QUADMATH=".true." else CC_HAS_QUADMATH=".false." fi AC_SUBST([CC_HAS_QUADMATH]) ######################################################################## ###--------------------------------------------------------------------- ### Host system MAC OS X check for XCode case $host in *-darwin*) WO_HLINE() AC_MSG_NOTICE([Host is $host, checking for XCode]) AC_PATH_PROG(XCODE_SELECT, xcode-select) # locate currently selected Xcode path if test "x$XCODE_SELECT" != "x"; then AC_MSG_CHECKING(Xcode location) DEVELOPER_DIR=`$XCODE_SELECT -print-path` AC_MSG_RESULT([$DEVELOPER_DIR]) else DEVELOPER_DIR=/Developer fi AC_SUBST(DEVELOPER_DIR) XCODEPLIST=$DEVELOPER_DIR/Applications/Xcode.app/Contents/version.plist if test -r "$XCODEPLIST"; then AC_MSG_CHECKING(Xcode version) if test "x$DEFAULTS" != "x"; then XCODE_VERSION=`$DEFAULTS read $DEVELOPER_DIR/Applications/Xcode.app/Contents/version CFBundleShortVersionString` else XCODE_VERSION=`tr -d '\r\n' < $XCODEPLIST | sed -e 's/.*CFBundleShortVersionString<\/key>.\([[0-9.]]*\)<\/string>.*/\1/'` fi AC_MSG_RESULT([$XCODE_VERSION]) AC_SUBST(XCODE_VERSION) fi AC_MSG_NOTICE([checking for Security Integrity Protocol (SIP)]) AC_PATH_PROG(CSRUTIL, csrutil) if test "x$CSRUTIL" != "x"; then SIP_CHECK=`$CSRUTIL status | $SED "s/System Integrity Protection status: //"` if test "$SIP_CHECK" = "enabled."; then SIP_ACTIVE="yes" else SIP_ACTIVE="no" fi else SIP_ACTIVE="no" fi AC_MSG_CHECKING([Checking whether MAC OS X SIP is activated]) AC_MSG_RESULT([$SIP_ACTIVE]) AC_SUBST([SIP_ACTIVE]) WO_HLINE() ;; *) ;; esac ######################################################################## ###--------------------------------------------------------------------- ### Enable the distribution tools ### (default: disabled, to speed up compilation) AC_ARG_ENABLE([distribution], [AS_HELP_STRING([--enable-distribution], [build the distribution incl. all docu (developers only) [[no]]])]) AC_CACHE_CHECK([whether we want to build the distribution], [wo_cv_distribution], [dnl if test "$enable_distribution" = "yes"; then wo_cv_distribution=yes else wo_cv_distribution=no fi]) AM_CONDITIONAL([DISTRIBUTION], [test "$enable_distribution" = "yes"]) ### ONLY_FULL {{{ ######################################################################## ###--------------------------------------------------------------------- if test "$enable_shared" = no; then AC_MSG_ERROR([you've used --disable-shared which will not produce a working Whizard.]) fi ### ONLY_FULL }}} ######################################################################## ###--------------------------------------------------------------------- ### We include the m4 macro tool here AC_PATH_PROG(M4,m4,false) if test "$M4" = false; then AM_CONDITIONAL([M4_AVAILABLE],[false]) else AM_CONDITIONAL([M4_AVAILABLE],[true]) fi ######################################################################## ###--------------------------------------------------------------------- ### Dynamic runtime linking WO_CONFIGURE_SECTION([Dynamic runtime linking]) ### Look for libdl (should provide 'dlopen' and friends) AC_PROG_CC() WO_PROG_DL() ### Define the conditional for static builds if test "$enable_static" = yes; then AM_CONDITIONAL([STATIC_AVAILABLE],[true]) else AM_CONDITIONAL([STATIC_AVAILABLE],[false]) fi ######################################################################## ###--------------------------------------------------------------------- ### Noweb WO_CONFIGURE_SECTION([Checks for 'noweb' system]) ### Enable/disable noweb and determine locations of notangle, cpif, noweave WO_PROG_NOWEB() ######################################################################## ###--------------------------------------------------------------------- ### LaTeX WO_CONFIGURE_SECTION([Checks for 'LaTeX' system]) ### Determine whether LaTeX is present AC_PROG_LATEX() AC_PROG_DVIPS() AC_PROG_PDFLATEX() AC_PROG_MAKEINDEX() AC_PROG_PS2PDF() AC_PROG_EPSPDF() AC_PROG_EPSTOPDF() if test "$EPSPDF" = "no" -a "$EPSTOPDF" = "no"; then AC_MSG_NOTICE([*********************************************************]) AC_MSG_NOTICE([WARNING: eps(to)pdf n/a; O'Mega documentation will crash!]) AC_MSG_NOTICE([WARNING: this applies only to the svn developer version!]) AC_MSG_NOTICE([*********************************************************]) fi AC_PROG_SUPP_PDF() AC_PROG_GZIP() AC_PATH_PROG(ACROREAD,acroread,false) AC_PATH_PROG(GHOSTVIEW,gv ghostview,false) AC_PROG_DOT() ### Determine whether Metapost is present and whether event display is possible AC_PROG_MPOST() WO_CHECK_EVENT_ANALYSIS_METHODS() ### We put here the check for HEVEA components as well WO_PROG_HEVEA() ######################################################################## ###--------------------------------------------------------------------- ### Fortran compiler WO_CONFIGURE_SECTION([Fortran compiler checks]) ### Determine default compiler to use user_FCFLAGS="${FCFLAGS}" AC_PROG_FC() ### Choose FC standard for PYTHIA6 F77 files AC_PROG_F77([$FC]) ### Determine compiler vendor and version WO_FC_GET_VENDOR_AND_VERSION() ### Veto against old gfortran 4 versions WO_FC_VETO_GFORTRAN_4() ### Veto against buggy gfortran 6.5.0 version WO_FC_VETO_GFORTRAN_65() ### Veto against ifort 15/16/17 WO_FC_VETO_IFORT_15_18() ### Veto against ifort 19.0.0/1/2 WO_FC_VETO_IFORT_190012() ### Require extension '.f90' for all compiler checks AC_FC_SRCEXT([f90]) ### Determine flags and extensions WO_FC_PARAMETERS() ### Determine flags for linking the Fortran runtime library WO_FC_LIBRARY_LDFLAGS() ### Check for Fortran 95 features WO_FC_CHECK_F95() ### Check for allocatable subobjects (TR15581) WO_FC_CHECK_TR15581() ### Check for allocatable scalars WO_FC_CHECK_ALLOCATABLE_SCALARS() ### Check for ISO C binding support WO_FC_CHECK_C_BINDING() ### Check for procedures pointers and abstract interfaces WO_FC_CHECK_PROCEDURE_POINTERS() ### Check for type extension and further OO features WO_FC_CHECK_OO_FEATURES() ### Check for submodules (not yet used) WO_FC_CHECK_TR19767() ### Check for F2003 command-line interface WO_FC_CHECK_CMDLINE() ### Check for F2003-style access to environment variables WO_FC_CHECK_ENVVAR() ### Check for the flush statement WO_FC_CHECK_FLUSH() ### Check for iso_fortran_env WO_FC_CHECK_ISO_FORTRAN_ENV() WO_FC_CHECK_ISO_FORTRAN_ENV_2008() ### Turn on/off master switch for debugging features WO_FC_SET_DEBUG() ### OpenMP threading activated upon request AC_OPENMP() WO_FC_SET_OPENMP() ### Profiling compilation enforced upon request WO_FC_SET_PROFILING() ### Impure subroutines enforced upon request WO_FC_SET_OMEGA_IMPURE() ### Find the extension of Fortran module files -WO_FC_MODULE_FILE([FC_MODULE_NAME], [FC_MODULE_EXT], [$FC], [f90]) +WO_FC_MODULE_FILE([FC_MODULE_NAME], [FCMOD], [$FC], [f90]) ###--------------------------------------------------------------------- ### Check for the requested precision WO_FC_CONFIGURE_KINDS([src/basics/kinds.f90]) ### ONLY_FULL {{{ AC_PROG_INSTALL() ${INSTALL} -d circe1/src cp -a src/basics/kinds.f90 circe1/src ${INSTALL} -d circe2/src cp -a src/basics/kinds.f90 circe2/src ${INSTALL} -d omega/src cp -a src/basics/kinds.f90 omega/src ${INSTALL} -d vamp/src cp -a src/basics/kinds.f90 vamp/src ### ONLY_FULL }}} ### ONLY_VAMP_AND_FULL {{{ ######################################################################## # VAMP Fortran options for the configure script ######################################################################## WO_FC_SET_MPI() ### ONLY_VAMP_AND_FULL }}} ######################################################################## ###--------------------------------------------------------------------- ### O'Caml WO_CONFIGURE_SECTION([Objective Caml checks]) ### Check for ocamlc and its relatives AC_PROG_OCAML() if test "$enable_ocaml" != "no"; then AC_OCAML_VERSION_CHECK(402003) AC_PROG_OCAMLLEX() AC_PROG_OCAMLYACC() AC_PROG_OCAMLCP() AC_OCAML_BIGARRAY_MODULE() ### Ocamlweb is required to be newer than v0.9 AC_PROG_OCAMLWEB(009000) AC_PROG_OCAML_LABLGTK() AC_PATH_PROGS([OCAMLDOT],[ocamldot],[no]) AM_CONDITIONAL([OCAMLDOT_AVAILABLE],[test "$OCAMLDOT" != "no"]) AC_PATH_PROGS([OCAMLDEP],[ocamldep],[no]) AM_CONDITIONAL([OCAMLDEP_AVAILABLE],[test "$OCAMLDEP" != "no"]) AC_PATH_PROGS([OCAMLDEFUN],[ocamldefun],[no]) else AC_MSG_NOTICE([WARNING: O'Caml and O'Mega matrix elements disabled by request!]) AM_CONDITIONAL([OCAMLWEB_AVAILABLE],[false]) AM_CONDITIONAL([OCAMLDOT_AVAILABLE],[false]) AM_CONDITIONAL([OCAMLDEP_AVAILABLE],[false]) fi ######################################################################## ###--------------------------------------------------------------------- ### C++ WO_CONFIGURE_SECTION([C++ compiler checks]) AC_PROG_CXX() AC_CXX_LIBRARY_LDFLAGS() +######################################################################## +###--------------------------------------------------------------------- +### Checks for external interfaces + +WO_CONFIGURE_SECTION([Checking for PYTHON / PYTHON API]) + +AX_PYTHON_DEVEL([>= '2.7']) +WO_PROG_PYTHON_API() + ### ONLY_OMEGA_AND_FULL {{{ ######################################################################## # O'Mega options for the configure script ######################################################################## ######################################################################## ###--------------------------------------------------------------------- ### O'Mega UFO file paths WO_CONFIGURE_SECTION([O'Mega UFO file paths]) AC_ARG_ENABLE([default-UFO-dir], [ --enable-default-UFO-dir=directory Read precomputed model tables from this directory, which will be populated by an administrator at install time [[default=$datadir/UFO, enabled]].], [case "$enableval" in no) OMEGA_DEFAULT_UFO_DIR="." ;; *) OMEGA_DEFAULT_UFO_DIR="$enableval" ;; esac], [### use eval b/c $datadir defaults to unexpanded ${datarootdir} case "$OMEGA_DEFAULT_UFO_DIR" in "") OMEGA_DEFAULT_UFO_DIR="${prefix}/omega/share/UFO" ;; *) eval OMEGA_DEFAULT_UFO_DIR="$datadir/UFO" ;; esac]) AC_SUBST([OMEGA_DEFAULT_UFO_DIR]) case "$OMEGA_DEFAULT_UFO_DIR" in .|""|NONE*) OMEGA_DEFAULT_UFO_DIR="." ;; *) AC_MSG_NOTICE([Creating default UFO directory $OMEGA_DEFAULT_UFO_DIR]) $MKDIR_P "$OMEGA_DEFAULT_UFO_DIR" 2>/dev/null chmod u+w "$OMEGA_DEFAULT_UFO_DIR" 2>/dev/null ;; esac ###--------------------------------------------------------------------- ### Recola WO_CONFIGURE_SECTION([RECOLA]) WO_PROG_RECOLA() ### ONLY_OMEGA_AND_FULL }}} ### ONLY_FULL {{{ ######################################################################## ###--------------------------------------------------------------------- ### Libraries ###--------------------------------------------------------------------- ### LHAPDF WO_CONFIGURE_SECTION([LHAPDF]) WO_PROG_LHAPDF() ###--------------------------------------------------------------------- ### ROOT WO_CONFIGURE_SECTION([ROOT]) WO_ROOT_PATH(,[ AC_DEFINE([HAVE_ROOT],,[Root library]) AC_CHECK_LIB([dl],[dlopen],[],AC_MSG_WARN([Root libraries not linking properly])) ],AC_MSG_RESULT([The ROOT support of HepMC might not be working properly])) ###--------------------------------------------------------------------- ### HepMC WO_CONFIGURE_SECTION([HepMC]) WO_PROG_HEPMC() ###--------------------------------------------------------------------- ### STDHEP WO_CONFIGURE_SECTION([STDHEP]) WO_PROG_TIRPC() AC_MSG_NOTICE([StdHEP v5.06.01 is included internally]) ###--------------------------------------------------------------------- ### LCIO WO_CONFIGURE_SECTION([LCIO]) WO_PROG_LCIO() ###--------------------------------------------------------------------- ### PYTHIA6, PYTHIA8 etc WO_CONFIGURE_SECTION([SHOWERS PYTHIA6 PYTHIA8 MPI]) WO_PROG_QCD() WO_PROG_PYTHIA8() ###--------------------------------------------------------------------- ### HOPPET WO_CONFIGURE_SECTION([HOPPET]) WO_PROG_HOPPET() ###--------------------------------------------------------------------- ### FASTJET WO_CONFIGURE_SECTION([FASTJET]) WO_PROG_FASTJET() ###--------------------------------------------------------------------- ### GoSam WO_CONFIGURE_SECTION([GOSAM]) WO_PROG_GOSAM() ###--------------------------------------------------------------------- ### OpenLoops WO_CONFIGURE_SECTION([OPENLOOPS]) WO_PROG_OPENLOOPS() ###--------------------------------------------------------------------- ### LoopTools WO_CONFIGURE_SECTION([LOOPTOOLS]) WO_PROG_LOOPTOOLS() ### ONLY_FULL }}} ######################################################################## ###--------------------------------------------------------------------- ### Extra flags for helping the linker finding libraries WO_CONFIGURE_SECTION([Handle linking with C++ libraries]) WO_PROG_STDCPP() ### ONLY_FULL {{{ ######################################################################## ###--------------------------------------------------------------------- ### Miscellaneous WO_CONFIGURE_SECTION([Numerical checks]) ### Disable irrelevant optimization for parameter files ### (default: disabled, to speed up compilation) AC_ARG_ENABLE([optimization-for-parameter-files], [AS_HELP_STRING([--enable-optimization-for-parameter-files], [enable (useless) optimization for parameter files [[no]]])]) AC_CACHE_CHECK([whether we want optimization for parameter files], [wo_cv_optimization_for_parfiles], [dnl if test "$enable_optimization_for_parameter_files" = "yes"; then wo_cv_optimization_for_parfiles=yes else wo_cv_optimization_for_parfiles=no fi]) AM_CONDITIONAL([OPTIMIZATION_FOR_PARFILES], [test "$enable_optimization_for_parameter_files" = "yes"]) -######################################################################## -###--------------------------------------------------------------------- -### Checks for external interfaces - -WO_CONFIGURE_SECTION([Auxiliary stuff for external interfaces]) - -AX_PYTHON() - ### ONLY_FULL }}} ######################################################################## ###--------------------------------------------------------------------- ### Wrapup WO_CONFIGURE_SECTION([Finalize configuration]) ### Main directory AC_CONFIG_FILES([Makefile]) ### ONLY_FULL {{{ ###--------------------------------------------------------------------- ### Subdirectory src AC_CONFIG_FILES([src/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/hepmc AC_CONFIG_FILES([src/hepmc/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/lcio AC_CONFIG_FILES([src/lcio/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory pythia6: WHIZARD's internal PYTHIA6 version AC_CONFIG_FILES([pythia6/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory tauola: WHIZARD's internal TAUOLA version AC_CONFIG_FILES([tauola/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory stdhep: WHIZARD's internal StdHep version AC_CONFIG_FILES([mcfio/Makefile]) AC_CONFIG_FILES([stdhep/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/muli: multiple interactions AC_CONFIG_FILES([src/muli/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/lhapdf5: dummy library as LHAPDF5 replacement AC_CONFIG_FILES([src/lhapdf5/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/lhapdf: LHAPDF v6 AC_CONFIG_FILES([src/lhapdf/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/pdf_builtin: Builtin PDFs AC_CONFIG_FILES([src/pdf_builtin/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/pdf_builtin: Electron PDFs AC_CONFIG_FILES([src/qed_pdf/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/tauola AC_CONFIG_FILES([src/tauola/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/xdr: XDR reader AC_CONFIG_FILES([src/xdr/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/hoppet AC_CONFIG_FILES([src/hoppet/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/fastjet AC_CONFIG_FILES([src/fastjet/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/looptools AC_CONFIG_FILES([src/looptools/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/shower: shower and all that AC_CONFIG_FILES([src/pythia8/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/shower: shower and all that AC_CONFIG_FILES([src/shower/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/noweb-frame: frame for whizard Noweb sources AC_CONFIG_FILES([src/noweb-frame/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/basics: numeric kinds, strings AC_CONFIG_FILES([src/basics/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/utilities: simple utilities AC_CONFIG_FILES([src/utilities/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/testing: unit-test support AC_CONFIG_FILES([src/testing/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/system: modules related to local setup and OS issues AC_CONFIG_FILES([src/system/Makefile]) AC_CONFIG_FILES([src/system/system_dependencies.f90], [ maxlen=70 i=1 pat="" while test ${i} -lt ${maxlen}; do pat="${pat}."; i=`expr ${i} + 1`; done pat=${pat}[[^\"]] pat="/^ \"${pat}/ s/${pat}/&\&\\ \&/g" $SED "${pat}" < src/system/system_dependencies.f90 > \ src/system/system_dependencies.tmp mv -f src/system/system_dependencies.tmp src/system/system_dependencies.f90 ]) AC_CONFIG_FILES([src/system/debug_master.f90]) ###--------------------------------------------------------------------- ### Subdirectory src/combinatorics: standard algorithms AC_CONFIG_FILES([src/combinatorics/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/parsing: text-handling and parsing AC_CONFIG_FILES([src/parsing/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/rng: random-number generation AC_CONFIG_FILES([src/rng/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/expr_base: abstract expressions AC_CONFIG_FILES([src/expr_base/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/physics: particle-physics related functions AC_CONFIG_FILES([src/physics/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/qft: quantum (field) theory concepts as data types AC_CONFIG_FILES([src/qft/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/types: HEP and other types for common use AC_CONFIG_FILES([src/types/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/matrix_elements: process code and libraries AC_CONFIG_FILES([src/matrix_elements/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/me_methods: specific process code and interface AC_CONFIG_FILES([src/me_methods/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/particles: particle objects AC_CONFIG_FILES([src/particles/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/beams: beams and beam structure AC_CONFIG_FILES([src/beams/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/events: generic events and event I/O AC_CONFIG_FILES([src/events/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/vegas: VEGAS Monte Carlo adaptive integration AC_CONFIG_FILES([src/vegas/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/mci: multi-channel integration and event generation AC_CONFIG_FILES([src/mci/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/phase_space: parameterization and evaluation AC_CONFIG_FILES([src/phase_space/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/blha: BLHA support (NLO data record) AC_CONFIG_FILES([src/blha/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/gosam: GoSAM support (NLO amplitudes) AC_CONFIG_FILES([src/gosam/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/openloops: OpenLoops support (NLO amplitudes) AC_CONFIG_FILES([src/openloops/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/recola: Recola support (NLO amplitudes) AC_CONFIG_FILES([src/recola/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/fks: FKS subtraction algorithm AC_CONFIG_FILES([src/fks/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/matching: matching algorithms AC_CONFIG_FILES([src/matching/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/variables: Implementation of variable lists AC_CONFIG_FILES([src/variables/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/model_features: Model access and methods AC_CONFIG_FILES([src/model_features/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/models: Model-specific code AC_CONFIG_FILES([src/models/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/threshold AC_CONFIG_FILES([src/threshold/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/models/threeshl_bundle AC_CONFIG_FILES([src/models/threeshl_bundle/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/process_integration AC_CONFIG_FILES([src/process_integration/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/transforms: event transforms and event API AC_CONFIG_FILES([src/transforms/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/whizard-core AC_CONFIG_FILES([src/whizard-core/Makefile]) ###--------------------------------------------------------------------- +### Subdirectory src/api + +AC_CONFIG_FILES([src/api/Makefile]) + +###--------------------------------------------------------------------- +### Subdirectory src/main + +AC_CONFIG_FILES([src/main/Makefile]) + +###--------------------------------------------------------------------- ### Subdirectory src/prebuilt AC_CONFIG_FILES([src/prebuilt/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/feynmf AC_CONFIG_FILES([src/feynmf/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory src/gamelan: WHIZARD graphics package AC_CONFIG_FILES([src/gamelan/Makefile]) AC_CONFIG_FILES([src/gamelan/whizard-gml], [chmod u+x src/gamelan/whizard-gml]) ###--------------------------------------------------------------------- ### Subdirectory share AC_CONFIG_FILES([share/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory share/doc AC_CONFIG_FILES([share/doc/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory share/models AC_CONFIG_FILES([share/models/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory share/cuts AC_CONFIG_FILES([share/cuts/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory share/beam-sim AC_CONFIG_FILES([share/beam-sim/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory share/susy AC_CONFIG_FILES([share/susy/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory share/examples AC_CONFIG_FILES([share/examples/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory share/tests AC_CONFIG_FILES([share/tests/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory share/muli AC_CONFIG_FILES([share/muli/Makefile]) ###--------------------------------------------------------------------- -### Subdirectory share/interfaces - -AC_CONFIG_FILES([share/interfaces/Makefile]) -AC_CONFIG_FILES([share/interfaces/py_whiz_setup.py]) - -###--------------------------------------------------------------------- ### Subdirectory share/SM_tt_threshold_data AC_CONFIG_FILES([share/SM_tt_threshold_data/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory share/gui AC_CONFIG_FILES([share/gui/Makefile]) ###--------------------------------------------------------------------- ### Subdirectory tests AC_CONFIG_FILES([tests/Makefile]) AC_CONFIG_FILES([tests/models/Makefile]) AC_CONFIG_FILES([tests/models/UFO/Makefile]) AC_CONFIG_FILES([tests/models/UFO/SM/Makefile]) AC_CONFIG_FILES([tests/models/UFO/MSSM/Makefile]) AC_CONFIG_FILES([tests/unit_tests/Makefile]) AC_CONFIG_FILES([tests/functional_tests/Makefile]) AC_CONFIG_FILES([tests/ext_tests_mssm/Makefile]) AC_CONFIG_FILES([tests/ext_tests_nmssm/Makefile]) AC_CONFIG_FILES([tests/ext_tests_ilc/Makefile]) AC_CONFIG_FILES([tests/ext_tests_shower/Makefile]) AC_CONFIG_FILES([tests/ext_tests_nlo/Makefile]) AC_CONFIG_FILES([tests/ext_tests_nlo_add/Makefile]) AC_CONFIG_FILES([tests/unit_tests/run_whizard_ut.sh], [chmod u+x tests/unit_tests/run_whizard_ut.sh]) +AC_CONFIG_FILES([tests/unit_tests/run_whizard_ut_c.sh], + [chmod u+x tests/unit_tests/run_whizard_ut_c.sh]) +AC_CONFIG_FILES([tests/unit_tests/run_whizard_ut_cc.sh], + [chmod u+x tests/unit_tests/run_whizard_ut_cc.sh]) AC_CONFIG_FILES([tests/functional_tests/run_whizard.sh], [chmod u+x tests/functional_tests/run_whizard.sh]) AC_CONFIG_FILES([tests/ext_tests_mssm/run_whizard.sh], [chmod u+x tests/ext_tests_mssm/run_whizard.sh]) AC_CONFIG_FILES([tests/ext_tests_nmssm/run_whizard.sh], [chmod u+x tests/ext_tests_nmssm/run_whizard.sh]) AC_CONFIG_FILES([tests/ext_tests_ilc/run_whizard.sh], [chmod u+x tests/ext_tests_ilc/run_whizard.sh]) AC_CONFIG_FILES([tests/ext_tests_shower/run_whizard.sh], [chmod u+x tests/ext_tests_shower/run_whizard.sh]) AC_CONFIG_FILES([tests/ext_tests_nlo/run_whizard.sh], [chmod u+x tests/ext_tests_nlo/run_whizard.sh]) AC_CONFIG_FILES([tests/ext_tests_nlo_add/run_whizard.sh], [chmod u+x tests/ext_tests_nlo_add/run_whizard.sh]) ###-------------------------------------------------------------------- ### Subdirectory scripts AC_CONFIG_FILES([scripts/Makefile]) AC_CONFIG_FILES([scripts/whizard-config], [chmod u+x scripts/whizard-config]) AC_CONFIG_FILES([scripts/whizard-setup.sh], [chmod u+x scripts/whizard-setup.sh]) AC_CONFIG_FILES([scripts/whizard-setup.csh], [chmod u+x scripts/whizard-setup.csh]) ### ONLY_FULL }}} ### ONLY_CIRCE1_AND_FULL {{{ ###-------------------------------------------------------------------- ### CIRCE1 subdirectory files AC_CONFIG_FILES([circe1/Makefile]) AC_CONFIG_FILES([circe1/src/Makefile]) AC_CONFIG_FILES([circe1/minuit/Makefile]) AC_CONFIG_FILES([circe1/tools/Makefile]) AC_CONFIG_FILES([circe1/share/Makefile]) AC_CONFIG_FILES([circe1/share/data/Makefile]) AC_CONFIG_FILES([circe1/share/doc/Makefile]) ### ONLY_CIRCE1_AND_FULL }}} ### ONLY_CIRCE2_AND_FULL {{{ ###-------------------------------------------------------------------- ### CIRCE2 subdirectory files AC_CONFIG_FILES([circe2/Makefile]) AC_CONFIG_FILES([circe2/src/Makefile]) AC_CONFIG_FILES([circe2/share/Makefile]) AC_CONFIG_FILES([circe2/share/doc/Makefile]) AC_CONFIG_FILES([circe2/share/examples/Makefile]) AC_CONFIG_FILES([circe2/share/data/Makefile]) AC_CONFIG_FILES([circe2/share/tests/Makefile]) AC_CONFIG_FILES([circe2/tests/Makefile]) AC_CONFIG_FILES([circe2/tests/test_wrapper.sh], [chmod u+x circe2/tests/test_wrapper.sh]) AC_CONFIG_FILES([circe2/tests/circe2_tool.sh], [chmod u+x circe2/tests/circe2_tool.sh]) AC_CONFIG_FILES([circe2/tests/generate.sh], [chmod u+x circe2/tests/generate.sh]) ### ONLY_CIRCE2_AND_FULL }}} ### ONLY_OMEGA_AND_FULL {{{ ###-------------------------------------------------------------------- ### OMEGA subdirectory files AC_CONFIG_FILES([omega/Makefile]) AC_CONFIG_FILES([omega/bin/Makefile]) AC_CONFIG_FILES([omega/lib/Makefile]) AC_CONFIG_FILES([omega/models/Makefile]) AC_CONFIG_FILES([omega/src/Makefile]) AC_CONFIG_FILES([omega/share/Makefile]) AC_CONFIG_FILES([omega/share/doc/Makefile]) AC_CONFIG_FILES([omega/extensions/Makefile]) AC_CONFIG_FILES([omega/extensions/people/Makefile]) AC_CONFIG_FILES([omega/extensions/people/jr/Makefile]) AC_CONFIG_FILES([omega/extensions/people/tho/Makefile]) AC_CONFIG_FILES([omega/tests/Makefile]) AC_CONFIG_FILES([omega/tests/UFO/Makefile]) AC_CONFIG_FILES([omega/tests/UFO/SM/Makefile]) AC_CONFIG_FILES([omega/tests/UFO/MSSM/Makefile]) AC_CONFIG_FILES([omega/tools/Makefile]) AC_CONFIG_FILES([omega/scripts/Makefile]) AC_CONFIG_FILES([omega/scripts/omega-config], [chmod u+x omega/scripts/omega-config]) # Copy config.mli to the build directory (otherwise ocamlc and/or # ocamlopt would create one on their own). ###-------------------------------------------------------------------- AC_CONFIG_FILES([omega/src/config.ml]) case "$srcdir" in .) ;; *) $MKDIR_P ./omega/src rm -f ./omega/src/config.mli cp $srcdir/omega/src/config.mli ./omega/src/config.mli 1>/dev/null 2>&1;; esac ###-------------------------------------------------------------------- ### ONLY_OMEGA_AND_FULL }}} ### ONLY_VAMP_AND_FULL {{{ ###-------------------------------------------------------------------- ### VAMP subdirectory files AC_CONFIG_FILES([vamp/Makefile]) AC_CONFIG_FILES([vamp/src/Makefile]) AC_CONFIG_FILES([vamp/share/Makefile]) AC_CONFIG_FILES([vamp/share/doc/Makefile]) AC_CONFIG_FILES([vamp/tests/Makefile]) ### ONLY_VAMP_AND_FULL }}} ######################################################################## ###--------------------------------------------------------------------- ### Final output AC_OUTPUT() ### ONLY_FULL {{{ ######################################################################## ###--------------------------------------------------------------------- ### Final output WO_SUMMARY() ### ONLY_FULL }}} ######################################################################## Index: trunk/m4/ax_python.m4 =================================================================== --- trunk/m4/ax_python.m4 (revision 8428) +++ trunk/m4/ax_python.m4 (revision 8429) @@ -1,110 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_python.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PYTHON -# -# DESCRIPTION -# -# This macro does a complete Python development environment check. -# -# It recurses through several python versions (from 2.1 to 2.6 in this -# version), looking for an executable. When it finds an executable, it -# looks to find the header files and library. -# -# It sets PYTHON_BIN to the name of the python executable, -# PYTHON_INCLUDE_DIR to the directory holding the header files, and -# PYTHON_LIB to the name of the Python library. -# -# This macro calls AC_SUBST on PYTHON_BIN (via AC_CHECK_PROG), -# PYTHON_INCLUDE_DIR and PYTHON_LIB. -# -# LICENSE -# -# Copyright (c) 2008 Michael Tindal -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 14 - -AC_DEFUN([AX_PYTHON], -[AC_MSG_CHECKING(for python build information) -AC_MSG_RESULT([]) -for python in python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python; do -AC_CHECK_PROGS(PYTHON_BIN, [$python]) -ax_python_bin=$PYTHON_BIN -if test x$ax_python_bin != x; then - AC_CHECK_LIB($ax_python_bin, main, ax_python_lib=$ax_python_bin, ax_python_lib=no) - if test x$ax_python_lib == xno; then - AC_CHECK_LIB(${ax_python_bin}m, main, ax_python_lib=${ax_python_bin}m, ax_python_lib=no) - fi - if test x$ax_python_lib != xno; then - ax_python_header=`$ax_python_bin -c "from distutils.sysconfig import *; print(get_config_var('CONFINCLUDEPY'))"` - if test x$ax_python_header != x; then - break; - fi - fi -fi -done -if test x$ax_python_bin = x; then - ax_python_bin=no -else - $PYTHON_BIN --version >>conftest.log 2>&1 - - version_string=`$GREP -i 'Python' conftest.log | head -1` - ax_python_major_version=[`echo $version_string | $SED -n -e 's|Python .*\([0-9][0-9]*\.[0-9][0-9]*\)\.[0-9][0-9]*|\1|p'`] - rm -f conftest.log - PYTHON_MAJOR_VERSION=$ax_python_major_version - AC_SUBST([PYTHON_MAJOR_VERSION]) -fi -if test x$ax_python_header = x; then - ax_python_header=no -fi -if test x$ax_python_lib = x; then - ax_python_lib=no -fi - - -AC_MSG_RESULT([ results of the Python check:]) -AC_MSG_RESULT([ Binary: $ax_python_bin]) -AC_MSG_RESULT([ Major version: $ax_python_major_version]) -AC_MSG_RESULT([ Library: $ax_python_lib]) -AC_MSG_RESULT([ Include Dir: $ax_python_header]) - -if test x$ax_python_header != xno; then - PYTHON_INCLUDE_DIR=$ax_python_header - AC_SUBST(PYTHON_INCLUDE_DIR) -fi -if test x$ax_python_lib != xno; then - PYTHON_LIB=$ax_python_lib - AC_SUBST(PYTHON_LIB) -fi -AM_CONDITIONAL([PYTHON_AVAILABLE], - [test $ax_python_bin != "no"]) -])dnl Index: trunk/m4/aux.m4 =================================================================== --- trunk/m4/aux.m4 (revision 8428) +++ trunk/m4/aux.m4 (revision 8429) @@ -1,337 +1,340 @@ dnl aux.m4 -- Auxiliary macros for WHIZARD's configure.ac dnl dnl Horizontal line for readability: AC_DEFUN([WO_HLINE], [AC_MSG_NOTICE([--------------------------------------------------------------])]) dnl Message at the beginning of a configure section AC_DEFUN([WO_CONFIGURE_SECTION], [WO_HLINE() AC_MSG_NOTICE([--- ]$1[ ---]) AC_MSG_NOTICE([]) ]) dnl Define a variable and export it dnl WO_SET(variable, value) AC_DEFUN([WO_SET], [$1=$2 AC_SUBST($1)]) dnl Add a list of names to the list of output or executable files dnl WO_OUTFILES(subdir, files) AC_DEFUN([WO_OUTFILES], [for file in $2; do OUTFILES="$OUTFILES $1/$file"; done]) dnl WO_EXECUTABLES(subdir, files) AC_DEFUN([WO_EXECUTABLES], [for file in $2; do OUTFILES="$OUTFILES $1/$file"; EXECUTABLES="$EXECUTABLES $1/$file" done]) dnl Add a list of names to the list of automake-controlled files AC_DEFUN([WO_AUTOMAKE], [for file in $2; do AUTOMAKEFILES="$AUTOMAKEFILES $1/$file"; done]) dnl This adds a package which resides in a subdirectory of 'src' dnl The `variable' is inserted into AC_SUBST; it will refer to enl the package subdirectory in Makefiles. The package dnl resides in src/XXX and and optionally has a Makefile (or similar). dnl WO_PACKAGE(variable, identifier [,Makefiles [,Executables]]) AC_DEFUN([WO_PACKAGE], [WO_SET($1,src/$2) ifelse($#, 3, [WO_OUTFILES($$1, $3) WO_AUTOMAKE($$1, $3)]) ifelse($#, 4, [WO_OUTFILES($$1, $3) WO_EXECUTABLES($$1, $4)]) ]) dnl This is like WO_PACKAGE, but it calls AC_ARG_ENABLE in addition. dnl If the package `id' is disabled or the 'file' is not found, dnl the variable `var' is set to "no". dnl WO_PACKAGE_ENABLE(var, id, help, file [,Makefiles [,Executables]]) AC_DEFUN([WO_PACKAGE_ENABLE], [AC_ARG_ENABLE($2,[$3]) if test "$enable_$2" = "no"; then AC_MSG_CHECKING([for src/$2/$4]) WO_SET($1, no) AC_MSG_RESULT([(disabled)]) else AC_CHECK_FILE(src/$2/$4, enable_$2=yes, enable_$2=no) if test "$enable_$2" = "no"; then WO_SET($1, no) else ifelse($#, 4, [WO_PACKAGE($1, $2)]) ifelse($#, 5, [WO_PACKAGE($1, $2, $5)]) ifelse($#, 6, [WO_PACKAGE($1, $2, $5, $6)]) fi fi ]) dnl The same, but disabled by default. dnl If the package `id' is disabled or the 'file' is not found, dnl the variable `var' is set to "no". dnl WO_PACKAGE_DISABLE(var, id, help, file [,Makefiles [,Executables]]) AC_DEFUN([WO_PACKAGE_DISABLE], [AC_ARG_ENABLE($2,[$3]) if test "$enable_$2" = "yes"; then AC_CHECK_FILE(src/$2/$4, enable_$2=yes, enable_$2=no) if test "$enable_$2" = "no"; then WO_SET($1, no) else ifelse($#, 4, [WO_PACKAGE($1, $2)]) ifelse($#, 5, [WO_PACKAGE($1, $2, $5)]) ifelse($#, 6, [WO_PACKAGE($1, $2, $5, $6)]) fi else enable_$2="no" AC_MSG_CHECKING([for src/$2/$4]) WO_SET($1, no) AC_MSG_RESULT([(disabled)]) fi ]) dnl Extension of AC_PATH_PROG: Search for libraries for which the name dnl is not exactly known (because it may have the version number in it) dnl Set output variables $var, $var_DIR, $var_LIB accordingly dnl WO_PATH_LIB(var, id, name-list, path) AC_DEFUN([WO_PATH_LIB], [AC_CACHE_CHECK(for $3, wo_cv_path_$1, [case "$$1" in /*) wo_cv_path_$1="$$1" # User-supplied path ;; *) IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy=$4 for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. unset wo_cv_path_$1 ac_pwd=`pwd` if test -d "$ac_dir"; then cd $ac_dir for ac_word in $3; do test -f "$ac_word" && wo_cv_path_$1="$ac_dir/$ac_word" done cd $ac_pwd fi if test -n "$wo_cv_path_$1"; then break fi done IFS="$ac_save_ifs" if test -z "$wo_cv_path_$1"; then wo_cv_path_$1="no" fi ;; esac ]) $1=$wo_cv_path_$1 if test "$$1" != "no"; then $1_DIR=`echo $$1 | sed -e 's|/lib$2.*\.a$||'` $1_LIB=`echo $$1 | sed -e 's|^.*/lib\($2.*\)\.a$|\1|'` fi AC_SUBST($1) AC_SUBST($1_DIR) AC_SUBST($1_LIB) ]) dnl WHIZARD summary AC_DEFUN([WO_SUMMARY],[dnl WO_VERSION=AC_PACKAGE_VERSION() function echo_summary () { echo "|=============================================================================|" echo "| |" echo "| WW WW WW WW WW WWWWWW WW WWWWW WWWW |" echo "| WW WW WW WW WW WW WW WWWW WW WW WW WW |" echo "| WW WW WW WW WWWWWWW WW WW WW WW WWWWW WW WW |" echo "| WWWW WWWW WW WW WW WW WWWWWWWW WW WW WW WW |" echo "| WW WW WW WW WW WWWWWW WW WW WW WW WWWW |" echo "| |" echo "| |" echo "| W |" echo "| sW |" echo "| WW |" echo "| sWW |" echo "| WWW |" echo "| wWWW |" echo "| wWWWW |" echo "| WW WW |" echo "| WW WW |" echo "| wWW WW |" echo "| wWW WW |" echo "| WW WW |" echo "| WW WW |" echo "| WW WW |" echo "| WW WW |" echo "| WW WW |" echo "| WW WW |" echo "| wwwwww WW WW |" echo "| WWWWWww WW WW |" echo "| WWWWWwwwww WW WW |" echo "| wWWWwwwwwWW WW |" echo "| wWWWWWWWWWWwWWW WW |" echo "| wWWWWW wW WWWWWWW |" echo "| WWWW wW WW wWWWWWWWwww |" echo "| WWWW wWWWWWWWwwww |" echo "| WWWW WWWW WWw |" echo "| WWWWww WWWW |" echo "| WWWwwww WWWW |" echo "| wWWWWwww wWWWWW |" echo "| WwwwwwwwwWWW |" echo "| |" echo "| |" echo "| |" echo "| by: Wolfgang Kilian, Thorsten Ohl, Juergen Reuter |" echo "| with contributions from Christian Speckner |" echo "| Contact: |" echo "| |" echo "| if you use WHIZARD please cite: |" echo "| W. Kilian, T. Ohl, J. Reuter, Eur.Phys.J.C71 (2011) 1742 |" echo "| @<:@arXiv: 0708.4233 @<:@hep-ph@:>@@:>@ |" echo "| M. Moretti, T. Ohl, J. Reuter, arXiv: hep-ph/0102195 |" echo "| |" echo "|=============================================================================|" echo "**************************************************************" echo "--------------------------------------------------------------" echo "--- AC_PACKAGE_NAME() CONFIGURATION SUMMARY ---" echo "**************************************************************" echo "Package name: AC_PACKAGE_NAME()" echo "Version: AC_PACKAGE_VERSION()" echo "Date: $PACKAGE_DATE" echo "Status: $PACKAGE_STATUS" echo "**************************************************************" echo "--- Compilers ---" echo "--------------------------------------------------------------" echo "Fortran compiler: --- $FC_VENDOR ---" echo " Version: --- $FC_VERSION ---" echo " Flags: --- $FCFLAGS ---" echo " float precision: --- $FC_PRECISION ---" if test "$FC_DEBUG_ON" = ".true."; then echo " debug features: --- on ---" else echo " debug features: --- off ---" fi if test "$FC_OPENMP_OFF" = "!" ; then echo " OpenMP: --- on with max. $FC_OPENMP_DEFAULT_MAX_THREADS threads" elif test "$FC_OPENMP_ON" = "!" ; then echo " OpenMP: --- off ---" fi if test "$MPI_AVAILABLE" = "yes" ; then echo " MPI: --- on ---" echo " MPI Library: --- $MPI_LIBRARY, v$MPI_VERSION ---" else echo " MPI: --- off ---" fi echo "--------------------------------------------------------------" echo " OCaml compiler: --- $OCAMLOPT ---" echo " Version: --- $OCAMLVERSION ---" echo " Flags: --- $OCAMLFLAGS ---" echo "--------------------------------------------------------------" echo " C++ compiler: --- $CXX --- @<:@interfaces only@:>@" echo " Flags: --- $CXXFLAGS ---" +echo "--------------------------------------------------------------" +echo " Python compiler: --- $PYTHON --- @<:@interfaces only@:>@" +echo " Version: --- $PYTHON_FULL_VERSION ---" echo "**************************************************************" echo "--- Internal and shipped packages ---" echo "--------------------------------------------------------------" echo "VAMP (multi-channel adapative integrator) : yes, v$WO_VERSION" if test "$OCAMLOPT" != "no" ; then echo "O'Mega (matrix element generator) : yes, v$WO_VERSION" else echo "O'Mega (matrix element generator) : no" fi echo "CIRCE1 (lepton beam spectra, parameterized): yes, v$WO_VERSION" echo "CIRCE2 (lepton beam spectra, sampled) : yes, v$WO_VERSION" if test "$OCAMLOPT" != "no" ; then echo " incl. tools for generating new spectra : yes" else echo " incl. tools for generating new spectra : no" fi echo "--------------------------------------------------------------" if test "$PYTHIA6_AVAILABLE_FLAG" = ".true." ; then echo "PYTHIA6 (parton showering & hadronization) : yes, v6.427" echo "TAUOLA (tau decays) : yes" else echo "PYTHIA6 (parton showering & hadronization) : no" echo "TAUOLA (tau decays) : no" fi echo "StdHEP (event format) : yes, v5.06.01" echo "--------------------------------------------------------------" echo "--- External packages ---" echo "--------------------------------------------------------------" if test "$HEPMC_AVAILABLE_FLAG" = "yes" ; then echo "HepMC (event format): yes, v$HEPMC_VERSION" else echo "HepMC (event format): no" fi if test "$LCIO_AVAILABLE_FLAG" = "yes" ; then echo "LCIO (event format) : yes, v$LCIO_VERSION" else echo "LCIO (event format) : no" fi if test "$LHAPDF5_AVAILABLE_FLAG" = ".true." ; then echo "LHAPDF (PDF sets) : yes, v$LHAPDF_FULL_VERSION" elif test "$LHAPDF6_AVAILABLE_FLAG" = ".true." ; then echo "LHAPDF (PDF sets) : yes, v$LHAPDF_FULL_VERSION" echo " PDF set path: $LHAPDF_PDFSETS_PATH" else echo "LHAPDF (PDF sets) : no" fi if test "$HOPPET_AVAILABLE_FLAG" = ".true." ; then echo "HOPPET (PDF match.) : yes, v$HOPPET_VERSION" else echo "HOPPET (PDF match.) : no" fi if test "$FASTJET_AVAILABLE_FLAG" = "yes" ; then echo "FastJet (clustering): yes, v$FASTJET_VERSION" else echo "FastJet (clustering): no" fi if test "$PYTHIA8_AVAILABLE_FLAG" = ".true." ; then echo "PYTHIA8 (QCD) : yes, v$PYTHIA8_VERSION" else echo "PYTHIA8 (QCD) : no" fi if test "$GOSAM_AVAILABLE_FLAG" = ".true." ; then echo "GoSam (OLP) : yes, v$GOSAM_VERSION" else echo "GoSam (OLP) : no" fi if test "$OPENLOOPS_AVAILABLE_FLAG" = ".true." ; then echo "OpenLoops (OLP) : yes, v$OPENLOOPS_VERSION" echo " path : $OPENLOOPS_DIR" else echo "OpenLoops (OLP) : no" fi if test "$RECOLA_AVAILABLE_FLAG" = ".true." ; then echo "RECOLA (OLP) : yes, v$RECOLA_VERSION" echo " path : $RECOLA_DIR" else echo "RECOLA (OLP) : no" fi if test "$LOOPTOOLS_AVAILABLE_FLAG" = ".true." ; then echo "LoopTools : yes" else echo "LoopTools : no" fi echo "--------------------------------------------------------------" if test "$SIP_ACTIVE" = "yes" ; then echo "**************************************************************" echo "*** MAC OS X Darwin system with ***" echo "*** Security Integrity Protection (SIP) enabled. ***" echo "*** 'make check' will not work, and most likely also ***" echo "*** 'make installcheck' will not work. The installed ***" echo "*** WHIZARD will work as intended. ***" echo "**************************************************************" fi } echo_summary | tee config-summary.log ]) Index: trunk/m4/dl.m4 =================================================================== --- trunk/m4/dl.m4 (revision 8428) +++ trunk/m4/dl.m4 (revision 8429) @@ -1,76 +1,76 @@ dnl dl.m4 -- checks for dynamic-linking library dnl ### Activate dynamic linking: look for 'dlopen' AC_DEFUN([WO_PROG_DL], [dnl AC_ARG_ENABLE([dl], [AS_HELP_STRING([--enable-dl], [enable libdl for creating/loading process libraries on-the-fly [[yes]]])], [], [enable_dl="yes"]) RTLD_LAZY_VALUE=0 RTLD_NOW_VALUE=0 RTLD_GLOBAL_VALUE=0 RTLD_LOCAL_VALUE=0 AC_SUBST([RTLD_LAZY_VALUE]) AC_SUBST([RTLD_NOW_VALUE]) AC_SUBST([RTLD_GLOBAL_VALUE]) AC_SUBST([RTLD_LOCAL_VALUE]) if test "$enable_dl" = "yes"; then AC_LANG_PUSH([C]) AC_SEARCH_LIBS([dlopen], [dl], [], [enable_dl="no"]) AC_CHECK_HEADERS([dlfcn.h],[],[enable_dl="no"]) if test "$enable_dl" = "yes"; then AC_MSG_CHECKING([for the values of RTLD_LAZY & friends]) AC_RUN_IFELSE([AC_LANG_SOURCE([dnl #include #include int main () { FILE* handle = fopen ("conftest.out", "w"); if (!handle) return 1; if (!fprintf (handle, "RTLD_LAZY_VALUE=%i\n", RTLD_LAZY)) return 1; if (!fprintf (handle, "RTLD_NOW_VALUE=%i\n", RTLD_NOW)) return 1; if (!fprintf (handle, "RTLD_GLOBAL_VALUE=%i\n", RTLD_GLOBAL)) return 1; if (!fprintf (handle, "RTLD_LOCAL_VALUE=%i\n", RTLD_LOCAL)) return 1; if (fclose (handle)) return 1; } ])],[. ./conftest.out],[enable_dl="no"]) if test "$enable_dl" = "yes"; then AC_MSG_RESULT([success]) else AC_MSG_RESULT([failed]) fi fi AC_MSG_CHECKING([for $CC flag to produce position-independent code]) AC_MSG_RESULT([$lt_prog_compiler_pic_CC]) CFLAGS_PIC=$lt_prog_compiler_pic_CC AC_SUBST([CFLAGS_PIC]) AC_LANG_POP() else AC_MSG_CHECKING([for dl (dynamic linking)]) CFLAGS_PIC='' AC_SUBST([CFLAGS_PIC]) AC_MSG_RESULT([(disabled)]) fi AM_CONDITIONAL([DL_AVAILABLE], [test "$enable_dl" = "yes"]) ### For make check of an installed WHIZARD we have to take ### care of library interdependencies on MAC OS X case $host in *-darwin*) - DYLD_FLAGS="DYLD_LIBRARY_PATH=\$(pwd)/../../src/.libs:\$(pwd)/../../src/whizard-core/.libs:\$(pwd)/../../omega/src/.libs:\${DYLD_LIBRARY_PATH}; export DYLD_LIBRARY_PATH" ;; + DYLD_FLAGS="DYLD_LIBRARY_PATH=\$(pwd)/../../src/.libs:\$(pwd)/../../src/main/.libs:\$(pwd)/../../omega/src/.libs:\${DYLD_LIBRARY_PATH}; export DYLD_LIBRARY_PATH" ;; *) DYLD_FLAGS="" ;; esac AC_SUBST(DYLD_FLAGS) ]) AC_DEFUN([WO_CC_FLAGS], [dnl ]) Index: trunk/m4/api_python.m4 =================================================================== --- trunk/m4/api_python.m4 (revision 0) +++ trunk/m4/api_python.m4 (revision 8429) @@ -0,0 +1,33 @@ +dnl pythia8.m4 -- checks for PYTHIA 8 library +dnl + +AC_DEFUN([WO_PROG_PYTHON_API], +[dnl +AC_REQUIRE([AX_PYTHON_DEVEL]) + +AC_ARG_ENABLE([python], + [AS_HELP_STRING([--enable-python], + [enable PYTHON/Cython API for WHIZARD [[no]]])], + [], [enable_python="no"]) + +if test "$enable_python" = "yes"; then + AC_MSG_CHECKING([for PYTHON API]) + AC_MSG_RESULT([(trying to enable)]) + # ACX_CHECK_PYTHIA8() + #if test "$enable_python" = "yes"; then + #fi +else + AC_MSG_CHECKING([for PYTHON API]) + AC_MSG_RESULT([(disabled)]) +fi + +if test "$enable_python" = "yes"; then + PYTHON_API_AVAILABLE_FLAG=".true." +else + PYTHON_API_AVAILABLE_FLAG=".false." +fi +AC_SUBST([PYTHON_API_AVAILABLE_FLAG]) + +AM_CONDITIONAL([PYTHON_API_AVAILABLE], [test "$enable_python" = "yes"]) +]) + Index: trunk/m4/ax_python_devel.m4 =================================================================== --- trunk/m4/ax_python_devel.m4 (revision 0) +++ trunk/m4/ax_python_devel.m4 (revision 8429) @@ -0,0 +1,347 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_python_devel.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PYTHON_DEVEL([version]) +# +# DESCRIPTION +# +# Note: Defines as a precious variable "PYTHON_VERSION". Don't override it +# in your configure.ac. +# +# This macro checks for Python and tries to get the include path to +# 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LIBS) output +# variables. It also exports $(PYTHON_EXTRA_LIBS) and +# $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code. +# +# You can search for some particular version of Python by passing a +# parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please +# note that you *have* to pass also an operator along with the version to +# match, and pay special attention to the single quotes surrounding the +# version number. Don't use "PYTHON_VERSION" for this: that environment +# variable is declared as precious and thus reserved for the end-user. +# +# This macro should work for all versions of Python >= 2.1.0. As an end +# user, you can disable the check for the python version by setting the +# PYTHON_NOVERSIONCHECK environment variable to something else than the +# empty string. +# +# If you need to use this macro for an older Python version, please +# contact the authors. We're always open for feedback. +# +# LICENSE +# +# Copyright (c) 2009 Sebastian Huber +# Copyright (c) 2009 Alan W. Irwin +# Copyright (c) 2009 Rafael Laboissiere +# Copyright (c) 2009 Andrew Collier +# Copyright (c) 2009 Matteo Settenvini +# Copyright (c) 2009 Horst Knorr +# Copyright (c) 2013 Daniel Mullner +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 21 + +AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL]) +AC_DEFUN([AX_PYTHON_DEVEL],[ + # + # Allow the use of a (user set) custom python version + # + AC_ARG_VAR([PYTHON_VERSION],[The installed Python + version to use, for example '2.3'. This string + will be appended to the Python interpreter + canonical name.]) + + AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]]) + + AM_CONDITIONAL([PYTHON_AVAILABLE], + [test -z "$PYTHON"]) + if test -z "$PYTHON"; then + AC_MSG_NOTICE([error: Cannot find python$PYTHON_VERSION in your system path]) + AC_MSG_NOTICE([error: disabling all python tests and interfaces]) + PYTHON_VERSION="" + PYTHON_LINKABLE="no" + else + # + # Check for a version of Python >= 2.1.0 + # + AC_MSG_CHECKING([for a version of Python >= '2.1.0']) + ac_supports_python_ver=`$PYTHON -c "import sys; \ + ver = sys.version.split ()[[0]]; \ + print (ver >= '2.1.0')"` + if test "$ac_supports_python_ver" != "True"; then + if test -z "$PYTHON_NOVERSIONCHECK"; then + AC_MSG_RESULT([no]) + AC_MSG_FAILURE([ +This version of the AC@&t@_PYTHON_DEVEL macro +doesn't work properly with versions of Python before +2.1.0. You may need to re-run configure, setting the +variables PYTHON_CPPFLAGS, PYTHON_LIBS, PYTHON_SITE_PKG, +PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand. +Moreover, to disable this check, set PYTHON_NOVERSIONCHECK +to something else than an empty string. +]) + else + AC_MSG_RESULT([skip at user request]) + fi + else + AC_MSG_RESULT([yes]) + fi + + # + # if the macro parameter ``version'' is set, honour it + # + if test -n "$1"; then + AC_MSG_CHECKING([for a version of Python $1]) + ac_supports_python_ver=`$PYTHON -c "import sys; \ + ver = sys.version.split ()[[0]]; \ + print (ver $1)"` + if test "$ac_supports_python_ver" = "True"; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AC_MSG_WARN([Tests and interfaces requires Python $1. +If you have it installed, but it isn't the default Python +interpreter in your system path, please pass the PYTHON_VERSION +variable to configure. See ``configure --help'' for reference. +]) + PYTHON_VERSION="" + fi + fi + + # + # Check if you have distutils, else fail + # + AC_MSG_CHECKING([for the distutils Python package]) + ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` + if test $? -eq 0; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AC_MSG_WARN([cannot import Python module "distutils". +Please check your Python installation. The error was: +$ac_distutils_result]) + PYTHON_VERSION="" + fi + + # + # Check for Python include path + # + AC_MSG_CHECKING([for Python include path]) + if test -z "$PYTHON_CPPFLAGS"; then + python_path=`$PYTHON -c "import distutils.sysconfig; \ + print (distutils.sysconfig.get_python_inc ());"` + plat_python_path=`$PYTHON -c "import distutils.sysconfig; \ + print (distutils.sysconfig.get_python_inc (plat_specific=1));"` + if test -n "${python_path}"; then + if test "${plat_python_path}" != "${python_path}"; then + python_path="-I$python_path -I$plat_python_path" + else + python_path="-I$python_path" + fi + fi + PYTHON_CPPFLAGS=$python_path + fi + AC_MSG_RESULT([$PYTHON_CPPFLAGS]) + AC_SUBST([PYTHON_CPPFLAGS]) + + # + # Check for Python library path + # + AC_MSG_CHECKING([for Python library path]) + if test -z "$PYTHON_LIBS"; then + # (makes two attempts to ensure we've got a version number + # from the interpreter) + ac_python_version=`cat<]], + [[Py_Initialize();]]) + ],[pythonexists=yes],[pythonexists=no]) + AC_LANG_POP([C]) + # turn back to default flags + CPPFLAGS="$ac_save_CPPFLAGS" + LIBS="$ac_save_LIBS" + LDFLAGS="$ac_save_LDFLAGS" + + AC_MSG_RESULT([$pythonexists]) + + if test ! "x$pythonexists" = "xyes"; then + AC_MSG_WARN([ + Could not link test program to Python. Maybe the main Python library has been + installed in some non-standard library path. If so, pass it to configure, + via the LIBS environment variable. + Example: ./configure LIBS="-L/usr/non-standard-path/python/lib" + ============================================================================ + WARNING! + You probably have to install the development version of the Python package + for your distribution. The exact name of this package varies among them. + PYTHON interfacing will be disabled. + ============================================================================ + ]) + PYTHON_VERSION="" + PYTHON_LINKABLE="no" + else + PYTHON_LINKABLE="yes" + fi + + + # + # all done! + # + fi + AC_SUBST([PYTHON_LINKABLE]) + AM_CONDITIONAL([PYTHON_LINK], [test "$PYTHON_LINKABLE" != "no"]) +]) Index: trunk/src/physics/Makefile.am =================================================================== --- trunk/src/physics/Makefile.am (revision 8428) +++ trunk/src/physics/Makefile.am (revision 8429) @@ -1,203 +1,200 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement physics definitions and functions ## for use in the WHIZARD generator. ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libphysics.la check_LTLIBRARIES = libphysics_ut.la libphysics_la_SOURCES = \ physics_defs.f90 \ c_particles.f90 \ lorentz.f90 \ sm_physics.f90 \ sm_qcd.f90 \ sm_qed.f90 \ shower_algorithms.f90 libphysics_ut_la_SOURCES = \ sm_physics_uti.f90 sm_physics_ut.f90 \ sm_qcd_uti.f90 sm_qcd_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = physics.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libphysics_la_SOURCES:.f90=.$(FCMOD)} + libphysics_Modules = \ ${libphysics_la_SOURCES:.f90=} \ ${libphysics_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libphysics_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../combinatorics/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libphysics_la_SOURCES) $(libphysics_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libphysics_la_SOURCES) $(libphysics_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -execmoddir = $(pkglibdir)/mod/physics -nodist_execmod_HEADERS = \ - physics_defs.$(FC_MODULE_EXT) \ - c_particles.$(FC_MODULE_EXT) \ - lorentz.$(FC_MODULE_EXT) \ - sm_physics.$(FC_MODULE_EXT) - ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw physics.stamp: $(PRELUDE) $(srcdir)/physics.nw $(POSTLUDE) @rm -f physics.tmp @touch physics.tmp for src in $(libphysics_la_SOURCES) $(libphysics_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f physics.tmp physics.stamp $(libphysics_la_SOURCES) $(libphysics_ut_la_SOURCES): physics.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f physics.stamp; \ $(MAKE) $(AM_MAKEFLAGS) physics.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f physics.stamp physics.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/system/system_dependencies.f90.in =================================================================== --- trunk/src/system/system_dependencies.f90.in (revision 8428) +++ trunk/src/system/system_dependencies.f90.in (revision 8429) @@ -1,386 +1,373 @@ ! WHIZARD <> <> ! ! Copyright (C) 1999-2020 by ! Wolfgang Kilian ! Thorsten Ohl ! Juergen Reuter ! with contributions from ! cf. main AUTHORS file ! ! WHIZARD is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2, or (at your option) ! any later version. ! ! WHIZARD is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! module system_dependencies !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! All character strings indented by 7 blanks will be automatically ! split into chunks respecting the FORTRAN line length constraint by ! configure. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @FC_OPENMP_HEADER@ implicit none public ! Program version character(*), parameter :: WHIZARD_VERSION = "@PACKAGE_VERSION@" character(*), parameter :: WHIZARD_DATE = "@PACKAGE_DATE@" ! System paths ! These are used for testing without existing installation character(*), parameter :: WHIZARD_TEST_BASICS_MODPATH = & "@BUILDDIR@/src/basics" character(*), parameter :: WHIZARD_TEST_UTILITIES_MODPATH = & "@BUILDDIR@/src/utilities" character(*), parameter :: WHIZARD_TEST_COMBINATORICS_MODPATH = & "@BUILDDIR@/src/combinatorics" character(*), parameter :: WHIZARD_TEST_SYSTEM_MODPATH = & "@BUILDDIR@/src/system" character(*), parameter :: WHIZARD_TEST_PHYSICS_MODPATH = & "@BUILDDIR@/src/physics" character(*), parameter :: WHIZARD_TEST_ME_MODPATH = & "@BUILDDIR@/src/matrix_elements" character(*), parameter :: WHIZARD_TEST_MODELS_MODPATH = & "@BUILDDIR@/src/models" character(*), parameter :: WHIZARD_TEST_THRESHOLD_MODPATH = & "@BUILDDIR@/src/threshold" character(*), parameter :: WHIZARD_TEST_OMEGA_MODPATH = & "@BUILDDIR@/omega/src" - character(*), parameter :: WHIZARD_TEST_CORE_LIBPATH = & - "@BUILDDIR@/src/whizard-core" + character(*), parameter :: WHIZARD_TEST_MAIN_LIBPATH = & + "@BUILDDIR@/src/main" character(*), parameter :: WHIZARD_TEST_OMEGA_BINPATH = & "@BUILDDIR@/omega/bin" character(*), parameter :: WHIZARD_TEST_SRC_LIBPATH = & "@BUILDDIR@/src" character(*), parameter :: WHIZARD_TEST_HEPMC_LIBPATH = & "@BUILDDIR@/src/hepmc" character(*), parameter :: WHIZARD_TEST_LCIO_LIBPATH = & "@BUILDDIR@/src/lcio" character(*), parameter :: WHIZARD_TEST_HOPPET_LIBPATH = & "@BUILDDIR@/src/hoppet" character(*), parameter :: WHIZARD_TEST_LOOPTOOLS_LIBPATH = & "@BUILDDIR@/src/looptools" character(*), parameter :: WHIZARD_TEST_MODELPATH = & "@SRCDIR@/share/models" character(*), parameter :: WHIZARD_TEST_MODELPATH_UFO = & "@SRCDIR@/share/models/UFO" character(*), parameter :: WHIZARD_TEST_MODELS_LIBPATH = & "@BUILDDIR@/src/models" character(*), parameter :: WHIZARD_TEST_SUSYPATH = & "@SRCDIR@/share/susy" character(*), parameter :: WHIZARD_TEST_GMLPATH= & "@BUILDDIR@/src/gamelan" character(*), parameter :: WHIZARD_TEST_CUTSPATH = & "@SRCDIR@/share/cuts" character(*), parameter :: WHIZARD_TEST_SHAREPATH = & "@SRCDIR@/share" character(*), parameter :: WHIZARD_TEST_TESTDATAPATH = & "@SRCDIR@/share/test" character(*), parameter :: WHIZARD_TEST_TEXPATH = & "@SRCDIR@/src/feynmf" character(*), parameter :: WHIZARD_TEST_CIRCE2PATH = & "@SRCDIR@/circe2/share/data" character(*), parameter :: WHIZARD_TEST_BEAMSIMPATH = & "@SRCDIR@/share/beam-sim" character(*), parameter :: WHIZARD_TEST_MULIPATH = & "@SRCDIR@/share/muli" character(*), parameter :: PDF_BUILTIN_TEST_DATAPATH = & "@SRCDIR@/share/pdf_builtin" ! WHIZARD-specific include flags character(*), parameter :: WHIZARD_TEST_INCLUDES = & "-I" // WHIZARD_TEST_MODELS_MODPATH // " " // & "-I" // WHIZARD_TEST_THRESHOLD_MODPATH // " " // & "-I" // WHIZARD_TEST_OMEGA_MODPATH // " " // & "-I" // WHIZARD_TEST_ME_MODPATH // " " // & "-I" // WHIZARD_TEST_PHYSICS_MODPATH // " " // & "-I" // WHIZARD_TEST_SYSTEM_MODPATH // " " // & "-I" // WHIZARD_TEST_COMBINATORICS_MODPATH // " " // & "-I" // WHIZARD_TEST_UTILITIES_MODPATH // " " // & "-I" // WHIZARD_TEST_BASICS_MODPATH // " " // & "@OPENLOOPS_INCLUDES@ @RECOLA_INCLUDES@" ! WHIZARD-specific link flags character(*), parameter :: WHIZARD_TEST_LDFLAGS = & - "-L" // WHIZARD_TEST_CORE_LIBPATH // " " // & + "-L" // WHIZARD_TEST_MAIN_LIBPATH // " " // & "-L" // WHIZARD_TEST_SRC_LIBPATH // " " // & "-L" // WHIZARD_TEST_HEPMC_LIBPATH // " " // & "-L" // WHIZARD_TEST_LCIO_LIBPATH // " " // & "-L" // WHIZARD_TEST_HOPPET_LIBPATH // " " // & "-L" // WHIZARD_TEST_LOOPTOOLS_LIBPATH // " " // & "-lwhizard_main -lwhizard -lomega " // & + "@RPC_CFLAGS@ " // & "@LDFLAGS_HEPMC@ @LDFLAGS_LCIO@ @LDFLAGS_HOPPET@ " // & "@LDFLAGS_LOOPTOOLS@ @LDFLAGS_OPENLOOPS@ " // & "@LDFLAGS_RECOLA@" ! Libtool character(*), parameter :: WHIZARD_LIBTOOL_TEST = & "@BUILDDIR@/libtool" ! System paths ! These are used for the installed version character(*), parameter :: PREFIX = & "@prefix@" character(*), parameter :: EXEC_PREFIX = & "@exec_prefix@" character(*), parameter :: BINDIR = & "@bindir@" character(*), parameter :: LIBDIR = & "@libdir@" character(*), parameter :: INCLUDEDIR = & "@includedir@" character(*), parameter :: DATAROOTDIR = & "@datarootdir@" + character(*), parameter :: FMODDIR = & + "@FMODDIR@" character(*), parameter :: PKGLIBDIR = LIBDIR // "/whizard" character(*), parameter :: PKGDATADIR = DATAROOTDIR // "/whizard" character(*), parameter :: PKGTEXDIR = DATAROOTDIR // "/texmf/whizard" character(*), parameter :: PKGCIRCE2DIR = DATAROOTDIR // "/circe2" - character(*), parameter :: WHIZARD_BASICS_MODPATH = & - PKGLIBDIR // "/mod/basics" - character(*), parameter :: WHIZARD_UTILITIES_MODPATH = & - PKGLIBDIR // "/mod/utilities" - character(*), parameter :: WHIZARD_COMBINATORICS_MODPATH = & - PKGLIBDIR // "/mod/combinatorics" - character(*), parameter :: WHIZARD_SYSTEM_MODPATH = & - PKGLIBDIR // "/mod/system" - character(*), parameter :: WHIZARD_PHYSICS_MODPATH = & - PKGLIBDIR // "/mod/physics" - character(*), parameter :: WHIZARD_ME_MODPATH = & - PKGLIBDIR // "/mod/matrix_elements" - character(*), parameter :: WHIZARD_MODELS_MODPATH = & - PKGLIBDIR // "/mod/models" - character(*), parameter :: WHIZARD_THRESHOLD_MODPATH = & - PKGLIBDIR // "/mod/threshold" - character(*), parameter :: WHIZARD_OMEGA_MODPATH = & - INCLUDEDIR // "/omega" + character(*), parameter :: WHIZARD_MODPATH = & + FMODDIR // "/whizard" + character(*), parameter :: OMEGA_MODPATH = & + FMODDIR // "/omega" + character(*), parameter :: MODELS_MODPATH = & + FMODDIR // "/models" character(*), parameter :: WHIZARD_OMEGA_BINPATH = & BINDIR character(*), parameter :: WHIZARD_OMEGA_LIBPATH = & LIBDIR character(*), parameter :: WHIZARD_MODELPATH = & PKGDATADIR // "/models" character(*), parameter :: WHIZARD_MODELPATH_UFO = & PKGDATADIR // "/models/UFO" character(*), parameter :: WHIZARD_MODELS_LIBPATH = & PKGLIBDIR // "/models" character(*), parameter :: WHIZARD_SUSYPATH = & PKGDATADIR // "/susy" character(*), parameter :: WHIZARD_GMLPATH= & PKGLIBDIR // "/gamelan" character(*), parameter :: WHIZARD_SHAREPATH = & PKGDATADIR character(*), parameter :: WHIZARD_TESTDATAPATH = & PKGDATADIR // "/test" character(*), parameter :: WHIZARD_CUTSPATH = & PKGDATADIR // "/cuts" character(*), parameter :: WHIZARD_TEXPATH = & PKGTEXDIR character(*), parameter :: WHIZARD_CIRCE2PATH = & PKGCIRCE2DIR // "/data" character(*), parameter :: WHIZARD_BEAMSIMPATH = & PKGDATADIR // "/beam-sim" character(*), parameter :: WHIZARD_MULIPATH = & PKGDATADIR // "/muli" character(*), parameter :: PDF_BUILTIN_DATAPATH = & PKGDATADIR // "/pdf_builtin" ! WHIZARD-specific include flags character(*), parameter :: WHIZARD_INCLUDES = & - "-I" // WHIZARD_MODELS_MODPATH // " " // & - "-I" // WHIZARD_THRESHOLD_MODPATH // " " // & - "-I" // WHIZARD_OMEGA_MODPATH // " " // & - "-I" // WHIZARD_ME_MODPATH // " " // & - "-I" // WHIZARD_PHYSICS_MODPATH // " " // & - "-I" // WHIZARD_SYSTEM_MODPATH // " " // & - "-I" // WHIZARD_COMBINATORICS_MODPATH // " " // & - "-I" // WHIZARD_UTILITIES_MODPATH // " " // & - "-I" // WHIZARD_BASICS_MODPATH // " " // & + "-I" // WHIZARD_MODPATH // " " // & + "-I" // OMEGA_MODPATH // " " // & + "-I" // MODELS_MODPATH // " " // & "@OPENLOOPS_INCLUDES@ @RECOLA_INCLUDES@" ! WHIZARD-specific link flags character(*), parameter :: WHIZARD_LDFLAGS = & "-L" // WHIZARD_OMEGA_LIBPATH // " " // & "-lwhizard_main -lwhizard -lomega " // & + "@RPC_CFLAGS@ " // & "@LDFLAGS_HEPMC@ @LDFLAGS_LCIO@ @LDFLAGS_HOPPET@ " // & "@LDFLAGS_LOOPTOOLS@ @LDFLAGS_OPENLOOPS@ " // & "@LDFLAGS_RECOLA@" ! Libtool character(*), parameter :: WHIZARD_LIBTOOL = & PKGLIBDIR // "/libtool" ! Fortran compiler character(*), parameter :: DEFAULT_FC = & "@FC@" character(*), parameter :: DEFAULT_FCFLAGS = & "@FCFLAGS_PROFILING@ @FCFLAGS_OPENMP@ @FCFLAGS_MPI@ @FCFLAGS@" character(*), parameter :: DEFAULT_FCFLAGS_PIC = & "@FCFLAGS_PIC@" character(*), parameter :: DEFAULT_FC_SRC_EXT = & ".@FC_SRC_EXT@" character(*), parameter :: DEFAULT_FC_PRECISION = & "@FC_PRECISION@" ! Fortran compiler character(*), parameter :: DEFAULT_CC = & "@CC@" character(*), parameter :: DEFAULT_CFLAGS = & "@CFLAGS@" character(*), parameter :: DEFAULT_CFLAGS_PIC = & "@CFLAGS_PIC@" logical, parameter :: CC_IS_GNU = @CC_IS_GNU@ logical, parameter :: CC_HAS_QUADMATH = @CC_HAS_QUADMATH@ ! Object files character(*), parameter :: DEFAULT_OBJ_EXT = & ".@OBJ_EXT@" ! Linker character(*), parameter :: DEFAULT_LD = & "@LD@" character(*), parameter :: DEFAULT_LDFLAGS = & "" character(*), parameter :: DEFAULT_LDFLAGS_SO = "-shared" character(*), parameter :: DEFAULT_LDFLAGS_STATIC = & "@LDFLAGS_STATIC@" character(*), parameter :: DEFAULT_LDFLAGS_HEPMC = & "@LDFLAGS_HEPMC@" character(*), parameter :: DEFAULT_LDFLAGS_LCIO = & "@LDFLAGS_LCIO@" character(*), parameter :: DEFAULT_LDFLAGS_HOPPET = & "@LDFLAGS_HOPPET@" character(*), parameter :: DEFAULT_LDFLAGS_LOOPTOOLS = & "@LDFLAGS_LOOPTOOLS@" character(*), parameter :: DEFAULT_SHRLIB_EXT = "@SHRLIB_EXT@" character(*), parameter :: DEFAULT_FC_SHRLIB_EXT = "so" ! Pack/unpack character(*), parameter :: DEFAULT_PACK_CMD = "tar -czf" character(*), parameter :: DEFAULT_UNPACK_CMD = "tar -xzf" character(*), parameter :: DEFAULT_PACK_EXT = ".tgz" ! Make character(*), parameter :: DEFAULT_MAKEFLAGS = & "@DEFAULT_MAKEFLAGS@" ! LHAPDF library character(*), parameter :: LHAPDF_PDFSETS_PATH = & "@LHAPDF_PDFSETS_PATH@" ! Available methods for event analysis display character(*), parameter :: EVENT_ANALYSIS = & "@EVENT_ANALYSIS@" character(*), parameter :: EVENT_ANALYSIS_PS = & "@EVENT_ANALYSIS_PS@" character(*), parameter :: EVENT_ANALYSIS_PDF = & "@EVENT_ANALYSIS_PDF@" ! Programs used for event analysis display character(*), parameter :: PRG_LATEX = & "@LATEX@" character(*), parameter :: PRG_MPOST = & "@MPOST@" character(*), parameter :: PRG_DVIPS = & "@DVIPS@" character(*), parameter :: PRG_PS2PDF = & "@PS2PDF@" ! Programs and libraries used for NLO calculations ! GoSam character(*), parameter :: GOSAM_DIR = & "@GOSAM_DIR@" character(*), parameter :: GOLEM_DIR = & "@GOLEM_DIR@" character(*), parameter :: FORM_DIR = & "@FORM_DIR@" character(*), parameter :: QGRAF_DIR = & "@QGRAF_DIR@" character(*), parameter :: NINJA_DIR = & "@NINJA_DIR@" character(*), parameter :: SAMURAI_DIR = & "@SAMURAI_DIR@" ! OpenLoops character(*), parameter :: OPENLOOPS_DIR = & "@OPENLOOPS_DIR@" character(*), parameter :: RECOLA_DIR = & "@RECOLA_DIR@" ! Hardwired options for batch-mode processing character(*), parameter :: OPT_LATEX = & "-halt-on-error" character(*), parameter :: OPT_MPOST = & "@MPOSTFLAG@ -halt-on-error" ! dlopen parameters integer, parameter :: & RTLD_LAZY = @RTLD_LAZY_VALUE@ , & RTLD_NOW = @RTLD_NOW_VALUE@ , & RTLD_GLOBAL = @RTLD_GLOBAL_VALUE@ , & RTLD_LOCAL = @RTLD_LOCAL_VALUE@ ! Misc logical, parameter :: LHAPDF5_AVAILABLE = @LHAPDF5_AVAILABLE_FLAG@ logical, parameter :: LHAPDF6_AVAILABLE = @LHAPDF6_AVAILABLE_FLAG@ logical, parameter :: HEPMC2_AVAILABLE = @HEPMC2_AVAILABLE_FLAG@ logical, parameter :: HEPMC3_AVAILABLE = @HEPMC3_AVAILABLE_FLAG@ + logical, parameter :: LCIO_AVAILABLE = "@LCIO_AVAILABLE_FLAG@" == "yes" logical, parameter :: HOPPET_AVAILABLE = @HOPPET_AVAILABLE_FLAG@ logical, parameter :: PYTHIA6_AVAILABLE = @PYTHIA6_AVAILABLE_FLAG@ logical, parameter :: PYTHIA8_AVAILABLE = @PYTHIA8_AVAILABLE_FLAG@ logical, parameter :: GOSAM_AVAILABLE = @GOSAM_AVAILABLE_FLAG@ logical, parameter :: OPENLOOPS_AVAILABLE = @OPENLOOPS_AVAILABLE_FLAG@ logical, parameter :: RECOLA_AVAILABLE = @RECOLA_AVAILABLE_FLAG@ contains ! Subroutines that depend on configure settings ! OpenMP wrapper routines, work independent of OpenMP status function openmp_is_active () result (flag) logical :: flag @FC_OPENMP_ON@ flag = .true. @FC_OPENMP_OFF@ flag = .false. end function openmp_is_active subroutine openmp_set_num_threads (num) integer, intent(in) :: num @FC_OPENMP_ON@ call omp_set_num_threads (num) end subroutine openmp_set_num_threads function openmp_get_num_threads () result (num) integer :: num @FC_OPENMP_ON@ num = omp_get_num_threads () @FC_OPENMP_OFF@ num = 1 end function openmp_get_num_threads function openmp_get_max_threads () result (num) integer :: num @FC_OPENMP_ON@ num = omp_get_max_threads () @FC_OPENMP_OFF@ num = 1 end function openmp_get_max_threads function openmp_get_default_max_threads () result (num) integer :: num num = @FC_OPENMP_DEFAULT_MAX_THREADS@ end function openmp_get_default_max_threads end module system_dependencies Index: trunk/src/system/Makefile.am =================================================================== --- trunk/src/system/Makefile.am (revision 8428) +++ trunk/src/system/Makefile.am (revision 8429) @@ -1,236 +1,238 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement OS interactions of WHIZARD ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libsystem.la check_LTLIBRARIES = libsystem_ut.la COMMON_F90 = \ system_defs.f90 \ signal_interface.c \ sprintf_interface.c \ diagnostics.f90 \ formats.f90 \ cputime.f90 MPI_F90 = \ os_interface.f90_mpi SERIAL_F90 = \ os_interface.f90_serial EXTRA_DIST = \ $(COMMON_F90) \ $(SERIAL_F90) \ $(MPI_F90) nodist_libsystem_la_SOURCES = \ system_dependencies.f90 \ debug_master.f90 \ os_interface.f90 \ $(COMMON_F90) DISTCLEANFILES = os_interface.f90 if FC_USE_MPI os_interface.f90: os_interface.f90_mpi -cp -f $< $@ else os_interface.f90: os_interface.f90_serial -cp -f $< $@ endif libsystem_ut_la_SOURCES = \ os_interface_uti.f90 os_interface_ut.f90 \ formats_uti.f90 formats_ut.f90 \ cputime_uti.f90 cputime_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = system.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + system_dependencies.$(FCMOD) \ + debug_master.$(FCMOD) \ + system_defs.$(FCMOD) \ + cputime.$(FCMOD) \ + diagnostics.$(FCMOD) \ + formats.$(FCMOD) \ + os_interface.$(FCMOD) + libsystem_Modules = \ $(nodist_libsystem_la_SOURCES:.f90=) \ $(libsystem_ut_la_SOURCES:.f90=) Modules: Makefile @for module in $(libsystem_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(nodist_libsystem_la_SOURCES) $(libsystem_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES += Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(nodist_libsystem_la_SOURCES) $(libsystem_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend -## Install the modules used by generated matrix element code -execmoddir = $(pkglibdir)/mod/system -nodist_execmod_HEADERS = \ - system_dependencies.$(FC_MODULE_EXT) \ - debug_master.$(FC_MODULE_EXT) \ - system_defs.$(FC_MODULE_EXT) \ - diagnostics.$(FC_MODULE_EXT) \ - os_interface.$(FC_MODULE_EXT) - -SUFFIXES = .lo .$(FC_MODULE_EXT) +SUFFIXES = .lo .$(FCMOD) # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE FILTER = -filter "sed 's/defn MPI:/defn/'" PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw system.stamp: $(PRELUDE) $(srcdir)/system.nw $(POSTLUDE) @rm -f system.tmp @touch system.tmp for src in $(COMMON_F90) $(libsystem_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done for src in $(SERIAL_F90:.f90_serial=.f90); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src'_serial'; \ done for src in $(MPI_F90:.f90_mpi=.f90); do \ $(NOTANGLE) -R[[$$src]] $(FILTER) $^ | $(CPIF) $$src'_mpi'; \ done @mv -f system.tmp system.stamp $(COMMON_F90) $(SERIAL_F90) $(MPI_F90) $(libsystem_ut_la_SOURCES): system.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f system.stamp; \ $(MAKE) $(AM_MAKEFLAGS) system.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.f90_serial *.f90_mpi *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.f90_serial *.f90_mpi *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f system.stamp system.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/me_methods/Makefile.am =================================================================== --- trunk/src/me_methods/Makefile.am (revision 8428) +++ trunk/src/me_methods/Makefile.am (revision 8429) @@ -1,205 +1,210 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement quantum field theory concepts ## such as model representation and quantum numbers. ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libme_methods.la check_LTLIBRARIES = libme_methods_ut.la libme_methods_la_SOURCES = \ prc_core.f90 \ prc_test_core.f90 \ prc_template_me.f90 \ prc_omega.f90 \ prc_external.f90 \ prc_threshold.f90 libme_methods_ut_la_SOURCES = \ prc_template_me_uti.f90 prc_template_me_ut.f90 \ prc_omega_uti.f90 prc_omega_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = me_methods.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libme_methods_la_SOURCES:.f90=.$(FCMOD)} + libme_methods_Modules = \ ${libme_methods_la_SOURCES:.f90=}\ ${libme_methods_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libme_methods_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../combinatorics/Modules \ ../parsing/Modules \ ../expr_base/Modules \ ../physics/Modules \ ../qft/Modules \ ../types/Modules \ ../matrix_elements/Modules \ ../beams/Modules \ ../variables/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libme_methods_la_SOURCES) $(libme_methods_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libme_methods_la_SOURCES) $(libme_methods_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../parsing -I../physics -I../qft -I../expr_base -I../types -I../matrix_elements -I../particles -I../beams -I ../variables -I../fastjet -I../pdf_builtin -I../lhapdf ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw me_methods.stamp: $(PRELUDE) $(srcdir)/me_methods.nw $(POSTLUDE) @rm -f me_methods.tmp @touch me_methods.tmp for src in \ $(libme_methods_la_SOURCES) \ $(libme_methods_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f me_methods.tmp me_methods.stamp $(libme_methods_la_SOURCES) $(libme_methods_ut_la_SOURCES): me_methods.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f me_methods.stamp; \ $(MAKE) $(AM_MAKEFLAGS) me_methods.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f me_methods.stamp me_methods.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/rng/Makefile.am =================================================================== --- trunk/src/rng/Makefile.am (revision 8428) +++ trunk/src/rng/Makefile.am (revision 8429) @@ -1,201 +1,201 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement standard algorithms for WHIZARD ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = librng.la check_LTLIBRARIES = librng_ut.la librng_la_SOURCES = \ rng_base.f90 \ selectors.f90 \ rng_tao.f90 \ rng_stream.f90 \ dispatch_rng.f90 librng_ut_la_SOURCES = \ rng_base_uti.f90 rng_base_ut.f90 \ selectors_uti.f90 selectors_ut.f90 \ rng_tao_uti.f90 rng_tao_ut.f90 \ rng_stream_uti.f90 rng_stream_ut.f90 \ dispatch_rng_uti.f90 dispatch_rng_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = rng.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${librng_la_SOURCES:.f90=.$(FCMOD)} + librng_Modules = ${librng_la_SOURCES:.f90=} ${librng_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(librng_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../variables/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(librng_la_SOURCES) $(librng_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(librng_la_SOURCES) $(librng_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend ## Dependencies across directories and packages, if not automatically generated -rng_tao.lo: ../../vamp/src/tao_random_numbers.$(FC_MODULE_EXT) +rng_tao.lo: ../../vamp/src/tao_random_numbers.$(FCMOD) # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../../vamp/src -I../variables -I../expr_base -I../parsing -I../types -I../fastjet -I../physics -I../combinatorics ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -## and by the user code library -#execmoddir = $(pkglibdir)/mod/rng -#nodist_execmod_HEADERS = - ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw rng.stamp: $(PRELUDE) $(srcdir)/rng.nw $(POSTLUDE) @rm -f rng.tmp @touch rng.tmp for src in $(librng_la_SOURCES) $(librng_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f rng.tmp rng.stamp $(librng_la_SOURCES) $(librng_ut_la_SOURCES): rng.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f rng.stamp; \ $(MAKE) $(AM_MAKEFLAGS) rng.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f rng.stamp rng.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/pythia8/Makefile.am =================================================================== --- trunk/src/pythia8/Makefile.am (revision 8428) +++ trunk/src/pythia8/Makefile.am (revision 8429) @@ -1,221 +1,227 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement the LHA user process interface for WHIZARD ## and the interface to Pythia8. ## The files in this directory end up in an auxiliary libtool library. noinst_LTLIBRARIES = libwo_pythia8.la check_LTLIBRARIES = libwo_pythia8_ut.la if PYTHIA8_AVAILABLE libwo_pythia8_la_SOURCES = \ LHAWhizard_events.h \ LHAWhizard.h \ LHAWhizard.cpp \ LHAWhizardWrap.cpp \ Pythia8Wrap.h \ Pythia8Wrap.cpp libwo_pythia8_la_CPPFLAGS = $(PYTHIA8_CXXFLAGS) else libwo_pythia8_la_SOURCES = \ LHAWhizard_dummy.f90 \ Pythia8Wrap_dummy.f90 endif libwo_pythia8_la_SOURCES += \ whizard_lha.f90 \ pythia8.f90 libwo_pythia8_ut_la_SOURCES = \ whizard_lha_uti.f90 \ whizard_lha_ut.f90 \ pythia8_uti.f90 \ pythia8_ut.f90 SRC_FROM_NOWEB = \ whizard_lha.f90 \ pythia8.f90 \ whizard_lha_uti.f90 whizard_lha_ut.f90 \ pythia8_uti.f90 pythia8_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = pythia8.nw + +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + pythia8.$(FCMOD) whizard_lha.$(FCMOD) + libwo_pythia8_Modules = ${libwo_pythia8_la_SOURCES:.f90=} ${libwo_pythia8_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libwo_pythia8_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../events/Modules \ ../utilities/Modules \ ../particles/Modules \ ../physics/Modules \ ../qft/Modules \ ../rng/Modules \ ../types/Modules \ ../testing/Modules \ ../system/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libwo_pythia8_la_SOURCES) $(libwo_pythia8_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done ; \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libwo_pythia8_la_SOURCES) ${libwo_pythia8_ut_la_SOURCES} @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../events -I../utilities -I../testing -I../system -I../physics -I../particles -I../qft -I../rng -I../types -I../combinatorics -I../fastjet -I../variables ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE FILTER = if FC_USE_MPI FILTER += -filter "sed 's/defn MPI:/defn/'" endif PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw Pythia8.stamp: $(PRELUDE) $(srcdir)/pythia8.nw $(POSTLUDE) @rm -f Pythia8.tmp @touch Pythia8.tmp for src in $(SRC_FROM_NOWEB); do \ $(NOTANGLE) -R[[$$src]] $(FILTER) $^ | $(CPIF) $$src; \ done @mv -f Pythia8.tmp Pythia8.stamp $(SRC_FROM_NOWEB): Pythia8.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f Pythia8.stamp; \ $(MAKE) $(AM_MAKEFLAGS) Pythia8.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f Pythia8.stamp Pythia8.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/beams/Makefile.am =================================================================== --- trunk/src/beams/Makefile.am (revision 8428) +++ trunk/src/beams/Makefile.am (revision 8429) @@ -1,232 +1,233 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libbeams.la check_LTLIBRARIES = libbeams_ut.la libbeams_la_SOURCES = \ beam_structures.f90 \ beams.f90 \ sf_mappings.f90 \ sf_aux.f90 \ sf_base.f90 \ sf_isr.f90 \ sf_epa.f90 \ sf_ewa.f90 \ sf_escan.f90 \ sf_gaussian.f90 \ sf_beam_events.f90 \ sf_circe1.f90 \ sf_circe2.f90 \ hoppet_interface.f90 \ sf_pdf_builtin.f90 \ sf_lhapdf.f90 \ pdf.f90 \ dispatch_beams.f90 libbeams_ut_la_SOURCES = \ beam_structures_uti.f90 beam_structures_ut.f90 \ beams_uti.f90 beams_ut.f90 \ sf_aux_uti.f90 sf_aux_ut.f90 \ sf_mappings_uti.f90 sf_mappings_ut.f90 \ sf_base_uti.f90 sf_base_ut.f90 \ sf_isr_uti.f90 sf_isr_ut.f90 \ sf_epa_uti.f90 sf_epa_ut.f90 \ sf_ewa_uti.f90 sf_ewa_ut.f90 \ sf_escan_uti.f90 sf_escan_ut.f90 \ sf_gaussian_uti.f90 sf_gaussian_ut.f90 \ sf_beam_events_uti.f90 sf_beam_events_ut.f90 \ sf_circe1_uti.f90 sf_circe1_ut.f90 \ sf_circe2_uti.f90 sf_circe2_ut.f90 \ sf_pdf_builtin_uti.f90 sf_pdf_builtin_ut.f90 \ sf_lhapdf_uti.f90 sf_lhapdf_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = beams.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libbeams_la_SOURCES:.f90=.$(FCMOD)} + libbeams_Modules = ${libbeams_la_SOURCES:.f90=} ${libbeams_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libbeams_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../combinatorics/Modules \ ../rng/Modules \ ../physics/Modules \ ../qft/Modules \ ../types/Modules \ ../particles/Modules \ ../variables/Modules \ ../qed_pdf/Modules # Explicit dependencies, not automatically generated -sf_circe1.lo: ../../circe1/src/circe1.$(FC_MODULE_EXT) -sf_circe2.lo: ../../circe2/src/circe2.$(FC_MODULE_EXT) -hoppet_interface.lo: ../lhapdf/lhapdf.$(FC_MODULE_EXT) -sf_pdf_builtin.lo: ../pdf_builtin/pdf_builtin.$(FC_MODULE_EXT) -sf_lhapdf.lo: ../lhapdf/lhapdf.$(FC_MODULE_EXT) +sf_circe1.lo: ../../circe1/src/circe1.$(FCMOD) +sf_circe2.lo: ../../circe2/src/circe2.$(FCMOD) +hoppet_interface.lo: ../lhapdf/lhapdf.$(FCMOD) +sf_pdf_builtin.lo: ../pdf_builtin/pdf_builtin.$(FCMOD) +sf_lhapdf.lo: ../lhapdf/lhapdf.$(FCMOD) $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libbeams_la_SOURCES) $(libbeams_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libbeams_la_SOURCES) $(libbeams_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../rng -I../physics -I../fastjet -I../qft -I../types -I../particles -I../../circe1/src -I../../circe2/src -I../pdf_builtin -I../lhapdf -I../qed_pdf -I../variables -I../expr_base -I../parsing ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -#execmoddir = $(pkglibdir)/mod/beams -#nodist_execmod_HEADERS = \# - ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw beams.stamp: $(PRELUDE) $(srcdir)/beams.nw $(POSTLUDE) @rm -f beams.tmp @touch beams.tmp for src in $(libbeams_la_SOURCES) $(libbeams_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f beams.tmp beams.stamp $(libbeams_la_SOURCES) $(libbeams_ut_la_SOURCES): beams.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f beams.stamp; \ $(MAKE) $(AM_MAKEFLAGS) beams.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f beams.stamp beams.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/qft/Makefile.am =================================================================== --- trunk/src/qft/Makefile.am (revision 8428) +++ trunk/src/qft/Makefile.am (revision 8429) @@ -1,205 +1,207 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement quantum field theory concepts ## such as model representation and quantum numbers. ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libqft.la check_LTLIBRARIES = libqft_ut.la libqft_la_SOURCES = \ model_data.f90 \ helicities.f90 \ colors.f90 \ flavors.f90 \ quantum_numbers.f90 \ state_matrices.f90 \ interactions.f90 \ evaluators.f90 libqft_ut_la_SOURCES = \ model_testbed.f90 \ colors_uti.f90 colors_ut.f90 \ state_matrices_uti.f90 state_matrices_ut.f90 \ interactions_uti.f90 interactions_ut.f90 \ evaluators_uti.f90 evaluators_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = qft.nw +# Modules and installation +# Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libqft_la_SOURCES:.f90=.$(FCMOD)} + # Dump module names into file Modules libqft_Modules = ${libqft_la_SOURCES:.f90=} ${libqft_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libqft_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../combinatorics/Modules \ ../expr_base/Modules \ ../physics/Modules \ ../types/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libqft_la_SOURCES) $(libqft_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libqft_la_SOURCES) $(libqft_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../expr_base -I../physics -I../types ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -#execmoddir = $(pkglibdir)/mod/qft -#nodist_execmod_HEADERS = \# - ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw qft.stamp: $(PRELUDE) $(srcdir)/qft.nw $(POSTLUDE) @rm -f qft.tmp @touch qft.tmp for src in $(libqft_la_SOURCES) $(libqft_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f qft.tmp qft.stamp $(libqft_la_SOURCES) $(libqft_ut_la_SOURCES): qft.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f qft.stamp; \ $(MAKE) $(AM_MAKEFLAGS) qft.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f qft.stamp qft.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/xdr/Makefile.am =================================================================== --- trunk/src/xdr/Makefile.am (revision 8428) +++ trunk/src/xdr/Makefile.am (revision 8429) @@ -1,147 +1,148 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory end up in an auxiliary libtool library. noinst_PROGRAMS = stdhep_rd stdhep_rd_SOURCES = StdHepRdr.cpp stdhep_rd_LDADD = libWOStdHep.la FC_SOURCE = xdr_wo_stdhep.f90 noinst_LTLIBRARIES = libWOStdHep.la libWOStdHep_la_SOURCES = \ WOXDR.hh \ WOXDR.cpp \ WOStdHep.hh \ WOStdHep.cpp \ WOStdHepRdr.h \ WOStdHepRdr.cpp \ $(FC_SOURCE) +# Modules and installation +# Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${FC_SOURCE:.f90=.$(FCMOD)} + libWOStdHep_Modules = ${FC_SOURCE:.f90=} Modules: Makefile @for module in $(libWOStdHep_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(FC_SOURCE) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(FC_SOURCE) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend -## Install the modules used by generated matrix element code -execmoddir = $(pkglibdir)/mod/xdr -nodist_execmod_HEADERS = \ - xdr_wo_stdhep.$(FC_MODULE_EXT) - -SUFFIXES = .lo .$(FC_MODULE_EXT) +SUFFIXES = .lo .$(FCMOD) # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard cleanup tasks ### Remove DWARF debug information on MAC OS X clean-macosx: -rm -rf stdhep_rd.dSYM .PHONY: clean-macosx clean-local: clean-macosx - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-local: -rm -f *~ Index: trunk/src/model_features/Makefile.am =================================================================== --- trunk/src/model_features/Makefile.am (revision 8428) +++ trunk/src/model_features/Makefile.am (revision 8429) @@ -1,208 +1,214 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory handle process definitions and models ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libmodel_features.la check_LTLIBRARIES = libmodel_features_ut.la libmodel_features_la_SOURCES = \ auto_components.f90 \ radiation_generator.f90 \ eval_trees.f90 \ models.f90 \ slha_interface.f90 libmodel_features_ut_la_SOURCES = \ auto_components_uti.f90 auto_components_ut.f90 \ radiation_generator_uti.f90 radiation_generator_ut.f90 \ eval_trees_uti.f90 eval_trees_ut.f90 \ models_uti.f90 models_ut.f90 \ slha_interface_uti.f90 slha_interface_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = model_features.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${nodist_libbasics_la_SOURCES:.f90=.$(FCMOD)} \ + ${libmodel_features_la_SOURCES:.f90=.$(FCMOD)} + libmodel_features_Modules = \ ${libmodel_features_la_SOURCES:.f90=} \ ${libmodel_features_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libmodel_features_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../combinatorics/Modules \ ../parsing/Modules \ ../physics/Modules \ ../qft/Modules \ ../expr_base/Modules \ ../types/Modules \ ../particles/Modules \ ../variables/Modules \ ../threshold/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libmodel_features_la_SOURCES) \ $(libmodel_features_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libmodel_features_la_SOURCES) \ $(libmodel_features_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../parsing -I../physics -I../qft -I../expr_base -I../types -I../particles -I../threshold -I../fastjet -I../variables ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw model_features.stamp: $(PRELUDE) $(srcdir)/model_features.nw $(POSTLUDE) @rm -f model_features.tmp @touch model_features.tmp for src in \ $(libmodel_features_la_SOURCES) \ $(libmodel_features_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f model_features.tmp model_features.stamp $(libmodel_features_la_SOURCES) $(libmodel_features_ut_la_SOURCES): model_features.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f model_features.stamp; \ $(MAKE) $(AM_MAKEFLAGS) model_features.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f model_features.stamp model_features.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/lhapdf/Makefile.am =================================================================== --- trunk/src/lhapdf/Makefile.am (revision 8428) +++ trunk/src/lhapdf/Makefile.am (revision 8429) @@ -1,82 +1,96 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory end up in an auxiliary libtool library. if LHAPDF6_AVAILABLE noinst_LTLIBRARIES = libLHAPDFWrap.la libLHAPDFWrap_la_SOURCES = \ LHAPDFWrap.cpp lhapdf.f90 libLHAPDFWrap_la_CPPFLAGS = $(LHAPDF_CXXFLAGS) else noinst_LTLIBRARIES = libLHAPDFWrap_dummy.la libLHAPDFWrap_dummy_la_SOURCES = \ LHAPDFWrap_dummy.f90 lhapdf.f90 endif +# Modules and installation +# Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + lhapdf.$(FCMOD) + +SUFFIXES = .lo .$(FCMOD) + +# Fortran90 module files are generated at the same time as object files +.lo.$(FCMOD): + @: +# touch $@ + AM_FCFLAGS = ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Explicit dependencies -lhapdf.lo: ../basics/kinds.$(FC_MODULE_EXT) +lhapdf.lo: ../basics/kinds.$(FCMOD) +lhapdf.$(FCMOD): lhapdf.lo AM_FCFLAGS += -I../basics MODULES= \ - lhapdf.$(FC_MODULE_EXT) + lhapdf.$(FCMOD) ######################################################################## ## Non-standard cleanup tasks ## Remove backup files maintainer-clean-local: -rm -f *~ ## Remove module files clean-local: -rm -f $(MODULES) if FC_SUBMODULES -rm -f *.smod endif Index: trunk/src/transforms/transforms.nw =================================================================== --- trunk/src/transforms/transforms.nw (revision 8428) +++ trunk/src/transforms/transforms.nw (revision 8429) @@ -1,14331 +1,14335 @@ % -*- ess-noweb-default-code-mode: f90-mode; noweb-default-code-mode: f90-mode; -*- % WHIZARD event transforms and event API %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Event Implementation} \includemodulegraph{transforms} With a process object and the associated methods at hand, we can generate events for elementary processes and, by subsequent transformation, for complete physical processes. We have the following modules: \begin{description} \item[event\_transforms] Abstract base type for transforming a physical process with process instance and included evaluators, etc., into a new object. The following modules extend this base type. \item[resonance\_insertion] Insert a resonance history into an event record, based on kinematical and matrix-element information. \item[recoil\_kinematics] Common kinematics routines for the ISR and EPA handlers. \item[isr\_photon\_handler] Transform collinear kinematics, as it results from applying ISR radiation, to non-collinear kinematics with a reasonable transverse-momentum distribution of the radiated photons, and also of the recoiling partonic event. \item[epa\_beam\_handler] For photon-initiated processes where the effective photon approximation is used in integration, to add in beam-particle recoil. Analogous to the ISR handler. \item[decays] Combine the elementary process with elementary decay processes and thus transform the elementary event into a decayed event, still at the parton level. \item[showers] Create QED/QCD showers out of the partons that are emitted by elementary processes. This should be interleaved with showering of radiated particles (structure functions) and multiple interactions. \item[hadrons] (not implemented yet) Apply hadronization to the partonic events, interleaved with hadron decays. (The current setup relies on hadronizing partonic events externally.) \item[tau\_decays] (not implemented yet) Let $\tau$ leptons decay taking full spin correlations into account. \item[evt\_nlo] Handler for fixed-order NLO events. \item[events] Combine all pieces to generate full events. \item[eio\_raw] Raw I/O for complete events. \end{description} @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Abstract Event Transforms} <<[[event_transforms.f90]]>>= <> module event_transforms <> <> use io_units use format_utils, only: write_separator use diagnostics use model_data use interactions use particles use subevents use rng_base use quantum_numbers, only: quantum_numbers_t use process, only: process_t use instances, only: process_instance_t use process_stacks <> <> <> <> contains <> end module event_transforms @ %def event_transforms @ \subsection{Abstract base type} Essentially, all methods are abstract, but some get minimal base versions. We know that there will be a random-number generator at top level, and that we will relate to an elementary process. The model is stored separately. It may contain modified settings that differ from the model instance stored in the process object. Each event transform contains a particle set that it can fill for further use. There is a flag that indicates this. We will collect event transforms in a list, therefore we include [[previous]] and [[next]] pointers. <>= public :: evt_t <>= type, abstract :: evt_t type(process_t), pointer :: process => null () type(process_instance_t), pointer :: process_instance => null () class(model_data_t), pointer :: model => null () class(rng_t), allocatable :: rng integer :: rejection_count = 0 logical :: particle_set_exists = .false. type(particle_set_t) :: particle_set class(evt_t), pointer :: previous => null () class(evt_t), pointer :: next => null () logical :: only_weighted_events = .false. contains <> end type evt_t @ %def evt_t @ Finalizer. In any case, we finalize the r.n.g. The process instance is a pointer and should not be finalized here. <>= procedure :: final => evt_final procedure :: base_final => evt_final <>= subroutine evt_final (evt) class(evt_t), intent(inout) :: evt if (allocated (evt%rng)) call evt%rng%final () if (evt%particle_set_exists) & call evt%particle_set%final () end subroutine evt_final @ %def evt_final @ Print out the type of the [[evt]]. <>= procedure (evt_write_name), deferred :: write_name <>= abstract interface subroutine evt_write_name (evt, unit) import class(evt_t), intent(in) :: evt integer, intent(in), optional :: unit end subroutine evt_write_name end interface @ %def evt_write_name @ <>= procedure (evt_write), deferred :: write <>= abstract interface subroutine evt_write (evt, unit, verbose, more_verbose, testflag) import class(evt_t), intent(in) :: evt integer, intent(in), optional :: unit logical, intent(in), optional :: verbose, more_verbose, testflag end subroutine evt_write end interface @ %def evt_write @ Output. We can print r.n.g. info. <>= procedure :: base_write => evt_base_write <>= subroutine evt_base_write (evt, unit, testflag, show_set) class(evt_t), intent(in) :: evt integer, intent(in), optional :: unit logical, intent(in), optional :: testflag, show_set integer :: u logical :: show u = given_output_unit (unit) show = .true.; if (present (show_set)) show = show_set if (associated (evt%process)) then write (u, "(3x,A,A,A)") "Associated process: '", & char (evt%process%get_id ()), "'" end if if (allocated (evt%rng)) then call evt%rng%write (u, 1) write (u, "(3x,A,I0)") "Number of tries = ", evt%rejection_count end if if (show) then if (evt%particle_set_exists) then call write_separator (u) call evt%particle_set%write (u, testflag = testflag) end if end if end subroutine evt_base_write @ %def evt_base_write @ Connect the transform with a process instance (and thus with the associated process). Use this to allocate the master random-number generator. This is not an initializer; we may initialize the transform by implementation-specific methods. <>= procedure :: connect => evt_connect procedure :: base_connect => evt_connect <>= subroutine evt_connect (evt, process_instance, model, process_stack) class(evt_t), intent(inout), target :: evt type(process_instance_t), intent(in), target :: process_instance class(model_data_t), intent(in), target :: model type(process_stack_t), intent(in), optional :: process_stack evt%process => process_instance%process evt%process_instance => process_instance evt%model => model call evt%process%make_rng (evt%rng) end subroutine evt_connect @ %def evt_connect @ Reset internal state. <>= procedure :: reset => evt_reset procedure :: base_reset => evt_reset <>= subroutine evt_reset (evt) class(evt_t), intent(inout) :: evt evt%rejection_count = 0 call evt%particle_set%final () evt%particle_set_exists = .false. end subroutine evt_reset @ %def evt_reset @ Prepare for a new event: reset internal state, if necessary. We provide MCI and term index of the parent process. <>= procedure (evt_prepare_new_event), deferred :: prepare_new_event <>= interface subroutine evt_prepare_new_event (evt, i_mci, i_term) import class(evt_t), intent(inout) :: evt integer, intent(in) :: i_mci, i_term end subroutine evt_prepare_new_event end interface @ %def evt_prepare_new_event @ Generate a weighted event, using a valid initiator event in the process instance, and the random-number generator. The returned event probability should be a number between zero and one that we can use for rejection. <>= procedure (evt_generate_weighted), deferred :: generate_weighted <>= abstract interface subroutine evt_generate_weighted (evt, probability) import class(evt_t), intent(inout) :: evt real(default), intent(inout) :: probability end subroutine evt_generate_weighted end interface @ %def evt_generate_weighted @ The unweighted event generation routine is actually implemented. It uses the random-number generator for simple rejection. Of course, the implementation may override this and implement a different way of generating an unweighted event. <>= procedure :: generate_unweighted => evt_generate_unweighted procedure :: base_generate_unweighted => evt_generate_unweighted <>= subroutine evt_generate_unweighted (evt) class(evt_t), intent(inout) :: evt real(default) :: p, x evt%rejection_count = 0 REJECTION: do evt%rejection_count = evt%rejection_count + 1 call evt%generate_weighted (p) if (signal_is_pending ()) return call evt%rng%generate (x) if (x < p) exit REJECTION end do REJECTION end subroutine evt_generate_unweighted @ %def evt_generate_unweighted @ Make a particle set. This should take the most recent evaluator (or whatever stores the event), factorize the density matrix if necessary, and store as a particle set. If applicable, the factorization should make use of the [[factorization_mode]] and [[keep_correlations]] settings. The values [[r]], if set, should control the factorization in more detail, e.g., bypassing the random-number generator. <>= procedure (evt_make_particle_set), deferred :: make_particle_set <>= interface subroutine evt_make_particle_set & (evt, factorization_mode, keep_correlations, r) import class(evt_t), intent(inout) :: evt integer, intent(in) :: factorization_mode logical, intent(in) :: keep_correlations real(default), dimension(:), intent(in), optional :: r end subroutine evt_make_particle_set end interface @ %def evt_make_particle_set @ Copy an existing particle set into the event record. This bypasses all methods to evaluate the internal state, but may be sufficient for further processing. <>= procedure :: set_particle_set => evt_set_particle_set <>= subroutine evt_set_particle_set (evt, particle_set, i_mci, i_term) class(evt_t), intent(inout) :: evt type(particle_set_t), intent(in) :: particle_set integer, intent(in) :: i_term, i_mci call evt%prepare_new_event (i_mci, i_term) evt%particle_set = particle_set evt%particle_set_exists = .true. end subroutine evt_set_particle_set @ %def evt_set_particle_set @ This procedure can help in the previous task, if the particles are available in the form of an interaction object. (We need two interactions, one with color summed over, and one with the probability distributed among flows.) We use the two values from the random number generator for factorizing the state. For testing purposes, we can provide those numbers explicitly. <>= procedure :: factorize_interactions => evt_factorize_interactions <>= subroutine evt_factorize_interactions & (evt, int_matrix, int_flows, factorization_mode, & keep_correlations, r, qn_select) class(evt_t), intent(inout) :: evt type(interaction_t), intent(in), target :: int_matrix, int_flows integer, intent(in) :: factorization_mode logical, intent(in) :: keep_correlations real(default), dimension(:), intent(in), optional :: r type(quantum_numbers_t), dimension(:), intent(in), optional :: qn_select real(default), dimension(2) :: x if (present (r)) then if (size (r) == 2) then x = r else call msg_bug ("event factorization: size of r array must be 2") end if else call evt%rng%generate (x) end if call evt%particle_set%init (evt%particle_set_exists, & int_matrix, int_flows, factorization_mode, x, & keep_correlations, keep_virtual=.true., qn_select = qn_select) evt%particle_set_exists = .true. end subroutine evt_factorize_interactions @ %def evt_factorize_interactions @ <>= public :: make_factorized_particle_set <>= subroutine make_factorized_particle_set (evt, factorization_mode, & keep_correlations, r, ii_term, qn_select) class(evt_t), intent(inout) :: evt integer, intent(in) :: factorization_mode logical, intent(in) :: keep_correlations real(default), dimension(:), intent(in), optional :: r integer, intent(in), optional :: ii_term type(quantum_numbers_t), dimension(:), intent(in), optional :: qn_select integer :: i_term type(interaction_t), pointer :: int_matrix, int_flows if (evt%process_instance%is_complete_event ()) then if (present (ii_term)) then i_term = ii_term else i_term = evt%process_instance%select_i_term () end if int_matrix => evt%process_instance%get_matrix_int_ptr (i_term) int_flows => evt%process_instance%get_flows_int_ptr (i_term) call evt%factorize_interactions (int_matrix, int_flows, & factorization_mode, keep_correlations, r, qn_select) call evt%tag_incoming () else call msg_bug ("Event factorization: event is incomplete") end if end subroutine make_factorized_particle_set @ %def make_factorized_particle_set @ Mark the incoming particles as incoming in the particle set. This is necessary because in the interaction objects they are usually marked as virtual. In the inquiry functions we set the term index to one; the indices of beams and incoming particles should be identical for all process terms. We use the initial elementary process for obtaining the indices. Thus, we implicitly assume that the beam and incoming indices stay the same across event transforms. If this is not true for a transform (say, MPI), it should override this method. <>= procedure :: tag_incoming => evt_tag_incoming <>= subroutine evt_tag_incoming (evt) class(evt_t), intent(inout) :: evt integer :: i_term, n_in integer, dimension(:), allocatable :: beam_index, in_index n_in = evt%process%get_n_in () i_term = 1 allocate (beam_index (n_in)) call evt%process_instance%get_beam_index (i_term, beam_index) call evt%particle_set%reset_status (beam_index, PRT_BEAM) allocate (in_index (n_in)) call evt%process_instance%get_in_index (i_term, in_index) call evt%particle_set%reset_status (in_index, PRT_INCOMING) end subroutine evt_tag_incoming @ %def evt_tag_incoming @ \subsection{Implementation: Trivial transform} This transform contains just a pointer to process and process instance. The [[generate]] methods do nothing. <>= public :: evt_trivial_t <>= type, extends (evt_t) :: evt_trivial_t contains <> end type evt_trivial_t @ %def evt_trivial_t @ <>= procedure :: write_name => evt_trivial_write_name <>= subroutine evt_trivial_write_name (evt, unit) class(evt_trivial_t), intent(in) :: evt integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A)") "Event transform: trivial (hard process)" end subroutine evt_trivial_write_name @ %def evt_trivial_write_name @ The finalizer is trivial. Some output: <>= procedure :: write => evt_trivial_write <>= subroutine evt_trivial_write (evt, unit, verbose, more_verbose, testflag) class(evt_trivial_t), intent(in) :: evt integer, intent(in), optional :: unit logical, intent(in), optional :: verbose, more_verbose, testflag integer :: u u = given_output_unit (unit) call write_separator (u, 2) call evt%write_name (u) call write_separator (u) call evt%base_write (u, testflag = testflag) !!! More readable but wider output; in line with evt_resonance_write ! if (verbose .and. evt%particle_set_exists) then ! call evt%particle_set%write & ! (u, summary = .true., compressed = .true., testflag = testflag) ! call write_separator (u) ! end if end subroutine evt_trivial_write @ %def evt_trivial_write @ Nothing to do here: <>= procedure :: prepare_new_event => evt_trivial_prepare_new_event <>= subroutine evt_trivial_prepare_new_event (evt, i_mci, i_term) class(evt_trivial_t), intent(inout) :: evt integer, intent(in) :: i_mci, i_term call evt%reset () end subroutine evt_trivial_prepare_new_event @ %def evt_trivial_prepare_new_event @ The weighted generator is, surprisingly, trivial. <>= procedure :: generate_weighted => evt_trivial_generate_weighted <>= subroutine evt_trivial_generate_weighted (evt, probability) class(evt_trivial_t), intent(inout) :: evt real(default), intent(inout) :: probability probability = 1 end subroutine evt_trivial_generate_weighted @ %def evt_trivial_generate_weighted @ This routine makes a particle set, using the associated process instance as-is. <>= procedure :: make_particle_set => evt_trivial_make_particle_set <>= subroutine evt_trivial_make_particle_set & (evt, factorization_mode, keep_correlations, r) class(evt_trivial_t), intent(inout) :: evt integer, intent(in) :: factorization_mode logical, intent(in) :: keep_correlations real(default), dimension(:), intent(in), optional :: r call make_factorized_particle_set (evt, factorization_mode, & keep_correlations, r) evt%particle_set_exists = .true. end subroutine evt_trivial_make_particle_set @ %def event_trivial_make_particle_set @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[event_transforms_ut.f90]]>>= <> module event_transforms_ut use unit_tests use event_transforms_uti <> <> contains <> end module event_transforms_ut @ %def event_transforms_ut @ <<[[event_transforms_uti.f90]]>>= <> module event_transforms_uti <> <> use format_utils, only: write_separator use os_interface use sm_qcd use models use state_matrices, only: FM_IGNORE_HELICITY use interactions, only: reset_interaction_counter use process_libraries use rng_base use mci_base use mci_midpoint use phs_base use phs_single use prc_core use prc_test, only: prc_test_create_library use process, only: process_t use instances, only: process_instance_t use event_transforms use rng_base_ut, only: rng_test_factory_t <> <> contains <> <> end module event_transforms_uti @ %def event_transforms_uti @ API: driver for the unit tests below. <>= public :: event_transforms_test <>= subroutine event_transforms_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine event_transforms_test @ %def event_transforms_test @ \subsubsection{Test trivial event transform} The trivial transform, as an instance of the abstract transform, does nothing but to trigger event generation for an elementary process. <>= call test (event_transforms_1, "event_transforms_1", & "trivial event transform", & u, results) <>= public :: event_transforms_1 <>= subroutine event_transforms_1 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(model_t), target :: model type(process_library_t), target :: lib type(string_t) :: libname, procname1 class(phs_config_t), allocatable :: phs_config_template real(default) :: sqrts type(process_t), allocatable, target :: process type(process_instance_t), allocatable, target :: process_instance class(evt_t), allocatable :: evt integer :: factorization_mode logical :: keep_correlations write (u, "(A)") "* Test output: event_transforms_1" write (u, "(A)") "* Purpose: handle trivial transform" write (u, "(A)") write (u, "(A)") "* Initialize environment and parent process" write (u, "(A)") call os_data%init () libname = "event_transforms_1_lib" procname1 = "event_transforms_1_p" call prc_test_create_library (libname, lib, & scattering = .true., procname1 = procname1) call reset_interaction_counter () call model%init_test () allocate (process) call process%init (procname1, lib, os_data, model) call process%setup_test_cores () allocate (phs_single_config_t :: phs_config_template) call process%init_components (phs_config_template) sqrts = 1000 call process%setup_beams_sqrts (sqrts, i_core = 1) call process%configure_phs () call process%setup_mci (dispatch_mci_test_midpoint) call process%setup_terms () allocate (process_instance) call process_instance%init (process) call process_instance%integrate (1, n_it=1, n_calls=100) call process%final_integration (1) call process_instance%final () deallocate (process_instance) allocate (process_instance) call process_instance%init (process) call process_instance%setup_event_data () call process_instance%init_simulation (1) write (u, "(A)") "* Initialize trivial event transform" write (u, "(A)") allocate (evt_trivial_t :: evt) call evt%connect (process_instance, process%get_model_ptr ()) write (u, "(A)") "* Generate event and subsequent transform" write (u, "(A)") call process_instance%generate_unweighted_event (1) call process_instance%evaluate_event_data () call evt%prepare_new_event (1, 1) call evt%generate_unweighted () call write_separator (u, 2) call evt%write (u) call write_separator (u, 2) write (u, "(A)") write (u, "(A)") "* Obtain particle set" write (u, "(A)") factorization_mode = FM_IGNORE_HELICITY keep_correlations = .false. call evt%make_particle_set (factorization_mode, keep_correlations) call write_separator (u, 2) call evt%write (u) call write_separator (u, 2) write (u, "(A)") write (u, "(A)") "* Cleanup" call evt%final () call process_instance%final () deallocate (process_instance) write (u, "(A)") write (u, "(A)") "* Test output end: event_transforms_1" end subroutine event_transforms_1 @ %def event_transforms_1 @ MCI record prepared for midpoint integrator. <>= subroutine dispatch_mci_test_midpoint (mci, var_list, process_id, is_nlo) use variables, only: var_list_t class(mci_t), allocatable, intent(out) :: mci type(var_list_t), intent(in) :: var_list type(string_t), intent(in) :: process_id logical, intent(in), optional :: is_nlo allocate (mci_midpoint_t :: mci) end subroutine dispatch_mci_test_midpoint @ %def dispatch_mci_test_midpoint @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Hadronization interface} <<[[hadrons.f90]]>>= <> module hadrons <> <> <> use constants use diagnostics use event_transforms use format_utils, only: write_separator use helicities use hep_common use io_units use lorentz use model_data use models use numeric_utils, only: vanishes use particles use physics_defs use process, only: process_t use instances, only: process_instance_t use process_stacks use pythia8 use rng_base, only: rng_t use shower_base use shower_pythia6 use sm_qcd use subevents use variables use whizard_lha <> <> <> <> <> contains <> end module hadrons @ %def hadrons @ \subsection{Hadronization implementations} <>= public :: HADRONS_UNDEFINED, HADRONS_WHIZARD, HADRONS_PYTHIA6, HADRONS_PYTHIA8 <>= integer, parameter :: HADRONS_UNDEFINED = 0 integer, parameter :: HADRONS_WHIZARD = 1 integer, parameter :: HADRONS_PYTHIA6 = 2 integer, parameter :: HADRONS_PYTHIA8 = 3 @ %def HADRONS_UNDEFINED HADRONS_WHIZARD HADRONS_PYTHIA6 HADRONS_PYTHIA8 @ A dictionary <>= public :: hadrons_method <>= interface hadrons_method module procedure hadrons_method_of_string module procedure hadrons_method_to_string end interface <>= elemental function hadrons_method_of_string (string) result (i) integer :: i type(string_t), intent(in) :: string select case (char(string)) case ("WHIZARD") i = HADRONS_WHIZARD case ("PYTHIA6") i = HADRONS_PYTHIA6 case ("PYTHIA8") i = HADRONS_PYTHIA8 case default i = HADRONS_UNDEFINED end select end function hadrons_method_of_string elemental function hadrons_method_to_string (i) result (string) type(string_t) :: string integer, intent(in) :: i select case (i) case (HADRONS_WHIZARD) string = "WHIZARD" case (HADRONS_PYTHIA6) string = "PYTHIA6" case (HADRONS_PYTHIA8) string = "PYTHIA8" case default string = "UNDEFINED" end select end function hadrons_method_to_string @ %def hadrons_method @ \subsection{Hadronization settings} These are the general settings and parameters for the different shower methods. <>= public :: hadron_settings_t <>= type :: hadron_settings_t logical :: active = .false. integer :: method = HADRONS_UNDEFINED real(default) :: enhanced_fraction = 0 real(default) :: enhanced_width = 0 contains <> end type hadron_settings_t @ %def hadron_settings_t @ Read in the hadronization settings. <>= procedure :: init => hadron_settings_init <>= subroutine hadron_settings_init (hadron_settings, var_list) class(hadron_settings_t), intent(out) :: hadron_settings type(var_list_t), intent(in) :: var_list hadron_settings%active = & var_list%get_lval (var_str ("?hadronization_active")) hadron_settings%method = hadrons_method_of_string ( & var_list%get_sval (var_str ("$hadronization_method"))) hadron_settings%enhanced_fraction = & var_list%get_rval (var_str ("hadron_enhanced_fraction")) hadron_settings%enhanced_width = & var_list%get_rval (var_str ("hadron_enhanced_width")) end subroutine hadron_settings_init @ %def hadron_settings_init @ <>= procedure :: write => hadron_settings_write <>= subroutine hadron_settings_write (settings, unit) class(hadron_settings_t), intent(in) :: settings integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit); if (u < 0) return write (u, "(1x,A)") "Hadronization settings:" call write_separator (u) write (u, "(1x,A)") "Master switches:" write (u, "(3x,A,1x,L1)") & "active = ", settings%active write (u, "(1x,A)") "General settings:" if (settings%active) then write (u, "(3x,A)") & "hadron_method = " // & char (hadrons_method_to_string (settings%method)) else write (u, "(3x,A)") " [Hadronization off]" end if write (u, "(1x,A)") "pT generation parameters" write (u, "(3x,A,1x,ES19.12)") & "enhanced_fraction = ", settings%enhanced_fraction write (u, "(3x,A,1x,ES19.12)") & "enhanced_width = ", settings%enhanced_width end subroutine hadron_settings_write @ %def hadron_settings_write @ \subsection{Abstract Hadronization Type} The [[model]] is the fallback model including all hadrons <>= type, abstract :: hadrons_t class(rng_t), allocatable :: rng type(shower_settings_t) :: shower_settings type(hadron_settings_t) :: hadron_settings type(model_t), pointer :: model => null() contains <> end type hadrons_t @ %def hadrons_t @ <>= procedure (hadrons_init), deferred :: init <>= abstract interface subroutine hadrons_init & (hadrons, shower_settings, hadron_settings, model_hadrons) import class(hadrons_t), intent(out) :: hadrons type(shower_settings_t), intent(in) :: shower_settings type(hadron_settings_t), intent(in) :: hadron_settings type(model_t), target, intent(in) :: model_hadrons end subroutine hadrons_init end interface @ %def hadrons_init @ <>= procedure (hadrons_hadronize), deferred :: hadronize <>= abstract interface subroutine hadrons_hadronize (hadrons, particle_set, valid) import class(hadrons_t), intent(inout) :: hadrons type(particle_set_t), intent(in) :: particle_set logical, intent(out) :: valid end subroutine hadrons_hadronize end interface @ %def hadrons_hadronize @ <>= procedure (hadrons_make_particle_set), deferred :: make_particle_set <>= abstract interface subroutine hadrons_make_particle_set (hadrons, particle_set, & model, valid) import class(hadrons_t), intent(in) :: hadrons type(particle_set_t), intent(inout) :: particle_set class(model_data_t), intent(in), target :: model logical, intent(out) :: valid end subroutine hadrons_make_particle_set end interface @ %def hadrons_make_particle_set @ <>= procedure :: import_rng => hadrons_import_rng <>= pure subroutine hadrons_import_rng (hadrons, rng) class(hadrons_t), intent(inout) :: hadrons class(rng_t), intent(inout), allocatable :: rng call move_alloc (from = rng, to = hadrons%rng) end subroutine hadrons_import_rng @ %def hadrons_import_rng @ \subsection{[[WHIZARD]] Hadronization Type} Hadronization can be (incompletely) performed through \whizard's internal routine. <>= public :: hadrons_hadrons_t <>= type, extends (hadrons_t) :: hadrons_hadrons_t contains <> end type hadrons_hadrons_t @ %def hadrons_hadrons_t @ <>= procedure :: init => hadrons_hadrons_init <>= subroutine hadrons_hadrons_init & (hadrons, shower_settings, hadron_settings, model_hadrons) class(hadrons_hadrons_t), intent(out) :: hadrons type(shower_settings_t), intent(in) :: shower_settings type(hadron_settings_t), intent(in) :: hadron_settings type(model_t), intent(in), target :: model_hadrons hadrons%model => model_hadrons hadrons%shower_settings = shower_settings hadrons%hadron_settings = hadron_settings call msg_message & ("Hadronization: WHIZARD model for hadronization and decays") end subroutine hadrons_hadrons_init @ %def hadrons_hadrons_init @ <>= procedure :: hadronize => hadrons_hadrons_hadronize <>= subroutine hadrons_hadrons_hadronize (hadrons, particle_set, valid) class(hadrons_hadrons_t), intent(inout) :: hadrons type(particle_set_t), intent(in) :: particle_set logical, intent(out) :: valid integer, dimension(:), allocatable :: cols, acols, octs integer :: n if (signal_is_pending ()) return if (debug_on) call msg_debug (D_TRANSFORMS, "hadrons_hadrons_hadronize") call particle_set%write (6, compressed=.true.) n = particle_set%get_n_tot () allocate (cols (n), acols (n), octs (n)) call extract_color_systems (particle_set, cols, acols, octs) print *, "size(cols) = ", size (cols) if (size(cols) > 0) then print *, "cols = ", cols end if print *, "size(acols) = ", size(acols) if (size(acols) > 0) then print *, "acols = ", acols end if print *, "size(octs) = ", size(octs) if (size (octs) > 0) then print *, "octs = ", octs end if !!! if all arrays are empty, i.e. zero particles found, nothing to do end subroutine hadrons_hadrons_hadronize @ %def hadrons_hadrons_hadronize @ This type contains a flavor selector for the creation of hadrons, including parameters for the special handling of baryons. <>= public :: had_flav_t <>= type had_flav_t end type had_flav_t @ %def had_flav_t @ This is the type for the ends of Lund strings. <>= public :: lund_end <>= type lund_end logical :: from_pos integer :: i_end integer :: i_max integer :: id_had integer :: i_pos_old integer :: i_neg_old integer :: i_pos_new integer :: i_neg_new real(default) :: px_old real(default) :: py_old real(default) :: px_new real(default) :: py_new real(default) :: px_had real(default) :: py_had real(default) :: m_had real(default) :: mT2_had real(default) :: z_had real(default) :: gamma_old real(default) :: gamma_new real(default) :: x_pos_old real(default) :: x_pos_new real(default) :: x_pos_had real(default) :: x_neg_old real(default) :: x_neg_new real(default) :: x_neg_had type(had_flav_t) :: old_flav type(had_flav_t) :: new_flav type(vector4_t) :: p_had type(vector4_t) :: p_pre end type lund_end @ %def lund_end @ Generator for transverse momentum for the fragmentation. <>= public :: lund_pt_t <>= type lund_pt_t real(default) :: sigma_min real(default) :: sigma_q real(default) :: enhanced_frac real(default) :: enhanced_width real(default) :: sigma_to_had class(rng_t), allocatable :: rng contains <> end type lund_pt_t @ %def lund_pt <>= procedure :: init => lund_pt_init <>= subroutine lund_pt_init (lund_pt, settings) class (lund_pt_t), intent(out) :: lund_pt type(hadron_settings_t), intent(in) :: settings end subroutine lund_pt_init @ %def lund_pt_init @ <>= procedure :: make_particle_set => hadrons_hadrons_make_particle_set <>= subroutine hadrons_hadrons_make_particle_set & (hadrons, particle_set, model, valid) class(hadrons_hadrons_t), intent(in) :: hadrons type(particle_set_t), intent(inout) :: particle_set class(model_data_t), intent(in), target :: model logical, intent(out) :: valid if (signal_is_pending ()) return valid = .false. if (valid) then else call msg_fatal ("WHIZARD hadronization not yet implemented") end if end subroutine hadrons_hadrons_make_particle_set @ %def hadrons_hadrons_make_particle_set @ <>= subroutine extract_color_systems (p_set, cols, acols, octs) type(particle_set_t), intent(in) :: p_set integer, dimension(:), allocatable, intent(out) :: cols, acols, octs logical, dimension(:), allocatable :: mask integer :: i, n, n_cols, n_acols, n_octs n = p_set%get_n_tot () allocate (mask (n)) do i = 1, n mask(i) = p_set%prt(i)%col%get_col () /= 0 .and. & p_set%prt(i)%col%get_acl () == 0 .and. & p_set%prt(i)%get_status () == PRT_OUTGOING end do n_cols = count (mask) allocate (cols (n_cols)) cols = p_set%get_indices (mask) do i = 1, n mask(i) = p_set%prt(i)%col%get_col () == 0 .and. & p_set%prt(i)%col%get_acl () /= 0 .and. & p_set%prt(i)%get_status () == PRT_OUTGOING end do n_acols = count (mask) allocate (acols (n_acols)) acols = p_set%get_indices (mask) do i = 1, n mask(i) = p_set%prt(i)%col%get_col () /= 0 .and. & p_set%prt(i)%col%get_acl () /= 0 .and. & p_set%prt(i)%get_status () == PRT_OUTGOING end do n_octs = count (mask) allocate (octs (n_octs)) octs = p_set%get_indices (mask) end subroutine extract_color_systems @ %def extract_color_systems @ \subsection{[[PYTHIA6]] Hadronization Type} Hadronization via [[PYTHIA6]] is at another option for hadronization within \whizard. <>= public :: hadrons_pythia6_t <>= type, extends (hadrons_t) :: hadrons_pythia6_t contains <> end type hadrons_pythia6_t @ %def hadrons_pythia6_t <>= procedure :: init => hadrons_pythia6_init <>= subroutine hadrons_pythia6_init & (hadrons, shower_settings, hadron_settings, model_hadrons) class(hadrons_pythia6_t), intent(out) :: hadrons type(shower_settings_t), intent(in) :: shower_settings type(hadron_settings_t), intent(in) :: hadron_settings type(model_t), intent(in), target :: model_hadrons logical :: pygive_not_set_by_shower hadrons%model => model_hadrons hadrons%shower_settings = shower_settings hadrons%hadron_settings = hadron_settings pygive_not_set_by_shower = .not. (shower_settings%method == PS_PYTHIA6 & .and. (shower_settings%isr_active .or. shower_settings%fsr_active)) if (pygive_not_set_by_shower) then call pythia6_set_verbose (shower_settings%verbose) call pythia6_set_config (shower_settings%pythia6_pygive) end if call msg_message & ("Hadronization: Using PYTHIA6 interface for hadronization and decays") end subroutine hadrons_pythia6_init @ %def hadrons_pythia6_init @ Assume that the event record is still in the PYTHIA COMMON BLOCKS transferred there by the WHIZARD or PYTHIA6 shower routines. <>= procedure :: hadronize => hadrons_pythia6_hadronize <>= subroutine hadrons_pythia6_hadronize (hadrons, particle_set, valid) class(hadrons_pythia6_t), intent(inout) :: hadrons type(particle_set_t), intent(in) :: particle_set logical, intent(out) :: valid integer :: N, NPAD, K real(double) :: P, V common /PYJETS/ N, NPAD, K(4000,5), P(4000,5), V(4000,5) save /PYJETS/ if (signal_is_pending ()) return if (debug_on) call msg_debug (D_TRANSFORMS, "hadrons_pythia6_hadronize") call pygive ("MSTP(111)=1") !!! Switch on hadronization and decays call pygive ("MSTJ(1)=1") !!! String fragmentation call pygive ("MSTJ(21)=2") !!! String fragmentation keeping resonance momentum call pygive ("MSTJ(28)=0") !!! Switch off tau decays if (debug_active (D_TRANSFORMS)) then call msg_debug (D_TRANSFORMS, "N", N) call pylist(2) print *, ' line 7 : ', k(7,1:5), p(7,1:5) end if call pyedit (12) call pythia6_set_last_treated_line (N) call pyexec () call pyedit (12) valid = .true. end subroutine hadrons_pythia6_hadronize @ %def hadrons_pythia6_hadronize @ <>= procedure :: make_particle_set => hadrons_pythia6_make_particle_set <>= subroutine hadrons_pythia6_make_particle_set & (hadrons, particle_set, model, valid) class(hadrons_pythia6_t), intent(in) :: hadrons type(particle_set_t), intent(inout) :: particle_set class(model_data_t), intent(in), target :: model logical, intent(out) :: valid if (signal_is_pending ()) return valid = pythia6_handle_errors () if (valid) then call pythia6_combine_with_particle_set & (particle_set, model, hadrons%model, hadrons%shower_settings) end if end subroutine hadrons_pythia6_make_particle_set @ %def hadrons_pythia6_make_particle_set @ \subsection{[[PYTHIA8]] Hadronization} @ <>= public :: hadrons_pythia8_t <>= type, extends (hadrons_t) :: hadrons_pythia8_t type(pythia8_t) :: pythia type(whizard_lha_t) :: lhaup logical :: user_process_set = .false. logical :: pythia_initialized = .false., & lhaup_initialized = .false. contains <> end type hadrons_pythia8_t @ %def hadrons_pythia8_t @ <>= procedure :: init => hadrons_pythia8_init <>= subroutine hadrons_pythia8_init & (hadrons, shower_settings, hadron_settings, model_hadrons) class(hadrons_pythia8_t), intent(out) :: hadrons type(shower_settings_t), intent(in) :: shower_settings type(hadron_settings_t), intent(in) :: hadron_settings type(model_t), intent(in), target :: model_hadrons hadrons%model => model_hadrons hadrons%shower_settings = shower_settings hadrons%hadron_settings = hadron_settings call msg_message & ("Hadronization: Using PYTHIA8 interface for hadronization and decays.") ! TODO sbrass which verbose? call hadrons%pythia%init (verbose = shower_settings%verbose) call hadrons%lhaup%init () end subroutine hadrons_pythia8_init @ %def hadrons_pythia8_init @ Transfer hadron settings to [[PYTHIA8]]. <>= procedure, private :: transfer_settings => hadrons_pythia8_transfer_settings <>= subroutine hadrons_pythia8_transfer_settings (hadrons) class(hadrons_pythia8_t), intent(inout), target :: hadrons real(default) :: r if (debug_on) call msg_debug (D_TRANSFORMS, "hadrons_pythia8_transfer_settings") if (debug_on) call msg_debug2 (D_TRANSFORMS, "pythia_initialized", hadrons%pythia_initialized) if (hadrons%pythia_initialized) return call hadrons%pythia%import_rng (hadrons%rng) call hadrons%pythia%parse_and_set_config (hadrons%shower_settings%pythia8_config) if (len (hadrons%shower_settings%pythia8_config_file) > 0) & call hadrons%pythia%read_file (hadrons%shower_settings%pythia8_config_file) call hadrons%pythia%read_string (var_str ("Beams:frameType = 5")) call hadrons%pythia%read_string (var_str ("ProcessLevel:all = off")) if (.not. hadrons%shower_settings%verbose) then call hadrons%pythia%read_string (var_str ("Print:quiet = on")) end if call hadrons%pythia%set_lhaup_ptr (hadrons%lhaup) call hadrons%pythia%init_pythia () hadrons%pythia_initialized = .true. end subroutine hadrons_pythia8_transfer_settings @ %def hadrons_pythia8_transfer_settings @ Set user process for the LHA interface. <>= procedure, private :: set_user_process => hadrons_pythia8_set_user_process <>= subroutine hadrons_pythia8_set_user_process (hadrons, pset) class(hadrons_pythia8_t), intent(inout) :: hadrons type(particle_set_t), intent(in) :: pset integer, dimension(2) :: beam_pdg real(default), dimension(2) :: beam_energy integer, parameter :: process_id = 0, n_processes = 0 if (debug_on) call msg_debug (D_TRANSFORMS, "hadrons_pythia8_set_user_process") beam_pdg = [pset%prt(1)%get_pdg (), pset%prt(2)%get_pdg ()] beam_energy = [energy(pset%prt(1)%p), energy(pset%prt(2)%p)] call hadrons%lhaup%set_init (beam_pdg, beam_energy, & n_processes, unweighted = .false., negative_weights = .false.) call hadrons%lhaup%set_process_parameters (process_id = process_id, & cross_section = one, error = one) end subroutine hadrons_pythia8_set_user_process @ %def hadrons_pythia8_set_user_process @ Import particle set. <>= procedure, private :: import_particle_set => hadrons_pythia8_import_particle_set <>= subroutine hadrons_pythia8_import_particle_set (hadrons, particle_set) class(hadrons_pythia8_t), target, intent(inout) :: hadrons type(particle_set_t), intent(in) :: particle_set type(particle_set_t) :: pset_reduced integer, parameter :: PROCESS_ID = 1 if (debug_on) call msg_debug (D_TRANSFORMS, "hadrons_pythia8_import_particle_set") if (.not. hadrons%user_process_set) then call hadrons%set_user_process (particle_set) hadrons%user_process_set = .true. end if call hadrons%lhaup%set_event_process (process_id = PROCESS_ID, scale = -one, & alpha_qcd = -one, alpha_qed = -one, weight = -one) call hadrons%lhaup%set_event (process_id = PROCESS_ID, particle_set = particle_set, & polarization = .true.) if (debug_active (D_TRANSFORMS)) then call hadrons%lhaup%list_init () end if end subroutine hadrons_pythia8_import_particle_set @ %def hadrons_pythia8_import_particle_set @ <>= procedure :: hadronize => hadrons_pythia8_hadronize <>= subroutine hadrons_pythia8_hadronize (hadrons, particle_set, valid) class(hadrons_pythia8_t), intent(inout) :: hadrons type(particle_set_t), intent(in) :: particle_set logical, intent(out) :: valid if (signal_is_pending ()) return call hadrons%import_particle_set (particle_set) if (.not. hadrons%pythia_initialized) & call hadrons%transfer_settings () call hadrons%pythia%next (valid) if (debug_active (D_TRANSFORMS)) then call hadrons%pythia%list_event () call particle_set%write (summary=.true., compressed=.true.) end if end subroutine hadrons_pythia8_hadronize @ %def hadrons_pythia8_hadronize @ <>= procedure :: make_particle_set => hadrons_pythia8_make_particle_set <>= subroutine hadrons_pythia8_make_particle_set & (hadrons, particle_set, model, valid) class(hadrons_pythia8_t), intent(in) :: hadrons type(particle_set_t), intent(inout) :: particle_set class(model_data_t), intent(in), target :: model logical, intent(out) :: valid type(particle_t), dimension(:), allocatable :: beam if (debug_on) call msg_debug (D_TRANSFORMS, "hadrons_pythia8_make_particle_set") if (signal_is_pending ()) return associate (settings => hadrons%shower_settings) if (debug_active (D_TRANSFORMS)) then call msg_debug (D_TRANSFORMS, 'Combine PYTHIA8 with particle set') call msg_debug (D_TRANSFORMS, 'Particle set before replacing') call particle_set%write (summary=.true., compressed=.true.) call hadrons%pythia%list_event () call msg_debug (D_TRANSFORMS, string = "settings%hadron_collision", & value = settings%hadron_collision) end if call hadrons%pythia%get_hadron_particles (& model, hadrons%model, particle_set, & helicity = PRT_DEFINITE_HELICITY) end associate if (debug_active (D_TRANSFORMS)) then print *, 'Particle set after replacing' call particle_set%write (summary=.true., compressed=.true.) end if valid = .true. end subroutine hadrons_pythia8_make_particle_set @ %def hadrons_pythia8_make_particle_set @ \subsection{Hadronization Event Transform} This is the type for the hadronization event transform. It does not depend on the specific hadronization implementation of [[hadrons_t]]. <>= public :: evt_hadrons_t <>= type, extends (evt_t) :: evt_hadrons_t class(hadrons_t), allocatable :: hadrons type(model_t), pointer :: model_hadrons => null() type(qcd_t) :: qcd logical :: is_first_event contains <> end type evt_hadrons_t @ %def evt_hadrons_t @ Initialize the parameters. The [[model_hadrons]] is supposed to be the SM variant that contains all hadrons that may be generated in the shower. <>= procedure :: init => evt_hadrons_init <>= subroutine evt_hadrons_init (evt, model_hadrons) class(evt_hadrons_t), intent(out) :: evt type(model_t), intent(in), target :: model_hadrons evt%model_hadrons => model_hadrons evt%is_first_event = .true. end subroutine evt_hadrons_init @ %def evt_hadrons_init @ <>= procedure :: write_name => evt_hadrons_write_name <>= subroutine evt_hadrons_write_name (evt, unit) class(evt_hadrons_t), intent(in) :: evt integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A)") "Event transform: hadronization" end subroutine evt_hadrons_write_name @ %def evt_hadrons_write_name @ Output. <>= procedure :: write => evt_hadrons_write <>= subroutine evt_hadrons_write (evt, unit, verbose, more_verbose, testflag) class(evt_hadrons_t), intent(in) :: evt integer, intent(in), optional :: unit logical, intent(in), optional :: verbose, more_verbose, testflag integer :: u u = given_output_unit (unit) call write_separator (u, 2) call evt%write_name (u) call write_separator (u) call evt%base_write (u, testflag = testflag, show_set = .false.) if (evt%particle_set_exists) & call evt%particle_set%write & (u, summary = .true., compressed = .true., testflag = testflag) call write_separator (u) call evt%hadrons%shower_settings%write (u) call write_separator (u) call evt%hadrons%hadron_settings%write (u) end subroutine evt_hadrons_write @ %def evt_hadrons_write @ <>= procedure :: first_event => evt_hadrons_first_event <>= subroutine evt_hadrons_first_event (evt) class(evt_hadrons_t), intent(inout) :: evt if (debug_on) call msg_debug (D_TRANSFORMS, "evt_hadrons_first_event") associate (settings => evt%hadrons%shower_settings) settings%hadron_collision = .false. !!! !!! !!! Workaround for PGF90 16.1 !!! if (all (evt%particle_set%prt(1:2)%flv%get_pdg_abs () <= 39)) then if (evt%particle_set%prt(1)%flv%get_pdg_abs () <= 39 .and. & evt%particle_set%prt(2)%flv%get_pdg_abs () <= 39) then settings%hadron_collision = .false. !!! else if (all (evt%particle_set%prt(1:2)%flv%get_pdg_abs () >= 100)) then else if (evt%particle_set%prt(1)%flv%get_pdg_abs () >= 100 .and. & evt%particle_set%prt(2)%flv%get_pdg_abs () >= 100) then settings%hadron_collision = .true. else call msg_fatal ("evt_hadrons didn't recognize beams setup") end if if (debug_on) call msg_debug (D_TRANSFORMS, "hadron_collision", settings%hadron_collision) if (.not. (settings%isr_active .or. settings%fsr_active)) then call msg_fatal ("Hadronization without shower is not supported") end if end associate evt%is_first_event = .false. end subroutine evt_hadrons_first_event @ %def evt_hadrons_first_event @ Here we take the particle set from the previous event transform and apply the hadronization. The result is stored in the [[evt%hadrons]] object. We always return a probability of unity as we don't have the analytic weight of the hadronization. Invalid events have to be discarded by the caller which is why we mark the particle set as invalid. <>= procedure :: generate_weighted => evt_hadrons_generate_weighted <>= subroutine evt_hadrons_generate_weighted (evt, probability) class(evt_hadrons_t), intent(inout) :: evt real(default), intent(inout) :: probability logical :: valid if (signal_is_pending ()) return evt%particle_set = evt%previous%particle_set if (evt%is_first_event) then call evt%first_event () end if call evt%hadrons%hadronize (evt%particle_set, valid) probability = 1 evt%particle_set_exists = valid end subroutine evt_hadrons_generate_weighted @ %def evt_hadrons_generate_weighted @ The factorization parameters are irrelevant. <>= procedure :: make_particle_set => evt_hadrons_make_particle_set <>= subroutine evt_hadrons_make_particle_set & (evt, factorization_mode, keep_correlations, r) class(evt_hadrons_t), intent(inout) :: evt integer, intent(in) :: factorization_mode logical, intent(in) :: keep_correlations real(default), dimension(:), intent(in), optional :: r logical :: valid call evt%hadrons%make_particle_set (evt%particle_set, evt%model, valid) evt%particle_set_exists = evt%particle_set_exists .and. valid end subroutine evt_hadrons_make_particle_set @ %def event_hadrons_make_particle_set @ Connect the process with the hadrons object. <>= procedure :: connect => evt_hadrons_connect <>= subroutine evt_hadrons_connect & (evt, process_instance, model, process_stack) class(evt_hadrons_t), intent(inout), target :: evt type(process_instance_t), intent(in), target :: process_instance class(model_data_t), intent(in), target :: model type(process_stack_t), intent(in), optional :: process_stack call evt%base_connect (process_instance, model, process_stack) call evt%make_rng (evt%process) end subroutine evt_hadrons_connect @ %def evt_hadrons_connect @ Create RNG instances, spawned by the process object. <>= procedure :: make_rng => evt_hadrons_make_rng <>= subroutine evt_hadrons_make_rng (evt, process) class(evt_hadrons_t), intent(inout) :: evt type(process_t), intent(inout) :: process class(rng_t), allocatable :: rng call process%make_rng (rng) call evt%hadrons%import_rng (rng) end subroutine evt_hadrons_make_rng @ %def evt_hadrons_make_rng @ <>= procedure :: prepare_new_event => evt_hadrons_prepare_new_event <>= subroutine evt_hadrons_prepare_new_event (evt, i_mci, i_term) class(evt_hadrons_t), intent(inout) :: evt integer, intent(in) :: i_mci, i_term call evt%reset () end subroutine evt_hadrons_prepare_new_event @ %def evt_hadrons_prepare_new_event @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Resonance Insertion} <<[[resonance_insertion.f90]]>>= <> module resonance_insertion <> <> use io_units use format_utils, only: write_separator use format_defs, only: FMT_12 use rng_base, only: rng_t use selectors, only: selector_t use sm_qcd use model_data use interactions, only: interaction_t use particles, only: particle_t, particle_set_t use subevents, only: PRT_RESONANT use models use resonances, only: resonance_history_set_t use resonances, only: resonance_tree_t use instances, only: process_instance_ptr_t use event_transforms <> <> <> contains <> end module resonance_insertion @ %def resonance_insertion @ \subsection{Resonance-Insertion Event Transform} This is the type for the event transform that applies resonance insertion. The resonance history set describe the resonance histories that we may consider. There is a process library with process objects that correspond to the resonance histories. Library creation, compilation etc.\ is done outside the scope of this module. <>= public :: evt_resonance_t <>= type, extends (evt_t) :: evt_resonance_t type(resonance_history_set_t), dimension(:), allocatable :: res_history_set integer, dimension(:), allocatable :: index_offset integer :: selected_component = 0 type(string_t) :: libname type(string_t), dimension(:), allocatable :: proc_id real(default) :: on_shell_limit = 0 real(default) :: on_shell_turnoff = 0 real(default) :: background_factor = 1 logical :: selector_active = .false. type(selector_t) :: selector integer :: selected_history = 0 type(process_instance_ptr_t), dimension(:), allocatable :: instance contains <> end type evt_resonance_t @ %def evt_resonance_t <>= procedure :: write_name => evt_resonance_write_name <>= subroutine evt_resonance_write_name (evt, unit) class(evt_resonance_t), intent(in) :: evt integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A)") "Event transform: resonance insertion" end subroutine evt_resonance_write_name @ %def evt_resonance_write_name @ Output. <>= procedure :: write => evt_resonance_write <>= subroutine evt_resonance_write (evt, unit, verbose, more_verbose, testflag) class(evt_resonance_t), intent(in) :: evt integer, intent(in), optional :: unit logical, intent(in), optional :: verbose, more_verbose, testflag integer :: u, i u = given_output_unit (unit) call write_separator (u, 2) call evt%write_name (u) call write_separator (u, 2) write (u, "(1x,A,A,A)") "Process library = '", char (evt%libname), "'" if (allocated (evt%res_history_set)) then do i = 1, size (evt%res_history_set) if (i == evt%selected_component) then write (u, "(1x,A,I0,A)") "Component #", i, ": *" else write (u, "(1x,A,I0,A)") "Component #", i, ":" end if call evt%res_history_set(i)%write (u, indent=1) end do end if call write_separator (u) if (allocated (evt%instance)) then write (u, "(1x,A)") "Subprocess instances: allocated" else write (u, "(1x,A)") "Subprocess instances: not allocated" end if if (evt%particle_set_exists) then if (evt%selected_history > 0) then write (u, "(1x,A,I0)") "Selected: resonance history #", & evt%selected_history else write (u, "(1x,A)") "Selected: no resonance history" end if else write (u, "(1x,A)") "Selected: [none]" end if write (u, "(1x,A,1x," // FMT_12 // ")") & "On-shell limit =", evt%on_shell_limit write (u, "(1x,A,1x," // FMT_12 // ")") & "On-shell turnoff =", evt%on_shell_turnoff write (u, "(1x,A,1x," // FMT_12 // ")") & "Background factor =", evt%background_factor call write_separator (u) if (evt%selector_active) then write (u, "(2x)", advance="no") call evt%selector%write (u, testflag=testflag) call write_separator (u) end if call evt%base_write (u, testflag = testflag, show_set = .false.) call write_separator (u) if (evt%particle_set_exists) then call evt%particle_set%write & (u, summary = .true., compressed = .true., testflag = testflag) call write_separator (u) end if end subroutine evt_resonance_write @ %def evt_resonance_write @ \subsection{Set contained data} Insert the resonance data, in form of a pre-generated resonance history set. Accumulate the number of histories for each set, to initialize an array of index offsets for lookup. <>= procedure :: set_resonance_data => evt_resonance_set_resonance_data <>= subroutine evt_resonance_set_resonance_data (evt, res_history_set) class(evt_resonance_t), intent(inout) :: evt type(resonance_history_set_t), dimension(:), intent(in) :: res_history_set integer :: i evt%res_history_set = res_history_set allocate (evt%index_offset (size (evt%res_history_set)), source = 0) do i = 2, size (evt%res_history_set) evt%index_offset(i) = & evt%index_offset(i-1) + evt%res_history_set(i-1)%get_n_history () end do end subroutine evt_resonance_set_resonance_data @ %def evt_resonance_set_resonance_data @ Set the library that contains the resonant subprocesses. <>= procedure :: set_library => evt_resonance_set_library <>= subroutine evt_resonance_set_library (evt, libname) class(evt_resonance_t), intent(inout) :: evt type(string_t), intent(in) :: libname evt%libname = libname end subroutine evt_resonance_set_library @ %def evt_resonance_set_library @ Assign pointers to subprocess instances. Once a subprocess has been selected, the instance is used for generating the particle set with valid quantum-number assignments, ready for resonance insertion. <>= procedure :: set_subprocess_instances & => evt_resonance_set_subprocess_instances <>= subroutine evt_resonance_set_subprocess_instances (evt, instance) class(evt_resonance_t), intent(inout) :: evt type(process_instance_ptr_t), dimension(:), intent(in) :: instance evt%instance = instance end subroutine evt_resonance_set_subprocess_instances @ %def evt_resonance_set_subprocess_instances @ Set the on-shell limit, the relative distance from a resonance that is still considered to be on-shell. The probability for being considered on-shell can be reduced by the turnoff parameter below. For details, see the [[resonances]] module. <>= procedure :: set_on_shell_limit => evt_resonance_set_on_shell_limit <>= subroutine evt_resonance_set_on_shell_limit (evt, on_shell_limit) class(evt_resonance_t), intent(inout) :: evt real(default), intent(in) :: on_shell_limit evt%on_shell_limit = on_shell_limit end subroutine evt_resonance_set_on_shell_limit @ %def evt_resonance_set_on_shell_limit @ Set the Gaussian on-shell turnoff parameter, the width of the weighting factor for the resonance squared matrix element. If the resonance is off shell, this factor reduces the weight of the matrix element in the selector, such that the probability for considered resonant is reduced. The factor is applied only if the offshellness is less than the [[on_shell_limit]] above. For details, see the [[resonances]] module. <>= procedure :: set_on_shell_turnoff => evt_resonance_set_on_shell_turnoff <>= subroutine evt_resonance_set_on_shell_turnoff (evt, on_shell_turnoff) class(evt_resonance_t), intent(inout) :: evt real(default), intent(in) :: on_shell_turnoff evt%on_shell_turnoff = on_shell_turnoff end subroutine evt_resonance_set_on_shell_turnoff @ %def evt_resonance_set_on_shell_turnoff @ Reweight (suppress) the background contribution if there is a resonance history that applies. The event will be registered as background if there is no applicable resonance history, or if the background configuration has been selected based on (reweighted) squared matrix elements. <>= procedure :: set_background_factor => evt_resonance_set_background_factor <>= subroutine evt_resonance_set_background_factor (evt, background_factor) class(evt_resonance_t), intent(inout) :: evt real(default), intent(in) :: background_factor evt%background_factor = background_factor end subroutine evt_resonance_set_background_factor @ %def evt_resonance_set_background_factor @ \subsection{Selector} Manually import a random-number generator object. This should be done only for testing purposes. The standard procedure is to [[connect]] a process to an event transform; this will create an appropriate [[rng]] from the RNG factory in the process object. <>= procedure :: import_rng => evt_resonance_import_rng <>= subroutine evt_resonance_import_rng (evt, rng) class(evt_resonance_t), intent(inout) :: evt class(rng_t), allocatable, intent(inout) :: rng call move_alloc (from = rng, to = evt%rng) end subroutine evt_resonance_import_rng @ %def evt_resonance_import_rng @ We use a standard selector object to choose from the available resonance histories. If the selector is inactive, we do not insert resonances. <>= procedure :: write_selector => evt_resonance_write_selector <>= subroutine evt_resonance_write_selector (evt, unit, testflag) class(evt_resonance_t), intent(in) :: evt integer, intent(in), optional :: unit logical, intent(in), optional :: testflag integer :: u u = given_output_unit (unit) if (evt%selector_active) then call evt%selector%write (u, testflag) else write (u, "(1x,A)") "Selector: [inactive]" end if end subroutine evt_resonance_write_selector @ %def evt_resonance_write_selector @ The selector is initialized with relative weights of histories which need not be normalized. Channels with weight zero are ignored. The [[offset]] will normally be $-1$, so we count from zero, and zero is a valid result from the selector. Selecting the zero entry implies no resonance insertion. However, this behavior is not hard-coded here (without offset, no resonance is not possible as a result). <>= procedure :: init_selector => evt_resonance_init_selector <>= subroutine evt_resonance_init_selector (evt, weight, offset) class(evt_resonance_t), intent(inout) :: evt real(default), dimension(:), intent(in) :: weight integer, intent(in), optional :: offset if (any (weight > 0)) then call evt%selector%init (weight, offset = offset) evt%selector_active = .true. else evt%selector_active = .false. end if end subroutine evt_resonance_init_selector @ %def evt_resonance_init_selector @ Return all selector weights, for inspection. Note that the index counts from zero. <>= procedure :: get_selector_weights => evt_resonance_get_selector_weights <>= subroutine evt_resonance_get_selector_weights (evt, weight) class(evt_resonance_t), intent(in) :: evt real(default), dimension(0:), intent(out) :: weight integer :: i do i = 0, ubound (weight,1) weight(i) = evt%selector%get_weight (i) end do end subroutine evt_resonance_get_selector_weights @ %def evt_resonance_get_selector_weights @ \subsection{Runtime calculations} Use the associated master process instance and the subprocess instances to distribute the current momentum set, then compute the squared matrix elements weights for all subprocesses. NOTE: Procedures in this subsection are not covered by unit tests in this module, but by unit tests of the [[restricted_subprocesses]] module. Fill the particle set, so the momentum configuration can be used by the subprocess instances. The standard workflow is to copy from the previous particle set. <>= procedure :: fill_momenta => evt_resonance_fill_momenta <>= subroutine evt_resonance_fill_momenta (evt) class(evt_resonance_t), intent(inout) :: evt integer :: i, n if (associated (evt%previous)) then evt%particle_set = evt%previous%particle_set else if (associated (evt%process_instance)) then ! this branch only for unit test call evt%process_instance%get_trace & (evt%particle_set, i_term=1, n_incoming=evt%process%get_n_in ()) end if end subroutine evt_resonance_fill_momenta @ %def evt_resonance_fill_momenta @ Return the indices of those subprocesses which can be considered on-shell. The result depends on the stored particle set (outgoing momenta) and on the on-shell limit value. The index [[evt%selected_component]] identifies the particular history set that corresponds to the given process component. Recall that process components may have different external particles, so they have distinct history sets. <>= procedure :: determine_on_shell_histories & => evt_resonance_determine_on_shell_histories <>= subroutine evt_resonance_determine_on_shell_histories & (evt, index_array) class(evt_resonance_t), intent(in) :: evt integer, dimension(:), allocatable, intent(out) :: index_array integer :: i i = evt%selected_component call evt%res_history_set(i)%determine_on_shell_histories & (evt%particle_set%get_outgoing_momenta (), & evt%on_shell_limit, & index_array) end subroutine evt_resonance_determine_on_shell_histories @ %def evt_resonance_determine_on_shell_histories @ Evaluate selected subprocesses. (In actual operation, the ones that have been tagged as on-shell.) We assume that the MCI, term, and channel indices for the subprocesses can all be set to 1. <>= procedure :: evaluate_subprocess => evt_resonance_evaluate_subprocess <>= subroutine evt_resonance_evaluate_subprocess (evt, index_array) class(evt_resonance_t), intent(inout) :: evt integer, dimension(:), intent(in) :: index_array integer :: k, i if (allocated (evt%instance)) then do k = 1, size (index_array) i = index_array(k) associate (instance => evt%instance(i)%p) call instance%choose_mci (1) call instance%set_trace (evt%particle_set, 1, check_match=.false.) call instance%recover (channel = 1, i_term = 1, & update_sqme = .true., recover_phs = .false.) end associate end do end if end subroutine evt_resonance_evaluate_subprocess @ %def evt_resonance_evaluate_subprocess @ Return the current squared matrix-element value of the master process, and of the selected resonant subprocesses, respectively. <>= procedure :: get_master_sqme => evt_resonance_get_master_sqme procedure :: get_subprocess_sqme => evt_resonance_get_subprocess_sqme <>= function evt_resonance_get_master_sqme (evt) result (sqme) class(evt_resonance_t), intent(in) :: evt real(default) :: sqme sqme = evt%process_instance%get_sqme () end function evt_resonance_get_master_sqme subroutine evt_resonance_get_subprocess_sqme (evt, sqme, index_array) class(evt_resonance_t), intent(in) :: evt real(default), dimension(:), intent(out) :: sqme integer, dimension(:), intent(in), optional :: index_array integer :: k, i if (present (index_array)) then sqme = 0 do k = 1, size (index_array) call get_sqme (index_array(k)) end do else do i = 1, size (evt%instance) call get_sqme (i) end do end if contains subroutine get_sqme (i) integer, intent(in) :: i associate (instance => evt%instance(i)%p) sqme(i) = instance%get_sqme () end associate end subroutine get_sqme end subroutine evt_resonance_get_subprocess_sqme @ %def evt_resonance_get_master_sqme @ %def evt_resonance_get_subprocess_sqme @ Apply a turnoff factor for off-shell kinematics to the [[sqme]] values. The [[sqme]] array indices are offset from the resonance history set entries. <>= procedure :: apply_turnoff_factor => evt_resonance_apply_turnoff_factor <>= subroutine evt_resonance_apply_turnoff_factor (evt, sqme, index_array) class(evt_resonance_t), intent(in) :: evt real(default), dimension(:), intent(inout) :: sqme integer, dimension(:), intent(in) :: index_array integer :: k, i_res, i_prc do k = 1, size (index_array) i_res = evt%selected_component i_prc = index_array(k) + evt%index_offset(i_res) sqme(i_prc) = sqme(i_prc) & * evt%res_history_set(i_res)%evaluate_gaussian & & (evt%particle_set%get_outgoing_momenta (), & & evt%on_shell_turnoff, index_array(k)) end do end subroutine evt_resonance_apply_turnoff_factor @ %def evt_resonance_apply_turnoff_factor @ We use the calculations of resonant matrix elements to determine probabilities for all applicable resonance configurations. This method combines the steps implemented above. First, we determine the selected process component. TODO: the version below selects the first component which is found active. This make sense only for standard LO process components, where exactly one component corresponds to a MCI set. For the selected process component, we query the kinematics and determine the applicable resonance histories. We collect squared matrix elements for those resonance histories and compare them to the master-process squared matrix element. The result is the probability for each resonance history together with the probability for non-resonant background (zeroth entry). The latter is defined as the difference between the complete process result and the sum of the resonances, ignoring the possibility for interference. If the complete process result is actually undershooting the sum of resonances, we nevertheless count the background with positive probability. When looking up the subprocess sqme, we must add the [[index_offset]] to the resulting array, since the indices returned by the individual history set all count from one, while the subprocess instances that belong to process components are collected in one flat array. After determining matrix elements and background, we may reduce the weight of the matrix elements in the selector by applying a turnoff factor. The factor [[background_factor]] indicates whether to include the background contribution at all, as long as there is a nonvanishing resonance contribution. Note that instead of setting background to zero, we just multiply it by a very small number. This ensures that indices are assigned correctly, and that background will eventually be selected if smooth turnoff is chosen. <>= procedure :: compute_probabilities => evt_resonance_compute_probabilities <>= subroutine evt_resonance_compute_probabilities (evt) class(evt_resonance_t), intent(inout) :: evt integer, dimension(:), allocatable :: index_array real(default) :: sqme_master, sqme_sum, sqme_bg real(default), dimension(:), allocatable :: sqme_res integer :: n, ic if (.not. associated (evt%process_instance)) return n = size (evt%instance) call evt%select_component (0) FIND_ACTIVE_COMPONENT: do ic = 1, evt%process%get_n_components () if (evt%process%component_is_selected (ic)) then call evt%select_component (ic) exit FIND_ACTIVE_COMPONENT end if end do FIND_ACTIVE_COMPONENT if (evt%selected_component > 0) then call evt%determine_on_shell_histories (index_array) else allocate (index_array (0)) end if call evt%evaluate_subprocess & (index_array + evt%index_offset(evt%selected_component)) allocate (sqme_res (n), source = 0._default) call evt%get_subprocess_sqme & (sqme_res, index_array + evt%index_offset(evt%selected_component)) sqme_master = evt%get_master_sqme () sqme_sum = sum (sqme_res) sqme_bg = abs (sqme_master - sqme_sum) if (evt%on_shell_turnoff > 0) then call evt%apply_turnoff_factor (sqme_res, index_array) end if if (any (sqme_res > 0)) then sqme_bg = sqme_bg * evt%background_factor end if call evt%init_selector ([sqme_bg, sqme_res], offset = -1) end subroutine evt_resonance_compute_probabilities @ %def evt_resonance_compute_probabilities @ Set the selected component (unit tests). <>= procedure :: select_component => evt_resonance_select_component <>= subroutine evt_resonance_select_component (evt, i_component) class(evt_resonance_t), intent(inout) :: evt integer, intent(in) :: i_component evt%selected_component = i_component end subroutine evt_resonance_select_component @ %def evt_resonance_select_component @ \subsection{Sanity check} Check the color assignment, which may be wrong for the inserted resonances. Delegated to the particle-set component. Return offending particle indices and, optionally, particles as arrays. This is done in a unit test. The current algorithm, i.e., selecting the color assignment from the resonant-subprocess instance, should not generate invalid color assignments. <>= procedure :: find_prt_invalid_color => evt_resonance_find_prt_invalid_color <>= subroutine evt_resonance_find_prt_invalid_color (evt, index, prt) class(evt_resonance_t), intent(in) :: evt integer, dimension(:), allocatable, intent(out) :: index type(particle_t), dimension(:), allocatable, intent(out), optional :: prt if (evt%particle_set_exists) then call evt%particle_set%find_prt_invalid_color (index, prt) else allocate (prt (0)) end if end subroutine evt_resonance_find_prt_invalid_color @ %def evt_resonance_find_prt_invalid_color @ \subsection{API implementation} <>= procedure :: prepare_new_event => evt_resonance_prepare_new_event <>= subroutine evt_resonance_prepare_new_event (evt, i_mci, i_term) class(evt_resonance_t), intent(inout) :: evt integer, intent(in) :: i_mci, i_term call evt%reset () end subroutine evt_resonance_prepare_new_event @ %def evt_resonance_prepare_new_event @ Select one of the histories, based on the momentum array from the current particle set. Compute the probabilities for all resonant subprocesses and initialize the selector accordingly. Then select one resonance history, or none. <>= procedure :: generate_weighted => evt_resonance_generate_weighted <>= subroutine evt_resonance_generate_weighted (evt, probability) class(evt_resonance_t), intent(inout) :: evt real(default), intent(inout) :: probability call evt%fill_momenta () call evt%compute_probabilities () call evt%selector%generate (evt%rng, evt%selected_history) probability = 1 end subroutine evt_resonance_generate_weighted @ %def evt_resonance_generate_weighted @ Here take the current particle set and insert resonance intermediate states if applicable. The resonance history has already been chosen by the generator above. If no resonance history applies, just retain the particle set. If a resonance history applies, we factorize the exclusive interaction of the selected (resonance-process) process instance. With a temporary particle set [[prt_set]] as workspace, we the insert the resonances, reinstate parent-child relations and set colors and momenta for the resonances. The temporary is then copied back. Taking the event data from the resonant subprocess instead of the master process, guarantees that all flavor, helicity, and color assignments are valid for the selected resonance history. Note that the transform may thus choose a quantum-number combination that is different from the one chosen by the master process. The [[i_term]] value for the selected subprocess instance is always 1. We support only LO process. For those, the master process may have several terms (= components) that correspond to different external states. The subprocesses are distinct, each one corresponds to a definite master component, and by itself it consists of a single component/term. However, if the selector chooses resonance history \#0, i.e., no resonance, we just copy the particle set from the previous (i.e., trivial) event transform and ignore all subprocess data. <>= procedure :: make_particle_set => evt_resonance_make_particle_set <>= subroutine evt_resonance_make_particle_set & (evt, factorization_mode, keep_correlations, r) class(evt_resonance_t), intent(inout) :: evt integer, intent(in) :: factorization_mode logical, intent(in) :: keep_correlations real(default), dimension(:), intent(in), optional :: r type(particle_set_t), target :: prt_set type(particle_t), dimension(:), allocatable :: prt integer :: n_beam, n_in, n_vir, n_res, n_out, i, i_res, i_term, i_tree type(interaction_t), pointer :: int_matrix, int_flows integer, dimension(:), allocatable :: map type(resonance_tree_t) :: res_tree if (associated (evt%previous)) then if (evt%previous%particle_set_exists) then if (evt%selected_history > 0) then if (allocated (evt%instance)) then associate (instance => evt%instance(evt%selected_history)%p) call instance%evaluate_event_data (weight = 1._default) i_term = 1 int_matrix => instance%get_matrix_int_ptr (i_term) int_flows => instance%get_flows_int_ptr (i_term) call evt%factorize_interactions (int_matrix, int_flows, & factorization_mode, keep_correlations, r) call evt%tag_incoming () end associate else ! this branch only for unit test evt%particle_set = evt%previous%particle_set end if i_tree = evt%selected_history & - evt%index_offset(evt%selected_component) call evt%res_history_set(evt%selected_component)%get_tree & (i_tree, res_tree) n_beam = evt%particle_set%get_n_beam () n_in = evt%particle_set%get_n_in () n_vir = evt%particle_set%get_n_vir () n_out = evt%particle_set%get_n_out () n_res = res_tree%get_n_resonances () allocate (map (n_beam + n_in + n_vir + n_out)) map(1:n_beam+n_in+n_vir) & = [(i, i = 1, n_beam+n_in+n_vir)] map(n_beam+n_in+n_vir+1:n_beam+n_in+n_vir+n_out) & = [(i + n_res, & & i = n_beam+n_in+n_vir+1, & & n_beam+n_in+n_vir+n_out)] call prt_set%transfer (evt%particle_set, n_res, map) do i = 1, n_res i_res = n_beam + n_in + n_vir + i call prt_set%insert (i_res, & PRT_RESONANT, & res_tree%get_flv (i), & res_tree%get_children (i, & & n_beam+n_in+n_vir, n_beam+n_in+n_vir+n_res)) end do do i = n_res, 1, -1 i_res = n_beam + n_in + n_vir + i call prt_set%recover_color (i_res) end do call prt_set%set_momentum & (map(:), evt%particle_set%get_momenta (), on_shell = .true.) do i = n_res, 1, -1 i_res = n_beam + n_in + n_vir + i call prt_set%recover_momentum (i_res) end do call evt%particle_set%final () evt%particle_set = prt_set call prt_set%final () evt%particle_set_exists = .true. else ! retain particle set, as copied from previous evt evt%particle_set_exists = .true. end if else evt%particle_set_exists = .false. end if else evt%particle_set_exists = .false. end if end subroutine evt_resonance_make_particle_set @ %def event_resonance_make_particle_set @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[resonance_insertion_ut.f90]]>>= <> module resonance_insertion_ut use unit_tests use resonance_insertion_uti <> <> contains <> end module resonance_insertion_ut @ %def resonance_insertion_ut @ <<[[resonance_insertion_uti.f90]]>>= <> module resonance_insertion_uti <> <> use format_utils, only: write_separator use os_interface use lorentz use rng_base, only: rng_t use flavors, only: flavor_t use colors, only: color_t use models, only: syntax_model_file_init, syntax_model_file_final use models, only: model_list_t, model_t use particles, only: particle_t, particle_set_t use resonances, only: resonance_info_t use resonances, only: resonance_history_t use resonances, only: resonance_history_set_t use event_transforms use resonance_insertion use rng_base_ut, only: rng_test_t <> <> contains <> end module resonance_insertion_uti @ %def resonance_insertion_uti @ API: driver for the unit tests below. <>= public :: resonance_insertion_test <>= subroutine resonance_insertion_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine resonance_insertion_test @ %def resonance_insertion_test @ \subsubsection{Test resonance insertion as event transform} Insert a resonance (W boson) into an event with momentum assignment. <>= call test (resonance_insertion_1, "resonance_insertion_1", & "simple resonance insertion", & u, results) <>= public :: resonance_insertion_1 <>= subroutine resonance_insertion_1 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(particle_set_t) :: pset type(model_list_t) :: model_list type(model_t), pointer :: model type(resonance_info_t) :: res_info type(resonance_history_t) :: res_history type(resonance_history_set_t), dimension(1) :: res_history_set type(evt_trivial_t), target :: evt_trivial type(evt_resonance_t), target :: evt_resonance type(flavor_t) :: fw type(color_t) :: col real(default) :: mw, ew, pw type(vector4_t), dimension(5) :: p class(rng_t), allocatable :: rng real(default) :: probability integer, dimension(:), allocatable :: i_invalid type(particle_t), dimension(:), allocatable :: prt_invalid integer :: i write (u, "(A)") "* Test output: resonance_insertion_1" write (u, "(A)") "* Purpose: apply simple resonance insertion" write (u, "(A)") write (u, "(A)") "* Initialize environment" write (u, "(A)") call syntax_model_file_init () call os_data%init () call model_list%read_model & (var_str ("SM"), var_str ("SM.mdl"), & os_data, model) ! reset slightly in order to avoid a rounding ambiguity call model%set_real (var_str ("mW"), 80.418_default) write (u, "(A)") "* Initialize particle set" write (u, "(A)") call pset%init_direct (n_beam = 0, n_in = 2, n_rem = 0, n_vir = 0, n_out = 3, & pdg = [1, -1, 1, -2, 24], model = model) call fw%init (24, model) mw = fw%get_mass () ew = 200._default pw = sqrt (ew**2 - mw**2) p(1) = vector4_moving (ew, ew, 3) p(2) = vector4_moving (ew,-ew, 3) p(3) = vector4_moving (ew/2, vector3_moving ([pw/2, mw/2, 0._default])) p(4) = vector4_moving (ew/2, vector3_moving ([pw/2,-mw/2, 0._default])) p(5) = vector4_moving (ew, vector3_moving ([-pw, 0._default, 0._default])) call pset%set_momentum (p, on_shell = .true.) call col%init_col_acl (1,0) call pset%set_color (1, col) call col%init_col_acl (0,1) call pset%set_color (2, col) call col%init_col_acl (2,0) call pset%set_color (3, col) call col%init_col_acl (0,2) call pset%set_color (4, col) call col%init_col_acl (0,0) call pset%set_color (5, col) write (u, "(A)") "* Fill trivial event transform" write (u, "(A)") call evt_trivial%reset () call evt_trivial%set_particle_set (pset, 1, 1) call evt_trivial%write (u) call write_separator (u, 2) write (u, "(A)") write (u, "(A)") "* Prepare resonance history set" write (u, "(A)") call res_history_set(1)%init () call res_info%init (3, -24, model, 2) call res_history%add_resonance (res_info) call res_history_set(1)%enter (res_history) call res_history%clear () call res_history_set(1)%freeze () write (u, "(A)") "* Initialize resonance insertion transform" write (u, "(A)") evt_trivial%next => evt_resonance evt_resonance%previous => evt_trivial allocate (rng_test_t :: rng) call evt_resonance%import_rng (rng) call evt_resonance%set_resonance_data (res_history_set) call evt_resonance%select_component (1) call evt_resonance%write (u) write (u, "(A)") write (u, "(A)") "* Fill resonance insertion transform" write (u, "(A)") call evt_resonance%prepare_new_event (1, 1) call evt_resonance%init_selector ([1._default]) call evt_resonance%generate_weighted (probability) call evt_resonance%make_particle_set (0, .false.) call evt_resonance%write (u) write (u, "(A)") write (u, "(A,1x,F8.5)") "Event probability =", probability write (u, "(A)") call evt_resonance%find_prt_invalid_color (i_invalid, prt_invalid) write (u, "(A)") "Particles with invalid color:" select case (size (prt_invalid)) case (0) write (u, "(2x,A)") "[none]" case default do i = 1, size (prt_invalid) write (u, "(1x,A,1x,I0)", advance="no") "Particle", i_invalid(i) call prt_invalid(i)%write (u) end do end select write (u, "(A)") write (u, "(A)") "* Cleanup" call evt_resonance%final () call evt_trivial%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: resonance_insertion_1" end subroutine resonance_insertion_1 @ %def resonance_insertion_1 @ \subsubsection{Resonance insertion with color mismatch} Same as previous test (but no momenta); resonance insertion should fail because of color mismatch: W boson is color-neutral. <>= call test (resonance_insertion_2, "resonance_insertion_2", & "resonance color mismatch", & u, results) <>= public :: resonance_insertion_2 <>= subroutine resonance_insertion_2 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(particle_set_t) :: pset type(model_list_t) :: model_list type(model_t), pointer :: model type(resonance_info_t) :: res_info type(resonance_history_t) :: res_history type(resonance_history_set_t), dimension(1) :: res_history_set type(evt_trivial_t), target :: evt_trivial type(evt_resonance_t), target :: evt_resonance type(color_t) :: col class(rng_t), allocatable :: rng real(default) :: probability type(particle_t), dimension(:), allocatable :: prt_invalid integer, dimension(:), allocatable :: i_invalid integer :: i write (u, "(A)") "* Test output: resonance_insertion_2" write (u, "(A)") "* Purpose: resonance insertion with color mismatch" write (u, "(A)") write (u, "(A)") "* Initialize environment" write (u, "(A)") call syntax_model_file_init () call os_data%init () call model_list%read_model & (var_str ("SM"), var_str ("SM.mdl"), & os_data, model) write (u, "(A)") "* Initialize particle set" write (u, "(A)") call pset%init_direct (n_beam = 0, n_in = 2, n_rem = 0, n_vir = 0, n_out = 3, & pdg = [1, -1, 1, -2, 24], model = model) call col%init_col_acl (1,0) call pset%set_color (1, col) call col%init_col_acl (0,2) call pset%set_color (2, col) call col%init_col_acl (1,0) call pset%set_color (3, col) call col%init_col_acl (0,2) call pset%set_color (4, col) call col%init_col_acl (0,0) call pset%set_color (5, col) write (u, "(A)") "* Fill trivial event transform" write (u, "(A)") call evt_trivial%reset () call evt_trivial%set_particle_set (pset, 1, 1) call evt_trivial%write (u) call write_separator (u, 2) write (u, "(A)") write (u, "(A)") "* Prepare resonance history set" write (u, "(A)") call res_history_set(1)%init () call res_info%init (3, -24, model, 2) call res_history%add_resonance (res_info) call res_history_set(1)%enter (res_history) call res_history%clear () call res_history_set(1)%freeze () write (u, "(A)") "* Initialize resonance insertion transform" write (u, "(A)") evt_trivial%next => evt_resonance evt_resonance%previous => evt_trivial allocate (rng_test_t :: rng) call evt_resonance%import_rng (rng) call evt_resonance%set_resonance_data (res_history_set) call evt_resonance%select_component (1) call evt_resonance%write (u) write (u, "(A)") write (u, "(A)") "* Fill resonance insertion transform" write (u, "(A)") call evt_resonance%prepare_new_event (1, 1) call evt_resonance%init_selector ([1._default]) call evt_resonance%generate_weighted (probability) call evt_resonance%make_particle_set (0, .false.) call evt_resonance%write (u) write (u, "(A)") write (u, "(A,1x,F8.5)") "Event probability =", probability write (u, "(A)") call evt_resonance%find_prt_invalid_color (i_invalid, prt_invalid) write (u, "(A)") "Particles with invalid color:" select case (size (prt_invalid)) case (0) write (u, "(2x,A)") "[none]" case default do i = 1, size (prt_invalid) write (u, "(1x,A,1x,I0)", advance="no") "Particle", i_invalid(i) call prt_invalid(i)%write (u) end do end select write (u, "(A)") write (u, "(A)") "* Cleanup" call evt_resonance%final () call evt_trivial%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: resonance_insertion_2" end subroutine resonance_insertion_2 @ %def resonance_insertion_2 @ \subsubsection{Complex resonance history} This is the resonance history $u\bar u \to (t\to W^+ b) + (\bar t\to (h \to b\bar b) + (\bar t^\ast \to W^-\bar b))$. <>= call test (resonance_insertion_3, "resonance_insertion_3", & "complex resonance history", & u, results) <>= public :: resonance_insertion_3 <>= subroutine resonance_insertion_3 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(particle_set_t) :: pset type(model_list_t) :: model_list type(model_t), pointer :: model type(resonance_info_t) :: res_info type(resonance_history_t) :: res_history type(resonance_history_set_t), dimension(1) :: res_history_set type(evt_trivial_t), target :: evt_trivial type(evt_resonance_t), target :: evt_resonance type(color_t) :: col class(rng_t), allocatable :: rng real(default) :: probability type(particle_t), dimension(:), allocatable :: prt_invalid integer, dimension(:), allocatable :: i_invalid integer :: i write (u, "(A)") "* Test output: resonance_insertion_3" write (u, "(A)") "* Purpose: resonance insertion with color mismatch" write (u, "(A)") write (u, "(A)") "* Initialize environment" write (u, "(A)") call syntax_model_file_init () call os_data%init () call model_list%read_model & (var_str ("SM"), var_str ("SM.mdl"), & os_data, model) write (u, "(A)") "* Initialize particle set" write (u, "(A)") call pset%init_direct (n_beam = 0, n_in = 2, n_rem = 0, n_vir = 0, n_out = 6, & pdg = [2, -2, 24, 5, 5, -5, -24, -5], model = model) call col%init_col_acl (1,0) call pset%set_color (1, col) call col%init_col_acl (0,2) call pset%set_color (2, col) call col%init_col_acl (0,0) call pset%set_color (3, col) call col%init_col_acl (1,0) call pset%set_color (4, col) call col%init_col_acl (3,0) call pset%set_color (5, col) call col%init_col_acl (0,3) call pset%set_color (6, col) call col%init_col_acl (0,0) call pset%set_color (7, col) call col%init_col_acl (0,2) call pset%set_color (8, col) write (u, "(A)") "* Fill trivial event transform" write (u, "(A)") call evt_trivial%reset () call evt_trivial%set_particle_set (pset, 1, 1) call evt_trivial%write (u) call write_separator (u, 2) write (u, "(A)") write (u, "(A)") "* Prepare resonance history set" write (u, "(A)") call res_history_set(1)%init () call res_info%init (3, 6, model, 6) call res_history%add_resonance (res_info) call res_info%init (12, 25, model, 6) call res_history%add_resonance (res_info) call res_info%init (60, -6, model, 6) call res_history%add_resonance (res_info) call res_history_set(1)%enter (res_history) call res_history%clear () call res_history_set(1)%freeze () write (u, "(A)") "* Initialize resonance insertion transform" write (u, "(A)") evt_trivial%next => evt_resonance evt_resonance%previous => evt_trivial allocate (rng_test_t :: rng) call evt_resonance%import_rng (rng) call evt_resonance%set_resonance_data (res_history_set) call evt_resonance%select_component (1) call evt_resonance%write (u) write (u, "(A)") write (u, "(A)") "* Fill resonance insertion transform" write (u, "(A)") call evt_resonance%prepare_new_event (1, 1) call evt_resonance%init_selector ([1._default]) call evt_resonance%generate_weighted (probability) call evt_resonance%make_particle_set (0, .false.) call evt_resonance%write (u) write (u, "(A)") call evt_resonance%find_prt_invalid_color (i_invalid, prt_invalid) write (u, "(A)") "Particles with invalid color:" select case (size (prt_invalid)) case (0) write (u, "(2x,A)") "[none]" case default do i = 1, size (prt_invalid) write (u, "(1x,A,1x,I0)", advance="no") "Particle", i_invalid(i) call prt_invalid(i)%write (u) end do end select write (u, "(A)") write (u, "(A)") "* Cleanup" call evt_resonance%final () call evt_trivial%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: resonance_insertion_3" end subroutine resonance_insertion_3 @ %def resonance_insertion_3 @ \subsubsection{Resonance history selection} Another test with zero momenta: select one of several resonant channels using the selector component. <>= call test (resonance_insertion_4, "resonance_insertion_4", & "resonance history selection", & u, results) <>= public :: resonance_insertion_4 <>= subroutine resonance_insertion_4 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(particle_set_t) :: pset type(model_list_t) :: model_list type(model_t), pointer :: model type(resonance_info_t) :: res_info type(resonance_history_t) :: res_history type(resonance_history_set_t), dimension(1) :: res_history_set type(evt_trivial_t), target :: evt_trivial type(evt_resonance_t), target :: evt_resonance type(color_t) :: col class(rng_t), allocatable :: rng real(default) :: probability integer :: i write (u, "(A)") "* Test output: resonance_insertion_4" write (u, "(A)") "* Purpose: resonance history selection" write (u, "(A)") write (u, "(A)") "* Initialize environment" write (u, "(A)") call syntax_model_file_init () call os_data%init () call model_list%read_model & (var_str ("SM"), var_str ("SM.mdl"), & os_data, model) write (u, "(A)") "* Initialize particle set" write (u, "(A)") call pset%init_direct (n_beam = 0, n_in = 2, n_rem = 0, n_vir = 0, n_out = 4, & pdg = [1, -1, 1, -2, -3, 4], model = model) write (u, "(A)") "* Fill trivial event transform" write (u, "(A)") call evt_trivial%reset () call evt_trivial%set_particle_set (pset, 1, 1) call evt_trivial%write (u) call write_separator (u, 2) write (u, "(A)") write (u, "(A)") "* Prepare resonance history set" write (u, "(A)") call res_history_set(1)%init () call res_info%init (3, -24, model, 4) call res_history%add_resonance (res_info) call res_history_set(1)%enter (res_history) call res_history%clear () call res_info%init (12, 24, model, 4) call res_history%add_resonance (res_info) call res_history_set(1)%enter (res_history) call res_history%clear () call res_info%init (12, 24, model, 4) call res_history%add_resonance (res_info) call res_info%init (15, 25, model, 4) call res_history%add_resonance (res_info) call res_history_set(1)%enter (res_history) call res_history%clear () call res_history_set(1)%freeze () write (u, "(A)") "* Initialize resonance insertion transform" write (u, "(A)") evt_trivial%next => evt_resonance evt_resonance%previous => evt_trivial allocate (rng_test_t :: rng) call evt_resonance%import_rng (rng) call evt_resonance%set_resonance_data (res_history_set) call evt_resonance%select_component (1) call evt_resonance%write (u) write (u, "(A)") write (u, "(A)") "* Fill resonance insertion transform" write (u, "(A)") do i = 1, 6 write (u, "(A,1x,I0)") "* Event #", i write (u, "(A)") call evt_resonance%prepare_new_event (1, 1) call evt_resonance%init_selector ([1._default, 2._default, 1._default]) call evt_resonance%generate_weighted (probability) call evt_resonance%make_particle_set (0, .false.) call evt_resonance%write (u) write (u, "(A)") end do write (u, "(A)") write (u, "(A)") "* Cleanup" call evt_resonance%final () call evt_trivial%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: resonance_insertion_4" end subroutine resonance_insertion_4 @ %def resonance_insertion_4 @ \subsubsection{Resonance history selection} Another test with zero momenta: select either a resonant channel or no resonance. <>= call test (resonance_insertion_5, "resonance_insertion_5", & "resonance history on/off", & u, results) <>= public :: resonance_insertion_5 <>= subroutine resonance_insertion_5 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(particle_set_t) :: pset type(model_list_t) :: model_list type(model_t), pointer :: model type(resonance_info_t) :: res_info type(resonance_history_t) :: res_history type(resonance_history_set_t), dimension(1) :: res_history_set type(evt_trivial_t), target :: evt_trivial type(evt_resonance_t), target :: evt_resonance type(color_t) :: col class(rng_t), allocatable :: rng real(default) :: probability integer :: i write (u, "(A)") "* Test output: resonance_insertion_5" write (u, "(A)") "* Purpose: resonance history selection including no resonance" write (u, "(A)") write (u, "(A)") "* Initialize environment" write (u, "(A)") call syntax_model_file_init () call os_data%init () call model_list%read_model & (var_str ("SM"), var_str ("SM.mdl"), & os_data, model) write (u, "(A)") "* Initialize particle set" write (u, "(A)") call pset%init_direct (n_beam = 0, n_in = 2, n_rem = 0, n_vir = 0, n_out = 4, & pdg = [1, -1, 1, -2, -3, 4], model = model) write (u, "(A)") "* Fill trivial event transform" write (u, "(A)") call evt_trivial%reset () call evt_trivial%set_particle_set (pset, 1, 1) write (u, "(A)") "* Prepare resonance history set" write (u, "(A)") call res_history_set(1)%init () call res_info%init (3, -24, model, 4) call res_history%add_resonance (res_info) call res_history_set(1)%enter (res_history) call res_history%clear () call res_history_set(1)%freeze () write (u, "(A)") "* Initialize resonance insertion transform" write (u, "(A)") evt_trivial%next => evt_resonance evt_resonance%previous => evt_trivial allocate (rng_test_t :: rng) call evt_resonance%import_rng (rng) call evt_resonance%set_resonance_data (res_history_set) call evt_resonance%select_component (1) write (u, "(A)") "* Fill resonance insertion transform" write (u, "(A)") do i = 1, 2 write (u, "(A,1x,I0)") "* Event #", i write (u, "(A)") call evt_resonance%prepare_new_event (1, 1) call evt_resonance%init_selector ([1._default, 3._default], offset = -1) call evt_resonance%generate_weighted (probability) call evt_resonance%make_particle_set (0, .false.) call evt_resonance%write (u) write (u, "(A)") end do write (u, "(A)") write (u, "(A)") "* Cleanup" call evt_resonance%final () call evt_trivial%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: resonance_insertion_5" end subroutine resonance_insertion_5 @ %def resonance_insertion_5 @ \subsubsection{Resonance insertion with structured beams} Insert a resonance (W boson) into an event with beam and virtual particles. <>= call test (resonance_insertion_6, "resonance_insertion_6", & "resonance insertion with beam structure", & u, results) <>= public :: resonance_insertion_6 <>= subroutine resonance_insertion_6 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(model_list_t) :: model_list type(particle_set_t) :: pset type(model_t), pointer :: model type(resonance_info_t) :: res_info type(resonance_history_t) :: res_history type(resonance_history_set_t), dimension(1) :: res_history_set type(evt_trivial_t), target :: evt_trivial type(evt_resonance_t), target :: evt_resonance class(rng_t), allocatable :: rng real(default) :: probability write (u, "(A)") "* Test output: resonance_insertion_6" write (u, "(A)") "* Purpose: resonance insertion with structured beams" write (u, "(A)") write (u, "(A)") "* Initialize environment" write (u, "(A)") call syntax_model_file_init () call os_data%init () call model_list%read_model & (var_str ("SM"), var_str ("SM.mdl"), & os_data, model) write (u, "(A)") "* Initialize particle set" write (u, "(A)") call pset%init_direct (n_beam = 2, n_in = 2, n_rem = 2, n_vir = 0, n_out = 2, & pdg = [11, -11, 11, -11, 22, 22, 13, -13], model = model) write (u, "(A)") "* Fill trivial event transform" write (u, "(A)") call evt_trivial%reset () call evt_trivial%set_particle_set (pset, 1, 1) call evt_trivial%write (u) call write_separator (u, 2) write (u, "(A)") write (u, "(A)") "* Prepare resonance history set" write (u, "(A)") call res_history_set(1)%init () call res_info%init (3, 23, model, 2) call res_history%add_resonance (res_info) call res_history_set(1)%enter (res_history) call res_history%clear () call res_history_set(1)%freeze () write (u, "(A)") "* Initialize resonance insertion transform" write (u, "(A)") evt_trivial%next => evt_resonance evt_resonance%previous => evt_trivial allocate (rng_test_t :: rng) call evt_resonance%import_rng (rng) call evt_resonance%set_resonance_data (res_history_set) call evt_resonance%select_component (1) call evt_resonance%write (u) write (u, "(A)") write (u, "(A)") "* Fill resonance insertion transform" write (u, "(A)") call evt_resonance%prepare_new_event (1, 1) call evt_resonance%init_selector ([1._default]) call evt_resonance%generate_weighted (probability) call evt_resonance%make_particle_set (0, .false.) call evt_resonance%write (u) write (u, "(A)") write (u, "(A,1x,F8.5)") "Event probability =", probability write (u, "(A)") write (u, "(A)") "* Cleanup" call evt_resonance%final () call evt_trivial%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: resonance_insertion_6" end subroutine resonance_insertion_6 @ %def resonance_insertion_6 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Recoil kinematics} <<[[recoil_kinematics.f90]]>>= <> module recoil_kinematics <> use constants, only: twopi use lorentz, only: vector4_t use lorentz, only: vector4_null use lorentz, only: vector4_moving use lorentz, only: vector3_moving use lorentz, only: transverse_part use lorentz, only: lorentz_transformation_t use lorentz, only: inverse use lorentz, only: boost use lorentz, only: transformation use lorentz, only: operator(+) use lorentz, only: operator(-) use lorentz, only: operator(*) use lorentz, only: operator(**) use lorentz, only: lambda <> <> <> <> contains <> end module recoil_kinematics @ %def recoil_kinematics @ \subsection{$\phi$ sampler} This is trivial. Generate an azimuthal angle, given a $(0,1)$ RNG parameter. <>= elemental subroutine generate_phi_recoil (r, phi) real(default), intent(in) :: r real(default), intent(out) :: phi phi = r * twopi end subroutine generate_phi_recoil @ %def generate_phi_recoil @ \subsection{$Q^2$ sampler} The dynamics of factorization suggests to generate a flat $Q^2$ distribution from a (random) number, event by event. At the lowest momentum transfer values, the particle (electron) mass sets a smooth cutoff. The formula can produce $Q$ values below the electron mass, down to zero, but with a power distribution that eventually evolves into the expected logarithmic distribution for $Q^2 > m^2$. We are talking about the absolute value here, so all $Q^2$ values are positive. For the actual momentum transfer, $q^2=-Q^2$. <>= public :: generate_q2_recoil <>= elemental subroutine generate_q2_recoil (s, x_bar, q2_max, m2, r, q2) real(default), intent(in) :: s real(default), intent(in) :: q2_max real(default), intent(in) :: x_bar real(default), intent(in) :: m2 real(default), intent(in) :: r real(default), intent(out) :: q2 real(default) :: q2_max_evt q2_max_evt = q2_max_event (s, x_bar, q2_max) q2 = m2 * (exp (r * log (1 + (q2_max_evt / m2))) - 1) end subroutine generate_q2_recoil @ %def generate_q_recoil @ The $Q$ distribution is cut off from above by the kinematic limit, which depends on the energy that is available for the radiated photon, or by a user-defined cutoff -- whichever is less. The kinematic limit fits the formulas for recoil momenta (see below), and it also implicitly enters the ISR collinear structure function, so the normalization of the distribution should be correct. <>= elemental function q2_max_event (s, x_bar, q2_max) result (q2) real(default), intent(in) :: s real(default), intent(in) :: x_bar real(default), intent(in) :: q2_max real(default) :: q2 q2 = min (x_bar * s, q2_max) end function q2_max_event @ %def q2_max_event @ \subsection{Kinematics functions} Given values for energies, $Q_{1,2}^2$, azimuthal angle, compute the matching polar angle of the radiating particle. The subroutine returns $\sin\theta$ and $\cos\theta$. <>= subroutine polar_angles (s, xb, rho, ee, q2, sin_th, cos_th, ok) real(default), intent(in) :: s real(default), intent(in) :: xb real(default), intent(in) :: rho real(default), dimension(2), intent(in) :: ee real(default), dimension(2), intent(in) :: q2 real(default), dimension(2), intent(out) :: sin_th real(default), dimension(2), intent(out) :: cos_th logical, intent(out) :: ok real(default), dimension(2) :: sin2_th_2 sin2_th_2 = q2 / (ee * rho * xb * s) if (all (sin2_th_2 <= 1)) then sin_th = 2 * sqrt (sin2_th_2 * (1 - sin2_th_2)) cos_th = 1 - 2 * sin2_th_2 ok = .true. else sin_th = 0 cos_th = 1 ok = .false. end if end subroutine polar_angles @ %def polar_angles @ Compute the acollinearity parameter $\lambda$ from azimuthal and polar angles. The result is a number between $0$ and $1$. <>= function lambda_factor (sin_th, cos_th, cphi) result (lambda) real(default), dimension(2), intent(in) :: sin_th real(default), dimension(2), intent(in) :: cos_th real(default), intent(in) :: cphi real(default) :: lambda lambda = (1 - cos_th(1) * cos_th(2) - cphi * sin_th(1) * sin_th(2)) / 2 end function lambda_factor @ %def lambda_factor @ Compute the factor that rescales photon energies, such that the radiation angles match the kinematics parameters. For small values of $\bar x/\cosh\eta$, we have to use the Taylor expansion if we do not want to lose precision. The optional argument allows for a unit test that compares exact and approximate. <>= function scale_factor (che, lambda, xb0, approximate) result (rho) real(default), intent(in) :: che real(default), intent(in) :: lambda real(default), intent(in) :: xb0 logical, intent(in), optional :: approximate real(default) :: rho real(default), parameter :: & e0 = (100 * epsilon (1._default)) ** (0.3_default) logical :: approx if (present (approximate)) then approx = approximate else approx = (xb0/che) < e0 end if if (approx) then rho = 1 - lambda * (xb0/(2*che)) * (1 + (1-lambda) * (xb0/che)) else rho = (che / ((1-lambda)*xb0)) & * (1 - sqrt (1 - 2 * (1-lambda) * (xb0/che) & & + (1-lambda) * (xb0 / che)**2)) end if end function scale_factor @ %def scale_factor @ The code snippet below is not used anywhere, but may be manually inserted in a unit test to numerically verify the approximation above. <>= write (u, "(A)") write (u, "(A)") "*** Table: scale factor calculation" write (u, "(A)") lambda = 0.25_default write (u, FMT1) "lambda =", lambda che = 4._default write (u, FMT1) "che =", che write (u, "(A)") " x0 rho(exact) rho(approx) rho(chosen)" xb0 = 1._default do i = 1, 30 xb0 = xb0 / 10 write (u, FMT4) xb0, & scale_factor (che, lambda, xb0, approximate=.false.), & scale_factor (che, lambda, xb0, approximate=.true.), & scale_factor (che, lambda, xb0) end do @ Compute the current values for the $x_{1,2}$ parameters, given the updated scale factor $\rho$ and the collinear parameters. <>= subroutine scaled_x (rho, ee, xb0, x, xb) real(default), intent(in) :: rho real(default), dimension(2), intent(in) :: ee real(default), intent(in) :: xb0 real(default), dimension(2), intent(out) :: x real(default), dimension(2), intent(out) :: xb xb = rho * ee * xb0 x = 1 - xb end subroutine scaled_x @ %def scaled_x @ \subsection{Iterative solution of kinematics constraints} Find a solution of the kinematics constraints. We know the parameters appropriate for collinear kinematics $\sqrt{s}$, $x^c_{1,2}$. We have picked values vor the momentum transfer $Q_{1,2}$ and the azimuthal angles $\phi_{1,2}$. The solution consists of modified energy fractions $x_{1,2}$ and polar angles $\theta_{1,2}$. If the computation fails, which can happen for large momentum transfer, the flag [[ok]] will indicate this. <>= public :: solve_recoil <>= subroutine solve_recoil (sqrts, xc, xcb, phi, q2, x, xb, cos_th, sin_th, ok) real(default), intent(in) :: sqrts real(default), dimension(2), intent(in) :: xc real(default), dimension(2), intent(in) :: xcb real(default), dimension(2), intent(in) :: phi real(default), dimension(2), intent(in) :: q2 real(default), dimension(2), intent(out) :: x real(default), dimension(2), intent(out) :: xb real(default), dimension(2), intent(out) :: cos_th real(default), dimension(2), intent(out) :: sin_th logical, intent(out) :: ok real(default) :: s real(default), dimension(2) :: ee real(default), dimension(2) :: th real(default) :: xb0, cphi real(default) :: che, lambda real(default) :: rho_new, rho, rho_old real(default) :: dr_old, dr_new real(default), parameter :: dr_limit = 100 * epsilon (1._default) integer, parameter :: n_it_max = 20 integer :: i ok = .true. s = sqrts**2 ee = sqrt ([xcb(1)/xcb(2), xcb(2)/xcb(1)]) che = sum (ee) / 2 xb0 = sqrt (xcb(1) * xcb(2)) cphi = cos (phi(1) - phi(2)) rho_old = 10 rho = 1 th = 0 sin_th = sin (th) cos_th = cos (th) lambda = lambda_factor (sin_th, cos_th, cphi) call scaled_x (rho, ee, xb0, x, xb) iterate_loop: do i = 1, n_it_max call polar_angles (s, xb0, rho, ee, q2, sin_th, cos_th, ok) if (.not. ok) return th = atan2 (sin_th, cos_th) lambda = lambda_factor (sin_th, cos_th, cphi) rho_new = scale_factor (che, lambda, xb0) call scaled_x (rho_new, ee, xb0, x, xb) dr_old = abs (rho - rho_old) dr_new = abs (rho_new - rho) rho_old = rho rho = rho_new if (dr_new < dr_limit .or. dr_new >= dr_old) exit iterate_loop end do iterate_loop end subroutine solve_recoil @ %def solve_recoil @ With all kinematics parameters known, construct actual four-vectors for the recoil momenta, the off-shell (spacelike) parton momenta, and on-shell projected parton momenta. <>= public :: recoil_momenta <>= subroutine recoil_momenta (sqrts, xc, xb, cos_th, sin_th, phi, mo, & km, qm, qo, ok) real(default), intent(in) :: sqrts real(default), dimension(2), intent(in) :: xc real(default), dimension(2), intent(in) :: xb real(default), dimension(2), intent(in) :: cos_th real(default), dimension(2), intent(in) :: sin_th real(default), dimension(2), intent(in) :: phi real(default), dimension(2), intent(in) :: mo type(vector4_t), dimension(2), intent(out) :: km type(vector4_t), dimension(2), intent(out) :: qm type(vector4_t), dimension(2), intent(out) :: qo logical, intent(out) :: ok type(vector4_t), dimension(2) :: pm type(lorentz_transformation_t) :: lt real(default) :: sqsh real(default) :: po4, po2 real(default), dimension(2) :: p0, p3 pm(1) = & vector4_moving (sqrts/2, & vector3_moving ([0._default, 0._default, sqrts/2])) pm(2) = & vector4_moving (sqrts/2, & vector3_moving ([0._default, 0._default,-sqrts/2])) km(1) = xb(1) * (sqrts/2) * vector4_moving ( & 1._default, & vector3_moving ([ & & sin_th(1) * cos (phi(1)), & & sin_th(1) * sin (phi(1)), & & cos_th(1)]) & ) km(2) = xb(2) * (sqrts/2) * vector4_moving ( & 1._default, & vector3_moving ([ & & -sin_th(2) * cos (phi(2)), & & -sin_th(2) * sin (phi(2)), & & -cos_th(2)]) & ) qm(1) = pm(1) - km(1) qm(2) = pm(2) - km(2) sqsh = sqrt (xc(1)*xc(2)) * sqrts lt = transformation (3, qm(1), qm(2), sqsh) po4 = lambda (sqsh**2, mo(1)**2, mo(2)**2) ok = po4 > 0 if (ok) then po2 = sqrt (po4)/4 p0 = sqrt (po2 + mo**2) p3 = [sqrt (po2), -sqrt (po2)] qo = lt * vector4_moving (p0, p3, 3) else qo = vector4_null end if end subroutine recoil_momenta @ %def recoil_momenta @ Compute the Lorentz transformation that we can use to transform any outgoing momenta into the new c.m.\ system of the incoming partons. Not relying on the previous calculations, we determine the transformation that transforms the original collinear partons into their c.m.\ system, and then transform this to the new c.m.\ system. <>= public :: recoil_transformation <>= subroutine recoil_transformation (sqrts, xc, qo, lt) real(default), intent(in) :: sqrts real(default), dimension(2), intent(in) :: xc type(vector4_t), dimension(2), intent(in) :: qo type(lorentz_transformation_t), intent(out) :: lt real(default) :: sqsh type(vector4_t), dimension(2) :: qc type(lorentz_transformation_t) :: ltc, lto qc(1) = xc(1) * vector4_moving (sqrts/2, sqrts/2, 3) qc(2) = xc(2) * vector4_moving (sqrts/2,-sqrts/2, 3) sqsh = sqrt (xc(1) * xc(2)) * sqrts ltc = transformation (3, qc(1), qc(2), sqsh) lto = transformation (3, qo(1), qo(2), sqsh) lt = lto * inverse (ltc) end subroutine recoil_transformation @ %def recoil_transformation @ Compute the Lorentz boost that transforms the c.m.\ frame of the momenta into the lab frame where they are given. Also return their common invariant mass, $\sqrt{s}$. If the initial momenta are not collinear, [[ok]] is set false. <>= public :: initial_transformation <>= subroutine initial_transformation (p, sqrts, lt, ok) type(vector4_t), dimension(2), intent(in) :: p real(default), intent(out) :: sqrts type(lorentz_transformation_t), intent(out) :: lt logical, intent(out) :: ok ok = all (transverse_part (p) == 0) sqrts = (p(1) + p(2)) ** 1 lt = boost (p(1) + p(2), sqrts) end subroutine initial_transformation @ %def initial_transformation @ \subsection{Generate recoil event} Combine the above kinematics calculations. First generate azimuthal angles and momentum transfer, solve kinematics and compute momenta for the radiated photons and the on-shell projected, recoiling partons. The [[mo]] masses are used for the on-shell projection of the partons after radiation. They may be equal to [[m]], or set to zero. If [[ok]] is false, the data point has failed and we should repeat the procedure for a new set of RNG parameters [[r]]. <>= public :: generate_recoil <>= subroutine generate_recoil (sqrts, q_max, m, mo, xc, xcb, r, km, qm, qo, ok) real(default), intent(in) :: sqrts real(default), intent(in), dimension(2) :: q_max real(default), intent(in), dimension(2) :: m real(default), intent(in), dimension(2) :: mo real(default), intent(in), dimension(2) :: xc real(default), intent(in), dimension(2) :: xcb real(default), intent(in), dimension(4) :: r type(vector4_t), dimension(2), intent(out) :: km type(vector4_t), dimension(2), intent(out) :: qm type(vector4_t), dimension(2), intent(out) :: qo logical, intent(out) :: ok real(default), dimension(2) :: q2 real(default), dimension(2) :: phi real(default), dimension(2) :: x real(default), dimension(2) :: xb real(default), dimension(2) :: cos_th real(default), dimension(2) :: sin_th call generate_q2_recoil (sqrts**2, xcb, q_max**2, m**2, r(1:2), q2) call generate_phi_recoil (r(3:4), phi) call solve_recoil (sqrts, xc, xcb, phi, q2, x, xb, cos_th, sin_th, ok) if (ok) then call recoil_momenta & (sqrts, xc, xb, cos_th, sin_th, phi, mo, km, qm, qo, ok) end if end subroutine generate_recoil @ %def generate_recoil @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[recoil_kinematics_ut.f90]]>>= <> module recoil_kinematics_ut use unit_tests use recoil_kinematics_uti <> <> contains <> end module recoil_kinematics_ut @ %def recoil_kinematics_ut @ <<[[recoil_kinematics_uti.f90]]>>= <> module recoil_kinematics_uti <> use constants, only: twopi use constants, only: degree use lorentz, only: vector4_t use lorentz, only: vector4_moving use lorentz, only: lorentz_transformation_t use lorentz, only: inverse use lorentz, only: operator(+) use lorentz, only: operator(*) use lorentz, only: operator(**) use lorentz, only: pacify use recoil_kinematics, only: solve_recoil use recoil_kinematics, only: recoil_momenta use recoil_kinematics, only: recoil_transformation use recoil_kinematics, only: initial_transformation use recoil_kinematics, only: generate_q2_recoil use recoil_kinematics, only: generate_recoil <> <> contains <> end module recoil_kinematics_uti @ %def recoil_kinematics_uti @ API: driver for the unit tests below. <>= public :: recoil_kinematics_test <>= subroutine recoil_kinematics_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine recoil_kinematics_test @ %def recoil_kinematics_test @ \subsubsection{Recoil kinematics} For a set of input data, solve the kinematics constraints and generate momenta accordingly. <>= call test (recoil_kinematics_1, "recoil_kinematics_1", & "iterative solution of non-collinear kinematics", & u, results) <>= public :: recoil_kinematics_1 <>= subroutine recoil_kinematics_1 (u) integer, intent(in) :: u real(default) :: sqrts real(default), dimension(2) :: xc, xcb real(default), dimension(2) :: q real(default), dimension(2) :: phi real(default), dimension(2) :: mo real(default), dimension(2) :: cos_th, sin_th real(default), dimension(2) :: x real(default), dimension(2) :: xb type(vector4_t), dimension(2) :: km type(vector4_t), dimension(2) :: qm type(vector4_t), dimension(2) :: qo integer :: i logical :: ok character(*), parameter :: FMT1 = "(1x,A,9(1x,F15.10))" character(*), parameter :: FMT2 = "(1x,A,9(1x,F10.5))" character(*), parameter :: FMT4 = "(3x,ES8.1,9(1x,ES19.12))" write (u, "(A)") "* Test output: recoil_kinematics_1" write (u, "(A)") "* Purpose: compute kinematics for various input data" write (u, "(A)") sqrts = 100 write (u, FMT1) "sqrts =", sqrts write (u, "(A)") write (u, "(A)") "*** collinear data set" write (u, "(A)") xc = [0.6_default, 0.9_default] xcb = 1 - xc phi = [0.1_default, 0.2_default] * twopi q = 0 mo = 0 call show_data call solve_recoil (sqrts, xc, xcb, phi, q**2, x, xb, cos_th, sin_th, ok) call show_results call recoil_momenta (sqrts, xc, xb, cos_th, sin_th, phi, mo, km, qm, qo, ok) call show_momenta write (u, "(A)") write (u, "(A)") "*** moderate data set" write (u, "(A)") xc = [0.6_default, 0.9_default] xcb = 1 - xc phi = [0.1_default, 0.2_default] * twopi q = [0.2_default, 0.05_default] * sqrts call show_data call solve_recoil (sqrts, xc, xcb, phi, q**2, x, xb, cos_th, sin_th, ok) call show_results call recoil_momenta (sqrts, xc, xb, cos_th, sin_th, phi, mo, km, qm, qo, ok) call show_momenta write (u, "(A)") write (u, "(A)") "*** semi-soft data set" write (u, "(A)") xcb= [0.1_default, 0.0001_default] xc = 1 - xcb phi = [0.1_default, 0.2_default] * twopi q = [0.2_default, 0.00001_default] * sqrts call show_data call solve_recoil (sqrts, xc, xcb, phi, q**2, x, xb, cos_th, sin_th, ok) call show_results call recoil_momenta (sqrts, xc, xb, cos_th, sin_th, phi, mo, km, qm, qo, ok) call show_momenta write (u, "(A)") write (u, "(A)") "*** hard-soft data set" write (u, "(A)") xcb= [0.1_default, 1.e-30_default] xc = 1 - xcb phi = [0.1_default, 0.2_default] * twopi q = [0.2_default, 1.e-35_default] * sqrts call show_data call solve_recoil (sqrts, xc, xcb, phi, q**2, x, xb, cos_th, sin_th, ok) call show_results call recoil_momenta (sqrts, xc, xb, cos_th, sin_th, phi, mo, km, qm, qo, ok) call show_momenta write (u, "(A)") write (u, "(A)") "*** hard data set" write (u, "(A)") xc = [0.2_default, 0.4_default] xcb = 1 - xc phi = [0.1_default, 0.8_default] * twopi q = [0.74_default, 0.3_default] * sqrts call show_data call solve_recoil (sqrts, xc, xcb, phi, q**2, x, xb, cos_th, sin_th, ok) call show_results call recoil_momenta (sqrts, xc, xb, cos_th, sin_th, phi, mo, km, qm, qo, ok) call show_momenta write (u, "(A)") write (u, "(A)") "*** failing data set" write (u, "(A)") xc = [0.2_default, 0.4_default] xcb = 1 - xc phi = [0.1_default, 0.8_default] * twopi q = [0.9_default, 0.3_default] * sqrts call show_data call solve_recoil (sqrts, xc, xcb, phi, q**2, x, xb, cos_th, sin_th, ok) if (.not. ok) then write (u, "(A)") write (u, "(A)") "Failed as expected." end if write (u, "(A)") write (u, "(A)") "* Test output end: recoil_kinematics_1" contains subroutine show_data write (u, FMT1) "sqs_h =", sqrt (xc(1) * xc(2)) * sqrts write (u, FMT1) "xc =", xc write (u, FMT1) "xcb =", xcb write (u, FMT1) "Q =", Q write (u, FMT1) "phi/D =", phi / degree end subroutine show_data subroutine show_results write (u, "(A)") write (u, "(A)") "Result:" write (u, FMT1) "th/D =", atan2 (sin_th, cos_th) / degree write (u, FMT1) "x =", x write (u, "(A)") end subroutine show_results subroutine show_momenta type(vector4_t) :: qm0, qo0 real(default), parameter :: tol = 1.e-7_default call pacify (km, tol) call pacify (qm, tol) call pacify (qo, tol) write (u, "(A)") "Momenta: k" call km(1)%write (u, testflag=.true.) call km(2)%write (u, testflag=.true.) write (u, FMT1) "k^2 =", abs (km(1)**2), abs (km(2)**2) write (u, "(A)") write (u, "(A)") "Momenta: q" call qm(1)%write (u, testflag=.true.) call qm(2)%write (u, testflag=.true.) write (u, "(A)") write (u, "(A)") "Momenta: q(os)" call qo(1)%write (u, testflag=.true.) call qo(2)%write (u, testflag=.true.) write (u, "(A)") write (u, "(A)") "Check: parton momentum sum: q vs q(os)" qm0 = qm(1) + qm(2) call qm0%write (u, testflag=.true.) qo0 = qo(1) + qo(2) call qo0%write (u, testflag=.true.) write (u, "(A)") write (u, "(A)") "* Check: momentum transfer (off-shell/on-shell)" write (u, FMT2) "|q| =", abs (qm(1)**1), abs (qm(2)**1) write (u, FMT2) "Q =", q write (u, FMT2) "|qo|=", abs (qo(1)**1), abs (qo(2)**1) write (u, "(A)") write (u, "(A)") "* Check: sqrts, sqrts_hat" write (u, FMT1) "|p| =", (km(1)+km(2)+qm(1)+qm(2))**1, (qm(1)+qm(2))**1 write (u, FMT1) "sqs =", sqrts, sqrt (product (xc)) * sqrts write (u, FMT1) "|po|=", abs ((km(1)+km(2)+qo(1)+qo(2))**1), abs ((qo(1)+qo(2))**1) end subroutine show_momenta end subroutine recoil_kinematics_1 @ %def recoil_kinematics_1 @ \subsubsection{Recoil $Q$ distribution} Sample the $Q$ distribution for equidistant bins in the input variable. <>= call test (recoil_kinematics_2, "recoil_kinematics_2", & "Q distribution", & u, results) <>= public :: recoil_kinematics_2 <>= subroutine recoil_kinematics_2 (u) integer, intent(in) :: u real(default) :: sqrts real(default) :: q_max real(default) :: m real(default) :: x_bar real(default) :: r real(default) :: q2, q2_old integer :: i integer :: n_bin character(*), parameter :: FMT1 = "(1x,A,9(1x,F15.10))" character(*), parameter :: FMT3 = "(2x,9(1x,F10.5))" write (u, "(A)") "* Test output: recoil_kinematics_2" write (u, "(A)") "* Purpose: compute Q distribution" write (u, "(A)") n_bin = 20 write (u, "(A)") "* No Q cutoff, xbar = 1" write (u, "(A)") sqrts = 100 q_max = sqrts m = 0.511e-3_default x_bar = 1._default call show_table write (u, "(A)") write (u, "(A)") "* With Q cutoff, xbar = 1" write (u, "(A)") q_max = 10 call show_table write (u, "(A)") write (u, "(A)") "* No Q cutoff, xbar = 0.01" write (u, "(A)") q_max = sqrts x_bar = 0.01_default call show_table write (u, "(A)") write (u, "(A)") "* Test output end: recoil_kinematics_2" contains subroutine show_table write (u, FMT1) "sqrts =", sqrts write (u, FMT1) "q_max =", q_max write (u, FMT1) "m =", m write (u, FMT1) "x_bar =", x_bar write (u, "(A)") write (u, "(1x,A)") "Table: r |Q| |Q_i/Q_(i-1)|" q2_old = 0 do i = 0, n_bin r = real (i, default) / n_bin call generate_q2_recoil (sqrts**2, x_bar, q_max**2, m**2, r, q2) if (q2_old > 0) then write (u, FMT3) r, sqrt (q2), sqrt (q2 / q2_old) else write (u, FMT3) r, sqrt (q2) end if q2_old = q2 end do end subroutine show_table end subroutine recoil_kinematics_2 @ %def recoil_kinematics_2 @ \subsubsection{Generate recoil event} Combine $Q^2$ sampling with momentum generation. <>= call test (recoil_kinematics_3, "recoil_kinematics_3", & "generate recoil event", & u, results) <>= public :: recoil_kinematics_3 <>= subroutine recoil_kinematics_3 (u) integer, intent(in) :: u real(default) :: sqrts real(default), dimension(2) :: q_max real(default), dimension(2) :: m, mo real(default), dimension(2) :: xc, xcb real(default), dimension(4) :: r type(vector4_t), dimension(2) :: km type(vector4_t), dimension(2) :: qm type(vector4_t), dimension(2) :: qo logical :: ok character(*), parameter :: FMT1 = "(1x,A,9(1x,F15.10))" character(*), parameter :: FMT2 = "(1x,A,9(1x,F10.5))" write (u, "(A)") "* Test output: recoil_kinematics_3" write (u, "(A)") "* Purpose: generate momenta from RNG parameters" write (u, "(A)") write (u, "(A)") "*** collinear data set" write (u, "(A)") sqrts = 100 q_max = sqrts m = 0.511e-3_default mo = 0 xc = [0.6_default, 0.9_default] xcb = 1 - xc r = [0._default, 0._default, 0._default, 0._default] call show_data call generate_recoil (sqrts, q_max, m, mo, xc, xcb, r, km, qm, qo, ok) call show_momenta write (u, "(A)") write (u, "(A)") "*** moderate data set" write (u, "(A)") xc = [0.6_default, 0.9_default] xcb = 1 - xc r = [0.8_default, 0.2_default, 0.1_default, 0.2_default] call show_data call generate_recoil (sqrts, q_max, m, mo, xc, xcb, r, km, qm, qo, ok) call show_momenta write (u, "(A)") write (u, "(A)") "*** failing data set" write (u, "(A)") xc = [0.2_default, 0.4_default] xcb = 1 - xc r = [0.9999_default, 0.3_default, 0.1_default, 0.8_default] call show_data call generate_recoil (sqrts, q_max, m, mo, xc, xcb, r, km, qm, qo, ok) if (.not. ok) then write (u, "(A)") write (u, "(A)") "Failed as expected." else call show_momenta end if contains subroutine show_data write (u, FMT1) "sqrts =", sqrts write (u, FMT1) "q_max =", q_max write (u, FMT1) "m =", m write (u, FMT1) "xc =", xc write (u, FMT1) "xcb =", xcb write (u, FMT1) "r =", r end subroutine show_data subroutine show_momenta real(default), parameter :: tol = 1.e-7_default call pacify (km, tol) call pacify (qo, tol) write (u, "(A)") write (u, "(A)") "* Momenta: k" call km(1)%write (u, testflag=.true.) call km(2)%write (u, testflag=.true.) write (u, FMT1) "k^2 =", abs (km(1)**2), abs (km(2)**2) write (u, "(A)") write (u, "(A)") "* Momenta: q(os)" call qo(1)%write (u, testflag=.true.) call qo(2)%write (u, testflag=.true.) write (u, FMT1) "q^2 =", abs (qo(1)**2), abs (qo(2)**2) write (u, "(A)") write (u, "(A)") "* Check: momentum transfer (off-shell/on-shell)" write (u, FMT2) "Q =", q_check (1), q_check (2) write (u, FMT2) "|q| =", abs (qm(1)**1), abs (qm(2)**1) write (u, "(A)") write (u, "(A)") "* Check: sqrts, sqrts_hat" write (u, FMT1) "sqs =", sqrts, sqrt (product (xc)) * sqrts write (u, FMT1) "|po|=", abs ((km(1)+km(2)+qo(1)+qo(2))**1), abs ((qo(1)+qo(2))**1) end subroutine show_momenta function q_check (i) result (q) integer, intent(in) :: i real(default) :: q real(default) :: q2 call generate_q2_recoil (sqrts**2, xcb(i), q_max(i)**2, m(i)**2, r(i), q2) q = sqrt (q2) end function q_check end subroutine recoil_kinematics_3 @ %def recoil_kinematics_3 @ \subsubsection{Transformation after recoil} Given a solution to recoil kinematics, compute the Lorentz transformation that transforms the old collinear parton momenta into the new parton momenta. <>= call test (recoil_kinematics_4, "recoil_kinematics_4", & "reference frame", & u, results) <>= public :: recoil_kinematics_4 <>= subroutine recoil_kinematics_4 (u) integer, intent(in) :: u real(default) :: sqrts real(default), dimension(2) :: xc, xcb real(default), dimension(2) :: q real(default), dimension(2) :: phi real(default), dimension(2) :: cos_th, sin_th real(default), dimension(2) :: mo real(default), dimension(2) :: x real(default), dimension(2) :: xb type(vector4_t), dimension(2) :: km type(vector4_t), dimension(2) :: qm type(vector4_t), dimension(2) :: qo type(lorentz_transformation_t) :: lt logical :: ok character(*), parameter :: FMT1 = "(1x,A,9(1x,F15.10))" character(*), parameter :: FMT2 = "(1x,A,9(1x,F10.5))" write (u, "(A)") "* Test output: recoil_kinematics_4" write (u, "(A)") "* Purpose: check Lorentz transformation for recoil" write (u, "(A)") sqrts = 100 write (u, FMT1) "sqrts =", sqrts write (u, "(A)") write (u, "(A)") "*** collinear data set" write (u, "(A)") xc = [0.6_default, 0.9_default] xcb = 1 - xc phi = [0.1_default, 0.2_default] * twopi q = 0 mo = 0 call show_data call solve_recoil (sqrts, xc, xcb, phi, q**2, x, xb, cos_th, sin_th, ok) call recoil_momenta (sqrts, xc, xb, cos_th, sin_th, phi, mo, km, qm, qo, ok) call recoil_transformation (sqrts, xc, qo, lt) call show_transformation write (u, "(A)") write (u, "(A)") "*** moderate data set" write (u, "(A)") xc = [0.6_default, 0.9_default] xcb = 1 - xc phi = [0.1_default, 0.2_default] * twopi q = [0.2_default, 0.05_default] * sqrts call show_data call solve_recoil (sqrts, xc, xcb, phi, q**2, x, xb, cos_th, sin_th, ok) call recoil_momenta (sqrts, xc, xb, cos_th, sin_th, phi, mo, km, qm, qo, ok) call recoil_transformation (sqrts, xc, qo, lt) call show_transformation write (u, "(A)") write (u, "(A)") "* Test output end: recoil_kinematics_4" contains subroutine show_data write (u, FMT1) "sqs_h =", sqrt (xc(1) * xc(2)) * sqrts write (u, FMT1) "xc =", xc write (u, FMT1) "xcb =", xcb write (u, FMT1) "Q =", Q write (u, FMT1) "phi/D =", phi / degree end subroutine show_data subroutine show_transformation type(vector4_t), dimension(2) :: qc type(vector4_t), dimension(2) :: qct real(default), parameter :: tol = 1.e-7_default qc(1) = xc(1) * vector4_moving (sqrts/2, sqrts/2, 3) qc(2) = xc(2) * vector4_moving (sqrts/2,-sqrts/2, 3) qct = lt * qc call pacify (qct, tol) write (u, "(A)") write (u, "(A)") "Momenta: q(os)" call qo(1)%write (u, testflag=.true.) call qo(2)%write (u, testflag=.true.) write (u, "(A)") write (u, "(A)") "Momenta: LT * qc" call qct(1)%write (u, testflag=.true.) call qct(2)%write (u, testflag=.true.) end subroutine show_transformation end subroutine recoil_kinematics_4 @ %def recoil_kinematics_4 @ \subsubsection{Transformation before recoil} Given a pair of incoming `beam' partons (i.e., before ISR splitting), compute the transformation that transforms their common c.m.\ frame into the lab frame. <>= call test (recoil_kinematics_5, "recoil_kinematics_5", & "initial reference frame", & u, results) <>= public :: recoil_kinematics_5 <>= subroutine recoil_kinematics_5 (u) integer, intent(in) :: u real(default) :: sqrts real(default) :: sqrtsi real(default), dimension(2) :: x type(vector4_t), dimension(2) :: p type(vector4_t), dimension(2) :: pi type(vector4_t), dimension(2) :: p0 type(lorentz_transformation_t) :: lt logical :: ok character(*), parameter :: FMT1 = "(1x,A,9(1x,F15.10))" character(*), parameter :: FMT2 = "(1x,A,9(1x,F10.5))" write (u, "(A)") "* Test output: recoil_kinematics_5" write (u, "(A)") "* Purpose: determine initial Lorentz transformation" write (u, "(A)") sqrts = 100 write (u, FMT1) "sqrts =", sqrts x = [0.6_default, 0.9_default] p(1) = x(1) * vector4_moving (sqrts/2, sqrts/2, 3) p(2) = x(2) * vector4_moving (sqrts/2,-sqrts/2, 3) call show_data call initial_transformation (p, sqrtsi, lt, ok) pi(1) = vector4_moving (sqrtsi/2, sqrtsi/2, 3) pi(2) = vector4_moving (sqrtsi/2,-sqrtsi/2, 3) p0 = inverse (lt) * p call show_momenta write (u, "(A)") write (u, "(A)") "* Test output end: recoil_kinematics_5" contains subroutine show_data write (u, FMT1) "sqrts =", sqrts write (u, FMT1) "x =", x end subroutine show_data subroutine show_momenta real(default), parameter :: tol = 1.e-7_default write (u, "(A)") write (u, "(A)") "* Momenta: p_in(c.m.)" call pi(1)%write (u, testflag=.true.) call pi(2)%write (u, testflag=.true.) write (u, "(A)") write (u, "(A)") "* Momenta: inv(LT) * p_in(lab)" call p0(1)%write (u, testflag=.true.) call p0(2)%write (u, testflag=.true.) end subroutine show_momenta end subroutine recoil_kinematics_5 @ %def recoil_kinematics_5 @ \subsubsection{Transformation after recoil with on-shell momenta} Given a solution to recoil kinematics, compute the Lorentz transformation that transforms the old collinear parton momenta into the new parton momenta. Compare the results for massless and massive on-shell projection. <>= call test (recoil_kinematics_6, "recoil_kinematics_6", & "massless/massive on-shell projection", & u, results) <>= public :: recoil_kinematics_6 <>= subroutine recoil_kinematics_6 (u) integer, intent(in) :: u real(default) :: sqrts real(default), dimension(2) :: xc, xcb real(default), dimension(2) :: q real(default), dimension(2) :: phi real(default), dimension(2) :: cos_th, sin_th real(default), dimension(2) :: x real(default), dimension(2) :: xb real(default), dimension(2) :: mo, z type(vector4_t), dimension(2) :: km type(vector4_t), dimension(2) :: qm type(vector4_t), dimension(2) :: qo type(lorentz_transformation_t) :: lt logical :: ok character(*), parameter :: FMT1 = "(1x,A,9(1x,F15.10))" character(*), parameter :: FMT2 = "(1x,A,9(1x,F11.6))" write (u, "(A)") "* Test output: recoil_kinematics_6" write (u, "(A)") "* Purpose: check effect of mass in on-shell projection" write (u, "(A)") sqrts = 10 write (u, FMT1) "sqrts =", sqrts z = 0 mo = 0.511e-3 write (u, FMT1) "mass =", mo write (u, "(A)") write (u, "(A)") "*** collinear data set" write (u, "(A)") xc = [0.6_default, 0.9_default] xcb = 1 - xc phi = [0.1_default, 0.2_default] * twopi q = 0 call show_data call solve_recoil (sqrts, xc, xcb, phi, q**2, x, xb, cos_th, sin_th, ok) call recoil_momenta (sqrts, xc, xb, cos_th, sin_th, phi, z, km, qm, qo, ok) call recoil_transformation (sqrts, xc, qo, lt) write (u, "(A)") write (u, "(A)") "Massless projection:" call show_momenta call recoil_momenta (sqrts, xc, xb, cos_th, sin_th, phi, mo, km, qm, qo, ok) call recoil_transformation (sqrts, xc, qo, lt) write (u, "(A)") write (u, "(A)") "Massive projection:" call show_momenta write (u, "(A)") write (u, "(A)") "*** moderate data set" write (u, "(A)") xc = [0.6_default, 0.9_default] xcb = 1 - xc phi = [0.1_default, 0.2_default] * twopi q = [0.2_default, 0.05_default] * sqrts call show_data call solve_recoil (sqrts, xc, xcb, phi, q**2, x, xb, cos_th, sin_th, ok) call recoil_momenta (sqrts, xc, xb, cos_th, sin_th, phi, z, km, qm, qo, ok) call recoil_transformation (sqrts, xc, qo, lt) write (u, "(A)") write (u, "(A)") "Massless projection:" call show_momenta call recoil_momenta (sqrts, xc, xb, cos_th, sin_th, phi, mo, km, qm, qo, ok) call recoil_transformation (sqrts, xc, qo, lt) write (u, "(A)") write (u, "(A)") "Massive projection:" call show_momenta write (u, "(A)") write (u, "(A)") "* Test output end: recoil_kinematics_6" contains subroutine show_data write (u, FMT1) "sqs_h =", sqrt (xc(1) * xc(2)) * sqrts write (u, FMT1) "xc =", xc write (u, FMT1) "xcb =", xcb write (u, FMT1) "Q =", Q write (u, FMT1) "phi/D =", phi / degree end subroutine show_data subroutine show_momenta write (u, "(A)") "Momenta: q(os)" call qo(1)%write (u, testflag=.true.) write (u, FMT2) "m = ", abs (qo(1)**1) call qo(2)%write (u, testflag=.true.) write (u, FMT2) "m = ", abs (qo(2)**1) end subroutine show_momenta end subroutine recoil_kinematics_6 @ %def recoil_kinematics_6 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Transverse momentum for the ISR and EPA approximations} The ISR and EPA handler takes an event with a single radiated collinear particle (photon for ISR, beam particle for EPA) for each beam, respectively, and inserts transverse momentum for both. The four-particle kinematics allows us to generate $Q^2$ and azimuthal angles independently, without violating energy-momentum conservation. The $Q^2$ distribution is logarithmic, as required by the effective particle approximation, and reflected in the inclusive ISR/EPA structure functions. We also conserve the invariant mass of the partonic systm after radiation. The total transverse-momentum kick is applied in form of a Lorentz transformation to the elementary process, both in- and out-particles. In fact, the incoming partons (beam particle for ISR, photon for EPA) which would be virtual space-like in the exact kinematics configuration, are replaced by on-shell incoming partons, such that energy, momentum, and invariant mass $\sqrt{\hat s}$ are conserved. Regarding kinematics, we treat all particles as massless. The beam-particle mass only appears as the parameter [[isr_mass]] or [[epa_mass]], respectively, and cuts off the logarithmic distribution. The upper cutoff is [[isr_q_max]] ([[epa_q_max]]), which defaults to the available energy $\sqrt{s}$. The only differences between ISR and EPA, in this context, are the particle types, and an extra $\bar x$ factor in the lower cutoff for EPA, see below. <<[[isr_epa_handler.f90]]>>= <> module isr_epa_handler <> <> use diagnostics, only: msg_fatal use diagnostics, only: msg_bug use io_units use format_defs, only: FMT_12, FMT_19 use format_utils, only: write_separator use format_utils, only: pac_fmt use physics_defs, only: PHOTON use lorentz, only: vector4_t use lorentz, only: energy use lorentz, only: lorentz_transformation_t use lorentz, only: identity use lorentz, only: inverse use lorentz, only: operator(*) use sm_qcd use flavors, only: flavor_t use particles, only: particle_t use model_data use models use rng_base, only: rng_t use event_transforms use recoil_kinematics, only: initial_transformation use recoil_kinematics, only: generate_recoil use recoil_kinematics, only: recoil_transformation <> <> <> <> contains <> end module isr_epa_handler @ %def isr_epa_handler @ \subsection{Event transform type} Convention: [[beam]] are the incoming partons before ISR -- not necessarily the actual beams, need not be in c.m.\ frame. [[radiated]] are the radiated particles (photon for ISR), and [[parton]] are the remainders which initiate the elementary process. These particles are copied verbatim from the event record, and must be collinear. The kinematical parameters are [[sqrts]] = invariant mass of the [[beam]] particles, [[q_max]] and [[m]] determining the $Q^2$ distribution, and [[xc]]/[[xcb]] as the energy fraction (complement) of the partons, relative to the beams. Transformations: [[lti]] is the Lorentz transformation that would boosts [[pi]] (c.m. frame) back to the original [[beam]] momenta (lab frame). [[lto]] is the recoil transformation, transforming the partons after ISR from the collinear frame to the recoiling frame. [[lt]] is the combination of both, which is to be applied to all particles after the hard interaction. Momenta: [[pi]] are the beams transformed to their common c.m.\ frame. [[ki]] and [[qi]] are the photon/parton momenta in the [[pi]] c.m.\ frame. [[km]] and [[qm]] are the photon/parton momenta with the $Q$ distribution applied, and finally [[qo]] are the partons [[qm]] projected on-shell. <>= public :: evt_isr_epa_t <>= type, extends (evt_t) :: evt_isr_epa_t private integer :: mode = ISR_TRIVIAL_COLLINEAR logical :: isr_active = .false. logical :: epa_active = .false. real(default) :: isr_q_max = 0 real(default) :: epa_q_max = 0 real(default) :: isr_mass = 0 real(default) :: epa_mass = 0 logical :: isr_keep_mass = .true. real(default) :: sqrts = 0 integer, dimension(2) :: rad_mode = BEAM_RAD_NONE real(default), dimension(2) :: q_max = 0 real(default), dimension(2) :: m = 0 real(default), dimension(2) :: xc = 0 real(default), dimension(2) :: xcb = 0 type(lorentz_transformation_t) :: lti = identity type(lorentz_transformation_t) :: lto = identity type(lorentz_transformation_t) :: lt = identity integer, dimension(2) :: i_beam = 0 type(particle_t), dimension(2) :: beam type(vector4_t), dimension(2) :: pi integer, dimension(2) :: i_radiated = 0 type(particle_t), dimension(2) :: radiated type(vector4_t), dimension(2) :: ki type(vector4_t), dimension(2) :: km integer, dimension(2) :: i_parton = 0 type(particle_t), dimension(2) :: parton type(vector4_t), dimension(2) :: qi type(vector4_t), dimension(2) :: qm type(vector4_t), dimension(2) :: qo contains <> end type evt_isr_epa_t @ %def evt_isr_epa_t @ \subsection{ISR/EPA distinction} <>= integer, parameter, public :: BEAM_RAD_NONE = 0 integer, parameter, public :: BEAM_RAD_ISR = 1 integer, parameter, public :: BEAM_RAD_EPA = 2 @ %def BEAM_RAD_NONE @ %def BEAM_RAD_ISR @ %def BEAM_RAD_EPA <>= function rad_mode_string (mode) result (string) type(string_t) :: string integer, intent(in) :: mode select case (mode) case (BEAM_RAD_NONE); string = "---" case (BEAM_RAD_ISR); string = "ISR" case (BEAM_RAD_EPA); string = "EPA" case default; string = "???" end select end function rad_mode_string @ %def rad_mode_string @ \subsection{Photon insertion modes} <>= integer, parameter, public :: ISR_TRIVIAL_COLLINEAR = 0 integer, parameter, public :: ISR_PAIR_RECOIL = 1 @ %def ISR_TRIVIAL_COLLINEAR ISR_PAIR_RECOIL @ <>= procedure :: get_mode_string => evt_isr_epa_get_mode_string <>= function evt_isr_epa_get_mode_string (evt) result (string) type(string_t) :: string class(evt_isr_epa_t), intent(in) :: evt select case (evt%mode) case (ISR_TRIVIAL_COLLINEAR) string = "trivial, collinear" case (ISR_PAIR_RECOIL) string = "pair recoil" case default string = "[undefined]" end select end function evt_isr_epa_get_mode_string @ %def evt_isr_epa_get_mode_string @ Set the numerical mode ID from a user-level string representation. <>= procedure :: set_mode_string => evt_isr_epa_set_mode_string <>= subroutine evt_isr_epa_set_mode_string (evt, string) class(evt_isr_epa_t), intent(inout) :: evt type(string_t), intent(in) :: string select case (char (string)) case ("trivial") evt%mode = ISR_TRIVIAL_COLLINEAR case ("recoil") evt%mode = ISR_PAIR_RECOIL case default call msg_fatal ("ISR handler: mode '" // char (string) & // "' is undefined") end select end subroutine evt_isr_epa_set_mode_string @ %def evt_isr_epa_set_mode_string @ \subsection{Output} <>= procedure :: write_name => evt_isr_epa_write_name <>= subroutine evt_isr_epa_write_name (evt, unit) class(evt_isr_epa_t), intent(in) :: evt integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A)") "Event transform: ISR/EPA handler" end subroutine evt_isr_epa_write_name @ %def evt_isr_epa_write_name @ The overall recoil-handling mode. <>= procedure :: write_mode => evt_isr_epa_write_mode <>= subroutine evt_isr_epa_write_mode (evt, unit) class(evt_isr_epa_t), intent(in) :: evt integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A,1x,I0,':',1x,A)") "Insertion mode =", evt%mode, & char (evt%get_mode_string ()) end subroutine evt_isr_epa_write_mode @ %def evt_isr_epa_write_mode @ The input data for ISR and EPA, respectively. <>= procedure :: write_input => evt_isr_epa_write_input <>= subroutine evt_isr_epa_write_input (evt, unit, testflag) class(evt_isr_epa_t), intent(in) :: evt integer, intent(in), optional :: unit logical, intent(in), optional :: testflag character(len=7) :: fmt integer :: u u = given_output_unit (unit) call pac_fmt (fmt, FMT_19, FMT_12, testflag) if (evt%isr_active) then write (u, "(3x,A,1x," // fmt // ")") "ISR: Q_max =", evt%isr_q_max write (u, "(3x,A,1x," // fmt // ")") " m =", evt%isr_mass write (u, "(3x,A,1x,L1)") " keep m=", evt%isr_keep_mass else write (u, "(3x,A)") "ISR: [inactive]" end if if (evt%epa_active) then write (u, "(3x,A,1x," // fmt // ")") "EPA: Q_max =", evt%epa_q_max write (u, "(3x,A,1x," // fmt // ")") " m =", evt%epa_mass else write (u, "(3x,A)") "EPA: [inactive]" end if end subroutine evt_isr_epa_write_input @ %def evt_isr_epa_write_input @ The trivial mode does not depend on any data, since it does nothing to the event. <>= procedure :: write_data => evt_isr_epa_write_data <>= subroutine evt_isr_epa_write_data (evt, unit, testflag) class(evt_isr_epa_t), intent(in) :: evt integer, intent(in), optional :: unit logical, intent(in), optional :: testflag character(len=7), parameter :: FMTL_19 = "A3,16x" character(len=7), parameter :: FMTL_12 = "A3,9x" character(len=7) :: fmt, fmtl integer :: u u = given_output_unit (unit) call pac_fmt (fmt, FMT_19, FMT_12, testflag) call pac_fmt (fmtl, FMTL_19, FMTL_12, testflag) select case (evt%mode) case (ISR_PAIR_RECOIL) write (u, "(1x,A)") "Event:" write (u, "(3x,A,2(1x," // fmtl // "))") & "mode = ", & char (rad_mode_string (evt%rad_mode(1))), & char (rad_mode_string (evt%rad_mode(2))) write (u, "(3x,A,2(1x," // fmt // "))") "Q_max =", evt%q_max write (u, "(3x,A,2(1x," // fmt // "))") "m =", evt%m write (u, "(3x,A,2(1x," // fmt // "))") "x =", evt%xc write (u, "(3x,A,2(1x," // fmt // "))") "xb =", evt%xcb write (u, "(3x,A,1x," // fmt // ")") "sqrts =", evt%sqrts call write_separator (u) write (u, "(A)") "Lorentz boost (partons before radiation & &c.m. -> lab) =" call evt%lti%write (u, testflag) write (u, "(A)") "Lorentz transformation (collinear partons & &-> partons with recoil in c.m.) =" call evt%lto%write (u, testflag) write (u, "(A)") "Combined transformation (partons & &-> partons with recoil in lab frame) =" call evt%lt%write (u, testflag) end select end subroutine evt_isr_epa_write_data @ %def evt_isr_epa_write_data @ Output method. <>= procedure :: write => evt_isr_epa_write <>= subroutine evt_isr_epa_write (evt, unit, verbose, more_verbose, testflag) class(evt_isr_epa_t), intent(in) :: evt integer, intent(in), optional :: unit logical, intent(in), optional :: verbose, more_verbose, testflag logical :: show_mass integer :: u, i u = given_output_unit (unit) if (present (testflag)) then show_mass = .not. testflag else show_mass = .true. end if call write_separator (u, 2) call evt%write_name (u) call write_separator (u, 2) call evt%write_mode (u) call evt%write_input (u, testflag=testflag) call evt%write_data (u, testflag=testflag) call write_separator (u) call evt%base_write (u, testflag = testflag, show_set = .false.) if (all (evt%i_beam > 0)) then call write_separator (u) write (u, "(A,2(1x,I0))") "Partons before radiation:", evt%i_beam do i = 1, 2 call evt%beam(i)%write (u, testflag=testflag) end do call write_separator (u) write (u, "(A)") "... boosted to c.m.:" do i = 1, 2 call evt%pi(i)%write (u, show_mass=show_mass, testflag=testflag) end do end if if (all (evt%i_radiated > 0)) then call write_separator (u) write (u, "(A,2(1x,I0))") "Radiated particles, collinear:", & evt%i_radiated do i = 1, 2 call evt%radiated(i)%write (u, testflag=testflag) end do call write_separator (u) write (u, "(A)") "... boosted to c.m.:" do i = 1, 2 call evt%ki(i)%write (u, show_mass=show_mass, testflag=testflag) end do call write_separator (u) write (u, "(A)") "... with kT:" do i = 1, 2 call evt%km(i)%write (u, show_mass=show_mass, testflag=testflag) end do end if if (all (evt%i_parton > 0)) then call write_separator (u) write (u, "(A,2(1x,I0))") "Partons after radiation, collinear:", & evt%i_parton do i = 1, 2 call evt%parton(i)%write (u, testflag=testflag) end do call write_separator (u) write (u, "(A)") "... boosted to c.m.:" do i = 1, 2 call evt%qi(i)%write (u, show_mass=show_mass, testflag=testflag) end do call write_separator (u) write (u, "(A)") "... with qT, off-shell:" do i = 1, 2 call evt%qm(i)%write (u, show_mass=show_mass, testflag=testflag) end do call write_separator (u) write (u, "(A)") "... projected on-shell:" do i = 1, 2 call evt%qo(i)%write (u, show_mass=show_mass, testflag=testflag) end do call write_separator (u) end if if (evt%particle_set_exists) & call evt%particle_set%write & (u, summary = .true., compressed = .true., testflag = testflag) call write_separator (u) end subroutine evt_isr_epa_write @ %def evt_isr_epa_write @ \subsection{Initialization} Manually import a random-number generator object. This should be done only for testing purposes. The standard procedure is to [[connect]] a process to an event transform; this will create an appropriate [[rng]] from the RNG factory in the process object. <>= procedure :: import_rng => evt_isr_epa_import_rng <>= subroutine evt_isr_epa_import_rng (evt, rng) class(evt_isr_epa_t), intent(inout) :: evt class(rng_t), allocatable, intent(inout) :: rng call move_alloc (from = rng, to = evt%rng) end subroutine evt_isr_epa_import_rng @ %def evt_isr_epa_import_rng @ Set constant kinematics limits and initialize for ISR. Note that [[sqrts]] is used only as the fallback value for [[q_max]]. The actual [[sqrts]] value for the transform object is inferred from the incoming particles, event by event. <>= procedure :: set_data_isr => evt_isr_epa_set_data_isr <>= subroutine evt_isr_epa_set_data_isr (evt, sqrts, q_max, m, keep_mass) class(evt_isr_epa_t), intent(inout) :: evt real(default), intent(in) :: sqrts real(default), intent(in) :: q_max real(default), intent(in) :: m logical, intent(in) :: keep_mass if (sqrts <= 0) then call msg_fatal ("ISR handler: sqrts value must be positive") end if if (q_max <= 0 .or. q_max > sqrts) then evt%isr_q_max = sqrts else evt%isr_q_max = q_max end if if (m > 0) then evt%isr_mass = m else call msg_fatal ("ISR handler: ISR_mass value must be positive") end if evt%isr_active = .true. evt%isr_keep_mass = keep_mass end subroutine evt_isr_epa_set_data_isr @ %def evt_isr_epa_set_data_isr @ Set constant kinematics limits and initialize for EPA. Note that [[sqrts]] is used only as the fallback value for [[q_max]]. The actual [[sqrts]] value for the transform object is inferred from the incoming particles, event by event. <>= procedure :: set_data_epa => evt_isr_epa_set_data_epa <>= subroutine evt_isr_epa_set_data_epa (evt, sqrts, q_max, m) class(evt_isr_epa_t), intent(inout) :: evt real(default), intent(in) :: sqrts real(default), intent(in) :: q_max real(default), intent(in) :: m if (sqrts <= 0) then call msg_fatal ("EPA handler: sqrts value must be positive") end if if (q_max <= 0 .or. q_max > sqrts) then evt%epa_q_max = sqrts else evt%epa_q_max = q_max end if if (m > 0) then evt%epa_mass = m else call msg_fatal ("EPA handler: EPA_mass value must be positive") end if evt%epa_active = .true. end subroutine evt_isr_epa_set_data_epa @ %def evt_isr_epa_set_data_epa @ \subsection{Fetch event data} Identify the radiated particles and the recoil momenta in the particle set. Without much sophistication, start from the end and find particles with the ``remnant'' status. Their parents should point to the recoiling parton. If successful, set the particle indices in the [[evt]] object, for further processing. <>= procedure, private :: identify_radiated <>= subroutine identify_radiated (evt) class(evt_isr_epa_t), intent(inout) :: evt integer :: i, k k = 2 FIND_LAST_RADIATED: do i = evt%particle_set%get_n_tot (), 1, -1 associate (prt => evt%particle_set%prt(i)) if (prt%is_beam_remnant ()) then evt%i_radiated(k) = i evt%radiated(k) = prt k = k - 1 if (k == 0) exit FIND_LAST_RADIATED end if end associate end do FIND_LAST_RADIATED if (k /= 0) call err_count contains subroutine err_count call evt%particle_set%write () call msg_fatal ("ISR/EPA handler: & &event does not contain two radiated particles") end subroutine err_count end subroutine identify_radiated @ %def identify_radiated @ When the radiated particles are known, we can fetch their parent particles and ask for the other child, the incoming parton. <>= procedure, private :: identify_partons <>= subroutine identify_partons (evt) class(evt_isr_epa_t), intent(inout) :: evt integer, dimension(:), allocatable :: parent, child integer :: i, j if (all (evt%i_radiated > 0)) then do i = 1, 2 parent = evt%radiated(i)%get_parents () if (size (parent) /= 1) call err_mismatch evt%i_beam(i) = parent(1) evt%beam(i) = evt%particle_set%prt(parent(1)) associate (prt => evt%beam(i)) child = prt%get_children () if (size (child) /= 2) call err_mismatch do j = 1, 2 if (child(j) /= evt%i_radiated(i)) then evt%i_parton(i) = child(j) evt%parton(i) = evt%particle_set%prt(child(j)) end if end do end associate end do end if contains subroutine err_mismatch call evt%particle_set%write () call msg_bug ("ISR/EPA handler: mismatch in parent-child relations") end subroutine err_mismatch end subroutine identify_partons @ %def identify_partons @ Check whether the radiated particle is a photon, or the incoming parton is a photon. Then set the ISR/EPA switch appropriately, for each beam. <>= procedure :: check_radiation => evt_isr_epa_check_radiation <>= subroutine evt_isr_epa_check_radiation (evt) class(evt_isr_epa_t), intent(inout) :: evt type(flavor_t) :: flv integer :: i do i = 1, 2 flv = evt%radiated(i)%get_flv () if (flv%get_pdg () == PHOTON) then if (evt%isr_active) then evt%rad_mode(i) = BEAM_RAD_ISR else call err_isr_init end if else flv = evt%parton(i)%get_flv () if (flv%get_pdg () == PHOTON) then if (evt%epa_active) then evt%rad_mode(i) = BEAM_RAD_EPA else call err_epa_init end if else call err_no_photon end if end if end do contains subroutine err_isr_init call evt%particle_set%write () call msg_fatal ("ISR/EPA handler: & &event contains radiated photon, but ISR is not initialized") end subroutine err_isr_init subroutine err_epa_init call evt%particle_set%write () call msg_fatal ("ISR/EPA handler: & &event contains incoming photon, but EPA is not initialized") end subroutine err_epa_init subroutine err_no_photon call evt%particle_set%write () call msg_fatal ("ISR/EPA handler: & &event does not appear to be ISR or EPA - missing photon") end subroutine err_no_photon end subroutine evt_isr_epa_check_radiation @ %def evt_isr_epa_check_radiation @ Internally set the appropriate parameters (ISR/EPA) for the two beams in the recoil mode. <>= procedure :: set_recoil_parameters => evt_isr_epa_set_recoil_parameters <>= subroutine evt_isr_epa_set_recoil_parameters (evt) class(evt_isr_epa_t), intent(inout) :: evt integer :: i do i = 1, 2 select case (evt%rad_mode(i)) case (BEAM_RAD_ISR) evt%q_max(i) = evt%isr_q_max evt%m(i) = evt%isr_mass case (BEAM_RAD_EPA) evt%q_max(i) = evt%epa_q_max evt%m(i) = evt%epa_mass end select end do end subroutine evt_isr_epa_set_recoil_parameters @ %def evt_isr_epa_set_recoil_parameters @ Boost the particles that participate in ISR to their proper c.m.\ frame, copying the momenta to [[pi]], [[ki]], [[qi]]. Also assign [[sqrts]] properly. <>= procedure, private :: boost_to_cm <>= subroutine boost_to_cm (evt) class(evt_isr_epa_t), intent(inout) :: evt type(vector4_t), dimension(2) :: p type(vector4_t), dimension(2) :: k type(vector4_t), dimension(2) :: q logical :: ok p = evt%beam%get_momentum () k = evt%radiated%get_momentum () q = evt%parton%get_momentum () call initial_transformation (p, evt%sqrts, evt%lti, ok) if (.not. ok) call err_non_collinear evt%pi = inverse (evt%lti) * p evt%ki = inverse (evt%lti) * k evt%qi = inverse (evt%lti) * q contains subroutine err_non_collinear call evt%particle_set%write () call msg_fatal ("ISR/EPA handler: & &partons before radiation are not collinear") end subroutine err_non_collinear end subroutine boost_to_cm @ %def boost_to_cm @ We can infer the $x$ and $\bar x$ values of the event by looking at the energy fractions of the radiated particles and incoming partons, respectively, relative to their parents. Of course, we must assume that they are all collinear, and that energy is conserved. <>= procedure, private :: infer_x <>= subroutine infer_x (evt) class(evt_isr_epa_t), intent(inout) :: evt real(default) :: E_parent, E_radiated, E_parton integer :: i if (all (evt%i_radiated > 0)) then do i = 1, 2 E_parent = energy (evt%pi(i)) E_radiated = energy (evt%ki(i)) E_parton = energy (evt%qi(i)) if (E_parent > 0) then evt%xc(i) = E_parton / E_parent evt%xcb(i)= E_radiated / E_parent else call err_energy end if end do end if contains subroutine err_energy call evt%particle_set%write () call msg_bug ("ISR/EPA handler: non-positive energy in splitting") end subroutine err_energy end subroutine infer_x @ %def infer_x @ \subsection{Two-parton recoil} For transforming partons into recoil momenta, we make use of the routines in the [[recoil_kinematics]] module. In addition to the collinear momenta, we use the $x$ energy fractions, and four numbers from the RNG. There is one subtle difference w.r.t.\ ISR case: the EPA mass parameter is multiplied by the energy fraction $x$, separately for each beam. This is the effective lower $Q$ cutoff. For certain kinematics, close to the $Q_\text{max}$ endpoint, this may fail, and [[ok]] is set to false. In that case, we should generate new recoil momenta for the same event. This is handled by the generic unweighting procedure. <>= procedure, private :: generate_recoil => evt_generate_recoil <>= subroutine evt_generate_recoil (evt, ok) class(evt_isr_epa_t), intent(inout) :: evt logical, intent(out) :: ok real(default), dimension(4) :: r real(default), dimension(2) :: m, mo integer :: i call evt%rng%generate (r) m = 0 mo = 0 do i = 1, 2 select case (evt%rad_mode(i)) case (BEAM_RAD_ISR) m(i) = evt%m(i) if (evt%isr_keep_mass) mo(i) = m(i) case (BEAM_RAD_EPA) m(i) = evt%xc(i) * evt%m(i) end select end do call generate_recoil (evt%sqrts, evt%q_max, m, mo, evt%xc, evt%xcb, r, & evt%km, evt%qm, evt%qo, ok) end subroutine evt_generate_recoil @ %def evt_generate_recoil @ Replace the collinear radiated (incoming) parton momenta by the momenta that we have generated, respectively. Recall that the recoil has been applied in the c.m.\ system of the partons before ISR, so we apply the stored Lorentz transformation to boost them to the lab frame. <>= procedure, private :: replace_radiated procedure, private :: replace_partons <>= subroutine replace_radiated (evt) class(evt_isr_epa_t), intent(inout) :: evt integer :: i do i = 1, 2 associate (prt => evt%particle_set%prt(evt%i_radiated(i))) call prt%set_momentum (evt%lti * evt%km(i)) end associate end do end subroutine replace_radiated subroutine replace_partons (evt) class(evt_isr_epa_t), intent(inout) :: evt integer :: i do i = 1, 2 associate (prt => evt%particle_set%prt(evt%i_parton(i))) call prt%set_momentum (evt%lti * evt%qo(i)) end associate end do end subroutine replace_partons @ %def replace_radiated @ %def replace_partons @ \subsection{Transform the event} Knowing the new incoming partons for the elementary process, we can make use of another procedure in [[recoil_kinematics]] to determine the Lorentz transformation that transforms the collinear frame into the frame with transverse momentum. We apply this transformation, recursively, to all particles that originate from those incoming partons in the original particle set. We have to allow for the pre-ISR partons being not in their common c.m.\ frame. Taking into account non-commutativity, we actually have to first transform the outgoing particles to that c.m.\ frame, then apply the recoil transformation, then boost back to the lab frame. The [[mask]] keep track of particles that we transform, just in case the parent-child tree is multiply connected. <>= procedure :: transform_outgoing => evt_transform_outgoing <>= subroutine evt_transform_outgoing (evt) class(evt_isr_epa_t), intent(inout) :: evt logical, dimension(:), allocatable :: mask call recoil_transformation (evt%sqrts, evt%xc, evt%qo, evt%lto) evt%lt = evt%lti * evt%lto * inverse (evt%lti) allocate (mask (evt%particle_set%get_n_tot ()), source=.false.) call transform_children (evt%i_parton(1)) contains recursive subroutine transform_children (i) integer, intent(in) :: i integer :: j, n_child, c integer, dimension(:), allocatable :: child child = evt%particle_set%prt(i)%get_children () do j = 1, size (child) c = child(j) if (.not. mask(c)) then associate (prt => evt%particle_set%prt(c)) call prt%set_momentum (evt%lt * prt%get_momentum ()) mask(c) = .true. call transform_children (c) end associate end if end do end subroutine transform_children end subroutine evt_transform_outgoing @ %def evt_transform_outgoing @ \subsection{Implemented methods} Here we take the particle set from the previous event transform and copy it, then generate the transverse momentum for the radiated particles and for the incoming partons. If this fails (rarely, for large $p_T$), return zero for the probability, to trigger another try. NOTE: The boost for the initial partonic system, if not in the c.m.\ frame, has not been implemented yet. <>= procedure :: generate_weighted => & evt_isr_epa_generate_weighted <>= subroutine evt_isr_epa_generate_weighted (evt, probability) class(evt_isr_epa_t), intent(inout) :: evt real(default), intent(inout) :: probability logical :: valid call evt%particle_set%final () evt%particle_set = evt%previous%particle_set evt%particle_set_exists = .true. select case (evt%mode) case (ISR_TRIVIAL_COLLINEAR) probability = 1 valid = .true. case (ISR_PAIR_RECOIL) call evt%identify_radiated () call evt%identify_partons () call evt%check_radiation () call evt%set_recoil_parameters () call evt%boost_to_cm () call evt%infer_x () call evt%generate_recoil (valid) if (valid) then probability = 1 else probability = 0 end if case default call msg_bug ("ISR/EPA handler: generate weighted: unsupported mode") end select evt%particle_set_exists = .false. end subroutine evt_isr_epa_generate_weighted @ %def evt_isr_epa_generate_weighted @ Insert the generated radiated particles and incoming partons with $p_T$ in their respective places. The factorization parameters are irrelevant. <>= procedure :: make_particle_set => & evt_isr_epa_make_particle_set <>= subroutine evt_isr_epa_make_particle_set & (evt, factorization_mode, keep_correlations, r) class(evt_isr_epa_t), intent(inout) :: evt integer, intent(in) :: factorization_mode logical, intent(in) :: keep_correlations real(default), dimension(:), intent(in), optional :: r select case (evt%mode) case (ISR_TRIVIAL_COLLINEAR) case (ISR_PAIR_RECOIL) call evt%replace_radiated () call evt%replace_partons () call evt%transform_outgoing () case default call msg_bug ("ISR/EPA handler: make particle set: unsupported mode") end select evt%particle_set_exists = .true. end subroutine evt_isr_epa_make_particle_set @ %def event_isr_epa_handler_make_particle_set @ <>= procedure :: prepare_new_event => & evt_isr_epa_prepare_new_event <>= subroutine evt_isr_epa_prepare_new_event (evt, i_mci, i_term) class(evt_isr_epa_t), intent(inout) :: evt integer, intent(in) :: i_mci, i_term call evt%reset () end subroutine evt_isr_epa_prepare_new_event @ %def evt_isr_epa_prepare_new_event @ \subsection{Unit tests: ISR} Test module, followed by the corresponding implementation module. This test module differs from most of the other test modules, since it contains two test subroutines: one for ISR and one for EPA below. <<[[isr_epa_handler_ut.f90]]>>= <> module isr_epa_handler_ut use unit_tests use isr_epa_handler_uti <> <> contains <> end module isr_epa_handler_ut @ %def isr_epa_handler_ut @ <<[[isr_epa_handler_uti.f90]]>>= <> module isr_epa_handler_uti <> <> use format_utils, only: write_separator use os_interface use lorentz, only: vector4_t, vector4_moving, operator(*) use rng_base, only: rng_t use models, only: syntax_model_file_init, syntax_model_file_final use models, only: model_list_t, model_t use particles, only: particle_set_t use event_transforms use isr_epa_handler, only: evt_isr_epa_t use rng_base_ut, only: rng_test_t <> <> contains <> end module isr_epa_handler_uti @ %def isr_epa_handler_uti @ API: driver for the unit tests below. <>= public :: isr_handler_test <>= subroutine isr_handler_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine isr_handler_test @ %def isr_handler_test @ \subsubsection{Trivial case} Handle photons resulting from ISR radiation. This test is for the trivial case where the event is kept collinear. <>= call test (isr_handler_1, "isr_handler_1", & "collinear case, no modification", & u, results) <>= public :: isr_handler_1 <>= subroutine isr_handler_1 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(particle_set_t) :: pset type(model_list_t) :: model_list type(model_t), pointer :: model type(evt_trivial_t), target :: evt_trivial type(evt_isr_epa_t), target :: evt_isr_epa type(vector4_t), dimension(8) :: p real(default) :: sqrts real(default), dimension(2) :: x, xb real(default) :: probability write (u, "(A)") "* Test output: isr_handler_1" write (u, "(A)") "* Purpose: apply photon handler trivially (no-op)" write (u, "(A)") write (u, "(A)") "* Initialize environment" write (u, "(A)") call syntax_model_file_init () call os_data%init () call model_list%read_model & (var_str ("SM"), var_str ("SM.mdl"), & os_data, model) write (u, "(A)") "* Initialize particle set" write (u, "(A)") call pset%init_direct (n_beam = 2, n_in = 2, n_rem = 2, n_vir = 0, n_out = 2, & pdg = [11, -11, 11, -11, 22, 22, 13, -13], model = model) sqrts = 100._default x = [0.6_default, 0.9_default] xb= 1 - x p(1) = vector4_moving (sqrts/2, sqrts/2, 3) p(2) = vector4_moving (sqrts/2,-sqrts/2, 3) p(3:4) = x * p(1:2) p(5:6) = xb * p(1:2) p(7:8) = p(3:4) call pset%set_momentum (p, on_shell = .false.) write (u, "(A)") "* Fill trivial event transform" write (u, "(A)") call evt_trivial%reset () call evt_trivial%set_particle_set (pset, 1, 1) call evt_trivial%write (u) call write_separator (u, 2) write (u, "(A)") write (u, "(A)") "* Initialize ISR handler transform" write (u, "(A)") evt_trivial%next => evt_isr_epa evt_isr_epa%previous => evt_trivial call evt_isr_epa%write (u) write (u, "(A)") write (u, "(A)") "* Fill ISR handler transform" write (u, "(A)") call evt_isr_epa%prepare_new_event (1, 1) call evt_isr_epa%generate_weighted (probability) call evt_isr_epa%make_particle_set (0, .false.) call evt_isr_epa%write (u) write (u, "(A)") write (u, "(A,1x,F8.5)") "Event probability =", probability write (u, "(A)") write (u, "(A)") "* Cleanup" call evt_isr_epa%final () call evt_trivial%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: isr_handler_1" end subroutine isr_handler_1 @ %def isr_handler_1 @ \subsubsection{Photon pair with recoil} Handle photons resulting from ISR radiation. This test invokes the two-photon recoil mechanism. Both photons acquire transverse momentum, the parton momenta recoil, such that total energy-momentum is conserved, and all outgoing photons and partons are on-shell (massless). <>= call test (isr_handler_2, "isr_handler_2", & "two-photon recoil", & u, results) <>= public :: isr_handler_2 <>= subroutine isr_handler_2 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(particle_set_t) :: pset type(model_list_t) :: model_list type(model_t), pointer :: model type(evt_trivial_t), target :: evt_trivial type(evt_isr_epa_t), target :: evt_isr_epa type(vector4_t), dimension(8) :: p real(default) :: sqrts real(default), dimension(2) :: x, xb class(rng_t), allocatable :: rng real(default) :: probability write (u, "(A)") "* Test output: isr_handler_2" write (u, "(A)") "* Purpose: apply photon handler with two-photon recoil" write (u, "(A)") write (u, "(A)") "* Initialize environment" write (u, "(A)") call syntax_model_file_init () call os_data%init () call model_list%read_model & (var_str ("SM"), var_str ("SM.mdl"), & os_data, model) write (u, "(A)") "* Initialize particle set" write (u, "(A)") call pset%init_direct (n_beam = 2, n_in = 2, n_rem = 2, n_vir = 0, n_out = 2, & pdg = [11, -11, 11, -11, 22, 22, 13, -13], model = model) sqrts = 100._default x = [0.6_default, 0.9_default] xb= 1 - x p(1) = vector4_moving (sqrts/2, sqrts/2, 3) p(2) = vector4_moving (sqrts/2,-sqrts/2, 3) p(3:4) = x * p(1:2) p(5:6) = xb * p(1:2) p(7:8) = p(3:4) call pset%set_momentum (p, on_shell = .false.) write (u, "(A)") "* Fill trivial event transform" write (u, "(A)") call evt_trivial%reset () call evt_trivial%set_particle_set (pset, 1, 1) call evt_trivial%write (u) call write_separator (u, 2) write (u, "(A)") write (u, "(A)") "* Initialize ISR handler transform" write (u, "(A)") evt_trivial%next => evt_isr_epa evt_isr_epa%previous => evt_trivial call evt_isr_epa%set_mode_string (var_str ("recoil")) call evt_isr_epa%set_data_isr ( & sqrts = sqrts, & q_max = sqrts, & m = 511.e-3_default, & keep_mass = .false. & ) allocate (rng_test_t :: rng) call rng%init (3) ! default would produce pi for azimuthal angle call evt_isr_epa%import_rng (rng) call evt_isr_epa%write (u, testflag=.true.) write (u, "(A)") write (u, "(A)") "* Fill ISR handler transform" write (u, "(A)") call evt_isr_epa%prepare_new_event (1, 1) call evt_isr_epa%generate_weighted (probability) call evt_isr_epa%make_particle_set (0, .false.) call evt_isr_epa%write (u, testflag=.true.) write (u, "(A)") write (u, "(A,1x,F8.5)") "Event probability =", probability write (u, "(A)") write (u, "(A)") "* Cleanup" call evt_isr_epa%final () call evt_trivial%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: isr_handler_2" end subroutine isr_handler_2 @ %def isr_handler_2 @ \subsubsection{Boosted beams} Handle photons resulting from ISR radiation. This test invokes the two-photon recoil mechanism, in the case that the partons before ISR are not in their c.m.\ frame (but collinear). <>= call test (isr_handler_3, "isr_handler_3", & "two-photon recoil with boost", & u, results) <>= public :: isr_handler_3 <>= subroutine isr_handler_3 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(particle_set_t) :: pset type(model_list_t) :: model_list type(model_t), pointer :: model type(evt_trivial_t), target :: evt_trivial type(evt_isr_epa_t), target :: evt_isr_epa type(vector4_t), dimension(8) :: p real(default) :: sqrts real(default), dimension(2) :: x0 real(default), dimension(2) :: x, xb class(rng_t), allocatable :: rng real(default) :: probability write (u, "(A)") "* Test output: isr_handler_3" write (u, "(A)") "* Purpose: apply photon handler for boosted beams & &and two-photon recoil" write (u, "(A)") write (u, "(A)") "* Initialize environment" write (u, "(A)") call syntax_model_file_init () call os_data%init () call model_list%read_model & (var_str ("SM"), var_str ("SM.mdl"), & os_data, model) write (u, "(A)") "* Initialize particle set" write (u, "(A)") call pset%init_direct (n_beam = 2, n_in = 2, n_rem = 2, n_vir = 0, n_out = 2, & pdg = [11, -11, 11, -11, 22, 22, 13, -13], model = model) write (u, "(A)") "* Event data" write (u, "(A)") sqrts = 100._default write (u, "(A,2(1x,F12.7))") "sqrts =", sqrts x0 = [0.9_default, 0.4_default] write (u, "(A,2(1x,F12.7))") "x0 =", x0 write (u, "(A)") write (u, "(A,2(1x,F12.7))") "sqs_hat =", sqrts * sqrt (product (x0)) x = [0.6_default, 0.9_default] xb= 1 - x write (u, "(A,2(1x,F12.7))") "x =", x write (u, "(A)") write (u, "(A,2(1x,F12.7))") "x0 * x =", x0 * x p(1) = x0(1) * vector4_moving (sqrts/2, sqrts/2, 3) p(2) = x0(2) * vector4_moving (sqrts/2,-sqrts/2, 3) p(3:4) = x * p(1:2) p(5:6) = xb * p(1:2) p(7:8) = p(3:4) call pset%set_momentum (p, on_shell = .false.) write (u, "(A)") write (u, "(A)") "* Fill trivial event transform" write (u, "(A)") call evt_trivial%reset () call evt_trivial%set_particle_set (pset, 1, 1) call evt_trivial%write (u) call write_separator (u, 2) write (u, "(A)") write (u, "(A)") "* Initialize ISR handler transform" write (u, "(A)") evt_trivial%next => evt_isr_epa evt_isr_epa%previous => evt_trivial call evt_isr_epa%set_mode_string (var_str ("recoil")) call evt_isr_epa%set_data_isr ( & sqrts = sqrts, & q_max = sqrts, & m = 511.e-3_default, & keep_mass = .false. & ) allocate (rng_test_t :: rng) call rng%init (3) ! default would produce pi for azimuthal angle call evt_isr_epa%import_rng (rng) call evt_isr_epa%write (u, testflag=.true.) write (u, "(A)") write (u, "(A)") "* Fill ISR handler transform" write (u, "(A)") call evt_isr_epa%prepare_new_event (1, 1) call evt_isr_epa%generate_weighted (probability) call evt_isr_epa%make_particle_set (0, .false.) call evt_isr_epa%write (u, testflag=.true.) write (u, "(A)") write (u, "(A,1x,F8.5)") "Event probability =", probability write (u, "(A)") write (u, "(A)") "* Cleanup" call evt_isr_epa%final () call evt_trivial%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: isr_handler_3" end subroutine isr_handler_3 @ %def isr_handler_3 @ \subsection{Unit tests: EPA} API: Extra driver for the unit tests below. <>= public :: epa_handler_test <>= subroutine epa_handler_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine epa_handler_test @ %def epa_handler_test @ \subsubsection{Trivial case} Handle events resulting from the EPA approximation. This test is for the trivial case where the event is kept collinear. <>= call test (epa_handler_1, "epa_handler_1", & "collinear case, no modification", & u, results) <>= public :: epa_handler_1 <>= subroutine epa_handler_1 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(particle_set_t) :: pset type(model_list_t) :: model_list type(model_t), pointer :: model type(evt_trivial_t), target :: evt_trivial type(evt_isr_epa_t), target :: evt_isr_epa type(vector4_t), dimension(8) :: p real(default) :: sqrts real(default), dimension(2) :: x, xb real(default) :: probability write (u, "(A)") "* Test output: epa_handler_1" write (u, "(A)") "* Purpose: apply beam handler trivially (no-op)" write (u, "(A)") write (u, "(A)") "* Initialize environment" write (u, "(A)") call syntax_model_file_init () call os_data%init () call model_list%read_model & (var_str ("SM"), var_str ("SM.mdl"), & os_data, model) write (u, "(A)") "* Initialize particle set" write (u, "(A)") call pset%init_direct & (n_beam = 2, n_in = 2, n_rem = 2, n_vir = 0, n_out = 2, & pdg = [11, -11, 22, 22, 11, -11, 13, -13], & model = model) sqrts = 100._default x = [0.6_default, 0.9_default] xb= 1 - x p(1) = vector4_moving (sqrts/2, sqrts/2, 3) p(2) = vector4_moving (sqrts/2,-sqrts/2, 3) p(3:4) = x * p(1:2) p(5:6) = xb * p(1:2) p(7:8) = p(3:4) call pset%set_momentum (p, on_shell = .false.) write (u, "(A)") "* Fill trivial event transform" write (u, "(A)") call evt_trivial%reset () call evt_trivial%set_particle_set (pset, 1, 1) call evt_trivial%write (u) call write_separator (u, 2) write (u, "(A)") write (u, "(A)") "* Initialize EPA handler transform" write (u, "(A)") evt_trivial%next => evt_isr_epa evt_isr_epa%previous => evt_trivial call evt_isr_epa%write (u) write (u, "(A)") write (u, "(A)") "* Fill EPA handler transform" write (u, "(A)") call evt_isr_epa%prepare_new_event (1, 1) call evt_isr_epa%generate_weighted (probability) call evt_isr_epa%make_particle_set (0, .false.) call evt_isr_epa%write (u) write (u, "(A)") write (u, "(A,1x,F8.5)") "Event probability =", probability write (u, "(A)") write (u, "(A)") "* Cleanup" call evt_isr_epa%final () call evt_trivial%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: epa_handler_1" end subroutine epa_handler_1 @ %def epa_handler_1 @ \subsubsection{Beam pair with recoil} Handle beams resulting from the EPA approximation. This test invokes the two-beam recoil mechanism. Both beam remnants acquire transverse momentum, the photon momenta recoil, such that total energy-momentum is conserved, and all outgoing beam remnants and photons are on-shell (massless). <>= call test (epa_handler_2, "epa_handler_2", & "two-beam recoil", & u, results) <>= public :: epa_handler_2 <>= subroutine epa_handler_2 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(particle_set_t) :: pset type(model_list_t) :: model_list type(model_t), pointer :: model type(evt_trivial_t), target :: evt_trivial type(evt_isr_epa_t), target :: evt_isr_epa type(vector4_t), dimension(8) :: p real(default) :: sqrts real(default), dimension(2) :: x, xb class(rng_t), allocatable :: rng real(default) :: probability write (u, "(A)") "* Test output: epa_handler_2" write (u, "(A)") "* Purpose: apply beam handler with two-beam recoil" write (u, "(A)") write (u, "(A)") "* Initialize environment" write (u, "(A)") call syntax_model_file_init () call os_data%init () call model_list%read_model & (var_str ("SM"), var_str ("SM.mdl"), & os_data, model) write (u, "(A)") "* Initialize particle set" write (u, "(A)") call pset%init_direct (n_beam = 2, n_in = 2, n_rem = 2, n_vir = 0, n_out = 2, & pdg = [11, -11, 22, 22, 11, -11, 13, -13], model = model) sqrts = 100._default x = [0.6_default, 0.9_default] xb= 1 - x p(1) = vector4_moving (sqrts/2, sqrts/2, 3) p(2) = vector4_moving (sqrts/2,-sqrts/2, 3) p(3:4) = x * p(1:2) p(5:6) = xb * p(1:2) p(7:8) = p(3:4) call pset%set_momentum (p, on_shell = .false.) write (u, "(A)") "* Fill trivial event transform" write (u, "(A)") call evt_trivial%reset () call evt_trivial%set_particle_set (pset, 1, 1) call evt_trivial%write (u) call write_separator (u, 2) write (u, "(A)") write (u, "(A)") "* Initialize EPA handler transform" write (u, "(A)") evt_trivial%next => evt_isr_epa evt_isr_epa%previous => evt_trivial call evt_isr_epa%set_mode_string (var_str ("recoil")) call evt_isr_epa%set_data_epa ( & sqrts = sqrts, & q_max = sqrts, & m = 511.e-3_default & ) allocate (rng_test_t :: rng) call rng%init (3) ! default would produce pi for azimuthal angle call evt_isr_epa%import_rng (rng) call evt_isr_epa%write (u, testflag=.true.) write (u, "(A)") write (u, "(A)") "* Fill EPA handler transform" write (u, "(A)") call evt_isr_epa%prepare_new_event (1, 1) call evt_isr_epa%generate_weighted (probability) call evt_isr_epa%make_particle_set (0, .false.) call evt_isr_epa%write (u, testflag=.true.) write (u, "(A)") write (u, "(A,1x,F8.5)") "Event probability =", probability write (u, "(A)") write (u, "(A)") "* Cleanup" call evt_isr_epa%final () call evt_trivial%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: epa_handler_2" end subroutine epa_handler_2 @ %def epa_handler_2 @ \subsubsection{Boosted beams} Handle radiated beam remnants resulting from EPA radiation. This test invokes the two-beam recoil mechanism, in the case that the partons before EPA are not in their c.m.\ frame (but collinear). <>= call test (epa_handler_3, "epa_handler_3", & "two-beam recoil with boost", & u, results) <>= public :: epa_handler_3 <>= subroutine epa_handler_3 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(particle_set_t) :: pset type(model_list_t) :: model_list type(model_t), pointer :: model type(evt_trivial_t), target :: evt_trivial type(evt_isr_epa_t), target :: evt_isr_epa type(vector4_t), dimension(8) :: p real(default) :: sqrts real(default), dimension(2) :: x0 real(default), dimension(2) :: x, xb class(rng_t), allocatable :: rng real(default) :: probability write (u, "(A)") "* Test output: epa_handler_3" write (u, "(A)") "* Purpose: apply beam handler for boosted beams & &and two-beam recoil" write (u, "(A)") write (u, "(A)") "* Initialize environment" write (u, "(A)") call syntax_model_file_init () call os_data%init () call model_list%read_model & (var_str ("SM"), var_str ("SM.mdl"), & os_data, model) write (u, "(A)") "* Initialize particle set" write (u, "(A)") call pset%init_direct (n_beam = 2, n_in = 2, n_rem = 2, n_vir = 0, n_out = 2, & pdg = [11, -11, 22, 22, 11, -11, 13, -13], model = model) write (u, "(A)") "* Event data" write (u, "(A)") sqrts = 100._default write (u, "(A,2(1x,F12.7))") "sqrts =", sqrts x0 = [0.9_default, 0.4_default] write (u, "(A,2(1x,F12.7))") "x0 =", x0 write (u, "(A)") write (u, "(A,2(1x,F12.7))") "sqs_hat =", sqrts * sqrt (product (x0)) x = [0.6_default, 0.9_default] xb= 1 - x write (u, "(A,2(1x,F12.7))") "x =", x write (u, "(A)") write (u, "(A,2(1x,F12.7))") "x0 * x =", x0 * x p(1) = x0(1) * vector4_moving (sqrts/2, sqrts/2, 3) p(2) = x0(2) * vector4_moving (sqrts/2,-sqrts/2, 3) p(3:4) = x * p(1:2) p(5:6) = xb * p(1:2) p(7:8) = p(3:4) call pset%set_momentum (p, on_shell = .false.) write (u, "(A)") write (u, "(A)") "* Fill trivial event transform" write (u, "(A)") call evt_trivial%reset () call evt_trivial%set_particle_set (pset, 1, 1) call evt_trivial%write (u) call write_separator (u, 2) write (u, "(A)") write (u, "(A)") "* Initialize EPA handler transform" write (u, "(A)") evt_trivial%next => evt_isr_epa evt_isr_epa%previous => evt_trivial call evt_isr_epa%set_mode_string (var_str ("recoil")) call evt_isr_epa%set_data_epa ( & sqrts = sqrts, & q_max = sqrts, & m = 511.e-3_default & ) allocate (rng_test_t :: rng) call rng%init (3) ! default would produce pi for azimuthal angle call evt_isr_epa%import_rng (rng) call evt_isr_epa%write (u, testflag=.true.) write (u, "(A)") write (u, "(A)") "* Fill EPA handler transform" write (u, "(A)") call evt_isr_epa%prepare_new_event (1, 1) call evt_isr_epa%generate_weighted (probability) call evt_isr_epa%make_particle_set (0, .false.) call evt_isr_epa%write (u, testflag=.true.) write (u, "(A)") write (u, "(A,1x,F8.5)") "Event probability =", probability write (u, "(A)") write (u, "(A)") "* Cleanup" call evt_isr_epa%final () call evt_trivial%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: epa_handler_3" end subroutine epa_handler_3 @ %def epa_handler_3 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Decays} <<[[decays.f90]]>>= <> module decays <> <> use io_units use format_utils, only: write_indent, write_separator use format_defs, only: FMT_15 use numeric_utils use diagnostics use flavors use helicities use quantum_numbers use interactions use evaluators use variables, only: var_list_t use model_data use rng_base use selectors use parton_states use process, only: process_t use instances, only: process_instance_t, pacify use process_stacks use event_transforms <> <> <> <> contains <> end module decays @ %def decays @ \subsection{Final-State Particle Configuration} A final-state particle may be either stable or unstable. Here is an empty abstract type as the parent of both, with holds just the flavor information. <>= type, abstract :: any_config_t private contains <> end type any_config_t @ %def any_config_t @ Finalizer, depends on the implementation. <>= procedure (any_config_final), deferred :: final <>= interface subroutine any_config_final (object) import class(any_config_t), intent(inout) :: object end subroutine any_config_final end interface @ %def any_config_final @ The output is also deferred: <>= procedure (any_config_write), deferred :: write <>= interface subroutine any_config_write (object, unit, indent, verbose) import class(any_config_t), intent(in) :: object integer, intent(in), optional :: unit, indent logical, intent(in), optional :: verbose end subroutine any_config_write end interface @ %def any_config_write @ This is a container for a stable or unstable particle configurator. We need this wrapper for preparing arrays that mix stable and unstable particles. <>= type :: particle_config_t private class(any_config_t), allocatable :: c end type particle_config_t @ %def particle_config_t @ \subsection{Final-State Particle} In theory, for the particle instance we only need to consider the unstable case. However, it is more straightforward to treat configuration and instance on the same footing, and to introduce a wrapper for particle objects as above. <>= type, abstract :: any_t private contains <> end type any_t @ %def any_t @ Finalizer, depends on the implementation. <>= procedure (any_final), deferred :: final <>= interface subroutine any_final (object) import class(any_t), intent(inout) :: object end subroutine any_final end interface @ %def any_final @ The output is also deferred: <>= procedure (any_write), deferred :: write <>= interface subroutine any_write (object, unit, indent) import class(any_t), intent(in) :: object integer, intent(in), optional :: unit, indent end subroutine any_write end interface @ %def any_write @ This is a container for a stable or unstable outgoing particle. We need this wrapper for preparing arrays that mix stable and unstable particles. <>= type :: particle_out_t private class(any_t), allocatable :: c end type particle_out_t @ %def particle_config_t @ \subsection{Decay Term Configuration} A decay term is a distinct final state, corresponding to a process term. Each decay process may give rise to several terms with, possibly, differing flavor content. <>= type :: decay_term_config_t private type(particle_config_t), dimension(:), allocatable :: prt contains <> end type decay_term_config_t @ %def decay_term_config_t @ Finalizer, recursive. <>= procedure :: final => decay_term_config_final <>= recursive subroutine decay_term_config_final (object) class(decay_term_config_t), intent(inout) :: object integer :: i if (allocated (object%prt)) then do i = 1, size (object%prt) if (allocated (object%prt(i)%c)) call object%prt(i)%c%final () end do end if end subroutine decay_term_config_final @ %def decay_term_config_final @ Output, with optional indentation <>= procedure :: write => decay_term_config_write <>= recursive subroutine decay_term_config_write (object, unit, indent, verbose) class(decay_term_config_t), intent(in) :: object integer, intent(in), optional :: unit, indent logical, intent(in), optional :: verbose integer :: i, j, u, ind logical :: verb u = given_output_unit (unit) ind = 0; if (present (indent)) ind = indent verb = .true.; if (present (verbose)) verb = verbose call write_indent (u, ind) write (u, "(1x,A)", advance="no") "Final state:" do i = 1, size (object%prt) select type (prt_config => object%prt(i)%c) type is (stable_config_t) write (u, "(1x,A)", advance="no") & char (prt_config%flv(1)%get_name ()) do j = 2, size (prt_config%flv) write (u, "(':',A)", advance="no") & char (prt_config%flv(j)%get_name ()) end do type is (unstable_config_t) write (u, "(1x,A)", advance="no") & char (prt_config%flv%get_name ()) end select end do write (u, *) if (verb) then do i = 1, size (object%prt) call object%prt(i)%c%write (u, ind) end do end if end subroutine decay_term_config_write @ %def decay_term_config_write @ Initialize, given a set of flavors. For each flavor, we must indicate whether the particle is stable. The second index of the flavor array runs over alternatives for each decay product; alternatives are allowed only if the decay product is itself stable. <>= procedure :: init => decay_term_config_init <>= recursive subroutine decay_term_config_init & (term, flv, stable, model, process_stack, var_list) class(decay_term_config_t), intent(out) :: term type(flavor_t), dimension(:,:), intent(in) :: flv logical, dimension(:), intent(in) :: stable class(model_data_t), intent(in), target :: model type(process_stack_t), intent(in), optional :: process_stack type(var_list_t), intent(in), optional :: var_list type(string_t), dimension(:), allocatable :: decay integer :: i allocate (term%prt (size (flv, 1))) do i = 1, size (flv, 1) associate (prt => term%prt(i)) if (stable(i)) then allocate (stable_config_t :: prt%c) else allocate (unstable_config_t :: prt%c) end if select type (prt_config => prt%c) type is (stable_config_t) call prt_config%init (flv(i,:)) type is (unstable_config_t) if (all (flv(i,:) == flv(i,1))) then call prt_config%init (flv(i,1)) call flv(i,1)%get_decays (decay) call prt_config%init_decays & (decay, model, process_stack, var_list) else call prt_config%write () call msg_fatal ("Decay configuration: & &unstable product must be unique") end if end select end associate end do end subroutine decay_term_config_init @ %def decay_term_config_init @ Recursively compute widths and branching ratios for all unstable particles. <>= procedure :: compute => decay_term_config_compute <>= recursive subroutine decay_term_config_compute (term) class(decay_term_config_t), intent(inout) :: term integer :: i do i = 1, size (term%prt) select type (unstable_config => term%prt(i)%c) type is (unstable_config_t) call unstable_config%compute () end select end do end subroutine decay_term_config_compute @ %def decay_term_config_compute @ \subsection{Decay Term} A decay term instance is selected when we generate an event for the associated process instance. When evaluated, it triggers further decays down the chain. Only unstable products are allocated as child particles. <>= type :: decay_term_t private type(decay_term_config_t), pointer :: config => null () type(particle_out_t), dimension(:), allocatable :: particle_out contains <> end type decay_term_t @ %def decay_term_t @ Finalizer. <>= procedure :: final => decay_term_final <>= recursive subroutine decay_term_final (object) class(decay_term_t), intent(inout) :: object integer :: i if (allocated (object%particle_out)) then do i = 1, size (object%particle_out) call object%particle_out(i)%c%final () end do end if end subroutine decay_term_final @ %def decay_term_final @ Output. <>= procedure :: write => decay_term_write <>= recursive subroutine decay_term_write (object, unit, indent) class(decay_term_t), intent(in) :: object integer, intent(in), optional :: unit, indent integer :: i, u, ind u = given_output_unit (unit) ind = 0; if (present (indent)) ind = indent call object%config%write (u, ind, verbose = .false.) do i = 1, size (object%particle_out) call object%particle_out(i)%c%write (u, ind) end do end subroutine decay_term_write @ %def decay_term_write @ Recursively write the embedded process instances. <>= procedure :: write_process_instances => decay_term_write_process_instances <>= recursive subroutine decay_term_write_process_instances (term, unit, verbose) class(decay_term_t), intent(in) :: term integer, intent(in), optional :: unit logical, intent(in), optional :: verbose integer :: i do i = 1, size (term%particle_out) select type (unstable => term%particle_out(i)%c) type is (unstable_t) call unstable%write_process_instances (unit, verbose) end select end do end subroutine decay_term_write_process_instances @ %def decay_term_write_process_instances @ Initialization, using the configuration object. We allocate particle objects in parallel to the particle configuration objects which we use to initialize them, one at a time. <>= procedure :: init => decay_term_init <>= recursive subroutine decay_term_init (term, config) class(decay_term_t), intent(out) :: term type(decay_term_config_t), intent(in), target :: config integer :: i term%config => config allocate (term%particle_out (size (config%prt))) do i = 1, size (config%prt) select type (prt_config => config%prt(i)%c) type is (stable_config_t) allocate (stable_t :: term%particle_out(i)%c) select type (stable => term%particle_out(i)%c) type is (stable_t) call stable%init (prt_config) end select type is (unstable_config_t) allocate (unstable_t :: term%particle_out(i)%c) select type (unstable => term%particle_out(i)%c) type is (unstable_t) call unstable%init (prt_config) end select end select end do end subroutine decay_term_init @ %def decay_term_init @ Implement a RNG instance, spawned by the process object. <>= procedure :: make_rng => decay_term_make_rng <>= subroutine decay_term_make_rng (term, process) class(decay_term_t), intent(inout) :: term type(process_t), intent(inout) :: process class(rng_t), allocatable :: rng integer :: i do i = 1, size (term%particle_out) select type (unstable => term%particle_out(i)%c) type is (unstable_t) call process%make_rng (rng) call unstable%import_rng (rng) end select end do end subroutine decay_term_make_rng @ %def decay_term_make_rng @ Link the interactions for unstable decay products to the interaction of the parent process. <>= procedure :: link_interactions => decay_term_link_interactions <>= recursive subroutine decay_term_link_interactions (term, trace) class(decay_term_t), intent(inout) :: term type(interaction_t), intent(in), target :: trace integer :: i do i = 1, size (term%particle_out) select type (unstable => term%particle_out(i)%c) type is (unstable_t) call unstable%link_interactions (i, trace) end select end do end subroutine decay_term_link_interactions @ %def decay_term_link_interactions @ Recursively generate a decay chain, for each of the unstable particles in the final state. <>= procedure :: select_chain => decay_term_select_chain <>= recursive subroutine decay_term_select_chain (term) class(decay_term_t), intent(inout) :: term integer :: i do i = 1, size (term%particle_out) select type (unstable => term%particle_out(i)%c) type is (unstable_t) call unstable%select_chain () end select end do end subroutine decay_term_select_chain @ %def decay_term_select_chain @ Recursively generate a decay event, for each of the unstable particles in the final state. <>= procedure :: generate => decay_term_generate <>= recursive subroutine decay_term_generate (term) class(decay_term_t), intent(inout) :: term integer :: i do i = 1, size (term%particle_out) select type (unstable => term%particle_out(i)%c) type is (unstable_t) call unstable%generate () end select end do end subroutine decay_term_generate @ %def decay_term_generate @ \subsection{Decay Root Configuration} At the root of a decay chain, there is a parent process. The decay root stores a pointer to the parent process and the set of decay configurations. <>= public :: decay_root_config_t <>= type :: decay_root_config_t private type(string_t) :: process_id type(process_t), pointer :: process => null () class(model_data_t), pointer :: model => null () type(decay_term_config_t), dimension(:), allocatable :: term_config contains <> end type decay_root_config_t @ %def decay_root_config_t @ The finalizer is recursive since there may be cascade decays. <>= procedure :: final => decay_root_config_final <>= recursive subroutine decay_root_config_final (object) class(decay_root_config_t), intent(inout) :: object integer :: i if (allocated (object%term_config)) then do i = 1, size (object%term_config) call object%term_config(i)%final () end do end if end subroutine decay_root_config_final @ %def decay_root_config_final @ The output routine is also recursive, and it contains an adjustable indentation. <>= procedure :: write => decay_root_config_write procedure :: write_header => decay_root_config_write_header procedure :: write_terms => decay_root_config_write_terms <>= recursive subroutine decay_root_config_write (object, unit, indent, verbose) class(decay_root_config_t), intent(in) :: object integer, intent(in), optional :: unit, indent logical, intent(in), optional :: verbose integer :: u, ind u = given_output_unit (unit) ind = 0; if (present (indent)) ind = indent call write_indent (u, ind) write (u, "(1x,A)") "Final-state decay tree:" call object%write_header (unit, indent) call object%write_terms (unit, indent, verbose) end subroutine decay_root_config_write subroutine decay_root_config_write_header (object, unit, indent) class(decay_root_config_t), intent(in) :: object integer, intent(in), optional :: unit, indent integer :: u, ind u = given_output_unit (unit) ind = 0; if (present (indent)) ind = indent call write_indent (u, ind) if (associated (object%process)) then write (u, 3) "process ID =", char (object%process_id), "*" else write (u, 3) "process ID =", char (object%process_id) end if 3 format (3x,A,2(1x,A)) end subroutine decay_root_config_write_header recursive subroutine decay_root_config_write_terms & (object, unit, indent, verbose) class(decay_root_config_t), intent(in) :: object integer, intent(in), optional :: unit, indent logical, intent(in), optional :: verbose integer :: i, u, ind logical :: verb u = given_output_unit (unit) ind = 0; if (present (indent)) ind = indent verb = .true.; if (present (verbose)) verb = verbose if (verb .and. allocated (object%term_config)) then do i = 1, size (object%term_config) call object%term_config(i)%write (u, ind + 1) end do end if end subroutine decay_root_config_write_terms @ %def decay_root_config_write @ Initialize for a named process and (optionally) a pre-determined number of terms. <>= procedure :: init => decay_root_config_init <>= subroutine decay_root_config_init (decay, model, process_id, n_terms) class(decay_root_config_t), intent(out) :: decay class(model_data_t), intent(in), target :: model type(string_t), intent(in) :: process_id integer, intent(in), optional :: n_terms decay%model => model decay%process_id = process_id if (present (n_terms)) then allocate (decay%term_config (n_terms)) end if end subroutine decay_root_config_init @ %def decay_root_config_init @ Declare a decay term, given an array of flavors. <>= procedure :: init_term => decay_root_config_init_term <>= recursive subroutine decay_root_config_init_term & (decay, i, flv, stable, model, process_stack, var_list) class(decay_root_config_t), intent(inout) :: decay integer, intent(in) :: i type(flavor_t), dimension(:,:), intent(in) :: flv logical, dimension(:), intent(in) :: stable class(model_data_t), intent(in), target :: model type(process_stack_t), intent(in), optional :: process_stack type(var_list_t), intent(in), optional, target :: var_list call decay%term_config(i)%init (flv, stable, model, process_stack, var_list) end subroutine decay_root_config_init_term @ %def decay_root_config_init_term @ Connect the decay root configuration with a process object (which should represent the parent process). This includes initialization, therefore intent(out). The flavor state is retrieved from the process term object. However, we have to be careful: the flavor object points to the model instance that is stored in the process object. This model instance may not contain the current setting for unstable particles and decay. Therefore, we assign the model directly. If the [[process_instance]] argument is provided, we use this for the flavor state. This applies to the decay root only, where the process can be entangled with a beam setup, and the latter contains beam remnants as further outgoing particles. These must be included in the set of outgoing flavors, since the decay application is also done on the connected state. Infer stability from the particle properties, using the first row in the set of flavor states. For unstable particles, we look for decays, recursively, available from the process stack (if present). For the unstable particles, we have to check whether their masses match between the production and the decay. Fortunately, both versions are available for comparison. The optional [[var_list]] argument may override integral/error values for decay processes. <>= procedure :: connect => decay_root_config_connect <>= recursive subroutine decay_root_config_connect & (decay, process, model, process_stack, process_instance, var_list) class(decay_root_config_t), intent(out) :: decay type(process_t), intent(in), target :: process class(model_data_t), intent(in), target :: model type(process_stack_t), intent(in), optional :: process_stack type(process_instance_t), intent(in), optional, target :: process_instance type(var_list_t), intent(in), optional, target :: var_list type(connected_state_t), pointer :: connected_state type(interaction_t), pointer :: int type(flavor_t), dimension(:,:), allocatable :: flv logical, dimension(:), allocatable :: stable real(default), dimension(:), allocatable :: m_prod, m_dec integer :: i call decay%init (model, process%get_id (), process%get_n_terms ()) do i = 1, size (decay%term_config) if (present (process_instance)) then connected_state => process_instance%get_connected_state_ptr (i) int => connected_state%get_matrix_int_ptr () call interaction_get_flv_out (int, flv) else call process%get_term_flv_out (i, flv) end if allocate (m_prod (size (flv(:,1)%get_mass ()))) m_prod = flv(:,1)%get_mass () call flv%set_model (model) allocate (m_dec (size (flv(:,1)%get_mass ()))) m_dec = flv(:,1)%get_mass () allocate (stable (size (flv, 1))) stable = flv(:,1)%is_stable () call check_masses () call decay%init_term (i, flv, stable, model, process_stack, var_list) deallocate (flv, stable, m_prod, m_dec) end do decay%process => process contains subroutine check_masses () integer :: i logical :: ok ok = .true. do i = 1, size (m_prod) if (.not. stable(i)) then if (.not. nearly_equal (m_prod(i), m_dec(i))) then write (msg_buffer, "(A,A,A)") "particle '", & char (flv(i,1)%get_name ()), "':" call msg_message write (msg_buffer, & "(2x,A,1x," // FMT_15 // ",3x,A,1x," // FMT_15 // ")") & "m_prod =", m_prod(i), "m_dec =", m_dec(i) call msg_message ok = .false. end if end if end do if (.not. ok) call msg_fatal & ("Particle mass mismatch between production and decay") end subroutine check_masses end subroutine decay_root_config_connect @ %def decay_root_config_connect @ Recursively compute widths, errors, and branching ratios. <>= procedure :: compute => decay_root_config_compute <>= recursive subroutine decay_root_config_compute (decay) class(decay_root_config_t), intent(inout) :: decay integer :: i do i = 1, size (decay%term_config) call decay%term_config(i)%compute () end do end subroutine decay_root_config_compute @ %def decay_root_config_compute @ \subsection{Decay Root Instance} This is the common parent type for decay and decay root. The process instance points to the parent process. The model pointer is separate because particle settings may be updated w.r.t.\ the parent process object. <>= type, abstract :: decay_gen_t private type(decay_term_t), dimension(:), allocatable :: term type(process_instance_t), pointer :: process_instance => null () integer :: selected_mci = 0 integer :: selected_term = 0 contains <> end type decay_gen_t @ %def decay_gen_t @ The decay root represents the parent process. When an event is generated, the generator selects the term to which the decay chain applies (if possible). The process instance is just a pointer. <>= public :: decay_root_t <>= type, extends (decay_gen_t) :: decay_root_t private type(decay_root_config_t), pointer :: config => null () contains <> end type decay_root_t @ %def decay_root_t @ The finalizer has to recursively finalize the terms, but we can skip the process instance which is not explicitly allocated. <>= procedure :: base_final => decay_gen_final <>= recursive subroutine decay_gen_final (object) class(decay_gen_t), intent(inout) :: object integer :: i if (allocated (object%term)) then do i = 1, size (object%term) call object%term(i)%final () end do end if end subroutine decay_gen_final @ %def decay_gen_final @ No extra finalization for the decay root. <>= procedure :: final => decay_root_final <>= subroutine decay_root_final (object) class(decay_root_t), intent(inout) :: object call object%base_final () end subroutine decay_root_final @ %def decay_gen_final @ Output. <>= procedure :: write => decay_root_write <>= subroutine decay_root_write (object, unit) class(decay_root_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) if (associated (object%config)) then call object%config%write (unit, verbose = .false.) else write (u, "(1x,A)") "Final-state decay tree: [not configured]" end if if (object%selected_mci > 0) then write (u, "(3x,A,I0)") "Selected MCI = ", object%selected_mci else write (u, "(3x,A)") "Selected MCI = [undefined]" end if if (object%selected_term > 0) then write (u, "(3x,A,I0)") "Selected term = ", object%selected_term call object%term(object%selected_term)%write (u, 1) else write (u, "(3x,A)") "Selected term = [undefined]" end if end subroutine decay_root_write @ %def decay_root_write @ Write the process instances, recursively. <>= procedure :: write_process_instances => decay_gen_write_process_instances <>= recursive subroutine decay_gen_write_process_instances (decay, unit, verbose) class(decay_gen_t), intent(in) :: decay integer, intent(in), optional :: unit logical, intent(in), optional :: verbose logical :: verb verb = .true.; if (present (verbose)) verb = verbose if (associated (decay%process_instance)) then if (verb) then call decay%process_instance%write (unit) else call decay%process_instance%write_header (unit) end if end if if (decay%selected_term > 0) then call decay%term(decay%selected_term)%write_process_instances (unit, verb) end if end subroutine decay_gen_write_process_instances @ %def decay_gen_write_process_instances @ Generic initializer. All can be done recursively. <>= procedure :: base_init => decay_gen_init <>= recursive subroutine decay_gen_init (decay, term_config) class(decay_gen_t), intent(out) :: decay type(decay_term_config_t), dimension(:), intent(in), target :: term_config integer :: i allocate (decay%term (size (term_config))) do i = 1, size (decay%term) call decay%term(i)%init (term_config(i)) end do end subroutine decay_gen_init @ %def decay_gen_init @ Specific initializer. We assign the configuration object, which should correspond to a completely initialized decay configuration tree. We also connect to an existing process instance. Then, we recursively link the child interactions to the parent process. <>= procedure :: init => decay_root_init <>= subroutine decay_root_init (decay_root, config, process_instance) class(decay_root_t), intent(out) :: decay_root type(decay_root_config_t), intent(in), target :: config type(process_instance_t), intent(in), target :: process_instance call decay_root%base_init (config%term_config) decay_root%config => config decay_root%process_instance => process_instance call decay_root%make_term_rng (config%process) call decay_root%link_term_interactions () end subroutine decay_root_init @ %def decay_root_init @ Explicitly set/get mci and term indices. (Used in unit test.) <>= procedure :: set_mci => decay_gen_set_mci procedure :: set_term => decay_gen_set_term procedure :: get_mci => decay_gen_get_mci procedure :: get_term => decay_gen_get_term <>= subroutine decay_gen_set_mci (decay, i) class(decay_gen_t), intent(inout) :: decay integer, intent(in) :: i decay%selected_mci = i end subroutine decay_gen_set_mci subroutine decay_gen_set_term (decay, i) class(decay_gen_t), intent(inout) :: decay integer, intent(in) :: i decay%selected_term = i end subroutine decay_gen_set_term function decay_gen_get_mci (decay) result (i) class(decay_gen_t), intent(inout) :: decay integer :: i i = decay%selected_mci end function decay_gen_get_mci function decay_gen_get_term (decay) result (i) class(decay_gen_t), intent(inout) :: decay integer :: i i = decay%selected_term end function decay_gen_get_term @ %def decay_gen_set_mci @ %def decay_gen_set_term @ %def decay_gen_get_mci @ %def decay_gen_get_term @ Implement random-number generators for unstable decay selection in all terms. This is not recursive. We also make use of the fact that [[process]] is a pointer; the (state of the RNG factory inside the) target process will be modified by the rng-spawning method, but not the pointer. <>= procedure :: make_term_rng => decay_gen_make_term_rng <>= subroutine decay_gen_make_term_rng (decay, process) class(decay_gen_t), intent(inout) :: decay type(process_t), intent(in), pointer :: process integer :: i do i = 1, size (decay%term) call decay%term(i)%make_rng (process) end do end subroutine decay_gen_make_term_rng @ %def decay_gen_make_term_rng @ Recursively link interactions of the enclosed decay terms to the corresponding terms in the current process instance. <>= procedure :: link_term_interactions => decay_gen_link_term_interactions <>= recursive subroutine decay_gen_link_term_interactions (decay) class(decay_gen_t), intent(inout) :: decay integer :: i type(interaction_t), pointer :: trace associate (instance => decay%process_instance) do i = 1, size (decay%term) trace => instance%get_trace_int_ptr (i) call decay%term(i)%link_interactions (trace) end do end associate end subroutine decay_gen_link_term_interactions @ %def decay_gen_link_term_interactions @ Select a decay chain: decay modes and process components. <>= procedure :: select_chain => decay_root_select_chain <>= subroutine decay_root_select_chain (decay_root) class(decay_root_t), intent(inout) :: decay_root if (decay_root%selected_term > 0) then call decay_root%term(decay_root%selected_term)%select_chain () else call msg_bug ("Decays: no term selected for parent process") end if end subroutine decay_root_select_chain @ %def decay_root_select_chain @ Generate a decay tree, i.e., for the selected term in the parent process, recursively generate a decay event for all unstable particles. Factor out the trace of the connected state of the parent process. This trace should not be taken into account for unweighting the decay chain, since it was already used for unweighting the parent event, or it determines the overall event weight. <>= procedure :: generate => decay_root_generate <>= subroutine decay_root_generate (decay_root) class(decay_root_t), intent(inout) :: decay_root type(connected_state_t), pointer :: connected_state if (decay_root%selected_term > 0) then connected_state => decay_root%process_instance%get_connected_state_ptr & (decay_root%selected_term) call connected_state%normalize_matrix_by_trace () call decay_root%term(decay_root%selected_term)%generate () else call msg_bug ("Decays: no term selected for parent process") end if end subroutine decay_root_generate @ %def decay_root_generate @ \subsection{Decay Configuration} A decay configuration describes a distinct decay mode of a particle. Each decay mode may include several terms, which correspond to the terms in the associated process. In addition to the base type, the decay configuration object contains the integral of the parent process and the selector for the MCI group inside this process. The flavor component should be identical to the flavor component of the parent particle ([[unstable]] object). <>= type, extends (decay_root_config_t) :: decay_config_t private type(flavor_t) :: flv real(default) :: weight = 0 real(default) :: integral = 0 real(default) :: abs_error = 0 real(default) :: rel_error = 0 type(selector_t) :: mci_selector contains <> end type decay_config_t @ %def decay_config_t @ The output routine extends the decay-root writer by listing numerical component values. <>= procedure :: write => decay_config_write <>= recursive subroutine decay_config_write (object, unit, indent, verbose) class(decay_config_t), intent(in) :: object integer, intent(in), optional :: unit, indent logical, intent(in), optional :: verbose integer :: u, ind u = given_output_unit (unit) ind = 0; if (present (indent)) ind = indent call write_indent (u, ind) write (u, "(1x,A)") "Decay:" call object%write_header (unit, indent) call write_indent (u, ind) write (u, 2) "branching ratio =", object%weight * 100 call write_indent (u, ind) write (u, 1) "partial width =", object%integral call write_indent (u, ind) write (u, 1) "error (abs) =", object%abs_error call write_indent (u, ind) write (u, 1) "error (rel) =", object%rel_error 1 format (3x,A,ES19.12) 2 format (3x,A,F11.6,1x,'%') call object%write_terms (unit, indent, verbose) end subroutine decay_config_write @ %def decay_config_write @ Connect a decay configuration with a process object (which should represent the decay). This includes initialization, therefore intent(out). We first connect the process itself, then do initializations that are specific for this decay. Infer stability from the particle properties, using the first row in the set of flavor states. Once we can deal with predetermined decay chains, they should be used instead. If there is an optional [[var_list]], check if the stored values for the decay partial width and error have been overridden there. <>= procedure :: connect => decay_config_connect <>= recursive subroutine decay_config_connect & (decay, process, model, process_stack, process_instance, var_list) class(decay_config_t), intent(out) :: decay type(process_t), intent(in), target :: process class(model_data_t), intent(in), target :: model type(process_stack_t), intent(in), optional :: process_stack type(process_instance_t), intent(in), optional, target :: process_instance type(var_list_t), intent(in), optional, target :: var_list real(default), dimension(:), allocatable :: integral_mci type(string_t) :: process_id integer :: i, n_mci call decay%decay_root_config_t%connect & (process, model, process_stack, var_list=var_list) process_id = process%get_id () if (process%cm_frame ()) then call msg_fatal ("Decay process " // char (process_id) & // ": unusable because rest frame is fixed.") end if decay%integral = process%get_integral () decay%abs_error = process%get_error () if (present (var_list)) then call update (decay%integral, "integral(" // process_id // ")") call update (decay%abs_error, "error(" // process_id // ")") end if n_mci = process%get_n_mci () allocate (integral_mci (n_mci)) do i = 1, n_mci integral_mci(i) = process%get_integral_mci (i) end do call decay%mci_selector%init (integral_mci) contains subroutine update (var, var_name) real(default), intent(inout) :: var type(string_t), intent(in) :: var_name if (var_list%contains (var_name)) then var = var_list%get_rval (var_name) end if end subroutine update end subroutine decay_config_connect @ %def decay_config_connect @ Set the flavor entry, which repeats the flavor of the parent unstable particle. <>= procedure :: set_flv => decay_config_set_flv <>= subroutine decay_config_set_flv (decay, flv) class(decay_config_t), intent(inout) :: decay type(flavor_t), intent(in) :: flv decay%flv = flv end subroutine decay_config_set_flv @ %def decay_config_set_flv @ Compute embedded branchings and the relative error. This method does not apply to the decay root. <>= procedure :: compute => decay_config_compute <>= recursive subroutine decay_config_compute (decay) class(decay_config_t), intent(inout) :: decay call decay%decay_root_config_t%compute () if (.not. vanishes (decay%integral)) then decay%rel_error = decay%abs_error / decay%integral else decay%rel_error = 0 end if end subroutine decay_config_compute @ %def decay_config_compute @ \subsection{Decay Instance} The decay contains a collection of terms. One of them is selected when the decay is evaluated. This is similar to the decay root, but we implement it independently. The process instance object is allocated via a pointer, so it automatically behaves as a target. <>= type, extends (decay_gen_t) :: decay_t private type(decay_config_t), pointer :: config => null () class(rng_t), allocatable :: rng contains <> end type decay_t @ %def decay_t @ The finalizer is recursive. <>= procedure :: final => decay_final <>= recursive subroutine decay_final (object) class(decay_t), intent(inout) :: object integer :: i call object%base_final () do i = 1, object%config%process%get_n_mci () call object%process_instance%final_simulation (i) end do call object%process_instance%final () deallocate (object%process_instance) end subroutine decay_final @ %def decay_final @ Output. <>= procedure :: write => decay_write <>= recursive subroutine decay_write (object, unit, indent, recursive) class(decay_t), intent(in) :: object integer, intent(in), optional :: unit, indent, recursive integer :: u, ind u = given_output_unit (unit) ind = 0; if (present (indent)) ind = indent call object%config%write (unit, indent, verbose = .false.) if (allocated (object%rng)) then call object%rng%write (u, ind + 1) end if call write_indent (u, ind) if (object%selected_mci > 0) then write (u, "(3x,A,I0)") "Selected MCI = ", object%selected_mci else write (u, "(3x,A)") "Selected MCI = [undefined]" end if call write_indent (u, ind) if (object%selected_term > 0) then write (u, "(3x,A,I0)") "Selected term = ", object%selected_term call object%term(object%selected_term)%write (u, ind + 1) else write (u, "(3x,A)") "Selected term = [undefined]" end if end subroutine decay_write @ %def decay_write @ Initializer. Base initialization is done recursively. Then, we prepare the current process instance and allocate a random-number generator for term selection. For all unstable particles, we also allocate a r.n.g. as spawned by the current process. <>= procedure :: init => decay_init <>= recursive subroutine decay_init (decay, config) class(decay_t), intent(out) :: decay type(decay_config_t), intent(in), target :: config integer :: i call decay%base_init (config%term_config) decay%config => config allocate (decay%process_instance) call decay%process_instance%init (decay%config%process) call decay%process_instance%setup_event_data (decay%config%model) do i = 1, decay%config%process%get_n_mci () call decay%process_instance%init_simulation (i) end do call decay%config%process%make_rng (decay%rng) call decay%make_term_rng (decay%config%process) end subroutine decay_init @ %def decay_init @ Link interactions to the parent process. [[i_prt]] is the index of the current outgoing particle in the parent interaction, for which we take the trace evaluator. We link it to the beam particle in the beam interaction of the decay process instance. Then, repeat the procedure for the outgoing particles. <>= procedure :: link_interactions => decay_link_interactions <>= recursive subroutine decay_link_interactions (decay, i_prt, trace) class(decay_t), intent(inout) :: decay integer, intent(in) :: i_prt type(interaction_t), intent(in), target :: trace type(interaction_t), pointer :: beam_int integer :: n_in, n_vir beam_int => decay%process_instance%get_beam_int_ptr () n_in = trace%get_n_in () n_vir = trace%get_n_vir () call beam_int%set_source_link (1, trace, & n_in + n_vir + i_prt) call decay%link_term_interactions () end subroutine decay_link_interactions @ %def decay_link_interactions @ Determine a decay chain. For each unstable particle we select one of the possible decay modes, and for each decay process we select one of the possible decay MCI components, calling the random-number generators. We do not generate momenta, yet. <>= procedure :: select_chain => decay_select_chain <>= recursive subroutine decay_select_chain (decay) class(decay_t), intent(inout) :: decay real(default) :: x integer :: i call decay%rng%generate (x) decay%selected_mci = decay%config%mci_selector%select (x) call decay%process_instance%choose_mci (decay%selected_mci) decay%selected_term = decay%process_instance%select_i_term () do i = 1, size (decay%term) call decay%term(i)%select_chain () end do end subroutine decay_select_chain @ %def decay_select_chain @ Generate a decay. We first receive the beam momenta from the parent process (assuming that this is properly linked), then call the associated process object for a new event. Factor out the trace of the helicity density matrix of the isolated state (the one that will be used for the decay chain). The trace is taken into account for unweighting the individual decay event and should therefore be ignored for unweighting the correlated decay chain afterwards. <>= procedure :: generate => decay_generate <>= recursive subroutine decay_generate (decay) class(decay_t), intent(inout) :: decay type(isolated_state_t), pointer :: isolated_state integer :: i call decay%process_instance%receive_beam_momenta () call decay%process_instance%generate_unweighted_event (decay%selected_mci) if (signal_is_pending ()) return call decay%process_instance%evaluate_event_data () isolated_state => & decay%process_instance%get_isolated_state_ptr (decay%selected_term) call isolated_state%normalize_matrix_by_trace () do i = 1, size (decay%term) call decay%term(i)%generate () if (signal_is_pending ()) return end do end subroutine decay_generate @ %def decay_generate @ \subsection{Stable Particles} This is a stable particle. The flavor can be ambiguous (e.g., partons). <>= type, extends (any_config_t) :: stable_config_t private type(flavor_t), dimension(:), allocatable :: flv contains <> end type stable_config_t @ %def stable_config_t @ The finalizer is empty: <>= procedure :: final => stable_config_final <>= subroutine stable_config_final (object) class(stable_config_t), intent(inout) :: object end subroutine stable_config_final @ %def stable_config_final @ Output. <>= procedure :: write => stable_config_write <>= recursive subroutine stable_config_write (object, unit, indent, verbose) class(stable_config_t), intent(in) :: object integer, intent(in), optional :: unit, indent logical, intent(in), optional :: verbose integer :: u, i, ind u = given_output_unit (unit) ind = 0; if (present (indent)) ind = indent call write_indent (u, ind) write (u, "(1x,'+',1x,A)", advance = "no") "Stable:" write (u, "(1x,A)", advance = "no") char (object%flv(1)%get_name ()) do i = 2, size (object%flv) write (u, "(':',A)", advance = "no") & char (object%flv(i)%get_name ()) end do write (u, *) end subroutine stable_config_write @ %def stable_config_write @ Initializer. We are presented with an array of flavors, but there may be double entries which we remove, so we store only the distinct flavors. <>= procedure :: init => stable_config_init <>= subroutine stable_config_init (config, flv) class(stable_config_t), intent(out) :: config type(flavor_t), dimension(:), intent(in) :: flv integer, dimension (size (flv)) :: pdg logical, dimension (size (flv)) :: mask integer :: i pdg = flv%get_pdg () mask(1) = .true. forall (i = 2 : size (pdg)) mask(i) = all (pdg(i) /= pdg(1:i-1)) end forall allocate (config%flv (count (mask))) config%flv = pack (flv, mask) end subroutine stable_config_init @ %def stable_config_init @ Here is the corresponding object instance. Except for the pointer to the configuration, there is no content. <>= type, extends (any_t) :: stable_t private type(stable_config_t), pointer :: config => null () contains <> end type stable_t @ %def stable_t @ The finalizer does nothing. <>= procedure :: final => stable_final <>= subroutine stable_final (object) class(stable_t), intent(inout) :: object end subroutine stable_final @ %def stable_final @ We can delegate output to the configuration object. <>= procedure :: write => stable_write <>= subroutine stable_write (object, unit, indent) class(stable_t), intent(in) :: object integer, intent(in), optional :: unit, indent call object%config%write (unit, indent) end subroutine stable_write @ %def stable_write @ Initializer: just assign the configuration. <>= procedure :: init => stable_init <>= subroutine stable_init (stable, config) class(stable_t), intent(out) :: stable type(stable_config_t), intent(in), target :: config stable%config => config end subroutine stable_init @ %def stable_init @ \subsection{Unstable Particles} A branching configuration enables us to select among distinct decay modes of a particle. We store the particle flavor (with its implicit link to a model), an array of decay configurations, and a selector object. The total width, absolute and relative error are stored as [[integral]], [[abs_error]], and [[rel_error]], respectively. The flavor must be unique in this case. <>= public :: unstable_config_t <>= type, extends (any_config_t) :: unstable_config_t private type(flavor_t) :: flv real(default) :: integral = 0 real(default) :: abs_error = 0 real(default) :: rel_error = 0 type(selector_t) :: selector type(decay_config_t), dimension(:), allocatable :: decay_config contains <> end type unstable_config_t @ %def unstable_config_t @ Finalizer. The branching configuration can be a recursive structure. <>= procedure :: final => unstable_config_final <>= recursive subroutine unstable_config_final (object) class(unstable_config_t), intent(inout) :: object integer :: i if (allocated (object%decay_config)) then do i = 1, size (object%decay_config) call object%decay_config(i)%final () end do end if end subroutine unstable_config_final @ %def unstable_config_final @ Output. Since this may be recursive, we include indentation. <>= procedure :: write => unstable_config_write <>= recursive subroutine unstable_config_write (object, unit, indent, verbose) class(unstable_config_t), intent(in) :: object integer, intent(in), optional :: unit, indent logical, intent(in), optional :: verbose integer :: u, i, ind logical :: verb u = given_output_unit (unit) ind = 0; if (present (indent)) ind = indent verb = .true.; if (present (verbose)) verb = verbose call write_indent (u, ind) write (u, "(1x,'+',1x,A,1x,A)") "Unstable:", & char (object%flv%get_name ()) call write_indent (u, ind) write (u, 1) "total width =", object%integral call write_indent (u, ind) write (u, 1) "error (abs) =", object%abs_error call write_indent (u, ind) write (u, 1) "error (rel) =", object%rel_error 1 format (5x,A,ES19.12) if (verb .and. allocated (object%decay_config)) then do i = 1, size (object%decay_config) call object%decay_config(i)%write (u, ind + 1) end do end if end subroutine unstable_config_write @ %def unstable_config_write @ Initializer. For the unstable particle, the flavor is unique. <>= procedure :: init => unstable_config_init <>= subroutine unstable_config_init (unstable, flv, set_decays, model) class(unstable_config_t), intent(out) :: unstable type(flavor_t), intent(in) :: flv logical, intent(in), optional :: set_decays class(model_data_t), intent(in), optional, target :: model type(string_t), dimension(:), allocatable :: decay unstable%flv = flv if (present (set_decays)) then call unstable%flv%get_decays (decay) call unstable%init_decays (decay, model) end if end subroutine unstable_config_init @ %def unstable_config_init @ Further initialization: determine the number of decay modes. We can assume that the flavor of the particle has been set already. If the process stack is given, we can delve recursively into actually assigning decay processes. Otherwise, we just initialize with decay process names. <>= procedure :: init_decays => unstable_config_init_decays <>= recursive subroutine unstable_config_init_decays & (unstable, decay_id, model, process_stack, var_list) class(unstable_config_t), intent(inout) :: unstable type(string_t), dimension(:), intent(in) :: decay_id class(model_data_t), intent(in), target :: model type(process_stack_t), intent(in), optional :: process_stack type(var_list_t), intent(in), optional :: var_list integer :: i allocate (unstable%decay_config (size (decay_id))) do i = 1, size (decay_id) associate (decay => unstable%decay_config(i)) if (present (process_stack)) then call decay%connect (process_stack%get_process_ptr (decay_id(i)), & model, process_stack, var_list=var_list) else call decay%init (model, decay_id(i)) end if call decay%set_flv (unstable%flv) end associate end do end subroutine unstable_config_init_decays @ %def unstable_config_init @ Explicitly connect a specific decay with a process. This is used only in unit tests. <>= procedure :: connect_decay => unstable_config_connect_decay <>= subroutine unstable_config_connect_decay (unstable, i, process, model) class(unstable_config_t), intent(inout) :: unstable integer, intent(in) :: i type(process_t), intent(in), target :: process class(model_data_t), intent(in), target :: model associate (decay => unstable%decay_config(i)) call decay%connect (process, model) end associate end subroutine unstable_config_connect_decay @ %def unstable_config_connect_decay @ Compute the total width and branching ratios, initializing the decay selector. <>= procedure :: compute => unstable_config_compute <>= recursive subroutine unstable_config_compute (unstable) class(unstable_config_t), intent(inout) :: unstable integer :: i do i = 1, size (unstable%decay_config) call unstable%decay_config(i)%compute () end do unstable%integral = sum (unstable%decay_config%integral) if (unstable%integral <= 0) then call unstable%write () call msg_fatal ("Decay configuration: computed total width is zero") end if unstable%abs_error = sqrt (sum (unstable%decay_config%abs_error ** 2)) unstable%rel_error = unstable%abs_error / unstable%integral call unstable%selector%init (unstable%decay_config%integral) do i = 1, size (unstable%decay_config) unstable%decay_config(i)%weight & = unstable%selector%get_weight (i) end do end subroutine unstable_config_compute @ %def unstable_config_compute @ Now we define the instance of an unstable particle. <>= public :: unstable_t <>= type, extends (any_t) :: unstable_t private type(unstable_config_t), pointer :: config => null () class(rng_t), allocatable :: rng integer :: selected_decay = 0 type(decay_t), dimension(:), allocatable :: decay contains <> end type unstable_t @ %def unstable_t @ Recursive finalizer. <>= procedure :: final => unstable_final <>= recursive subroutine unstable_final (object) class(unstable_t), intent(inout) :: object integer :: i if (allocated (object%decay)) then do i = 1, size (object%decay) call object%decay(i)%final () end do end if end subroutine unstable_final @ %def unstable_final @ Output. <>= procedure :: write => unstable_write <>= recursive subroutine unstable_write (object, unit, indent) class(unstable_t), intent(in) :: object integer, intent(in), optional :: unit, indent integer :: u, ind u = given_output_unit (unit) ind = 0; if (present (indent)) ind = indent call object%config%write (u, ind, verbose=.false.) if (allocated (object%rng)) then call object%rng%write (u, ind + 2) end if call write_indent (u, ind) if (object%selected_decay > 0) then write (u, "(5x,A,I0)") "Sel. decay = ", object%selected_decay call object%decay(object%selected_decay)%write (u, ind + 1) else write (u, "(5x,A)") "Sel. decay = [undefined]" end if end subroutine unstable_write @ %def unstable_write @ Write the embedded process instances. <>= procedure :: write_process_instances => unstable_write_process_instances <>= recursive subroutine unstable_write_process_instances & (unstable, unit, verbose) class(unstable_t), intent(in) :: unstable integer, intent(in), optional :: unit logical, intent(in), optional :: verbose if (unstable%selected_decay > 0) then call unstable%decay(unstable%selected_decay)% & write_process_instances (unit, verbose) end if end subroutine unstable_write_process_instances @ %def unstable_write_process_instances @ Initialization, using the configuration object. <>= procedure :: init => unstable_init <>= recursive subroutine unstable_init (unstable, config) class(unstable_t), intent(out) :: unstable type(unstable_config_t), intent(in), target :: config integer :: i unstable%config => config allocate (unstable%decay (size (config%decay_config))) do i = 1, size (config%decay_config) call unstable%decay(i)%init (config%decay_config(i)) end do end subroutine unstable_init @ %def unstable_init @ Recursively link interactions to the parent process. [[i_prt]] is the index of the current outgoing particle in the parent interaction. <>= procedure :: link_interactions => unstable_link_interactions <>= recursive subroutine unstable_link_interactions (unstable, i_prt, trace) class(unstable_t), intent(inout) :: unstable integer, intent(in) :: i_prt type(interaction_t), intent(in), target :: trace integer :: i do i = 1, size (unstable%decay) call unstable%decay(i)%link_interactions (i_prt, trace) end do end subroutine unstable_link_interactions @ %def unstable_link_interactions @ Import the random-number generator state. <>= procedure :: import_rng => unstable_import_rng <>= subroutine unstable_import_rng (unstable, rng) class(unstable_t), intent(inout) :: unstable class(rng_t), intent(inout), allocatable :: rng call move_alloc (from = rng, to = unstable%rng) end subroutine unstable_import_rng @ %def unstable_import_rng @ Generate a decay chain. First select a decay mode, then call the [[select_chain]] method of the selected mode. <>= procedure :: select_chain => unstable_select_chain <>= recursive subroutine unstable_select_chain (unstable) class(unstable_t), intent(inout) :: unstable real(default) :: x call unstable%rng%generate (x) unstable%selected_decay = unstable%config%selector%select (x) call unstable%decay(unstable%selected_decay)%select_chain () end subroutine unstable_select_chain @ %def unstable_select_chain @ Generate a decay event. <>= procedure :: generate => unstable_generate <>= recursive subroutine unstable_generate (unstable) class(unstable_t), intent(inout) :: unstable call unstable%decay(unstable%selected_decay)%generate () end subroutine unstable_generate @ %def unstable_generate @ \subsection{Decay Chain} While the decay configuration tree and the decay tree are static entities (during a simulation run), the decay chain is dynamically generated for each event. The reason is that with the possibility of several decay modes for each particle, and several terms for each process, the total number of distinct decay chains is not under control. Each entry in the decay chain is a connected parton state. The origin of the chain is a connected state in the parent process (not part of the chain itself). For each decay, mode and term chosen, we convolute this with the isolated (!) state of the current decay, to generate a new connected state. We accumulate this chain by recursively traversing the allocated decay tree. Whenever a particle decays, it becomes virtual and is replaced by its decay product, while all other particles stay in the parton state as spectators. Technically, we implement the decay chain as a stack structure and include information from the associated decay object for easier debugging. This is a decay chain entry: <>= type, extends (connected_state_t) :: decay_chain_entry_t private integer :: index = 0 type(decay_config_t), pointer :: config => null () integer :: selected_mci = 0 integer :: selected_term = 0 type(decay_chain_entry_t), pointer :: previous => null () end type decay_chain_entry_t @ %def decay_chain_entry_t @ This is the complete chain; we need just a pointer to the last entry. We also include a pointer to the master process instance, which serves as the seed for the decay chain. The evaluator [[correlated_trace]] traces over all quantum numbers for the final spin-correlated (but color-summed) evaluator of the decay chain. This allows us to compute the probability for a momentum configuration, given that all individual density matrices (of the initial process and the subsequent decays) have been normalized to one. Note: This trace is summed over color, so color is treated exactly when computing spin correlations. However, we do not keep non-diagonal color correlations. When an event is accepted, we compute probabilities for all color states and can choose one of them. <>= public :: decay_chain_t <>= type :: decay_chain_t private type(process_instance_t), pointer :: process_instance => null () integer :: selected_term = 0 type(evaluator_t) :: correlated_trace type(decay_chain_entry_t), pointer :: last => null () contains <> end type decay_chain_t @ %def decay_chain_t @ The finalizer recursively deletes and deallocates the entries. <>= procedure :: final => decay_chain_final <>= subroutine decay_chain_final (object) class(decay_chain_t), intent(inout) :: object type(decay_chain_entry_t), pointer :: entry do while (associated (object%last)) entry => object%last object%last => entry%previous call entry%final () deallocate (entry) end do call object%correlated_trace%final () end subroutine decay_chain_final @ %def decay_chain_final @ Doing output recursively allows us to display the chain in chronological order. <>= procedure :: write => decay_chain_write <>= subroutine decay_chain_write (object, unit) class(decay_chain_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) call write_separator (u, 2) write (u, "(1x,A)") "Decay chain:" call write_entries (object%last) call write_separator (u, 2) write (u, "(1x,A)") "Evaluator (correlated trace of the decay chain):" call write_separator (u) call object%correlated_trace%write (u) call write_separator (u, 2) contains recursive subroutine write_entries (entry) type(decay_chain_entry_t), intent(in), pointer :: entry if (associated (entry)) then call write_entries (entry%previous) call write_separator (u, 2) write (u, "(1x,A,I0)") "Decay #", entry%index call entry%config%write_header (u) write (u, "(3x,A,I0)") "Selected MCI = ", entry%selected_mci write (u, "(3x,A,I0)") "Selected term = ", entry%selected_term call entry%config%term_config(entry%selected_term)%write (u, indent=1) call entry%write (u) end if end subroutine write_entries end subroutine decay_chain_write @ %def decay_chain_write @ Build a decay chain, recursively following the selected decays and terms in a decay tree. Before start, we finalize the chain, deleting any previous contents. <>= procedure :: build => decay_chain_build <>= subroutine decay_chain_build (chain, decay_root) class(decay_chain_t), intent(inout), target :: chain type(decay_root_t), intent(in) :: decay_root type(quantum_numbers_mask_t), dimension(:), allocatable :: qn_mask type(interaction_t), pointer :: int_last_decay call chain%final () if (decay_root%selected_term > 0) then chain%process_instance => decay_root%process_instance chain%selected_term = decay_root%selected_term call chain%build_term_entries (decay_root%term(decay_root%selected_term)) end if int_last_decay => chain%last%get_matrix_int_ptr () allocate (qn_mask (int_last_decay%get_n_tot ())) call qn_mask%init (mask_f = .true., mask_c = .true., mask_h = .true.) call chain%correlated_trace%init_qn_sum (int_last_decay, qn_mask) end subroutine decay_chain_build @ %def decay_chain_build @ Build the entries that correspond to a decay term. We have to scan all unstable particles. <>= procedure :: build_term_entries => decay_chain_build_term_entries <>= recursive subroutine decay_chain_build_term_entries (chain, term) class(decay_chain_t), intent(inout) :: chain type(decay_term_t), intent(in) :: term integer :: i do i = 1, size (term%particle_out) select type (unstable => term%particle_out(i)%c) type is (unstable_t) if (unstable%selected_decay > 0) then call chain%build_decay_entries & (unstable%decay(unstable%selected_decay)) end if end select end do end subroutine decay_chain_build_term_entries @ %def decay_chain_build_term_entries @ Build the entries that correspond to a specific decay. The decay term should have been determined, so we allocate a decay chain entry and fill it, then proceed to child decays. For the first entry, we convolute the connected state of the parent process instance with the isolated state of the current decay (which does not contain an extra beam entry for the parent). For subsequent entries, we take the previous entry as first factor. In principle, each chain entry (as a parton state) is capable of holding a subevent object and associated expressions. We currently do not make use of that feature. Before generating the decays, factor out the trace of the helicity density matrix of the parent parton state. This trace has been used for unweighting the original event (unweighted case) or it determines the overall weight, so it should not be taken into account in the decay chain generation. <>= procedure :: build_decay_entries => decay_chain_build_decay_entries <>= recursive subroutine decay_chain_build_decay_entries (chain, decay) class(decay_chain_t), intent(inout) :: chain type(decay_t), intent(in) :: decay type(decay_chain_entry_t), pointer :: entry type(connected_state_t), pointer :: previous_state type(isolated_state_t), pointer :: current_decay type(helicity_t) :: hel type(quantum_numbers_t) :: qn_filter_conn allocate (entry) if (associated (chain%last)) then entry%previous => chain%last entry%index = entry%previous%index + 1 previous_state => entry%previous%connected_state_t else entry%index = 1 previous_state => & chain%process_instance%get_connected_state_ptr (chain%selected_term) end if entry%config => decay%config entry%selected_mci = decay%selected_mci entry%selected_term = decay%selected_term current_decay => decay%process_instance%get_isolated_state_ptr & (decay%selected_term) call entry%setup_connected_trace & (current_decay, previous_state%get_trace_int_ptr (), resonant=.true.) if (entry%config%flv%has_decay_helicity ()) then call hel%init (entry%config%flv%get_decay_helicity ()) call qn_filter_conn%init (hel) call entry%setup_connected_matrix & (current_decay, previous_state%get_matrix_int_ptr (), & resonant=.true., qn_filter_conn = qn_filter_conn) call entry%setup_connected_flows & (current_decay, previous_state%get_flows_int_ptr (), & resonant=.true., qn_filter_conn = qn_filter_conn) else call entry%setup_connected_matrix & (current_decay, previous_state%get_matrix_int_ptr (), & resonant=.true.) call entry%setup_connected_flows & (current_decay, previous_state%get_flows_int_ptr (), & resonant=.true.) end if chain%last => entry call chain%build_term_entries (decay%term(decay%selected_term)) end subroutine decay_chain_build_decay_entries @ %def decay_chain_build_decay_entries @ Recursively fill the decay chain with momenta and evaluate the matrix elements. Since all evaluators should have correct source entries at this point, momenta are automatically retrieved from the appropriate process instance. Like we did above for the parent process, factor out the trace for each subsequent decay (the helicity density matrix in the isolated state, which is taken for the convolution). <>= procedure :: evaluate => decay_chain_evaluate <>= subroutine decay_chain_evaluate (chain) class(decay_chain_t), intent(inout) :: chain call evaluate (chain%last) call chain%correlated_trace%receive_momenta () call chain%correlated_trace%evaluate () contains recursive subroutine evaluate (entry) type(decay_chain_entry_t), intent(inout), pointer :: entry if (associated (entry)) then call evaluate (entry%previous) call entry%receive_kinematics () call entry%evaluate_trace () call entry%evaluate_event_data () end if end subroutine evaluate end subroutine decay_chain_evaluate @ %def decay_chain_evaluate @ Return the probability of a decay chain. This is given as the trace of the density matrix with intermediate helicity correlations, normalized by the product of the uncorrelated density matrix traces. This works only if an event has been evaluated and the [[correlated_trace]] evaluator is filled. By definition, this evaluator has only one matrix element, and this must be real. <>= procedure :: get_probability => decay_chain_get_probability <>= function decay_chain_get_probability (chain) result (x) class(decay_chain_t), intent(in) :: chain real(default) :: x x = real (chain%correlated_trace%get_matrix_element (1)) end function decay_chain_get_probability @ %def decay_chain_get_probability @ \subsection{Decay as Event Transform} The [[evt_decay]] object combines decay configuration, decay tree, and chain in a single object, as an implementation of the [[evt]] (event transform) abstract type. The [[var_list]] may be a pointer to the user variable list, which could contain overridden parameters for the decay processes. <>= public :: evt_decay_t <>= type, extends (evt_t) :: evt_decay_t private type(decay_root_config_t) :: decay_root_config type(decay_root_t) :: decay_root type(decay_chain_t) :: decay_chain type(var_list_t), pointer :: var_list => null () contains <> end type evt_decay_t @ %def evt_decay_t @ <>= procedure :: write_name => evt_decay_write_name <>= subroutine evt_decay_write_name (evt, unit) class(evt_decay_t), intent(in) :: evt integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A)") "Event transform: partonic decays" end subroutine evt_decay_write_name @ %def evt_decay_write_name @ Output. We display the currently selected decay tree, which includes configuration data, and the decay chain, i.e., the evaluators. <>= procedure :: write => evt_decay_write <>= subroutine evt_decay_write (evt, unit, verbose, more_verbose, testflag) class(evt_decay_t), intent(in) :: evt integer, intent(in), optional :: unit logical, intent(in), optional :: verbose, more_verbose, testflag logical :: verb, verb2 integer :: u u = given_output_unit (unit) verb = .true.; if (present (verbose)) verb = verbose verb2 = .false.; if (present (more_verbose)) verb2 = more_verbose call write_separator (u, 2) call evt%write_name (u) call write_separator (u, 2) call evt%base_write (u, testflag = testflag) if (associated (evt%var_list)) then call write_separator (u) write (u, "(1x,A)") "Variable list for simulation: & &[associated, not shown]" end if if (verb) then call write_separator (u) call evt%decay_root%write (u) if (verb2) then call evt%decay_chain%write (u) call evt%decay_root%write_process_instances (u, verb) end if else call write_separator (u, 2) end if end subroutine evt_decay_write @ %def evt_decay_write @ Set the pointer to a user variable list. <>= procedure :: set_var_list => evt_decay_set_var_list <>= subroutine evt_decay_set_var_list (evt, var_list) class(evt_decay_t), intent(inout) :: evt type(var_list_t), intent(in), target :: var_list evt%var_list => var_list end subroutine evt_decay_set_var_list @ %def evt_decay_set_var_list @ Connect with a process instance and process. This initializes the decay configuration. The process stack is used to look for process objects that implement daughter decays. When all processes are assigned, configure the decay tree instance, using the decay tree configuration. First obtain the branching ratios, then allocate the decay tree. This is done once for all events. <>= procedure :: connect => evt_decay_connect <>= subroutine evt_decay_connect (evt, process_instance, model, process_stack) class(evt_decay_t), intent(inout), target :: evt type(process_instance_t), intent(in), target :: process_instance class(model_data_t), intent(in), target :: model type(process_stack_t), intent(in), optional :: process_stack call evt%base_connect (process_instance, model) if (associated (evt%var_list)) then call evt%decay_root_config%connect (process_instance%process, & model, process_stack, process_instance, evt%var_list) else call evt%decay_root_config%connect (process_instance%process, & model, process_stack, process_instance) end if call evt%decay_root_config%compute () call evt%decay_root%init (evt%decay_root_config, evt%process_instance) end subroutine evt_decay_connect @ %def evt_decay_connect @ Prepare a new event: Select a decay chain and build the corresponding chain object. <>= procedure :: prepare_new_event => evt_decay_prepare_new_event <>= subroutine evt_decay_prepare_new_event (evt, i_mci, i_term) class(evt_decay_t), intent(inout) :: evt integer, intent(in) :: i_mci, i_term call evt%reset () evt%decay_root%selected_mci = i_mci evt%decay_root%selected_term = i_term call evt%decay_root%select_chain () call evt%decay_chain%build (evt%decay_root) end subroutine evt_decay_prepare_new_event @ %def evt_decay_prepare_new_event @ Generate a weighted event and assign the resulting weight (probability). We use a chain initialized by the preceding subroutine, fill it with momenta and evaluate. <>= procedure :: generate_weighted => evt_decay_generate_weighted <>= subroutine evt_decay_generate_weighted (evt, probability) class(evt_decay_t), intent(inout) :: evt real(default), intent(inout) :: probability call evt%decay_root%generate () if (signal_is_pending ()) return call evt%decay_chain%evaluate () probability = evt%decay_chain%get_probability () end subroutine evt_decay_generate_weighted @ %def evt_decay_generate_weighted @ To create a usable event, we have to transform the interaction into a particle set; this requires factorization for the correlated density matrix, according to the factorization mode. <>= procedure :: make_particle_set => evt_decay_make_particle_set <>= subroutine evt_decay_make_particle_set & (evt, factorization_mode, keep_correlations, r) class(evt_decay_t), intent(inout) :: evt integer, intent(in) :: factorization_mode logical, intent(in) :: keep_correlations real(default), dimension(:), intent(in), optional :: r type(interaction_t), pointer :: int_matrix, int_flows type(decay_chain_entry_t), pointer :: last_entry last_entry => evt%decay_chain%last int_matrix => last_entry%get_matrix_int_ptr () int_flows => last_entry%get_flows_int_ptr () call evt%factorize_interactions (int_matrix, int_flows, & factorization_mode, keep_correlations, r) call evt%tag_incoming () end subroutine evt_decay_make_particle_set @ %def event_decay_make_particle_set @ \subsubsection{Auxiliary} Eliminate numerical noise for the associated process instances. <>= public :: pacify <>= interface pacify module procedure pacify_decay module procedure pacify_decay_gen module procedure pacify_term module procedure pacify_unstable end interface pacify <>= subroutine pacify_decay (evt) class(evt_decay_t), intent(inout) :: evt call pacify_decay_gen (evt%decay_root) end subroutine pacify_decay recursive subroutine pacify_decay_gen (decay) class(decay_gen_t), intent(inout) :: decay if (associated (decay%process_instance)) then call pacify (decay%process_instance) end if if (decay%selected_term > 0) then call pacify_term (decay%term(decay%selected_term)) end if end subroutine pacify_decay_gen recursive subroutine pacify_term (term) class(decay_term_t), intent(inout) :: term integer :: i do i = 1, size (term%particle_out) select type (unstable => term%particle_out(i)%c) type is (unstable_t); call pacify_unstable (unstable) end select end do end subroutine pacify_term recursive subroutine pacify_unstable (unstable) class(unstable_t), intent(inout) :: unstable if (unstable%selected_decay > 0) then call pacify_decay_gen (unstable%decay(unstable%selected_decay)) end if end subroutine pacify_unstable @ %def pacify @ Prepare specific configurations for use in unit tests. <>= procedure :: init_test_case1 procedure :: init_test_case2 <>= subroutine init_test_case1 (unstable, i, flv, integral, relerr, model) class(unstable_config_t), intent(inout) :: unstable integer, intent(in) :: i type(flavor_t), dimension(:,:), intent(in) :: flv real(default), intent(in) :: integral real(default), intent(in) :: relerr class(model_data_t), intent(in), target :: model associate (decay => unstable%decay_config(i)) allocate (decay%term_config (1)) call decay%init_term (1, flv, stable = [.true., .true.], model=model) decay%integral = integral decay%abs_error = integral * relerr end associate end subroutine init_test_case1 subroutine init_test_case2 (unstable, flv1, flv21, flv22, model) class(unstable_config_t), intent(inout) :: unstable type(flavor_t), dimension(:,:), intent(in) :: flv1, flv21, flv22 class(model_data_t), intent(in), target :: model associate (decay => unstable%decay_config(1)) decay%integral = 1.e-3_default decay%abs_error = decay%integral * .01_default allocate (decay%term_config (1)) call decay%init_term (1, flv1, stable = [.false., .true.], model=model) select type (w => decay%term_config(1)%prt(1)%c) type is (unstable_config_t) associate (w_decay => w%decay_config(1)) w_decay%integral = 2._default allocate (w_decay%term_config (1)) call w_decay%init_term (1, flv21, stable = [.true., .true.], & model=model) end associate associate (w_decay => w%decay_config(2)) w_decay%integral = 1._default allocate (w_decay%term_config (1)) call w_decay%init_term (1, flv22, stable = [.true., .true.], & model=model) end associate call w%compute () end select end associate end subroutine init_test_case2 @ %def init_test_case1 @ %def init_test_case2 @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[decays_ut.f90]]>>= <> module decays_ut use unit_tests use decays_uti <> <> <> contains <> end module decays_ut @ %def decays_ut @ <<[[decays_uti.f90]]>>= <> module decays_uti <> <> use os_interface use sm_qcd use model_data use models use state_matrices, only: FM_IGNORE_HELICITY use interactions, only: reset_interaction_counter use flavors use process_libraries use rng_base use mci_base use mci_midpoint use phs_base use phs_single use prc_core use prc_test, only: prc_test_create_library use process, only: process_t use instances, only: process_instance_t use process_stacks use decays use rng_base_ut, only: rng_test_t, rng_test_factory_t <> <> <> contains <> <> end module decays_uti @ %def decays_uti @ API: driver for the unit tests below. <>= public :: decays_test <>= subroutine decays_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine decays_test @ %def decays_test @ \subsubsection{Testbed} As a variation of the [[prepare_test_process]] routine used elsewhere, we define here a routine that creates two processes (scattering $ss\to ss$ and decay $s\to f\bar f$), compiles and integrates them and prepares for event generation. <>= public :: prepare_testbed <>= subroutine prepare_testbed & (lib, process_stack, prefix, os_data, & scattering, decay, decay_rest_frame) type(process_library_t), intent(out), target :: lib type(process_stack_t), intent(out) :: process_stack type(string_t), intent(in) :: prefix type(os_data_t), intent(in) :: os_data logical, intent(in) :: scattering, decay logical, intent(in), optional :: decay_rest_frame type(model_t), target :: model type(model_t), target :: model_copy type(string_t) :: libname, procname1, procname2 type(process_entry_t), pointer :: process type(process_instance_t), allocatable, target :: process_instance class(phs_config_t), allocatable :: phs_config_template type(field_data_t), pointer :: field_data real(default) :: sqrts libname = prefix // "_lib" procname1 = prefix // "_p" procname2 = prefix // "_d" call model%init_test () call model%set_par (var_str ("ff"), 0.4_default) call model%set_par (var_str ("mf"), & model%get_real (var_str ("ff")) * model%get_real (var_str ("ms"))) if (scattering .and. decay) then field_data => model%get_field_ptr (25) call field_data%set (p_is_stable = .false.) end if call prc_test_create_library (libname, lib, & scattering = .true., decay = .true., & procname1 = procname1, procname2 = procname2) call reset_interaction_counter () allocate (phs_single_config_t :: phs_config_template) if (scattering) then call model_copy%init (model%get_name (), & model%get_n_real (), & model%get_n_complex (), & model%get_n_field (), & model%get_n_vtx ()) call model_copy%copy_from (model) allocate (process) call process%init (procname1, lib, os_data, model_copy) call process%setup_test_cores () call process%init_components (phs_config_template) sqrts = 1000 call process%setup_beams_sqrts (sqrts, i_core = 1) call process%configure_phs () call process%setup_mci (dispatch_mci_test_midpoint) call process%setup_terms () allocate (process_instance) call process_instance%init (process%process_t) call process_instance%integrate (1, n_it = 1, n_calls = 100) call process%final_integration (1) call process_instance%final () deallocate (process_instance) call process%prepare_simulation (1) call process_stack%push (process) end if if (decay) then call model_copy%init (model%get_name (), & model%get_n_real (), & model%get_n_complex (), & model%get_n_field (), & model%get_n_vtx ()) call model_copy%copy_from (model) allocate (process) call process%init (procname2, lib, os_data, model_copy) call process%setup_test_cores () call process%init_components (phs_config_template) if (present (decay_rest_frame)) then call process%setup_beams_decay (rest_frame = decay_rest_frame, i_core = 1) else call process%setup_beams_decay (rest_frame = .not. scattering, i_core = 1) end if call process%configure_phs () call process%setup_mci (dispatch_mci_test_midpoint) call process%setup_terms () allocate (process_instance) call process_instance%init (process%process_t) call process_instance%integrate (1, n_it=1, n_calls=100) call process%final_integration (1) call process_instance%final () deallocate (process_instance) call process%prepare_simulation (1) call process_stack%push (process) end if call model%final () call model_copy%final () end subroutine prepare_testbed @ %def prepare_testbed @ MCI record prepared for midpoint integrator. <>= subroutine dispatch_mci_test_midpoint (mci, var_list, process_id, is_nlo) use variables, only: var_list_t class(mci_t), allocatable, intent(out) :: mci type(var_list_t), intent(in) :: var_list type(string_t), intent(in) :: process_id logical, intent(in), optional :: is_nlo allocate (mci_midpoint_t :: mci) end subroutine dispatch_mci_test_midpoint @ %def dispatch_mci_test_midpoint @ \subsubsection{Simple decay configuration} We define a branching configuration with two decay modes. We set the integral values by hand, so we do not need to evaluate processes, yet. <>= call test (decays_1, "decays_1", & "branching and decay configuration", & u, results) <>= public :: decays_1 <>= subroutine decays_1 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(model_data_t), target :: model type(flavor_t) :: flv_h type(flavor_t), dimension(2,1) :: flv_hbb, flv_hgg type(unstable_config_t), allocatable :: unstable write (u, "(A)") "* Test output: decays_1" write (u, "(A)") "* Purpose: Set up branching and decay configuration" write (u, "(A)") write (u, "(A)") "* Initialize environment" write (u, "(A)") call os_data%init () call model%init_sm_test () call flv_h%init (25, model) call flv_hbb(:,1)%init ([5, -5], model) call flv_hgg(:,1)%init ([22, 22], model) write (u, "(A)") "* Set up branching and decay" write (u, "(A)") allocate (unstable) call unstable%init (flv_h) call unstable%init_decays ([var_str ("h_bb"), var_str ("h_gg")], model) call unstable%init_test_case1 & (1, flv_hbb, 1.234e-3_default, .02_default, model) call unstable%init_test_case1 & (2, flv_hgg, 3.085e-4_default, .08_default, model) call unstable%compute () call unstable%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call unstable%final () call model%final () write (u, "(A)") write (u, "(A)") "* Test output end: decays_1" end subroutine decays_1 @ %def decays_1 @ \subsubsection{Cascade decay configuration} We define a branching configuration with one decay, which is followed by another branching. <>= call test (decays_2, "decays_2", & "cascade decay configuration", & u, results) <>= public :: decays_2 <>= subroutine decays_2 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(model_data_t), target :: model type(flavor_t) :: flv_h, flv_wp, flv_wm type(flavor_t), dimension(2,1) :: flv_hww, flv_wud, flv_wen type(unstable_config_t), allocatable :: unstable write (u, "(A)") "* Test output: decays_2" write (u, "(A)") "* Purpose: Set up cascade branching" write (u, "(A)") write (u, "(A)") "* Initialize environment" write (u, "(A)") call os_data%init () call model%init_sm_test () call model%set_unstable (25, [var_str ("h_ww")]) call model%set_unstable (24, [var_str ("w_ud"), var_str ("w_en")]) call flv_h%init (25, model) call flv_hww(:,1)%init ([24, -24], model) call flv_wp%init (24, model) call flv_wm%init (-24, model) call flv_wud(:,1)%init ([2, -1], model) call flv_wen(:,1)%init ([-11, 12], model) write (u, "(A)") "* Set up branching and decay" write (u, "(A)") allocate (unstable) call unstable%init (flv_h, set_decays=.true., model=model) call unstable%init_test_case2 (flv_hww, flv_wud, flv_wen, model) call unstable%compute () call unstable%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call unstable%final () call model%final () write (u, "(A)") write (u, "(A)") "* Test output end: decays_2" end subroutine decays_2 @ %def decays_2 @ \subsubsection{Decay and Process Object} We define a branching configuration with one decay and connect this with an actual process object. <>= call test (decays_3, "decays_3", & "associate process", & u, results) <>= public :: decays_3 <>= subroutine decays_3 (u) integer, intent(in) :: u type(os_data_t) :: os_data class(model_data_t), pointer :: model type(process_library_t), target :: lib type(string_t) :: prefix type(string_t) :: procname2 type(process_stack_t) :: process_stack type(process_t), pointer :: process type(unstable_config_t), allocatable :: unstable type(flavor_t) :: flv write (u, "(A)") "* Test output: decays_3" write (u, "(A)") "* Purpose: Connect a decay configuration & &with a process" write (u, "(A)") write (u, "(A)") "* Initialize environment and integrate process" write (u, "(A)") call os_data%init () prefix = "decays_3" call prepare_testbed & (lib, process_stack, prefix, os_data, & scattering=.false., decay=.true., decay_rest_frame=.false.) procname2 = prefix // "_d" process => process_stack%get_process_ptr (procname2) model => process%get_model_ptr () call process%write (.false., u) write (u, "(A)") write (u, "(A)") "* Set up branching and decay" write (u, "(A)") call flv%init (25, model) allocate (unstable) call unstable%init (flv) call unstable%init_decays ([procname2], model) write (u, "(A)") "* Connect decay with process object" write (u, "(A)") call unstable%connect_decay (1, process, model) call unstable%compute () call unstable%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call unstable%final () call process_stack%final () write (u, "(A)") write (u, "(A)") "* Test output end: decays_3" end subroutine decays_3 @ %def decays_3 @ \subsubsection{Decay and Process Object} Building upon the previous test, we set up a decay instance and generate a decay event. <>= call test (decays_4, "decays_4", & "decay instance", & u, results) <>= public :: decays_4 <>= subroutine decays_4 (u) integer, intent(in) :: u type(os_data_t) :: os_data class(model_data_t), pointer :: model type(process_library_t), target :: lib type(string_t) :: prefix, procname2 class(rng_t), allocatable :: rng type(process_stack_t) :: process_stack type(process_t), pointer :: process type(unstable_config_t), allocatable, target :: unstable type(flavor_t) :: flv type(unstable_t), allocatable :: instance write (u, "(A)") "* Test output: decays_4" write (u, "(A)") "* Purpose: Create a decay process and evaluate & &an instance" write (u, "(A)") write (u, "(A)") "* Initialize environment, process, & &and decay configuration" write (u, "(A)") call os_data%init () prefix = "decays_4" call prepare_testbed & (lib, process_stack, prefix, os_data, & scattering=.false., decay=.true., decay_rest_frame = .false.) procname2 = prefix // "_d" process => process_stack%get_process_ptr (procname2) model => process%get_model_ptr () call flv%init (25, model) allocate (unstable) call unstable%init (flv) call unstable%init_decays ([procname2], model) call model%set_unstable (25, [procname2]) call unstable%connect_decay (1, process, model) call unstable%compute () allocate (rng_test_t :: rng) allocate (instance) call instance%init (unstable) call instance%import_rng (rng) call instance%select_chain () call instance%generate () call instance%write (u) write (u, *) call instance%write_process_instances (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call instance%final () call process_stack%final () call unstable%final () write (u, "(A)") write (u, "(A)") "* Test output end: decays_4" end subroutine decays_4 @ %def decays_4 @ \subsubsection{Decay with Parent Process} We define a scattering process $ss\to ss$ and subsequent decays $s\to f\bar f$. <>= call test (decays_5, "decays_5", & "parent process and decay", & u, results) <>= public :: decays_5 <>= subroutine decays_5 (u) integer, intent(in) :: u type(os_data_t) :: os_data class(model_data_t), pointer :: model type(process_library_t), target :: lib type(string_t) :: prefix, procname1, procname2 type(process_stack_t) :: process_stack type(process_t), pointer :: process type(process_instance_t), allocatable, target :: process_instance type(decay_root_config_t), target :: decay_root_config type(decay_root_t) :: decay_root type(decay_chain_t) :: decay_chain write (u, "(A)") "* Test output: decays_5" write (u, "(A)") "* Purpose: Handle a process with subsequent decays" write (u, "(A)") write (u, "(A)") "* Initialize environment and parent process" write (u, "(A)") call os_data%init () prefix = "decays_5" procname1 = prefix // "_p" procname2 = prefix // "_d" call prepare_testbed & (lib, process_stack, prefix, os_data, & scattering=.true., decay=.true.) write (u, "(A)") "* Initialize decay process" write (u, "(A)") process => process_stack%get_process_ptr (procname1) model => process%get_model_ptr () call model%set_unstable (25, [procname2]) write (u, "(A)") "* Initialize decay tree configuration" write (u, "(A)") call decay_root_config%connect (process, model, process_stack) call decay_root_config%compute () call decay_root_config%write (u) write (u, "(A)") write (u, "(A)") "* Initialize decay tree" allocate (process_instance) call process_instance%init (process) call process_instance%setup_event_data () call process_instance%init_simulation (1) call decay_root%init (decay_root_config, process_instance) write (u, "(A)") write (u, "(A)") "* Select decay chain" write (u, "(A)") call decay_root%set_mci (1) !!! Not yet implemented; there is only one term anyway: ! call process_instance%select_i_term (decay_root%selected_term) call decay_root%set_term (1) call decay_root%select_chain () call decay_chain%build (decay_root) call decay_root%write (u) write (u, "(A)") write (u, "(A)") "* Generate event" write (u, "(A)") call process_instance%generate_unweighted_event (decay_root%get_mci ()) call process_instance%evaluate_event_data () call decay_root%generate () call pacify (decay_root) write (u, "(A)") "* Process instances" write (u, "(A)") call decay_root%write_process_instances (u) write (u, "(A)") write (u, "(A)") "* Generate decay chain" write (u, "(A)") call decay_chain%evaluate () call decay_chain%write (u) write (u, *) write (u, "(A,ES19.12)") "chain probability =", & decay_chain%get_probability () write (u, "(A)") write (u, "(A)") "* Cleanup" call decay_chain%final () call decay_root%final () call decay_root_config%final () call process_instance%final () deallocate (process_instance) call process_stack%final () write (u, "(A)") write (u, "(A)") "* Test output end: decays_5" end subroutine decays_5 @ %def decays_5 @ \subsubsection{Decay as Event Transform} Again, we define a scattering process $ss\to ss$ and subsequent decays $s\to f\bar f$. <>= call test (decays_6, "decays_6", & "evt_decay object", & u, results) <>= public :: decays_6 <>= subroutine decays_6 (u) integer, intent(in) :: u type(os_data_t) :: os_data class(model_data_t), pointer :: model type(process_library_t), target :: lib type(string_t) :: prefix, procname1, procname2 type(process_stack_t) :: process_stack type(process_t), pointer :: process type(process_instance_t), allocatable, target :: process_instance type(evt_decay_t), target :: evt_decay integer :: factorization_mode logical :: keep_correlations write (u, "(A)") "* Test output: decays_6" write (u, "(A)") "* Purpose: Handle a process with subsequent decays" write (u, "(A)") write (u, "(A)") "* Initialize environment and parent process" write (u, "(A)") call os_data%init () prefix = "decays_6" procname1 = prefix // "_p" procname2 = prefix // "_d" call prepare_testbed & (lib, process_stack, prefix, os_data, & scattering=.true., decay=.true.) write (u, "(A)") "* Initialize decay process" process => process_stack%get_process_ptr (procname1) model => process%get_model_ptr () call model%set_unstable (25, [procname2]) allocate (process_instance) call process_instance%init (process) call process_instance%setup_event_data () call process_instance%init_simulation (1) write (u, "(A)") write (u, "(A)") "* Initialize decay object" call evt_decay%connect (process_instance, model, process_stack) write (u, "(A)") write (u, "(A)") "* Generate scattering event" call process_instance%generate_unweighted_event (1) call process_instance%evaluate_event_data () write (u, "(A)") write (u, "(A)") "* Select decay chain and generate event" write (u, "(A)") call evt_decay%prepare_new_event (1, 1) call evt_decay%generate_unweighted () factorization_mode = FM_IGNORE_HELICITY keep_correlations = .false. call evt_decay%make_particle_set (factorization_mode, keep_correlations) call evt_decay%write (u, verbose = .true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call evt_decay%final () call process_instance%final () deallocate (process_instance) call process_stack%final () write (u, "(A)") write (u, "(A)") "* Test output end: decays_6" end subroutine decays_6 @ %def decays_6 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Tau decays} <<[[tau_decays.f90]]>>= <> module tau_decays <> use io_units use format_utils, only: write_separator use sm_qcd use model_data use models use event_transforms <> <> <> contains <> end module tau_decays @ %def tau_decays \subsection{Tau Decays Event Transform} This is the type for the tau decay event transform. <>= public :: evt_tau_decays_t <>= type, extends (evt_t) :: evt_tau_decays_t type(model_t), pointer :: model_hadrons => null() type(qcd_t) :: qcd contains <> end type evt_tau_decays_t @ %def evt_tau_decays_t <>= procedure :: write_name => evt_tau_decays_write_name <>= subroutine evt_tau_decays_write_name (evt, unit) class(evt_tau_decays_t), intent(in) :: evt integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A)") "Event transform: tau decays" end subroutine evt_tau_decays_write_name @ %def evt_tau_decays_write_name @ Output. <>= procedure :: write => evt_tau_decays_write <>= subroutine evt_tau_decays_write (evt, unit, verbose, more_verbose, testflag) class(evt_tau_decays_t), intent(in) :: evt integer, intent(in), optional :: unit logical, intent(in), optional :: verbose, more_verbose, testflag integer :: u u = given_output_unit (unit) call write_separator (u, 2) call evt%write_name (u) call write_separator (u) call evt%base_write (u, testflag = testflag, show_set = .false.) if (evt%particle_set_exists) & call evt%particle_set%write & (u, summary = .true., compressed = .true., testflag = testflag) call write_separator (u) end subroutine evt_tau_decays_write @ %def evt_tau_decays_write @ Here we take the particle set from the previous event transform and apply the tau decays. What probability should be given back, the product of branching ratios of the corresponding tau decays? <>= procedure :: generate_weighted => evt_tau_decays_generate_weighted <>= subroutine evt_tau_decays_generate_weighted (evt, probability) class(evt_tau_decays_t), intent(inout) :: evt real(default), intent(inout) :: probability logical :: valid evt%particle_set = evt%previous%particle_set !!! To be checked or expanded probability = 1 valid = .true. evt%particle_set_exists = valid end subroutine evt_tau_decays_generate_weighted @ %def evt_tau_decays_generate_weighted @ The factorization parameters are irrelevant. <>= procedure :: make_particle_set => evt_tau_decays_make_particle_set <>= subroutine evt_tau_decays_make_particle_set & (evt, factorization_mode, keep_correlations, r) class(evt_tau_decays_t), intent(inout) :: evt integer, intent(in) :: factorization_mode logical, intent(in) :: keep_correlations real(default), dimension(:), intent(in), optional :: r logical :: valid !!! to be checked and expanded valid = .true. evt%particle_set_exists = evt%particle_set_exists .and. valid end subroutine evt_tau_decays_make_particle_set @ %def event_tau_decays_make_particle_set @ <>= procedure :: prepare_new_event => evt_tau_decays_prepare_new_event <>= subroutine evt_tau_decays_prepare_new_event (evt, i_mci, i_term) class(evt_tau_decays_t), intent(inout) :: evt integer, intent(in) :: i_mci, i_term call evt%reset () end subroutine evt_tau_decays_prepare_new_event @ %def evt_tau_decays_prepare_new_event @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Shower} We might use matrix elements of LO and NLO to increase the accuracy of the shower in the sense of matching as well as merging. <<[[shower.f90]]>>= <> module shower <> <> <> use io_units use format_utils, only: write_separator use system_defs, only: LF use os_interface use diagnostics use lorentz use pdf use subevents, only: PRT_BEAM_REMNANT, PRT_INCOMING, PRT_OUTGOING use shower_base use matching_base use powheg_matching, only: powheg_matching_t use sm_qcd use model_data use rng_base use event_transforms use models use hep_common use process, only: process_t use instances, only: process_instance_t use process_stacks <> <> <> <> contains <> end module shower @ %def shower @ \subsection{Configuration Parameters} [[POWHEG_TESTING]] allows to disable the parton shower for validation and testing of the POWHEG procedure. <>= logical, parameter :: POWHEG_TESTING = .false. @ %def POWHEG_TESTING @ \subsection{Event Transform} The event transforms can do more than mere showering. Especially, it may reweight showered events to fixed-order matrix elements. The [[model_hadrons]] is supposed to be the SM variant that contains all hadrons that can be generated in the shower. <>= public :: evt_shower_t <>= type, extends (evt_t) :: evt_shower_t class(shower_base_t), allocatable :: shower class(matching_t), allocatable :: matching type(model_t), pointer :: model_hadrons => null () type(qcd_t) :: qcd type(pdf_data_t) :: pdf_data type(os_data_t) :: os_data logical :: is_first_event contains <> end type evt_shower_t @ %def evt_shower_t @ <>= procedure :: write_name => evt_shower_write_name <>= subroutine evt_shower_write_name (evt, unit) class(evt_shower_t), intent(in) :: evt integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A)") "Event transform: shower" end subroutine evt_shower_write_name @ %def evt_shower_write_name @ Output. <>= procedure :: write => evt_shower_write <>= subroutine evt_shower_write (evt, unit, verbose, more_verbose, testflag) class(evt_shower_t), intent(in) :: evt integer, intent(in), optional :: unit logical, intent(in), optional :: verbose, more_verbose, testflag integer :: u u = given_output_unit (unit) call write_separator (u, 2) call evt%write_name (u) call write_separator (u) call evt%base_write (u, testflag = testflag, show_set = .false.) if (evt%particle_set_exists) call evt%particle_set%write & (u, summary = .true., compressed = .true., testflag = testflag) call write_separator (u) call evt%shower%settings%write (u) end subroutine evt_shower_write @ %def evt_shower_write <>= procedure :: connect => evt_shower_connect <>= subroutine evt_shower_connect & (evt, process_instance, model, process_stack) class(evt_shower_t), intent(inout), target :: evt type(process_instance_t), intent(in), target :: process_instance class(model_data_t), intent(in), target :: model type(process_stack_t), intent(in), optional :: process_stack call evt%base_connect (process_instance, model, process_stack) call evt%make_rng (evt%process) if (allocated (evt%matching)) then call evt%matching%connect (process_instance, model, evt%shower) end if end subroutine evt_shower_connect @ %def evt_shower_connect @ Initialize the event transformation. This will be executed once during dispatching. The [[model_hadrons]] is supposed to be the SM variant that contains all hadrons that may be generated in the shower. <>= procedure :: init => evt_shower_init <>= subroutine evt_shower_init (evt, model_hadrons, os_data) class(evt_shower_t), intent(out) :: evt type(model_t), intent(in), target :: model_hadrons type(os_data_t), intent(in) :: os_data evt%os_data = os_data evt%model_hadrons => model_hadrons evt%is_first_event = .true. end subroutine evt_shower_init @ %def evt_shower_init @ Create RNG instances, spawned by the process object. <>= procedure :: make_rng => evt_shower_make_rng <>= subroutine evt_shower_make_rng (evt, process) class(evt_shower_t), intent(inout) :: evt type(process_t), intent(inout) :: process class(rng_t), allocatable :: rng call process%make_rng (rng) call evt%shower%import_rng (rng) if (allocated (evt%matching)) then call process%make_rng (rng) call evt%matching%import_rng (rng) end if end subroutine evt_shower_make_rng @ %def evt_shower_make_rng @ Things we want to do for a new event before the whole event transformation chain is evaluated. <>= procedure :: prepare_new_event => evt_shower_prepare_new_event <>= subroutine evt_shower_prepare_new_event (evt, i_mci, i_term) class(evt_shower_t), intent(inout) :: evt integer, intent(in) :: i_mci, i_term real(default) :: fac_scale, alpha_s fac_scale = evt%process_instance%get_fac_scale (i_term) alpha_s = evt%process_instance%get_alpha_s (i_term) call evt%reset () call evt%shower%prepare_new_event (fac_scale, alpha_s) end subroutine evt_shower_prepare_new_event @ %def evt_shower_prepare_new_event @ <>= procedure :: first_event => evt_shower_first_event <>= subroutine evt_shower_first_event (evt) class(evt_shower_t), intent(inout) :: evt double precision :: pdftest if (debug_on) call msg_debug (D_TRANSFORMS, "evt_shower_first_event") associate (settings => evt%shower%settings) settings%hadron_collision = .false. !!! !!! !!! Workaround for PGF90 v16.1 !!! if (all (evt%particle_set%prt(1:2)%flv%get_pdg_abs () <= 39)) then if (evt%particle_set%prt(1)%flv%get_pdg_abs () <= 39 .and. & evt%particle_set%prt(2)%flv%get_pdg_abs () <= 39) then settings%hadron_collision = .false. !!! else if (all (evt%particle_set%prt(1:2)%flv%get_pdg_abs () >= 100)) then else if (evt%particle_set%prt(1)%flv%get_pdg_abs () >= 100 .and. & evt%particle_set%prt(2)%flv%get_pdg_abs () >= 100) then settings%hadron_collision = .true. else call msg_fatal ("evt_shower didn't recognize beams setup") end if if (debug_on) call msg_debug (D_TRANSFORMS, "hadron_collision", settings%hadron_collision) if (allocated (evt%matching)) then evt%matching%is_hadron_collision = settings%hadron_collision call evt%matching%first_event () end if if (.not. settings%hadron_collision .and. settings%isr_active) then call msg_fatal ("?ps_isr_active is only intended for hadron-collisions") end if if (evt%pdf_data%type == STRF_LHAPDF5) then if (settings%isr_active .and. settings%hadron_collision) then call GetQ2max (0, pdftest) if (pdftest < epsilon (pdftest)) then call msg_bug ("ISR QCD shower enabled, but LHAPDF not " // & "initialized," // LF // " aborting simulation") return end if end if else if (evt%pdf_data%type == STRF_PDF_BUILTIN .and. & settings%method == PS_PYTHIA6) then call msg_fatal ("Builtin PDFs cannot be used for PYTHIA showers," & // LF // " aborting simulation") return end if end associate evt%is_first_event = .false. end subroutine evt_shower_first_event @ %def evt_shower_first_event @ Here we take the particle set from the previous event transform (assuming that there is always one) and apply the shower algorithm. The result is stored in the event transform of the current object. We always return a probability of unity as we don't have the analytic weight of the combination of shower, MLM matching and hadronization. A subdivision into multiple event transformations is under construction. Invalid or vetoed events have to be discarded by the caller which is why we mark the particle set as invalid. This procedure directly takes the (MLM) matching into account. <>= procedure :: generate_weighted => evt_shower_generate_weighted <>= subroutine evt_shower_generate_weighted (evt, probability) class(evt_shower_t), intent(inout) :: evt real(default), intent(inout) :: probability logical :: valid, vetoed if (debug_on) call msg_debug (D_TRANSFORMS, "evt_shower_generate_weighted") if (signal_is_pending ()) return evt%particle_set = evt%previous%particle_set valid = .true.; vetoed = .false. if (evt%is_first_event) call evt%first_event () call evt%shower%import_particle_set (evt%particle_set) if (allocated (evt%matching)) then call evt%matching%before_shower (evt%particle_set, vetoed) if (msg_level(D_TRANSFORMS) >= DEBUG) then if (debug_on) call msg_debug (D_TRANSFORMS, "Matching before generate emissions") call evt%matching%write () end if end if if (.not. (vetoed .or. POWHEG_TESTING)) then if (evt%shower%settings%method == PS_PYTHIA6 .or. & evt%shower%settings%hadronization_active) then call assure_heprup (evt%particle_set) end if call evt%shower%generate_emissions (valid) end if probability = 1 evt%particle_set_exists = valid .and. .not. vetoed end subroutine evt_shower_generate_weighted @ %def evt_shower_generate_weighted @ Here, we fill the particle set with the partons from the shower. The factorization parameters are irrelevant. We make a sanity check that the initial energy lands either in the outgoing particles or add to the beam remnant. <>= procedure :: make_particle_set => evt_shower_make_particle_set <>= subroutine evt_shower_make_particle_set & (evt, factorization_mode, keep_correlations, r) class(evt_shower_t), intent(inout) :: evt integer, intent(in) :: factorization_mode logical, intent(in) :: keep_correlations real(default), dimension(:), intent(in), optional :: r type(vector4_t) :: sum_vec_in, sum_vec_out, sum_vec_beamrem, & sum_vec_beamrem_before logical :: vetoed, sane if (evt%particle_set_exists) then vetoed = .false. sum_vec_beamrem_before = sum (evt%particle_set%prt%p, & mask=evt%particle_set%prt%get_status () == PRT_BEAM_REMNANT) call evt%shower%make_particle_set (evt%particle_set, & evt%model, evt%model_hadrons) if (allocated (evt%matching)) then call evt%matching%after_shower (evt%particle_set, vetoed) end if if (debug_active (D_TRANSFORMS)) then call msg_debug (D_TRANSFORMS, & "Shower: obtained particle set after shower + matching") call evt%particle_set%write (summary = .true., compressed = .true.) end if sum_vec_in = sum (evt%particle_set%prt%p, & mask=evt%particle_set%prt%get_status () == PRT_INCOMING) sum_vec_out = sum (evt%particle_set%prt%p, & mask=evt%particle_set%prt%get_status () == PRT_OUTGOING) sum_vec_beamrem = sum (evt%particle_set%prt%p, & mask=evt%particle_set%prt%get_status () == PRT_BEAM_REMNANT) sum_vec_beamrem = sum_vec_beamrem - sum_vec_beamrem_before sane = abs(sum_vec_out%p(0) - sum_vec_in%p(0)) < & sum_vec_in%p(0) / 10 .or. & abs((sum_vec_out%p(0) + sum_vec_beamrem%p(0)) - sum_vec_in%p(0)) < & sum_vec_in%p(0) / 10 sane = .true. evt%particle_set_exists = .not. vetoed .and. sane end if end subroutine evt_shower_make_particle_set @ %def event_shower_make_particle_set @ <>= procedure :: contains_powheg_matching => evt_shower_contains_powheg_matching <>= function evt_shower_contains_powheg_matching (evt) result (val) logical :: val class(evt_shower_t), intent(in) :: evt val = .false. if (allocated (evt%matching)) & val = evt%matching%get_method () == "POWHEG" end function evt_shower_contains_powheg_matching @ %def evt_shower_contains_powheg_matching @ <>= procedure :: disable_powheg_matching => evt_shower_disable_powheg_matching <>= subroutine evt_shower_disable_powheg_matching (evt) class(evt_shower_t), intent(inout) :: evt select type (matching => evt%matching) type is (powheg_matching_t) matching%active = .false. class default call msg_fatal ("Trying to disable powheg but no powheg matching is allocated!") end select end subroutine evt_shower_disable_powheg_matching @ %def evt_shower_disable_powheg_matching @ <>= procedure :: enable_powheg_matching => evt_shower_enable_powheg_matching <>= subroutine evt_shower_enable_powheg_matching (evt) class(evt_shower_t), intent(inout) :: evt select type (matching => evt%matching) type is (powheg_matching_t) matching%active = .true. class default call msg_fatal ("Trying to enable powheg but no powheg matching is allocated!") end select end subroutine evt_shower_enable_powheg_matching @ %def evt_shower_enable_powheg_matching @ <>= procedure :: final => evt_shower_final <>= subroutine evt_shower_final (evt) class(evt_shower_t), intent(inout) :: evt call evt%base_final () if (allocated (evt%matching)) call evt%matching%final () end subroutine evt_shower_final @ %def evt_shower_final @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[shower_ut.f90]]>>= <> module shower_ut use unit_tests use shower_uti <> <> contains <> end module shower_ut @ %def shower_ut @ <<[[shower_uti.f90]]>>= <> module shower_uti <> <> use format_utils, only: write_separator use os_interface use sm_qcd use physics_defs, only: BORN use model_data use models use state_matrices, only: FM_IGNORE_HELICITY use process_libraries use rng_base use rng_tao use dispatch_rng, only: dispatch_rng_factory_fallback use mci_base use mci_midpoint use phs_base use phs_single use prc_core_def, only: prc_core_def_t use prc_core use prc_omega use variables use event_transforms use tauola_interface !NODEP! use process, only: process_t use instances, only: process_instance_t use pdf use shower_base use shower_core use dispatch_rng_ut, only: dispatch_rng_factory_tao use shower <> <> contains <> end module shower_uti @ %def shower_uti @ API: driver for the unit tests below. <>= public :: shower_test <>= subroutine shower_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine shower_test @ %def shower_test @ \subsubsection{Testbed} This sequence sets up a two-jet process, ready for generating events. <>= <> @ <>= subroutine setup_testbed & (prefix, os_data, lib, model_list, process, process_instance) type(string_t), intent(in) :: prefix type(os_data_t), intent(out) :: os_data type(process_library_t), intent(out), target :: lib type(model_list_t), intent(out) :: model_list type(model_t), pointer :: model type(model_t), pointer :: model_tmp type(process_t), target, intent(out) :: process type(process_instance_t), target, intent(out) :: process_instance type(var_list_t), pointer :: model_vars type(string_t) :: model_name, libname, procname type(process_def_entry_t), pointer :: entry type(string_t), dimension(:), allocatable :: prt_in, prt_out class(prc_core_t), allocatable :: core_template class(phs_config_t), allocatable :: phs_config_template real(default) :: sqrts model_name = "SM" libname = prefix // "_lib" procname = prefix // "p" call os_data%init () dispatch_rng_factory_fallback => dispatch_rng_factory_tao allocate (model_tmp) call model_list%read_model (model_name, model_name // ".mdl", & os_data, model_tmp) model_vars => model_tmp%get_var_list_ptr () call model_vars%set_real (var_str ("me"), 0._default, & is_known = .true.) model => model_tmp call lib%init (libname) allocate (prt_in (2), source = [var_str ("e-"), var_str ("e+")]) allocate (prt_out (2), source = [var_str ("d"), var_str ("dbar")]) allocate (entry) call entry%init (procname, model, n_in = 2, n_components = 1) call omega_make_process_component (entry, 1, & model_name, prt_in, prt_out, & report_progress=.true.) call lib%append (entry) call lib%configure (os_data) call lib%write_makefile (os_data, force = .true., verbose = .false.) call lib%clean (os_data, distclean = .false.) call lib%write_driver (force = .true.) call lib%load (os_data) call process%init (procname, lib, os_data, model) allocate (prc_omega_t :: core_template) allocate (phs_single_config_t :: phs_config_template) call process%setup_cores (dispatch_core_omega_test) call process%init_components (phs_config_template) sqrts = 1000 call process%setup_beams_sqrts (sqrts, i_core = 1) call process%configure_phs () call process%setup_mci (dispatch_mci_test_midpoint) call process%setup_terms () call process_instance%init (process) call process_instance%integrate (1, 1, 1000) call process%final_integration (1) call process_instance%setup_event_data (i_core = 1) call process_instance%init_simulation (1) call process_instance%generate_weighted_event (1) call process_instance%evaluate_event_data () end subroutine setup_testbed @ %def setup_testbed @ A minimal dispatcher version that allocates the core object for testing. <>= subroutine dispatch_core_omega_test (core, core_def, model, & helicity_selection, qcd, use_color_factors, has_beam_pol) class(prc_core_t), allocatable, intent(inout) :: core class(prc_core_def_t), intent(in) :: core_def class(model_data_t), intent(in), target, optional :: model type(helicity_selection_t), intent(in), optional :: helicity_selection type(qcd_t), intent(in), optional :: qcd logical, intent(in), optional :: use_color_factors logical, intent(in), optional :: has_beam_pol allocate (prc_omega_t :: core) select type (core) type is (prc_omega_t) call core%set_parameters (model) end select end subroutine dispatch_core_omega_test @ %def dispatch_core_omega_test @ MCI record prepared for midpoint integrator. <>= subroutine dispatch_mci_test_midpoint (mci, var_list, process_id, is_nlo) use variables, only: var_list_t class(mci_t), allocatable, intent(out) :: mci type(var_list_t), intent(in) :: var_list type(string_t), intent(in) :: process_id logical, intent(in), optional :: is_nlo allocate (mci_midpoint_t :: mci) end subroutine dispatch_mci_test_midpoint @ %def dispatch_mci_test_midpoint @ \subsubsection{Trivial Test} We generate a two-jet event and shower it using default settings, i.e. in disabled mode. <>= call test (shower_1, "shower_1", & "disabled shower", & u, results) <>= public :: shower_1 <>= subroutine shower_1 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(process_library_t), target :: lib type(model_list_t) :: model_list class(model_data_t), pointer :: model type(model_t), pointer :: model_hadrons type(process_t), target :: process type(process_instance_t), target :: process_instance type(pdf_data_t) :: pdf_data integer :: factorization_mode logical :: keep_correlations class(evt_t), allocatable, target :: evt_trivial class(evt_t), allocatable, target :: evt_shower type(shower_settings_t) :: settings type(taudec_settings_t) :: taudec_settings write (u, "(A)") "* Test output: shower_1" write (u, "(A)") "* Purpose: Two-jet event with disabled shower" write (u, "(A)") write (u, "(A)") "* Initialize environment" write (u, "(A)") call syntax_model_file_init () call os_data%init () call model_list%read_model & (var_str ("SM_hadrons"), var_str ("SM_hadrons.mdl"), & os_data, model_hadrons) call setup_testbed (var_str ("shower_1"), & os_data, lib, model_list, process, process_instance) write (u, "(A)") "* Set up trivial transform" write (u, "(A)") allocate (evt_trivial_t :: evt_trivial) model => process%get_model_ptr () call evt_trivial%connect (process_instance, model) call evt_trivial%prepare_new_event (1, 1) call evt_trivial%generate_unweighted () factorization_mode = FM_IGNORE_HELICITY keep_correlations = .false. call evt_trivial%make_particle_set (factorization_mode, keep_correlations) select type (evt_trivial) type is (evt_trivial_t) call evt_trivial%write (u) call write_separator (u, 2) end select write (u, "(A)") write (u, "(A)") "* Set up shower event transform" write (u, "(A)") allocate (evt_shower_t :: evt_shower) select type (evt_shower) type is (evt_shower_t) call evt_shower%init (model_hadrons, os_data) allocate (shower_t :: evt_shower%shower) call evt_shower%shower%init (settings, taudec_settings, pdf_data, os_data) call evt_shower%connect (process_instance, model) end select evt_trivial%next => evt_shower evt_shower%previous => evt_trivial call evt_shower%prepare_new_event (1, 1) call evt_shower%generate_unweighted () call evt_shower%make_particle_set (factorization_mode, keep_correlations) select type (evt_shower) type is (evt_shower_t) call evt_shower%write (u) call write_separator (u, 2) end select write (u, "(A)") write (u, "(A)") "* Cleanup" call evt_shower%final () call evt_trivial%final () call process_instance%final () call process%final () call lib%final () call model_hadrons%final () deallocate (model_hadrons) call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: shower_1" end subroutine shower_1 @ %def shower_1 @ \subsubsection{FSR Shower} We generate a two-jet event and shower it with the Whizard FSR shower. <>= call test (shower_2, "shower_2", & "final-state shower", & u, results) <>= public :: shower_2 <>= subroutine shower_2 (u) integer, intent(in) :: u type(os_data_t) :: os_data type(process_library_t), target :: lib type(model_list_t) :: model_list type(model_t), pointer :: model_hadrons class(model_data_t), pointer :: model type(process_t), target :: process type(process_instance_t), target :: process_instance integer :: factorization_mode logical :: keep_correlations type(pdf_data_t) :: pdf_data class(evt_t), allocatable, target :: evt_trivial class(evt_t), allocatable, target :: evt_shower type(shower_settings_t) :: settings type(taudec_settings_t) :: taudec_settings write (u, "(A)") "* Test output: shower_2" write (u, "(A)") "* Purpose: Two-jet event with FSR shower" write (u, "(A)") write (u, "(A)") "* Initialize environment" write (u, "(A)") call syntax_model_file_init () call os_data%init () call model_list%read_model & (var_str ("SM_hadrons"), var_str ("SM_hadrons.mdl"), & os_data, model_hadrons) call setup_testbed (var_str ("shower_2"), & os_data, lib, model_list, process, process_instance) model => process%get_model_ptr () write (u, "(A)") "* Set up trivial transform" write (u, "(A)") allocate (evt_trivial_t :: evt_trivial) call evt_trivial%connect (process_instance, model) call evt_trivial%prepare_new_event (1, 1) call evt_trivial%generate_unweighted () factorization_mode = FM_IGNORE_HELICITY keep_correlations = .false. call evt_trivial%make_particle_set (factorization_mode, keep_correlations) select type (evt_trivial) type is (evt_trivial_t) call evt_trivial%write (u) call write_separator (u, 2) end select write (u, "(A)") write (u, "(A)") "* Set up shower event transform" write (u, "(A)") settings%fsr_active = .true. allocate (evt_shower_t :: evt_shower) select type (evt_shower) type is (evt_shower_t) call evt_shower%init (model_hadrons, os_data) allocate (shower_t :: evt_shower%shower) call evt_shower%shower%init (settings, taudec_settings, pdf_data, os_data) call evt_shower%connect (process_instance, model) end select evt_trivial%next => evt_shower evt_shower%previous => evt_trivial call evt_shower%prepare_new_event (1, 1) call evt_shower%generate_unweighted () call evt_shower%make_particle_set (factorization_mode, keep_correlations) select type (evt_shower) type is (evt_shower_t) call evt_shower%write (u, testflag = .true.) call write_separator (u, 2) end select write (u, "(A)") write (u, "(A)") "* Cleanup" call evt_shower%final () call evt_trivial%final () call process_instance%final () call process%final () call lib%final () call model_hadrons%final () deallocate (model_hadrons) call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: shower_2" end subroutine shower_2 @ %def shower_2 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Fixed Order NLO Events} This section deals with the generation of weighted event samples which take into account next-to-leading order corrections. An approach generating unweighted events is not possible here, because negative weights might occur due to subtraction. Note that the events produced this way are not physical in the sense that they will not keep NLO-accuracy when interfaced to a parton shower. They are rather useful for theoretical consistency checks and a fast estimate of NLO effects.\\ We generate NLO events in the following way: First, the integration is carried out using the complete divergence-subtracted NLO matrix element. In the subsequent simulation, $N$-particle kinematics are generated using $\mathcal{B}+\mathcal{V}+\mathcal{C}$ as weight. After that, the program loops over all singular regions and for each of them generates an event with $N+1$-particle kinematics. The weight for those events corresponds to the real matrix element $\mathcal{R}^\alpha$ evaluated at the $\alpha$-region's emitter's phase space point, multiplied with $S_\alpha$. This procedure is implemented using the [[evt_nlo]] transform. <<[[evt_nlo.f90]]>>= <> module evt_nlo <> <> <> use io_units, only: given_output_unit use constants use lorentz use diagnostics use format_utils, only: write_separator use physics_defs, only: NLO_REAL use sm_qcd use model_data use particles use instances, only: process_instance_t use pcm, only: pcm_nlo_t, pcm_instance_nlo_t use process_stacks use event_transforms use prc_core, only: prc_core_t use prc_external, only: prc_external_t use phs_fks, only: phs_fks_t, phs_fks_generator_t use phs_fks, only: phs_identifier_t, phs_point_set_t use resonances, only: resonance_contributors_t use fks_regions, only: region_data_t <> <> <> <> contains <> end module evt_nlo @ %def evt_nlo @ <>= type :: nlo_event_deps_t logical :: cm_frame = .true. type(phs_point_set_t) :: p_born_cms type(phs_point_set_t) :: p_born_lab type(phs_point_set_t) :: p_real_cms type(phs_point_set_t) :: p_real_lab type(resonance_contributors_t), dimension(:), allocatable :: contributors type(phs_identifier_t), dimension(:), allocatable :: phs_identifiers integer, dimension(:), allocatable :: alr_to_i_con integer :: n_phs = 0 end type nlo_event_deps_t @ %def nlo_event_deps_t @ This event transformation is for the generation of fixed-order NLO events. It takes an event with Born kinematics and creates $N_\alpha + 1$ modified weighted events. The first one has Born kinematics and its weight is the sum of Born, virtual and subtraction matrix elements. The other $N_\alpha$ events have a weight which is equal to the real matrix element, evaluated with the phase space corresponding to the emitter of the $\alpha$-region. All NLO event objects share the same event transformation. For this reason, we save the particle set of the current $\alpha$-region in the array [[particle_set_radiated]]. Otherwise it would be unretrievable if the usual particle set of the event object was used. <>= integer, parameter, public :: EVT_NLO_UNDEFINED = 0 integer, parameter, public :: EVT_NLO_SEPARATE_BORNLIKE = 1 integer, parameter, public :: EVT_NLO_SEPARATE_REAL = 2 integer, parameter, public :: EVT_NLO_COMBINED = 3 <>= public :: evt_nlo_t <>= type, extends (evt_t) :: evt_nlo_t type(phs_fks_generator_t) :: phs_fks_generator real(default) :: sqme_rad = zero integer :: i_evaluation = 0 type(particle_set_t), dimension(:), allocatable :: particle_set_radiated type(qcd_t) :: qcd type(nlo_event_deps_t) :: event_deps integer :: mode = EVT_NLO_UNDEFINED integer, dimension(:), allocatable :: & i_evaluation_to_i_phs, i_evaluation_to_emitter, & i_evaluation_to_i_term logical :: keep_failed_events = .false. integer :: selected_i_flv = 0 contains <> end type evt_nlo_t @ %def evt_nlo_t @ <>= procedure :: write_name => evt_nlo_write_name <>= subroutine evt_nlo_write_name (evt, unit) class(evt_nlo_t), intent(in) :: evt integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A)") "Event transform: NLO" end subroutine evt_nlo_write_name @ %def evt_nlo_write_name @ <>= procedure :: write => evt_nlo_write <>= subroutine evt_nlo_write (evt, unit, verbose, more_verbose, testflag) class(evt_nlo_t), intent(in) :: evt integer, intent(in), optional :: unit logical, intent(in), optional :: verbose, more_verbose, testflag integer :: u, i u = given_output_unit (unit) call write_separator (u, 2) call evt%write_name (u) call write_separator (u) call evt%base_write (u, testflag = testflag, show_set = .true.) write (u,'(A,ES16.9)') "sqme_rad = ", evt%sqme_rad write (u, "(3x,A,I0)") "i_evaluation = ", evt%i_evaluation call write_separator (u) write (u, "(1x,A)") "Radiated particle sets:" do i = 1, size (evt%particle_set_radiated) call evt%particle_set_radiated(i)%write (u, testflag = testflag) call write_separator (u) end do end subroutine evt_nlo_write @ %def evt_nlo_write @ Connects the event transform to the process. Here also the phase space is set up by making [[real_kinematics]] point to the corresponding object in the [[pcm_instance]]. <>= procedure :: connect => evt_nlo_connect <>= subroutine evt_nlo_connect (evt, process_instance, model, process_stack) class(evt_nlo_t), intent(inout), target :: evt type(process_instance_t), intent(in), target :: process_instance class(model_data_t), intent(in), target :: model type(process_stack_t), intent(in), optional :: process_stack if (debug_on) call msg_debug (D_TRANSFORMS, "evt_nlo_connect") call evt%base_connect (process_instance, model, process_stack) select type (pcm => process_instance%pcm) class is (pcm_instance_nlo_t) select type (config => pcm%config) type is (pcm_nlo_t) call config%setup_phs_generator (pcm, evt%phs_fks_generator, & process_instance%get_sqrts ()) call evt%set_i_evaluation_mappings (config%region_data, & pcm%real_kinematics%alr_to_i_phs) end select end select call evt%set_mode (process_instance) call evt%setup_general_event_kinematics (process_instance) if (evt%mode > EVT_NLO_SEPARATE_BORNLIKE) & call evt%setup_real_event_kinematics (process_instance) if (debug_on) call msg_debug2 (D_TRANSFORMS, "evt_nlo_connect: success") end subroutine evt_nlo_connect @ %def evt_nlo_connect @ <>= procedure :: set_i_evaluation_mappings => evt_nlo_set_i_evaluation_mappings <>= subroutine evt_nlo_set_i_evaluation_mappings (evt, reg_data, alr_to_i_phs) class(evt_nlo_t), intent(inout) :: evt type(region_data_t), intent(in) :: reg_data integer, intent(in), dimension(:) :: alr_to_i_phs integer :: n_phs, alr integer :: i_evaluation, i_phs, emitter logical :: checked type :: registered_triple_t integer, dimension(2) :: phs_em type(registered_triple_t), pointer :: next => null () end type registered_triple_t type(registered_triple_t), allocatable, target :: check_list i_evaluation = 1 n_phs = reg_data%n_phs allocate (evt%i_evaluation_to_i_phs (n_phs), source = 0) allocate (evt%i_evaluation_to_emitter (n_phs), source = -1) allocate (evt%i_evaluation_to_i_term (0 : n_phs), source = 0) do alr = 1, reg_data%n_regions i_phs = alr_to_i_phs (alr) emitter = reg_data%regions(alr)%emitter call search_check_list (checked) if (.not. checked) then evt%i_evaluation_to_i_phs (i_evaluation) = i_phs evt%i_evaluation_to_emitter (i_evaluation) = emitter i_evaluation = i_evaluation + 1 end if end do call fill_i_evaluation_to_i_term () if (.not. (all (evt%i_evaluation_to_i_phs > 0) & .and. all (evt%i_evaluation_to_emitter > -1))) then call msg_fatal ("evt_nlo: Inconsistent mappings!") else if (debug2_active (D_TRANSFORMS)) then print *, 'evt_nlo Mappings, i_evaluation -> ' print *, 'i_phs: ', evt%i_evaluation_to_i_phs print *, 'emitter: ', evt%i_evaluation_to_emitter end if end if contains subroutine fill_i_evaluation_to_i_term () integer :: i_term, i_evaluation, term_emitter !!! First find subtraction component i_evaluation = 1 do i_term = 1, evt%process%get_n_terms () if (evt%process_instance%term(i_term)%nlo_type /= NLO_REAL) cycle term_emitter = evt%process_instance%term(i_term)%k_term%emitter if (term_emitter < 0) then evt%i_evaluation_to_i_term (0) = i_term else if (evt%i_evaluation_to_emitter(i_evaluation) == term_emitter) then evt%i_evaluation_to_i_term (i_evaluation) = i_term i_evaluation = i_evaluation + 1 end if end do end subroutine fill_i_evaluation_to_i_term subroutine search_check_list (found) logical, intent(out) :: found type(registered_triple_t), pointer :: current_triple => null () if (allocated (check_list)) then current_triple => check_list do if (all (current_triple%phs_em == [i_phs, emitter])) then found = .true. exit end if if (.not. associated (current_triple%next)) then allocate (current_triple%next) current_triple%next%phs_em = [i_phs, emitter] found = .false. exit else current_triple => current_triple%next end if end do else allocate (check_list) check_list%phs_em = [i_phs, emitter] found = .false. end if end subroutine search_check_list end subroutine evt_nlo_set_i_evaluation_mappings @ %def evt_nlo_set_i_evaluation_mappings @ <>= procedure :: get_i_phs => evt_nlo_get_i_phs <>= function evt_nlo_get_i_phs (evt) result (i_phs) integer :: i_phs class(evt_nlo_t), intent(in) :: evt i_phs = evt%i_evaluation_to_i_phs (evt%i_evaluation) end function evt_nlo_get_i_phs @ %def evt_nlo_get_i_phs @ <>= procedure :: get_emitter => evt_nlo_get_emitter <>= function evt_nlo_get_emitter (evt) result (emitter) integer :: emitter class(evt_nlo_t), intent(in) :: evt emitter = evt%i_evaluation_to_emitter (evt%i_evaluation) end function evt_nlo_get_emitter @ %def evt_nlo_get_emitter @ <>= procedure :: get_i_term => evt_nlo_get_i_term <>= function evt_nlo_get_i_term (evt) result (i_term) integer :: i_term class(evt_nlo_t), intent(in) :: evt if (evt%mode >= EVT_NLO_SEPARATE_REAL) then i_term = evt%i_evaluation_to_i_term (evt%i_evaluation) else i_term = evt%process_instance%get_first_active_i_term () end if end function evt_nlo_get_i_term @ %def evt_nlo_get_i_term @ <>= procedure :: copy_previous_particle_set => evt_nlo_copy_previous_particle_set <>= subroutine evt_nlo_copy_previous_particle_set (evt) class(evt_nlo_t), intent(inout) :: evt if (associated (evt%previous)) then evt%particle_set = evt%previous%particle_set else call msg_fatal ("evt_nlo requires one preceeding evt_trivial!") end if end subroutine evt_nlo_copy_previous_particle_set @ %def evt_nlo_copy_previous_particle_set @ The event transform has a variable which counts the number of times it has already been called for one generation point. If this variable, [[i_evaluation]], is zero, this means that [[evt_nlo_generate]] is called for the first time, so that the generation of an $N$-particle event is required. In all other cases, emission events are generated.\\ During a separate integration of the real component, the first event of each event group will become the counterevent. In this case, we return the sum of all subtraction matrix elements. \\ During a combined integration, the first event will be a combination of all Born-like events. To get the sum of their matrix elements, we subtract the sum of all real emissions from the sum of all matrix elements as the real contribution is the only non-Born contribution. \\ Note that the argument named [[probablity]], the use of the routine [[generate_weighted]] and the procedure we use to generate NLO events via an event transformation is an abuse of the interface which should be refactored. <>= procedure :: generate_weighted => evt_nlo_generate_weighted <>= subroutine evt_nlo_generate_weighted (evt, probability) class(evt_nlo_t), intent(inout) :: evt real(default), intent(inout) :: probability real(default) :: sqme call print_debug_info () sqme = probability if (evt%mode > EVT_NLO_SEPARATE_BORNLIKE) then if (evt%i_evaluation == 0) then call evt%reset_phs_identifiers () call evt%evaluate_real_kinematics () if (evt%mode == EVT_NLO_SEPARATE_REAL) then sqme = evt%compute_subtraction_sqmes () else sqme = sqme - evt%compute_all_sqme_rad () end if else call evt%compute_real () sqme = evt%sqme_rad end if end if probability = sqme if (debug_on) call msg_debug (D_TRANSFORMS, "probability (after)", probability) evt%particle_set_exists = .true. contains function status_code_to_string (mode) result (smode) type(string_t) :: smode integer, intent(in) :: mode select case (mode) case (EVT_NLO_UNDEFINED) smode = var_str ("Undefined") case (EVT_NLO_SEPARATE_BORNLIKE) smode = var_str ("Born-like") case (EVT_NLO_SEPARATE_REAL) smode = var_str ("Real") case (EVT_NLO_COMBINED) smode = var_str ("Combined") end select end function status_code_to_string subroutine print_debug_info () if (debug_on) call msg_debug (D_TRANSFORMS, "evt_nlo_generate_weighted") if (debug_on) call msg_debug (D_TRANSFORMS, char ("mode: " // status_code_to_string (evt%mode))) if (debug_on) call msg_debug (D_TRANSFORMS, "probability (before)", probability) if (debug_on) call msg_debug (D_TRANSFORMS, "evt%i_evaluation", evt%i_evaluation) if (debug2_active (D_TRANSFORMS)) then if (evt%mode > EVT_NLO_SEPARATE_BORNLIKE) then if (evt%i_evaluation == 0) then print *, 'Evaluate subtraction component' else print *, 'Evaluate radiation component' end if end if end if end subroutine print_debug_info end subroutine evt_nlo_generate_weighted @ %def evt_nlo_generate_weighted @ <>= procedure :: reset_phs_identifiers => evt_nlo_reset_phs_identifiers <>= subroutine evt_nlo_reset_phs_identifiers (evt) class(evt_nlo_t), intent(inout) :: evt evt%event_deps%phs_identifiers%evaluated = .false. end subroutine evt_nlo_reset_phs_identifiers @ %def evt_nlo_reset_phs_identifiers @ <>= procedure :: make_particle_set => evt_nlo_make_particle_set <>= subroutine evt_nlo_make_particle_set & (evt, factorization_mode, keep_correlations, r) class(evt_nlo_t), intent(inout) :: evt integer, intent(in) :: factorization_mode logical, intent(in) :: keep_correlations real(default), dimension(:), intent(in), optional :: r if (evt%mode >= EVT_NLO_SEPARATE_BORNLIKE) then select type (config => evt%process_instance%pcm%config) type is (pcm_nlo_t) if (evt%i_evaluation > 0) then call make_factorized_particle_set (evt, factorization_mode, & keep_correlations, r, evt%get_i_term (), & config%qn_real(:, evt%selected_i_flv)) else call make_factorized_particle_set (evt, factorization_mode, & keep_correlations, r, evt%get_i_term (), & config%qn_born(:, evt%selected_i_flv)) end if end select else call make_factorized_particle_set (evt, factorization_mode, & keep_correlations, r) end if end subroutine evt_nlo_make_particle_set @ %def evt_nlo_make_particle_set @ <>= procedure :: keep_and_boost_born_particle_set => & evt_nlo_keep_and_boost_born_particle_set <>= subroutine evt_nlo_keep_and_boost_born_particle_set (evt, i_event) class(evt_nlo_t), intent(inout) :: evt integer, intent(in) :: i_event evt%particle_set_radiated(i_event) = evt%particle_set if (evt%event_deps%cm_frame) then evt%event_deps%p_born_cms%phs_point(1) = & evt%particle_set%get_in_and_out_momenta () evt%event_deps%p_born_lab%phs_point(1) = & evt%boost_to_lab (evt%event_deps%p_born_cms%phs_point(1)) call evt%particle_set_radiated(i_event)%replace_incoming_momenta & (evt%event_deps%p_born_lab%phs_point(1)%p) call evt%particle_set_radiated(i_event)%replace_outgoing_momenta & (evt%event_deps%p_born_lab%phs_point(1)%p) end if end subroutine evt_nlo_keep_and_boost_born_particle_set @ %def evt_nlo_keep_and_boost_born_particle_set @ <>= procedure :: evaluate_real_kinematics => evt_nlo_evaluate_real_kinematics <>= subroutine evt_nlo_evaluate_real_kinematics (evt) class(evt_nlo_t), intent(inout) :: evt integer :: alr, i_phs, i_con, emitter real(default), dimension(3) :: x_rad logical :: use_contributors integer :: i_term select type (pcm => evt%process_instance%pcm) class is (pcm_instance_nlo_t) x_rad = pcm%real_kinematics%x_rad associate (event_deps => evt%event_deps) i_term = evt%get_i_term () event_deps%p_born_lab%phs_point(1) = & evt%process_instance%term(i_term)%connected%matrix%get_momenta () event_deps%p_born_cms%phs_point(1) & = evt%boost_to_cms (event_deps%p_born_lab%phs_point(1)) call evt%phs_fks_generator%set_sqrts_hat & (event_deps%p_born_cms%get_energy (1, 1)) use_contributors = allocated (event_deps%contributors) do alr = 1, pcm%get_n_regions () i_phs = pcm%real_kinematics%alr_to_i_phs(alr) if (event_deps%phs_identifiers(i_phs)%evaluated) cycle emitter = event_deps%phs_identifiers(i_phs)%emitter associate (generator => evt%phs_fks_generator) if (emitter <= evt%process%get_n_in ()) then call generator%prepare_generation (x_rad, i_phs, emitter, & event_deps%p_born_cms%phs_point(1)%p, event_deps%phs_identifiers) call generator%generate_isr (i_phs, & event_deps%p_born_lab%phs_point(1)%p, & event_deps%p_real_lab%phs_point(i_phs)%p) event_deps%p_real_cms%phs_point(i_phs) & = evt%boost_to_cms (event_deps%p_real_lab%phs_point(i_phs)) else if (use_contributors) then i_con = event_deps%alr_to_i_con(alr) call generator%prepare_generation (x_rad, i_phs, emitter, & event_deps%p_born_cms%phs_point(1)%p, & event_deps%phs_identifiers, event_deps%contributors, i_con) call generator%generate_fsr (emitter, i_phs, i_con, & event_deps%p_born_cms%phs_point(1)%p, & event_deps%p_real_cms%phs_point(i_phs)%p) else call generator%prepare_generation (x_rad, i_phs, emitter, & event_deps%p_born_cms%phs_point(1)%p, event_deps%phs_identifiers) call generator%generate_fsr (emitter, i_phs, & event_deps%p_born_cms%phs_point(1)%p, & event_deps%p_real_cms%phs_point(i_phs)%p) end if event_deps%p_real_lab%phs_point(i_phs) & = evt%boost_to_lab (event_deps%p_real_cms%phs_point(i_phs)) end if end associate call pcm%set_momenta (event_deps%p_born_lab%phs_point(1)%p, & event_deps%p_real_lab%phs_point(i_phs)%p, i_phs) call pcm%set_momenta (event_deps%p_born_cms%phs_point(1)%p, & event_deps%p_real_cms%phs_point(i_phs)%p, i_phs, cms = .true.) event_deps%phs_identifiers(i_phs)%evaluated = .true. end do end associate end select end subroutine evt_nlo_evaluate_real_kinematics @ %def evt_nlo_evaluate_real_kinematics @ This routine calls the evaluation of the singular regions only for the subtraction terms. <>= procedure :: compute_subtraction_sqmes => evt_nlo_compute_subtraction_sqmes <>= function evt_nlo_compute_subtraction_sqmes (evt) result (sqme) class(evt_nlo_t), intent(inout) :: evt real(default) :: sqme integer :: i_phs, i_term if (debug_on) call msg_debug (D_TRANSFORMS, "evt_nlo_compute_subtraction_sqmes") sqme = zero select type (pcm => evt%process_instance%pcm) class is (pcm_instance_nlo_t) i_phs = 1; i_term = evt%i_evaluation_to_i_term(0) call evt%process_instance%compute_sqme_rad (i_term, i_phs, is_subtraction = .true.) sqme = sqme + evt%process_instance%get_sqme (i_term) end select end function evt_nlo_compute_subtraction_sqmes @ %def evt_nlo_compute_subtraction_sqmes @ This routine calls the evaluation of the singular regions only for emission matrix elements. <>= procedure :: compute_real => evt_nlo_compute_real <>= subroutine evt_nlo_compute_real (evt) class(evt_nlo_t), intent(inout) :: evt integer :: i_phs, i_term if (debug_on) call msg_debug (D_TRANSFORMS, "evt_nlo_compute_real") i_phs = evt%get_i_phs () i_term = evt%i_evaluation_to_i_term (evt%i_evaluation) select type (pcm => evt%process_instance%pcm) class is (pcm_instance_nlo_t) call evt%process_instance%compute_sqme_rad (i_term, i_phs, is_subtraction = .false.) evt%sqme_rad = evt%process_instance%get_sqme (i_term) end select end subroutine evt_nlo_compute_real @ %def evt_nlo_compute_real @ This routine calls the evaluation of the singular regions only for all emission matrix elements. This is needed for the combined mode. It returns the sum of all valid real matrix elements. <>= procedure :: compute_all_sqme_rad => evt_nlo_compute_all_sqme_rad <>= function evt_nlo_compute_all_sqme_rad (evt) result (sqme) class(evt_nlo_t), intent(inout) :: evt real(default) :: sqme integer :: i_phs, i_term if (debug_on) call msg_debug (D_TRANSFORMS, "evt_nlo_compute_all_sqme_rad") sqme = zero select type (pcm => evt%process_instance%pcm) class is (pcm_instance_nlo_t) do i_term = 1, size (evt%process_instance%term) if (evt%is_valid_event (i_term)) then associate (term => evt%process_instance%term(i_term)) if (term%nlo_type == NLO_REAL .and. .not. term%is_subtraction ()) then i_phs = term%k_term%i_phs call evt%process_instance%compute_sqme_rad ( & i_term, i_phs, is_subtraction = .false.) sqme = sqme + evt%process_instance%get_sqme (i_term) end if end associate end if end do end select end function evt_nlo_compute_all_sqme_rad @ %def evt_nlo_compute_all_sqme_rad @ <>= procedure :: boost_to_cms => evt_nlo_boost_to_cms <>= function evt_nlo_boost_to_cms (evt, p_lab) result (p_cms) type(phs_point_t), intent(in) :: p_lab class(evt_nlo_t), intent(in) :: evt type(phs_point_t) :: p_cms type(lorentz_transformation_t) :: lt_lab_to_cms integer :: i_boost if (evt%event_deps%cm_frame) then lt_lab_to_cms = identity else if (evt%mode == EVT_NLO_COMBINED) then i_boost = 1 else i_boost = evt%process_instance%select_i_term () end if lt_lab_to_cms = evt%process_instance%get_boost_to_cms (i_boost) end if p_cms = lt_lab_to_cms * p_lab end function evt_nlo_boost_to_cms @ %def evt_nlo_boost_to_cms @ <>= procedure :: boost_to_lab => evt_nlo_boost_to_lab <>= function evt_nlo_boost_to_lab (evt, p_cms) result (p_lab) type(phs_point_t) :: p_lab class(evt_nlo_t), intent(in) :: evt type(phs_point_t), intent(in) :: p_cms type(lorentz_transformation_t) :: lt_cms_to_lab integer :: i_boost if (.not. evt%event_deps%cm_frame) then lt_cms_to_lab = identity else if (evt%mode == EVT_NLO_COMBINED) then i_boost = 1 else i_boost = evt%process_instance%select_i_term () end if lt_cms_to_lab = evt%process_instance%get_boost_to_lab (i_boost) end if p_lab = lt_cms_to_lab * p_cms end function evt_nlo_boost_to_lab @ %def evt_nlo_boost_to_lab @ <>= procedure :: setup_general_event_kinematics => evt_nlo_setup_general_event_kinematics <>= subroutine evt_nlo_setup_general_event_kinematics (evt, process_instance) class(evt_nlo_t), intent(inout) :: evt type(process_instance_t), intent(in) :: process_instance integer :: n_born associate (event_deps => evt%event_deps) event_deps%cm_frame = process_instance%is_cm_frame (1) select type (pcm => process_instance%pcm) type is (pcm_instance_nlo_t) n_born = pcm%get_n_born () end select call event_deps%p_born_cms%init (n_born, 1) call event_deps%p_born_lab%init (n_born, 1) end associate end subroutine evt_nlo_setup_general_event_kinematics @ %def evt_nlo_setup_general_event_kinematics @ <>= procedure :: setup_real_event_kinematics => evt_nlo_setup_real_event_kinematics <>= subroutine evt_nlo_setup_real_event_kinematics (evt, process_instance) class(evt_nlo_t), intent(inout) :: evt type(process_instance_t), intent(in) :: process_instance integer :: n_real, n_phs integer :: i_real associate (event_deps => evt%event_deps) select type (pcm => process_instance%pcm) class is (pcm_instance_nlo_t) n_real = pcm%get_n_real () end select i_real = evt%process%get_first_real_term () select type (phs => process_instance%term(i_real)%k_term%phs) type is (phs_fks_t) event_deps%phs_identifiers = phs%phs_identifiers end select n_phs = size (event_deps%phs_identifiers) call event_deps%p_real_cms%init (n_real, n_phs) call event_deps%p_real_lab%init (n_real, n_phs) select type (pcm => process_instance%pcm) type is (pcm_instance_nlo_t) select type (config => pcm%config) type is (pcm_nlo_t) if (allocated (config%region_data%alr_contributors)) then allocate (event_deps%contributors (size (config%region_data%alr_contributors))) event_deps%contributors = config%region_data%alr_contributors end if if (allocated (config%region_data%alr_to_i_contributor)) then allocate (event_deps%alr_to_i_con & (size (config%region_data%alr_to_i_contributor))) event_deps%alr_to_i_con = config%region_data%alr_to_i_contributor end if end select end select end associate end subroutine evt_nlo_setup_real_event_kinematics @ %def evt_nlo_setup_real_event_kinematics @ <>= procedure :: set_mode => evt_nlo_set_mode <>= subroutine evt_nlo_set_mode (evt, process_instance) class(evt_nlo_t), intent(inout) :: evt type(process_instance_t), intent(in) :: process_instance integer :: i_real select type (pcm => process_instance%pcm) type is (pcm_instance_nlo_t) select type (config => pcm%config) type is (pcm_nlo_t) if (config%settings%combined_integration) then evt%mode = EVT_NLO_COMBINED else i_real = evt%process%get_first_real_component () if (i_real == evt%process%extract_active_component_mci ()) then evt%mode = EVT_NLO_SEPARATE_REAL else evt%mode = EVT_NLO_SEPARATE_BORNLIKE end if end if end select end select end subroutine evt_nlo_set_mode @ %def evt_nlo_set_mode @ <>= procedure :: is_valid_event => evt_nlo_is_valid_event <>= function evt_nlo_is_valid_event (evt, i_term) result (valid) logical :: valid class(evt_nlo_t), intent(in) :: evt integer, intent(in) :: i_term valid = evt%process_instance%term(i_term)%passed end function evt_nlo_is_valid_event @ %def evt_nlo_is_valid_event @ Prepares a new event. Selects a flavor structure such that each flavor structure is as probable as its portion of the total squared matrix element. <>= procedure :: prepare_new_event => evt_nlo_prepare_new_event <>= subroutine evt_nlo_prepare_new_event (evt, i_mci, i_term) class(evt_nlo_t), intent(inout) :: evt integer, intent(in) :: i_mci, i_term real(default) :: s, x real(default) :: sqme_total real(default), dimension(:), allocatable :: sqme_flv integer :: i, i_flv, i_core class(prc_core_t), pointer :: core => null () call evt%reset () if (evt%i_evaluation > 0) return call evt%rng%generate (x) sqme_total = zero allocate (sqme_flv (evt%process_instance%term(1)%config%data%n_flv)) sqme_flv = zero i_core = evt%process%get_i_core (i_term) core => evt%process%get_core_ptr (i_core) do i = 1, size (evt%process_instance%term) associate (term => evt%process_instance%term(i)) sqme_total = sqme_total + real (sum ( & term%connected%matrix%get_matrix_element ())) !!! TODO: figure out why this select type is needed for prc_omega_t !!! For NLO and prc_omega_t the connected trace seems to be set up incorrectly! select type (core) class is (prc_external_t) do i_flv = 1, size (sqme_flv) sqme_flv(i_flv) = sqme_flv(i_flv) & + real (term%connected%matrix%get_matrix_element ( & term%connected_qn_index%get_index (i_flv, i_sub = 0))) end do class default sqme_flv = sqme_flv & + real (term%connected%matrix%get_matrix_element ()) end select end associate end do !!! Need absolute values to take into account negative weights x = x * abs (sqme_total) s = zero do i_flv = 1, size (sqme_flv) s = s + abs (sqme_flv (i_flv)) if (s > x) then evt%selected_i_flv = i_flv exit end if end do if (debug2_active (D_TRANSFORMS)) then call msg_print_color ("Selected i_flv: ", COL_GREEN) print *, evt%selected_i_flv end if end subroutine evt_nlo_prepare_new_event @ %def evt_nlo_prepare_new_event @ \section{Complete Events} This module combines hard processes with decay chains, shower, and hadronization (not implemented yet) to complete events. It also manages the input and output of event records in various formats. <<[[events.f90]]>>= <> module events <> <> <> use constants, only: one use io_units use format_utils, only: pac_fmt, write_separator use format_defs, only: FMT_12, FMT_19 use numeric_utils use diagnostics use variables use expr_base use model_data use state_matrices, only: FM_IGNORE_HELICITY, & FM_SELECT_HELICITY, FM_FACTOR_HELICITY, FM_CORRELATED_HELICITY use particles use subevt_expr use rng_base use process, only: process_t use instances, only: process_instance_t use pcm, only: pcm_instance_nlo_t use process_stacks use event_base use event_transforms use decays use evt_nlo <> <> <> <> contains <> end module events @ %def events @ \subsection{Event configuration} The parameters govern the transformation of an event to a particle set. The [[safety_factor]] reduces the acceptance probability for unweighting. If greater than one, excess events become less likely, but the reweighting efficiency also drops. The [[sigma]] and [[n]] values, if nontrivial, allow for reweighting the events according to the requested [[norm_mode]]. Various [[parse_node_t]] objects are taken from the SINDARIN input. They encode expressions that apply to the current event. The workspaces for evaluating those expressions are set up in the [[event_expr_t]] objects. Note that these are really pointers, so the actual nodes are not stored inside the event object. <>= type :: event_config_t logical :: unweighted = .false. integer :: norm_mode = NORM_UNDEFINED integer :: factorization_mode = FM_IGNORE_HELICITY logical :: keep_correlations = .false. logical :: colorize_subevt = .false. real(default) :: sigma = 1 integer :: n = 1 real(default) :: safety_factor = 1 class(expr_factory_t), allocatable :: ef_selection class(expr_factory_t), allocatable :: ef_reweight class(expr_factory_t), allocatable :: ef_analysis contains <> end type event_config_t @ %def event_config_t @ Output. <>= procedure :: write => event_config_write <>= subroutine event_config_write (object, unit, show_expressions) class(event_config_t), intent(in) :: object integer, intent(in), optional :: unit logical, intent(in), optional :: show_expressions integer :: u u = given_output_unit (unit) write (u, "(3x,A,L1)") "Unweighted = ", object%unweighted write (u, "(3x,A,A)") "Normalization = ", & char (event_normalization_string (object%norm_mode)) write (u, "(3x,A)", advance="no") "Helicity handling = " select case (object%factorization_mode) case (FM_IGNORE_HELICITY) write (u, "(A)") "drop" case (FM_SELECT_HELICITY) write (u, "(A)") "select" case (FM_FACTOR_HELICITY) write (u, "(A)") "factorize" end select write (u, "(3x,A,L1)") "Keep correlations = ", object%keep_correlations if (object%colorize_subevt) then write (u, "(3x,A,L1)") "Colorize subevent = ", object%colorize_subevt end if if (.not. nearly_equal (object%safety_factor, one)) then write (u, "(3x,A," // FMT_12 // ")") & "Safety factor = ", object%safety_factor end if if (present (show_expressions)) then if (show_expressions) then if (allocated (object%ef_selection)) then call write_separator (u) write (u, "(3x,A)") "Event selection expression:" call object%ef_selection%write (u) end if if (allocated (object%ef_reweight)) then call write_separator (u) write (u, "(3x,A)") "Event reweighting expression:" call object%ef_reweight%write (u) end if if (allocated (object%ef_analysis)) then call write_separator (u) write (u, "(3x,A)") "Analysis expression:" call object%ef_analysis%write (u) end if end if end if end subroutine event_config_write @ %def event_config_write @ \subsection{The event type} This is the concrete implementation of the [[generic_event_t]] core that is defined above in the [[event_base]] module. The core manages the main (dressed) particle set pointer and the current values for weights and sqme. The implementation adds configuration data, expressions, process references, and event transforms. Each event refers to a single elementary process. This process may be dressed by a shower, a decay chain etc. We maintain pointers to a process instance. A list of event transforms (class [[evt_t]]) transform the connected interactions of the process instance into the final particle set. In this list, the first transform is always the trivial one, which just factorizes the process instance. Subsequent transforms may apply decays, etc. The [[particle_set]] pointer identifies the particle set that we want to be analyzed and returned by the event, usually the last one. Squared matrix element and weight values: when reading events from file, the [[ref]] value is the number in the file, while the [[prc]] value is the number that we calculate from the momenta in the file, possibly with different parameters. When generating events the first time, or if we do not recalculate, the numbers should coincide. Furthermore, the array of [[alt]] values is copied from an array of alternative event records. These values should represent calculated values. The [[sqme]] and [[weight]] values mirror corresponding values in the [[expr]] subobject. The idea is that when generating or reading events, the event record is filled first, then the [[expr]] object acquires copies. These copies are used for writing events and as targets for pointer variables in the analysis expression. All data that involve user-provided expressions (selection, reweighting, analysis) are handled by the [[expr]] subobject. In particular, evaluating the event-selection expression sets the [[passed]] flag. Furthermore, the [[expr]] subobject collects data that can be used in the analysis and should be written to file, including copies of [[sqme]] and [[weight]]. <>= public :: event_t <>= type, extends (generic_event_t) :: event_t type(event_config_t) :: config type(process_t), pointer :: process => null () type(process_instance_t), pointer :: instance => null () class(rng_t), allocatable :: rng integer :: selected_i_mci = 0 integer :: selected_i_term = 0 integer :: selected_channel = 0 logical :: is_complete = .false. class(evt_t), pointer :: transform_first => null () class(evt_t), pointer :: transform_last => null () type(event_expr_t) :: expr logical :: selection_evaluated = .false. logical :: passed = .false. real(default), allocatable :: alpha_qcd_forced real(default), allocatable :: scale_forced real(default) :: reweight = 1 logical :: analysis_flag = .false. integer :: i_event = 0 contains <> end type event_t @ %def event_t @ <>= procedure :: clone => event_clone <>= subroutine event_clone (event, event_new) class(event_t), intent(in), target :: event class(event_t), intent(out), target:: event_new type(string_t) :: id integer :: num_id event_new%config = event%config event_new%process => event%process event_new%instance => event%instance if (allocated (event%rng)) & allocate(event_new%rng, source=event%rng) event_new%selected_i_mci = event%selected_i_mci event_new%selected_i_term = event%selected_i_term event_new%selected_channel = event%selected_channel event_new%is_complete = event%is_complete event_new%transform_first => event%transform_first event_new%transform_last => event%transform_last event_new%selection_evaluated = event%selection_evaluated event_new%passed = event%passed if (allocated (event%alpha_qcd_forced)) & allocate(event_new%alpha_qcd_forced, source=event%alpha_qcd_forced) if (allocated (event%scale_forced)) & allocate(event_new%scale_forced, source=event%scale_forced) event_new%reweight = event%reweight event_new%analysis_flag = event%analysis_flag event_new%i_event = event%i_event id = event_new%process%get_id () if (id /= "") call event_new%expr%set_process_id (id) num_id = event_new%process%get_num_id () if (num_id /= 0) call event_new%expr%set_process_num_id (num_id) call event_new%expr%setup_vars (event_new%process%get_sqrts ()) call event_new%expr%link_var_list (event_new%process%get_var_list_ptr ()) end subroutine event_clone @ %def event_clone @ Finalizer: the list of event transforms is deleted iteratively. <>= procedure :: final => event_final <>= subroutine event_final (object) class(event_t), intent(inout) :: object class(evt_t), pointer :: evt if (allocated (object%rng)) call object%rng%final () call object%expr%final () do while (associated (object%transform_first)) evt => object%transform_first object%transform_first => evt%next call evt%final () deallocate (evt) end do end subroutine event_final @ %def event_final @ Output. The event index is written in the header, it should coincide with the [[event_index]] variable that can be used in selection and analysis. Particle set: this is a pointer to one of the event transforms, so it should suffice to print the latter. <>= procedure :: write => event_write <>= subroutine event_write (object, unit, show_process, show_transforms, & show_decay, verbose, testflag) class(event_t), intent(in) :: object integer, intent(in), optional :: unit logical, intent(in), optional :: show_process, show_transforms, show_decay logical, intent(in), optional :: verbose logical, intent(in), optional :: testflag logical :: prc, trans, dec, verb class(evt_t), pointer :: evt character(len=7) :: fmt integer :: u, i call pac_fmt (fmt, FMT_19, FMT_12, testflag) u = given_output_unit (unit) prc = .true.; if (present (show_process)) prc = show_process trans = .true.; if (present (show_transforms)) trans = show_transforms dec = .true.; if (present (show_decay)) dec = show_decay verb = .false.; if (present (verbose)) verb = verbose call write_separator (u, 2) write (u, "(1x,A)", advance="no") "Event" if (object%has_index ()) then write (u, "(1x,'#',I0)", advance="no") object%get_index () end if if (object%is_complete) then write (u, *) else write (u, "(1x,A)") "[incomplete]" end if call write_separator (u) call object%config%write (u) if (object%sqme_ref_is_known () .or. object%weight_ref_is_known ()) then call write_separator (u) end if if (object%sqme_ref_is_known ()) then write (u, "(3x,A," // fmt // ")") & "Squared matrix el. (ref) = ", object%get_sqme_ref () if (object%sqme_alt_is_known ()) then do i = 1, object%get_n_alt () write (u, "(5x,A," // fmt // ",1x,I0)") & "alternate sqme = ", object%get_sqme_alt(i), i end do end if end if if (object%sqme_prc_is_known ()) & write (u, "(3x,A," // fmt // ")") & "Squared matrix el. (prc) = ", object%get_sqme_prc () if (object%weight_ref_is_known ()) then write (u, "(3x,A," // fmt // ")") & "Event weight (ref) = ", object%get_weight_ref () if (object%weight_alt_is_known ()) then do i = 1, object%get_n_alt () write (u, "(5x,A," // fmt // ",1x,I0)") & "alternate weight = ", object%get_weight_alt(i), i end do end if end if if (object%weight_prc_is_known ()) & write (u, "(3x,A," // fmt // ")") & "Event weight (prc) = ", object%get_weight_prc () if (object%selected_i_mci /= 0) then call write_separator (u) write (u, "(3x,A,I0)") "Selected MCI group = ", object%selected_i_mci write (u, "(3x,A,I0)") "Selected term = ", object%selected_i_term write (u, "(3x,A,I0)") "Selected channel = ", object%selected_channel end if if (object%selection_evaluated) then call write_separator (u) write (u, "(3x,A,L1)") "Passed selection = ", object%passed if (object%passed) then write (u, "(3x,A," // fmt // ")") & "Reweighting factor = ", object%reweight write (u, "(3x,A,L1)") & "Analysis flag = ", object%analysis_flag end if end if if (associated (object%instance)) then if (prc) then if (verb) then call object%instance%write (u, testflag) else call object%instance%write_header (u) end if end if if (trans) then evt => object%transform_first do while (associated (evt)) select type (evt) type is (evt_decay_t) call evt%write (u, verbose = dec, more_verbose = verb, & testflag = testflag) class default call evt%write (u, verbose = verb, testflag = testflag) end select call write_separator (u, 2) evt => evt%next end do else call write_separator (u, 2) end if if (object%expr%subevt_filled) then call object%expr%write (u, pacified = testflag) call write_separator (u, 2) end if else call write_separator (u, 2) write (u, "(1x,A)") "Process instance: [undefined]" call write_separator (u, 2) end if end subroutine event_write @ %def event_write @ \subsection{Initialization} Initialize: set configuration parameters, using a variable list. We do not call this [[init]], because this method name will be used by a type extension. The default normalization is [[NORM_SIGMA]], since the default generation mode is weighted. For unweighted events, we may want to a apply a safety factor to event rejection. (By default, this factor is unity and can be ignored.) We also allocate the trivial event transform, which is always the first one. <>= procedure :: basic_init => event_init <>= subroutine event_init (event, var_list, n_alt) class(event_t), intent(out) :: event type(var_list_t), intent(in), optional :: var_list integer, intent(in), optional :: n_alt type(string_t) :: norm_string, mode_string logical :: polarized_events if (present (n_alt)) then call event%base_init (n_alt) call event%expr%init (n_alt) else call event%base_init (0) end if if (present (var_list)) then event%config%unweighted = var_list%get_lval (& var_str ("?unweighted")) norm_string = var_list%get_sval (& var_str ("$sample_normalization")) event%config%norm_mode = & event_normalization_mode (norm_string, event%config%unweighted) polarized_events = & var_list%get_lval (var_str ("?polarized_events")) if (polarized_events) then mode_string = & var_list%get_sval (var_str ("$polarization_mode")) select case (char (mode_string)) case ("ignore") event%config%factorization_mode = FM_IGNORE_HELICITY case ("helicity") event%config%factorization_mode = FM_SELECT_HELICITY case ("factorized") event%config%factorization_mode = FM_FACTOR_HELICITY case ("correlated") event%config%factorization_mode = FM_CORRELATED_HELICITY case default call msg_fatal ("Polarization mode " & // char (mode_string) // " is undefined") end select else event%config%factorization_mode = FM_IGNORE_HELICITY end if event%config%colorize_subevt = & var_list%get_lval (var_str ("?colorize_subevt")) if (event%config%unweighted) then event%config%safety_factor = var_list%get_rval (& var_str ("safety_factor")) end if else event%config%norm_mode = NORM_SIGMA end if allocate (evt_trivial_t :: event%transform_first) event%transform_last => event%transform_first end subroutine event_init @ %def event_init @ Set the [[sigma]] and [[n]] values in the configuration record that determine non-standard event normalizations. If these numbers are not set explicitly, the default value for both is unity, and event renormalization has no effect. <>= procedure :: set_sigma => event_set_sigma procedure :: set_n => event_set_n <>= elemental subroutine event_set_sigma (event, sigma) class(event_t), intent(inout) :: event real(default), intent(in) :: sigma event%config%sigma = sigma end subroutine event_set_sigma elemental subroutine event_set_n (event, n) class(event_t), intent(inout) :: event integer, intent(in) :: n event%config%n = n end subroutine event_set_n @ %def event_set_n @ Append an event transform (decays, etc.). The transform is not yet connected to a process. The transform is then considered to belong to the event object, and will be finalized together with it. The original pointer is removed. We can assume that the trivial transform is already present in the event object, at least. <>= procedure :: import_transform => event_import_transform <>= subroutine event_import_transform (event, evt) class(event_t), intent(inout) :: event class(evt_t), intent(inout), pointer :: evt event%transform_last%next => evt evt%previous => event%transform_last event%transform_last => evt evt => null () end subroutine event_import_transform @ %def event_import_transform @ We link the event to an existing process instance. This includes the variable list, which is linked to the process variable list. Note that this is not necessarily identical to the variable list used for event initialization. The variable list will contain pointers to [[event]] subobjects, therefore the [[target]] attribute. Once we have a process connected, we can use it to obtain an event generator instance. The model and process stack may be needed by event transforms. The current model setting may be different from the model in the process (regarding unstable particles, etc.). The process stack can be used for assigning extra processes that we need for the event transforms. <>= procedure :: connect => event_connect <>= subroutine event_connect (event, process_instance, model, process_stack) class(event_t), intent(inout), target :: event type(process_instance_t), intent(in), target :: process_instance class(model_data_t), intent(in), target :: model type(process_stack_t), intent(in), optional :: process_stack type(string_t) :: id integer :: num_id class(evt_t), pointer :: evt event%process => process_instance%process event%instance => process_instance id = event%process%get_id () if (id /= "") call event%expr%set_process_id (id) num_id = event%process%get_num_id () if (num_id /= 0) call event%expr%set_process_num_id (num_id) call event%expr%setup_vars (event%process%get_sqrts ()) call event%expr%link_var_list (event%process%get_var_list_ptr ()) call event%process%make_rng (event%rng) evt => event%transform_first do while (associated (evt)) call evt%connect (process_instance, model, process_stack) evt => evt%next end do end subroutine event_connect @ %def event_connect @ Set the parse nodes for the associated expressions, individually. The parse-node pointers may be null. <>= procedure :: set_selection => event_set_selection procedure :: set_reweight => event_set_reweight procedure :: set_analysis => event_set_analysis <>= subroutine event_set_selection (event, ef_selection) class(event_t), intent(inout) :: event class(expr_factory_t), intent(in) :: ef_selection allocate (event%config%ef_selection, source = ef_selection) end subroutine event_set_selection subroutine event_set_reweight (event, ef_reweight) class(event_t), intent(inout) :: event class(expr_factory_t), intent(in) :: ef_reweight allocate (event%config%ef_reweight, source = ef_reweight) end subroutine event_set_reweight subroutine event_set_analysis (event, ef_analysis) class(event_t), intent(inout) :: event class(expr_factory_t), intent(in) :: ef_analysis allocate (event%config%ef_analysis, source = ef_analysis) end subroutine event_set_analysis @ %def event_set_selection @ %def event_set_reweight @ %def event_set_analysis @ Create evaluation trees from the parse trees. The [[target]] attribute is required because the expressions contain pointers to event subobjects. <>= procedure :: setup_expressions => event_setup_expressions <>= subroutine event_setup_expressions (event) class(event_t), intent(inout), target :: event call event%expr%setup_selection (event%config%ef_selection) call event%expr%setup_analysis (event%config%ef_analysis) call event%expr%setup_reweight (event%config%ef_reweight) call event%expr%colorize (event%config%colorize_subevt) end subroutine event_setup_expressions @ %def event_setup_expressions @ \subsection{Evaluation} To fill the [[particle_set]], i.e., the event record proper, we have to apply all event transforms in order. The last transform should fill its associated particle set, factorizing the state matrix according to the current settings. There are several parameters in the event configuration that control this. We always fill the particle set for the first transform (the hard process) and the last transform, if different from the first (the fully dressed process). Each event transform is an event generator of its own. We choose to generate an \emph{unweighted} event for each of them, even if the master event is assumed to be weighted. Thus, the overall event weight is the one of the hard process only. (There may be more options in future extensions.) We can generate the two random numbers that the factorization needs. For testing purpose, we allow for providing them explicitly, as an option. <>= procedure :: evaluate_transforms => event_evaluate_transforms <>= subroutine event_evaluate_transforms (event, r) class(event_t), intent(inout) :: event real(default), dimension(:), intent(in), optional :: r class(evt_t), pointer :: evt real(default) :: weight_over_sqme integer :: i_term logical :: failed_but_keep failed_but_keep = .false. if (debug_on) call msg_debug (D_TRANSFORMS, "event_evaluate_transforms") call event%discard_particle_set () call event%check () if (event%instance%is_complete_event ()) then i_term = event%instance%select_i_term () event%selected_i_term = i_term evt => event%transform_first do while (associated (evt)) call evt%prepare_new_event & (event%selected_i_mci, event%selected_i_term) evt => evt%next end do evt => event%transform_first if (debug_on) call msg_debug (D_TRANSFORMS, "Before event transformations") if (debug_on) call msg_debug (D_TRANSFORMS, "event%weight_prc", event%weight_prc) if (debug_on) call msg_debug (D_TRANSFORMS, "event%sqme_prc", event%sqme_prc) do while (associated (evt)) call print_transform_name_if_debug () if (evt%only_weighted_events) then select type (evt) type is (evt_nlo_t) failed_but_keep = .not. evt%is_valid_event (evt%get_i_term ()) & .and. evt%keep_failed_events if (.not. any(evt%process_instance%term%passed .and. evt%process_instance%term%active) & .and. .not. evt%keep_failed_events) return end select if (abs (event%weight_prc) > 0._default) then weight_over_sqme = event%weight_prc / event%sqme_prc call evt%generate_weighted (event%sqme_prc) event%weight_prc = weight_over_sqme * event%sqme_prc select type (evt) type is (evt_nlo_t) if (.not. evt%is_valid_event (evt%get_i_term ())) event%weight_prc = 0 end select else if (.not. failed_but_keep) exit end if else call evt%generate_unweighted () end if if (signal_is_pending ()) return call evt%make_particle_set (event%config%factorization_mode, & event%config%keep_correlations) if (signal_is_pending ()) return if (.not. evt%particle_set_exists) exit evt => evt%next end do evt => event%transform_last if ((associated (evt) .and. evt%particle_set_exists) .or. failed_but_keep) then if (event%is_nlo ()) then select type (evt) type is (evt_nlo_t) if (evt%i_evaluation > 0) then evt%particle_set_radiated (event%i_event + 1) = evt%particle_set else call evt%keep_and_boost_born_particle_set (event%i_event + 1) end if evt%i_evaluation = evt%i_evaluation + 1 call event%link_particle_set & (evt%particle_set_radiated(event%i_event + 1)) end select else call event%link_particle_set (evt%particle_set) end if end if if (debug_on) call msg_debug (D_TRANSFORMS, "After event transformations") if (debug_on) call msg_debug (D_TRANSFORMS, "event%weight_prc", event%weight_prc) if (debug_on) call msg_debug (D_TRANSFORMS, "event%sqme_prc", event%sqme_prc) if (debug_on) call msg_debug (D_TRANSFORMS, "evt%particle_set_exists", evt%particle_set_exists) end if contains subroutine print_transform_name_if_debug () if (debug_active (D_TRANSFORMS)) then print *, 'Current event transform: ' call evt%write_name () end if end subroutine print_transform_name_if_debug end subroutine event_evaluate_transforms @ %def event_evaluate_transforms @ Set / increment the event index for the current event. There is no condition for this to happen. The event index is actually stored in the subevent expression, because this allows us to access it in subevent expressions as a variable. <>= procedure :: set_index => event_set_index procedure :: increment_index => event_increment_index <>= subroutine event_set_index (event, index) class(event_t), intent(inout) :: event integer, intent(in) :: index call event%expr%set_event_index (index) end subroutine event_set_index subroutine event_increment_index (event, offset) class(event_t), intent(inout) :: event integer, intent(in), optional :: offset call event%expr%increment_event_index (offset) end subroutine event_increment_index @ %def event_set_index @ %def event_increment_index @ Evaluate the event-related expressions, given a valid [[particle_set]]. If [[update_sqme]] is set, we use the process instance for the [[sqme_prc]] value. The [[sqme_ref]] value is always taken from the event record. <>= procedure :: evaluate_expressions => event_evaluate_expressions <>= subroutine event_evaluate_expressions (event) class(event_t), intent(inout) :: event if (event%has_valid_particle_set ()) then call event%expr%fill_subevt (event%get_particle_set_ptr ()) end if if (event%weight_ref_is_known ()) then call event%expr%set (weight_ref = event%get_weight_ref ()) end if if (event%weight_prc_is_known ()) then call event%expr%set (weight_prc = event%get_weight_prc ()) end if if (event%excess_prc_is_known ()) then call event%expr%set (excess_prc = event%get_excess_prc ()) end if if (event%sqme_ref_is_known ()) then call event%expr%set (sqme_ref = event%get_sqme_ref ()) end if if (event%sqme_prc_is_known ()) then call event%expr%set (sqme_prc = event%get_sqme_prc ()) end if if (event%has_valid_particle_set ()) then call event%expr%evaluate & (event%passed, event%reweight, event%analysis_flag) event%selection_evaluated = .true. end if end subroutine event_evaluate_expressions @ %def event_evaluate_expressions @ Report the result of the [[selection]] evaluation. <>= procedure :: passed_selection => event_passed_selection <>= function event_passed_selection (event) result (flag) class(event_t), intent(in) :: event logical :: flag flag = event%passed end function event_passed_selection @ %def event_passed_selection @ Set alternate sqme and weight arrays. This should be merged with the previous routine, if the expressions are allowed to refer to these values. <>= procedure :: store_alt_values => event_store_alt_values <>= subroutine event_store_alt_values (event) class(event_t), intent(inout) :: event if (event%weight_alt_is_known ()) then call event%expr%set (weight_alt = event%get_weight_alt ()) end if if (event%sqme_alt_is_known ()) then call event%expr%set (sqme_alt = event%get_sqme_alt ()) end if end subroutine event_store_alt_values @ %def event_store_alt_values @ <>= procedure :: is_nlo => event_is_nlo <>= function event_is_nlo (event) result (is_nlo) logical :: is_nlo class(event_t), intent(in) :: event if (associated (event%instance)) then select type (pcm => event%instance%pcm) type is (pcm_instance_nlo_t) is_nlo = pcm%is_fixed_order_nlo_events () class default is_nlo = .false. end select else is_nlo = .false. end if end function event_is_nlo @ %def event_is_nlo @ \subsection{Reset to empty state} Applying this, current event contents are marked as incomplete but are not deleted. In particular, the initialization is kept. The event index is also kept, this can be reset separately. <>= procedure :: reset_contents => event_reset_contents procedure :: reset_index => event_reset_index <>= subroutine event_reset_contents (event) class(event_t), intent(inout) :: event class(evt_t), pointer :: evt call event%base_reset_contents () event%selected_i_mci = 0 event%selected_i_term = 0 event%selected_channel = 0 event%is_complete = .false. call event%expr%reset_contents () event%selection_evaluated = .false. event%passed = .false. event%analysis_flag = .false. if (associated (event%instance)) then call event%instance%reset (reset_mci = .true.) end if if (allocated (event%alpha_qcd_forced)) deallocate (event%alpha_qcd_forced) if (allocated (event%scale_forced)) deallocate (event%scale_forced) evt => event%transform_first do while (associated (evt)) call evt%reset () evt => evt%next end do end subroutine event_reset_contents subroutine event_reset_index (event) class(event_t), intent(inout) :: event call event%expr%reset_event_index () end subroutine event_reset_index @ %def event_reset_contents @ %def event_reset_index @ \subsection{Squared Matrix Element and Weight} Transfer the result of the process instance calculation to the event record header. <>= procedure :: import_instance_results => event_import_instance_results <>= subroutine event_import_instance_results (event) class(event_t), intent(inout) :: event if (associated (event%instance)) then if (event%instance%has_evaluated_trace ()) then call event%set ( & sqme_prc = event%instance%get_sqme (), & weight_prc = event%instance%get_weight (), & excess_prc = event%instance%get_excess (), & n_dropped = event%instance%get_n_dropped () & ) end if end if end subroutine event_import_instance_results @ %def event_import_instance_results @ Duplicate the instance result / the reference result in the event record. <>= procedure :: accept_sqme_ref => event_accept_sqme_ref procedure :: accept_sqme_prc => event_accept_sqme_prc procedure :: accept_weight_ref => event_accept_weight_ref procedure :: accept_weight_prc => event_accept_weight_prc <>= subroutine event_accept_sqme_ref (event) class(event_t), intent(inout) :: event if (event%sqme_ref_is_known ()) then call event%set (sqme_prc = event%get_sqme_ref ()) end if end subroutine event_accept_sqme_ref subroutine event_accept_sqme_prc (event) class(event_t), intent(inout) :: event if (event%sqme_prc_is_known ()) then call event%set (sqme_ref = event%get_sqme_prc ()) end if end subroutine event_accept_sqme_prc subroutine event_accept_weight_ref (event) class(event_t), intent(inout) :: event if (event%weight_ref_is_known ()) then call event%set (weight_prc = event%get_weight_ref ()) end if end subroutine event_accept_weight_ref subroutine event_accept_weight_prc (event) class(event_t), intent(inout) :: event if (event%weight_prc_is_known ()) then call event%set (weight_ref = event%get_weight_prc ()) end if end subroutine event_accept_weight_prc @ %def event_accept_sqme_ref @ %def event_accept_sqme_prc @ %def event_accept_weight_ref @ %def event_accept_weight_prc @ Update the weight normalization, just after generation. Unweighted and weighted events are generated with a different default normalization. The intended normalization is stored in the configuration record. <>= procedure :: update_normalization => event_update_normalization <>= subroutine event_update_normalization (event, mode_ref) class(event_t), intent(inout) :: event integer, intent(in), optional :: mode_ref integer :: mode_old real(default) :: weight, excess if (present (mode_ref)) then mode_old = mode_ref else if (event%config%unweighted) then mode_old = NORM_UNIT else mode_old = NORM_SIGMA end if weight = event%get_weight_prc () call event_normalization_update (weight, & event%config%sigma, event%config%n, & mode_new = event%config%norm_mode, & mode_old = mode_old) call event%set_weight_prc (weight) excess = event%get_excess_prc () call event_normalization_update (excess, & event%config%sigma, event%config%n, & mode_new = event%config%norm_mode, & mode_old = mode_old) call event%set_excess_prc (excess) end subroutine event_update_normalization @ %def event_update_normalization @ The event is complete if it has a particle set plus valid entries for the sqme and weight values. <>= procedure :: check => event_check <>= subroutine event_check (event) class(event_t), intent(inout) :: event event%is_complete = event%has_valid_particle_set () & .and. event%sqme_ref_is_known () & .and. event%sqme_prc_is_known () & .and. event%weight_ref_is_known () & .and. event%weight_prc_is_known () if (event%get_n_alt () /= 0) then event%is_complete = event%is_complete & .and. event%sqme_alt_is_known () & .and. event%weight_alt_is_known () end if end subroutine event_check @ %def event_check @ @ \subsection{Generation} Assuming that we have a valid process associated to the event, we generate an event. We complete the event data, then factorize the spin density matrix and transfer it to the particle set. When done, we retrieve squared matrix element and weight. In case of explicit generation, the reference values coincide with the process values, so we [[accept]] the latter. The explicit random number argument [[r]] should be generated by a random-number generator. It is taken for the factorization algorithm, bypassing the event-specific random-number generator. This is useful for deterministic testing. <>= procedure :: generate => event_generate <>= subroutine event_generate (event, i_mci, r, i_nlo) class(event_t), intent(inout) :: event integer, intent(in) :: i_mci real(default), dimension(:), intent(in), optional :: r integer, intent(in), optional :: i_nlo logical :: generate_new generate_new = .true. if (present (i_nlo)) generate_new = (i_nlo == 1) if (generate_new) call event%reset_contents () event%selected_i_mci = i_mci if (event%config%unweighted) then call event%instance%generate_unweighted_event (i_mci) if (signal_is_pending ()) return call event%instance%evaluate_event_data () call event%instance%normalize_weight () else if (generate_new) & call event%instance%generate_weighted_event (i_mci) if (signal_is_pending ()) return call event%instance%evaluate_event_data () end if event%selected_channel = event%instance%get_channel () call event%import_instance_results () call event%accept_sqme_prc () call event%update_normalization () call event%accept_weight_prc () call event%evaluate_transforms (r) if (signal_is_pending ()) return call event%check () end subroutine event_generate @ %def event_generate @ Get a copy of the particle set belonging to the hard process. <>= procedure :: get_hard_particle_set => event_get_hard_particle_set <>= subroutine event_get_hard_particle_set (event, pset) class(event_t), intent(in) :: event type(particle_set_t), intent(out) :: pset class(evt_t), pointer :: evt evt => event%transform_first pset = evt%particle_set end subroutine event_get_hard_particle_set @ %def event_get_hard_particle_set @ \subsection{Recovering an event} Select MC group, term, and integration channel. <>= procedure :: select => event_select <>= subroutine event_select (event, i_mci, i_term, channel) class(event_t), intent(inout) :: event integer, intent(in) :: i_mci, i_term, channel if (associated (event%instance)) then event%selected_i_mci = i_mci event%selected_i_term = i_term event%selected_channel = channel else event%selected_i_mci = 0 event%selected_i_term = 0 event%selected_channel = 0 end if end subroutine event_select @ %def event_select @ Copy a particle set into the event record. We deliberately use the first (the trivial) transform for this, i.e., the hard process. The event reader may either read in the transformed event separately, or apply all event transforms to the hard particle set to (re)generate a fully dressed event. Since this makes all subsequent event transforms invalid, we call [[reset]] on them. <>= procedure :: set_hard_particle_set => event_set_hard_particle_set <>= subroutine event_set_hard_particle_set (event, particle_set) class(event_t), intent(inout) :: event type(particle_set_t), intent(in) :: particle_set class(evt_t), pointer :: evt evt => event%transform_first call evt%set_particle_set (particle_set, & event%selected_i_mci, event%selected_i_term) call event%link_particle_set (evt%particle_set) evt => evt%next do while (associated (evt)) call evt%reset () evt => evt%next end do end subroutine event_set_hard_particle_set @ %def event_set_hard_particle_set @ Set the $\alpha_s$ value that should be used in a recalculation. This should be called only if we explicitly want to override the QCD setting of the process core. <>= procedure :: set_alpha_qcd_forced => event_set_alpha_qcd_forced <>= subroutine event_set_alpha_qcd_forced (event, alpha_qcd) class(event_t), intent(inout) :: event real(default), intent(in) :: alpha_qcd if (allocated (event%alpha_qcd_forced)) then event%alpha_qcd_forced = alpha_qcd else allocate (event%alpha_qcd_forced, source = alpha_qcd) end if end subroutine event_set_alpha_qcd_forced @ %def event_set_alpha_qcd_forced @ Analogously, for the common scale. This forces also renormalization and factorization scale. <>= procedure :: set_scale_forced => event_set_scale_forced <>= subroutine event_set_scale_forced (event, scale) class(event_t), intent(inout) :: event real(default), intent(in) :: scale if (allocated (event%scale_forced)) then event%scale_forced = scale else allocate (event%scale_forced, source = scale) end if end subroutine event_set_scale_forced @ %def event_set_scale_forced @ Here we try to recover an event from the [[particle_set]] subobject and recalculate the structure functions and matrix elements. We have the appropriate [[process]] object and an initialized [[process_instance]] at hand, so beam and configuration data are known. From the [[particle_set]], we get the momenta. The quantum-number information may be incomplete, e.g., helicity information may be partial or absent. We recover the event just from the momentum configuration. We do not transfer the matrix element from the process instance to the event record, as we do when generating an event. The event record may contain the matrix element as read from file, and the current calculation may use different parameters. We thus can compare old and new values. The event [[weight]] may also be known already. If yes, we pass it to the [[evaluate_event_data]] procedure. It should already be normalized. If we have an [[weight_factor]] value, we obtain the event weight by multiplying the computed [[sqme]] by this factor. Otherwise, we make use of the MCI setup (which should be valid then) to compute the event weight, and we should normalize the result just as when generating events. Evaluating event expressions must also be done separately. If [[recover_phs]] is set (and false), do not attempt any phase-space calculation, including MCI evaluation. Useful if we need only matrix elements. <>= procedure :: recalculate => event_recalculate <>= subroutine event_recalculate & (event, update_sqme, weight_factor, recover_beams, recover_phs) class(event_t), intent(inout) :: event logical, intent(in) :: update_sqme real(default), intent(in), optional :: weight_factor logical, intent(in), optional :: recover_beams logical, intent(in), optional :: recover_phs type(particle_set_t), pointer :: particle_set integer :: i_mci, i_term, channel logical :: rec_phs_mci rec_phs_mci = .true.; if (present (recover_phs)) rec_phs_mci = recover_phs if (event%has_valid_particle_set ()) then particle_set => event%get_particle_set_ptr () i_mci = event%selected_i_mci i_term = event%selected_i_term channel = event%selected_channel if (i_mci == 0 .or. i_term == 0 .or. channel == 0) then call msg_bug ("Event: recalculate: undefined selection parameters") end if call event%instance%choose_mci (i_mci) call event%instance%set_trace (particle_set, i_term, recover_beams) if (allocated (event%alpha_qcd_forced)) then call event%instance%set_alpha_qcd_forced & (i_term, event%alpha_qcd_forced) end if call event%instance%recover (channel, i_term, & update_sqme, rec_phs_mci, event%scale_forced) if (signal_is_pending ()) return if (update_sqme .and. present (weight_factor)) then call event%instance%evaluate_event_data & (weight = event%instance%get_sqme () * weight_factor) else if (event%weight_ref_is_known ()) then call event%instance%evaluate_event_data & (weight = event%get_weight_ref ()) else if (rec_phs_mci) then call event%instance%recover_event () if (signal_is_pending ()) return call event%instance%evaluate_event_data () if (event%config%unweighted) then call event%instance%normalize_weight () end if end if if (signal_is_pending ()) return if (update_sqme) then call event%import_instance_results () else call event%accept_sqme_ref () call event%accept_weight_ref () end if else call msg_bug ("Event: can't recalculate, particle set is undefined") end if end subroutine event_recalculate @ %def event_recalculate @ \subsection{Access content} Pointer to the associated process object (the associated model). <>= procedure :: get_process_ptr => event_get_process_ptr procedure :: get_process_instance_ptr => event_get_process_instance_ptr procedure :: get_model_ptr => event_get_model_ptr <>= function event_get_process_ptr (event) result (ptr) class(event_t), intent(in) :: event type(process_t), pointer :: ptr ptr => event%process end function event_get_process_ptr function event_get_process_instance_ptr (event) result (ptr) class(event_t), intent(in) :: event type(process_instance_t), pointer :: ptr ptr => event%instance end function event_get_process_instance_ptr function event_get_model_ptr (event) result (model) class(event_t), intent(in) :: event class(model_data_t), pointer :: model if (associated (event%process)) then model => event%process%get_model_ptr () else model => null () end if end function event_get_model_ptr @ %def event_get_process_ptr @ %def event_get_process_instance_ptr @ %def event_get_model_ptr @ Return the current values of indices: the MCI group of components, the term index (different terms corresponding, potentially, to different effective kinematics), and the MC integration channel. The [[i_mci]] call is delegated to the current process instance. <>= procedure :: get_i_mci => event_get_i_mci procedure :: get_i_term => event_get_i_term procedure :: get_channel => event_get_channel <>= function event_get_i_mci (event) result (i_mci) class(event_t), intent(in) :: event integer :: i_mci i_mci = event%selected_i_mci end function event_get_i_mci function event_get_i_term (event) result (i_term) class(event_t), intent(in) :: event integer :: i_term i_term = event%selected_i_term end function event_get_i_term function event_get_channel (event) result (channel) class(event_t), intent(in) :: event integer :: channel channel = event%selected_channel end function event_get_channel @ %def event_get_i_mci @ %def event_get_i_term @ %def event_get_channel @ This flag tells us whether the event consists just of a hard process (i.e., holds at most the first, trivial transform), or is a dressed events with additional transforms. <>= procedure :: has_transform => event_has_transform <>= function event_has_transform (event) result (flag) class(event_t), intent(in) :: event logical :: flag if (associated (event%transform_first)) then flag = associated (event%transform_first%next) else flag = .false. end if end function event_has_transform @ %def event_has_transform @ Return the currently selected normalization mode, or alternate normalization mode. <>= procedure :: get_norm_mode => event_get_norm_mode <>= elemental function event_get_norm_mode (event) result (norm_mode) class(event_t), intent(in) :: event integer :: norm_mode norm_mode = event%config%norm_mode end function event_get_norm_mode @ %def event_get_norm_mode @ Return the kinematical weight, defined as the ratio of event weight and squared matrix element. <>= procedure :: get_kinematical_weight => event_get_kinematical_weight <>= function event_get_kinematical_weight (event) result (f) class(event_t), intent(in) :: event real(default) :: f if (event%sqme_ref_is_known () .and. event%weight_ref_is_known () & .and. abs (event%get_sqme_ref ()) > 0) then f = event%get_weight_ref () / event%get_sqme_ref () else f = 0 end if end function event_get_kinematical_weight @ %def event_get_kinematical_weight @ Return data used by external event formats. <>= procedure :: has_index => event_has_index procedure :: get_index => event_get_index procedure :: get_fac_scale => event_get_fac_scale procedure :: get_alpha_s => event_get_alpha_s procedure :: get_sqrts => event_get_sqrts procedure :: get_polarization => event_get_polarization procedure :: get_beam_file => event_get_beam_file procedure :: get_process_name => event_get_process_name <>= function event_has_index (event) result (flag) class(event_t), intent(in) :: event logical :: flag flag = event%expr%has_event_index () end function event_has_index function event_get_index (event) result (index) class(event_t), intent(in) :: event integer :: index index = event%expr%get_event_index () end function event_get_index function event_get_fac_scale (event) result (fac_scale) class(event_t), intent(in) :: event real(default) :: fac_scale fac_scale = event%instance%get_fac_scale (event%selected_i_term) end function event_get_fac_scale function event_get_alpha_s (event) result (alpha_s) class(event_t), intent(in) :: event real(default) :: alpha_s alpha_s = event%instance%get_alpha_s (event%selected_i_term) end function event_get_alpha_s function event_get_sqrts (event) result (sqrts) class(event_t), intent(in) :: event real(default) :: sqrts sqrts = event%instance%get_sqrts () end function event_get_sqrts function event_get_polarization (event) result (pol) class(event_t), intent(in) :: event real(default), dimension(2) :: pol pol = event%instance%get_polarization () end function event_get_polarization function event_get_beam_file (event) result (file) class(event_t), intent(in) :: event type(string_t) :: file file = event%instance%get_beam_file () end function event_get_beam_file function event_get_process_name (event) result (name) class(event_t), intent(in) :: event type(string_t) :: name name = event%instance%get_process_name () end function event_get_process_name @ %def event_get_index @ %def event_get_fac_scale @ %def event_get_alpha_s @ %def event_get_sqrts @ %def event_get_polarization @ %def event_get_beam_file @ %def event_get_process_name @ Return the actual number of calls, as stored in the process instance. <>= procedure :: get_actual_calls_total => event_get_actual_calls_total <>= elemental function event_get_actual_calls_total (event) result (n) class(event_t), intent(in) :: event integer :: n if (associated (event%instance)) then n = event%instance%get_actual_calls_total () else n = 0 end if end function event_get_actual_calls_total @ %def event_get_actual_calls_total @ Eliminate numerical noise in the [[subevt]] expression and in the event transforms (which includes associated process instances). <>= public :: pacify <>= interface pacify module procedure pacify_event end interface pacify <>= subroutine pacify_event (event) class(event_t), intent(inout) :: event class(evt_t), pointer :: evt call event%pacify_particle_set () if (event%expr%subevt_filled) call pacify (event%expr) evt => event%transform_first do while (associated (evt)) select type (evt) type is (evt_decay_t); call pacify (evt) end select evt => evt%next end do end subroutine pacify_event @ %def pacify @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[events_ut.f90]]>>= <> module events_ut use unit_tests use events_uti <> <> contains <> end module events_ut @ %def events_ut @ <<[[events_uti.f90]]>>= <> module events_uti <> <> use os_interface use model_data use particles use process_libraries use process_stacks use event_transforms use decays use decays_ut, only: prepare_testbed use process, only: process_t use instances, only: process_instance_t use events <> <> contains <> end module events_uti @ %def events_uti @ API: driver for the unit tests below. <>= public :: events_test <>= subroutine events_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine events_test @ %def events_test @ \subsubsection{Empty event record} <>= call test (events_1, "events_1", & "empty event record", & u, results) <>= public :: events_1 <>= subroutine events_1 (u) integer, intent(in) :: u type(event_t), target :: event write (u, "(A)") "* Test output: events_1" write (u, "(A)") "* Purpose: display an empty event object" write (u, "(A)") call event%write (u) write (u, "(A)") write (u, "(A)") "* Test output end: events_1" end subroutine events_1 @ %def events_1 @ \subsubsection{Simple event} <>= call test (events_2, "events_2", & "generate event", & u, results) <>= public :: events_2 <>= subroutine events_2 (u) use processes_ut, only: prepare_test_process, cleanup_test_process integer, intent(in) :: u type(event_t), allocatable, target :: event type(process_t), allocatable, target :: process type(process_instance_t), allocatable, target :: process_instance type(model_data_t), target :: model write (u, "(A)") "* Test output: events_2" write (u, "(A)") "* Purpose: generate and display an event" write (u, "(A)") call model%init_test () write (u, "(A)") "* Generate test process event" allocate (process) allocate (process_instance) call prepare_test_process (process, process_instance, model) call process_instance%setup_event_data () write (u, "(A)") write (u, "(A)") "* Initialize event object" allocate (event) call event%basic_init () call event%connect (process_instance, process%get_model_ptr ()) write (u, "(A)") write (u, "(A)") "* Generate test process event" call process_instance%generate_weighted_event (1) write (u, "(A)") write (u, "(A)") "* Fill event object" write (u, "(A)") call event%generate (1, [0.4_default, 0.4_default]) call event%increment_index () call event%evaluate_expressions () call event%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call event%final () deallocate (event) call cleanup_test_process (process, process_instance) deallocate (process_instance) deallocate (process) call model%final () write (u, "(A)") write (u, "(A)") "* Test output end: events_2" end subroutine events_2 @ %def events_2 @ \subsubsection{Recovering an event} Generate an event and store the particle set. Then reset the event record, recall the particle set, and recover the event from that. <>= call test (events_4, "events_4", & "recover event", & u, results) <>= public :: events_4 <>= subroutine events_4 (u) use processes_ut, only: prepare_test_process, cleanup_test_process integer, intent(in) :: u type(event_t), allocatable, target :: event type(process_t), allocatable, target :: process type(process_instance_t), allocatable, target :: process_instance type(process_t), allocatable, target :: process2 type(process_instance_t), allocatable, target :: process2_instance type(particle_set_t) :: particle_set type(model_data_t), target :: model write (u, "(A)") "* Test output: events_4" write (u, "(A)") "* Purpose: generate and recover an event" write (u, "(A)") call model%init_test () write (u, "(A)") "* Generate test process event and save particle set" write (u, "(A)") allocate (process) allocate (process_instance) call prepare_test_process (process, process_instance, model) call process_instance%setup_event_data () allocate (event) call event%basic_init () call event%connect (process_instance, process%get_model_ptr ()) call event%generate (1, [0.4_default, 0.4_default]) call event%increment_index () call event%evaluate_expressions () call event%write (u) particle_set = event%get_particle_set_ptr () ! NB: 'particle_set' contains pointers to the model within 'process' call event%final () deallocate (event) write (u, "(A)") write (u, "(A)") "* Recover event from particle set" write (u, "(A)") allocate (process2) allocate (process2_instance) call prepare_test_process (process2, process2_instance, model) call process2_instance%setup_event_data () allocate (event) call event%basic_init () call event%connect (process2_instance, process2%get_model_ptr ()) call event%select (1, 1, 1) call event%set_hard_particle_set (particle_set) call event%recalculate (update_sqme = .true.) call event%write (u) write (u, "(A)") write (u, "(A)") "* Transfer sqme and evaluate expressions" write (u, "(A)") call event%accept_sqme_prc () call event%accept_weight_prc () call event%check () call event%set_index (1) call event%evaluate_expressions () call event%write (u) write (u, "(A)") write (u, "(A)") "* Reset contents" write (u, "(A)") call event%reset_contents () call event%reset_index () event%transform_first%particle_set_exists = .false. call event%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call particle_set%final () call event%final () deallocate (event) call cleanup_test_process (process2, process2_instance) deallocate (process2_instance) deallocate (process2) call cleanup_test_process (process, process_instance) deallocate (process_instance) deallocate (process) call model%final () write (u, "(A)") write (u, "(A)") "* Test output end: events_4" end subroutine events_4 @ %def events_4 @ \subsubsection{Partially Recovering an event} Generate an event and store the particle set. Then reset the event record, recall the particle set, and recover the event as far as possible without recomputing the squared matrix element. <>= call test (events_5, "events_5", & "partially recover event", & u, results) <>= public :: events_5 <>= subroutine events_5 (u) use processes_ut, only: prepare_test_process, cleanup_test_process integer, intent(in) :: u type(event_t), allocatable, target :: event type(process_t), allocatable, target :: process type(process_instance_t), allocatable, target :: process_instance type(process_t), allocatable, target :: process2 type(process_instance_t), allocatable, target :: process2_instance type(particle_set_t) :: particle_set real(default) :: sqme, weight type(model_data_t), target :: model write (u, "(A)") "* Test output: events_5" write (u, "(A)") "* Purpose: generate and recover an event" write (u, "(A)") call model%init_test () write (u, "(A)") "* Generate test process event and save particle set" write (u, "(A)") allocate (process) allocate (process_instance) call prepare_test_process (process, process_instance, model) call process_instance%setup_event_data () allocate (event) call event%basic_init () call event%connect (process_instance, process%get_model_ptr ()) call event%generate (1, [0.4_default, 0.4_default]) call event%increment_index () call event%evaluate_expressions () call event%write (u) particle_set = event%get_particle_set_ptr () sqme = event%get_sqme_ref () weight = event%get_weight_ref () call event%final () deallocate (event) write (u, "(A)") write (u, "(A)") "* Recover event from particle set" write (u, "(A)") allocate (process2) allocate (process2_instance) call prepare_test_process (process2, process2_instance, model) call process2_instance%setup_event_data () allocate (event) call event%basic_init () call event%connect (process2_instance, process2%get_model_ptr ()) call event%select (1, 1, 1) call event%set_hard_particle_set (particle_set) call event%recalculate (update_sqme = .false.) call event%write (u) write (u, "(A)") write (u, "(A)") "* Manually set sqme and evaluate expressions" write (u, "(A)") call event%set (sqme_ref = sqme, weight_ref = weight) call event%accept_sqme_ref () call event%accept_weight_ref () call event%set_index (1) call event%evaluate_expressions () call event%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call particle_set%final () call event%final () deallocate (event) call cleanup_test_process (process2, process2_instance) deallocate (process2_instance) deallocate (process2) call cleanup_test_process (process, process_instance) deallocate (process_instance) deallocate (process) call model%final () write (u, "(A)") write (u, "(A)") "* Test output end: events_5" end subroutine events_5 @ %def events_5 @ \subsubsection{Decays} Generate an event with subsequent decays. <>= call test (events_6, "events_6", & "decays", & u, results) <>= public :: events_6 <>= subroutine events_6 (u) integer, intent(in) :: u type(os_data_t) :: os_data class(model_data_t), pointer :: model type(string_t) :: prefix, procname1, procname2 type(process_library_t), target :: lib type(process_stack_t) :: process_stack class(evt_t), pointer :: evt_decay type(event_t), allocatable, target :: event type(process_t), pointer :: process type(process_instance_t), allocatable, target :: process_instance write (u, "(A)") "* Test output: events_6" write (u, "(A)") "* Purpose: generate an event with subsequent decays" write (u, "(A)") write (u, "(A)") "* Generate test process and decay" write (u, "(A)") call os_data%init () prefix = "events_6" procname1 = prefix // "_p" procname2 = prefix // "_d" call prepare_testbed & (lib, process_stack, prefix, os_data, & scattering=.true., decay=.true.) write (u, "(A)") "* Initialize decay process" process => process_stack%get_process_ptr (procname1) model => process%get_model_ptr () call model%set_unstable (25, [procname2]) allocate (process_instance) call process_instance%init (process) call process_instance%setup_event_data () call process_instance%init_simulation (1) write (u, "(A)") write (u, "(A)") "* Initialize event transform: decay" allocate (evt_decay_t :: evt_decay) call evt_decay%connect (process_instance, model, process_stack) write (u, "(A)") write (u, "(A)") "* Initialize event object" write (u, "(A)") allocate (event) call event%basic_init () call event%connect (process_instance, model) call event%import_transform (evt_decay) call event%write (u, show_decay = .true.) write (u, "(A)") write (u, "(A)") "* Generate event" write (u, "(A)") call event%generate (1, [0.4_default, 0.4_default]) call event%increment_index () call event%evaluate_expressions () call event%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call event%final () deallocate (event) call process_instance%final () deallocate (process_instance) call process_stack%final () write (u, "(A)") write (u, "(A)") "* Test output end: events_6" end subroutine events_6 @ %def events_6 @ \subsubsection{Decays} Generate a decay event with varying options. <>= call test (events_7, "events_7", & "decay options", & u, results) <>= public :: events_7 <>= subroutine events_7 (u) integer, intent(in) :: u type(os_data_t) :: os_data class(model_data_t), pointer :: model type(string_t) :: prefix, procname2 type(process_library_t), target :: lib type(process_stack_t) :: process_stack type(process_t), pointer :: process type(process_instance_t), allocatable, target :: process_instance write (u, "(A)") "* Test output: events_7" write (u, "(A)") "* Purpose: check decay options" write (u, "(A)") write (u, "(A)") "* Prepare test process" write (u, "(A)") call os_data%init () prefix = "events_7" procname2 = prefix // "_d" call prepare_testbed & (lib, process_stack, prefix, os_data, & scattering=.false., decay=.true.) write (u, "(A)") "* Generate decay event, default options" write (u, "(A)") process => process_stack%get_process_ptr (procname2) model => process%get_model_ptr () call model%set_unstable (25, [procname2]) allocate (process_instance) call process_instance%init (process) call process_instance%setup_event_data (model) call process_instance%init_simulation (1) call process_instance%generate_weighted_event (1) call process_instance%write (u) call process_instance%final () deallocate (process_instance) write (u, "(A)") write (u, "(A)") "* Generate decay event, helicity-diagonal decay" write (u, "(A)") process => process_stack%get_process_ptr (procname2) model => process%get_model_ptr () call model%set_unstable (25, [procname2], diagonal = .true.) allocate (process_instance) call process_instance%init (process) call process_instance%setup_event_data (model) call process_instance%init_simulation (1) call process_instance%generate_weighted_event (1) call process_instance%write (u) call process_instance%final () deallocate (process_instance) write (u, "(A)") write (u, "(A)") "* Generate decay event, isotropic decay, & &polarized final state" write (u, "(A)") process => process_stack%get_process_ptr (procname2) model => process%get_model_ptr () call model%set_unstable (25, [procname2], isotropic = .true.) call model%set_polarized (6) call model%set_polarized (-6) allocate (process_instance) call process_instance%init (process) call process_instance%setup_event_data (model) call process_instance%init_simulation (1) call process_instance%generate_weighted_event (1) call process_instance%write (u) call process_instance%final () deallocate (process_instance) write (u, "(A)") write (u, "(A)") "* Cleanup" call process_stack%final () write (u, "(A)") write (u, "(A)") "* Test output end: events_7" end subroutine events_7 @ %def events_7 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Raw Event I/O} The raw format is for internal use only. All data are stored unformatted, so they can be efficiently be re-read on the same machine, but not necessarily on another machine. This module explicitly depends on the [[events]] module which provides the concrete implementation of [[event_base]]. The other I/O formats access only the methods that are defined in [[event_base]]. <<[[eio_raw.f90]]>>= <> module eio_raw <> <> use io_units use diagnostics use model_data use particles use event_base + use event_handles, only: event_handle_t use eio_data use eio_base use events <> <> <> <> contains <> end module eio_raw @ %def eio_raw @ \subsection{File Format Version} This is the current default file version. <>= integer, parameter :: CURRENT_FILE_VERSION = 2 @ %def CURRENT_FILE_VERSION @ The user may change this number; this should force some compatibility mode for reading and writing. In any case, the file version stored in a event file that we read has to match the expected file version. History of version numbers: \begin{enumerate} \item Format for WHIZARD 2.2.0 to 2.2.3. No version number stored in the raw file. \item Format from 2.2.4 on. File contains version number. The file contains the transformed particle set (if applicable) after the hard-process particle set. \end{enumerate} @ \subsection{Type} Note the file version number. The default may be reset during initialization, which should enforce some compatibility mode. <>= public :: eio_raw_t <>= type, extends (eio_t) :: eio_raw_t logical :: reading = .false. logical :: writing = .false. integer :: unit = 0 integer :: norm_mode = NORM_UNDEFINED real(default) :: sigma = 1 integer :: n = 1 integer :: n_alt = 0 logical :: check = .false. logical :: use_alphas_from_file = .false. logical :: use_scale_from_file = .false. integer :: file_version = CURRENT_FILE_VERSION contains <> end type eio_raw_t @ %def eio_raw_t @ Output. This is not the actual event format, but a readable account of the current object status. <>= procedure :: write => eio_raw_write <>= subroutine eio_raw_write (object, unit) class(eio_raw_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A)") "Raw event stream:" write (u, "(3x,A,L1)") "Check MD5 sum = ", object%check if (object%n_alt > 0) then write (u, "(3x,A,I0)") "Alternate weights = ", object%n_alt end if write (u, "(3x,A,L1)") "Alpha_s from file = ", & object%use_alphas_from_file write (u, "(3x,A,L1)") "Scale from file = ", & object%use_scale_from_file if (object%reading) then write (u, "(3x,A,A)") "Reading from file = ", char (object%filename) else if (object%writing) then write (u, "(3x,A,A)") "Writing to file = ", char (object%filename) else write (u, "(3x,A)") "[closed]" end if end subroutine eio_raw_write @ %def eio_raw_write @ Finalizer: close any open file. <>= procedure :: final => eio_raw_final <>= subroutine eio_raw_final (object) class(eio_raw_t), intent(inout) :: object if (object%reading .or. object%writing) then write (msg_buffer, "(A,A,A)") "Events: closing raw file '", & char (object%filename), "'" call msg_message () close (object%unit) object%reading = .false. object%writing = .false. end if end subroutine eio_raw_final @ %def eio_raw_final @ Set the [[check]] flag which determines whether we compare checksums on input. <>= procedure :: set_parameters => eio_raw_set_parameters <>= subroutine eio_raw_set_parameters (eio, check, use_alphas_from_file, & use_scale_from_file, version_string, extension) class(eio_raw_t), intent(inout) :: eio logical, intent(in), optional :: check, use_alphas_from_file, & use_scale_from_file type(string_t), intent(in), optional :: version_string type(string_t), intent(in), optional :: extension if (present (check)) eio%check = check if (present (use_alphas_from_file)) eio%use_alphas_from_file = & use_alphas_from_file if (present (use_scale_from_file)) eio%use_scale_from_file = & use_scale_from_file if (present (version_string)) then select case (char (version_string)) case ("", "2.2.4") eio%file_version = CURRENT_FILE_VERSION case ("2.2") eio%file_version = 1 case default call msg_fatal ("Raw event I/O: unsupported version '" & // char (version_string) // "'") eio%file_version = 0 end select end if if (present (extension)) then eio%extension = extension else eio%extension = "evx" end if end subroutine eio_raw_set_parameters @ %def eio_raw_set_parameters @ Initialize event writing. <>= procedure :: init_out => eio_raw_init_out <>= subroutine eio_raw_init_out (eio, sample, data, success, extension) class(eio_raw_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(event_sample_data_t), intent(in), optional :: data logical, intent(out), optional :: success type(string_t), intent(in), optional :: extension character(32) :: md5sum_prc, md5sum_cfg character(32), dimension(:), allocatable :: md5sum_alt integer :: i if (present (extension)) then eio%extension = extension else eio%extension = "evx" end if eio%filename = sample // "." // eio%extension eio%unit = free_unit () write (msg_buffer, "(A,A,A)") "Events: writing to raw file '", & char (eio%filename), "'" call msg_message () eio%writing = .true. if (present (data)) then md5sum_prc = data%md5sum_prc md5sum_cfg = data%md5sum_cfg eio%norm_mode = data%norm_mode eio%sigma = data%total_cross_section eio%n = data%n_evt eio%n_alt = data%n_alt if (eio%n_alt > 0) then !!! !!! !!! Workaround for gfortran 5.0 ICE allocate (md5sum_alt (data%n_alt)) md5sum_alt = data%md5sum_alt !!! allocate (md5sum_alt (data%n_alt), source = data%md5sum_alt) end if else md5sum_prc = "" md5sum_cfg = "" end if open (eio%unit, file = char (eio%filename), form = "unformatted", & action = "write", status = "replace") select case (eio%file_version) case (2:); write (eio%unit) eio%file_version end select write (eio%unit) md5sum_prc write (eio%unit) md5sum_cfg write (eio%unit) eio%norm_mode write (eio%unit) eio%n_alt if (allocated (md5sum_alt)) then do i = 1, eio%n_alt write (eio%unit) md5sum_alt(i) end do end if if (present (success)) success = .true. end subroutine eio_raw_init_out @ %def eio_raw_init_out @ Initialize event reading. <>= procedure :: init_in => eio_raw_init_in <>= subroutine eio_raw_init_in (eio, sample, data, success, extension) class(eio_raw_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(event_sample_data_t), intent(inout), optional :: data logical, intent(out), optional :: success type(string_t), intent(in), optional :: extension character(32) :: md5sum_prc, md5sum_cfg character(32), dimension(:), allocatable :: md5sum_alt integer :: i, file_version if (present (success)) success = .true. if (present (extension)) then eio%extension = extension else eio%extension = "evx" end if eio%filename = sample // "." // eio%extension eio%unit = free_unit () if (present (data)) then eio%sigma = data%total_cross_section eio%n = data%n_evt end if write (msg_buffer, "(A,A,A)") "Events: reading from raw file '", & char (eio%filename), "'" call msg_message () eio%reading = .true. open (eio%unit, file = char (eio%filename), form = "unformatted", & action = "read", status = "old") select case (eio%file_version) case (2:); read (eio%unit) file_version case default; file_version = 1 end select if (file_version /= eio%file_version) then call msg_error ("Reading event file: raw-file version mismatch.") if (present (success)) success = .false. return else if (file_version /= CURRENT_FILE_VERSION) then call msg_warning ("Reading event file: compatibility mode.") end if read (eio%unit) md5sum_prc read (eio%unit) md5sum_cfg read (eio%unit) eio%norm_mode read (eio%unit) eio%n_alt if (present (data)) then if (eio%n_alt /= data%n_alt) then if (present (success)) success = .false. return end if end if allocate (md5sum_alt (eio%n_alt)) do i = 1, eio%n_alt read (eio%unit) md5sum_alt(i) end do if (present (success)) then if (present (data)) then if (eio%check) then if (data%md5sum_prc /= "") then success = success .and. md5sum_prc == data%md5sum_prc end if if (data%md5sum_cfg /= "") then success = success .and. md5sum_cfg == data%md5sum_cfg end if do i = 1, eio%n_alt if (data%md5sum_alt(i) /= "") then success = success .and. md5sum_alt(i) == data%md5sum_alt(i) end if end do else call msg_warning ("Reading event file: MD5 sum check disabled") end if end if end if end subroutine eio_raw_init_in @ %def eio_raw_init_in @ Switch from input to output: reopen the file for reading. <>= procedure :: switch_inout => eio_raw_switch_inout <>= subroutine eio_raw_switch_inout (eio, success) class(eio_raw_t), intent(inout) :: eio logical, intent(out), optional :: success write (msg_buffer, "(A,A,A)") "Events: appending to raw file '", & char (eio%filename), "'" call msg_message () close (eio%unit, status = "keep") eio%reading = .false. open (eio%unit, file = char (eio%filename), form = "unformatted", & action = "write", position = "append", status = "old") eio%writing = .true. if (present (success)) success = .true. end subroutine eio_raw_switch_inout @ %def eio_raw_switch_inout @ Output an event. Write first the event indices, then weight and squared matrix element, then the particle set. We always write the particle set of the hard process. (Note: this should be reconsidered.) We do make a physical copy. On output, we write the [[prc]] values for weight and sqme, since these are the values just computed. On input, we store the values as [[ref]] values. The caller can then decide whether to recompute values and thus obtain distinct [[prc]] values, or just accept them. The [[passed]] flag is not written. This allow us to apply different selection criteria upon rereading. <>= procedure :: output => eio_raw_output <>= - subroutine eio_raw_output (eio, event, i_prc, reading, passed, pacify) + subroutine eio_raw_output & + (eio, event, i_prc, reading, passed, pacify, event_handle) class(eio_raw_t), intent(inout) :: eio class(generic_event_t), intent(in), target :: event logical, intent(in), optional :: reading, passed, pacify + class(event_handle_t), intent(inout), optional :: event_handle integer, intent(in) :: i_prc type(particle_set_t), pointer :: pset integer :: i if (eio%writing) then if (event%has_valid_particle_set ()) then select type (event) type is (event_t) write (eio%unit) i_prc write (eio%unit) event%get_index () write (eio%unit) event%get_i_mci () write (eio%unit) event%get_i_term () write (eio%unit) event%get_channel () write (eio%unit) event%expr%weight_prc write (eio%unit) event%expr%excess_prc write (eio%unit) event%get_n_dropped () write (eio%unit) event%expr%sqme_prc do i = 1, eio%n_alt write (eio%unit) event%expr%weight_alt(i) write (eio%unit) event%expr%sqme_alt(i) end do allocate (pset) call event%get_hard_particle_set (pset) call pset%write_raw (eio%unit) call pset%final () deallocate (pset) select case (eio%file_version) case (2:) if (event%has_transform ()) then write (eio%unit) .true. pset => event%get_particle_set_ptr () call pset%write_raw (eio%unit) else write (eio%unit) .false. end if end select class default call msg_bug ("Event: write raw: defined only for full event_t") end select else call msg_bug ("Event: write raw: particle set is undefined") end if else call eio%write () call msg_fatal ("Raw event file is not open for writing") end if end subroutine eio_raw_output @ %def eio_raw_output @ Input an event. Note: the particle set is physically copied. If there is a performance issue, we might choose to pointer-assign it instead, with a different version of [[event%set_hard_particle_set]]. <>= procedure :: input_i_prc => eio_raw_input_i_prc procedure :: input_event => eio_raw_input_event <>= subroutine eio_raw_input_i_prc (eio, i_prc, iostat) class(eio_raw_t), intent(inout) :: eio integer, intent(out) :: i_prc integer, intent(out) :: iostat if (eio%reading) then read (eio%unit, iostat = iostat) i_prc else call eio%write () call msg_fatal ("Raw event file is not open for reading") end if end subroutine eio_raw_input_i_prc - subroutine eio_raw_input_event (eio, event, iostat) + subroutine eio_raw_input_event (eio, event, iostat, event_handle) class(eio_raw_t), intent(inout) :: eio class(generic_event_t), intent(inout), target :: event integer, intent(out) :: iostat + class(event_handle_t), intent(inout), optional :: event_handle integer :: event_index, i_mci, i_term, channel, i real(default) :: weight, excess, sqme integer :: n_dropped real(default), dimension(:), allocatable :: weight_alt, sqme_alt logical :: has_transform type(particle_set_t), pointer :: pset class(model_data_t), pointer :: model if (eio%reading) then select type (event) type is (event_t) read (eio%unit, iostat = iostat) event_index if (iostat /= 0) return read (eio%unit, iostat = iostat) i_mci if (iostat /= 0) return read (eio%unit, iostat = iostat) i_term if (iostat /= 0) return read (eio%unit, iostat = iostat) channel if (iostat /= 0) return read (eio%unit, iostat = iostat) weight if (iostat /= 0) return read (eio%unit, iostat = iostat) excess if (iostat /= 0) return read (eio%unit, iostat = iostat) n_dropped if (iostat /= 0) return read (eio%unit, iostat = iostat) sqme if (iostat /= 0) return call event%reset_contents () call event%set_index (event_index) call event%select (i_mci, i_term, channel) if (eio%norm_mode /= NORM_UNDEFINED) then call event_normalization_update (weight, & eio%sigma, eio%n, event%get_norm_mode (), eio%norm_mode) call event_normalization_update (excess, & eio%sigma, eio%n, event%get_norm_mode (), eio%norm_mode) end if call event%set (sqme_ref = sqme, weight_ref = weight, & excess_prc = excess, & n_dropped = n_dropped) if (eio%n_alt /= 0) then allocate (sqme_alt (eio%n_alt), weight_alt (eio%n_alt)) do i = 1, eio%n_alt read (eio%unit, iostat = iostat) weight_alt(i) if (iostat /= 0) return read (eio%unit, iostat = iostat) sqme_alt(i) if (iostat /= 0) return end do call event%set (sqme_alt = sqme_alt, weight_alt = weight_alt) end if model => null () if (associated (event%process)) then model => event%process%get_model_ptr () end if allocate (pset) call pset%read_raw (eio%unit, iostat) if (iostat /= 0) return if (associated (model)) call pset%set_model (model) call event%set_hard_particle_set (pset) if (eio%use_alphas_from_file .or. eio%use_scale_from_file) then call event%recalculate (update_sqme = .true.) end if call pset%final () deallocate (pset) select case (eio%file_version) case (2:) read (eio%unit, iostat = iostat) has_transform if (iostat /= 0) return if (has_transform) then allocate (pset) call pset%read_raw (eio%unit, iostat) if (iostat /= 0) return if (associated (model)) & call pset%set_model (model) call event%link_particle_set (pset) end if end select class default call msg_bug ("Event: read raw: defined only for full event_t") end select else call eio%write () call msg_fatal ("Raw event file is not open for reading") end if end subroutine eio_raw_input_event @ %def eio_raw_input_i_prc @ %def eio_raw_input_event @ <>= procedure :: skip => eio_raw_skip <>= subroutine eio_raw_skip (eio, iostat) class(eio_raw_t), intent(inout) :: eio integer, intent(out) :: iostat if (eio%reading) then read (eio%unit, iostat = iostat) else call eio%write () call msg_fatal ("Raw event file is not open for reading") end if end subroutine eio_raw_skip @ %def eio_raw_skip @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[eio_raw_ut.f90]]>>= <> module eio_raw_ut use unit_tests use eio_raw_uti <> <> contains <> end module eio_raw_ut @ %def eio_raw_ut @ <<[[eio_raw_uti.f90]]>>= <> module eio_raw_uti <> <> use model_data use variables use events use eio_data use eio_base use eio_raw use process, only: process_t use instances, only: process_instance_t <> <> contains <> end module eio_raw_uti @ %def eio_raw_uti @ API: driver for the unit tests below. <>= public :: eio_raw_test <>= subroutine eio_raw_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine eio_raw_test @ %def eio_raw_test @ \subsubsection{Test I/O methods} We test the implementation of all I/O methods. <>= call test (eio_raw_1, "eio_raw_1", & "read and write event contents", & u, results) <>= public :: eio_raw_1 <>= subroutine eio_raw_1 (u) use processes_ut, only: prepare_test_process, cleanup_test_process integer, intent(in) :: u type(model_data_t), target :: model type(event_t), allocatable, target :: event type(process_t), allocatable, target :: process type(process_instance_t), allocatable, target :: process_instance class(eio_t), allocatable :: eio integer :: i_prc, iostat type(string_t) :: sample write (u, "(A)") "* Test output: eio_raw_1" write (u, "(A)") "* Purpose: generate and read/write an event" write (u, "(A)") write (u, "(A)") "* Initialize test process" call model%init_test () allocate (process) allocate (process_instance) call prepare_test_process (process, process_instance, model, & run_id = var_str ("run_test")) call process_instance%setup_event_data () allocate (event) call event%basic_init () call event%connect (process_instance, process%get_model_ptr ()) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_raw_1" allocate (eio_raw_t :: eio) call eio%init_out (sample) call event%generate (1, [0._default, 0._default]) call event%increment_index () call event%evaluate_expressions () call event%write (u) write (u, "(A)") call eio%output (event, i_prc = 42) call eio%write (u) call eio%final () call event%final () deallocate (event) call process_instance%final () deallocate (process_instance) write (u, "(A)") write (u, "(A)") "* Re-read the event" write (u, "(A)") call eio%init_in (sample) allocate (process_instance) call process_instance%init (process) call process_instance%setup_event_data () allocate (event) call event%basic_init () call event%connect (process_instance, process%get_model_ptr ()) call eio%input_i_prc (i_prc, iostat) if (iostat /= 0) write (u, "(A,I0)") "I/O error (i_prc):", iostat call eio%input_event (event, iostat) if (iostat /= 0) write (u, "(A,I0)") "I/O error (event):", iostat call eio%write (u) write (u, "(A)") write (u, "(1x,A,I0)") "i_prc = ", i_prc write (u, "(A)") call event%write (u) write (u, "(A)") write (u, "(A)") "* Generate and append another event" write (u, "(A)") call eio%switch_inout () call event%generate (1, [0._default, 0._default]) call event%increment_index () call event%evaluate_expressions () call event%write (u) write (u, "(A)") call eio%output (event, i_prc = 5) call eio%write (u) call eio%final () call event%final () deallocate (event) call process_instance%final () deallocate (process_instance) write (u, "(A)") write (u, "(A)") "* Re-read both events" write (u, "(A)") call eio%init_in (sample) allocate (process_instance) call process_instance%init (process) call process_instance%setup_event_data () allocate (event) call event%basic_init () call event%connect (process_instance, process%get_model_ptr ()) call eio%input_i_prc (i_prc, iostat) if (iostat /= 0) write (u, "(A,I0)") "I/O error (i_prc/1):", iostat call eio%input_event (event, iostat) if (iostat /= 0) write (u, "(A,I0)") "I/O error (event/1):", iostat call eio%input_i_prc (i_prc, iostat) if (iostat /= 0) write (u, "(A,I0)") "I/O error (i_prc/2):", iostat call eio%input_event (event, iostat) if (iostat /= 0) write (u, "(A,I0)") "I/O error (event/2):", iostat call eio%write (u) write (u, "(A)") write (u, "(1x,A,I0)") "i_prc = ", i_prc write (u, "(A)") call event%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio%final () deallocate (eio) call event%final () deallocate (event) call cleanup_test_process (process, process_instance) deallocate (process_instance) deallocate (process) call model%final () write (u, "(A)") write (u, "(A)") "* Test output end: eio_raw_1" end subroutine eio_raw_1 @ %def eio_raw_1 @ \subsubsection{Test I/O methods} We test the implementation of all I/O methods. <>= call test (eio_raw_2, "eio_raw_2", & "handle multiple weights", & u, results) <>= public :: eio_raw_2 <>= subroutine eio_raw_2 (u) use processes_ut, only: prepare_test_process, cleanup_test_process integer, intent(in) :: u type(model_data_t), target :: model type(var_list_t) :: var_list type(event_t), allocatable, target :: event type(process_t), allocatable, target :: process type(process_instance_t), allocatable, target :: process_instance type(event_sample_data_t) :: data class(eio_t), allocatable :: eio integer :: i_prc, iostat type(string_t) :: sample write (u, "(A)") "* Test output: eio_raw_2" write (u, "(A)") "* Purpose: generate and read/write an event" write (u, "(A)") "* with multiple weights" write (u, "(A)") call model%init_test () write (u, "(A)") "* Initialize test process" allocate (process) allocate (process_instance) call prepare_test_process (process, process_instance, model, & run_id = var_str ("run_test")) call process_instance%setup_event_data () call data%init (n_proc = 1, n_alt = 2) call var_list_append_log (var_list, var_str ("?unweighted"), .false., & intrinsic = .true.) call var_list_append_string (var_list, var_str ("$sample_normalization"), & var_str ("auto"), intrinsic = .true.) call var_list_append_real (var_list, var_str ("safety_factor"), & 1._default, intrinsic = .true.) allocate (event) call event%basic_init (var_list, n_alt = 2) call event%connect (process_instance, process%get_model_ptr ()) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_raw_2" allocate (eio_raw_t :: eio) call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%increment_index () call event%evaluate_expressions () call event%set (sqme_alt = [2._default, 3._default]) call event%set (weight_alt = & [2 * event%get_weight_ref (), 3 * event%get_weight_ref ()]) call event%store_alt_values () call event%check () call event%write (u) write (u, "(A)") call eio%output (event, i_prc = 42) call eio%write (u) call eio%final () call event%final () deallocate (event) call process_instance%final () deallocate (process_instance) write (u, "(A)") write (u, "(A)") "* Re-read the event" write (u, "(A)") call eio%init_in (sample, data) allocate (process_instance) call process_instance%init (process) call process_instance%setup_event_data () allocate (event) call event%basic_init (var_list, n_alt = 2) call event%connect (process_instance, process%get_model_ptr ()) call eio%input_i_prc (i_prc, iostat) if (iostat /= 0) write (u, "(A,I0)") "I/O error (i_prc):", iostat call eio%input_event (event, iostat) if (iostat /= 0) write (u, "(A,I0)") "I/O error (event):", iostat call eio%write (u) write (u, "(A)") write (u, "(1x,A,I0)") "i_prc = ", i_prc write (u, "(A)") call event%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio%final () deallocate (eio) call event%final () deallocate (event) call cleanup_test_process (process, process_instance) deallocate (process_instance) deallocate (process) call model%final () write (u, "(A)") write (u, "(A)") "* Test output end: eio_raw_2" end subroutine eio_raw_2 @ %def eio_raw_2 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Dispatch} An event transform is responsible for dressing a partonic event. Since event transforms are not mutually exclusive but are concatenated, we provide individual dispatchers for each of them. <<[[dispatch_transforms.f90]]>>= <> module dispatch_transforms <> <> use process use variables use system_defs, only: LF use system_dependencies, only: LHAPDF6_AVAILABLE use sf_lhapdf, only: lhapdf_initialize use diagnostics use models use os_interface use beam_structures use resonances, only: resonance_history_set_t use instances, only: process_instance_t, process_instance_hook_t use event_base, only: event_callback_t, event_callback_nop_t use hepmc_interface, only: HEPMC3_MODE_HEPMC2, HEPMC3_MODE_HEPMC3 use hepmc_interface, only: HEPMC3_MODE_ROOT, HEPMC3_MODE_ROOTTREE use hepmc_interface, only: HEPMC3_MODE_HEPEVT use eio_base use eio_raw use eio_checkpoints use eio_callback use eio_lhef use eio_hepmc use eio_lcio use eio_stdhep use eio_ascii use eio_weights use eio_dump use event_transforms use resonance_insertion use isr_epa_handler use decays use shower_base use shower_core use shower use shower_pythia6 use shower_pythia8 use hadrons use mlm_matching use powheg_matching use ckkw_matching use tauola_interface !NODEP! use evt_nlo <> <> contains <> end module dispatch_transforms @ %def dispatch_transforms @ <>= public :: dispatch_evt_nlo <>= subroutine dispatch_evt_nlo (evt, keep_failed_events) class(evt_t), intent(out), pointer :: evt logical, intent(in) :: keep_failed_events call msg_message ("Simulate: activating fixed-order NLO events") allocate (evt_nlo_t :: evt) evt%only_weighted_events = .true. select type (evt) type is (evt_nlo_t) evt%i_evaluation = 0 evt%keep_failed_events = keep_failed_events end select end subroutine dispatch_evt_nlo @ %def dispatch_evt_nlo @ <>= public :: dispatch_evt_resonance <>= subroutine dispatch_evt_resonance (evt, var_list, res_history_set, libname) class(evt_t), intent(out), pointer :: evt type(var_list_t), intent(in) :: var_list type(resonance_history_set_t), dimension(:), intent(in) :: res_history_set type(string_t), intent(in) :: libname logical :: resonance_history resonance_history = var_list%get_lval (var_str ("?resonance_history")) if (resonance_history) then allocate (evt_resonance_t :: evt) call msg_message ("Simulate: activating resonance insertion") select type (evt) type is (evt_resonance_t) call evt%set_resonance_data (res_history_set) call evt%set_library (libname) end select else evt => null () end if end subroutine dispatch_evt_resonance @ %def dispatch_evt_resonance @ Initialize the ISR/EPA handler, depending on active settings. The activation is independent for both handlers, since only one may be needed at a time. However, if both handlers are active, the current implementation requires the handler modes of ISR and EPA to coincide. <>= public :: dispatch_evt_isr_epa_handler <>= subroutine dispatch_evt_isr_epa_handler (evt, var_list) class(evt_t), intent(out), pointer :: evt type(var_list_t), intent(in) :: var_list logical :: isr_recoil logical :: epa_recoil logical :: isr_handler_active logical :: epa_handler_active type(string_t) :: isr_handler_mode type(string_t) :: epa_handler_mode logical :: isr_keep_mass real(default) :: sqrts real(default) :: isr_q_max real(default) :: epa_q_max real(default) :: isr_mass real(default) :: epa_mass isr_handler_active = var_list%get_lval (var_str ("?isr_handler")) if (isr_handler_active) then call msg_message ("Simulate: activating ISR handler") isr_recoil = & var_list%get_lval (var_str ("?isr_recoil")) isr_handler_mode = & var_list%get_sval (var_str ("$isr_handler_mode")) isr_keep_mass = & var_list%get_lval (var_str ("?isr_handler_keep_mass")) if (isr_recoil) then call msg_fatal ("Simulate: ISR handler is incompatible & &with ?isr_recoil=true") end if end if epa_handler_active = var_list%get_lval (var_str ("?epa_handler")) if (epa_handler_active) then call msg_message ("Simulate: activating EPA handler") epa_recoil = var_list%get_lval (var_str ("?epa_recoil")) epa_handler_mode = var_list%get_sval (var_str ("$epa_handler_mode")) if (epa_recoil) then call msg_fatal ("Simulate: EPA handler is incompatible & &with ?epa_recoil=true") end if end if if (isr_handler_active .and. epa_handler_active) then if (isr_handler_mode /= epa_handler_mode) then call msg_fatal ("Simulate: ISR/EPA handler: modes must coincide") end if end if if (isr_handler_active .or. epa_handler_active) then allocate (evt_isr_epa_t :: evt) select type (evt) type is (evt_isr_epa_t) if (isr_handler_active) then call evt%set_mode_string (isr_handler_mode) else call evt%set_mode_string (epa_handler_mode) end if sqrts = var_list%get_rval (var_str ("sqrts")) if (isr_handler_active) then isr_q_max = var_list%get_rval (var_str ("isr_q_max")) isr_mass = var_list%get_rval (var_str ("isr_mass")) call evt%set_data_isr (sqrts, isr_q_max, isr_mass, isr_keep_mass) end if if (epa_handler_active) then epa_q_max = var_list%get_rval (var_str ("epa_q_max")) epa_mass = var_list%get_rval (var_str ("epa_mass")) call evt%set_data_epa (sqrts, epa_q_max, epa_mass) end if call msg_message ("Simulate: ISR/EPA handler mode: " & // char (evt%get_mode_string ())) end select else evt => null () end if end subroutine dispatch_evt_isr_epa_handler @ %def dispatch_evt_isr_epa_handler @ <>= public :: dispatch_evt_decay <>= subroutine dispatch_evt_decay (evt, var_list) class(evt_t), intent(out), pointer :: evt type(var_list_t), intent(in), target :: var_list logical :: allow_decays allow_decays = var_list%get_lval (var_str ("?allow_decays")) if (allow_decays) then allocate (evt_decay_t :: evt) call msg_message ("Simulate: activating decays") select type (evt) type is (evt_decay_t) call evt%set_var_list (var_list) end select else evt => null () end if end subroutine dispatch_evt_decay @ %def dispatch_evt_decay @ <>= public :: dispatch_evt_shower <>= subroutine dispatch_evt_shower (evt, var_list, model, fallback_model, & os_data, beam_structure, process) class(evt_t), intent(out), pointer :: evt type(var_list_t), intent(in) :: var_list type(model_t), pointer, intent(in) :: model, fallback_model type(os_data_t), intent(in) :: os_data type(beam_structure_t), intent(in) :: beam_structure type(process_t), intent(in), optional :: process type(string_t) :: lhapdf_file, lhapdf_dir, process_name integer :: lhapdf_member type(shower_settings_t) :: settings type(taudec_settings_t) :: taudec_settings call msg_message ("Simulate: activating parton shower") allocate (evt_shower_t :: evt) call settings%init (var_list) if (associated (model)) then call taudec_settings%init (var_list, model) else call taudec_settings%init (var_list, fallback_model) end if if (present (process)) then process_name = process%get_id () else process_name = 'dispatch_testing' end if select type (evt) type is (evt_shower_t) call evt%init (fallback_model, os_data) lhapdf_member = & var_list%get_ival (var_str ("lhapdf_member")) if (LHAPDF6_AVAILABLE) then lhapdf_dir = & var_list%get_sval (var_str ("$lhapdf_dir")) lhapdf_file = & var_list%get_sval (var_str ("$lhapdf_file")) call lhapdf_initialize & (1, lhapdf_dir, lhapdf_file, lhapdf_member, evt%pdf_data%pdf) end if if (present (process)) call evt%pdf_data%setup ("Shower", & beam_structure, lhapdf_member, process%get_pdf_set ()) select case (settings%method) case (PS_WHIZARD) allocate (shower_t :: evt%shower) case (PS_PYTHIA6) allocate (shower_pythia6_t :: evt%shower) case (PS_PYTHIA8) allocate (shower_pythia8_t :: evt%shower) case default call msg_fatal ('Shower: Method ' // & char (var_list%get_sval (var_str ("$shower_method"))) // & 'not implemented!') end select call evt%shower%init (settings, taudec_settings, evt%pdf_data, os_data) end select call dispatch_matching (evt, settings, var_list, process_name) end subroutine dispatch_evt_shower @ %def dispatch_evt_shower @ <>= public :: dispatch_evt_shower_hook <>= subroutine dispatch_evt_shower_hook (hook, var_list, process_instance) class(process_instance_hook_t), pointer, intent(out) :: hook type(var_list_t), intent(in) :: var_list class(process_instance_t), intent(in), target :: process_instance if (var_list%get_lval (var_str ('?powheg_matching'))) then call msg_message ("Integration hook: add POWHEG hook") allocate (powheg_matching_hook_t :: hook) call hook%init (var_list, process_instance) else hook => null () end if end subroutine dispatch_evt_shower_hook @ %def dispatch_evt_shower_hook @ <>= public :: dispatch_matching <>= subroutine dispatch_matching (evt, settings, var_list, process_name) class(evt_t), intent(inout) :: evt type(var_list_t), intent(in) :: var_list type(string_t), intent(in) :: process_name type(shower_settings_t), intent(in) :: settings select type (evt) type is (evt_shower_t) if (settings%mlm_matching .and. settings%ckkw_matching) then call msg_fatal ("Both MLM and CKKW matching activated," // & LF // " aborting simulation") end if if (settings%powheg_matching) then call msg_message ("Simulate: applying POWHEG matching") allocate (powheg_matching_t :: evt%matching) end if if (settings%mlm_matching) then call msg_message ("Simulate: applying MLM matching") allocate (mlm_matching_t :: evt%matching) end if if (settings%ckkw_matching) then call msg_warning ("Simulate: CKKW(-L) matching not yet supported") allocate (ckkw_matching_t :: evt%matching) end if if (allocated (evt%matching)) & call evt%matching%init (var_list, process_name) end select end subroutine dispatch_matching @ %def dispatch_matching @ <>= public :: dispatch_evt_hadrons <>= subroutine dispatch_evt_hadrons (evt, var_list, fallback_model) class(evt_t), intent(out), pointer :: evt type(var_list_t), intent(in) :: var_list type(model_t), pointer, intent(in) :: fallback_model type(shower_settings_t) :: shower_settings type(hadron_settings_t) :: hadron_settings allocate (evt_hadrons_t :: evt) call msg_message ("Simulate: activating hadronization") call shower_settings%init (var_list) call hadron_settings%init (var_list) select type (evt) type is (evt_hadrons_t) call evt%init (fallback_model) select case (hadron_settings%method) case (HADRONS_WHIZARD) allocate (hadrons_hadrons_t :: evt%hadrons) case (HADRONS_PYTHIA6) allocate (hadrons_pythia6_t :: evt%hadrons) case (HADRONS_PYTHIA8) allocate (hadrons_pythia8_t :: evt%hadrons) case default call msg_fatal ('Hadronization: Method ' // & char (var_list%get_sval (var_str ("hadronization_method"))) // & 'not implemented!') end select call evt%hadrons%init & (shower_settings, hadron_settings, fallback_model) end select end subroutine dispatch_evt_hadrons @ %def dispatch_evt_hadrons @ We cannot put this in the [[events]] subdir due to [[eio_raw_t]], which is defined here. <>= public :: dispatch_eio <>= subroutine dispatch_eio (eio, method, var_list, fallback_model, & event_callback) class(eio_t), allocatable, intent(inout) :: eio type(string_t), intent(in) :: method type(var_list_t), intent(in) :: var_list type(model_t), target, intent(in) :: fallback_model class(event_callback_t), allocatable, intent(in) :: event_callback logical :: check, keep_beams, keep_remnants, recover_beams logical :: use_alphas_from_file, use_scale_from_file logical :: write_sqme_prc, write_sqme_ref, write_sqme_alt logical :: output_cross_section, ensure_order type(string_t) :: lhef_version, lhef_extension, raw_version type(string_t) :: extension_default, debug_extension, dump_extension, & extension_hepmc, & extension_lha, extension_hepevt, extension_ascii_short, & extension_ascii_long, extension_athena, extension_mokka, & extension_stdhep, extension_stdhep_up, extension_stdhep_ev4, & extension_raw, extension_hepevt_verb, extension_lha_verb, & extension_lcio integer :: checkpoint integer :: lcio_run_id, hepmc3_mode logical :: show_process, show_transforms, show_decay, verbose, pacified logical :: dump_weights, dump_compressed, dump_summary, dump_screen logical :: proc_as_run_id keep_beams = & var_list%get_lval (var_str ("?keep_beams")) keep_remnants = & var_list%get_lval (var_str ("?keep_remnants")) ensure_order = & var_list%get_lval (var_str ("?hepevt_ensure_order")) recover_beams = & var_list%get_lval (var_str ("?recover_beams")) use_alphas_from_file = & var_list%get_lval (var_str ("?use_alphas_from_file")) use_scale_from_file = & var_list%get_lval (var_str ("?use_scale_from_file")) select case (char (method)) case ("raw") allocate (eio_raw_t :: eio) select type (eio) type is (eio_raw_t) check = & var_list%get_lval (var_str ("?check_event_file")) raw_version = & var_list%get_sval (var_str ("$event_file_version")) extension_raw = & var_list%get_sval (var_str ("$extension_raw")) call eio%set_parameters (check, use_alphas_from_file, & use_scale_from_file, raw_version, extension_raw) end select case ("checkpoint") allocate (eio_checkpoints_t :: eio) select type (eio) type is (eio_checkpoints_t) checkpoint = & var_list%get_ival (var_str ("checkpoint")) pacified = & var_list%get_lval (var_str ("?pacify")) call eio%set_parameters (checkpoint, blank = pacified) end select case ("callback") allocate (eio_callback_t :: eio) select type (eio) type is (eio_callback_t) checkpoint = & var_list%get_ival (var_str ("event_callback_interval")) if (allocated (event_callback)) then call eio%set_parameters (event_callback, checkpoint) else call eio%set_parameters (event_callback_nop_t (), 0) end if end select case ("lhef") allocate (eio_lhef_t :: eio) select type (eio) type is (eio_lhef_t) lhef_version = & var_list%get_sval (var_str ("$lhef_version")) lhef_extension = & var_list%get_sval (var_str ("$lhef_extension")) write_sqme_prc = & var_list%get_lval (var_str ("?lhef_write_sqme_prc")) write_sqme_ref = & var_list%get_lval (var_str ("?lhef_write_sqme_ref")) write_sqme_alt = & var_list%get_lval (var_str ("?lhef_write_sqme_alt")) call eio%set_parameters ( & keep_beams, keep_remnants, recover_beams, & use_alphas_from_file, use_scale_from_file, & char (lhef_version), lhef_extension, & write_sqme_ref, write_sqme_prc, write_sqme_alt) end select case ("hepmc") allocate (eio_hepmc_t :: eio) select type (eio) type is (eio_hepmc_t) output_cross_section = & var_list%get_lval (var_str ("?hepmc_output_cross_section")) extension_hepmc = & var_list%get_sval (var_str ("$extension_hepmc")) select case (char (var_list%get_sval (var_str ("$hepmc3_mode")))) case ("HepMC2") hepmc3_mode = HEPMC3_MODE_HEPMC2 case ("HepMC3") hepmc3_mode = HEPMC3_MODE_HEPMC3 case ("Root") hepmc3_mode = HEPMC3_MODE_ROOT case ("RootTree") hepmc3_mode = HEPMC3_MODE_ROOTTREE case ("HepEVT") hepmc3_mode = HEPMC3_MODE_HEPEVT case default call msg_fatal ("Only supported HepMC3 modes are: 'HepMC2', " // & "'HepMC3', 'HepEVT', 'Root', and 'RootTree'.") end select call eio%set_parameters (recover_beams, & use_alphas_from_file, use_scale_from_file, & extension = extension_hepmc, & output_cross_section = output_cross_section, & hepmc3_mode = hepmc3_mode) end select case ("lcio") allocate (eio_lcio_t :: eio) select type (eio) type is (eio_lcio_t) extension_lcio = & var_list%get_sval (var_str ("$extension_lcio")) proc_as_run_id = & var_list%get_lval (var_str ("?proc_as_run_id")) lcio_run_id = & var_list%get_ival (var_str ("lcio_run_id")) call eio%set_parameters (recover_beams, & use_alphas_from_file, use_scale_from_file, & extension_lcio, proc_as_run_id = proc_as_run_id, & lcio_run_id = lcio_run_id) end select case ("stdhep") allocate (eio_stdhep_hepevt_t :: eio) select type (eio) type is (eio_stdhep_hepevt_t) extension_stdhep = & var_list%get_sval (var_str ("$extension_stdhep")) call eio%set_parameters & (keep_beams, keep_remnants, ensure_order, recover_beams, & use_alphas_from_file, use_scale_from_file, extension_stdhep) end select case ("stdhep_up") allocate (eio_stdhep_hepeup_t :: eio) select type (eio) type is (eio_stdhep_hepeup_t) extension_stdhep_up = & var_list%get_sval (var_str ("$extension_stdhep_up")) call eio%set_parameters (keep_beams, keep_remnants, ensure_order, & recover_beams, use_alphas_from_file, & use_scale_from_file, extension_stdhep_up) end select case ("stdhep_ev4") allocate (eio_stdhep_hepev4_t :: eio) select type (eio) type is (eio_stdhep_hepev4_t) extension_stdhep_ev4 = & var_list%get_sval (var_str ("$extension_stdhep_ev4")) call eio%set_parameters & (keep_beams, keep_remnants, ensure_order, recover_beams, & use_alphas_from_file, use_scale_from_file, extension_stdhep_ev4) end select case ("ascii") allocate (eio_ascii_ascii_t :: eio) select type (eio) type is (eio_ascii_ascii_t) extension_default = & var_list%get_sval (var_str ("$extension_default")) call eio%set_parameters & (keep_beams, keep_remnants, ensure_order, extension_default) end select case ("athena") allocate (eio_ascii_athena_t :: eio) select type (eio) type is (eio_ascii_athena_t) extension_athena = & var_list%get_sval (var_str ("$extension_athena")) call eio%set_parameters & (keep_beams, keep_remnants, ensure_order, extension_athena) end select case ("debug") allocate (eio_ascii_debug_t :: eio) select type (eio) type is (eio_ascii_debug_t) debug_extension = & var_list%get_sval (var_str ("$debug_extension")) show_process = & var_list%get_lval (var_str ("?debug_process")) show_transforms = & var_list%get_lval (var_str ("?debug_transforms")) show_decay = & var_list%get_lval (var_str ("?debug_decay")) verbose = & var_list%get_lval (var_str ("?debug_verbose")) call eio%set_parameters ( & extension = debug_extension, & show_process = show_process, & show_transforms = show_transforms, & show_decay = show_decay, & verbose = verbose) end select case ("dump") allocate (eio_dump_t :: eio) select type (eio) type is (eio_dump_t) dump_extension = & var_list%get_sval (var_str ("$dump_extension")) pacified = & var_list%get_lval (var_str ("?pacify")) dump_weights = & var_list%get_lval (var_str ("?dump_weights")) dump_compressed = & var_list%get_lval (var_str ("?dump_compressed")) dump_summary = & var_list%get_lval (var_str ("?dump_summary")) dump_screen = & var_list%get_lval (var_str ("?dump_screen")) call eio%set_parameters ( & extension = dump_extension, & pacify = pacified, & weights = dump_weights, & compressed = dump_compressed, & summary = dump_summary, & screen = dump_screen) end select case ("hepevt") allocate (eio_ascii_hepevt_t :: eio) select type (eio) type is (eio_ascii_hepevt_t) extension_hepevt = & var_list%get_sval (var_str ("$extension_hepevt")) call eio%set_parameters & (keep_beams, keep_remnants, ensure_order, extension_hepevt) end select case ("hepevt_verb") allocate (eio_ascii_hepevt_verb_t :: eio) select type (eio) type is (eio_ascii_hepevt_verb_t) extension_hepevt_verb = & var_list%get_sval (var_str ("$extension_hepevt_verb")) call eio%set_parameters & (keep_beams, keep_remnants, ensure_order, extension_hepevt_verb) end select case ("lha") allocate (eio_ascii_lha_t :: eio) select type (eio) type is (eio_ascii_lha_t) extension_lha = & var_list%get_sval (var_str ("$extension_lha")) call eio%set_parameters & (keep_beams, keep_remnants, ensure_order, extension_lha) end select case ("lha_verb") allocate (eio_ascii_lha_verb_t :: eio) select type (eio) type is (eio_ascii_lha_verb_t) extension_lha_verb = var_list%get_sval ( & var_str ("$extension_lha_verb")) call eio%set_parameters & (keep_beams, keep_remnants, ensure_order, extension_lha_verb) end select case ("long") allocate (eio_ascii_long_t :: eio) select type (eio) type is (eio_ascii_long_t) extension_ascii_long = & var_list%get_sval (var_str ("$extension_ascii_long")) call eio%set_parameters & (keep_beams, keep_remnants, ensure_order, extension_ascii_long) end select case ("mokka") allocate (eio_ascii_mokka_t :: eio) select type (eio) type is (eio_ascii_mokka_t) extension_mokka = & var_list%get_sval (var_str ("$extension_mokka")) call eio%set_parameters & (keep_beams, keep_remnants, ensure_order, extension_mokka) end select case ("short") allocate (eio_ascii_short_t :: eio) select type (eio) type is (eio_ascii_short_t) extension_ascii_short = & var_list%get_sval (var_str ("$extension_ascii_short")) call eio%set_parameters & (keep_beams, keep_remnants, ensure_order, extension_ascii_short) end select case ("weight_stream") allocate (eio_weights_t :: eio) select type (eio) type is (eio_weights_t) pacified = & var_list%get_lval (var_str ("?pacify")) call eio%set_parameters (pacify = pacified) end select case default call msg_fatal ("Event I/O method '" // char (method) & // "' not implemented") end select call eio%set_fallback_model (fallback_model) end subroutine dispatch_eio @ %def dispatch_eio @ @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[dispatch_transforms_ut.f90]]>>= <> module dispatch_transforms_ut use unit_tests use dispatch_transforms_uti <> <> contains <> end module dispatch_transforms_ut @ %def dispatch_transforms_ut @ <<[[dispatch_transforms_uti.f90]]>>= <> module dispatch_transforms_uti <> <> use format_utils, only: write_separator use variables use event_base, only: event_callback_t use models, only: model_t, model_list_t use models, only: syntax_model_file_init, syntax_model_file_final use resonances, only: resonance_history_set_t use beam_structures, only: beam_structure_t use eio_base, only: eio_t use os_interface, only: os_data_t use event_transforms, only: evt_t use dispatch_transforms <> <> contains <> end module dispatch_transforms_uti @ %def dispatch_transforms_uti @ API: driver for the unit tests below. <>= public ::dispatch_transforms_test <>= subroutine dispatch_transforms_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine dispatch_transforms_test @ %def dispatch_transforms_test @ \subsubsection{Event I/O} <>= call test (dispatch_transforms_1, "dispatch_transforms_1", & "event I/O", & u, results) <>= public :: dispatch_transforms_1 <>= subroutine dispatch_transforms_1 (u) integer, intent(in) :: u type(var_list_t) :: var_list type(model_list_t) :: model_list type(model_t), pointer :: model type(os_data_t) :: os_data class(event_callback_t), allocatable :: event_callback class(eio_t), allocatable :: eio write (u, "(A)") "* Test output: dispatch_transforms_1" write (u, "(A)") "* Purpose: allocate an event I/O (eio) stream" write (u, "(A)") call var_list%init_defaults (0) call os_data%init () call syntax_model_file_init () call model_list%read_model (var_str ("SM_hadrons"), & var_str ("SM_hadrons.mdl"), os_data, model) write (u, "(A)") "* Allocate as raw" write (u, "(A)") call dispatch_eio (eio, var_str ("raw"), var_list, & model, event_callback) call eio%write (u) call eio%final () deallocate (eio) write (u, "(A)") write (u, "(A)") "* Allocate as checkpoints:" write (u, "(A)") call dispatch_eio (eio, var_str ("checkpoint"), var_list, & model, event_callback) call eio%write (u) call eio%final () deallocate (eio) write (u, "(A)") write (u, "(A)") "* Allocate as LHEF:" write (u, "(A)") call var_list%set_string (var_str ("$lhef_extension"), & var_str ("lhe_custom"), is_known = .true.) call dispatch_eio (eio, var_str ("lhef"), var_list, & model, event_callback) call eio%write (u) call eio%final () deallocate (eio) write (u, "(A)") write (u, "(A)") "* Allocate as HepMC:" write (u, "(A)") call dispatch_eio (eio, var_str ("hepmc"), var_list, & model, event_callback) call eio%write (u) call eio%final () deallocate (eio) write (u, "(A)") write (u, "(A)") "* Allocate as weight_stream" write (u, "(A)") call dispatch_eio (eio, var_str ("weight_stream"), var_list, & model, event_callback) call eio%write (u) call eio%final () deallocate (eio) write (u, "(A)") write (u, "(A)") "* Allocate as debug format" write (u, "(A)") call var_list%set_log (var_str ("?debug_verbose"), & .false., is_known = .true.) call dispatch_eio (eio, var_str ("debug"), var_list, & model, event_callback) call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio%final () call var_list%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: dispatch_transforms_1" end subroutine dispatch_transforms_1 @ %def dispatch_transforms_1 @ \subsubsection{Event transforms} This test dispatches [[evt]] (event transform) objects. <>= call test (dispatch_transforms_2, "dispatch_transforms_2", & "event transforms", & u, results) <>= public :: dispatch_transforms_2 <>= subroutine dispatch_transforms_2 (u) integer, intent(in) :: u type(var_list_t), target :: var_list type(model_list_t) :: model_list type(model_t), pointer :: model type(os_data_t) :: os_data type(resonance_history_set_t), dimension(1) :: res_history_set type(beam_structure_t) :: beam_structure class(evt_t), pointer :: evt write (u, "(A)") "* Test output: dispatch_transforms_2" write (u, "(A)") "* Purpose: configure event transform" write (u, "(A)") call syntax_model_file_init () call var_list%init_defaults (0) call os_data%init () call model_list%read_model (var_str ("SM_hadrons"), & var_str ("SM_hadrons.mdl"), os_data, model) write (u, "(A)") "* Resonance insertion" write (u, "(A)") call var_list%set_log (var_str ("?resonance_history"), .true., & is_known = .true.) call dispatch_evt_resonance (evt, var_list, & res_history_set, & var_str ("foo_R")) call evt%write (u, verbose = .true., more_verbose = .true.) call evt%final () deallocate (evt) write (u, "(A)") write (u, "(A)") "* ISR handler" write (u, "(A)") call var_list%set_log (var_str ("?isr_handler"), .true., & is_known = .true.) call var_list%set_log (var_str ("?epa_handler"), .false., & is_known = .true.) call var_list%set_string (var_str ("$isr_handler_mode"), & var_str ("recoil"), & is_known = .true.) call var_list%set_real (var_str ("sqrts"), 100._default, & is_known = .true.) call var_list%set_real (var_str ("isr_mass"), 511.e-6_default, & is_known = .true.) call dispatch_evt_isr_epa_handler (evt, var_list) call evt%write (u, verbose = .true., more_verbose = .true.) call evt%final () deallocate (evt) write (u, "(A)") write (u, "(A)") "* EPA handler" write (u, "(A)") call var_list%set_log (var_str ("?isr_handler"), .false., & is_known = .true.) call var_list%set_log (var_str ("?epa_handler"), .true., & is_known = .true.) call var_list%set_string (var_str ("$epa_handler_mode"), & var_str ("recoil"), & is_known = .true.) call var_list%set_real (var_str ("sqrts"), 100._default, & is_known = .true.) call var_list%set_real (var_str ("epa_mass"), 511.e-6_default, & is_known = .true.) call dispatch_evt_isr_epa_handler (evt, var_list) call evt%write (u, verbose = .true., more_verbose = .true.) call evt%final () deallocate (evt) write (u, "(A)") write (u, "(A)") "* Partonic decays" write (u, "(A)") call dispatch_evt_decay (evt, var_list) call evt%write (u, verbose = .true., more_verbose = .true.) call evt%final () deallocate (evt) write (u, "(A)") write (u, "(A)") "* Shower" write (u, "(A)") call var_list%set_log (var_str ("?allow_shower"), .true., & is_known = .true.) call var_list%set_string (var_str ("$shower_method"), & var_str ("WHIZARD"), is_known = .true.) call dispatch_evt_shower (evt, var_list, model, & model, os_data, beam_structure) call evt%write (u) call write_separator (u, 2) call evt%final () deallocate (evt) call var_list%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: dispatch_transforms_2" end subroutine dispatch_transforms_2 @ %def dispatch_transforms_2 Index: trunk/src/transforms/Makefile.am =================================================================== --- trunk/src/transforms/Makefile.am (revision 8428) +++ trunk/src/transforms/Makefile.am (revision 8429) @@ -1,240 +1,241 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement quantum field theory concepts ## such as model representation and quantum numbers. ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libtransforms.la check_LTLIBRARIES = libtransforms_ut.la libtransforms_la_SOURCES = \ event_transforms.f90 \ resonance_insertion.f90 \ hadrons.f90 \ recoil_kinematics.f90 \ isr_epa_handler.f90 \ decays.f90 \ tau_decays.f90 \ shower.f90 \ evt_nlo.f90 \ events.f90 \ eio_raw.f90 \ dispatch_transforms.f90 libtransforms_ut_la_SOURCES = \ event_transforms_uti.f90 event_transforms_ut.f90 \ resonance_insertion_uti.f90 resonance_insertion_ut.f90 \ recoil_kinematics_uti.f90 recoil_kinematics_ut.f90 \ isr_epa_handler_uti.f90 isr_epa_handler_ut.f90 \ decays_uti.f90 decays_ut.f90 \ shower_uti.f90 shower_ut.f90 \ events_uti.f90 events_ut.f90 \ eio_raw_uti.f90 eio_raw_ut.f90 \ dispatch_transforms_uti.f90 dispatch_transforms_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = transforms.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libtransforms_la_SOURCES:.f90=.$(FCMOD)} + libtransforms_Modules = \ ${libtransforms_la_SOURCES:.f90=} \ ${libtransforms_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libtransforms_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../physics/Modules \ ../qft/Modules \ ../particles/Modules \ ../types/Modules \ ../matrix_elements/Modules \ ../me_methods/Modules \ ../rng/Modules \ ../mci/Modules \ ../phase_space/Modules \ ../process_integration/Modules \ ../matching/Modules \ ../model_features/Modules \ ../events/Modules \ ../shower/Modules \ ../pythia8/Modules \ ../expr_base/Modules \ ../variables/Modules \ ../beams/Modules \ ../threshold/Modules \ ../fks/Modules # Explicit dependencies, not automatically generated -event_transforms.lo: ../../vamp/src/vamp.$(FC_MODULE_EXT) -shower.lo: ../lhapdf/lhapdf.$(FC_MODULE_EXT) -shower.lo: ../pdf_builtin/pdf_builtin.$(FC_MODULE_EXT) +event_transforms.lo: ../../vamp/src/vamp.$(FCMOD) +shower.lo: ../lhapdf/lhapdf.$(FCMOD) +shower.lo: ../pdf_builtin/pdf_builtin.$(FCMOD) $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libtransforms_la_SOURCES) $(libtransforms_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libtransforms_la_SOURCES) $(libtransforms_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../parsing -I../physics -I../qft -I../particles -I../types -I../matrix_elements -I../me_methods -I../rng -I../mci -I../phase_space -I../process_integration -I../matching -I../model_features -I../events -I../tauola -I../shower -I../expr_base -I../variables -I../muli -I../beams -I../blha -I../threshold -I../fks -I../openloops -I../gosam -I../recola -I../../circe1/src -I../../circe2/src -I../pdf_builtin -I../lhapdf -I../qed_pdf -I../fastjet -I../../vamp/src -I../pythia8 ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif if RECOLA_AVAILABLE AM_FCFLAGS += $(RECOLA_INCLUDES) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -#execmoddir = $(pkglibdir)/mod/transforms -#nodist_execmod_HEADERS = \# - ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw transforms.stamp: $(PRELUDE) $(srcdir)/transforms.nw $(POSTLUDE) @rm -f transforms.tmp @touch transforms.tmp for src in \ $(libtransforms_la_SOURCES) \ $(libtransforms_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f transforms.tmp transforms.stamp $(libtransforms_la_SOURCES) $(libtransforms_ut_la_SOURCES): transforms.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f transforms.stamp; \ $(MAKE) $(AM_MAKEFLAGS) transforms.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f transforms.stamp transforms.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/whizard-core/Makefile.am =================================================================== --- trunk/src/whizard-core/Makefile.am (revision 8428) +++ trunk/src/whizard-core/Makefile.am (revision 8429) @@ -1,325 +1,308 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory make up the WHIZARD core ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libwhizard_core.la check_LTLIBRARIES = libwhizard_core_ut.la COMMON_F90 = \ user_files.f90 \ rt_data.f90 \ dispatch_me_methods.f90 \ process_configurations.f90 \ compilations.f90 \ event_streams.f90 \ whizard.f90 \ - cmdline_options.f90 \ features.f90 MPI_F90 = \ integrations.f90_mpi \ restricted_subprocesses.f90_mpi \ simulations.f90_mpi \ commands.f90_mpi SERIAL_F90 = \ integrations.f90_serial \ restricted_subprocesses.f90_serial \ simulations.f90_serial \ commands.f90_serial nodist_libwhizard_core_la_SOURCES = \ $(COMMON_F90) \ integrations.f90 \ restricted_subprocesses.f90 \ simulations.f90 \ commands.f90 DISTCLEANFILES = integrations.f90 restricted_subprocesses.f90 \ simulations.f90 commands.f90 if FC_USE_MPI integrations.f90: integrations.f90_mpi -cp -f $< $@ restricted_subprocesses.f90: restricted_subprocesses.f90_mpi -cp -f $< $@ simulations.f90: simulations.f90_mpi -cp -f $< $@ commands.f90: commands.f90_mpi -cp -f $< $@ else integrations.f90: integrations.f90_serial -cp -f $< $@ restricted_subprocesses.f90: restricted_subprocesses.f90_serial -cp -f $< $@ simulations.f90: simulations.f90_serial -cp -f $< $@ commands.f90: commands.f90_serial -cp -f $< $@ endif libwhizard_core_ut_la_SOURCES = \ expr_tests_uti.f90 expr_tests_ut.f90 \ rt_data_uti.f90 rt_data_ut.f90 \ dispatch_uti.f90 dispatch_ut.f90 \ process_configurations_uti.f90 process_configurations_ut.f90 \ compilations_uti.f90 compilations_ut.f90 \ integrations_uti.f90 integrations_ut.f90 \ event_streams_uti.f90 event_streams_ut.f90 \ restricted_subprocesses_uti.f90 restricted_subprocesses_ut.f90 \ simulations_uti.f90 simulations_ut.f90 \ commands_uti.f90 commands_ut.f90 # Adds the whizard-c-interface EXTRA_libwhizard_core_la_SOURCES = whizard-c-interface.f90 libwhizard_core_la_LIBADD = whizard-c-interface.lo -## The main program makes up a library on its own. -lib_LTLIBRARIES = libwhizard_main.la -check_LTLIBRARIES += libwhizard_main_ut.la - -MPI_F90 += main.f90_mpi -SERIAL_F90 += main.f90_serial - -nodist_libwhizard_main_la_SOURCES = \ - main.f90 - -DISTCLEANFILES += main.f90 - -if FC_USE_MPI -main.f90: main.f90_mpi - -cp -f $< $@ -else -main.f90: main.f90_serial - -cp -f $< $@ -endif - -MPI_F90 += main_ut.f90_mpi -SERIAL_F90 += main_ut.f90_serial - -nodist_libwhizard_main_ut_la_SOURCES = \ - main_ut.f90 - -DISTCLEANFILES += main_ut.f90 - -if FC_USE_MPI -main_ut.f90: main_ut.f90_mpi - -cp -f $< $@ -else -main_ut.f90: main_ut.f90_serial - -cp -f $< $@ -endif - EXTRA_DIST = \ $(COMMON_F90) \ $(SERIAL_F90) \ $(MPI_F90) ## Omitting this would exclude it from the distribution dist_noinst_DATA = whizard.nw +# Modules and installation +# Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${nodist_libwhizard_core_la_SOURCES:.f90=.$(FCMOD)} \ + ${libwhizard_core_la_SOURCES:.f90=.$(FCMOD)} + +libwhizard_core_Modules = \ + ${libwhizard_core_la_SOURCES:.f90=} \ + ${nodist_libwhizard_core_la_SOURCES:.f90=} \ + ${libwhizard_core_ut_la_SOURCES:.f90=} +Modules: Makefile + @for module in $(libwhizard_core_Modules); do \ + echo $$module >> $@.new; \ + done + @if diff $@ $@.new -q >/dev/null; then \ + rm $@.new; \ + else \ + mv $@.new $@; echo "Modules updated"; \ + fi +BUILT_SOURCES = Modules + ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../combinatorics/Modules \ ../parsing/Modules \ ../rng/Modules \ ../physics/Modules \ ../qft/Modules \ ../expr_base/Modules \ ../types/Modules \ ../matrix_elements/Modules \ ../particles/Modules \ ../beams/Modules \ ../me_methods/Modules \ ../pythia8/Modules \ ../events/Modules \ ../phase_space/Modules \ ../mci/Modules \ ../vegas/Modules \ ../blha/Modules \ ../gosam/Modules \ ../openloops/Modules \ ../recola/Modules \ ../fks/Modules \ ../variables/Modules \ ../model_features/Modules \ ../muli/Modules \ ../shower/Modules \ ../matching/Modules \ ../process_integration/Modules \ ../transforms/Modules \ ../threshold/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(nodist_libwhizard_core_la_SOURCES) \ $(libwhizard_core_ut_la_SOURCES) \ - $(nodist_libwhizard_main_la_SOURCES) \ - $(nodist_libwhizard_main_ut_la_SOURCES) \ $(EXTRA_libwhizard_core_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES += Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(nodist_libwhizard_core_la_SOURCES) \ $(libwhizard_core_ut_la_SOURCES) \ - $(nodist_libwhizard_main_la_SOURCES) \ - $(nodist_libwhizard_main_ut_la_SOURCES) \ $(EXTRA_libwhizard_core_la_SOURCES) +# $(nodist_libwhizard_main_la_SOURCES) \ +# $(nodist_libwhizard_main_ut_la_SOURCES) \ @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend -SUFFIXES = .lo .$(FC_MODULE_EXT) +SUFFIXES = .lo .$(FCMOD) # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../parsing -I../rng -I../physics -I../qed_pdf -I../qft -I../expr_base -I../types -I../matrix_elements -I../particles -I../beams -I../me_methods -I../events -I../phase_space -I../mci -I../vegas -I../blha -I../gosam -I../openloops -I../fks -I../variables -I../model_features -I../muli -I../pythia8 -I../shower -I../matching -I../process_integration -I../transforms -I../xdr -I../../vamp/src -I../pdf_builtin -I../../circe1/src -I../../circe2/src -I../lhapdf -I../fastjet -I../threshold -I../tauola -I../recola ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif if RECOLA_AVAILABLE AM_FCFLAGS += $(RECOLA_INCLUDES) endif ######################################################################## ## Non-standard targets and dependencies ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE FILTER = -filter "sed 's/defn MPI:/defn/'" COMMON_SRC = \ $(COMMON_F90) \ $(libwhizard_core_ut_la_SOURCES) \ $(EXTRA_libwhizard_core_la_SOURCES) PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw whizard.stamp: $(PRELUDE) $(srcdir)/whizard.nw $(POSTLUDE) @rm -f whizard.tmp @touch whizard.tmp for src in $(COMMON_SRC); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done for src in $(MPI_F90:.f90_mpi=.f90); do \ $(NOTANGLE) -R[[$$src]] $(FILTER) $^ | $(CPIF) $$src'_mpi'; \ done for src in $(SERIAL_F90:.f90_serial=.f90); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src'_serial'; \ done @mv -f whizard.tmp whizard.stamp $(MPI_F90) $(SERIAL_F90) $(COMMON_SRC): whizard.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f whizard.stamp; \ $(MAKE) $(AM_MAKEFLAGS) whizard.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.f90_mpi *.f90_serial *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.f90_mpi *.f90_serial *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f whizard.stamp whizard.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/whizard-core/whizard.nw =================================================================== --- trunk/src/whizard-core/whizard.nw (revision 8428) +++ trunk/src/whizard-core/whizard.nw (revision 8429) @@ -1,31446 +1,29072 @@ % -*- ess-noweb-default-code-mode: f90-mode; noweb-default-code-mode: f90-mode; -*- % WHIZARD main code as NOWEB source \includemodulegraph{whizard-core} \chapter{Integration and Simulation} @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{User-controlled File I/O} The SINDARIN language includes commands that write output to file (input may be added later). We identify files by their name, and manage the unit internally. We need procedures for opening, closing, and printing files. <<[[user_files.f90]]>>= <> module user_files <> use io_units use diagnostics use ifiles use analysis <> <> <> <> contains <> end module user_files @ %def user_files @ \subsection{The file type} This is a type that describes an open user file and its properties. The entry is part of a doubly-linked list. <>= type :: file_t private type(string_t) :: name integer :: unit = -1 logical :: reading = .false. logical :: writing = .false. type(file_t), pointer :: prev => null () type(file_t), pointer :: next => null () end type file_t @ %def file_t @ The initializer opens the file. <>= subroutine file_init (file, name, action, status, position) type(file_t), intent(out) :: file type(string_t), intent(in) :: name character(len=*), intent(in) :: action, status, position file%unit = free_unit () file%name = name open (unit = file%unit, file = char (file%name), & action = action, status = status, position = position) select case (action) case ("read") file%reading = .true. case ("write") file%writing = .true. case ("readwrite") file%reading = .true. file%writing = .true. end select end subroutine file_init @ %def file_init @ The finalizer closes it. <>= subroutine file_final (file) type(file_t), intent(inout) :: file close (unit = file%unit) file%unit = -1 end subroutine file_final @ %def file_final @ Check if a file is open with correct status. <>= function file_is_open (file, action) result (flag) logical :: flag type(file_t), intent(in) :: file character(*), intent(in) :: action select case (action) case ("read") flag = file%reading case ("write") flag = file%writing case ("readwrite") flag = file%reading .and. file%writing case default call msg_bug ("Checking file '" // char (file%name) & // "': illegal action specifier") end select end function file_is_open @ %def file_is_open @ Return the unit number of a file for direct access. It should be checked first whether the file is open. <>= function file_get_unit (file) result (unit) integer :: unit type(file_t), intent(in) :: file unit = file%unit end function file_get_unit @ %def file_get_unit @ Write to the file. Error if in wrong mode. If there is no string, just write an empty record. If there is a string, respect the [[advancing]] option. <>= subroutine file_write_string (file, string, advancing) type(file_t), intent(in) :: file type(string_t), intent(in), optional :: string logical, intent(in), optional :: advancing if (file%writing) then if (present (string)) then if (present (advancing)) then if (advancing) then write (file%unit, "(A)") char (string) else write (file%unit, "(A)", advance="no") char (string) end if else write (file%unit, "(A)") char (string) end if else write (file%unit, *) end if else call msg_error ("Writing to file: File '" // char (file%name) & // "' is not open for writing.") end if end subroutine file_write_string @ %def file_write @ Write a whole ifile, line by line. <>= subroutine file_write_ifile (file, ifile) type(file_t), intent(in) :: file type(ifile_t), intent(in) :: ifile type(line_p) :: line call line_init (line, ifile) do while (line_is_associated (line)) call file_write_string (file, line_get_string_advance (line)) end do end subroutine file_write_ifile @ %def file_write_ifile @ Write an analysis object (or all objects) to an open file. <>= subroutine file_write_analysis (file, tag) type(file_t), intent(in) :: file type(string_t), intent(in), optional :: tag if (file%writing) then if (present (tag)) then call analysis_write (tag, unit = file%unit) else call analysis_write (unit = file%unit) end if else call msg_error ("Writing analysis to file: File '" // char (file%name) & // "' is not open for writing.") end if end subroutine file_write_analysis @ %def file_write_analysis @ \subsection{The file list} We maintain a list of all open files and their attributes. The list must be doubly-linked because we may delete entries. <>= public :: file_list_t <>= type :: file_list_t type(file_t), pointer :: first => null () type(file_t), pointer :: last => null () end type file_list_t @ %def file_list_t @ There is no initialization routine, but a finalizer which deletes all: <>= public :: file_list_final <>= subroutine file_list_final (file_list) type(file_list_t), intent(inout) :: file_list type(file_t), pointer :: current do while (associated (file_list%first)) current => file_list%first file_list%first => current%next call file_final (current) deallocate (current) end do file_list%last => null () end subroutine file_list_final @ %def file_list_final @ Find an entry in the list. Return null pointer on failure. <>= function file_list_get_file_ptr (file_list, name) result (current) type(file_t), pointer :: current type(file_list_t), intent(in) :: file_list type(string_t), intent(in) :: name current => file_list%first do while (associated (current)) if (current%name == name) return current => current%next end do end function file_list_get_file_ptr @ %def file_list_get_file_ptr @ Check if a file is open, public version: <>= public :: file_list_is_open <>= function file_list_is_open (file_list, name, action) result (flag) logical :: flag type(file_list_t), intent(in) :: file_list type(string_t), intent(in) :: name character(len=*), intent(in) :: action type(file_t), pointer :: current current => file_list_get_file_ptr (file_list, name) if (associated (current)) then flag = file_is_open (current, action) else flag = .false. end if end function file_list_is_open @ %def file_list_is_open @ Return the unit number for a file. It should be checked first whether the file is open. <>= public :: file_list_get_unit <>= function file_list_get_unit (file_list, name) result (unit) integer :: unit type(file_list_t), intent(in) :: file_list type(string_t), intent(in) :: name type(file_t), pointer :: current current => file_list_get_file_ptr (file_list, name) if (associated (current)) then unit = file_get_unit (current) else unit = -1 end if end function file_list_get_unit @ %def file_list_get_unit @ Append a new file entry, i.e., open this file. Error if it is already open. <>= public :: file_list_open <>= subroutine file_list_open (file_list, name, action, status, position) type(file_list_t), intent(inout) :: file_list type(string_t), intent(in) :: name character(len=*), intent(in) :: action, status, position type(file_t), pointer :: current if (.not. associated (file_list_get_file_ptr (file_list, name))) then allocate (current) call msg_message ("Opening file '" // char (name) // "' for output") call file_init (current, name, action, status, position) if (associated (file_list%last)) then file_list%last%next => current current%prev => file_list%last else file_list%first => current end if file_list%last => current else call msg_error ("Opening file: File '" // char (name) & // "' is already open.") end if end subroutine file_list_open @ %def file_list_open @ Delete a file entry, i.e., close this file. Error if it is not open. <>= public :: file_list_close <>= subroutine file_list_close (file_list, name) type(file_list_t), intent(inout) :: file_list type(string_t), intent(in) :: name type(file_t), pointer :: current current => file_list_get_file_ptr (file_list, name) if (associated (current)) then if (associated (current%prev)) then current%prev%next => current%next else file_list%first => current%next end if if (associated (current%next)) then current%next%prev => current%prev else file_list%last => current%prev end if call msg_message ("Closing file '" // char (name) // "' for output") call file_final (current) deallocate (current) else call msg_error ("Closing file: File '" // char (name) & // "' is not open.") end if end subroutine file_list_close @ %def file_list_close @ Write a string to file. Error if it is not open. <>= public :: file_list_write <>= interface file_list_write module procedure file_list_write_string module procedure file_list_write_ifile end interface <>= subroutine file_list_write_string (file_list, name, string, advancing) type(file_list_t), intent(in) :: file_list type(string_t), intent(in) :: name type(string_t), intent(in), optional :: string logical, intent(in), optional :: advancing type(file_t), pointer :: current current => file_list_get_file_ptr (file_list, name) if (associated (current)) then call file_write_string (current, string, advancing) else call msg_error ("Writing to file: File '" // char (name) & // "'is not open.") end if end subroutine file_list_write_string subroutine file_list_write_ifile (file_list, name, ifile) type(file_list_t), intent(in) :: file_list type(string_t), intent(in) :: name type(ifile_t), intent(in) :: ifile type(file_t), pointer :: current current => file_list_get_file_ptr (file_list, name) if (associated (current)) then call file_write_ifile (current, ifile) else call msg_error ("Writing to file: File '" // char (name) & // "'is not open.") end if end subroutine file_list_write_ifile @ %def file_list_write @ Write an analysis object or all objects to data file. Error if it is not open. If the file name is empty, write to standard output. <>= public :: file_list_write_analysis <>= subroutine file_list_write_analysis (file_list, name, tag) type(file_list_t), intent(in) :: file_list type(string_t), intent(in) :: name type(string_t), intent(in), optional :: tag type(file_t), pointer :: current if (name == "") then if (present (tag)) then call analysis_write (tag) else call analysis_write end if else current => file_list_get_file_ptr (file_list, name) if (associated (current)) then call file_write_analysis (current, tag) else call msg_error ("Writing analysis to file: File '" // char (name) & // "' is not open.") end if end if end subroutine file_list_write_analysis @ %def file_list_write_analysis @ \clearpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Runtime data} <<[[rt_data.f90]]>>= <> module rt_data <> <> use io_units use format_utils, only: write_separator use format_defs, only: FMT_19, FMT_12 use system_dependencies use diagnostics use os_interface use lexers use parser use models use subevents use pdg_arrays use variables, only: var_list_t use process_libraries use prclib_stacks use prc_core, only: helicity_selection_t use beam_structures use event_base, only: event_callback_t use user_files use process_stacks use iterations <> <> <> contains <> end module rt_data @ %def rt_data @ \subsection{Strategy for models and variables} The program manages its data via a main [[rt_data_t]] object. During program flow, various commands create and use local [[rt_data_t]] objects. Those transient blocks contain either pointers to global object or local copies which are deleted after use. Each [[rt_data_t]] object contains a variable list component. This lists holds (local copies of) all kinds of intrinsic or user-defined variables. The variable list is linked to the variable list contained in the local process library. This, in turn, is linked to the variable list of the [[rt_data_t]] context, and so on. A variable lookup will thus be recursively delegated to the linked variable lists, until a match is found. When modifying a variable which is not yet local, the program creates a local copy and uses this afterwards. Thus, when the local [[rt_data_t]] object is deleted, the context value is recovered. Models are kept in a model list which is separate from the variable list. Otherwise, they are treated in a similar manner: the local list is linked to the context model list. Model lookup is thus recursively delegated. When a model or any part of it is modified, the model is copied to the local [[rt_data_t]] object, so the context model is not modified. Commands such as [[integrate]] will create their own copy of the current model (and of the current variable list) at the point where they are executed. When a model is encountered for the first time, it is read from file. The reading is automatically delegated to the global context. Thus, this master copy survives until the main [[rt_data_t]] object is deleted, at program completion. If there is a currently active model, its variable list is linked to the main variable list. Variable lookups will then start from the model variable list. When the current model is switched, the new active model will get this link instead. Consequently, a change to the current model is kept as long as this model has a local copy; it survives local model switches. On the other hand, a parameter change in the current model doesn't affect any other model, even if the parameter name is identical. @ \subsection{Container for parse nodes} The runtime data set contains a bunch of parse nodes (chunks of code that have not been compiled into evaluation trees but saved for later use). We collect them here. This implementation has the useful effect that an assignment between two objects of this type will establish a pointer-target relationship for all components. <>= type :: rt_parse_nodes_t type(parse_node_t), pointer :: cuts_lexpr => null () type(parse_node_t), pointer :: scale_expr => null () type(parse_node_t), pointer :: fac_scale_expr => null () type(parse_node_t), pointer :: ren_scale_expr => null () type(parse_node_t), pointer :: weight_expr => null () type(parse_node_t), pointer :: selection_lexpr => null () type(parse_node_t), pointer :: reweight_expr => null () type(parse_node_t), pointer :: analysis_lexpr => null () type(parse_node_p), dimension(:), allocatable :: alt_setup contains <> end type rt_parse_nodes_t @ %def rt_parse_nodes_t @ Clear individual components. The parse nodes are nullified. No finalization needed since the pointer targets are part of the global parse tree. <>= procedure :: clear => rt_parse_nodes_clear <>= subroutine rt_parse_nodes_clear (rt_pn, name) class(rt_parse_nodes_t), intent(inout) :: rt_pn type(string_t), intent(in) :: name select case (char (name)) case ("cuts") rt_pn%cuts_lexpr => null () case ("scale") rt_pn%scale_expr => null () case ("factorization_scale") rt_pn%fac_scale_expr => null () case ("renormalization_scale") rt_pn%ren_scale_expr => null () case ("weight") rt_pn%weight_expr => null () case ("selection") rt_pn%selection_lexpr => null () case ("reweight") rt_pn%reweight_expr => null () case ("analysis") rt_pn%analysis_lexpr => null () end select end subroutine rt_parse_nodes_clear @ %def rt_parse_nodes_clear @ Output for the parse nodes. <>= procedure :: write => rt_parse_nodes_write <>= subroutine rt_parse_nodes_write (object, unit) class(rt_parse_nodes_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit) call wrt ("Cuts", object%cuts_lexpr) call write_separator (u) call wrt ("Scale", object%scale_expr) call write_separator (u) call wrt ("Factorization scale", object%fac_scale_expr) call write_separator (u) call wrt ("Renormalization scale", object%ren_scale_expr) call write_separator (u) call wrt ("Weight", object%weight_expr) call write_separator (u, 2) call wrt ("Event selection", object%selection_lexpr) call write_separator (u) call wrt ("Event reweighting factor", object%reweight_expr) call write_separator (u) call wrt ("Event analysis", object%analysis_lexpr) if (allocated (object%alt_setup)) then call write_separator (u, 2) write (u, "(1x,A,':')") "Alternative setups" do i = 1, size (object%alt_setup) call write_separator (u) call wrt ("Commands", object%alt_setup(i)%ptr) end do end if contains subroutine wrt (title, pn) character(*), intent(in) :: title type(parse_node_t), intent(in), pointer :: pn if (associated (pn)) then write (u, "(1x,A,':')") title call write_separator (u) call parse_node_write_rec (pn, u) else write (u, "(1x,A,':',1x,A)") title, "[undefined]" end if end subroutine wrt end subroutine rt_parse_nodes_write @ %def rt_parse_nodes_write @ Screen output for individual components. (This should eventually be more condensed, currently we print the internal representation tree.) <>= procedure :: show => rt_parse_nodes_show <>= subroutine rt_parse_nodes_show (rt_pn, name, unit) class(rt_parse_nodes_t), intent(in) :: rt_pn type(string_t), intent(in) :: name integer, intent(in), optional :: unit type(parse_node_t), pointer :: pn integer :: u u = given_output_unit (unit) select case (char (name)) case ("cuts") pn => rt_pn%cuts_lexpr case ("scale") pn => rt_pn%scale_expr case ("factorization_scale") pn => rt_pn%fac_scale_expr case ("renormalization_scale") pn => rt_pn%ren_scale_expr case ("weight") pn => rt_pn%weight_expr case ("selection") pn => rt_pn%selection_lexpr case ("reweight") pn => rt_pn%reweight_expr case ("analysis") pn => rt_pn%analysis_lexpr end select if (associated (pn)) then write (u, "(A,1x,A,1x,A)") "Expression:", char (name), "(parse tree):" call parse_node_write_rec (pn, u) else write (u, "(A,1x,A,A)") "Expression:", char (name), ": [undefined]" end if end subroutine rt_parse_nodes_show @ %def rt_parse_nodes_show @ \subsection{The data type} This is a big data container which contains everything that is used and modified during the command flow. A local copy of this can be used to temporarily override defaults. The data set is transparent. <>= public :: rt_data_t <>= type :: rt_data_t type(lexer_t), pointer :: lexer => null () type(rt_data_t), pointer :: context => null () type(string_t), dimension(:), allocatable :: export type(var_list_t) :: var_list type(iterations_list_t) :: it_list type(os_data_t) :: os_data type(model_list_t) :: model_list type(model_t), pointer :: model => null () logical :: model_is_copy = .false. type(model_t), pointer :: preload_model => null () type(model_t), pointer :: fallback_model => null () type(prclib_stack_t) :: prclib_stack type(process_library_t), pointer :: prclib => null () type(beam_structure_t) :: beam_structure type(rt_parse_nodes_t) :: pn type(process_stack_t) :: process_stack type(string_t), dimension(:), allocatable :: sample_fmt class(event_callback_t), allocatable :: event_callback type(file_list_t), pointer :: out_files => null () logical :: quit = .false. integer :: quit_code = 0 type(string_t) :: logfile logical :: nlo_fixed_order = .false. logical, dimension(0:5) :: selected_nlo_parts = .false. integer, dimension(:), allocatable :: nlo_component contains <> end type rt_data_t @ %def rt_data_t @ \subsection{Output} <>= procedure :: write => rt_data_write <>= subroutine rt_data_write (object, unit, vars, pacify) class(rt_data_t), intent(in) :: object integer, intent(in), optional :: unit type(string_t), dimension(:), intent(in), optional :: vars logical, intent(in), optional :: pacify integer :: u, i u = given_output_unit (unit) call write_separator (u, 2) write (u, "(1x,A)") "Runtime data:" if (object%get_n_export () > 0) then call write_separator (u, 2) write (u, "(1x,A)") "Exported objects and variables:" call write_separator (u) call object%write_exports (u) end if if (present (vars)) then if (size (vars) /= 0) then call write_separator (u, 2) write (u, "(1x,A)") "Selected variables:" call write_separator (u) call object%write_vars (u, vars) end if else call write_separator (u, 2) if (associated (object%model)) then call object%model%write_var_list (u, follow_link=.true.) else call object%var_list%write (u, follow_link=.true.) end if end if if (object%it_list%get_n_pass () > 0) then call write_separator (u, 2) write (u, "(1x)", advance="no") call object%it_list%write (u) end if if (associated (object%model)) then call write_separator (u, 2) call object%model%write (u) end if call object%prclib_stack%write (u) call object%beam_structure%write (u) call write_separator (u, 2) call object%pn%write (u) if (allocated (object%sample_fmt)) then call write_separator (u) write (u, "(1x,A)", advance="no") "Event sample formats = " do i = 1, size (object%sample_fmt) if (i > 1) write (u, "(A,1x)", advance="no") "," write (u, "(A)", advance="no") char (object%sample_fmt(i)) end do write (u, "(A)") end if call write_separator (u) write (u, "(1x,A)", advance="no") "Event callback:" if (allocated (object%event_callback)) then call object%event_callback%write (u) else write (u, "(1x,A)") "[undefined]" end if call object%process_stack%write (u, pacify) write (u, "(1x,A,1x,L1)") "quit :", object%quit write (u, "(1x,A,1x,I0)") "quit_code:", object%quit_code call write_separator (u, 2) write (u, "(1x,A,1x,A)") "Logfile :", "'" // trim (char (object%logfile)) // "'" call write_separator (u, 2) end subroutine rt_data_write @ %def rt_data_write @ Write only selected variables. <>= procedure :: write_vars => rt_data_write_vars <>= subroutine rt_data_write_vars (object, unit, vars) class(rt_data_t), intent(in), target :: object integer, intent(in), optional :: unit type(string_t), dimension(:), intent(in) :: vars type(var_list_t), pointer :: var_list integer :: u, i u = given_output_unit (unit) var_list => object%get_var_list_ptr () do i = 1, size (vars) associate (var => vars(i)) if (var_list%contains (var, follow_link=.true.)) then call var_list%write_var (var, unit = u, & follow_link = .true., defined=.true.) end if end associate end do end subroutine rt_data_write_vars @ %def rt_data_write_vars @ Write only the model list. <>= procedure :: write_model_list => rt_data_write_model_list <>= subroutine rt_data_write_model_list (object, unit) class(rt_data_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) call object%model_list%write (u) end subroutine rt_data_write_model_list @ %def rt_data_write_model_list @ Write only the library stack. <>= procedure :: write_libraries => rt_data_write_libraries <>= subroutine rt_data_write_libraries (object, unit, libpath) class(rt_data_t), intent(in) :: object integer, intent(in), optional :: unit logical, intent(in), optional :: libpath integer :: u u = given_output_unit (unit) call object%prclib_stack%write (u, libpath) end subroutine rt_data_write_libraries @ %def rt_data_write_libraries @ Write only the beam data. <>= procedure :: write_beams => rt_data_write_beams <>= subroutine rt_data_write_beams (object, unit) class(rt_data_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) call write_separator (u, 2) call object%beam_structure%write (u) call write_separator (u, 2) end subroutine rt_data_write_beams @ %def rt_data_write_beams @ Write only the process and event expressions. <>= procedure :: write_expr => rt_data_write_expr <>= subroutine rt_data_write_expr (object, unit) class(rt_data_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) call write_separator (u, 2) call object%pn%write (u) call write_separator (u, 2) end subroutine rt_data_write_expr @ %def rt_data_write_expr @ Write only the process stack. <>= procedure :: write_process_stack => rt_data_write_process_stack <>= subroutine rt_data_write_process_stack (object, unit) class(rt_data_t), intent(in) :: object integer, intent(in), optional :: unit call object%process_stack%write (unit) end subroutine rt_data_write_process_stack @ %def rt_data_write_process_stack @ <>= procedure :: write_var_descriptions => rt_data_write_var_descriptions <>= subroutine rt_data_write_var_descriptions (rt_data, unit, ascii_output) class(rt_data_t), intent(in) :: rt_data integer, intent(in), optional :: unit logical, intent(in), optional :: ascii_output integer :: u logical :: ao u = given_output_unit (unit) ao = .false.; if (present (ascii_output)) ao = ascii_output call rt_data%var_list%write (u, follow_link=.true., & descriptions=.true., ascii_output=ao) end subroutine rt_data_write_var_descriptions @ %def rt_data_write_var_descriptions @ <>= procedure :: show_description_of_string => rt_data_show_description_of_string <>= subroutine rt_data_show_description_of_string (rt_data, string, & unit, ascii_output) class(rt_data_t), intent(in) :: rt_data type(string_t), intent(in) :: string integer, intent(in), optional :: unit logical, intent(in), optional :: ascii_output integer :: u logical :: ao u = given_output_unit (unit) ao = .false.; if (present (ascii_output)) ao = ascii_output call rt_data%var_list%write_var (string, unit=u, follow_link=.true., & defined=.false., descriptions=.true., ascii_output=ao) end subroutine rt_data_show_description_of_string @ %def rt_data_show_description_of_string @ \subsection{Clear} The [[clear]] command can remove the contents of various subobjects. The objects themselves should stay. <>= procedure :: clear_beams => rt_data_clear_beams <>= subroutine rt_data_clear_beams (global) class(rt_data_t), intent(inout) :: global call global%beam_structure%final_sf () call global%beam_structure%final_pol () call global%beam_structure%final_mom () end subroutine rt_data_clear_beams @ %def rt_data_clear_beams @ \subsection{Initialization} Initialize runtime data. This defines special variables such as [[sqrts]], and should be done only for the instance that is actually global. Local copies will inherit the special variables. We link the global variable list to the process stack variable list, so the latter is always available (and kept global). <>= procedure :: global_init => rt_data_global_init <>= subroutine rt_data_global_init (global, paths, logfile) class(rt_data_t), intent(out), target :: global type(paths_t), intent(in), optional :: paths type(string_t), intent(in), optional :: logfile integer :: seed call global%os_data%init (paths) if (present (logfile)) then global%logfile = logfile else global%logfile = "" end if allocate (global%out_files) call system_clock (seed) call global%var_list%init_defaults (seed, paths) call global%init_pointer_variables () call global%process_stack%init_var_list (global%var_list) end subroutine rt_data_global_init @ %def rt_data_global_init @ \subsection{Local copies} This is done at compile time when a local copy of runtime data is needed: Link the variable list and initialize all derived parameters. This allows for synchronizing them with local variable changes without affecting global data. Also re-initialize pointer variables, so they point to local copies of their targets. <>= procedure :: local_init => rt_data_local_init <>= subroutine rt_data_local_init (local, global, env) class(rt_data_t), intent(inout), target :: local type(rt_data_t), intent(in), target :: global integer, intent(in), optional :: env local%context => global call local%process_stack%link (global%process_stack) call local%process_stack%init_var_list (local%var_list) call local%process_stack%link_var_list (global%var_list) call local%var_list%append_string (var_str ("$model_name"), & var_str (""), intrinsic=.true.) call local%init_pointer_variables () local%fallback_model => global%fallback_model local%os_data = global%os_data local%logfile = global%logfile call local%model_list%link (global%model_list) local%model => global%model if (associated (local%model)) then call local%model%link_var_list (local%var_list) end if if (allocated (global%event_callback)) then allocate (local%event_callback, source = global%event_callback) end if end subroutine rt_data_local_init @ %def rt_data_local_init @ These variables point to objects which get local copies: <>= procedure :: init_pointer_variables => rt_data_init_pointer_variables <>= subroutine rt_data_init_pointer_variables (local) class(rt_data_t), intent(inout), target :: local logical, target, save :: known = .true. call local%var_list%append_string_ptr (var_str ("$fc"), & local%os_data%fc, known, intrinsic=.true., & description=var_str('This string variable gives the ' // & '\ttt{Fortran} compiler used within \whizard. It can ' // & 'only be accessed, not set by the user. (cf. also ' // & '\ttt{\$fcflags})')) call local%var_list%append_string_ptr (var_str ("$fcflags"), & local%os_data%fcflags, known, intrinsic=.true., & description=var_str('This string variable gives the ' // & 'compiler flags for the \ttt{Fortran} compiler used ' // & 'within \whizard. It can only be accessed, not set by ' // & 'the user. (cf. also \ttt{\$fc})')) end subroutine rt_data_init_pointer_variables @ %def rt_data_init_pointer_variables @ This is done at execution time: Copy data, transfer pointers. [[local]] has intent(inout) because its local variable list has already been prepared by the previous routine. To be pedantic, the local pointers to model and library should point to the entries in the local copies. (However, as long as these are just shallow copies with identical content, this is actually irrelevant.) The process library and process stacks behave as global objects. The copies of the process library and process stacks should be shallow copies, so the contents stay identical. Since objects may be pushed on the stack in the local environment, upon restoring the global environment, we should reverse the assignment. Then the added stack elements will end up on the global stack. (This should be reconsidered in a parallel environment.) <>= procedure :: activate => rt_data_activate <>= subroutine rt_data_activate (local) class(rt_data_t), intent(inout), target :: local class(rt_data_t), pointer :: global global => local%context if (associated (global)) then local%lexer => global%lexer call global%copy_globals (local) local%os_data = global%os_data local%logfile = global%logfile if (associated (global%prclib)) then local%prclib => & local%prclib_stack%get_library_ptr (global%prclib%get_name ()) end if call local%import_values () call local%process_stack%link (global%process_stack) local%it_list = global%it_list local%beam_structure = global%beam_structure local%pn = global%pn if (allocated (local%sample_fmt)) deallocate (local%sample_fmt) if (allocated (global%sample_fmt)) then allocate (local%sample_fmt (size (global%sample_fmt)), & source = global%sample_fmt) end if local%out_files => global%out_files local%model => global%model local%model_is_copy = .false. else if (.not. associated (local%model)) then local%model => local%preload_model local%model_is_copy = .false. end if if (associated (local%model)) then call local%model%link_var_list (local%var_list) call local%var_list%set_string (var_str ("$model_name"), & local%model%get_name (), is_known = .true.) else call local%var_list%set_string (var_str ("$model_name"), & var_str (""), is_known = .false.) end if end subroutine rt_data_activate @ %def rt_data_activate @ Restore the previous state of data, without actually finalizing the local environment. We also clear the local process stack. Some local modifications (model list and process library stack) are communicated to the global context, if there is any. If the [[keep_local]] flag is set, we want to retain current settings in the local environment. In particular, we create an instance of the currently selected model (which thus becomes separated from the model library!). The local variables are also kept. <>= procedure :: deactivate => rt_data_deactivate <>= subroutine rt_data_deactivate (local, global, keep_local) class(rt_data_t), intent(inout), target :: local class(rt_data_t), intent(inout), optional, target :: global logical, intent(in), optional :: keep_local type(string_t) :: local_model, local_scheme logical :: same_model, delete delete = .true.; if (present (keep_local)) delete = .not. keep_local if (present (global)) then if (associated (global%model) .and. associated (local%model)) then local_model = local%model%get_name () if (global%model%has_schemes ()) then local_scheme = local%model%get_scheme () same_model = & global%model%matches (local_model, local_scheme) else same_model = global%model%matches (local_model) end if else same_model = .false. end if if (delete) then call local%process_stack%clear () call local%unselect_model () call local%unset_values () else if (associated (local%model)) then call local%ensure_model_copy () end if if (.not. same_model .and. associated (global%model)) then if (global%model%has_schemes ()) then call msg_message ("Restoring model '" // & char (global%model%get_name ()) // "', scheme '" // & char (global%model%get_scheme ()) // "'") else call msg_message ("Restoring model '" // & char (global%model%get_name ()) // "'") end if end if if (associated (global%model)) then call global%model%link_var_list (global%var_list) end if call global%restore_globals (local) else call local%unselect_model () end if end subroutine rt_data_deactivate @ %def rt_data_deactivate @ This imports the global objects for which local modifications should be kept. Currently, this is only the process library stack. <>= procedure :: copy_globals => rt_data_copy_globals <>= subroutine rt_data_copy_globals (global, local) class(rt_data_t), intent(in) :: global class(rt_data_t), intent(inout) :: local local%prclib_stack = global%prclib_stack end subroutine rt_data_copy_globals @ %def rt_data_copy_globals @ This restores global objects for which local modifications should be kept. May also modify (remove) the local objects. <>= procedure :: restore_globals => rt_data_restore_globals <>= subroutine rt_data_restore_globals (global, local) class(rt_data_t), intent(inout) :: global class(rt_data_t), intent(inout) :: local global%prclib_stack = local%prclib_stack call local%handle_exports (global) end subroutine rt_data_restore_globals @ %def rt_data_restore_globals @ \subsection{Exported objects} Exported objects are transferred to the global state when a local environment is closed. (For the top-level global data set, there is no effect.) The current implementation handles only the [[results]] object, which resolves to the local process stack. The stack elements are appended to the global stack without modification, the local stack becomes empty. Write names of objects to be exported: <>= procedure :: write_exports => rt_data_write_exports <>= subroutine rt_data_write_exports (rt_data, unit) class(rt_data_t), intent(in) :: rt_data integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit) do i = 1, rt_data%get_n_export () write (u, "(A)") char (rt_data%export(i)) end do end subroutine rt_data_write_exports @ %def rt_data_write_exports @ The number of entries in the export list. <>= procedure :: get_n_export => rt_data_get_n_export <>= function rt_data_get_n_export (rt_data) result (n) class(rt_data_t), intent(in) :: rt_data integer :: n if (allocated (rt_data%export)) then n = size (rt_data%export) else n = 0 end if end function rt_data_get_n_export @ %def rt_data_get_n_export @ Return a specific export @ Append new names to the export list. If a duplicate occurs, do not transfer it. <>= procedure :: append_exports => rt_data_append_exports <>= subroutine rt_data_append_exports (rt_data, export) class(rt_data_t), intent(inout) :: rt_data type(string_t), dimension(:), intent(in) :: export logical, dimension(:), allocatable :: mask type(string_t), dimension(:), allocatable :: tmp integer :: i, j, n if (.not. allocated (rt_data%export)) allocate (rt_data%export (0)) n = size (rt_data%export) allocate (mask (size (export)), source=.false.) do i = 1, size (export) mask(i) = all (export(i) /= rt_data%export) & .and. all (export(i) /= export(:i-1)) end do if (count (mask) > 0) then allocate (tmp (n + count (mask))) tmp(1:n) = rt_data%export(:) j = n do i = 1, size (export) if (mask(i)) then j = j + 1 tmp(j) = export(i) end if end do call move_alloc (from=tmp, to=rt_data%export) end if end subroutine rt_data_append_exports @ %def rt_data_append_exports @ Transfer export-objects from the [[local]] rt data to the [[global]] rt data, as far as supported. <>= procedure :: handle_exports => rt_data_handle_exports <>= subroutine rt_data_handle_exports (local, global) class(rt_data_t), intent(inout), target :: local class(rt_data_t), intent(inout), target :: global type(string_t) :: export integer :: i if (local%get_n_export () > 0) then do i = 1, local%get_n_export () export = local%export(i) select case (char (export)) case ("results") call msg_message ("Exporting integration results & &to outer environment") call local%transfer_process_stack (global) case default call msg_bug ("handle exports: '" & // char (export) // "' unsupported") end select end do end if end subroutine rt_data_handle_exports @ %def rt_data_handle_exports @ Export the process stack. One-by-one, take the last process from the local stack and push it on the global stack. Also handle the corresponding result variables: append if the process did not exist yet in the global stack, otherwise update. TODO: result variables do not work that way yet, require initialization in the global variable list. <>= procedure :: transfer_process_stack => rt_data_transfer_process_stack <>= subroutine rt_data_transfer_process_stack (local, global) class(rt_data_t), intent(inout), target :: local class(rt_data_t), intent(inout), target :: global type(process_entry_t), pointer :: process type(string_t) :: process_id do call local%process_stack%pop_last (process) if (.not. associated (process)) exit process_id = process%get_id () call global%process_stack%push (process) call global%process_stack%fill_result_vars (process_id) call global%process_stack%update_result_vars & (process_id, global%var_list) end do end subroutine rt_data_transfer_process_stack @ %def rt_data_transfer_process_stack @ \subsection{Finalization} Finalizer for the variable list and the structure-function list. This is done only for the global RT dataset; local copies contain pointers to this and do not need a finalizer. <>= procedure :: final => rt_data_global_final <>= subroutine rt_data_global_final (global) class(rt_data_t), intent(inout) :: global call global%process_stack%final () call global%prclib_stack%final () call global%model_list%final () call global%var_list%final (follow_link=.false.) if (associated (global%out_files)) then call file_list_final (global%out_files) deallocate (global%out_files) end if end subroutine rt_data_global_final @ %def rt_data_global_final @ The local copy needs a finalizer for the variable list, which consists of local copies. This finalizer is called only when the local environment is finally discarded. (Note that the process stack should already have been cleared after execution, which can occur many times for the same local environment.) <>= procedure :: local_final => rt_data_local_final <>= subroutine rt_data_local_final (local) class(rt_data_t), intent(inout) :: local call local%process_stack%clear () call local%model_list%final () call local%var_list%final (follow_link=.false.) end subroutine rt_data_local_final @ %def rt_data_local_final @ \subsection{Model Management} Read a model, so it becomes available for activation. No variables or model copies, this is just initialization. If this is a local environment, the model will be automatically read into the global context. <>= procedure :: read_model => rt_data_read_model <>= subroutine rt_data_read_model (global, name, model, scheme) class(rt_data_t), intent(inout) :: global type(string_t), intent(in) :: name type(string_t), intent(in), optional :: scheme type(model_t), pointer, intent(out) :: model type(string_t) :: filename filename = name // ".mdl" call global%model_list%read_model & (name, filename, global%os_data, model, scheme) end subroutine rt_data_read_model @ %def rt_data_read_model @ Read a UFO model. Create it on the fly if necessary. <>= procedure :: read_ufo_model => rt_data_read_ufo_model <>= subroutine rt_data_read_ufo_model (global, name, model, ufo_path) class(rt_data_t), intent(inout) :: global type(string_t), intent(in) :: name type(model_t), pointer, intent(out) :: model type(string_t), intent(in), optional :: ufo_path type(string_t) :: filename filename = name // ".ufo.mdl" call global%model_list%read_model & (name, filename, global%os_data, model, ufo=.true., ufo_path=ufo_path) end subroutine rt_data_read_ufo_model @ %def rt_data_read_ufo_model @ Initialize the fallback model. This model is used whenever the current model does not describe all physical particles (hadrons, mainly). It is not supposed to be modified, and the pointer should remain linked to this model. <>= procedure :: init_fallback_model => rt_data_init_fallback_model <>= subroutine rt_data_init_fallback_model (global, name, filename) class(rt_data_t), intent(inout) :: global type(string_t), intent(in) :: name, filename call global%model_list%read_model & (name, filename, global%os_data, global%fallback_model) end subroutine rt_data_init_fallback_model @ %def rt_data_init_fallback_model @ Activate a model: assign the current-model pointer and set the model name in the variable list. If necessary, read the model from file. Link the global variable list to the model variable list. <>= procedure :: select_model => rt_data_select_model <>= subroutine rt_data_select_model (global, name, scheme, ufo, ufo_path) class(rt_data_t), intent(inout), target :: global type(string_t), intent(in) :: name type(string_t), intent(in), optional :: scheme logical, intent(in), optional :: ufo type(string_t), intent(in), optional :: ufo_path logical :: same_model, ufo_model ufo_model = .false.; if (present (ufo)) ufo_model = ufo if (associated (global%model)) then same_model = global%model%matches (name, scheme, ufo) else same_model = .false. end if if (.not. same_model) then global%model => global%model_list%get_model_ptr (name, scheme, ufo) if (.not. associated (global%model)) then if (ufo_model) then call global%read_ufo_model (name, global%model, ufo_path) else call global%read_model (name, global%model) end if global%model_is_copy = .false. else if (associated (global%context)) then global%model_is_copy = & global%model_list%model_exists (name, scheme, ufo, & follow_link=.false.) else global%model_is_copy = .false. end if end if if (associated (global%model)) then call global%model%link_var_list (global%var_list) call global%var_list%set_string (var_str ("$model_name"), & name, is_known = .true.) if (global%model%is_ufo_model ()) then call msg_message ("Switching to model '" // char (name) // "' " & // "(generated from UFO source)") else if (global%model%has_schemes ()) then call msg_message ("Switching to model '" // char (name) // "', " & // "scheme '" // char (global%model%get_scheme ()) // "'") else call msg_message ("Switching to model '" // char (name) // "'") end if else call global%var_list%set_string (var_str ("$model_name"), & var_str (""), is_known = .false.) end if end subroutine rt_data_select_model @ %def rt_data_select_model @ Remove the model link. Do not unset the model name variable, because this may unset the variable in a parent [[rt_data]] object (via linked var lists). <>= procedure :: unselect_model => rt_data_unselect_model <>= subroutine rt_data_unselect_model (global) class(rt_data_t), intent(inout), target :: global if (associated (global%model)) then global%model => null () global%model_is_copy = .false. end if end subroutine rt_data_unselect_model @ %def rt_data_unselect_model @ Create a copy of the currently selected model and append it to the local model list. The model pointer is redirected to the copy. (Not applicable for the global model list, those models will be modified in-place.) <>= procedure :: ensure_model_copy => rt_data_ensure_model_copy <>= subroutine rt_data_ensure_model_copy (global) class(rt_data_t), intent(inout), target :: global if (associated (global%context)) then if (.not. global%model_is_copy) then call global%model_list%append_copy (global%model, global%model) global%model_is_copy = .true. call global%model%link_var_list (global%var_list) end if end if end subroutine rt_data_ensure_model_copy @ %def rt_data_ensure_model_copy @ Modify a model variable. The update mechanism will ensure that the model parameter set remains consistent. This has to take place in a local copy of the current model. If there is none yet, create one. <>= procedure :: model_set_real => rt_data_model_set_real <>= subroutine rt_data_model_set_real (global, name, rval, verbose, pacified) class(rt_data_t), intent(inout), target :: global type(string_t), intent(in) :: name real(default), intent(in) :: rval logical, intent(in), optional :: verbose, pacified call global%ensure_model_copy () call global%model%set_real (name, rval, verbose, pacified) end subroutine rt_data_model_set_real @ %def rt_data_model_set_real @ Modify particle properties. This has to take place in a local copy of the current model. If there is none yet, create one. <>= procedure :: modify_particle => rt_data_modify_particle <>= subroutine rt_data_modify_particle & (global, pdg, polarized, stable, decay, & isotropic_decay, diagonal_decay, decay_helicity) class(rt_data_t), intent(inout), target :: global integer, intent(in) :: pdg logical, intent(in), optional :: polarized, stable logical, intent(in), optional :: isotropic_decay, diagonal_decay integer, intent(in), optional :: decay_helicity type(string_t), dimension(:), intent(in), optional :: decay call global%ensure_model_copy () if (present (polarized)) then if (polarized) then call global%model%set_polarized (pdg) else call global%model%set_unpolarized (pdg) end if end if if (present (stable)) then if (stable) then call global%model%set_stable (pdg) else if (present (decay)) then call global%model%set_unstable & (pdg, decay, isotropic_decay, diagonal_decay, decay_helicity) else call msg_bug ("Setting particle unstable: missing decay processes") end if end if end subroutine rt_data_modify_particle @ %def rt_data_modify_particle @ \subsection{Managing Variables} Return a pointer to the currently active variable list. If there is no model, this is the global variable list. If there is one, it is the model variable list, which should be linked to the former. <>= procedure :: get_var_list_ptr => rt_data_get_var_list_ptr <>= function rt_data_get_var_list_ptr (global) result (var_list) class(rt_data_t), intent(in), target :: global type(var_list_t), pointer :: var_list if (associated (global%model)) then var_list => global%model%get_var_list_ptr () else var_list => global%var_list end if end function rt_data_get_var_list_ptr @ %def rt_data_get_var_list_ptr @ Initialize a local variable: append it to the current variable list. No initial value, yet. <>= procedure :: append_log => rt_data_append_log procedure :: append_int => rt_data_append_int procedure :: append_real => rt_data_append_real procedure :: append_cmplx => rt_data_append_cmplx procedure :: append_subevt => rt_data_append_subevt procedure :: append_pdg_array => rt_data_append_pdg_array procedure :: append_string => rt_data_append_string <>= subroutine rt_data_append_log (local, name, lval, intrinsic, user) class(rt_data_t), intent(inout) :: local type(string_t), intent(in) :: name logical, intent(in), optional :: lval logical, intent(in), optional :: intrinsic, user call local%var_list%append_log (name, lval, & intrinsic = intrinsic, user = user) end subroutine rt_data_append_log subroutine rt_data_append_int (local, name, ival, intrinsic, user) class(rt_data_t), intent(inout) :: local type(string_t), intent(in) :: name integer, intent(in), optional :: ival logical, intent(in), optional :: intrinsic, user call local%var_list%append_int (name, ival, & intrinsic = intrinsic, user = user) end subroutine rt_data_append_int subroutine rt_data_append_real (local, name, rval, intrinsic, user) class(rt_data_t), intent(inout) :: local type(string_t), intent(in) :: name real(default), intent(in), optional :: rval logical, intent(in), optional :: intrinsic, user call local%var_list%append_real (name, rval, & intrinsic = intrinsic, user = user) end subroutine rt_data_append_real subroutine rt_data_append_cmplx (local, name, cval, intrinsic, user) class(rt_data_t), intent(inout) :: local type(string_t), intent(in) :: name complex(default), intent(in), optional :: cval logical, intent(in), optional :: intrinsic, user call local%var_list%append_cmplx (name, cval, & intrinsic = intrinsic, user = user) end subroutine rt_data_append_cmplx subroutine rt_data_append_subevt (local, name, pval, intrinsic, user) class(rt_data_t), intent(inout) :: local type(string_t), intent(in) :: name type(subevt_t), intent(in), optional :: pval logical, intent(in) :: intrinsic, user call local%var_list%append_subevt (name, & intrinsic = intrinsic, user = user) end subroutine rt_data_append_subevt subroutine rt_data_append_pdg_array (local, name, aval, intrinsic, user) class(rt_data_t), intent(inout) :: local type(string_t), intent(in) :: name type(pdg_array_t), intent(in), optional :: aval logical, intent(in), optional :: intrinsic, user call local%var_list%append_pdg_array (name, aval, & intrinsic = intrinsic, user = user) end subroutine rt_data_append_pdg_array subroutine rt_data_append_string (local, name, sval, intrinsic, user) class(rt_data_t), intent(inout) :: local type(string_t), intent(in) :: name type(string_t), intent(in), optional :: sval logical, intent(in), optional :: intrinsic, user call local%var_list%append_string (name, sval, & intrinsic = intrinsic, user = user) end subroutine rt_data_append_string @ %def rt_data_append_log @ %def rt_data_append_int @ %def rt_data_append_real @ %def rt_data_append_cmplx @ %def rt_data_append_subevt @ %def rt_data_append_pdg_array @ %def rt_data_append_string @ Import values for all local variables, given a global context environment where these variables are defined. <>= procedure :: import_values => rt_data_import_values <>= subroutine rt_data_import_values (local) class(rt_data_t), intent(inout) :: local type(rt_data_t), pointer :: global global => local%context if (associated (global)) then call local%var_list%import (global%var_list) end if end subroutine rt_data_import_values @ %def rt_data_import_values @ Unset all variable values. <>= procedure :: unset_values => rt_data_unset_values <>= subroutine rt_data_unset_values (global) class(rt_data_t), intent(inout) :: global call global%var_list%undefine (follow_link=.false.) end subroutine rt_data_unset_values @ %def rt_data_unset_values @ Set a variable. (Not a model variable, these are handled separately.) We can assume that the variable has been initialized. <>= procedure :: set_log => rt_data_set_log procedure :: set_int => rt_data_set_int procedure :: set_real => rt_data_set_real procedure :: set_cmplx => rt_data_set_cmplx procedure :: set_subevt => rt_data_set_subevt procedure :: set_pdg_array => rt_data_set_pdg_array procedure :: set_string => rt_data_set_string <>= subroutine rt_data_set_log & (global, name, lval, is_known, force, verbose) class(rt_data_t), intent(inout) :: global type(string_t), intent(in) :: name logical, intent(in) :: lval logical, intent(in) :: is_known logical, intent(in), optional :: force, verbose call global%var_list%set_log (name, lval, is_known, & force=force, verbose=verbose) end subroutine rt_data_set_log subroutine rt_data_set_int & (global, name, ival, is_known, force, verbose) class(rt_data_t), intent(inout) :: global type(string_t), intent(in) :: name integer, intent(in) :: ival logical, intent(in) :: is_known logical, intent(in), optional :: force, verbose call global%var_list%set_int (name, ival, is_known, & force=force, verbose=verbose) end subroutine rt_data_set_int subroutine rt_data_set_real & (global, name, rval, is_known, force, verbose, pacified) class(rt_data_t), intent(inout) :: global type(string_t), intent(in) :: name real(default), intent(in) :: rval logical, intent(in) :: is_known logical, intent(in), optional :: force, verbose, pacified call global%var_list%set_real (name, rval, is_known, & force=force, verbose=verbose, pacified=pacified) end subroutine rt_data_set_real subroutine rt_data_set_cmplx & (global, name, cval, is_known, force, verbose, pacified) class(rt_data_t), intent(inout) :: global type(string_t), intent(in) :: name complex(default), intent(in) :: cval logical, intent(in) :: is_known logical, intent(in), optional :: force, verbose, pacified call global%var_list%set_cmplx (name, cval, is_known, & force=force, verbose=verbose, pacified=pacified) end subroutine rt_data_set_cmplx subroutine rt_data_set_subevt & (global, name, pval, is_known, force, verbose) class(rt_data_t), intent(inout) :: global type(string_t), intent(in) :: name type(subevt_t), intent(in) :: pval logical, intent(in) :: is_known logical, intent(in), optional :: force, verbose call global%var_list%set_subevt (name, pval, is_known, & force=force, verbose=verbose) end subroutine rt_data_set_subevt subroutine rt_data_set_pdg_array & (global, name, aval, is_known, force, verbose) class(rt_data_t), intent(inout) :: global type(string_t), intent(in) :: name type(pdg_array_t), intent(in) :: aval logical, intent(in) :: is_known logical, intent(in), optional :: force, verbose call global%var_list%set_pdg_array (name, aval, is_known, & force=force, verbose=verbose) end subroutine rt_data_set_pdg_array subroutine rt_data_set_string & (global, name, sval, is_known, force, verbose) class(rt_data_t), intent(inout) :: global type(string_t), intent(in) :: name type(string_t), intent(in) :: sval logical, intent(in) :: is_known logical, intent(in), optional :: force, verbose call global%var_list%set_string (name, sval, is_known, & force=force, verbose=verbose) end subroutine rt_data_set_string @ %def rt_data_set_log @ %def rt_data_set_int @ %def rt_data_set_real @ %def rt_data_set_cmplx @ %def rt_data_set_subevt @ %def rt_data_set_pdg_array @ %def rt_data_set_string @ Return the value of a variable, assuming that the type is correct. <>= procedure :: get_lval => rt_data_get_lval procedure :: get_ival => rt_data_get_ival procedure :: get_rval => rt_data_get_rval procedure :: get_cval => rt_data_get_cval procedure :: get_pval => rt_data_get_pval procedure :: get_aval => rt_data_get_aval procedure :: get_sval => rt_data_get_sval <>= function rt_data_get_lval (global, name) result (lval) logical :: lval class(rt_data_t), intent(in), target :: global type(string_t), intent(in) :: name type(var_list_t), pointer :: var_list var_list => global%get_var_list_ptr () lval = var_list%get_lval (name) end function rt_data_get_lval function rt_data_get_ival (global, name) result (ival) integer :: ival class(rt_data_t), intent(in), target :: global type(string_t), intent(in) :: name type(var_list_t), pointer :: var_list var_list => global%get_var_list_ptr () ival = var_list%get_ival (name) end function rt_data_get_ival function rt_data_get_rval (global, name) result (rval) real(default) :: rval class(rt_data_t), intent(in), target :: global type(string_t), intent(in) :: name type(var_list_t), pointer :: var_list var_list => global%get_var_list_ptr () rval = var_list%get_rval (name) end function rt_data_get_rval function rt_data_get_cval (global, name) result (cval) complex(default) :: cval class(rt_data_t), intent(in), target :: global type(string_t), intent(in) :: name type(var_list_t), pointer :: var_list var_list => global%get_var_list_ptr () cval = var_list%get_cval (name) end function rt_data_get_cval function rt_data_get_aval (global, name) result (aval) type(pdg_array_t) :: aval class(rt_data_t), intent(in), target :: global type(string_t), intent(in) :: name type(var_list_t), pointer :: var_list var_list => global%get_var_list_ptr () aval = var_list%get_aval (name) end function rt_data_get_aval function rt_data_get_pval (global, name) result (pval) type(subevt_t) :: pval class(rt_data_t), intent(in), target :: global type(string_t), intent(in) :: name type(var_list_t), pointer :: var_list var_list => global%get_var_list_ptr () pval = var_list%get_pval (name) end function rt_data_get_pval function rt_data_get_sval (global, name) result (sval) type(string_t) :: sval class(rt_data_t), intent(in), target :: global type(string_t), intent(in) :: name type(var_list_t), pointer :: var_list var_list => global%get_var_list_ptr () sval = var_list%get_sval (name) end function rt_data_get_sval @ %def rt_data_get_lval @ %def rt_data_get_ival @ %def rt_data_get_rval @ %def rt_data_get_cval @ %def rt_data_get_pval @ %def rt_data_get_aval @ %def rt_data_get_sval @ Return true if the variable exists in the global list. <>= procedure :: contains => rt_data_contains <>= function rt_data_contains (global, name) result (lval) logical :: lval - class(rt_data_t), intent(in) :: global + class(rt_data_t), intent(in), target :: global type(string_t), intent(in) :: name type(var_list_t), pointer :: var_list var_list => global%get_var_list_ptr () lval = var_list%contains (name) end function rt_data_contains @ %def rt_data_contains +@ Return true if the value of the variable is known. +<>= + procedure :: is_known => rt_data_is_known +<>= + function rt_data_is_known (global, name) result (lval) + logical :: lval + class(rt_data_t), intent(in), target :: global + type(string_t), intent(in) :: name + type(var_list_t), pointer :: var_list + var_list => global%get_var_list_ptr () + lval = var_list%is_known (name) + end function rt_data_is_known + +@ %def rt_data_is_known @ \subsection{Further Content} Add a library (available via a pointer of type [[prclib_entry_t]]) to the stack and update the pointer and variable list to the current library. The pointer association of [[prclib_entry]] will be discarded. <>= procedure :: add_prclib => rt_data_add_prclib <>= subroutine rt_data_add_prclib (global, prclib_entry) class(rt_data_t), intent(inout) :: global type(prclib_entry_t), intent(inout), pointer :: prclib_entry call global%prclib_stack%push (prclib_entry) call global%update_prclib (global%prclib_stack%get_first_ptr ()) end subroutine rt_data_add_prclib @ %def rt_data_add_prclib @ Given a pointer to a process library, make this the currently active library. <>= procedure :: update_prclib => rt_data_update_prclib <>= subroutine rt_data_update_prclib (global, lib) class(rt_data_t), intent(inout) :: global type(process_library_t), intent(in), target :: lib global%prclib => lib if (global%var_list%contains (& var_str ("$library_name"), follow_link = .false.)) then call global%var_list%set_string (var_str ("$library_name"), & global%prclib%get_name (), is_known=.true.) else call global%var_list%append_string ( & var_str ("$library_name"), global%prclib%get_name (), & intrinsic = .true.) end if end subroutine rt_data_update_prclib @ %def rt_data_update_prclib @ \subsection{Miscellaneous} The helicity selection data are distributed among several parameters. Here, we collect them in a single record. <>= procedure :: get_helicity_selection => rt_data_get_helicity_selection <>= function rt_data_get_helicity_selection (rt_data) result (helicity_selection) class(rt_data_t), intent(in) :: rt_data type(helicity_selection_t) :: helicity_selection associate (var_list => rt_data%var_list) helicity_selection%active = var_list%get_lval (& var_str ("?helicity_selection_active")) if (helicity_selection%active) then helicity_selection%threshold = var_list%get_rval (& var_str ("helicity_selection_threshold")) helicity_selection%cutoff = var_list%get_ival (& var_str ("helicity_selection_cutoff")) end if end associate end function rt_data_get_helicity_selection @ %def rt_data_get_helicity_selection @ Show the beam setup: beam structure and relevant global variables. <>= procedure :: show_beams => rt_data_show_beams <>= subroutine rt_data_show_beams (rt_data, unit) class(rt_data_t), intent(in) :: rt_data integer, intent(in), optional :: unit type(string_t) :: s integer :: u u = given_output_unit (unit) associate (beams => rt_data%beam_structure, var_list => rt_data%var_list) call beams%write (u) if (.not. beams%asymmetric () .and. beams%get_n_beam () == 2) then write (u, "(2x,A," // FMT_19 // ",1x,'GeV')") "sqrts =", & var_list%get_rval (var_str ("sqrts")) end if if (beams%contains ("pdf_builtin")) then s = var_list%get_sval (var_str ("$pdf_builtin_set")) if (s /= "") then write (u, "(2x,A,1x,3A)") "PDF set =", '"', char (s), '"' else write (u, "(2x,A,1x,A)") "PDF set =", "[undefined]" end if end if if (beams%contains ("lhapdf")) then s = var_list%get_sval (var_str ("$lhapdf_dir")) if (s /= "") then write (u, "(2x,A,1x,3A)") "LHAPDF dir =", '"', char (s), '"' end if s = var_list%get_sval (var_str ("$lhapdf_file")) if (s /= "") then write (u, "(2x,A,1x,3A)") "LHAPDF file =", '"', char (s), '"' write (u, "(2x,A,1x,I0)") "LHAPDF member =", & var_list%get_ival (var_str ("lhapdf_member")) else write (u, "(2x,A,1x,A)") "LHAPDF file =", "[undefined]" end if end if if (beams%contains ("lhapdf_photon")) then s = var_list%get_sval (var_str ("$lhapdf_dir")) if (s /= "") then write (u, "(2x,A,1x,3A)") "LHAPDF dir =", '"', char (s), '"' end if s = var_list%get_sval (var_str ("$lhapdf_photon_file")) if (s /= "") then write (u, "(2x,A,1x,3A)") "LHAPDF file =", '"', char (s), '"' write (u, "(2x,A,1x,I0)") "LHAPDF member =", & var_list%get_ival (var_str ("lhapdf_member")) write (u, "(2x,A,1x,I0)") "LHAPDF scheme =", & var_list%get_ival (& var_str ("lhapdf_photon_scheme")) else write (u, "(2x,A,1x,A)") "LHAPDF file =", "[undefined]" end if end if if (beams%contains ("isr")) then write (u, "(2x,A," // FMT_19 // ")") "ISR alpha =", & var_list%get_rval (var_str ("isr_alpha")) write (u, "(2x,A," // FMT_19 // ")") "ISR Q max =", & var_list%get_rval (var_str ("isr_q_max")) write (u, "(2x,A," // FMT_19 // ")") "ISR mass =", & var_list%get_rval (var_str ("isr_mass")) write (u, "(2x,A,1x,I0)") "ISR order =", & var_list%get_ival (var_str ("isr_order")) write (u, "(2x,A,1x,L1)") "ISR recoil =", & var_list%get_lval (var_str ("?isr_recoil")) write (u, "(2x,A,1x,L1)") "ISR energy cons. =", & var_list%get_lval (var_str ("?isr_keep_energy")) end if if (beams%contains ("epa")) then write (u, "(2x,A," // FMT_19 // ")") "EPA alpha =", & var_list%get_rval (var_str ("epa_alpha")) write (u, "(2x,A," // FMT_19 // ")") "EPA x min =", & var_list%get_rval (var_str ("epa_x_min")) write (u, "(2x,A," // FMT_19 // ")") "EPA Q min =", & var_list%get_rval (var_str ("epa_q_min")) write (u, "(2x,A," // FMT_19 // ")") "EPA Q max =", & var_list%get_rval (var_str ("epa_q_max")) write (u, "(2x,A," // FMT_19 // ")") "EPA mass =", & var_list%get_rval (var_str ("epa_mass")) write (u, "(2x,A,1x,L1)") "EPA recoil =", & var_list%get_lval (var_str ("?epa_recoil")) write (u, "(2x,A,1x,L1)") "EPA energy cons. =", & var_list%get_lval (var_str ("?epa_keep_energy")) end if if (beams%contains ("ewa")) then write (u, "(2x,A," // FMT_19 // ")") "EWA x min =", & var_list%get_rval (var_str ("ewa_x_min")) write (u, "(2x,A," // FMT_19 // ")") "EWA Pt max =", & var_list%get_rval (var_str ("ewa_pt_max")) write (u, "(2x,A," // FMT_19 // ")") "EWA mass =", & var_list%get_rval (var_str ("ewa_mass")) write (u, "(2x,A,1x,L1)") "EWA recoil =", & var_list%get_lval (var_str ("?ewa_recoil")) write (u, "(2x,A,1x,L1)") "EWA energy cons. =", & var_list%get_lval (var_str ("ewa_keep_energy")) end if if (beams%contains ("circe1")) then write (u, "(2x,A,1x,I0)") "CIRCE1 version =", & var_list%get_ival (var_str ("circe1_ver")) write (u, "(2x,A,1x,I0)") "CIRCE1 revision =", & var_list%get_ival (var_str ("circe1_rev")) s = var_list%get_sval (var_str ("$circe1_acc")) write (u, "(2x,A,1x,A)") "CIRCE1 acceler. =", char (s) write (u, "(2x,A,1x,I0)") "CIRCE1 chattin. =", & var_list%get_ival (var_str ("circe1_chat")) write (u, "(2x,A," // FMT_19 // ")") "CIRCE1 sqrts =", & var_list%get_rval (var_str ("circe1_sqrts")) write (u, "(2x,A," // FMT_19 // ")") "CIRCE1 epsil. =", & var_list%get_rval (var_str ("circe1_eps")) write (u, "(2x,A,1x,L1)") "CIRCE1 phot. 1 =", & var_list%get_lval (var_str ("?circe1_photon1")) write (u, "(2x,A,1x,L1)") "CIRCE1 phot. 2 =", & var_list%get_lval (var_str ("?circe1_photon2")) write (u, "(2x,A,1x,L1)") "CIRCE1 generat. =", & var_list%get_lval (var_str ("?circe1_generate")) write (u, "(2x,A,1x,L1)") "CIRCE1 mapping =", & var_list%get_lval (var_str ("?circe1_map")) write (u, "(2x,A," // FMT_19 // ")") "CIRCE1 map. slope =", & var_list%get_rval (var_str ("circe1_mapping_slope")) write (u, "(2x,A,1x,L1)") "CIRCE recoil photon =", & var_list%get_lval (var_str ("?circe1_with_radiation")) end if if (beams%contains ("circe2")) then s = var_list%get_sval (var_str ("$circe2_design")) write (u, "(2x,A,1x,A)") "CIRCE2 design =", char (s) s = var_list%get_sval (var_str ("$circe2_file")) write (u, "(2x,A,1x,A)") "CIRCE2 file =", char (s) write (u, "(2x,A,1x,L1)") "CIRCE2 polarized =", & var_list%get_lval (var_str ("?circe2_polarized")) end if if (beams%contains ("gaussian")) then write (u, "(2x,A,1x," // FMT_12 // ")") "Gaussian spread 1 =", & var_list%get_rval (var_str ("gaussian_spread1")) write (u, "(2x,A,1x," // FMT_12 // ")") "Gaussian spread 2 =", & var_list%get_rval (var_str ("gaussian_spread2")) end if if (beams%contains ("beam_events")) then s = var_list%get_sval (var_str ("$beam_events_file")) write (u, "(2x,A,1x,A)") "Beam events file =", char (s) write (u, "(2x,A,1x,L1)") "Beam events EOF warn =", & var_list%get_lval (var_str ("?beam_events_warn_eof")) end if end associate end subroutine rt_data_show_beams @ %def rt_data_show_beams @ Return the collision energy as determined by the current beam settings. Without beam setup, this is the [[sqrts]] variable. If the value is meaningless for a setup, the function returns zero. <>= procedure :: get_sqrts => rt_data_get_sqrts <>= function rt_data_get_sqrts (rt_data) result (sqrts) class(rt_data_t), intent(in) :: rt_data real(default) :: sqrts sqrts = rt_data%var_list%get_rval (var_str ("sqrts")) end function rt_data_get_sqrts @ %def rt_data_get_sqrts @ For testing purposes, the [[rt_data_t]] contents can be pacified to suppress numerical fluctuations in (constant) test matrix elements. <>= procedure :: pacify => rt_data_pacify <>= subroutine rt_data_pacify (rt_data, efficiency_reset, error_reset) class(rt_data_t), intent(inout) :: rt_data logical, intent(in), optional :: efficiency_reset, error_reset type(process_entry_t), pointer :: process process => rt_data%process_stack%first do while (associated (process)) call process%pacify (efficiency_reset, error_reset) process => process%next end do end subroutine rt_data_pacify @ %def rt_data_pacify @ <>= procedure :: set_event_callback => rt_data_set_event_callback <>= subroutine rt_data_set_event_callback (global, callback) class(rt_data_t), intent(inout) :: global class(event_callback_t), intent(in) :: callback if (allocated (global%event_callback)) deallocate (global%event_callback) allocate (global%event_callback, source = callback) end subroutine rt_data_set_event_callback @ %def rt_data_set_event_callback @ <>= procedure :: has_event_callback => rt_data_has_event_callback procedure :: get_event_callback => rt_data_get_event_callback <>= function rt_data_has_event_callback (global) result (flag) class(rt_data_t), intent(in) :: global logical :: flag flag = allocated (global%event_callback) end function rt_data_has_event_callback function rt_data_get_event_callback (global) result (callback) class(rt_data_t), intent(in) :: global class(event_callback_t), allocatable :: callback if (allocated (global%event_callback)) then allocate (callback, source = global%event_callback) end if end function rt_data_get_event_callback @ %def rt_data_has_event_callback @ %def rt_data_get_event_callback @ Force system-dependent objects to well-defined values. Some of the variables are locked and therefore must be addressed directly. This is, of course, only required for testing purposes. In principle, the [[real_specimen]] variables could be set to their values in [[rt_data_t]], but this depends on the precision again, so we set them to some dummy values. <>= public :: fix_system_dependencies <>= subroutine fix_system_dependencies (global) class(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list var_list => global%get_var_list_ptr () call var_list%set_log (var_str ("?omega_openmp"), & .false., is_known = .true., force=.true.) call var_list%set_log (var_str ("?openmp_is_active"), & .false., is_known = .true., force=.true.) call var_list%set_int (var_str ("openmp_num_threads_default"), & 1, is_known = .true., force=.true.) call var_list%set_int (var_str ("openmp_num_threads"), & 1, is_known = .true., force=.true.) call var_list%set_int (var_str ("real_range"), & 307, is_known = .true., force=.true.) call var_list%set_int (var_str ("real_precision"), & 15, is_known = .true., force=.true.) call var_list%set_real (var_str ("real_epsilon"), & 1.e-16_default, is_known = .true., force=.true.) call var_list%set_real (var_str ("real_tiny"), & 1.e-300_default, is_known = .true., force=.true.) global%os_data%fc = "Fortran-compiler" global%os_data%fcflags = "Fortran-flags" end subroutine fix_system_dependencies @ %def fix_system_dependencies @ <>= public :: show_description_of_string <>= subroutine show_description_of_string (string) type(string_t), intent(in) :: string type(rt_data_t), target :: global call global%global_init () call global%show_description_of_string (string, ascii_output=.true.) end subroutine show_description_of_string @ %def show_description_of_string @ <>= public :: show_tex_descriptions <>= subroutine show_tex_descriptions () type(rt_data_t), target :: global call global%global_init () call fix_system_dependencies (global) call global%set_int (var_str ("seed"), 0, is_known=.true.) call global%var_list%sort () call global%write_var_descriptions () end subroutine show_tex_descriptions @ %def show_tex_descriptions @ \subsection{Unit Tests} Test module, followed by the corresponding implementation module. <<[[rt_data_ut.f90]]>>= <> module rt_data_ut use unit_tests use rt_data_uti <> <> contains <> end module rt_data_ut @ %def rt_data_ut @ <<[[rt_data_uti.f90]]>>= <> module rt_data_uti <> <> use format_defs, only: FMT_19 use ifiles use lexers use parser use flavors use variables, only: var_list_t, var_entry_t, var_entry_init_int use eval_trees use models use prclib_stacks use rt_data <> <> contains <> <> end module rt_data_uti @ %def rt_data_ut @ API: driver for the unit tests below. <>= public :: rt_data_test <>= subroutine rt_data_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine rt_data_test @ %def rt_data_test @ \subsubsection{Initial content} @ Display the RT data in the state just after (global) initialization. <>= call test (rt_data_1, "rt_data_1", & "initialize", & u, results) <>= public :: rt_data_1 <>= subroutine rt_data_1 (u) integer, intent(in) :: u type(rt_data_t), target :: global write (u, "(A)") "* Test output: rt_data_1" write (u, "(A)") "* Purpose: initialize global runtime data" write (u, "(A)") call global%global_init (logfile = var_str ("rt_data.log")) call fix_system_dependencies (global) call global%set_int (var_str ("seed"), 0, is_known=.true.) call global%it_list%init ([2, 3], [5000, 20000]) call global%write (u) call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: rt_data_1" end subroutine rt_data_1 @ %def rt_data_1 @ \subsubsection{Fill values} Fill in empty slots in the runtime data block. <>= call test (rt_data_2, "rt_data_2", & "fill", & u, results) <>= public :: rt_data_2 <>= subroutine rt_data_2 (u) integer, intent(in) :: u type(rt_data_t), target :: global type(flavor_t), dimension(2) :: flv type(string_t) :: cut_expr_text type(ifile_t) :: ifile type(stream_t) :: stream type(parse_tree_t) :: parse_tree write (u, "(A)") "* Test output: rt_data_2" write (u, "(A)") "* Purpose: initialize global runtime data & &and fill contents" write (u, "(A)") call syntax_model_file_init () call global%global_init () call fix_system_dependencies (global) call global%select_model (var_str ("Test")) call global%set_real (var_str ("sqrts"), & 1000._default, is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known=.true.) call flv%init ([25,25], global%model) call global%set_string (var_str ("$run_id"), & var_str ("run1"), is_known = .true.) call global%set_real (var_str ("luminosity"), & 33._default, is_known = .true.) call syntax_pexpr_init () cut_expr_text = "all Pt > 100 [s]" call ifile_append (ifile, cut_expr_text) call stream_init (stream, ifile) call parse_tree_init_lexpr (parse_tree, stream, .true.) global%pn%cuts_lexpr => parse_tree%get_root_ptr () allocate (global%sample_fmt (2)) global%sample_fmt(1) = "foo_fmt" global%sample_fmt(2) = "bar_fmt" call global%write (u) call parse_tree_final (parse_tree) call stream_final (stream) call ifile_final (ifile) call syntax_pexpr_final () call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: rt_data_2" end subroutine rt_data_2 @ %def rt_data_2 @ \subsubsection{Save and restore} Set up a local runtime data block, change some contents, restore the global block. <>= call test (rt_data_3, "rt_data_3", & "save/restore", & u, results) <>= public :: rt_data_3 <>= subroutine rt_data_3 (u) use event_base, only: event_callback_nop_t integer, intent(in) :: u type(rt_data_t), target :: global, local type(flavor_t), dimension(2) :: flv type(string_t) :: cut_expr_text type(ifile_t) :: ifile type(stream_t) :: stream type(parse_tree_t) :: parse_tree type(prclib_entry_t), pointer :: lib type(event_callback_nop_t) :: event_callback_nop write (u, "(A)") "* Test output: rt_data_3" write (u, "(A)") "* Purpose: initialize global runtime data & &and fill contents;" write (u, "(A)") "* copy to local block and back" write (u, "(A)") write (u, "(A)") "* Init global data" write (u, "(A)") call syntax_model_file_init () call global%global_init () call fix_system_dependencies (global) call global%set_int (var_str ("seed"), & 0, is_known=.true.) call global%select_model (var_str ("Test")) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call flv%init ([25,25], global%model) call global%beam_structure%init_sf (flv%get_name (), [1]) call global%beam_structure%set_sf (1, 1, var_str ("pdf_builtin")) call global%set_string (var_str ("$run_id"), & var_str ("run1"), is_known = .true.) call global%set_real (var_str ("luminosity"), & 33._default, is_known = .true.) call syntax_pexpr_init () cut_expr_text = "all Pt > 100 [s]" call ifile_append (ifile, cut_expr_text) call stream_init (stream, ifile) call parse_tree_init_lexpr (parse_tree, stream, .true.) global%pn%cuts_lexpr => parse_tree%get_root_ptr () allocate (global%sample_fmt (2)) global%sample_fmt(1) = "foo_fmt" global%sample_fmt(2) = "bar_fmt" allocate (lib) call lib%init (var_str ("library_1")) call global%add_prclib (lib) write (u, "(A)") "* Init and modify local data" write (u, "(A)") call local%local_init (global) call local%append_string (var_str ("$integration_method"), intrinsic=.true.) call local%append_string (var_str ("$phs_method"), intrinsic=.true.) call local%activate () write (u, "(1x,A,L1)") "model associated = ", associated (local%model) write (u, "(1x,A,L1)") "library associated = ", associated (local%prclib) write (u, *) call local%model_set_real (var_str ("ms"), 150._default) call local%set_string (var_str ("$integration_method"), & var_str ("midpoint"), is_known = .true.) call local%set_string (var_str ("$phs_method"), & var_str ("single"), is_known = .true.) local%os_data%fc = "Local compiler" allocate (lib) call lib%init (var_str ("library_2")) call local%add_prclib (lib) call local%set_event_callback (event_callback_nop) call local%write (u) write (u, "(A)") write (u, "(A)") "* Restore global data" write (u, "(A)") call local%deactivate (global) write (u, "(1x,A,L1)") "model associated = ", associated (global%model) write (u, "(1x,A,L1)") "library associated = ", associated (global%prclib) write (u, *) call global%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call parse_tree_final (parse_tree) call stream_final (stream) call ifile_final (ifile) call syntax_pexpr_final () call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: rt_data_3" end subroutine rt_data_3 @ %def rt_data_3 @ \subsubsection{Show variables} Display selected variables in the global record. <>= call test (rt_data_4, "rt_data_4", & "show variables", & u, results) <>= public :: rt_data_4 <>= subroutine rt_data_4 (u) integer, intent(in) :: u type(rt_data_t), target :: global type(string_t), dimension(0) :: empty_string_array write (u, "(A)") "* Test output: rt_data_4" write (u, "(A)") "* Purpose: display selected variables" write (u, "(A)") call global%global_init () write (u, "(A)") "* No variables:" write (u, "(A)") call global%write_vars (u, empty_string_array) write (u, "(A)") "* Two variables:" write (u, "(A)") call global%write_vars (u, & [var_str ("?unweighted"), var_str ("$phs_method")]) write (u, "(A)") write (u, "(A)") "* Display whole record with selected variables" write (u, "(A)") call global%write (u, & vars = [var_str ("?unweighted"), var_str ("$phs_method")]) call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: rt_data_4" end subroutine rt_data_4 @ %def rt_data_4 @ \subsubsection{Show parts} Display only selected parts in the state just after (global) initialization. <>= call test (rt_data_5, "rt_data_5", & "show parts", & u, results) <>= public :: rt_data_5 <>= subroutine rt_data_5 (u) integer, intent(in) :: u type(rt_data_t), target :: global write (u, "(A)") "* Test output: rt_data_5" write (u, "(A)") "* Purpose: display parts of rt data" write (u, "(A)") call global%global_init () call global%write_libraries (u) write (u, "(A)") call global%write_beams (u) write (u, "(A)") call global%write_process_stack (u) call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: rt_data_5" end subroutine rt_data_5 @ %def rt_data_5 @ \subsubsection{Local Model} Locally modify a model and restore the global one. We need an auxiliary function to determine the status of a model particle: <>= function is_stable (pdg, global) result (flag) integer, intent(in) :: pdg type(rt_data_t), intent(in) :: global logical :: flag type(flavor_t) :: flv call flv%init (pdg, global%model) flag = flv%is_stable () end function is_stable function is_polarized (pdg, global) result (flag) integer, intent(in) :: pdg type(rt_data_t), intent(in) :: global logical :: flag type(flavor_t) :: flv call flv%init (pdg, global%model) flag = flv%is_polarized () end function is_polarized @ %def is_stable is_polarized <>= call test (rt_data_6, "rt_data_6", & "local model", & u, results) <>= public :: rt_data_6 <>= subroutine rt_data_6 (u) integer, intent(in) :: u type(rt_data_t), target :: global, local type(var_list_t), pointer :: model_vars type(string_t) :: var_name write (u, "(A)") "* Test output: rt_data_6" write (u, "(A)") "* Purpose: apply and keep local modifications to model" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%select_model (var_str ("Test")) write (u, "(A)") "* Original model" write (u, "(A)") call global%write_model_list (u) write (u, *) write (u, "(A,L1)") "s is stable = ", is_stable (25, global) write (u, "(A,L1)") "f is polarized = ", is_polarized (6, global) write (u, *) var_name = "ff" write (u, "(A)", advance="no") "Global model variable: " model_vars => global%model%get_var_list_ptr () call model_vars%write_var (var_name, u) write (u, "(A)") write (u, "(A)") "* Apply local modifications: unstable" write (u, "(A)") call local%local_init (global) call local%activate () call local%model_set_real (var_name, 0.4_default) call local%modify_particle (25, stable = .false., decay = [var_str ("d1")]) call local%modify_particle (6, stable = .false., & decay = [var_str ("f1")], isotropic_decay = .true.) call local%modify_particle (-6, stable = .false., & decay = [var_str ("f2"), var_str ("f3")], diagonal_decay = .true.) call local%model%write (u) write (u, "(A)") write (u, "(A)") "* Further modifications" write (u, "(A)") call local%modify_particle (6, stable = .false., & decay = [var_str ("f1")], & diagonal_decay = .true., isotropic_decay = .false.) call local%modify_particle (-6, stable = .false., & decay = [var_str ("f2"), var_str ("f3")], & diagonal_decay = .false., isotropic_decay = .true.) call local%model%write (u) write (u, "(A)") write (u, "(A)") "* Further modifications: f stable but polarized" write (u, "(A)") call local%modify_particle (6, stable = .true., polarized = .true.) call local%modify_particle (-6, stable = .true.) call local%model%write (u) write (u, "(A)") write (u, "(A)") "* Global model" write (u, "(A)") call global%model%write (u) write (u, *) write (u, "(A,L1)") "s is stable = ", is_stable (25, global) write (u, "(A,L1)") "f is polarized = ", is_polarized (6, global) write (u, "(A)") write (u, "(A)") "* Local model" write (u, "(A)") call local%model%write (u) write (u, *) write (u, "(A,L1)") "s is stable = ", is_stable (25, local) write (u, "(A,L1)") "f is polarized = ", is_polarized (6, local) write (u, *) write (u, "(A)", advance="no") "Global model variable: " model_vars => global%model%get_var_list_ptr () call model_vars%write_var (var_name, u) write (u, "(A)", advance="no") "Local model variable: " associate (model_var_list_ptr => local%model%get_var_list_ptr()) call model_var_list_ptr%write_var (var_name, u) end associate write (u, "(A)") write (u, "(A)") "* Restore global" call local%deactivate (global, keep_local = .true.) write (u, "(A)") write (u, "(A)") "* Global model" write (u, "(A)") call global%model%write (u) write (u, *) write (u, "(A,L1)") "s is stable = ", is_stable (25, global) write (u, "(A,L1)") "f is polarized = ", is_polarized (6, global) write (u, "(A)") write (u, "(A)") "* Local model" write (u, "(A)") call local%model%write (u) write (u, *) write (u, "(A,L1)") "s is stable = ", is_stable (25, local) write (u, "(A,L1)") "f is polarized = ", is_polarized (6, local) write (u, *) write (u, "(A)", advance="no") "Global model variable: " model_vars => global%model%get_var_list_ptr () call model_vars%write_var (var_name, u) write (u, "(A)", advance="no") "Local model variable: " associate (model_var_list_ptr => local%model%get_var_list_ptr()) call model_var_list_ptr%write_var (var_name, u) end associate write (u, "(A)") write (u, "(A)") "* Cleanup" call local%model%final () deallocate (local%model) call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: rt_data_6" end subroutine rt_data_6 @ %def rt_data_6 @ \subsubsection{Result variables} Initialize result variables and check that they are accessible via the global variable list. <>= call test (rt_data_7, "rt_data_7", & "result variables", & u, results) <>= public :: rt_data_7 <>= subroutine rt_data_7 (u) integer, intent(in) :: u type(rt_data_t), target :: global write (u, "(A)") "* Test output: rt_data_7" write (u, "(A)") "* Purpose: set and access result variables" write (u, "(A)") write (u, "(A)") "* Initialize process variables" write (u, "(A)") call global%global_init () call global%process_stack%init_result_vars (var_str ("testproc")) call global%var_list%write_var (& var_str ("integral(testproc)"), u, defined=.true.) call global%var_list%write_var (& var_str ("error(testproc)"), u, defined=.true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: rt_data_7" end subroutine rt_data_7 @ %def rt_data_7 @ \subsubsection{Beam energy} If beam parameters are set, the variable [[sqrts]] is not necessarily the collision energy. The method [[get_sqrts]] fetches the correct value. <>= call test (rt_data_8, "rt_data_8", & "beam energy", & u, results) <>= public :: rt_data_8 <>= subroutine rt_data_8 (u) integer, intent(in) :: u type(rt_data_t), target :: global write (u, "(A)") "* Test output: rt_data_8" write (u, "(A)") "* Purpose: get correct collision energy" write (u, "(A)") write (u, "(A)") "* Initialize" write (u, "(A)") call global%global_init () write (u, "(A)") "* Set sqrts" write (u, "(A)") call global%set_real (var_str ("sqrts"), & 1000._default, is_known = .true.) write (u, "(1x,A," // FMT_19 // ")") "sqrts =", global%get_sqrts () write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: rt_data_8" end subroutine rt_data_8 @ %def rt_data_8 @ \subsubsection{Local variable modifications} <>= call test (rt_data_9, "rt_data_9", & "local variables", & u, results) <>= public :: rt_data_9 <>= subroutine rt_data_9 (u) integer, intent(in) :: u type(rt_data_t), target :: global, local type(var_list_t), pointer :: var_list write (u, "(A)") "* Test output: rt_data_9" write (u, "(A)") "* Purpose: handle local variables" write (u, "(A)") call syntax_model_file_init () write (u, "(A)") "* Initialize global record and set some variables" write (u, "(A)") call global%global_init () call global%select_model (var_str ("Test")) call global%set_real (var_str ("sqrts"), 17._default, is_known = .true.) call global%set_real (var_str ("luminosity"), 2._default, is_known = .true.) call global%model_set_real (var_str ("ff"), 0.5_default) call global%model_set_real (var_str ("gy"), 1.2_default) var_list => global%get_var_list_ptr () call var_list%write_var (var_str ("sqrts"), u, defined=.true.) call var_list%write_var (var_str ("luminosity"), u, defined=.true.) call var_list%write_var (var_str ("ff"), u, defined=.true.) call var_list%write_var (var_str ("gy"), u, defined=.true.) call var_list%write_var (var_str ("mf"), u, defined=.true.) call var_list%write_var (var_str ("x"), u, defined=.true.) write (u, "(A)") write (u, "(1x,A,1x,F5.2)") "sqrts = ", & global%get_rval (var_str ("sqrts")) write (u, "(1x,A,1x,F5.2)") "luminosity = ", & global%get_rval (var_str ("luminosity")) write (u, "(1x,A,1x,F5.2)") "ff = ", & global%get_rval (var_str ("ff")) write (u, "(1x,A,1x,F5.2)") "gy = ", & global%get_rval (var_str ("gy")) write (u, "(1x,A,1x,F5.2)") "mf = ", & global%get_rval (var_str ("mf")) write (u, "(1x,A,1x,F5.2)") "x = ", & global%get_rval (var_str ("x")) write (u, "(A)") write (u, "(A)") "* Create local record with local variables" write (u, "(A)") call local%local_init (global) call local%append_real (var_str ("luminosity"), intrinsic = .true.) call local%append_real (var_str ("x"), user = .true.) call local%activate () var_list => local%get_var_list_ptr () call var_list%write_var (var_str ("sqrts"), u) call var_list%write_var (var_str ("luminosity"), u) call var_list%write_var (var_str ("ff"), u) call var_list%write_var (var_str ("gy"), u) call var_list%write_var (var_str ("mf"), u) call var_list%write_var (var_str ("x"), u, defined=.true.) write (u, "(A)") write (u, "(1x,A,1x,F5.2)") "sqrts = ", & local%get_rval (var_str ("sqrts")) write (u, "(1x,A,1x,F5.2)") "luminosity = ", & local%get_rval (var_str ("luminosity")) write (u, "(1x,A,1x,F5.2)") "ff = ", & local%get_rval (var_str ("ff")) write (u, "(1x,A,1x,F5.2)") "gy = ", & local%get_rval (var_str ("gy")) write (u, "(1x,A,1x,F5.2)") "mf = ", & local%get_rval (var_str ("mf")) write (u, "(1x,A,1x,F5.2)") "x = ", & local%get_rval (var_str ("x")) write (u, "(A)") write (u, "(A)") "* Modify some local variables" write (u, "(A)") call local%set_real (var_str ("luminosity"), 42._default, is_known=.true.) call local%set_real (var_str ("x"), 6.66_default, is_known=.true.) call local%model_set_real (var_str ("ff"), 0.7_default) var_list => local%get_var_list_ptr () call var_list%write_var (var_str ("sqrts"), u) call var_list%write_var (var_str ("luminosity"), u) call var_list%write_var (var_str ("ff"), u) call var_list%write_var (var_str ("gy"), u) call var_list%write_var (var_str ("mf"), u) call var_list%write_var (var_str ("x"), u, defined=.true.) write (u, "(A)") write (u, "(1x,A,1x,F5.2)") "sqrts = ", & local%get_rval (var_str ("sqrts")) write (u, "(1x,A,1x,F5.2)") "luminosity = ", & local%get_rval (var_str ("luminosity")) write (u, "(1x,A,1x,F5.2)") "ff = ", & local%get_rval (var_str ("ff")) write (u, "(1x,A,1x,F5.2)") "gy = ", & local%get_rval (var_str ("gy")) write (u, "(1x,A,1x,F5.2)") "mf = ", & local%get_rval (var_str ("mf")) write (u, "(1x,A,1x,F5.2)") "x = ", & local%get_rval (var_str ("x")) write (u, "(A)") write (u, "(A)") "* Restore globals" write (u, "(A)") call local%deactivate (global) var_list => global%get_var_list_ptr () call var_list%write_var (var_str ("sqrts"), u) call var_list%write_var (var_str ("luminosity"), u) call var_list%write_var (var_str ("ff"), u) call var_list%write_var (var_str ("gy"), u) call var_list%write_var (var_str ("mf"), u) call var_list%write_var (var_str ("x"), u, defined=.true.) write (u, "(A)") write (u, "(1x,A,1x,F5.2)") "sqrts = ", & global%get_rval (var_str ("sqrts")) write (u, "(1x,A,1x,F5.2)") "luminosity = ", & global%get_rval (var_str ("luminosity")) write (u, "(1x,A,1x,F5.2)") "ff = ", & global%get_rval (var_str ("ff")) write (u, "(1x,A,1x,F5.2)") "gy = ", & global%get_rval (var_str ("gy")) write (u, "(1x,A,1x,F5.2)") "mf = ", & global%get_rval (var_str ("mf")) write (u, "(1x,A,1x,F5.2)") "x = ", & global%get_rval (var_str ("x")) write (u, "(A)") write (u, "(A)") "* Cleanup" call local%local_final () call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: rt_data_9" end subroutine rt_data_9 @ %def rt_data_9 @ \subsubsection{Descriptions} <>= call test(rt_data_10, "rt_data_10", & "descriptions", u, results) <>= public :: rt_data_10 <>= subroutine rt_data_10 (u) integer, intent(in) :: u type(rt_data_t) :: global ! type(var_list_t) :: var_list write (u, "(A)") "* Test output: rt_data_10" write (u, "(A)") "* Purpose: display descriptions" write (u, "(A)") call global%var_list%append_real (var_str ("sqrts"), & intrinsic=.true., & description=var_str ('Real variable in order to set the center-of-mass ' // & 'energy for the collisions.')) call global%var_list%append_real (var_str ("luminosity"), 0._default, & intrinsic=.true., & description=var_str ('This specifier \ttt{luminosity = {\em ' // & '}} sets the integrated luminosity (in inverse femtobarns, ' // & 'fb${}^{-1}$) for the event generation of the processes in the ' // & '\sindarin\ input files.')) call global%var_list%append_int (var_str ("seed"), 1234, & intrinsic=.true., & description=var_str ('Integer variable \ttt{seed = {\em }} ' // & 'that allows to set a specific random seed \ttt{num}.')) call global%var_list%append_string (var_str ("$method"), var_str ("omega"), & intrinsic=.true., & description=var_str ('This string variable specifies the method ' // & 'for the matrix elements to be used in the evaluation.')) call global%var_list%append_log (var_str ("?read_color_factors"), .true., & intrinsic=.true., & description=var_str ('This flag decides whether to read QCD ' // & 'color factors from the matrix element provided by each method, ' // & 'or to try and calculate the color factors in \whizard\ internally.')) call global%var_list%sort () call global%write_var_descriptions (u) call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: rt_data_10" end subroutine rt_data_10 @ %def rt_data_10 @ \subsubsection{Export objects} Export objects are variables or other data that should be copied or otherwise applied to corresponding objects in the outer scope. We test appending and retrieval for the export list. <>= call test(rt_data_11, "rt_data_11", & "export objects", u, results) <>= public :: rt_data_11 <>= subroutine rt_data_11 (u) integer, intent(in) :: u type(rt_data_t) :: global type(string_t), dimension(:), allocatable :: exports integer :: i write (u, "(A)") "* Test output: rt_data_11" write (u, "(A)") "* Purpose: handle export object list" write (u, "(A)") write (u, "(A)") "* Empty export list" write (u, "(A)") call global%write_exports (u) write (u, "(A)") "* Add an entry" write (u, "(A)") allocate (exports (1)) exports(1) = var_str ("results") do i = 1, size (exports) write (u, "('+ ',A)") char (exports(i)) end do write (u, *) call global%append_exports (exports) call global%write_exports (u) write (u, "(A)") write (u, "(A)") "* Add more entries, including doubler" write (u, "(A)") deallocate (exports) allocate (exports (3)) exports(1) = var_str ("foo") exports(2) = var_str ("results") exports(3) = var_str ("bar") do i = 1, size (exports) write (u, "('+ ',A)") char (exports(i)) end do write (u, *) call global%append_exports (exports) call global%write_exports (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: rt_data_11" end subroutine rt_data_11 @ %def rt_data_11 @ @ \clearpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Select implementations} For abstract types (process core, integrator, phase space, etc.), we need a way to dynamically select a concrete type, using either data given by the user or a previous selection of a concrete type. This is done by subroutines in the current module. We would like to put this in the [[me_methods]] folder but it also depends on [[gosam]] and [[openloops]], so it is unclear where to put it. <<[[dispatch_me_methods.f90]]>>= <> module dispatch_me_methods <> <> use physics_defs, only: BORN use diagnostics use sm_qcd use variables, only: var_list_t use models use model_data use prc_core_def use prc_core use prc_test_core use prc_template_me use prc_test use prc_omega use prc_external use prc_gosam use prc_openloops use prc_recola use prc_threshold <> <> contains <> end module dispatch_me_methods @ %def dispatch_me_methods @ \subsection{Process Core Definition} The [[prc_core_def_t]] abstract type can be instantiated by providing a [[$method]] string variable. <>= public :: dispatch_core_def <>= subroutine dispatch_core_def (core_def, prt_in, prt_out, & model, var_list, id, nlo_type, method) class(prc_core_def_t), allocatable, intent(out) :: core_def type(string_t), dimension(:), intent(in) :: prt_in type(string_t), dimension(:), intent(in) :: prt_out type(model_t), pointer, intent(in) :: model type(var_list_t), intent(in) :: var_list type(string_t), intent(in), optional :: id integer, intent(in), optional :: nlo_type type(string_t), intent(in), optional :: method type(string_t) :: model_name, meth type(string_t) :: ufo_path type(string_t) :: restrictions logical :: ufo logical :: cms_scheme logical :: openmp_support logical :: report_progress logical :: diags, diags_color logical :: write_phs_output type(string_t) :: extra_options, correction_type integer :: nlo integer :: alpha_power integer :: alphas_power if (present (method)) then meth = method else meth = var_list%get_sval (var_str ("$method")) end if if (debug_on) call msg_debug2 (D_CORE, "dispatch_core_def") if (associated (model)) then model_name = model%get_name () cms_scheme = model%get_scheme () == "Complex_Mass_Scheme" ufo = model%is_ufo_model () ufo_path = model%get_ufo_path () else model_name = "" cms_scheme = .false. ufo = .false. end if restrictions = var_list%get_sval (& var_str ("$restrictions")) diags = var_list%get_lval (& var_str ("?vis_diags")) diags_color = var_list%get_lval (& var_str ("?vis_diags_color")) openmp_support = var_list%get_lval (& var_str ("?omega_openmp")) report_progress = var_list%get_lval (& var_str ("?report_progress")) write_phs_output = var_list%get_lval (& var_str ("?omega_write_phs_output")) extra_options = var_list%get_sval (& var_str ("$omega_flags")) nlo = BORN; if (present (nlo_type)) nlo = nlo_type alpha_power = var_list%get_ival (var_str ("alpha_power")) alphas_power = var_list%get_ival (var_str ("alphas_power")) correction_type = var_list%get_sval (var_str ("$nlo_correction_type")) if (debug_on) call msg_debug2 (D_CORE, "dispatching core method: ", meth) select case (char (meth)) case ("unit_test") allocate (prc_test_def_t :: core_def) select type (core_def) type is (prc_test_def_t) call core_def%init (model_name, prt_in, prt_out) end select case ("template") allocate (template_me_def_t :: core_def) select type (core_def) type is (template_me_def_t) call core_def%init (model, prt_in, prt_out, unity = .false.) end select case ("template_unity") allocate (template_me_def_t :: core_def) select type (core_def) type is (template_me_def_t) call core_def%init (model, prt_in, prt_out, unity = .true.) end select case ("omega") allocate (omega_def_t :: core_def) select type (core_def) type is (omega_def_t) call core_def%init (model_name, prt_in, prt_out, & .false., ufo, ufo_path, & restrictions, cms_scheme, & openmp_support, report_progress, write_phs_output, & extra_options, diags, diags_color) end select case ("ovm") allocate (omega_def_t :: core_def) select type (core_def) type is (omega_def_t) call core_def%init (model_name, prt_in, prt_out, & .true., .false., var_str (""), & restrictions, cms_scheme, & openmp_support, report_progress, write_phs_output, & extra_options, diags, diags_color) end select case ("gosam") allocate (gosam_def_t :: core_def) select type (core_def) type is (gosam_def_t) if (present (id)) then call core_def%init (id, model_name, prt_in, & prt_out, nlo, restrictions, var_list) else call msg_fatal ("Dispatch GoSam def: No id!") end if end select case ("openloops") allocate (openloops_def_t :: core_def) select type (core_def) type is (openloops_def_t) if (present (id)) then call core_def%init (id, model_name, prt_in, & prt_out, nlo, restrictions, var_list) else call msg_fatal ("Dispatch OpenLoops def: No id!") end if end select case ("recola") call abort_if_recola_not_active () allocate (recola_def_t :: core_def) select type (core_def) type is (recola_def_t) if (present (id)) then call core_def%init (id, model_name, prt_in, prt_out, & nlo, alpha_power, alphas_power, correction_type, & restrictions) else call msg_fatal ("Dispatch RECOLA def: No id!") end if end select case ("dummy") allocate (prc_external_test_def_t :: core_def) select type (core_def) type is (prc_external_test_def_t) if (present (id)) then call core_def%init (id, model_name, prt_in, prt_out) else call msg_fatal ("Dispatch User-Defined Test def: No id!") end if end select case ("threshold") allocate (threshold_def_t :: core_def) select type (core_def) type is (threshold_def_t) if (present (id)) then call core_def%init (id, model_name, prt_in, prt_out, & nlo, restrictions) else call msg_fatal ("Dispatch Threshold def: No id!") end if end select case default call msg_fatal ("Process configuration: method '" & // char (meth) // "' not implemented") end select end subroutine dispatch_core_def @ %def dispatch_core_def @ \subsection{Process core allocation} Here we allocate an object of abstract type [[prc_core_t]] with a concrete type that matches a process definition. The [[prc_omega_t]] extension will require the current parameter set, so we take the opportunity to grab it from the model. <>= public :: dispatch_core <>= subroutine dispatch_core (core, core_def, model, & helicity_selection, qcd, use_color_factors, has_beam_pol) class(prc_core_t), allocatable, intent(inout) :: core class(prc_core_def_t), intent(in) :: core_def class(model_data_t), intent(in), target, optional :: model type(helicity_selection_t), intent(in), optional :: helicity_selection type(qcd_t), intent(in), optional :: qcd logical, intent(in), optional :: use_color_factors logical, intent(in), optional :: has_beam_pol select type (core_def) type is (prc_test_def_t) allocate (test_t :: core) type is (template_me_def_t) allocate (prc_template_me_t :: core) select type (core) type is (prc_template_me_t) call core%set_parameters (model) end select class is (omega_def_t) if (.not. allocated (core)) allocate (prc_omega_t :: core) select type (core) type is (prc_omega_t) call core%set_parameters (model, & helicity_selection, qcd, use_color_factors) end select type is (gosam_def_t) if (.not. allocated (core)) allocate (prc_gosam_t :: core) select type (core) type is (prc_gosam_t) call core%set_parameters (qcd) end select type is (openloops_def_t) if (.not. allocated (core)) allocate (prc_openloops_t :: core) select type (core) type is (prc_openloops_t) call core%set_parameters (qcd) end select type is (recola_def_t) if (.not. allocated (core)) allocate (prc_recola_t :: core) select type (core) type is (prc_recola_t) call core%set_parameters (qcd, model) end select type is (prc_external_test_def_t) if (.not. allocated (core)) allocate (prc_external_test_t :: core) select type (core) type is (prc_external_test_t) call core%set_parameters (qcd, model) end select type is (threshold_def_t) if (.not. allocated (core)) allocate (prc_threshold_t :: core) select type (core) type is (prc_threshold_t) call core%set_parameters (qcd, model) call core%set_beam_pol (has_beam_pol) end select class default call msg_bug ("Process core: unexpected process definition type") end select end subroutine dispatch_core @ %def dispatch_core @ \subsection{Process core update and restoration} Here we take an existing object of abstract type [[prc_core_t]] and update the parameters as given by the current state of [[model]]. Optionally, we can save the previous state as [[saved_core]]. The second routine restores the original from the save. (In the test case, there is no possible update.) <>= public :: dispatch_core_update public :: dispatch_core_restore <>= subroutine dispatch_core_update & (core, model, helicity_selection, qcd, saved_core) class(prc_core_t), allocatable, intent(inout) :: core class(model_data_t), intent(in), optional, target :: model type(helicity_selection_t), intent(in), optional :: helicity_selection type(qcd_t), intent(in), optional :: qcd class(prc_core_t), allocatable, intent(inout), optional :: saved_core if (present (saved_core)) then allocate (saved_core, source = core) end if select type (core) type is (test_t) type is (prc_omega_t) call core%set_parameters (model, helicity_selection, qcd) call core%activate_parameters () class is (prc_external_t) call msg_message ("Updating user defined cores is not implemented yet.") class default call msg_bug ("Process core update: unexpected process definition type") end select end subroutine dispatch_core_update subroutine dispatch_core_restore (core, saved_core) class(prc_core_t), allocatable, intent(inout) :: core class(prc_core_t), allocatable, intent(inout) :: saved_core call move_alloc (from = saved_core, to = core) select type (core) type is (test_t) type is (prc_omega_t) call core%activate_parameters () class default call msg_bug ("Process core restore: unexpected process definition type") end select end subroutine dispatch_core_restore @ %def dispatch_core_update dispatch_core_restore @ \subsection{Unit Tests} Test module, followed by the corresponding implementation module. <<[[dispatch_ut.f90]]>>= <> module dispatch_ut use unit_tests use dispatch_uti <> <> <> contains <> end module dispatch_ut @ %def dispatch_ut @ <<[[dispatch_uti.f90]]>>= <> module dispatch_uti <> <> use os_interface, only: os_data_t use physics_defs, only: ELECTRON, PROTON use sm_qcd, only: qcd_t use flavors, only: flavor_t use interactions, only: reset_interaction_counter use pdg_arrays, only: pdg_array_t, assignment(=) use prc_core_def, only: prc_core_def_t use prc_test_core, only: test_t use prc_core, only: prc_core_t use prc_test, only: prc_test_def_t use prc_omega, only: omega_def_t, prc_omega_t use sf_mappings, only: sf_channel_t use sf_base, only: sf_data_t, sf_config_t use phs_base, only: phs_channel_collection_t use variables, only: var_list_t use model_data, only: model_data_t use models, only: syntax_model_file_init, syntax_model_file_final use rt_data, only: rt_data_t use dispatch_phase_space, only: dispatch_sf_channels use dispatch_beams, only: sf_prop_t, dispatch_qcd use dispatch_beams, only: dispatch_sf_config, dispatch_sf_data use dispatch_me_methods, only: dispatch_core_def, dispatch_core use dispatch_me_methods, only: dispatch_core_update, dispatch_core_restore use sf_base_ut, only: sf_test_data_t <> <> <> contains <> <> end module dispatch_uti @ %def dispatch_uti @ API: driver for the unit tests below. <>= public :: dispatch_test <>= subroutine dispatch_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine dispatch_test @ %def dispatch_test @ \subsubsection{Select type: process definition} <>= call test (dispatch_1, "dispatch_1", & "process configuration method", & u, results) <>= public :: dispatch_1 <>= subroutine dispatch_1 (u) integer, intent(in) :: u type(string_t), dimension(2) :: prt_in, prt_out type(rt_data_t), target :: global class(prc_core_def_t), allocatable :: core_def write (u, "(A)") "* Test output: dispatch_1" write (u, "(A)") "* Purpose: select process configuration method" write (u, "(A)") call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) prt_in = [var_str ("a"), var_str ("b")] prt_out = [var_str ("c"), var_str ("d")] write (u, "(A)") "* Allocate core_def as prc_test_def" call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call dispatch_core_def (core_def, prt_in, prt_out, global%model, global%var_list) select type (core_def) type is (prc_test_def_t) call core_def%write (u) end select deallocate (core_def) write (u, "(A)") write (u, "(A)") "* Allocate core_def as omega_def" write (u, "(A)") call global%set_string (var_str ("$method"), & var_str ("omega"), is_known = .true.) call dispatch_core_def (core_def, prt_in, prt_out, global%model, global%var_list) select type (core_def) type is (omega_def_t) call core_def%write (u) end select call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: dispatch_1" end subroutine dispatch_1 @ %def dispatch_1 @ \subsubsection{Select type: process core} <>= call test (dispatch_2, "dispatch_2", & "process core", & u, results) <>= public :: dispatch_2 <>= subroutine dispatch_2 (u) integer, intent(in) :: u type(string_t), dimension(2) :: prt_in, prt_out type(rt_data_t), target :: global class(prc_core_def_t), allocatable :: core_def class(prc_core_t), allocatable :: core write (u, "(A)") "* Test output: dispatch_2" write (u, "(A)") "* Purpose: select process configuration method" write (u, "(A)") " and allocate process core" write (u, "(A)") call syntax_model_file_init () call global%global_init () prt_in = [var_str ("a"), var_str ("b")] prt_out = [var_str ("c"), var_str ("d")] write (u, "(A)") "* Allocate core as test_t" write (u, "(A)") call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call dispatch_core_def (core_def, prt_in, prt_out, global%model, global%var_list) call dispatch_core (core, core_def) select type (core) type is (test_t) call core%write (u) end select deallocate (core) deallocate (core_def) write (u, "(A)") write (u, "(A)") "* Allocate core as prc_omega_t" write (u, "(A)") call global%set_string (var_str ("$method"), & var_str ("omega"), is_known = .true.) call dispatch_core_def (core_def, prt_in, prt_out, global%model, global%var_list) call global%select_model (var_str ("Test")) call global%set_log (& var_str ("?helicity_selection_active"), & .true., is_known = .true.) call global%set_real (& var_str ("helicity_selection_threshold"), & 1e9_default, is_known = .true.) call global%set_int (& var_str ("helicity_selection_cutoff"), & 10, is_known = .true.) call dispatch_core (core, core_def, & global%model, & global%get_helicity_selection ()) call core_def%allocate_driver (core%driver, var_str ("")) select type (core) type is (prc_omega_t) call core%write (u) end select call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: dispatch_2" end subroutine dispatch_2 @ %def dispatch_2 @ \subsubsection{Select type: structure-function data} This is an extra dispatcher that enables the test structure functions. This procedure should be assigned to the [[dispatch_sf_data_extra]] hook before any tests are executed. <>= public :: dispatch_sf_data_test <>= subroutine dispatch_sf_data_test (data, sf_method, i_beam, sf_prop, & var_list, var_list_global, model, os_data, sqrts, pdg_in, pdg_prc, polarized) class(sf_data_t), allocatable, intent(inout) :: data type(string_t), intent(in) :: sf_method integer, dimension(:), intent(in) :: i_beam type(var_list_t), intent(in) :: var_list type(var_list_t), intent(inout) :: var_list_global class(model_data_t), target, intent(in) :: model type(os_data_t), intent(in) :: os_data real(default), intent(in) :: sqrts type(pdg_array_t), dimension(:), intent(inout) :: pdg_in type(pdg_array_t), dimension(:,:), intent(in) :: pdg_prc type(sf_prop_t), intent(inout) :: sf_prop logical, intent(in) :: polarized select case (char (sf_method)) case ("sf_test_0", "sf_test_1") allocate (sf_test_data_t :: data) select type (data) type is (sf_test_data_t) select case (char (sf_method)) case ("sf_test_0"); call data%init (model, pdg_in(i_beam(1))) case ("sf_test_1"); call data%init (model, pdg_in(i_beam(1)),& mode = 1) end select end select end select end subroutine dispatch_sf_data_test @ %def dispatch_sf_data_test @ The actual test. We can't move this to [[beams]] as it depends on [[model_features]] for the [[model_list_t]]. <>= call test (dispatch_7, "dispatch_7", & "structure-function data", & u, results) <>= public :: dispatch_7 <>= subroutine dispatch_7 (u) integer, intent(in) :: u type(rt_data_t), target :: global type(os_data_t) :: os_data type(string_t) :: prt, sf_method type(sf_prop_t) :: sf_prop class(sf_data_t), allocatable :: data type(pdg_array_t), dimension(1) :: pdg_in type(pdg_array_t), dimension(1,1) :: pdg_prc type(pdg_array_t), dimension(1) :: pdg_out integer, dimension(:), allocatable :: pdg1 write (u, "(A)") "* Test output: dispatch_7" write (u, "(A)") "* Purpose: select and configure & &structure function data" write (u, "(A)") call global%global_init () call os_data%init () call syntax_model_file_init () call global%select_model (var_str ("QCD")) call reset_interaction_counter () call global%set_real (var_str ("sqrts"), & 14000._default, is_known = .true.) prt = "p" call global%beam_structure%init_sf ([prt, prt], [1]) pdg_in = 2212 write (u, "(A)") "* Allocate data as sf_pdf_builtin_t" write (u, "(A)") sf_method = "pdf_builtin" call dispatch_sf_data (data, sf_method, [1], sf_prop, & global%get_var_list_ptr (), global%var_list, & global%model, global%os_data, global%get_sqrts (), & pdg_in, pdg_prc, .false.) call data%write (u) call data%get_pdg_out (pdg_out) pdg1 = pdg_out(1) write (u, "(A)") write (u, "(1x,A,99(1x,I0))") "PDG(out) = ", pdg1 deallocate (data) write (u, "(A)") write (u, "(A)") "* Allocate data for different PDF set" write (u, "(A)") pdg_in = 2212 call global%set_string (var_str ("$pdf_builtin_set"), & var_str ("CTEQ6M"), is_known = .true.) sf_method = "pdf_builtin" call dispatch_sf_data (data, sf_method, [1], sf_prop, & global%get_var_list_ptr (), global%var_list, & global%model, global%os_data, global%get_sqrts (), & pdg_in, pdg_prc, .false.) call data%write (u) call data%get_pdg_out (pdg_out) pdg1 = pdg_out(1) write (u, "(A)") write (u, "(1x,A,99(1x,I0))") "PDG(out) = ", pdg1 deallocate (data) call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: dispatch_7" end subroutine dispatch_7 @ %def dispatch_7 @ \subsubsection{Beam structure} The actual test. We can't move this to [[beams]] as it depends on [[model_features]] for the [[model_list_t]]. <>= call test (dispatch_8, "dispatch_8", & "beam structure", & u, results) <>= public :: dispatch_8 <>= subroutine dispatch_8 (u) integer, intent(in) :: u type(rt_data_t), target :: global type(os_data_t) :: os_data type(flavor_t), dimension(2) :: flv type(sf_config_t), dimension(:), allocatable :: sf_config type(sf_prop_t) :: sf_prop type(sf_channel_t), dimension(:), allocatable :: sf_channel type(phs_channel_collection_t) :: coll type(string_t) :: sf_string integer :: i type(pdg_array_t), dimension (2,1) :: pdg_prc write (u, "(A)") "* Test output: dispatch_8" write (u, "(A)") "* Purpose: configure a structure-function chain" write (u, "(A)") call global%global_init () call os_data%init () call syntax_model_file_init () call global%select_model (var_str ("QCD")) write (u, "(A)") "* Allocate LHC beams with PDF builtin" write (u, "(A)") call flv(1)%init (PROTON, global%model) call flv(2)%init (PROTON, global%model) call reset_interaction_counter () call global%set_real (var_str ("sqrts"), & 14000._default, is_known = .true.) call global%beam_structure%init_sf (flv%get_name (), [1]) call global%beam_structure%set_sf (1, 1, var_str ("pdf_builtin")) call dispatch_sf_config (sf_config, sf_prop, global%beam_structure, & global%get_var_list_ptr (), global%var_list, & global%model, global%os_data, global%get_sqrts (), pdg_prc) do i = 1, size (sf_config) call sf_config(i)%write (u) end do call dispatch_sf_channels (sf_channel, sf_string, sf_prop, coll, & global%var_list, global%get_sqrts(), global%beam_structure) write (u, "(1x,A)") "Mapping configuration:" do i = 1, size (sf_channel) write (u, "(2x)", advance = "no") call sf_channel(i)%write (u) end do write (u, "(A)") write (u, "(A)") "* Allocate ILC beams with CIRCE1" write (u, "(A)") call global%select_model (var_str ("QED")) call flv(1)%init ( ELECTRON, global%model) call flv(2)%init (-ELECTRON, global%model) call reset_interaction_counter () call global%set_real (var_str ("sqrts"), & 500._default, is_known = .true.) call global%set_log (var_str ("?circe1_generate"), & .false., is_known = .true.) call global%beam_structure%init_sf (flv%get_name (), [1]) call global%beam_structure%set_sf (1, 1, var_str ("circe1")) call dispatch_sf_config (sf_config, sf_prop, global%beam_structure, & global%get_var_list_ptr (), global%var_list, & global%model, global%os_data, global%get_sqrts (), pdg_prc) do i = 1, size (sf_config) call sf_config(i)%write (u) end do call dispatch_sf_channels (sf_channel, sf_string, sf_prop, coll, & global%var_list, global%get_sqrts(), global%beam_structure) write (u, "(1x,A)") "Mapping configuration:" do i = 1, size (sf_channel) write (u, "(2x)", advance = "no") call sf_channel(i)%write (u) end do write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: dispatch_8" end subroutine dispatch_8 @ %def dispatch_8 @ \subsubsection{Update process core parameters} This test dispatches a process core, temporarily modifies parameters, then restores the original. <>= call test (dispatch_10, "dispatch_10", & "process core update", & u, results) <>= public :: dispatch_10 <>= subroutine dispatch_10 (u) integer, intent(in) :: u type(string_t), dimension(2) :: prt_in, prt_out type(rt_data_t), target :: global class(prc_core_def_t), allocatable :: core_def class(prc_core_t), allocatable :: core, saved_core type(var_list_t), pointer :: model_vars write (u, "(A)") "* Test output: dispatch_10" write (u, "(A)") "* Purpose: select process configuration method," write (u, "(A)") " allocate process core," write (u, "(A)") " temporarily reset parameters" write (u, "(A)") call syntax_model_file_init () call global%global_init () prt_in = [var_str ("a"), var_str ("b")] prt_out = [var_str ("c"), var_str ("d")] write (u, "(A)") "* Allocate core as prc_omega_t" write (u, "(A)") call global%set_string (var_str ("$method"), & var_str ("omega"), is_known = .true.) call dispatch_core_def (core_def, prt_in, prt_out, global%model, global%var_list) call global%select_model (var_str ("Test")) call dispatch_core (core, core_def, global%model) call core_def%allocate_driver (core%driver, var_str ("")) select type (core) type is (prc_omega_t) call core%write (u) end select write (u, "(A)") write (u, "(A)") "* Update core with modified model and helicity selection" write (u, "(A)") model_vars => global%model%get_var_list_ptr () call model_vars%set_real (var_str ("gy"), 2._default, & is_known = .true.) call global%model%update_parameters () call global%set_log (& var_str ("?helicity_selection_active"), & .true., is_known = .true.) call global%set_real (& var_str ("helicity_selection_threshold"), & 2e10_default, is_known = .true.) call global%set_int (& var_str ("helicity_selection_cutoff"), & 5, is_known = .true.) call dispatch_core_update (core, & global%model, & global%get_helicity_selection (), & saved_core = saved_core) select type (core) type is (prc_omega_t) call core%write (u) end select write (u, "(A)") write (u, "(A)") "* Restore core from save" write (u, "(A)") call dispatch_core_restore (core, saved_core) select type (core) type is (prc_omega_t) call core%write (u) end select call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: dispatch_10" end subroutine dispatch_10 @ %def dispatch_10 @ \subsubsection{QCD Coupling} This test dispatches an [[qcd]] object, which is used to compute the (running) coupling by one of several possible methods. We can't move this to [[beams]] as it depends on [[model_features]] for the [[model_list_t]]. <>= call test (dispatch_11, "dispatch_11", & "QCD coupling", & u, results) <>= public :: dispatch_11 <>= subroutine dispatch_11 (u) integer, intent(in) :: u type(rt_data_t), target :: global type(var_list_t), pointer :: model_vars type(qcd_t) :: qcd write (u, "(A)") "* Test output: dispatch_11" write (u, "(A)") "* Purpose: select QCD coupling formula" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%select_model (var_str ("SM")) model_vars => global%get_var_list_ptr () write (u, "(A)") "* Allocate alpha_s as fixed" write (u, "(A)") call global%set_log (var_str ("?alphas_is_fixed"), & .true., is_known = .true.) call dispatch_qcd (qcd, global%get_var_list_ptr (), global%os_data) call qcd%write (u) write (u, "(A)") write (u, "(A)") "* Allocate alpha_s as running (built-in)" write (u, "(A)") call global%set_log (var_str ("?alphas_is_fixed"), & .false., is_known = .true.) call global%set_log (var_str ("?alphas_from_mz"), & .true., is_known = .true.) call global%set_int & (var_str ("alphas_order"), 1, is_known = .true.) call model_vars%set_real (var_str ("alphas"), 0.1234_default, & is_known=.true.) call model_vars%set_real (var_str ("mZ"), 91.234_default, & is_known=.true.) call dispatch_qcd (qcd, global%get_var_list_ptr (), global%os_data) call qcd%write (u) write (u, "(A)") write (u, "(A)") "* Allocate alpha_s as running (built-in, Lambda defined)" write (u, "(A)") call global%set_log (var_str ("?alphas_from_mz"), & .false., is_known = .true.) call global%set_log (& var_str ("?alphas_from_lambda_qcd"), & .true., is_known = .true.) call global%set_real & (var_str ("lambda_qcd"), 250.e-3_default, & is_known=.true.) call global%set_int & (var_str ("alphas_order"), 2, is_known = .true.) call global%set_int & (var_str ("alphas_nf"), 4, is_known = .true.) call dispatch_qcd (qcd, global%get_var_list_ptr (), global%os_data) call qcd%write (u) write (u, "(A)") write (u, "(A)") "* Allocate alpha_s as running (using builtin PDF set)" write (u, "(A)") call global%set_log (& var_str ("?alphas_from_lambda_qcd"), & .false., is_known = .true.) call global%set_log & (var_str ("?alphas_from_pdf_builtin"), & .true., is_known = .true.) call dispatch_qcd (qcd, global%get_var_list_ptr (), global%os_data) call qcd%write (u) call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: dispatch_11" end subroutine dispatch_11 @ %def dispatch_11 @ \clearpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Process Configuration} This module communicates between the toplevel command structure with its runtime data set and the process-library handling modules which collect the definition of individual processes. Its primary purpose is to select from the available matrix-element generating methods and configure the entry in the process library accordingly. <<[[process_configurations.f90]]>>= <> module process_configurations <> <> use diagnostics use io_units use physics_defs, only: BORN, NLO_VIRTUAL, NLO_REAL, NLO_DGLAP, & NLO_SUBTRACTION, NLO_MISMATCH use models use prc_core_def use particle_specifiers use process_libraries use rt_data use variables, only: var_list_t use dispatch_me_methods, only: dispatch_core_def use prc_external, only: prc_external_def_t <> <> <> contains <> end module process_configurations @ %def process_configurations @ \subsection{Data Type} <>= public :: process_configuration_t <>= type :: process_configuration_t type(process_def_entry_t), pointer :: entry => null () type(string_t) :: id integer :: num_id = 0 contains <> end type process_configuration_t @ %def process_configuration_t @ Output (for unit tests). <>= procedure :: write => process_configuration_write <>= subroutine process_configuration_write (config, unit) class(process_configuration_t), intent(in) :: config integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(A)") "Process configuration:" if (associated (config%entry)) then call config%entry%write (u) else write (u, "(1x,3A)") "ID = '", char (config%id), "'" write (u, "(1x,A,1x,I0)") "num ID =", config%num_id write (u, "(2x,A)") "[no entry]" end if end subroutine process_configuration_write @ %def process_configuration_write @ Initialize a process. We only need the name, the number of incoming particles, and the number of components. <>= procedure :: init => process_configuration_init <>= subroutine process_configuration_init & (config, prc_name, n_in, n_components, model, var_list, nlo_process) class(process_configuration_t), intent(out) :: config type(string_t), intent(in) :: prc_name integer, intent(in) :: n_in integer, intent(in) :: n_components type(model_t), intent(in), pointer :: model type(var_list_t), intent(in) :: var_list logical, intent(in), optional :: nlo_process logical :: nlo_proc logical :: requires_resonances if (debug_on) call msg_debug (D_CORE, "process_configuration_init") config%id = prc_name if (present (nlo_process)) then nlo_proc = nlo_process else nlo_proc = .false. end if requires_resonances = var_list%get_lval (var_str ("?resonance_history")) if (debug_on) call msg_debug (D_CORE, "nlo_process", nlo_proc) allocate (config%entry) if (var_list%is_known (var_str ("process_num_id"))) then config%num_id = & var_list%get_ival (var_str ("process_num_id")) call config%entry%init (prc_name, & model = model, n_in = n_in, n_components = n_components, & num_id = config%num_id, & nlo_process = nlo_proc, & requires_resonances = requires_resonances) else call config%entry%init (prc_name, & model = model, n_in = n_in, n_components = n_components, & nlo_process = nlo_proc, & requires_resonances = requires_resonances) end if end subroutine process_configuration_init @ %def process_configuration_init @ Initialize a process component. The details depend on the process method, which determines the type of the process component core. We set the incoming and outgoing particles (as strings, to be interpreted by the process driver). All other information is taken from the variable list. The dispatcher gets only the names of the particles. The process component definition gets the complete specifiers which contains a polarization flag and names of decay processes, where applicable. <>= procedure :: setup_component => process_configuration_setup_component <>= subroutine process_configuration_setup_component & (config, i_component, prt_in, prt_out, model, var_list, & nlo_type, can_be_integrated) class(process_configuration_t), intent(inout) :: config integer, intent(in) :: i_component type(prt_spec_t), dimension(:), intent(in) :: prt_in type(prt_spec_t), dimension(:), intent(in) :: prt_out type(model_t), pointer, intent(in) :: model type(var_list_t), intent(in) :: var_list integer, intent(in), optional :: nlo_type logical, intent(in), optional :: can_be_integrated type(string_t), dimension(:), allocatable :: prt_str_in type(string_t), dimension(:), allocatable :: prt_str_out class(prc_core_def_t), allocatable :: core_def type(string_t) :: method type(string_t) :: born_me_method type(string_t) :: real_tree_me_method type(string_t) :: loop_me_method type(string_t) :: correlation_me_method type(string_t) :: dglap_me_method integer :: i if (debug_on) call msg_debug2 (D_CORE, "process_configuration_setup_component") allocate (prt_str_in (size (prt_in))) allocate (prt_str_out (size (prt_out))) forall (i = 1:size (prt_in)) prt_str_in(i) = prt_in(i)% get_name () forall (i = 1:size (prt_out)) prt_str_out(i) = prt_out(i)%get_name () method = var_list%get_sval (var_str ("$method")) if (present (nlo_type)) then select case (nlo_type) case (BORN) born_me_method = var_list%get_sval (var_str ("$born_me_method")) if (born_me_method /= var_str ("")) then method = born_me_method end if case (NLO_VIRTUAL) loop_me_method = var_list%get_sval (var_str ("$loop_me_method")) if (loop_me_method /= var_str ("")) then method = loop_me_method end if case (NLO_REAL) real_tree_me_method = & var_list%get_sval (var_str ("$real_tree_me_method")) if (real_tree_me_method /= var_str ("")) then method = real_tree_me_method end if case (NLO_DGLAP) dglap_me_method = & var_list%get_sval (var_str ("$dglap_me_method")) if (dglap_me_method /= var_str ("")) then method = dglap_me_method end if case (NLO_SUBTRACTION,NLO_MISMATCH) correlation_me_method = & var_list%get_sval (var_str ("$correlation_me_method")) if (correlation_me_method /= var_str ("")) then method = correlation_me_method end if case default end select end if call dispatch_core_def (core_def, prt_str_in, prt_str_out, & model, var_list, config%id, nlo_type, method) select type (core_def) class is (prc_external_def_t) if (present (can_be_integrated)) then call core_def%set_active_writer (can_be_integrated) else call msg_fatal ("Cannot decide if external core is integrated!") end if end select if (debug_on) call msg_debug2 (D_CORE, "import_component with method ", method) call config%entry%import_component (i_component, & n_out = size (prt_out), & prt_in = prt_in, & prt_out = prt_out, & method = method, & variant = core_def, & nlo_type = nlo_type, & can_be_integrated = can_be_integrated) end subroutine process_configuration_setup_component @ %def process_configuration_setup_component @ <>= procedure :: set_fixed_emitter => process_configuration_set_fixed_emitter <>= subroutine process_configuration_set_fixed_emitter (config, i, emitter) class(process_configuration_t), intent(inout) :: config integer, intent(in) :: i, emitter call config%entry%set_fixed_emitter (i, emitter) end subroutine process_configuration_set_fixed_emitter @ %def process_configuration_set_fixed_emitter @ <>= procedure :: set_coupling_powers => process_configuration_set_coupling_powers <>= subroutine process_configuration_set_coupling_powers & (config, alpha_power, alphas_power) class(process_configuration_t), intent(inout) :: config integer, intent(in) :: alpha_power, alphas_power call config%entry%set_coupling_powers (alpha_power, alphas_power) end subroutine process_configuration_set_coupling_powers @ %def process_configuration_set_coupling_powers @ <>= procedure :: set_component_associations => & process_configuration_set_component_associations <>= subroutine process_configuration_set_component_associations & (config, i_list, remnant, use_real_finite, mismatch) class(process_configuration_t), intent(inout) :: config integer, dimension(:), intent(in) :: i_list logical, intent(in) :: remnant, use_real_finite, mismatch integer :: i_component do i_component = 1, config%entry%get_n_components () if (any (i_list == i_component)) then call config%entry%set_associated_components (i_component, & i_list, remnant, use_real_finite, mismatch) end if end do end subroutine process_configuration_set_component_associations @ %def process_configuration_set_component_associations @ Record a process configuration: append it to the currently selected process definition library. <>= procedure :: record => process_configuration_record <>= subroutine process_configuration_record (config, global) class(process_configuration_t), intent(inout) :: config type(rt_data_t), intent(inout) :: global if (associated (global%prclib)) then call global%prclib%open () call global%prclib%append (config%entry) if (config%num_id /= 0) then write (msg_buffer, "(5A,I0,A)") "Process library '", & char (global%prclib%get_name ()), & "': recorded process '", char (config%id), "' (", & config%num_id, ")" else write (msg_buffer, "(5A)") "Process library '", & char (global%prclib%get_name ()), & "': recorded process '", char (config%id), "'" end if call msg_message () else call msg_fatal ("Recording process '" // char (config%id) & // "': active process library undefined") end if end subroutine process_configuration_record @ %def process_configuration_record @ \subsection{Unit Tests} Test module, followed by the corresponding implementation module. <<[[process_configurations_ut.f90]]>>= <> module process_configurations_ut use unit_tests use process_configurations_uti <> <> <> contains <> end module process_configurations_ut @ %def process_configurations_ut @ <<[[process_configurations_uti.f90]]>>= <> module process_configurations_uti <> use particle_specifiers, only: new_prt_spec use prclib_stacks use models use rt_data use process_configurations <> <> <> contains <> <> end module process_configurations_uti @ %def process_configurations_uti @ API: driver for the unit tests below. <>= public :: process_configurations_test <>= subroutine process_configurations_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine process_configurations_test @ %def process_configurations_test @ \subsubsection{Minimal setup} The workflow for setting up a minimal process configuration with the test matrix element method. We wrap this in a public procedure, so we can reuse it in later modules. The procedure prepares a process definition list for two processes (one [[prc_test]] and one [[omega]] type) and appends this to the process library stack in the global data set. The [[mode]] argument determines which processes to build. The [[procname]] argument replaces the predefined procname(s). This is re-exported by the UT module. <>= public :: prepare_test_library <>= subroutine prepare_test_library (global, libname, mode, procname) type(rt_data_t), intent(inout), target :: global type(string_t), intent(in) :: libname integer, intent(in) :: mode type(string_t), intent(in), dimension(:), optional :: procname type(prclib_entry_t), pointer :: lib type(string_t) :: prc_name type(string_t), dimension(:), allocatable :: prt_in, prt_out integer :: n_components type(process_configuration_t) :: prc_config if (.not. associated (global%prclib_stack%get_first_ptr ())) then allocate (lib) call lib%init (libname) call global%add_prclib (lib) end if if (btest (mode, 0)) then call global%select_model (var_str ("Test")) if (present (procname)) then prc_name = procname(1) else prc_name = "prc_config_a" end if n_components = 1 allocate (prt_in (2), prt_out (2)) prt_in = [var_str ("s"), var_str ("s")] prt_out = [var_str ("s"), var_str ("s")] call global%set_string (var_str ("$method"),& var_str ("unit_test"), is_known = .true.) call prc_config%init (prc_name, & size (prt_in), n_components, & global%model, global%var_list) call prc_config%setup_component (1, & new_prt_spec (prt_in), new_prt_spec (prt_out), & global%model, global%var_list) call prc_config%record (global) deallocate (prt_in, prt_out) end if if (btest (mode, 1)) then call global%select_model (var_str ("QED")) if (present (procname)) then prc_name = procname(2) else prc_name = "prc_config_b" end if n_components = 1 allocate (prt_in (2), prt_out (2)) prt_in = [var_str ("e+"), var_str ("e-")] prt_out = [var_str ("m+"), var_str ("m-")] call global%set_string (var_str ("$method"),& var_str ("omega"), is_known = .true.) call prc_config%init (prc_name, & size (prt_in), n_components, & global%model, global%var_list) call prc_config%setup_component (1, & new_prt_spec (prt_in), new_prt_spec (prt_out), & global%model, global%var_list) call prc_config%record (global) deallocate (prt_in, prt_out) end if if (btest (mode, 2)) then call global%select_model (var_str ("Test")) if (present (procname)) then prc_name = procname(1) else prc_name = "prc_config_a" end if n_components = 1 allocate (prt_in (1), prt_out (2)) prt_in = [var_str ("s")] prt_out = [var_str ("f"), var_str ("fbar")] call global%set_string (var_str ("$method"),& var_str ("unit_test"), is_known = .true.) call prc_config%init (prc_name, & size (prt_in), n_components, & global%model, global%var_list) call prc_config%setup_component (1, & new_prt_spec (prt_in), new_prt_spec (prt_out), & global%model, global%var_list) call prc_config%record (global) deallocate (prt_in, prt_out) end if end subroutine prepare_test_library @ %def prepare_test_library @ The actual test: the previous procedure with some prelude and postlude. In the global variable list, just before printing we reset the variables where the value may depend on the system and run environment. <>= call test (process_configurations_1, "process_configurations_1", & "test processes", & u, results) <>= public :: process_configurations_1 <>= subroutine process_configurations_1 (u) integer, intent(in) :: u type(rt_data_t), target :: global write (u, "(A)") "* Test output: process_configurations_1" write (u, "(A)") "* Purpose: configure test processes" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) write (u, "(A)") "* Configure processes as prc_test, model Test" write (u, "(A)") "* and omega, model QED" write (u, *) call global%set_int (var_str ("process_num_id"), & 42, is_known = .true.) call prepare_test_library (global, var_str ("prc_config_lib_1"), 3) global%os_data%fc = "Fortran-compiler" global%os_data%fcflags = "Fortran-flags" call global%write_libraries (u) call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: process_configurations_1" end subroutine process_configurations_1 @ %def process_configurations_1 @ \subsubsection{\oMega\ options} Slightly extended example where we pass \oMega\ options to the library. The [[prepare_test_library]] contents are spelled out. <>= call test (process_configurations_2, "process_configurations_2", & "omega options", & u, results) <>= public :: process_configurations_2 <>= subroutine process_configurations_2 (u) integer, intent(in) :: u type(rt_data_t), target :: global type(string_t) :: libname type(prclib_entry_t), pointer :: lib type(string_t) :: prc_name type(string_t), dimension(:), allocatable :: prt_in, prt_out integer :: n_components type(process_configuration_t) :: prc_config write (u, "(A)") "* Test output: process_configurations_2" write (u, "(A)") "* Purpose: configure test processes with options" write (u, "(A)") call syntax_model_file_init () call global%global_init () write (u, "(A)") "* Configure processes as omega, model QED" write (u, *) libname = "prc_config_lib_2" allocate (lib) call lib%init (libname) call global%add_prclib (lib) call global%select_model (var_str ("QED")) prc_name = "prc_config_c" n_components = 2 allocate (prt_in (2), prt_out (2)) prt_in = [var_str ("e+"), var_str ("e-")] prt_out = [var_str ("m+"), var_str ("m-")] call global%set_string (var_str ("$method"),& var_str ("omega"), is_known = .true.) call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call prc_config%init (prc_name, size (prt_in), n_components, & global%model, global%var_list) call global%set_log (var_str ("?report_progress"), & .true., is_known = .true.) call prc_config%setup_component (1, & new_prt_spec (prt_in), new_prt_spec (prt_out), global%model, global%var_list) call global%set_log (var_str ("?report_progress"), & .false., is_known = .true.) call global%set_log (var_str ("?omega_openmp"), & .true., is_known = .true.) call global%set_string (var_str ("$restrictions"),& var_str ("3+4~A"), is_known = .true.) call global%set_string (var_str ("$omega_flags"), & var_str ("-fusion:progress_file omega_prc_config.log"), & is_known = .true.) call prc_config%setup_component (2, & new_prt_spec (prt_in), new_prt_spec (prt_out), global%model, global%var_list) call prc_config%record (global) deallocate (prt_in, prt_out) global%os_data%fc = "Fortran-compiler" global%os_data%fcflags = "Fortran-flags" call global%write_vars (u, [ & var_str ("$model_name"), & var_str ("$method"), & var_str ("?report_progress"), & var_str ("$restrictions"), & var_str ("$omega_flags")]) write (u, "(A)") call global%write_libraries (u) call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: process_configurations_2" end subroutine process_configurations_2 @ %def process_configurations_2 @ \clearpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Compilation} This module manages compilation and loading of of process libraries. It is needed as a separate module because integration depends on it. <<[[compilations.f90]]>>= <> module compilations <> use io_units use system_defs, only: TAB use diagnostics use os_interface use variables, only: var_list_t use model_data use process_libraries use prclib_stacks use rt_data <> <> <> <> contains <> end module compilations @ %def compilations @ \subsection{The data type} The compilation item handles the compilation and loading of a single process library. <>= public :: compilation_item_t <>= type :: compilation_item_t private type(string_t) :: libname type(string_t) :: static_external_tag type(process_library_t), pointer :: lib => null () logical :: recompile_library = .false. logical :: verbose = .false. logical :: use_workspace = .false. type(string_t) :: workspace contains <> end type compilation_item_t @ %def compilation_item_t @ Initialize. Set flags and global properties of the library. Establish the workspace name, if defined. <>= procedure :: init => compilation_item_init <>= subroutine compilation_item_init (comp, libname, stack, var_list) class(compilation_item_t), intent(out) :: comp type(string_t), intent(in) :: libname type(prclib_stack_t), intent(inout) :: stack type(var_list_t), intent(in) :: var_list comp%libname = libname comp%lib => stack%get_library_ptr (comp%libname) if (.not. associated (comp%lib)) then call msg_fatal ("Process library '" // char (comp%libname) & // "' has not been declared.") end if comp%recompile_library = & var_list%get_lval (var_str ("?recompile_library")) comp%verbose = & var_list%get_lval (var_str ("?me_verbose")) comp%use_workspace = & var_list%is_known (var_str ("$compile_workspace")) if (comp%use_workspace) then comp%workspace = & var_list%get_sval (var_str ("$compile_workspace")) if (comp%workspace == "") comp%use_workspace = .false. else comp%workspace = "" end if end subroutine compilation_item_init @ %def compilation_item_init @ Compile the current library. The [[force]] flag has the effect that we first delete any previous files, as far as accessible by the current makefile. It also guarantees that previous files not accessible by a makefile will be overwritten. <>= procedure :: compile => compilation_item_compile <>= subroutine compilation_item_compile (comp, model, os_data, force, recompile) class(compilation_item_t), intent(inout) :: comp class(model_data_t), intent(in), target :: model type(os_data_t), intent(in) :: os_data logical, intent(in) :: force, recompile if (associated (comp%lib)) then if (comp%use_workspace) call setup_workspace (comp%workspace, os_data) call msg_message ("Process library '" & // char (comp%libname) // "': compiling ...") call comp%lib%configure (os_data) if (signal_is_pending ()) return call comp%lib%compute_md5sum (model) call comp%lib%write_makefile & (os_data, force, verbose=comp%verbose, workspace=comp%workspace) if (signal_is_pending ()) return if (force) then call comp%lib%clean & (os_data, distclean = .false., workspace=comp%workspace) if (signal_is_pending ()) return end if call comp%lib%write_driver (force, workspace=comp%workspace) if (signal_is_pending ()) return if (recompile) then call comp%lib%load & (os_data, keep_old_source = .true., workspace=comp%workspace) if (signal_is_pending ()) return end if call comp%lib%update_status (os_data, workspace=comp%workspace) end if end subroutine compilation_item_compile @ %def compilation_item_compile @ The workspace directory is created if it does not exist. (Applies only if the use has set the workspace directory.) <>= character(*), parameter :: ALLOWED_IN_DIRNAME = & "abcdefghijklmnopqrstuvwxyz& &ABCDEFGHIJKLMNOPQRSTUVWXYZ& &1234567890& &.,_-+=" @ %def ALLOWED_IN_DIRNAME <>= subroutine setup_workspace (workspace, os_data) type(string_t), intent(in) :: workspace type(os_data_t), intent(in) :: os_data if (verify (workspace, ALLOWED_IN_DIRNAME) == 0) then call msg_message ("Compile: preparing workspace directory '" & // char (workspace) // "'") call os_system_call ("mkdir -p '" // workspace // "'") else call msg_fatal ("compile: workspace name '" & // char (workspace) // "' contains illegal characters") end if end subroutine setup_workspace @ %def setup_workspace @ Load the current library, just after compiling it. <>= procedure :: load => compilation_item_load <>= subroutine compilation_item_load (comp, os_data) class(compilation_item_t), intent(inout) :: comp type(os_data_t), intent(in) :: os_data if (associated (comp%lib)) then call comp%lib%load (os_data, workspace=comp%workspace) end if end subroutine compilation_item_load @ %def compilation_item_load @ Message as a separate call: <>= procedure :: success => compilation_item_success <>= subroutine compilation_item_success (comp) class(compilation_item_t), intent(in) :: comp if (associated (comp%lib)) then call msg_message ("Process library '" // char (comp%libname) & // "': ... success.") else call msg_fatal ("Process library '" // char (comp%libname) & // "': ... failure.") end if end subroutine compilation_item_success @ %def compilation_item_success @ %def compilation_item_failure @ \subsection{API for library compilation and loading} This is a shorthand for compiling and loading a single library. The [[compilation_item]] object is used only internally. The [[global]] data set may actually be local to the caller. The compilation affects the library specified by its name if it is on the stack, but it does not reset the currently selected library. <>= public :: compile_library <>= subroutine compile_library (libname, global) type(string_t), intent(in) :: libname type(rt_data_t), intent(inout), target :: global type(compilation_item_t) :: comp logical :: force, recompile force = & global%var_list%get_lval (var_str ("?rebuild_library")) recompile = & global%var_list%get_lval (var_str ("?recompile_library")) if (associated (global%model)) then call comp%init (libname, global%prclib_stack, global%var_list) call comp%compile (global%model, global%os_data, force, recompile) if (signal_is_pending ()) return call comp%load (global%os_data) if (signal_is_pending ()) return else call msg_fatal ("Process library compilation: " & // " model is undefined.") end if call comp%success () end subroutine compile_library @ %def compile_library @ \subsection{Compiling static executable} This object handles the creation of a static executable which should contain a set of static process libraries. <>= public :: compilation_t <>= type :: compilation_t private type(string_t) :: exe_name type(string_t), dimension(:), allocatable :: lib_name contains <> end type compilation_t @ %def compilation_t @ Output. <>= procedure :: write => compilation_write <>= subroutine compilation_write (object, unit) class(compilation_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit) write (u, "(1x,A)") "Compilation object:" write (u, "(3x,3A)") "executable = '", & char (object%exe_name), "'" write (u, "(3x,A)", advance="no") "process libraries =" do i = 1, size (object%lib_name) write (u, "(1x,3A)", advance="no") "'", char (object%lib_name(i)), "'" end do write (u, *) end subroutine compilation_write @ %def compilation_write @ Initialize: we know the names of the executable and of the libraries. Optionally, we may provide a workspace directory. <>= procedure :: init => compilation_init <>= subroutine compilation_init (compilation, exe_name, lib_name) class(compilation_t), intent(out) :: compilation type(string_t), intent(in) :: exe_name type(string_t), dimension(:), intent(in) :: lib_name compilation%exe_name = exe_name allocate (compilation%lib_name (size (lib_name))) compilation%lib_name = lib_name end subroutine compilation_init @ %def compilation_init @ Write the dispatcher subroutine for the compiled libraries. Also write a subroutine which returns the names of the compiled libraries. <>= procedure :: write_dispatcher => compilation_write_dispatcher <>= subroutine compilation_write_dispatcher (compilation) class(compilation_t), intent(in) :: compilation type(string_t) :: file integer :: u, i file = compilation%exe_name // "_prclib_dispatcher.f90" call msg_message ("Static executable '" // char (compilation%exe_name) & // "': writing library dispatcher") u = free_unit () open (u, file = char (file), status="replace", action="write") write (u, "(3A)") "! Whizard: process libraries for executable '", & char (compilation%exe_name), "'" write (u, "(A)") "! Automatically generated file, do not edit" write (u, "(A)") "subroutine dispatch_prclib_static " // & "(driver, basename, modellibs_ldflags)" write (u, "(A)") " use iso_varying_string, string_t => varying_string" write (u, "(A)") " use prclib_interfaces" do i = 1, size (compilation%lib_name) associate (lib_name => compilation%lib_name(i)) write (u, "(A)") " use " // char (lib_name) // "_driver" end associate end do write (u, "(A)") " implicit none" write (u, "(A)") " class(prclib_driver_t), intent(inout), allocatable & &:: driver" write (u, "(A)") " type(string_t), intent(in) :: basename" write (u, "(A)") " logical, intent(in), optional :: " // & "modellibs_ldflags" write (u, "(A)") " select case (char (basename))" do i = 1, size (compilation%lib_name) associate (lib_name => compilation%lib_name(i)) write (u, "(3A)") " case ('", char (lib_name), "')" write (u, "(3A)") " allocate (", char (lib_name), "_driver_t & &:: driver)" end associate end do write (u, "(A)") " end select" write (u, "(A)") "end subroutine dispatch_prclib_static" write (u, *) write (u, "(A)") "subroutine get_prclib_static (libname)" write (u, "(A)") " use iso_varying_string, string_t => varying_string" write (u, "(A)") " implicit none" write (u, "(A)") " type(string_t), dimension(:), intent(inout), & &allocatable :: libname" write (u, "(A,I0,A)") " allocate (libname (", & size (compilation%lib_name), "))" do i = 1, size (compilation%lib_name) associate (lib_name => compilation%lib_name(i)) write (u, "(A,I0,A,A,A)") " libname(", i, ") = '", & char (lib_name), "'" end associate end do write (u, "(A)") "end subroutine get_prclib_static" close (u) end subroutine compilation_write_dispatcher @ %def compilation_write_dispatcher @ Write the Makefile subroutine for the compiled libraries. <>= procedure :: write_makefile => compilation_write_makefile <>= subroutine compilation_write_makefile & (compilation, os_data, ext_libtag, verbose) class(compilation_t), intent(in) :: compilation type(os_data_t), intent(in) :: os_data logical, intent(in) :: verbose type(string_t), intent(in), optional :: ext_libtag type(string_t) :: file, ext_tag integer :: u, i if (present (ext_libtag)) then ext_tag = ext_libtag else ext_tag = "" end if file = compilation%exe_name // ".makefile" call msg_message ("Static executable '" // char (compilation%exe_name) & // "': writing makefile") u = free_unit () open (u, file = char (file), status="replace", action="write") write (u, "(3A)") "# WHIZARD: Makefile for executable '", & char (compilation%exe_name), "'" write (u, "(A)") "# Automatically generated file, do not edit" write (u, "(A)") "" write (u, "(A)") "# Executable name" write (u, "(A)") "EXE = " // char (compilation%exe_name) write (u, "(A)") "" write (u, "(A)") "# Compiler" write (u, "(A)") "FC = " // char (os_data%fc) write (u, "(A)") "" write (u, "(A)") "# Included libraries" write (u, "(A)") "FCINCL = " // char (os_data%whizard_includes) write (u, "(A)") "" write (u, "(A)") "# Compiler flags" write (u, "(A)") "FCFLAGS = " // char (os_data%fcflags) write (u, "(A)") "LDFLAGS = " // char (os_data%ldflags) write (u, "(A)") "LDFLAGS_STATIC = " // char (os_data%ldflags_static) write (u, "(A)") "LDFLAGS_HEPMC = " // char (os_data%ldflags_hepmc) write (u, "(A)") "LDFLAGS_LCIO = " // char (os_data%ldflags_lcio) write (u, "(A)") "LDFLAGS_HOPPET = " // char (os_data%ldflags_hoppet) write (u, "(A)") "LDFLAGS_LOOPTOOLS = " // char (os_data%ldflags_looptools) write (u, "(A)") "LDWHIZARD = " // char (os_data%whizard_ldflags) write (u, "(A)") "" write (u, "(A)") "# Libtool" write (u, "(A)") "LIBTOOL = " // char (os_data%whizard_libtool) if (verbose) then write (u, "(A)") "FCOMPILE = $(LIBTOOL) --tag=FC --mode=compile" write (u, "(A)") "LINK = $(LIBTOOL) --tag=FC --mode=link" else write (u, "(A)") "FCOMPILE = @$(LIBTOOL) --silent --tag=FC --mode=compile" write (u, "(A)") "LINK = @$(LIBTOOL) --silent --tag=FC --mode=link" end if write (u, "(A)") "" write (u, "(A)") "# Compile commands (default)" write (u, "(A)") "LTFCOMPILE = $(FCOMPILE) $(FC) -c $(FCINCL) $(FCFLAGS)" write (u, "(A)") "" write (u, "(A)") "# Default target" write (u, "(A)") "all: link" write (u, "(A)") "" write (u, "(A)") "# Libraries" do i = 1, size (compilation%lib_name) associate (lib_name => compilation%lib_name(i)) write (u, "(A)") "LIBRARIES += " // char (lib_name) // ".la" write (u, "(A)") char (lib_name) // ".la:" write (u, "(A)") TAB // "$(MAKE) -f " // char (lib_name) // ".makefile" end associate end do write (u, "(A)") "" write (u, "(A)") "# Library dispatcher" write (u, "(A)") "DISP = $(EXE)_prclib_dispatcher" write (u, "(A)") "$(DISP).lo: $(DISP).f90 $(LIBRARIES)" if (.not. verbose) then write (u, "(A)") TAB // '@echo " FC " $@' end if write (u, "(A)") TAB // "$(LTFCOMPILE) $<" write (u, "(A)") "" write (u, "(A)") "# Executable" write (u, "(A)") "$(EXE): $(DISP).lo $(LIBRARIES)" if (.not. verbose) then write (u, "(A)") TAB // '@echo " FCLD " $@' end if write (u, "(A)") TAB // "$(LINK) $(FC) -static $(FCFLAGS) \" write (u, "(A)") TAB // " $(LDWHIZARD) $(LDFLAGS) \" write (u, "(A)") TAB // " -o $(EXE) $^ \" write (u, "(A)") TAB // " $(LDFLAGS_HEPMC) $(LDFLAGS_LCIO) $(LDFLAGS_HOPPET) \" write (u, "(A)") TAB // " $(LDFLAGS_LOOPTOOLS) $(LDFLAGS_STATIC)" // char (ext_tag) write (u, "(A)") "" write (u, "(A)") "# Main targets" write (u, "(A)") "link: compile $(EXE)" write (u, "(A)") "compile: $(LIBRARIES) $(DISP).lo" write (u, "(A)") ".PHONY: link compile" write (u, "(A)") "" write (u, "(A)") "# Cleanup targets" write (u, "(A)") "clean-exe:" write (u, "(A)") TAB // "rm -f $(EXE)" write (u, "(A)") "clean-objects:" write (u, "(A)") TAB // "rm -f $(DISP).lo" write (u, "(A)") "clean-source:" write (u, "(A)") TAB // "rm -f $(DISP).f90" write (u, "(A)") "clean-makefile:" write (u, "(A)") TAB // "rm -f $(EXE).makefile" write (u, "(A)") "" write (u, "(A)") "clean: clean-exe clean-objects clean-source" write (u, "(A)") "distclean: clean clean-makefile" write (u, "(A)") ".PHONY: clean distclean" close (u) end subroutine compilation_write_makefile @ %def compilation_write_makefile @ Compile the dispatcher source code. <>= procedure :: make_compile => compilation_make_compile <>= subroutine compilation_make_compile (compilation, os_data) class(compilation_t), intent(in) :: compilation type(os_data_t), intent(in) :: os_data call os_system_call ("make compile " // os_data%makeflags & // " -f " // compilation%exe_name // ".makefile") end subroutine compilation_make_compile @ %def compilation_make_compile @ Link the dispatcher together with all matrix-element code and the \whizard\ and \oMega\ main libraries, to generate a static executable. <>= procedure :: make_link => compilation_make_link <>= subroutine compilation_make_link (compilation, os_data) class(compilation_t), intent(in) :: compilation type(os_data_t), intent(in) :: os_data call os_system_call ("make link " // os_data%makeflags & // " -f " // compilation%exe_name // ".makefile") end subroutine compilation_make_link @ %def compilation_make_link @ Cleanup. <>= procedure :: make_clean_exe => compilation_make_clean_exe <>= subroutine compilation_make_clean_exe (compilation, os_data) class(compilation_t), intent(in) :: compilation type(os_data_t), intent(in) :: os_data call os_system_call ("make clean-exe " // os_data%makeflags & // " -f " // compilation%exe_name // ".makefile") end subroutine compilation_make_clean_exe @ %def compilation_make_clean_exe @ \subsection{API for executable compilation} This is a shorthand for compiling and loading an executable, including the enclosed libraries. The [[compilation]] object is used only internally. The [[global]] data set may actually be local to the caller. The compilation affects the library specified by its name if it is on the stack, but it does not reset the currently selected library. <>= public :: compile_executable <>= subroutine compile_executable (exename, libname, global) type(string_t), intent(in) :: exename type(string_t), dimension(:), intent(in) :: libname type(rt_data_t), intent(inout), target :: global type(compilation_t) :: compilation type(compilation_item_t) :: item type(string_t) :: ext_libtag logical :: force, recompile, verbose integer :: i ext_libtag = "" force = & global%var_list%get_lval (var_str ("?rebuild_library")) recompile = & global%var_list%get_lval (var_str ("?recompile_library")) verbose = & global%var_list%get_lval (var_str ("?me_verbose")) call compilation%init (exename, [libname]) if (signal_is_pending ()) return call compilation%write_dispatcher () if (signal_is_pending ()) return do i = 1, size (libname) call item%init (libname(i), global%prclib_stack, global%var_list) call item%compile (global%model, global%os_data, & force=force, recompile=recompile) ext_libtag = "" // item%lib%get_static_modelname (global%os_data) if (signal_is_pending ()) return call item%success () end do call compilation%write_makefile & (global%os_data, ext_libtag=ext_libtag, verbose=verbose) if (signal_is_pending ()) return call compilation%make_compile (global%os_data) if (signal_is_pending ()) return call compilation%make_link (global%os_data) end subroutine compile_executable @ %def compile_executable @ \subsection{Unit Tests} Test module, followed by the stand-alone unit-test procedures. <<[[compilations_ut.f90]]>>= <> module compilations_ut use unit_tests use compilations_uti <> <> contains <> end module compilations_ut @ %def compilations_ut @ <<[[compilations_uti.f90]]>>= <> module compilations_uti <> use io_units use models use rt_data use process_configurations_ut, only: prepare_test_library use compilations <> <> contains <> end module compilations_uti @ %def compilations_uti @ API: driver for the unit tests below. <>= public :: compilations_test <>= subroutine compilations_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine compilations_test @ %def compilations_test @ \subsubsection{Intrinsic Matrix Element} Compile an intrinsic test matrix element ([[prc_test]] type). Note: In this and the following test, we reset the Fortran compiler and flag variables immediately before they are printed, so the test is portable. <>= call test (compilations_1, "compilations_1", & "intrinsic test processes", & u, results) <>= public :: compilations_1 <>= subroutine compilations_1 (u) integer, intent(in) :: u type(string_t) :: libname, procname type(rt_data_t), target :: global write (u, "(A)") "* Test output: compilations_1" write (u, "(A)") "* Purpose: configure and compile test process" write (u, "(A)") call syntax_model_file_init () call global%global_init () libname = "compilation_1" procname = "prc_comp_1" call prepare_test_library (global, libname, 1, [procname]) call compile_library (libname, global) call global%write_libraries (u) call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: compilations_1" end subroutine compilations_1 @ %def compilations_1 @ \subsubsection{External Matrix Element} Compile an external test matrix element ([[omega]] type) <>= call test (compilations_2, "compilations_2", & "external process (omega)", & u, results) <>= public :: compilations_2 <>= subroutine compilations_2 (u) integer, intent(in) :: u type(string_t) :: libname, procname type(rt_data_t), target :: global write (u, "(A)") "* Test output: compilations_2" write (u, "(A)") "* Purpose: configure and compile test process" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) libname = "compilation_2" procname = "prc_comp_2" call prepare_test_library (global, libname, 2, [procname,procname]) call compile_library (libname, global) call global%write_libraries (u, libpath = .false.) call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: compilations_2" end subroutine compilations_2 @ %def compilations_2 @ \subsubsection{External Matrix Element} Compile an external test matrix element ([[omega]] type) and create driver files for a static executable. <>= call test (compilations_3, "compilations_3", & "static executable: driver", & u, results) <>= public :: compilations_3 <>= subroutine compilations_3 (u) integer, intent(in) :: u type(string_t) :: libname, procname, exename type(rt_data_t), target :: global type(compilation_t) :: compilation integer :: u_file character(80) :: buffer write (u, "(A)") "* Test output: compilations_3" write (u, "(A)") "* Purpose: make static executable" write (u, "(A)") write (u, "(A)") "* Initialize library" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) libname = "compilations_3_lib" procname = "prc_comp_3" exename = "compilations_3" call prepare_test_library (global, libname, 2, [procname,procname]) call compilation%init (exename, [libname]) call compilation%write (u) write (u, "(A)") write (u, "(A)") "* Write dispatcher" write (u, "(A)") call compilation%write_dispatcher () u_file = free_unit () open (u_file, file = char (exename) // "_prclib_dispatcher.f90", & status = "old", action = "read") do read (u_file, "(A)", end = 1) buffer write (u, "(A)") trim (buffer) end do 1 close (u_file) write (u, "(A)") write (u, "(A)") "* Write Makefile" write (u, "(A)") associate (os_data => global%os_data) os_data%fc = "fortran-compiler" os_data%whizard_includes = "my-includes" os_data%fcflags = "my-fcflags" os_data%ldflags = "my-ldflags" os_data%ldflags_static = "my-ldflags-static" os_data%ldflags_hepmc = "my-ldflags-hepmc" os_data%ldflags_lcio = "my-ldflags-lcio" os_data%ldflags_hoppet = "my-ldflags-hoppet" os_data%ldflags_looptools = "my-ldflags-looptools" os_data%whizard_ldflags = "my-ldwhizard" os_data%whizard_libtool = "my-libtool" end associate call compilation%write_makefile (global%os_data, verbose = .true.) open (u_file, file = char (exename) // ".makefile", & status = "old", action = "read") do read (u_file, "(A)", end = 2) buffer write (u, "(A)") trim (buffer) end do 2 close (u_file) write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: compilations_3" end subroutine compilations_3 @ %def compilations_3 @ \subsection{Test static build} The tests for building a static executable are separate, since they should be skipped if the \whizard\ build itself has static libraries disabled. <>= public :: compilations_static_test <>= subroutine compilations_static_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine compilations_static_test @ %def compilations_static_test @ \subsubsection{External Matrix Element} Compile an external test matrix element ([[omega]] type) and incorporate this in a new static WHIZARD executable. <>= call test (compilations_static_1, "compilations_static_1", & "static executable: compilation", & u, results) <>= public :: compilations_static_1 <>= subroutine compilations_static_1 (u) integer, intent(in) :: u type(string_t) :: libname, procname, exename type(rt_data_t), target :: global type(compilation_item_t) :: item type(compilation_t) :: compilation logical :: exist write (u, "(A)") "* Test output: compilations_static_1" write (u, "(A)") "* Purpose: make static executable" write (u, "(A)") write (u, "(A)") "* Initialize library" call syntax_model_file_init () call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) libname = "compilations_static_1_lib" procname = "prc_comp_stat_1" exename = "compilations_static_1" call prepare_test_library (global, libname, 2, [procname,procname]) call compilation%init (exename, [libname]) write (u, "(A)") write (u, "(A)") "* Write dispatcher" call compilation%write_dispatcher () write (u, "(A)") write (u, "(A)") "* Write Makefile" call compilation%write_makefile (global%os_data, verbose = .true.) write (u, "(A)") write (u, "(A)") "* Build libraries" call item%init (libname, global%prclib_stack, global%var_list) call item%compile & (global%model, global%os_data, force=.true., recompile=.false.) call item%success () write (u, "(A)") write (u, "(A)") "* Check executable (should be absent)" write (u, "(A)") call compilation%make_clean_exe (global%os_data) inquire (file = char (exename), exist = exist) write (u, "(A,A,L1)") char (exename), " exists = ", exist write (u, "(A)") write (u, "(A)") "* Build executable" write (u, "(A)") call compilation%make_compile (global%os_data) call compilation%make_link (global%os_data) write (u, "(A)") "* Check executable (should be present)" write (u, "(A)") inquire (file = char (exename), exist = exist) write (u, "(A,A,L1)") char (exename), " exists = ", exist write (u, "(A)") write (u, "(A)") "* Cleanup" call compilation%make_clean_exe (global%os_data) call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: compilations_static_1" end subroutine compilations_static_1 @ %def compilations_static_1 @ \subsubsection{External Matrix Element} Compile an external test matrix element ([[omega]] type) and incorporate this in a new static WHIZARD executable. In this version, we use the wrapper [[compile_executable]] procedure. <>= call test (compilations_static_2, "compilations_static_2", & "static executable: shortcut", & u, results) <>= public :: compilations_static_2 <>= subroutine compilations_static_2 (u) integer, intent(in) :: u type(string_t) :: libname, procname, exename type(rt_data_t), target :: global logical :: exist integer :: u_file write (u, "(A)") "* Test output: compilations_static_2" write (u, "(A)") "* Purpose: make static executable" write (u, "(A)") write (u, "(A)") "* Initialize library and compile" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) libname = "compilations_static_2_lib" procname = "prc_comp_stat_2" exename = "compilations_static_2" call prepare_test_library (global, libname, 2, [procname,procname]) call compile_executable (exename, [libname], global) write (u, "(A)") "* Check executable (should be present)" write (u, "(A)") inquire (file = char (exename), exist = exist) write (u, "(A,A,L1)") char (exename), " exists = ", exist write (u, "(A)") write (u, "(A)") "* Cleanup" u_file = free_unit () open (u_file, file = char (exename), status = "old", action = "write") close (u_file, status = "delete") call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: compilations_static_2" end subroutine compilations_static_2 @ %def compilations_static_2 @ \clearpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Integration} This module manages phase space setup, matrix-element evaluation and integration, as far as it is not done by lower-level routines, in particular in the [[processes]] module. <<[[integrations.f90]]>>= <> module integrations <> <> <> use io_units use diagnostics use os_interface use cputime use sm_qcd use physics_defs use model_data use pdg_arrays use variables, only: var_list_t use eval_trees use sf_mappings use sf_base use phs_base use rng_base use mci_base use process_libraries use prc_core use process_config, only: COMP_MASTER, COMP_REAL_FIN, & COMP_MISMATCH, COMP_PDF, COMP_REAL, COMP_SUB, COMP_VIRT, & COMP_REAL_SING use process use pcm_base, only: pcm_t use instances use process_stacks use models use iterations use rt_data use dispatch_me_methods, only: dispatch_core use dispatch_beams, only: dispatch_qcd, sf_prop_t, dispatch_sf_config use dispatch_phase_space, only: dispatch_sf_channels use dispatch_phase_space, only: dispatch_phs use dispatch_mci, only: dispatch_mci_s, setup_grid_path use dispatch_transforms, only: dispatch_evt_shower_hook use compilations, only: compile_library use dispatch_fks, only: dispatch_fks_s use nlo_data <> <> <> <> contains <> end module integrations @ %def integrations @ \subsection{The integration type} This type holds all relevant data, the integration methods operates on this. In contrast to the [[simulation_t]] introduced later, the [[integration_t]] applies to a single process. <>= public :: integration_t <>= type :: integration_t private type(string_t) :: process_id type(string_t) :: run_id type(process_t), pointer :: process => null () logical :: rebuild_phs = .false. logical :: ignore_phs_mismatch = .false. logical :: phs_only = .false. logical :: process_has_me = .true. integer :: n_calls_test = 0 logical :: vis_history = .true. type(string_t) :: history_filename type(string_t) :: log_filename type(helicity_selection_t) :: helicity_selection logical :: use_color_factors = .false. logical :: has_beam_pol = .false. logical :: combined_integration = .false. type(iteration_multipliers_t) :: iteration_multipliers type(nlo_settings_t) :: nlo_settings contains <> end type integration_t @ %def integration_t @ @ \subsection{Initialization} Initialization, first part: Create a process entry. Push it on the stack if the [[global]] environment is supplied. <>= procedure :: create_process => integration_create_process <>= subroutine integration_create_process (intg, process_id, global) class(integration_t), intent(out) :: intg type(rt_data_t), intent(inout), optional, target :: global type(string_t), intent(in) :: process_id type(process_entry_t), pointer :: process_entry if (debug_on) call msg_debug (D_CORE, "integration_create_process") intg%process_id = process_id if (present (global)) then allocate (process_entry) intg%process => process_entry%process_t call global%process_stack%push (process_entry) else allocate (process_t :: intg%process) end if end subroutine integration_create_process @ %def integration_create_process @ Initialization, second part: Initialize the process object, using the local environment. We allocate a RNG factory and a QCD object. We also fetch a pointer to the model that the process uses. The process initializer will create a snapshot of that model. This procedure does not modify the [[local]] stack directly. The intent(inout) attribute for the [[local]] data set is due to the random generator seed which may be incremented during initialization. NOTE: Changes to model parameters within the current context are respected only if the process model coincides with the current model. This is the usual case. If not, we read the model from the global model library, which has default parameters. To become more flexible, we should implement a local model library which records local changes to currently inactive models. <>= procedure :: init_process => integration_init_process <>= subroutine integration_init_process (intg, local) class(integration_t), intent(inout) :: intg type(rt_data_t), intent(inout), target :: local type(string_t) :: model_name type(model_t), pointer :: model class(model_data_t), pointer :: model_instance type(var_list_t), pointer :: var_list if (debug_on) call msg_debug (D_CORE, "integration_init_process") if (.not. local%prclib%contains (intg%process_id)) then call msg_fatal ("Process '" // char (intg%process_id) // "' not found" & // " in library '" // char (local%prclib%get_name ()) // "'") return end if model_name = local%prclib%get_model_name (intg%process_id) if (local%get_sval (var_str ("$model_name")) == model_name) then model => local%model else model => local%model_list%get_model_ptr (model_name) end if var_list => local%get_var_list_ptr () call intg%process%init (intg%process_id, & local%prclib, & local%os_data, & model, & var_list, & local%beam_structure) intg%run_id = intg%process%get_run_id () end subroutine integration_init_process @ %def integration_init_process @ Initialization, third part: complete process configuration. <>= procedure :: setup_process => integration_setup_process <>= subroutine integration_setup_process (intg, local, verbose, init_only) class(integration_t), intent(inout) :: intg type(rt_data_t), intent(inout), target :: local logical, intent(in), optional :: verbose logical, intent(in), optional :: init_only type(var_list_t), pointer :: var_list class(mci_t), allocatable :: mci_template type(sf_config_t), dimension(:), allocatable :: sf_config type(sf_prop_t) :: sf_prop type(sf_channel_t), dimension(:), allocatable :: sf_channel type(phs_channel_collection_t) :: phs_channel_collection logical :: sf_trace logical :: verb, initialize_only type(string_t) :: sf_string type(string_t) :: workspace verb = .true.; if (present (verbose)) verb = verbose initialize_only = .false. if (present (init_only)) initialize_only = init_only call display_init_message (verb) var_list => local%get_var_list_ptr () call setup_log_and_history () associate (process => intg%process) call set_intg_parameters (process) call process%setup_cores (dispatch_core, & intg%helicity_selection, intg%use_color_factors, intg%has_beam_pol) call process%init_phs_config () call process%init_components () call process%record_inactive_components () intg%process_has_me = process%has_matrix_element () if (.not. intg%process_has_me) then call msg_warning ("Process '" & // char (intg%process_id) // "': matrix element vanishes") end if call setup_beams () call setup_structure_functions () workspace = var_list%get_sval (var_str ("$integrate_workspace")) if (workspace == "") then call process%configure_phs & (intg%rebuild_phs, & intg%ignore_phs_mismatch, & intg%combined_integration) else call setup_grid_path (workspace) call process%configure_phs & (intg%rebuild_phs, & intg%ignore_phs_mismatch, & intg%combined_integration, & workspace) end if call process%complete_pcm_setup () call process%prepare_blha_cores () call process%create_blha_interface () call process%prepare_any_external_code () call process%setup_terms (with_beams = intg%has_beam_pol) call process%check_masses () if (verb) then call process%write (screen = .true.) call process%print_phs_startup_message () end if if (intg%process_has_me) then if (size (sf_config) > 0) then call process%collect_channels (phs_channel_collection) else if (.not. initialize_only & .and. process%contains_trivial_component ()) then call msg_fatal ("Integrate: 2 -> 1 process can't be handled & &with fixed-energy beams") end if call dispatch_sf_channels & (sf_channel, sf_string, sf_prop, phs_channel_collection, & local%var_list, local%get_sqrts(), local%beam_structure) if (allocated (sf_channel)) then if (size (sf_channel) > 0) then call process%set_sf_channel (sf_channel) end if end if call phs_channel_collection%final () if (verb) call process%sf_startup_message (sf_string) end if call process%setup_mci (dispatch_mci_s) call setup_expressions () call process%compute_md5sum () end associate contains subroutine setup_log_and_history () if (intg%run_id /= "") then intg%history_filename = intg%process_id // "." // intg%run_id & // ".history" intg%log_filename = intg%process_id // "." // intg%run_id // ".log" else intg%history_filename = intg%process_id // ".history" intg%log_filename = intg%process_id // ".log" end if intg%vis_history = & var_list%get_lval (var_str ("?vis_history")) end subroutine setup_log_and_history subroutine set_intg_parameters (process) type(process_t), intent(in) :: process intg%n_calls_test = & var_list%get_ival (var_str ("n_calls_test")) intg%combined_integration = & var_list%get_lval (var_str ('?combined_nlo_integration')) & .and. process%is_nlo_calculation () intg%use_color_factors = & var_list%get_lval (var_str ("?read_color_factors")) intg%has_beam_pol = & local%beam_structure%has_polarized_beams () intg%helicity_selection = & local%get_helicity_selection () intg%rebuild_phs = & var_list%get_lval (var_str ("?rebuild_phase_space")) intg%ignore_phs_mismatch = & .not. var_list%get_lval (var_str ("?check_phs_file")) intg%phs_only = & var_list%get_lval (var_str ("?phs_only")) end subroutine set_intg_parameters subroutine display_init_message (verb) logical, intent(in) :: verb if (verb) then call msg_message ("Initializing integration for process " & // char (intg%process_id) // ":") if (intg%run_id /= "") & call msg_message ("Run ID = " // '"' // char (intg%run_id) // '"') end if end subroutine display_init_message subroutine setup_beams () real(default) :: sqrts logical :: decay_rest_frame sqrts = local%get_sqrts () decay_rest_frame = & var_list%get_lval (var_str ("?decay_rest_frame")) if (intg%process_has_me) then call intg%process%setup_beams_beam_structure & (local%beam_structure, sqrts, decay_rest_frame) end if if (verb .and. intg%process_has_me) then call intg%process%beams_startup_message & (beam_structure = local%beam_structure) end if end subroutine setup_beams subroutine setup_structure_functions () integer :: n_in type(pdg_array_t), dimension(:,:), allocatable :: pdg_prc type(string_t) :: sf_trace_file if (intg%process_has_me) then call intg%process%get_pdg_in (pdg_prc) else n_in = intg%process%get_n_in () allocate (pdg_prc (n_in, intg%process%get_n_components ())) pdg_prc = 0 end if call dispatch_sf_config (sf_config, sf_prop, local%beam_structure, & local%get_var_list_ptr (), local%var_list, & local%model, local%os_data, local%get_sqrts (), pdg_prc) sf_trace = & var_list%get_lval (var_str ("?sf_trace")) sf_trace_file = & var_list%get_sval (var_str ("$sf_trace_file")) if (sf_trace) then call intg%process%init_sf_chain (sf_config, sf_trace_file) else call intg%process%init_sf_chain (sf_config) end if end subroutine setup_structure_functions subroutine setup_expressions () type(eval_tree_factory_t) :: expr_factory if (associated (local%pn%cuts_lexpr)) then if (verb) call msg_message ("Applying user-defined cuts.") call expr_factory%init (local%pn%cuts_lexpr) call intg%process%set_cuts (expr_factory) else if (verb) call msg_warning ("No cuts have been defined.") end if if (associated (local%pn%scale_expr)) then if (verb) call msg_message ("Using user-defined general scale.") call expr_factory%init (local%pn%scale_expr) call intg%process%set_scale (expr_factory) end if if (associated (local%pn%fac_scale_expr)) then if (verb) call msg_message ("Using user-defined factorization scale.") call expr_factory%init (local%pn%fac_scale_expr) call intg%process%set_fac_scale (expr_factory) end if if (associated (local%pn%ren_scale_expr)) then if (verb) call msg_message ("Using user-defined renormalization scale.") call expr_factory%init (local%pn%ren_scale_expr) call intg%process%set_ren_scale (expr_factory) end if if (associated (local%pn%weight_expr)) then if (verb) call msg_message ("Using user-defined reweighting factor.") call expr_factory%init (local%pn%weight_expr) call intg%process%set_weight (expr_factory) end if end subroutine setup_expressions end subroutine integration_setup_process @ %def integration_setup_process @ \subsection{Integration} Integrate: do the final integration. Here, we do a multi-iteration integration. Again, we skip iterations that are already on file. Record the results in the global variable list. <>= procedure :: evaluate => integration_evaluate <>= subroutine integration_evaluate & (intg, process_instance, i_mci, pass, it_list, pacify) class(integration_t), intent(inout) :: intg type(process_instance_t), intent(inout), target :: process_instance integer, intent(in) :: i_mci integer, intent(in) :: pass type(iterations_list_t), intent(in) :: it_list logical, intent(in), optional :: pacify integer :: n_calls, n_it logical :: adapt_grids, adapt_weights, final n_it = it_list%get_n_it (pass) n_calls = it_list%get_n_calls (pass) adapt_grids = it_list%adapt_grids (pass) adapt_weights = it_list%adapt_weights (pass) final = pass == it_list%get_n_pass () call process_instance%integrate ( & i_mci, n_it, n_calls, adapt_grids, adapt_weights, & final, pacify) end subroutine integration_evaluate @ %def integration_evaluate @ In case the user has not provided a list of iterations, make a reasonable default. This can depend on the process. The usual approach is to define two distinct passes, one for adaptation and one for integration. <>= procedure :: make_iterations_list => integration_make_iterations_list <>= subroutine integration_make_iterations_list (intg, it_list) class(integration_t), intent(in) :: intg type(iterations_list_t), intent(out) :: it_list integer :: pass, n_pass integer, dimension(:), allocatable :: n_it, n_calls logical, dimension(:), allocatable :: adapt_grids, adapt_weights n_pass = intg%process%get_n_pass_default () allocate (n_it (n_pass), n_calls (n_pass)) allocate (adapt_grids (n_pass), adapt_weights (n_pass)) do pass = 1, n_pass n_it(pass) = intg%process%get_n_it_default (pass) n_calls(pass) = intg%process%get_n_calls_default (pass) adapt_grids(pass) = intg%process%adapt_grids_default (pass) adapt_weights(pass) = intg%process%adapt_weights_default (pass) end do call it_list%init (n_it, n_calls, & adapt_grids = adapt_grids, adapt_weights = adapt_weights) end subroutine integration_make_iterations_list @ %def integration_make_iterations_list @ In NLO calculations, the individual components might scale very differently with the number of calls. This especially applies to the real-subtracted component, which usually fluctuates more than the Born and virtual component, making it a bottleneck of the calculation. Thus, the calculation is throttled twice, first by the number of calls for the real component, second by the number of surplus calls of computation-intense virtual matrix elements. Therefore, we want to set a different number of calls for each component, which is done by the subroutine [[integration_apply_call_multipliers]]. <>= procedure :: init_iteration_multipliers => integration_init_iteration_multipliers <>= subroutine integration_init_iteration_multipliers (intg, local) class(integration_t), intent(inout) :: intg type(rt_data_t), intent(in) :: local integer :: n_pass, pass type(iterations_list_t) :: it_list n_pass = local%it_list%get_n_pass () if (n_pass == 0) then call intg%make_iterations_list (it_list) n_pass = it_list%get_n_pass () end if associate (it_multipliers => intg%iteration_multipliers) allocate (it_multipliers%n_calls0 (n_pass)) do pass = 1, n_pass it_multipliers%n_calls0(pass) = local%it_list%get_n_calls (pass) end do it_multipliers%mult_real = local%var_list%get_rval & (var_str ("mult_call_real")) it_multipliers%mult_virt = local%var_list%get_rval & (var_str ("mult_call_virt")) it_multipliers%mult_dglap = local%var_list%get_rval & (var_str ("mult_call_dglap")) end associate end subroutine integration_init_iteration_multipliers @ %def integration_init_iteration_multipliers @ <>= procedure :: apply_call_multipliers => integration_apply_call_multipliers <>= subroutine integration_apply_call_multipliers (intg, n_pass, i_component, it_list) class(integration_t), intent(in) :: intg integer, intent(in) :: n_pass, i_component type(iterations_list_t), intent(inout) :: it_list integer :: nlo_type integer :: n_calls0, n_calls integer :: pass real(default) :: multiplier nlo_type = intg%process%get_component_nlo_type (i_component) do pass = 1, n_pass associate (multipliers => intg%iteration_multipliers) select case (nlo_type) case (NLO_REAL) multiplier = multipliers%mult_real case (NLO_VIRTUAL) multiplier = multipliers%mult_virt case (NLO_DGLAP) multiplier = multipliers%mult_dglap case default return end select end associate if (n_pass <= size (intg%iteration_multipliers%n_calls0)) then n_calls0 = intg%iteration_multipliers%n_calls0 (pass) n_calls = floor (multiplier * n_calls0) call it_list%set_n_calls (pass, n_calls) end if end do end subroutine integration_apply_call_multipliers @ %def integration_apply_call_multipliers @ \subsection{API for integration objects} This initializer does everything except assigning cuts/scale/weight expressions. <>= procedure :: init => integration_init <>= subroutine integration_init & (intg, process_id, local, global, local_stack, init_only) class(integration_t), intent(out) :: intg type(string_t), intent(in) :: process_id type(rt_data_t), intent(inout), target :: local type(rt_data_t), intent(inout), optional, target :: global logical, intent(in), optional :: init_only logical, intent(in), optional :: local_stack logical :: use_local use_local = .false.; if (present (local_stack)) use_local = local_stack if (present (global)) then call intg%create_process (process_id, global) else if (use_local) then call intg%create_process (process_id, local) else call intg%create_process (process_id) end if call intg%init_process (local) call intg%setup_process (local, init_only = init_only) call intg%init_iteration_multipliers (local) end subroutine integration_init @ %def integration_init @ Do the integration for a single process, both warmup and final evaluation. The [[eff_reset]] flag is to suppress numerical noise in the graphical output of the integration history. <>= procedure :: integrate => integration_integrate <>= subroutine integration_integrate (intg, local, eff_reset) class(integration_t), intent(inout) :: intg type(rt_data_t), intent(in), target :: local logical, intent(in), optional :: eff_reset type(string_t) :: log_filename type(var_list_t), pointer :: var_list type(process_instance_t), allocatable, target :: process_instance type(iterations_list_t) :: it_list logical :: pacify integer :: pass, i_mci, n_mci, n_pass integer :: i_component integer :: nlo_type logical :: display_summed logical :: nlo_active type(string_t) :: component_output allocate (process_instance) call process_instance%init (intg%process) var_list => intg%process%get_var_list_ptr () call openmp_set_num_threads_verbose & (var_list%get_ival (var_str ("openmp_num_threads")), & var_list%get_lval (var_str ("?openmp_logging"))) pacify = var_list%get_lval (var_str ("?pacify")) display_summed = .true. n_mci = intg%process%get_n_mci () if (n_mci == 1) then write (msg_buffer, "(A,A,A)") & "Starting integration for process '", & char (intg%process%get_id ()), "'" call msg_message () end if call setup_hooks () nlo_active = any (intg%process%get_component_nlo_type & ([(i_mci, i_mci = 1, n_mci)]) /= BORN) do i_mci = 1, n_mci i_component = intg%process%get_master_component (i_mci) nlo_type = intg%process%get_component_nlo_type (i_component) if (intg%process%component_can_be_integrated (i_component)) then if (n_mci > 1) then if (nlo_active) then if (intg%combined_integration .and. nlo_type == BORN) then component_output = var_str ("Combined") else component_output = component_status (nlo_type) end if write (msg_buffer, "(A,A,A,A,A)") & "Starting integration for process '", & char (intg%process%get_id ()), "' part '", & char (component_output), "'" else write (msg_buffer, "(A,A,A,I0)") & "Starting integration for process '", & char (intg%process%get_id ()), "' part ", i_mci end if call msg_message () end if n_pass = local%it_list%get_n_pass () if (n_pass == 0) then call msg_message ("Integrate: iterations not specified, & &using default") call intg%make_iterations_list (it_list) n_pass = it_list%get_n_pass () else it_list = local%it_list end if call intg%apply_call_multipliers (n_pass, i_mci, it_list) call msg_message ("Integrate: " // char (it_list%to_string ())) do pass = 1, n_pass call intg%evaluate (process_instance, i_mci, pass, it_list, pacify) if (signal_is_pending ()) return end do call intg%process%final_integration (i_mci) if (intg%vis_history) then call intg%process%display_integration_history & (i_mci, intg%history_filename, local%os_data, eff_reset) end if if (local%logfile == intg%log_filename) then if (intg%run_id /= "") then log_filename = intg%process_id // "." // intg%run_id // & ".var.log" else log_filename = intg%process_id // ".var.log" end if call msg_message ("Name clash for global logfile and process log: ", & arr =[var_str ("| Renaming log file from ") // local%logfile, & var_str ("| to ") // log_filename // var_str (" .")]) else log_filename = intg%log_filename end if call intg%process%write_logfile (i_mci, log_filename) end if end do if (n_mci > 1 .and. display_summed) then call msg_message ("Integrate: sum of all components") call intg%process%display_summed_results (pacify) end if call process_instance%final () deallocate (process_instance) contains subroutine setup_hooks () class(process_instance_hook_t), pointer :: hook call dispatch_evt_shower_hook (hook, var_list, process_instance) if (associated (hook)) then call process_instance%append_after_hook (hook) end if end subroutine setup_hooks end subroutine integration_integrate @ %def integration_integrate @ Do a dummy integration for a process which could not be initialized (e.g., has no matrix element). The result is zero. <>= procedure :: integrate_dummy => integration_integrate_dummy <>= subroutine integration_integrate_dummy (intg) class(integration_t), intent(inout) :: intg call intg%process%integrate_dummy () end subroutine integration_integrate_dummy @ %def integration_integrate_dummy @ Just sample the matrix element under realistic conditions (but no cuts); throw away the results. <>= procedure :: sampler_test => integration_sampler_test <>= subroutine integration_sampler_test (intg) class(integration_t), intent(inout) :: intg type(process_instance_t), allocatable, target :: process_instance integer :: n_mci, i_mci type(timer_t) :: timer_mci, timer_tot real(default) :: t_mci, t_tot allocate (process_instance) call process_instance%init (intg%process) n_mci = intg%process%get_n_mci () if (n_mci == 1) then write (msg_buffer, "(A,A,A)") & "Test: probing process '", & char (intg%process%get_id ()), "'" call msg_message () end if call timer_tot%start () do i_mci = 1, n_mci if (n_mci > 1) then write (msg_buffer, "(A,A,A,I0)") & "Test: probing process '", & char (intg%process%get_id ()), "' part ", i_mci call msg_message () end if call timer_mci%start () call process_instance%sampler_test (i_mci, intg%n_calls_test) call timer_mci%stop () t_mci = timer_mci write (msg_buffer, "(A,ES12.5)") "Test: " & // "time in seconds (wallclock): ", t_mci call msg_message () end do call timer_tot%stop () t_tot = timer_tot if (n_mci > 1) then write (msg_buffer, "(A,ES12.5)") "Test: " & // "total time (wallclock): ", t_tot call msg_message () end if call process_instance%final () end subroutine integration_sampler_test @ %def integration_sampler_test @ Return the process pointer (needed by simulate): <>= procedure :: get_process_ptr => integration_get_process_ptr <>= function integration_get_process_ptr (intg) result (ptr) class(integration_t), intent(in) :: intg type(process_t), pointer :: ptr ptr => intg%process end function integration_get_process_ptr @ %def integration_get_process_ptr @ Simply integrate, do a dummy integration if necessary. The [[integration]] object exists only internally. If the [[global]] environment is provided, the process object is appended to the global stack. Otherwise, if [[local_stack]] is set, we append to the local process stack. If this is unset, the [[process]] object is not recorded permanently. The [[init_only]] flag can be used to skip the actual integration part. We will end up with a process object that is completely initialized, including phase space configuration. The [[eff_reset]] flag is to suppress numerical noise in the visualization of the integration history. <>= public :: integrate_process <>= subroutine integrate_process (process_id, local, global, local_stack, init_only, eff_reset) type(string_t), intent(in) :: process_id type(rt_data_t), intent(inout), target :: local type(rt_data_t), intent(inout), optional, target :: global logical, intent(in), optional :: local_stack, init_only, eff_reset type(string_t) :: prclib_name type(integration_t) :: intg character(32) :: buffer <> <> if (.not. associated (local%prclib)) then call msg_fatal ("Integrate: current process library is undefined") return end if if (.not. local%prclib%is_active ()) then call msg_message ("Integrate: current process library needs compilation") prclib_name = local%prclib%get_name () call compile_library (prclib_name, local) if (signal_is_pending ()) return call msg_message ("Integrate: compilation done") end if call intg%init (process_id, local, global, local_stack, init_only) if (signal_is_pending ()) return if (present (init_only)) then if (init_only) return end if if (intg%n_calls_test > 0) then write (buffer, "(I0)") intg%n_calls_test call msg_message ("Integrate: test (" // trim (buffer) // " calls) ...") call intg%sampler_test () call msg_message ("Integrate: ... test complete.") if (signal_is_pending ()) return end if <> if (intg%phs_only) then call msg_message ("Integrate: phase space only, skipping integration") else if (intg%process_has_me) then call intg%integrate (local, eff_reset) else call intg%integrate_dummy () end if end if end subroutine integrate_process @ %def integrate_process <>= @ <>= @ <>= @ @ The parallelization leads to undefined behavior while writing simultaneously to one file. The master worker has to initialize single-handed the corresponding library files and the phase space file. The slave worker will wait with a blocking [[MPI_BCAST]] until they receive a logical flag. <>= type(var_list_t), pointer :: var_list logical :: mpi_logging, process_init integer :: rank, n_size <>= if (debug_on) call msg_debug (D_MPI, "integrate_process") var_list => local%get_var_list_ptr () process_init = .false. call mpi_get_comm_id (n_size, rank) mpi_logging = (("vamp2" == char (var_list%get_sval (var_str ("$integration_method"))) .and. & & (n_size > 1)) .or. var_list%get_lval (var_str ("?mpi_logging"))) if (debug_on) call msg_debug (D_MPI, "n_size", rank) if (debug_on) call msg_debug (D_MPI, "rank", rank) if (debug_on) call msg_debug (D_MPI, "mpi_logging", mpi_logging) if (rank /= 0) then if (mpi_logging) then call msg_message ("MPI: wait for master to finish process initialization ...") end if call MPI_bcast (process_init, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD) else process_init = .true. end if if (process_init) then <>= if (rank == 0) then if (mpi_logging) then call msg_message ("MPI: finish process initialization, load slaves ...") end if call MPI_bcast (process_init, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD) end if end if call MPI_barrier (MPI_COMM_WORLD) call mpi_set_logging (mpi_logging) @ %def integrate_process_mpi @ \subsection{Unit Tests} Test module, followed by the stand-alone unit-test procedures. <<[[integrations_ut.f90]]>>= <> module integrations_ut use unit_tests use integrations_uti <> <> contains <> end module integrations_ut @ %def integrations_ut @ <<[[integrations_uti.f90]]>>= <> module integrations_uti <> <> use io_units use ifiles use lexers use parser use io_units use flavors use interactions, only: reset_interaction_counter use phs_forests use eval_trees use models use rt_data use process_configurations_ut, only: prepare_test_library use compilations, only: compile_library use integrations use phs_wood_ut, only: write_test_phs_file <> <> contains <> end module integrations_uti @ %def integrations_uti @ API: driver for the unit tests below. <>= public :: integrations_test <>= subroutine integrations_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine integrations_test @ %def integrations_test @ <>= public :: integrations_history_test <>= subroutine integrations_history_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine integrations_history_test @ %def integrations_history_test @ \subsubsection{Integration of test process} Compile and integrate an intrinsic test matrix element ([[prc_test]] type). The phase-space implementation is [[phs_single]] (single-particle phase space), the integrator is [[mci_midpoint]]. The cross section for the $2\to 2$ process $ss\to ss$ with its constant matrix element is given by \begin{equation} \sigma = c\times f\times \Phi_2 \times |M|^2. \end{equation} $c$ is the conversion constant \begin{equation} c = 0.3894\times 10^{12}\;\mathrm{fb}\,\mathrm{GeV}^2. \end{equation} $f$ is the flux of the incoming particles with mass $m=125\,\mathrm{GeV}$ and energy $\sqrt{s}=1000\,\mathrm{GeV}$ \begin{equation} f = \frac{(2\pi)^4}{2\lambda^{1/2}(s,m^2,m^2)} = \frac{(2\pi)^4}{2\sqrt{s}\,\sqrt{s - 4m^2}} = 8.048\times 10^{-4}\;\mathrm{GeV}^{-2} \end{equation} $\Phi_2$ is the volume of the two-particle phase space \begin{equation} \Phi_2 = \frac{1}{4(2\pi)^5} = 2.5529\times 10^{-5}. \end{equation} The squared matrix element $|M|^2$ is unity. Combining everything, we obtain \begin{equation} \sigma = 8000\;\mathrm{fb} \end{equation} This number should appear as the final result. Note: In this and the following test, we reset the Fortran compiler and flag variables immediately before they are printed, so the test is portable. <>= call test (integrations_1, "integrations_1", & "intrinsic test process", & u, results) <>= public :: integrations_1 <>= subroutine integrations_1 (u) integer, intent(in) :: u type(string_t) :: libname, procname type(rt_data_t), target :: global write (u, "(A)") "* Test output: integrations_1" write (u, "(A)") "* Purpose: integrate test process" write (u, "(A)") call syntax_model_file_init () call global%global_init () libname = "integration_1" procname = "prc_config_a" call prepare_test_library (global, libname, 1) call compile_library (libname, global) call global%set_string (var_str ("$run_id"), & var_str ("integrations1"), is_known = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("single"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known=.true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%it_list%init ([1], [1000]) call reset_interaction_counter () call integrate_process (procname, global, local_stack=.true.) call global%write (u, vars = [ & var_str ("$method"), & var_str ("sqrts"), & var_str ("$integration_method"), & var_str ("$phs_method"), & var_str ("$run_id")]) call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: integrations_1" end subroutine integrations_1 @ %def integrations_1 @ \subsubsection{Integration with cuts} Compile and integrate an intrinsic test matrix element ([[prc_test]] type) with cuts set. <>= call test (integrations_2, "integrations_2", & "intrinsic test process with cut", & u, results) <>= public :: integrations_2 <>= subroutine integrations_2 (u) integer, intent(in) :: u type(string_t) :: libname, procname type(rt_data_t), target :: global type(string_t) :: cut_expr_text type(ifile_t) :: ifile type(stream_t) :: stream type(parse_tree_t) :: parse_tree type(string_t), dimension(0) :: empty_string_array write (u, "(A)") "* Test output: integrations_2" write (u, "(A)") "* Purpose: integrate test process with cut" write (u, "(A)") call syntax_model_file_init () call global%global_init () write (u, "(A)") "* Prepare a cut expression" write (u, "(A)") call syntax_pexpr_init () cut_expr_text = "all Pt > 100 [s]" call ifile_append (ifile, cut_expr_text) call stream_init (stream, ifile) call parse_tree_init_lexpr (parse_tree, stream, .true.) global%pn%cuts_lexpr => parse_tree%get_root_ptr () write (u, "(A)") "* Build and initialize a test process" write (u, "(A)") libname = "integration_3" procname = "prc_config_a" call prepare_test_library (global, libname, 1) call compile_library (libname, global) call global%set_string (var_str ("$run_id"), & var_str ("integrations1"), is_known = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("single"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known=.true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%it_list%init ([1], [1000]) call reset_interaction_counter () call integrate_process (procname, global, local_stack=.true.) call global%write (u, vars = empty_string_array) call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: integrations_2" end subroutine integrations_2 @ %def integrations_2 @ \subsubsection{Standard phase space} Compile and integrate an intrinsic test matrix element ([[prc_test]] type) using the default ([[phs_wood]]) phase-space implementation. We use an explicit phase-space configuration file with a single channel and integrate by [[mci_midpoint]]. <>= call test (integrations_3, "integrations_3", & "standard phase space", & u, results) <>= public :: integrations_3 <>= subroutine integrations_3 (u) <> <> use interactions, only: reset_interaction_counter use models use rt_data use process_configurations_ut, only: prepare_test_library use compilations, only: compile_library use integrations implicit none integer, intent(in) :: u type(string_t) :: libname, procname type(rt_data_t), target :: global integer :: u_phs write (u, "(A)") "* Test output: integrations_3" write (u, "(A)") "* Purpose: integrate test process" write (u, "(A)") write (u, "(A)") "* Initialize process and parameters" write (u, "(A)") call syntax_model_file_init () call syntax_phs_forest_init () call global%global_init () libname = "integration_3" procname = "prc_config_a" call prepare_test_library (global, libname, 1) call compile_library (libname, global) call global%set_string (var_str ("$run_id"), & var_str ("integrations1"), is_known = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("default"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_log (var_str ("?phs_s_mapping"),& .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known=.true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) write (u, "(A)") "* Create a scratch phase-space file" write (u, "(A)") u_phs = free_unit () open (u_phs, file = "integrations_3.phs", & status = "replace", action = "write") call write_test_phs_file (u_phs, var_str ("prc_config_a_i1")) close (u_phs) call global%set_string (var_str ("$phs_file"),& var_str ("integrations_3.phs"), is_known = .true.) call global%it_list%init ([1], [1000]) write (u, "(A)") "* Integrate" write (u, "(A)") call reset_interaction_counter () call integrate_process (procname, global, local_stack=.true.) call global%write (u, vars = [ & var_str ("$phs_method"), & var_str ("$phs_file")]) write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () call syntax_phs_forest_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: integrations_3" end subroutine integrations_3 @ %def integrations_3 @ \subsubsection{VAMP integration} Compile and integrate an intrinsic test matrix element ([[prc_test]] type) using the single-channel ([[phs_single]]) phase-space implementation. The integration method is [[vamp]]. <>= call test (integrations_4, "integrations_4", & "VAMP integration (one iteration)", & u, results) <>= public :: integrations_4 <>= subroutine integrations_4 (u) integer, intent(in) :: u type(string_t) :: libname, procname type(rt_data_t), target :: global write (u, "(A)") "* Test output: integrations_4" write (u, "(A)") "* Purpose: integrate test process using VAMP" write (u, "(A)") write (u, "(A)") "* Initialize process and parameters" write (u, "(A)") call syntax_model_file_init () call global%global_init () libname = "integrations_4_lib" procname = "integrations_4" call prepare_test_library (global, libname, 1, [procname]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_grids"), .true., intrinsic = .true.) call global%set_string (var_str ("$run_id"), & var_str ("r1"), is_known = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("single"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("vamp"), is_known = .true.) call global%set_log (var_str ("?use_vamp_equivalences"),& .false., is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known=.true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%it_list%init ([1], [1000]) write (u, "(A)") "* Integrate" write (u, "(A)") call reset_interaction_counter () call integrate_process (procname, global, local_stack=.true.) call global%pacify (efficiency_reset = .true., error_reset = .true.) call global%write (u, vars = [var_str ("$integration_method")], & pacify = .true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: integrations_4" end subroutine integrations_4 @ %def integrations_4 @ \subsubsection{Multiple iterations integration} Compile and integrate an intrinsic test matrix element ([[prc_test]] type) using the single-channel ([[phs_single]]) phase-space implementation. The integration method is [[vamp]]. We launch three iterations. <>= call test (integrations_5, "integrations_5", & "VAMP integration (three iterations)", & u, results) <>= public :: integrations_5 <>= subroutine integrations_5 (u) integer, intent(in) :: u type(string_t) :: libname, procname type(rt_data_t), target :: global write (u, "(A)") "* Test output: integrations_5" write (u, "(A)") "* Purpose: integrate test process using VAMP" write (u, "(A)") write (u, "(A)") "* Initialize process and parameters" write (u, "(A)") call syntax_model_file_init () call global%global_init () libname = "integrations_5_lib" procname = "integrations_5" call prepare_test_library (global, libname, 1, [procname]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_grids"), .true., intrinsic = .true.) call global%set_string (var_str ("$run_id"), & var_str ("r1"), is_known = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("single"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("vamp"), is_known = .true.) call global%set_log (var_str ("?use_vamp_equivalences"),& .false., is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known=.true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%it_list%init ([3], [1000]) write (u, "(A)") "* Integrate" write (u, "(A)") call reset_interaction_counter () call integrate_process (procname, global, local_stack=.true.) call global%pacify (efficiency_reset = .true., error_reset = .true.) call global%write (u, vars = [var_str ("$integration_method")], & pacify = .true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: integrations_5" end subroutine integrations_5 @ %def integrations_5 @ \subsubsection{Multiple passes integration} Compile and integrate an intrinsic test matrix element ([[prc_test]] type) using the single-channel ([[phs_single]]) phase-space implementation. The integration method is [[vamp]]. We launch three passes with three iterations each. <>= call test (integrations_6, "integrations_6", & "VAMP integration (three passes)", & u, results) <>= public :: integrations_6 <>= subroutine integrations_6 (u) integer, intent(in) :: u type(string_t) :: libname, procname type(rt_data_t), target :: global type(string_t), dimension(0) :: no_vars write (u, "(A)") "* Test output: integrations_6" write (u, "(A)") "* Purpose: integrate test process using VAMP" write (u, "(A)") write (u, "(A)") "* Initialize process and parameters" write (u, "(A)") call syntax_model_file_init () call global%global_init () libname = "integrations_6_lib" procname = "integrations_6" call prepare_test_library (global, libname, 1, [procname]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_grids"), .true., intrinsic = .true.) call global%set_string (var_str ("$run_id"), & var_str ("r1"), is_known = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("single"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("vamp"), is_known = .true.) call global%set_log (var_str ("?use_vamp_equivalences"),& .false., is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known=.true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%it_list%init ([3, 3, 3], [1000, 1000, 1000], & adapt = [.true., .true., .false.], & adapt_code = [var_str ("wg"), var_str ("g"), var_str ("")]) write (u, "(A)") "* Integrate" write (u, "(A)") call reset_interaction_counter () call integrate_process (procname, global, local_stack=.true.) call global%pacify (efficiency_reset = .true., error_reset = .true.) call global%write (u, vars = no_vars, pacify = .true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: integrations_6" end subroutine integrations_6 @ %def integrations_6 @ \subsubsection{VAMP and default phase space} Compile and integrate an intrinsic test matrix element ([[prc_test]] type) using the default ([[phs_wood]]) phase-space implementation. The integration method is [[vamp]]. We launch three passes with three iterations each. We enable channel equivalences and groves. <>= call test (integrations_7, "integrations_7", & "VAMP integration with wood phase space", & u, results) <>= public :: integrations_7 <>= subroutine integrations_7 (u) integer, intent(in) :: u type(string_t) :: libname, procname type(rt_data_t), target :: global type(string_t), dimension(0) :: no_vars integer :: iostat, u_phs character(95) :: buffer type(string_t) :: phs_file logical :: exist write (u, "(A)") "* Test output: integrations_7" write (u, "(A)") "* Purpose: integrate test process using VAMP" write (u, "(A)") write (u, "(A)") "* Initialize process and parameters" write (u, "(A)") call syntax_model_file_init () call syntax_phs_forest_init () call global%global_init () libname = "integrations_7_lib" procname = "integrations_7" call prepare_test_library (global, libname, 1, [procname]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_grids"), .true., intrinsic = .true.) call global%set_string (var_str ("$run_id"), & var_str ("r1"), is_known = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("wood"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("vamp"), is_known = .true.) call global%set_log (var_str ("?use_vamp_equivalences"),& .true., is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_log (var_str ("?phs_s_mapping"),& .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known=.true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%it_list%init ([3, 3, 3], [1000, 1000, 1000], & adapt = [.true., .true., .false.], & adapt_code = [var_str ("wg"), var_str ("g"), var_str ("")]) write (u, "(A)") "* Integrate" write (u, "(A)") call reset_interaction_counter () call integrate_process (procname, global, local_stack=.true.) call global%pacify (efficiency_reset = .true., error_reset = .true.) call global%write (u, vars = no_vars, pacify = .true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () call syntax_phs_forest_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Generated phase-space file" write (u, "(A)") phs_file = procname // ".r1.i1.phs" inquire (file = char (phs_file), exist = exist) if (exist) then u_phs = free_unit () open (u_phs, file = char (phs_file), action = "read", status = "old") iostat = 0 do while (iostat == 0) read (u_phs, "(A)", iostat = iostat) buffer if (iostat == 0) write (u, "(A)") trim (buffer) end do close (u_phs) else write (u, "(A)") "[file is missing]" end if write (u, "(A)") write (u, "(A)") "* Test output end: integrations_7" end subroutine integrations_7 @ %def integrations_7 @ \subsubsection{Structure functions} Compile and integrate an intrinsic test matrix element ([[prc_test]] type) using the default ([[phs_wood]]) phase-space implementation. The integration method is [[vamp]]. There is a structure function of type [[unit_test]]. We use a test structure function $f(x)=x$ for both beams. Together with the $1/x_1x_2$ factor from the phase-space flux and a unit matrix element, we should get the same result as previously for the process without structure functions. There is a slight correction due to the $m_s$ mass which we set to zero here. <>= call test (integrations_8, "integrations_8", & "integration with structure function", & u, results) <>= public :: integrations_8 <>= subroutine integrations_8 (u) <> <> use interactions, only: reset_interaction_counter use phs_forests use models use rt_data use process_configurations_ut, only: prepare_test_library use compilations, only: compile_library use integrations implicit none integer, intent(in) :: u type(string_t) :: libname, procname type(rt_data_t), target :: global type(flavor_t) :: flv type(string_t) :: name write (u, "(A)") "* Test output: integrations_8" write (u, "(A)") "* Purpose: integrate test process using VAMP & &with structure function" write (u, "(A)") write (u, "(A)") "* Initialize process and parameters" write (u, "(A)") call syntax_model_file_init () call syntax_phs_forest_init () call global%global_init () libname = "integrations_8_lib" procname = "integrations_8" call prepare_test_library (global, libname, 1, [procname]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_grids"), .true., intrinsic = .true.) call global%set_string (var_str ("$run_id"), & var_str ("r1"), is_known = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("wood"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("vamp"), is_known = .true.) call global%set_log (var_str ("?use_vamp_equivalences"),& .true., is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_log (var_str ("?phs_s_mapping"),& .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known=.true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%model_set_real (var_str ("ms"), 0._default) call reset_interaction_counter () call flv%init (25, global%model) name = flv%get_name () call global%beam_structure%init_sf ([name, name], [1]) call global%beam_structure%set_sf (1, 1, var_str ("sf_test_1")) write (u, "(A)") "* Integrate" write (u, "(A)") call global%it_list%init ([1], [1000]) call integrate_process (procname, global, local_stack=.true.) call global%write (u, vars = [var_str ("ms")]) write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () call syntax_phs_forest_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: integrations_8" end subroutine integrations_8 @ %def integrations_8 @ \subsubsection{Integration with sign change} Compile and integrate an intrinsic test matrix element ([[prc_test]] type). The phase-space implementation is [[phs_single]] (single-particle phase space), the integrator is [[mci_midpoint]]. The weight that is applied changes the sign in half of phase space. The weight is $-3$ and $1$, respectively, so the total result is equal to the original, but negative sign. The efficiency should (approximately) become the average of $1$ and $1/3$, that is $2/3$. <>= call test (integrations_9, "integrations_9", & "handle sign change", & u, results) <>= public :: integrations_9 <>= subroutine integrations_9 (u) integer, intent(in) :: u type(string_t) :: libname, procname type(rt_data_t), target :: global type(string_t) :: wgt_expr_text type(ifile_t) :: ifile type(stream_t) :: stream type(parse_tree_t) :: parse_tree write (u, "(A)") "* Test output: integrations_9" write (u, "(A)") "* Purpose: integrate test process" write (u, "(A)") call syntax_model_file_init () call global%global_init () write (u, "(A)") "* Prepare a weight expression" write (u, "(A)") call syntax_pexpr_init () wgt_expr_text = "eval 2 * sgn (Pz) - 1 [s]" call ifile_append (ifile, wgt_expr_text) call stream_init (stream, ifile) call parse_tree_init_expr (parse_tree, stream, .true.) global%pn%weight_expr => parse_tree%get_root_ptr () write (u, "(A)") "* Build and evaluate a test process" write (u, "(A)") libname = "integration_9" procname = "prc_config_a" call prepare_test_library (global, libname, 1) call compile_library (libname, global) call global%set_string (var_str ("$run_id"), & var_str ("integrations1"), is_known = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("single"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known=.true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%it_list%init ([1], [1000]) call reset_interaction_counter () call integrate_process (procname, global, local_stack=.true.) call global%write (u, vars = [ & var_str ("$method"), & var_str ("sqrts"), & var_str ("$integration_method"), & var_str ("$phs_method"), & var_str ("$run_id")]) call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: integrations_9" end subroutine integrations_9 @ %def integrations_9 @ \subsubsection{Integration history for VAMP integration with default phase space} This test is only run when event analysis can be done. <>= call test (integrations_history_1, "integrations_history_1", & "Test integration history files", & u, results) <>= public :: integrations_history_1 <>= subroutine integrations_history_1 (u) integer, intent(in) :: u type(string_t) :: libname, procname type(rt_data_t), target :: global type(string_t), dimension(0) :: no_vars integer :: iostat, u_his character(91) :: buffer type(string_t) :: his_file, ps_file, pdf_file logical :: exist, exist_ps, exist_pdf write (u, "(A)") "* Test output: integrations_history_1" write (u, "(A)") "* Purpose: test integration history files" write (u, "(A)") write (u, "(A)") "* Initialize process and parameters" write (u, "(A)") call syntax_model_file_init () call syntax_phs_forest_init () call global%global_init () libname = "integrations_history_1_lib" procname = "integrations_history_1" call global%set_log (var_str ("?vis_history"), & .true., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_log (var_str ("?phs_s_mapping"),& .false., is_known = .true.) call prepare_test_library (global, libname, 1, [procname]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_grids"), .true., intrinsic = .true.) call global%set_string (var_str ("$run_id"), & var_str ("r1"), is_known = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("wood"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("vamp"), is_known = .true.) call global%set_log (var_str ("?use_vamp_equivalences"),& .true., is_known = .true.) call global%set_real (var_str ("error_threshold"),& 5E-6_default, is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known=.true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%it_list%init ([2, 2, 2], [1000, 1000, 1000], & adapt = [.true., .true., .false.], & adapt_code = [var_str ("wg"), var_str ("g"), var_str ("")]) write (u, "(A)") "* Integrate" write (u, "(A)") call reset_interaction_counter () call integrate_process (procname, global, local_stack=.true., & eff_reset = .true.) call global%pacify (efficiency_reset = .true., error_reset = .true.) call global%write (u, vars = no_vars, pacify = .true.) write (u, "(A)") write (u, "(A)") "* Generated history files" write (u, "(A)") his_file = procname // ".r1.history.tex" ps_file = procname // ".r1.history.ps" pdf_file = procname // ".r1.history.pdf" inquire (file = char (his_file), exist = exist) if (exist) then u_his = free_unit () open (u_his, file = char (his_file), action = "read", status = "old") iostat = 0 do while (iostat == 0) read (u_his, "(A)", iostat = iostat) buffer if (iostat == 0) write (u, "(A)") trim (buffer) end do close (u_his) else write (u, "(A)") "[History LaTeX file is missing]" end if inquire (file = char (ps_file), exist = exist_ps) if (exist_ps) then write (u, "(A)") "[History Postscript file exists and is nonempty]" else write (u, "(A)") "[History Postscript file is missing/non-regular]" end if inquire (file = char (pdf_file), exist = exist_pdf) if (exist_pdf) then write (u, "(A)") "[History PDF file exists and is nonempty]" else write (u, "(A)") "[History PDF file is missing/non-regular]" end if write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () call syntax_phs_forest_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: integrations_history_1" end subroutine integrations_history_1 @ %def integrations_history_1 @ \clearpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Event Streams} This module manages I/O from/to multiple concurrent event streams. Usually, there is at most one input stream, but several output streams. For the latter, we set up an array which can hold [[eio_t]] (event I/O) objects of different dynamic types simultaneously. One of them may be marked as an input channel. <<[[event_streams.f90]]>>= <> module event_streams <> use io_units use diagnostics use events + use event_handles, only: event_handle_t use eio_data use eio_base use rt_data use dispatch_transforms, only: dispatch_eio <> <> <> contains <> end module event_streams @ %def event_streams @ \subsection{Event Stream Array} Each entry is an [[eio_t]] object. Since the type is dynamic, we need a wrapper: <>= type :: event_stream_entry_t class(eio_t), allocatable :: eio end type event_stream_entry_t @ %def event_stream_entry_t @ An array of event-stream entry objects. If one of the entries is an input channel, [[i_in]] is the corresponding index. <>= public :: event_stream_array_t <>= type :: event_stream_array_t type(event_stream_entry_t), dimension(:), allocatable :: entry integer :: i_in = 0 contains <> end type event_stream_array_t @ %def event_stream_array_t @ Output. <>= procedure :: write => event_stream_array_write <>= subroutine event_stream_array_write (object, unit) class(event_stream_array_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit) write (u, "(1x,A)") "Event stream array:" if (allocated (object%entry)) then select case (size (object%entry)) case (0) write (u, "(3x,A)") "[empty]" case default do i = 1, size (object%entry) if (i == object%i_in) write (u, "(1x,A)") "Input stream:" call object%entry(i)%eio%write (u) end do end select else write (u, "(3x,A)") "[undefined]" end if end subroutine event_stream_array_write @ %def event_stream_array_write +@ Check if there is content. +<>= + procedure :: is_valid => event_stream_array_is_valid +<>= + function event_stream_array_is_valid (es_array) result (flag) + class(event_stream_array_t), intent(in) :: es_array + logical :: flag + + flag = allocated (es_array%entry) + + end function event_stream_array_is_valid + +@ %def event_stream_array_is_valid @ Finalize all streams. <>= procedure :: final => event_stream_array_final <>= subroutine event_stream_array_final (es_array) class(event_stream_array_t), intent(inout) :: es_array integer :: i - do i = 1, size (es_array%entry) - call es_array%entry(i)%eio%final () - end do + if (allocated (es_array%entry)) then + do i = 1, size (es_array%entry) + call es_array%entry(i)%eio%final () + end do + end if end subroutine event_stream_array_final @ %def event_stream_array_final @ Initialization. We use a generic [[sample]] name, open event I/O objects for all provided stream types (using the [[dispatch_eio]] routine), and initialize for the given list of process pointers. If there is an [[input]] argument, this channel is initialized as an input channel and appended to the array. The [[input_data]] or, if not present, [[data]] may be modified. This happens if we open a stream for reading and get new information there. <>= procedure :: init => event_stream_array_init <>= subroutine event_stream_array_init & (es_array, sample, stream_fmt, global, & data, input, input_sample, input_data, allow_switch, & checkpoint, callback, & error) class(event_stream_array_t), intent(out) :: es_array type(string_t), intent(in) :: sample type(string_t), dimension(:), intent(in) :: stream_fmt type(rt_data_t), intent(in) :: global type(event_sample_data_t), intent(inout), optional :: data type(string_t), intent(in), optional :: input type(string_t), intent(in), optional :: input_sample type(event_sample_data_t), intent(inout), optional :: input_data logical, intent(in), optional :: allow_switch integer, intent(in), optional :: checkpoint integer, intent(in), optional :: callback logical, intent(out), optional :: error type(string_t) :: sample_in integer :: n, i, n_output, i_input, i_checkpoint, i_callback logical :: success, switch if (present (input_sample)) then sample_in = input_sample else sample_in = sample end if if (present (allow_switch)) then switch = allow_switch else switch = .true. end if if (present (error)) then error = .false. end if n = size (stream_fmt) n_output = n if (present (input)) then n = n + 1 i_input = n else i_input = 0 end if if (present (checkpoint)) then n = n + 1 i_checkpoint = n else i_checkpoint = 0 end if if (present (callback)) then n = n + 1 i_callback = n else i_callback = 0 end if allocate (es_array%entry (n)) if (i_checkpoint > 0) then call dispatch_eio & (es_array%entry(i_checkpoint)%eio, var_str ("checkpoint"), & global%var_list, global%fallback_model, & global%event_callback) call es_array%entry(i_checkpoint)%eio%init_out (sample, data) end if if (i_callback > 0) then call dispatch_eio & (es_array%entry(i_callback)%eio, var_str ("callback"), & global%var_list, global%fallback_model, & global%event_callback) call es_array%entry(i_callback)%eio%init_out (sample, data) end if if (i_input > 0) then call dispatch_eio (es_array%entry(i_input)%eio, input, & global%var_list, global%fallback_model, & global%event_callback) if (present (input_data)) then call es_array%entry(i_input)%eio%init_in & (sample_in, input_data, success) else call es_array%entry(i_input)%eio%init_in & (sample_in, data, success) end if if (success) then es_array%i_in = i_input else if (present (input_sample)) then if (present (error)) then error = .true. else call msg_fatal ("Events: & ¶meter mismatch in input, aborting") end if else call msg_message ("Events: & ¶meter mismatch, discarding old event set") call es_array%entry(i_input)%eio%final () if (switch) then call msg_message ("Events: generating new events") call es_array%entry(i_input)%eio%init_out (sample, data) end if end if end if do i = 1, n_output call dispatch_eio (es_array%entry(i)%eio, stream_fmt(i), & global%var_list, global%fallback_model, & global%event_callback) call es_array%entry(i)%eio%init_out (sample, data) end do end subroutine event_stream_array_init @ %def event_stream_array_init @ Switch the (only) input channel to an output channel, so further events are appended to the respective stream. <>= procedure :: switch_inout => event_stream_array_switch_inout <>= subroutine event_stream_array_switch_inout (es_array) class(event_stream_array_t), intent(inout) :: es_array integer :: n if (es_array%has_input ()) then n = es_array%i_in call es_array%entry(n)%eio%switch_inout () es_array%i_in = 0 else call msg_bug ("Reading events: switch_inout: no input stream selected") end if end subroutine event_stream_array_switch_inout @ %def event_stream_array_switch_inout @ Output an event (with given process number) to all output streams. If there is no output stream, do nothing. <>= procedure :: output => event_stream_array_output <>= - subroutine event_stream_array_output (es_array, event, i_prc, & - event_index, passed, pacify) + subroutine event_stream_array_output & + (es_array, event, i_prc, event_index, passed, pacify, event_handle) class(event_stream_array_t), intent(inout) :: es_array type(event_t), intent(in), target :: event integer, intent(in) :: i_prc, event_index logical, intent(in), optional :: passed, pacify + class(event_handle_t), intent(inout), optional :: event_handle logical :: increased integer :: i do i = 1, size (es_array%entry) if (i /= es_array%i_in) then associate (eio => es_array%entry(i)%eio) if (eio%split) then if (eio%split_n_evt > 0 .and. event_index > 1) then if (mod (event_index, eio%split_n_evt) == 1) then call eio%split_out () end if else if (eio%split_n_kbytes > 0) then call eio%update_split_count (increased) if (increased) call eio%split_out () end if end if call eio%output (event, i_prc, reading = es_array%i_in /= 0, & passed = passed, & - pacify = pacify) + pacify = pacify, & + event_handle = event_handle) end associate end if end do end subroutine event_stream_array_output @ %def event_stream_array_output @ Input the [[i_prc]] index which selects the process for the current event. This is separated from reading the event, because it determines which event record to read. [[iostat]] may indicate an error or an EOF condition, as usual. <>= procedure :: input_i_prc => event_stream_array_input_i_prc <>= subroutine event_stream_array_input_i_prc (es_array, i_prc, iostat) class(event_stream_array_t), intent(inout) :: es_array integer, intent(out) :: i_prc integer, intent(out) :: iostat integer :: n if (es_array%has_input ()) then n = es_array%i_in call es_array%entry(n)%eio%input_i_prc (i_prc, iostat) else call msg_fatal ("Reading events: no input stream selected") end if end subroutine event_stream_array_input_i_prc @ %def event_stream_array_input_i_prc @ Input an event from the selected input stream. [[iostat]] may indicate an error or an EOF condition, as usual. <>= procedure :: input_event => event_stream_array_input_event <>= - subroutine event_stream_array_input_event (es_array, event, iostat) + subroutine event_stream_array_input_event & + (es_array, event, iostat, event_handle) class(event_stream_array_t), intent(inout) :: es_array type(event_t), intent(inout), target :: event integer, intent(out) :: iostat + class(event_handle_t), intent(inout), optional :: event_handle integer :: n if (es_array%has_input ()) then n = es_array%i_in - call es_array%entry(n)%eio%input_event (event, iostat) + call es_array%entry(n)%eio%input_event (event, iostat, event_handle) else call msg_fatal ("Reading events: no input stream selected") end if end subroutine event_stream_array_input_event @ %def event_stream_array_input_event @ Skip an entry of eio\_t. Used to synchronize the event read-in for NLO events. <>= procedure :: skip_eio_entry => event_stream_array_skip_eio_entry <>= subroutine event_stream_array_skip_eio_entry (es_array, iostat) class(event_stream_array_t), intent(inout) :: es_array integer, intent(out) :: iostat integer :: n if (es_array%has_input ()) then n = es_array%i_in call es_array%entry(n)%eio%skip (iostat) else call msg_fatal ("Reading events: no input stream selected") end if end subroutine event_stream_array_skip_eio_entry @ %def event_stream_array_skip_eio_entry @ Return true if there is an input channel among the event streams. <>= procedure :: has_input => event_stream_array_has_input <>= function event_stream_array_has_input (es_array) result (flag) class(event_stream_array_t), intent(in) :: es_array logical :: flag flag = es_array%i_in /= 0 end function event_stream_array_has_input @ %def event_stream_array_has_input @ \subsection{Unit Tests} Test module, followed by the stand-alone unit-test procedures. <<[[event_streams_ut.f90]]>>= <> module event_streams_ut use unit_tests use event_streams_uti <> <> contains <> end module event_streams_ut @ <<[[event_streams_uti.f90]]>>= <> module event_streams_uti <> <> use model_data use eio_data use process, only: process_t use instances, only: process_instance_t use models use rt_data use events use event_streams <> <> contains <> end module event_streams_uti @ %def event_streams_uti @ API: driver for the unit tests below. <>= public :: event_streams_test <>= subroutine event_streams_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine event_streams_test @ %def event_streams_test @ \subsubsection{Empty event stream} This should set up an empty event output stream array, including initialization, output, and finalization (which are all no-ops). <>= call test (event_streams_1, "event_streams_1", & "empty event stream array", & u, results) <>= public :: event_streams_1 <>= subroutine event_streams_1 (u) integer, intent(in) :: u type(event_stream_array_t) :: es_array type(rt_data_t) :: global type(event_t) :: event type(string_t) :: sample type(string_t), dimension(0) :: empty_string_array write (u, "(A)") "* Test output: event_streams_1" write (u, "(A)") "* Purpose: handle empty event stream array" write (u, "(A)") sample = "event_streams_1" call es_array%init (sample, empty_string_array, global) call es_array%output (event, 42, 1) call es_array%write (u) call es_array%final () write (u, "(A)") write (u, "(A)") "* Test output end: event_streams_1" end subroutine event_streams_1 @ %def event_streams_1 @ \subsubsection{Nontrivial event stream} Here we generate a trivial event and choose [[raw]] output as an entry in the stream array. <>= call test (event_streams_2, "event_streams_2", & "nontrivial event stream array", & u, results) <>= public :: event_streams_2 <>= subroutine event_streams_2 (u) use processes_ut, only: prepare_test_process integer, intent(in) :: u type(event_stream_array_t) :: es_array type(rt_data_t) :: global type(model_data_t), target :: model type(event_t), allocatable, target :: event type(process_t), allocatable, target :: process type(process_instance_t), allocatable, target :: process_instance type(string_t) :: sample type(string_t), dimension(0) :: empty_string_array integer :: i_prc, iostat write (u, "(A)") "* Test output: event_streams_2" write (u, "(A)") "* Purpose: handle empty event stream array" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%init_fallback_model & (var_str ("SM_hadrons"), var_str ("SM_hadrons.mdl")) call model%init_test () write (u, "(A)") "* Generate test process event" write (u, "(A)") allocate (process) allocate (process_instance) call prepare_test_process (process, process_instance, model, & run_id = var_str ("run_test")) call process_instance%setup_event_data () allocate (event) call event%basic_init () call event%connect (process_instance, process%get_model_ptr ()) call event%generate (1, [0.4_default, 0.4_default]) call event%set_index (42) call event%evaluate_expressions () call event%write (u) write (u, "(A)") write (u, "(A)") "* Allocate raw eio stream and write event to file" write (u, "(A)") sample = "event_streams_2" call es_array%init (sample, [var_str ("raw")], global) call es_array%output (event, 1, 1) call es_array%write (u) call es_array%final () write (u, "(A)") write (u, "(A)") "* Reallocate raw eio stream for reading" write (u, "(A)") sample = "foo" call es_array%init (sample, empty_string_array, global, & input = var_str ("raw"), input_sample = var_str ("event_streams_2")) call es_array%write (u) write (u, "(A)") write (u, "(A)") "* Reread event" write (u, "(A)") call es_array%input_i_prc (i_prc, iostat) write (u, "(1x,A,I0)") "i_prc = ", i_prc write (u, "(A)") call es_array%input_event (event, iostat) call es_array%final () call event%write (u) call global%final () call model%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: event_streams_2" end subroutine event_streams_2 @ %def event_streams_2 @ \subsubsection{Switch in/out} Here we generate an event file and test switching from writing to reading when the file is exhausted. <>= call test (event_streams_3, "event_streams_3", & "switch input/output", & u, results) <>= public :: event_streams_3 <>= subroutine event_streams_3 (u) use processes_ut, only: prepare_test_process integer, intent(in) :: u type(event_stream_array_t) :: es_array type(rt_data_t) :: global type(model_data_t), target :: model type(event_t), allocatable, target :: event type(process_t), allocatable, target :: process type(process_instance_t), allocatable, target :: process_instance type(string_t) :: sample type(string_t), dimension(0) :: empty_string_array integer :: i_prc, iostat write (u, "(A)") "* Test output: event_streams_3" write (u, "(A)") "* Purpose: handle in/out switching" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%init_fallback_model & (var_str ("SM_hadrons"), var_str ("SM_hadrons.mdl")) call model%init_test () write (u, "(A)") "* Generate test process event" write (u, "(A)") allocate (process) allocate (process_instance) call prepare_test_process (process, process_instance, model, & run_id = var_str ("run_test")) call process_instance%setup_event_data () allocate (event) call event%basic_init () call event%connect (process_instance, process%get_model_ptr ()) call event%generate (1, [0.4_default, 0.4_default]) call event%increment_index () call event%evaluate_expressions () write (u, "(A)") "* Allocate raw eio stream and write event to file" write (u, "(A)") sample = "event_streams_3" call es_array%init (sample, [var_str ("raw")], global) call es_array%output (event, 1, 1) call es_array%write (u) call es_array%final () write (u, "(A)") write (u, "(A)") "* Reallocate raw eio stream for reading" write (u, "(A)") call es_array%init (sample, empty_string_array, global, & input = var_str ("raw")) call es_array%write (u) write (u, "(A)") write (u, "(A)") "* Reread event" write (u, "(A)") call es_array%input_i_prc (i_prc, iostat) call es_array%input_event (event, iostat) write (u, "(A)") "* Attempt to read another event (fail), then generate" write (u, "(A)") call es_array%input_i_prc (i_prc, iostat) if (iostat < 0) then call es_array%switch_inout () call event%generate (1, [0.3_default, 0.3_default]) call event%increment_index () call event%evaluate_expressions () call es_array%output (event, 1, 2) end if call es_array%write (u) call es_array%final () write (u, "(A)") call event%write (u) write (u, "(A)") write (u, "(A)") "* Reallocate raw eio stream for reading" write (u, "(A)") call es_array%init (sample, empty_string_array, global, & input = var_str ("raw")) call es_array%write (u) write (u, "(A)") write (u, "(A)") "* Reread two events and display 2nd event" write (u, "(A)") call es_array%input_i_prc (i_prc, iostat) call es_array%input_event (event, iostat) call es_array%input_i_prc (i_prc, iostat) call es_array%input_event (event, iostat) call es_array%final () call event%write (u) call global%final () call model%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: event_streams_3" end subroutine event_streams_3 @ %def event_streams_3 @ \subsubsection{Checksum} Here we generate an event file and repeat twice, once with identical parameters and once with modified parameters. <>= call test (event_streams_4, "event_streams_4", & "check MD5 sum", & u, results) <>= public :: event_streams_4 <>= subroutine event_streams_4 (u) integer, intent(in) :: u type(event_stream_array_t) :: es_array type(rt_data_t) :: global type(process_t), allocatable, target :: process type(string_t) :: sample type(string_t), dimension(0) :: empty_string_array type(event_sample_data_t) :: data write (u, "(A)") "* Test output: event_streams_4" write (u, "(A)") "* Purpose: handle in/out switching" write (u, "(A)") write (u, "(A)") "* Generate test process event" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%init_fallback_model & (var_str ("SM_hadrons"), var_str ("SM_hadrons.mdl")) call global%set_log (var_str ("?check_event_file"), & .true., is_known = .true.) allocate (process) write (u, "(A)") "* Allocate raw eio stream for writing" write (u, "(A)") sample = "event_streams_4" data%md5sum_cfg = "1234567890abcdef1234567890abcdef" call es_array%init (sample, [var_str ("raw")], global, data) call es_array%write (u) call es_array%final () write (u, "(A)") write (u, "(A)") "* Reallocate raw eio stream for reading" write (u, "(A)") call es_array%init (sample, empty_string_array, global, & data, input = var_str ("raw")) call es_array%write (u) call es_array%final () write (u, "(A)") write (u, "(A)") "* Reallocate modified raw eio stream for reading (fail)" write (u, "(A)") data%md5sum_cfg = "1234567890______1234567890______" call es_array%init (sample, empty_string_array, global, & data, input = var_str ("raw")) call es_array%write (u) call es_array%final () write (u, "(A)") write (u, "(A)") "* Repeat ignoring checksum" write (u, "(A)") call global%set_log (var_str ("?check_event_file"), & .false., is_known = .true.) call es_array%init (sample, empty_string_array, global, & data, input = var_str ("raw")) call es_array%write (u) call es_array%final () call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: event_streams_4" end subroutine event_streams_4 @ %def event_streams_4 @ \clearpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Restricted Subprocesses} This module provides an automatic means to construct restricted subprocesses of a current process object. A restricted subprocess has the same initial and final state as the current process, but a restricted set of Feynman graphs. The actual application extracts the set of resonance histories that apply to the process and uses this to construct subprocesses that are restricted to one of those histories, respectively. The resonance histories are derived from the phase-space setup. This implies that the method is tied to the OMega matrix element generator and to the wood phase space method. The processes are collected in a new process library that is generated on-the-fly. The [[resonant_subprocess_t]] object is intended as a component of the event record, which manages all operations regarding resonance handling. The run-time calculations are delegated to an event transform ([[evt_resonance_t]]), as a part of the event transform chain. The transform selects one (or none) of the resonance histories, given the momentum configuration, computes matrix elements and inserts resonances into the particle set. <<[[restricted_subprocesses.f90]]>>= <> module restricted_subprocesses <> <> use diagnostics, only: msg_message, msg_fatal, msg_bug use diagnostics, only: signal_is_pending use io_units, only: given_output_unit use format_defs, only: FMT_14, FMT_19 use string_utils, only: str use lorentz, only: vector4_t use particle_specifiers, only: prt_spec_t use particles, only: particle_set_t use resonances, only: resonance_history_t, resonance_history_set_t use variables, only: var_list_t use models, only: model_t use process_libraries, only: process_component_def_t use process_libraries, only: process_library_t use process_libraries, only: STAT_ACTIVE use prclib_stacks, only: prclib_entry_t use event_transforms, only: evt_t use resonance_insertion, only: evt_resonance_t use rt_data, only: rt_data_t use compilations, only: compile_library use process_configurations, only: process_configuration_t use process, only: process_t, process_ptr_t use instances, only: process_instance_t, process_instance_ptr_t use integrations, only: integrate_process <> <> <> <> <> contains <> end module restricted_subprocesses @ %def restricted_subprocesses @ \subsection{Process configuration} We extend the [[process_configuration_t]] by another method for initialization that takes into account a resonance history. <>= public :: restricted_process_configuration_t <>= type, extends (process_configuration_t) :: restricted_process_configuration_t private contains <> end type restricted_process_configuration_t @ %def restricted_process_configuration_t @ Resonance history as an argument. We use it to override the [[restrictions]] setting in a local variable list. Since we can construct the restricted process only by using OMega, we enforce it as the ME method. Other settings are taken from the variable list. The model will most likely be set, but we insert a safeguard just in case. Also, the resonant subprocess should not itself spawn resonant subprocesses, so we unset [[?resonance_history]]. We have to create a local copy of the model here, via pointer allocation. The reason is that the model as stored (via pointer) in the base type will be finalized and deallocated. The current implementation will generate a LO process, the optional [[nlo_process]] is unset. (It is not obvious whether the construction makes sense beyond LO.) <>= procedure :: init_resonant_process <>= subroutine init_resonant_process & (prc_config, prc_name, prt_in, prt_out, res_history, model, var_list) class(restricted_process_configuration_t), intent(out) :: prc_config type(string_t), intent(in) :: prc_name type(prt_spec_t), dimension(:), intent(in) :: prt_in type(prt_spec_t), dimension(:), intent(in) :: prt_out type(resonance_history_t), intent(in) :: res_history type(model_t), intent(in), target :: model type(var_list_t), intent(in), target :: var_list type(model_t), pointer :: local_model type(var_list_t) :: local_var_list allocate (local_model) call local_model%init_instance (model) call local_var_list%link (var_list) call local_var_list%append_string (var_str ("$model_name"), & sval = local_model%get_name (), & intrinsic=.true.) call local_var_list%append_string (var_str ("$method"), & sval = var_str ("omega"), & intrinsic=.true.) call local_var_list%append_string (var_str ("$restrictions"), & sval = res_history%as_omega_string (size (prt_in)), & intrinsic = .true.) call local_var_list%append_log (var_str ("?resonance_history"), & lval = .false., & intrinsic = .true.) call prc_config%init (prc_name, size (prt_in), 1, & local_model, local_var_list) call prc_config%setup_component (1, & prt_in, prt_out, & local_model, local_var_list) end subroutine init_resonant_process @ %def init_resonant_process @ \subsection{Resonant-subprocess set manager} This data type enables generation of a library of resonant subprocesses for a given master process, and it allows for convenient access. The matrix elements from the subprocesses can be used as channel weights to activate a selector, which then returns a preferred channel via some random number generator. <>= public :: resonant_subprocess_set_t <>= type :: resonant_subprocess_set_t private integer, dimension(:), allocatable :: n_history type(resonance_history_set_t), dimension(:), allocatable :: res_history_set logical :: lib_active = .false. type(string_t) :: libname type(string_t), dimension(:), allocatable :: proc_id type(process_ptr_t), dimension(:), allocatable :: subprocess type(process_instance_ptr_t), dimension(:), allocatable :: instance logical :: filled = .false. type(evt_resonance_t), pointer :: evt => null () contains <> end type resonant_subprocess_set_t @ %def resonant_subprocess_set_t @ Output <>= procedure :: write => resonant_subprocess_set_write <>= subroutine resonant_subprocess_set_write (prc_set, unit, testflag) class(resonant_subprocess_set_t), intent(in) :: prc_set integer, intent(in), optional :: unit logical, intent(in), optional :: testflag logical :: truncate integer :: u, i u = given_output_unit (unit) truncate = .false.; if (present (testflag)) truncate = testflag write (u, "(1x,A)") "Resonant subprocess set:" if (allocated (prc_set%n_history)) then if (any (prc_set%n_history > 0)) then do i = 1, size (prc_set%n_history) if (prc_set%n_history(i) > 0) then write (u, "(1x,A,I0)") "Component #", i call prc_set%res_history_set(i)%write (u, indent=1) end if end do if (prc_set%lib_active) then write (u, "(3x,A,A,A)") "Process library = '", & char (prc_set%libname), "'" else write (u, "(3x,A)") "Process library: [inactive]" end if if (associated (prc_set%evt)) then if (truncate) then write (u, "(3x,A,1x," // FMT_14 // ")") & "Process sqme =", prc_set%get_master_sqme () else write (u, "(3x,A,1x," // FMT_19 // ")") & "Process sqme =", prc_set%get_master_sqme () end if end if if (associated (prc_set%evt)) then write (u, "(3x,A)") "Event transform: associated" write (u, "(2x)", advance="no") call prc_set%evt%write_selector (u, testflag) else write (u, "(3x,A)") "Event transform: not associated" end if else write (u, "(2x,A)") "[empty]" end if else write (u, "(3x,A)") "[not allocated]" end if end subroutine resonant_subprocess_set_write @ %def resonant_subprocess_set_write @ \subsection{Resonance history set} Initialize subprocess set with an array of pre-created resonance history sets. Safeguard: if there are no resonances in the input, initialize the local set as empty, but complete. <>= procedure :: init => resonant_subprocess_set_init procedure :: fill_resonances => resonant_subprocess_set_fill_resonances <>= subroutine resonant_subprocess_set_init (prc_set, n_component) class(resonant_subprocess_set_t), intent(out) :: prc_set integer, intent(in) :: n_component allocate (prc_set%res_history_set (n_component)) allocate (prc_set%n_history (n_component), source = 0) end subroutine resonant_subprocess_set_init subroutine resonant_subprocess_set_fill_resonances (prc_set, & res_history_set, i_component) class(resonant_subprocess_set_t), intent(inout) :: prc_set type(resonance_history_set_t), intent(in) :: res_history_set integer, intent(in) :: i_component prc_set%n_history(i_component) = res_history_set%get_n_history () if (prc_set%n_history(i_component) > 0) then prc_set%res_history_set(i_component) = res_history_set else call prc_set%res_history_set(i_component)%init (initial_size = 0) call prc_set%res_history_set(i_component)%freeze () end if end subroutine resonant_subprocess_set_fill_resonances @ %def resonant_subprocess_set_init @ %def resonant_subprocess_set_fill_resonances @ Return the resonance history set. <>= procedure :: get_resonance_history_set & => resonant_subprocess_set_get_resonance_history_set <>= function resonant_subprocess_set_get_resonance_history_set (prc_set) & result (res_history_set) class(resonant_subprocess_set_t), intent(in) :: prc_set type(resonance_history_set_t), dimension(:), allocatable :: res_history_set res_history_set = prc_set%res_history_set end function resonant_subprocess_set_get_resonance_history_set @ %def resonant_subprocess_set_get_resonance_history_set @ \subsection{Library for the resonance history set} The recommended library name: append [[_R]] to the process name. <>= public :: get_libname_res <>= elemental function get_libname_res (proc_id) result (libname) type(string_t), intent(in) :: proc_id type(string_t) :: libname libname = proc_id // "_R" end function get_libname_res @ %def get_libname_res @ Here we scan the global process library whether any processes require resonant subprocesses to be constructed. If yes, create process objects with phase space and construct the process libraries as usual. Then append the library names to the array. The temporary integration objects should carry the [[phs_only]] flag. We set this in the local environment. Once a process object with resonance histories (derived from phase space) has been created, we extract the resonance histories and use them, together with the process definition, to create the new library. Finally, compile the library. <>= public :: spawn_resonant_subprocess_libraries <>= subroutine spawn_resonant_subprocess_libraries & (libname, local, global, libname_res) type(string_t), intent(in) :: libname type(rt_data_t), intent(inout), target :: local type(rt_data_t), intent(inout), target :: global type(string_t), dimension(:), allocatable, intent(inout) :: libname_res type(process_library_t), pointer :: lib type(string_t), dimension(:), allocatable :: process_id_res type(process_t), pointer :: process type(resonance_history_set_t) :: res_history_set type(process_component_def_t), pointer :: process_component_def logical :: phs_only_saved, exist integer :: i_proc, i_component lib => global%prclib_stack%get_library_ptr (libname) call lib%get_process_id_req_resonant (process_id_res) if (size (process_id_res) > 0) then call msg_message ("Creating resonant-subprocess libraries & &for library '" // char (libname) // "'") libname_res = get_libname_res (process_id_res) phs_only_saved = local%var_list%get_lval (var_str ("?phs_only")) call local%var_list%set_log & (var_str ("?phs_only"), .true., is_known=.true.) do i_proc = 1, size (process_id_res) associate (proc_id => process_id_res (i_proc)) call msg_message ("Process '" // char (proc_id) // "': & &constructing phase space for resonance structure") call integrate_process (proc_id, local, global) process => global%process_stack%get_process_ptr (proc_id) call create_library (libname_res(i_proc), global, exist) if (.not. exist) then do i_component = 1, process%get_n_components () call process%extract_resonance_history_set & (res_history_set, i_component = i_component) process_component_def & => process%get_component_def_ptr (i_component) call add_to_library (libname_res(i_proc), & res_history_set, & process_component_def%get_prt_spec_in (), & process_component_def%get_prt_spec_out (), & global) end do call msg_message ("Process library '" & // char (libname_res(i_proc)) & // "': created") end if call global%update_prclib (lib) end associate end do call local%var_list%set_log & (var_str ("?phs_only"), phs_only_saved, is_known=.true.) end if end subroutine spawn_resonant_subprocess_libraries @ %def spawn_resonant_subprocess_libraries @ This is another version of the library constructor, bound to a restricted-subprocess set object. Create the appropriate process library, add processes, and close the library. <>= procedure :: create_library => resonant_subprocess_set_create_library procedure :: add_to_library => resonant_subprocess_set_add_to_library procedure :: freeze_library => resonant_subprocess_set_freeze_library <>= subroutine resonant_subprocess_set_create_library (prc_set, & libname, global, exist) class(resonant_subprocess_set_t), intent(inout) :: prc_set type(string_t), intent(in) :: libname type(rt_data_t), intent(inout), target :: global logical, intent(out) :: exist prc_set%libname = libname call create_library (prc_set%libname, global, exist) end subroutine resonant_subprocess_set_create_library subroutine resonant_subprocess_set_add_to_library (prc_set, & i_component, prt_in, prt_out, global) class(resonant_subprocess_set_t), intent(inout) :: prc_set integer, intent(in) :: i_component type(prt_spec_t), dimension(:), intent(in) :: prt_in type(prt_spec_t), dimension(:), intent(in) :: prt_out type(rt_data_t), intent(inout), target :: global call add_to_library (prc_set%libname, & prc_set%res_history_set(i_component), & prt_in, prt_out, global) end subroutine resonant_subprocess_set_add_to_library subroutine resonant_subprocess_set_freeze_library (prc_set, global) class(resonant_subprocess_set_t), intent(inout) :: prc_set type(rt_data_t), intent(inout), target :: global type(prclib_entry_t), pointer :: lib_entry type(process_library_t), pointer :: lib lib => global%prclib_stack%get_library_ptr (prc_set%libname) call lib%get_process_id_list (prc_set%proc_id) prc_set%lib_active = .true. end subroutine resonant_subprocess_set_freeze_library @ %def resonant_subprocess_set_create_library @ %def resonant_subprocess_set_add_to_library @ %def resonant_subprocess_set_freeze_library @ The common parts of the procedures above: (i) create a new process library or recover it, (ii) for each history, create a process configuration and record it. <>= subroutine create_library (libname, global, exist) type(string_t), intent(in) :: libname type(rt_data_t), intent(inout), target :: global logical, intent(out) :: exist type(prclib_entry_t), pointer :: lib_entry type(process_library_t), pointer :: lib type(resonance_history_t) :: res_history type(string_t), dimension(:), allocatable :: proc_id type(restricted_process_configuration_t) :: prc_config integer :: i lib => global%prclib_stack%get_library_ptr (libname) exist = associated (lib) if (.not. exist) then call msg_message ("Creating library for resonant subprocesses '" & // char (libname) // "'") allocate (lib_entry) call lib_entry%init (libname) lib => lib_entry%process_library_t call global%add_prclib (lib_entry) else call msg_message ("Using library for resonant subprocesses '" & // char (libname) // "'") call global%update_prclib (lib) end if end subroutine create_library subroutine add_to_library (libname, res_history_set, prt_in, prt_out, global) type(string_t), intent(in) :: libname type(resonance_history_set_t), intent(in) :: res_history_set type(prt_spec_t), dimension(:), intent(in) :: prt_in type(prt_spec_t), dimension(:), intent(in) :: prt_out type(rt_data_t), intent(inout), target :: global type(prclib_entry_t), pointer :: lib_entry type(process_library_t), pointer :: lib type(resonance_history_t) :: res_history type(string_t), dimension(:), allocatable :: proc_id type(restricted_process_configuration_t) :: prc_config integer :: n0, i lib => global%prclib_stack%get_library_ptr (libname) if (associated (lib)) then n0 = lib%get_n_processes () allocate (proc_id (res_history_set%get_n_history ())) do i = 1, size (proc_id) proc_id(i) = libname // str (n0 + i) res_history = res_history_set%get_history(i) call prc_config%init_resonant_process (proc_id(i), & prt_in, prt_out, & res_history, & global%model, global%var_list) call msg_message ("Resonant subprocess #" & // char (str(n0+i)) // ": " & // char (res_history%as_omega_string (size (prt_in)))) call prc_config%record (global) if (signal_is_pending ()) return end do else call msg_bug ("Adding subprocesses: library '" & // char (libname) // "' not found") end if end subroutine add_to_library @ %def create_library @ %def add_to_library @ Compile the generated library, required settings taken from the [[global]] data set. <>= procedure :: compile_library => resonant_subprocess_set_compile_library <>= subroutine resonant_subprocess_set_compile_library (prc_set, global) class(resonant_subprocess_set_t), intent(in) :: prc_set type(rt_data_t), intent(inout), target :: global type(process_library_t), pointer :: lib lib => global%prclib_stack%get_library_ptr (prc_set%libname) if (lib%get_status () < STAT_ACTIVE) then call compile_library (prc_set%libname, global) end if end subroutine resonant_subprocess_set_compile_library @ %def resonant_subprocess_set_compile_library @ Check if the library has been created / the process has been evaluated. <>= procedure :: is_active => resonant_subprocess_set_is_active <>= function resonant_subprocess_set_is_active (prc_set) result (flag) class(resonant_subprocess_set_t), intent(in) :: prc_set logical :: flag flag = prc_set%lib_active end function resonant_subprocess_set_is_active @ %def resonant_subprocess_set_is_active @ Return number of generated process objects, library, and process IDs. <>= procedure :: get_n_process => resonant_subprocess_set_get_n_process procedure :: get_libname => resonant_subprocess_set_get_libname procedure :: get_proc_id => resonant_subprocess_set_get_proc_id <>= function resonant_subprocess_set_get_n_process (prc_set) result (n) class(resonant_subprocess_set_t), intent(in) :: prc_set integer :: n if (prc_set%lib_active) then n = size (prc_set%proc_id) else n = 0 end if end function resonant_subprocess_set_get_n_process function resonant_subprocess_set_get_libname (prc_set) result (libname) class(resonant_subprocess_set_t), intent(in) :: prc_set type(string_t) :: libname if (prc_set%lib_active) then libname = prc_set%libname else libname = "" end if end function resonant_subprocess_set_get_libname function resonant_subprocess_set_get_proc_id (prc_set, i) result (proc_id) class(resonant_subprocess_set_t), intent(in) :: prc_set integer, intent(in) :: i type(string_t) :: proc_id if (allocated (prc_set%proc_id)) then proc_id = prc_set%proc_id(i) else proc_id = "" end if end function resonant_subprocess_set_get_proc_id @ %def resonant_subprocess_set_get_n_process @ %def resonant_subprocess_set_get_libname @ %def resonant_subprocess_set_get_proc_id @ \subsection{Process objects and instances} Prepare process objects for all entries in the resonant-subprocesses library. The process objects are appended to the global process stack. A local environment can be used where we place temporary variable settings that affect process-object generation. We initialize the processes, such that we can evaluate matrix elements, but we do not need to integrate them. The internal procedure [[prepare_process]] is an abridged version of the procedure with this name in the [[simulations]] module. <>= procedure :: prepare_process_objects & => resonant_subprocess_set_prepare_process_objects <>= subroutine resonant_subprocess_set_prepare_process_objects & (prc_set, local, global) class(resonant_subprocess_set_t), intent(inout) :: prc_set type(rt_data_t), intent(inout), target :: local type(rt_data_t), intent(inout), optional, target :: global type(rt_data_t), pointer :: current type(process_library_t), pointer :: lib type(string_t) :: proc_id, libname_cur, libname_res integer :: i, n if (.not. prc_set%is_active ()) return if (present (global)) then current => global else current => local end if libname_cur = current%prclib%get_name () libname_res = prc_set%get_libname () lib => current%prclib_stack%get_library_ptr (libname_res) if (associated (lib)) call current%update_prclib (lib) call local%set_string (var_str ("$phs_method"), & var_str ("none"), is_known = .true.) call local%set_string (var_str ("$integration_method"), & var_str ("none"), is_known = .true.) n = prc_set%get_n_process () allocate (prc_set%subprocess (n)) do i = 1, n proc_id = prc_set%get_proc_id (i) call prepare_process (prc_set%subprocess(i)%p, proc_id) if (signal_is_pending ()) return end do lib => current%prclib_stack%get_library_ptr (libname_cur) if (associated (lib)) call current%update_prclib (lib) contains subroutine prepare_process (process, process_id) type(process_t), pointer, intent(out) :: process type(string_t), intent(in) :: process_id call msg_message ("Simulate: initializing resonant subprocess '" & // char (process_id) // "'") if (present (global)) then call integrate_process (process_id, local, global, & init_only = .true.) else call integrate_process (process_id, local, local_stack = .true., & init_only = .true.) end if process => current%process_stack%get_process_ptr (process_id) if (.not. associated (process)) then call msg_fatal ("Simulate: resonant subprocess '" & // char (process_id) // "' could not be initialized: aborting") end if end subroutine prepare_process end subroutine resonant_subprocess_set_prepare_process_objects @ %def resonant_subprocess_set_prepare_process_objects @ Workspace for the resonant subprocesses. <>= procedure :: prepare_process_instances & => resonant_subprocess_set_prepare_process_instances <>= subroutine resonant_subprocess_set_prepare_process_instances (prc_set, global) class(resonant_subprocess_set_t), intent(inout) :: prc_set type(rt_data_t), intent(in), target :: global integer :: i, n if (.not. prc_set%is_active ()) return n = size (prc_set%subprocess) allocate (prc_set%instance (n)) do i = 1, n allocate (prc_set%instance(i)%p) call prc_set%instance(i)%p%init (prc_set%subprocess(i)%p) call prc_set%instance(i)%p%setup_event_data (global%model) end do end subroutine resonant_subprocess_set_prepare_process_instances @ %def resonant_subprocess_set_prepare_process_instances @ \subsection{Event transform connection} The idea is that the resonance-insertion event transform has been allocated somewhere (namely, in the standard event-transform chain), but we maintain a link such that we can inject matrix-element results event by event. The event transform holds a selector, to choose one of the resonance histories (or none), and it manages resonance insertion for the particle set. The data that the event transform requires can be provided here. The resonance history set has already been assigned with the [[dispatch]] initializer. Here, we supply the set of subprocess instances that we have generated (see above). The master-process instance is set when we [[connect]] the transform by the standard method. <>= procedure :: connect_transform => & resonant_subprocess_set_connect_transform <>= subroutine resonant_subprocess_set_connect_transform (prc_set, evt) class(resonant_subprocess_set_t), intent(inout) :: prc_set class(evt_t), intent(in), target :: evt select type (evt) type is (evt_resonance_t) prc_set%evt => evt call prc_set%evt%set_subprocess_instances (prc_set%instance) class default call msg_bug ("Resonant subprocess set: event transform has wrong type") end select end subroutine resonant_subprocess_set_connect_transform @ %def resonant_subprocess_set_connect_transform @ Set the on-shell limit value in the connected transform. <>= procedure :: set_on_shell_limit => resonant_subprocess_set_on_shell_limit <>= subroutine resonant_subprocess_set_on_shell_limit (prc_set, on_shell_limit) class(resonant_subprocess_set_t), intent(inout) :: prc_set real(default), intent(in) :: on_shell_limit call prc_set%evt%set_on_shell_limit (on_shell_limit) end subroutine resonant_subprocess_set_on_shell_limit @ %def resonant_subprocess_set_on_shell_limit @ Set the Gaussian turnoff parameter in the connected transform. <>= procedure :: set_on_shell_turnoff => resonant_subprocess_set_on_shell_turnoff <>= subroutine resonant_subprocess_set_on_shell_turnoff & (prc_set, on_shell_turnoff) class(resonant_subprocess_set_t), intent(inout) :: prc_set real(default), intent(in) :: on_shell_turnoff call prc_set%evt%set_on_shell_turnoff (on_shell_turnoff) end subroutine resonant_subprocess_set_on_shell_turnoff @ %def resonant_subprocess_set_on_shell_turnoff @ Reweight (suppress) the background contribution probability, for the kinematics where a resonance history is active. <>= procedure :: set_background_factor & => resonant_subprocess_set_background_factor <>= subroutine resonant_subprocess_set_background_factor & (prc_set, background_factor) class(resonant_subprocess_set_t), intent(inout) :: prc_set real(default), intent(in) :: background_factor call prc_set%evt%set_background_factor (background_factor) end subroutine resonant_subprocess_set_background_factor @ %def resonant_subprocess_set_background_factor @ \subsection{Wrappers for runtime calculations} All runtime calculations are delegated to the event transform. The following procedures are essentially redundant wrappers. We retain them for a unit test below. Debugging aid: <>= procedure :: dump_instances => resonant_subprocess_set_dump_instances <>= subroutine resonant_subprocess_set_dump_instances (prc_set, unit, testflag) class(resonant_subprocess_set_t), intent(inout) :: prc_set integer, intent(in), optional :: unit logical, intent(in), optional :: testflag integer :: i, n, u u = given_output_unit (unit) write (u, "(A)") "*** Process instances of resonant subprocesses" write (u, *) n = size (prc_set%subprocess) do i = 1, n associate (instance => prc_set%instance(i)%p) call instance%write (u, testflag) write (u, *) write (u, *) end associate end do end subroutine resonant_subprocess_set_dump_instances @ %def resonant_subprocess_set_dump_instances @ Inject the current kinematics configuration, reading from the previous event transform or from the process instance. <>= procedure :: fill_momenta => resonant_subprocess_set_fill_momenta <>= subroutine resonant_subprocess_set_fill_momenta (prc_set) class(resonant_subprocess_set_t), intent(inout) :: prc_set integer :: i, n call prc_set%evt%fill_momenta () end subroutine resonant_subprocess_set_fill_momenta @ %def resonant_subprocess_set_fill_momenta @ Determine the indices of the resonance histories that can be considered on-shell for the current kinematics. <>= procedure :: determine_on_shell_histories & => resonant_subprocess_set_determine_on_shell_histories <>= subroutine resonant_subprocess_set_determine_on_shell_histories & (prc_set, i_component, index_array) class(resonant_subprocess_set_t), intent(in) :: prc_set integer, intent(in) :: i_component integer, dimension(:), allocatable, intent(out) :: index_array call prc_set%evt%determine_on_shell_histories (index_array) end subroutine resonant_subprocess_set_determine_on_shell_histories @ %def resonant_subprocess_set_determine_on_shell_histories @ Evaluate selected subprocesses. (In actual operation, the ones that have been tagged as on-shell.) <>= procedure :: evaluate_subprocess & => resonant_subprocess_set_evaluate_subprocess <>= subroutine resonant_subprocess_set_evaluate_subprocess (prc_set, index_array) class(resonant_subprocess_set_t), intent(inout) :: prc_set integer, dimension(:), intent(in) :: index_array call prc_set%evt%evaluate_subprocess (index_array) end subroutine resonant_subprocess_set_evaluate_subprocess @ %def resonant_subprocess_set_evaluate_subprocess @ Extract the matrix elements of the master process / the resonant subprocesses. After the previous routine has been executed, they should be available and stored in the corresponding process instances. <>= procedure :: get_master_sqme & => resonant_subprocess_set_get_master_sqme procedure :: get_subprocess_sqme & => resonant_subprocess_set_get_subprocess_sqme <>= function resonant_subprocess_set_get_master_sqme (prc_set) result (sqme) class(resonant_subprocess_set_t), intent(in) :: prc_set real(default) :: sqme sqme = prc_set%evt%get_master_sqme () end function resonant_subprocess_set_get_master_sqme subroutine resonant_subprocess_set_get_subprocess_sqme (prc_set, sqme) class(resonant_subprocess_set_t), intent(in) :: prc_set real(default), dimension(:), intent(inout) :: sqme integer :: i call prc_set%evt%get_subprocess_sqme (sqme) end subroutine resonant_subprocess_set_get_subprocess_sqme @ %def resonant_subprocess_set_get_master_sqme @ %def resonant_subprocess_set_get_subprocess_sqme @ We use the calculations of resonant matrix elements to determine probabilities for all resonance configurations. <>= procedure :: compute_probabilities & => resonant_subprocess_set_compute_probabilities <>= subroutine resonant_subprocess_set_compute_probabilities (prc_set, prob_array) class(resonant_subprocess_set_t), intent(inout) :: prc_set real(default), dimension(:), allocatable, intent(out) :: prob_array integer, dimension(:), allocatable :: index_array real(default) :: sqme, sqme_sum, sqme_bg real(default), dimension(:), allocatable :: sqme_res integer :: n n = size (prc_set%subprocess) allocate (prob_array (0:n), source = 0._default) call prc_set%evt%compute_probabilities () call prc_set%evt%get_selector_weights (prob_array) end subroutine resonant_subprocess_set_compute_probabilities @ %def resonant_subprocess_set_compute_probabilities @ \subsection{Unit tests} Test module, followed by the stand-alone unit-test procedures. <<[[restricted_subprocesses_ut.f90]]>>= <> module restricted_subprocesses_ut use unit_tests use restricted_subprocesses_uti <> <> contains <> end module restricted_subprocesses_ut @ %def restricted_subprocesses_ut @ <<[[restricted_subprocesses_uti.f90]]>>= <> module restricted_subprocesses_uti <> <> use io_units, only: free_unit use format_defs, only: FMT_10, FMT_12 use lorentz, only: vector4_t, vector3_moving, vector4_moving use particle_specifiers, only: new_prt_spec use process_libraries, only: process_library_t use resonances, only: resonance_info_t use resonances, only: resonance_history_t use resonances, only: resonance_history_set_t use state_matrices, only: FM_IGNORE_HELICITY use particles, only: particle_set_t use model_data, only: model_data_t use models, only: syntax_model_file_init, syntax_model_file_final use models, only: model_t use rng_base_ut, only: rng_test_factory_t use mci_base, only: mci_t use mci_none, only: mci_none_t use phs_base, only: phs_config_t use phs_forests, only: syntax_phs_forest_init, syntax_phs_forest_final use phs_wood, only: phs_wood_config_t use process_libraries, only: process_def_entry_t use process_libraries, only: process_component_def_t use prclib_stacks, only: prclib_entry_t use prc_core_def, only: prc_core_def_t use prc_omega, only: omega_def_t use process, only: process_t use instances, only: process_instance_t use process_stacks, only: process_entry_t use event_transforms, only: evt_trivial_t use resonance_insertion, only: evt_resonance_t use integrations, only: integrate_process use rt_data, only: rt_data_t use restricted_subprocesses <> <> <> <> contains <> <> end module restricted_subprocesses_uti @ %def restricted_subprocesses_uti @ API: driver for the unit tests below. <>= public :: restricted_subprocesses_test <>= subroutine restricted_subprocesses_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine restricted_subprocesses_test @ %def restricted_subprocesses_test @ \subsubsection{subprocess configuration} Initialize a [[restricted_subprocess_configuration_t]] object which represents a given process with a defined resonance history. <>= call test (restricted_subprocesses_1, "restricted_subprocesses_1", & "single subprocess", & u, results) <>= public :: restricted_subprocesses_1 <>= subroutine restricted_subprocesses_1 (u) integer, intent(in) :: u type(rt_data_t) :: global type(resonance_info_t) :: res_info type(resonance_history_t) :: res_history type(string_t) :: prc_name type(string_t), dimension(2) :: prt_in type(string_t), dimension(3) :: prt_out type(restricted_process_configuration_t) :: prc_config write (u, "(A)") "* Test output: restricted_subprocesses_1" write (u, "(A)") "* Purpose: create subprocess list from resonances" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%select_model (var_str ("SM")) write (u, "(A)") "* Create resonance history" write (u, "(A)") call res_info%init (3, -24, global%model, 5) call res_history%add_resonance (res_info) call res_history%write (u) write (u, "(A)") write (u, "(A)") "* Create process configuration" write (u, "(A)") prc_name = "restricted_subprocesses_1_p" prt_in(1) = "e-" prt_in(2) = "e+" prt_out(1) = "d" prt_out(2) = "u" prt_out(3) = "W+" call prc_config%init_resonant_process (prc_name, & new_prt_spec (prt_in), new_prt_spec (prt_out), & res_history, global%model, global%var_list) call prc_config%write (u) write (u, *) write (u, "(A)") "* Cleanup" call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: restricted_subprocesses_1" end subroutine restricted_subprocesses_1 @ %def restricted_subprocesses_1 @ \subsubsection{Subprocess library configuration} Create a process library that represents restricted subprocesses for a given set of resonance histories <>= call test (restricted_subprocesses_2, "restricted_subprocesses_2", & "subprocess library", & u, results) <>= public :: restricted_subprocesses_2 <>= subroutine restricted_subprocesses_2 (u) integer, intent(in) :: u type(rt_data_t), target :: global type(resonance_info_t) :: res_info type(resonance_history_t), dimension(2) :: res_history type(resonance_history_set_t) :: res_history_set type(string_t) :: libname type(string_t), dimension(2) :: prt_in type(string_t), dimension(3) :: prt_out type(resonant_subprocess_set_t) :: prc_set type(process_library_t), pointer :: lib logical :: exist write (u, "(A)") "* Test output: restricted_subprocesses_2" write (u, "(A)") "* Purpose: create subprocess library from resonances" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%select_model (var_str ("SM")) write (u, "(A)") "* Create resonance histories" write (u, "(A)") call res_info%init (3, -24, global%model, 5) call res_history(1)%add_resonance (res_info) call res_history(1)%write (u) call res_info%init (7, 23, global%model, 5) call res_history(2)%add_resonance (res_info) call res_history(2)%write (u) call res_history_set%init () call res_history_set%enter (res_history(1)) call res_history_set%enter (res_history(2)) call res_history_set%freeze () write (u, "(A)") write (u, "(A)") "* Empty restricted subprocess set" write (u, "(A)") write (u, "(A,1x,L1)") "active =", prc_set%is_active () write (u, "(A)") call prc_set%write (u, testflag=.true.) write (u, "(A)") write (u, "(A)") "* Fill restricted subprocess set" write (u, "(A)") libname = "restricted_subprocesses_2_p_R" prt_in(1) = "e-" prt_in(2) = "e+" prt_out(1) = "d" prt_out(2) = "u" prt_out(3) = "W+" call prc_set%init (1) call prc_set%fill_resonances (res_history_set, 1) call prc_set%create_library (libname, global, exist) if (.not. exist) then call prc_set%add_to_library (1, & new_prt_spec (prt_in), new_prt_spec (prt_out), & global) end if call prc_set%freeze_library (global) write (u, "(A,1x,L1)") "active =", prc_set%is_active () write (u, "(A)") call prc_set%write (u, testflag=.true.) write (u, "(A)") write (u, "(A)") "* Queries" write (u, "(A)") write (u, "(A,1x,I0)") "n_process =", prc_set%get_n_process () write (u, "(A)") write (u, "(A,A,A)") "libname = '", char (prc_set%get_libname ()), "'" write (u, "(A)") write (u, "(A,A,A)") "proc_id(1) = '", char (prc_set%get_proc_id (1)), "'" write (u, "(A,A,A)") "proc_id(2) = '", char (prc_set%get_proc_id (2)), "'" write (u, "(A)") write (u, "(A)") "* Process library" write (u, "(A)") call prc_set%compile_library (global) lib => global%prclib_stack%get_library_ptr (libname) if (associated (lib)) call lib%write (u, libpath=.false.) write (u, *) write (u, "(A)") "* Cleanup" call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: restricted_subprocesses_2" end subroutine restricted_subprocesses_2 @ %def restricted_subprocesses_2 @ \subsubsection{Auxiliary: Test processes} Auxiliary subroutine that constructs the process library for the above test. This parallels a similar subroutine in [[processes_uti]], but this time we want an \oMega\ process. <>= public :: prepare_resonance_test_library <>= subroutine prepare_resonance_test_library & (lib, libname, procname, model, global, u) type(process_library_t), target, intent(out) :: lib type(string_t), intent(in) :: libname type(string_t), intent(in) :: procname class(model_data_t), intent(in), pointer :: model type(rt_data_t), intent(in), target :: global integer, intent(in) :: u type(string_t), dimension(:), allocatable :: prt_in, prt_out class(prc_core_def_t), allocatable :: def type(process_def_entry_t), pointer :: entry call lib%init (libname) allocate (prt_in (2), prt_out (3)) prt_in = [var_str ("e+"), var_str ("e-")] prt_out = [var_str ("d"), var_str ("ubar"), var_str ("W+")] allocate (omega_def_t :: def) select type (def) type is (omega_def_t) call def%init (model%get_name (), prt_in, prt_out, & ovm=.false., ufo=.false.) end select allocate (entry) call entry%init (procname, & model_name = model%get_name (), & n_in = 2, n_components = 1, & requires_resonances = .true.) call entry%import_component (1, n_out = size (prt_out), & prt_in = new_prt_spec (prt_in), & prt_out = new_prt_spec (prt_out), & method = var_str ("omega"), & variant = def) call entry%write (u) call lib%append (entry) call lib%configure (global%os_data) call lib%write_makefile (global%os_data, force = .true., verbose = .false.) call lib%clean (global%os_data, distclean = .false.) call lib%write_driver (force = .true.) call lib%load (global%os_data) end subroutine prepare_resonance_test_library @ %def prepare_resonance_test_library @ \subsubsection{Kinematics and resonance selection} Prepare an actual process with resonant subprocesses. Insert kinematics and apply the resonance selector in an associated event transform. <>= call test (restricted_subprocesses_3, "restricted_subprocesses_3", & "resonance kinematics and probability", & u, results) <>= public :: restricted_subprocesses_3 <>= subroutine restricted_subprocesses_3 (u) integer, intent(in) :: u type(rt_data_t), target :: global class(model_t), pointer :: model class(model_data_t), pointer :: model_data type(string_t) :: libname, libname_res type(string_t) :: procname type(process_component_def_t), pointer :: process_component_def type(prclib_entry_t), pointer :: lib_entry type(process_library_t), pointer :: lib logical :: exist type(process_t), pointer :: process type(process_instance_t), target :: process_instance type(resonance_history_set_t), dimension(1) :: res_history_set type(resonant_subprocess_set_t) :: prc_set type(particle_set_t) :: pset real(default) :: sqrts, mw, pp real(default), dimension(3) :: p3 type(vector4_t), dimension(:), allocatable :: p real(default), dimension(:), allocatable :: m integer, dimension(:), allocatable :: pdg real(default), dimension(:), allocatable :: sqme logical, dimension(:), allocatable :: mask real(default) :: on_shell_limit integer, dimension(:), allocatable :: i_array real(default), dimension(:), allocatable :: prob_array type(evt_resonance_t), target :: evt_resonance integer :: i, u_dump write (u, "(A)") "* Test output: restricted_subprocesses_3" write (u, "(A)") "* Purpose: handle process and resonance kinematics" write (u, "(A)") call syntax_model_file_init () call syntax_phs_forest_init () call global%global_init () call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%set_log (var_str ("?resonance_history"), & .true., is_known = .true.) call global%select_model (var_str ("SM")) allocate (model) call model%init_instance (global%model) model_data => model libname = "restricted_subprocesses_3_lib" libname_res = "restricted_subprocesses_3_lib_res" procname = "restricted_subprocesses_3_p" write (u, "(A)") "* Initialize process library and process" write (u, "(A)") allocate (lib_entry) call lib_entry%init (libname) lib => lib_entry%process_library_t call global%add_prclib (lib_entry) call prepare_resonance_test_library & (lib, libname, procname, model_data, global, u) call integrate_process (procname, global, & local_stack = .true., init_only = .true.) process => global%process_stack%get_process_ptr (procname) call process_instance%init (process) call process_instance%setup_event_data () write (u, "(A)") write (u, "(A)") "* Extract resonance history set" write (u, "(A)") call process%extract_resonance_history_set & (res_history_set(1), include_trivial=.true., i_component=1) call res_history_set(1)%write (u) write (u, "(A)") write (u, "(A)") "* Build resonant-subprocess library" write (u, "(A)") call prc_set%init (1) call prc_set%fill_resonances (res_history_set(1), 1) process_component_def => process%get_component_def_ptr (1) call prc_set%create_library (libname_res, global, exist) if (.not. exist) then call prc_set%add_to_library (1, & process_component_def%get_prt_spec_in (), & process_component_def%get_prt_spec_out (), & global) end if call prc_set%freeze_library (global) call prc_set%compile_library (global) call prc_set%write (u, testflag=.true.) write (u, "(A)") write (u, "(A)") "* Build particle set" write (u, "(A)") sqrts = global%get_rval (var_str ("sqrts")) mw = 80._default ! deliberately slightly different from true mw pp = sqrt (sqrts**2 - 4 * mw**2) / 2 allocate (pdg (5), p (5), m (5)) pdg(1) = -11 p(1) = vector4_moving (sqrts/2, sqrts/2, 3) m(1) = 0 pdg(2) = 11 p(2) = vector4_moving (sqrts/2,-sqrts/2, 3) m(2) = 0 pdg(3) = 1 p3(1) = pp/2 p3(2) = mw/2 p3(3) = 0 p(3) = vector4_moving (sqrts/4, vector3_moving (p3)) m(3) = 0 p3(2) = -mw/2 pdg(4) = -2 p(4) = vector4_moving (sqrts/4, vector3_moving (p3)) m(4) = 0 pdg(5) = 24 p(5) = vector4_moving (sqrts/2,-pp, 1) m(5) = mw call pset%init_direct (0, 2, 0, 0, 3, pdg, model) call pset%set_momentum (p, m**2) call pset%write (u, testflag=.true.) write (u, "(A)") write (u, "(A)") "* Fill process instance" ! workflow from event_recalculate call process_instance%choose_mci (1) call process_instance%set_trace (pset, 1) call process_instance%recover & (1, 1, update_sqme=.true., recover_phs=.false.) call process_instance%evaluate_event_data (weight = 1._default) write (u, "(A)") write (u, "(A)") "* Prepare resonant subprocesses" call prc_set%prepare_process_objects (global) call prc_set%prepare_process_instances (global) call evt_resonance%set_resonance_data (res_history_set) call evt_resonance%select_component (1) call prc_set%connect_transform (evt_resonance) call evt_resonance%connect (process_instance, model) call prc_set%fill_momenta () write (u, "(A)") write (u, "(A)") "* Show squared matrix element of master process," write (u, "(A)") " should coincide with 2nd subprocess sqme" write (u, "(A)") write (u, "(1x,I0,1x," // FMT_12 // ")") 0, prc_set%get_master_sqme () write (u, "(A)") write (u, "(A)") "* Compute squared matrix elements & &of selected resonant subprocesses [1,2]" write (u, "(A)") call prc_set%evaluate_subprocess ([1,2]) allocate (sqme (3), source = 0._default) call prc_set%get_subprocess_sqme (sqme) do i = 1, size (sqme) write (u, "(1x,I0,1x," // FMT_12 // ")") i, sqme(i) end do deallocate (sqme) write (u, "(A)") write (u, "(A)") "* Compute squared matrix elements & &of all resonant subprocesses" write (u, "(A)") call prc_set%evaluate_subprocess ([1,2,3]) allocate (sqme (3), source = 0._default) call prc_set%get_subprocess_sqme (sqme) do i = 1, size (sqme) write (u, "(1x,I0,1x," // FMT_12 // ")") i, sqme(i) end do deallocate (sqme) write (u, "(A)") write (u, "(A)") "* Write process instances to file & &restricted_subprocesses_3_lib_res.dat" u_dump = free_unit () open (unit = u_dump, file = "restricted_subprocesses_3_lib_res.dat", & action = "write", status = "replace") call prc_set%dump_instances (u_dump) close (u_dump) write (u, "(A)") write (u, "(A)") "* Determine on-shell resonant subprocesses" write (u, "(A)") on_shell_limit = 0 write (u, "(1x,A,1x," // FMT_10 // ")") "on_shell_limit =", on_shell_limit call prc_set%set_on_shell_limit (on_shell_limit) call prc_set%determine_on_shell_histories (1, i_array) write (u, "(1x,A,9(1x,I0))") "resonant =", i_array on_shell_limit = 0.1_default write (u, "(1x,A,1x," // FMT_10 // ")") "on_shell_limit =", on_shell_limit call prc_set%set_on_shell_limit (on_shell_limit) call prc_set%determine_on_shell_histories (1, i_array) write (u, "(1x,A,9(1x,I0))") "resonant =", i_array on_shell_limit = 10._default write (u, "(1x,A,1x," // FMT_10 // ")") "on_shell_limit =", on_shell_limit call prc_set%set_on_shell_limit (on_shell_limit) call prc_set%determine_on_shell_histories (1, i_array) write (u, "(1x,A,9(1x,I0))") "resonant =", i_array on_shell_limit = 10000._default write (u, "(1x,A,1x," // FMT_10 // ")") "on_shell_limit =", on_shell_limit call prc_set%set_on_shell_limit (on_shell_limit) call prc_set%determine_on_shell_histories (1, i_array) write (u, "(1x,A,9(1x,I0))") "resonant =", i_array write (u, "(A)") write (u, "(A)") "* Compute probabilities for applicable resonances" write (u, "(A)") " and initialize the process selector" write (u, "(A)") " (The first number is the probability for background)" write (u, "(A)") on_shell_limit = 0 write (u, "(1x,A,1x," // FMT_10 // ")") "on_shell_limit =", on_shell_limit call prc_set%set_on_shell_limit (on_shell_limit) call prc_set%determine_on_shell_histories (1, i_array) call prc_set%compute_probabilities (prob_array) write (u, "(1x,A,9(1x,"// FMT_12 // "))") "resonant =", prob_array call prc_set%write (u, testflag=.true.) write (u, *) on_shell_limit = 10._default write (u, "(1x,A,1x," // FMT_10 // ")") "on_shell_limit =", on_shell_limit call prc_set%set_on_shell_limit (on_shell_limit) call prc_set%determine_on_shell_histories (1, i_array) call prc_set%compute_probabilities (prob_array) write (u, "(1x,A,9(1x,"// FMT_12 // "))") "resonant =", prob_array call prc_set%write (u, testflag=.true.) write (u, *) on_shell_limit = 10000._default write (u, "(1x,A,1x," // FMT_10 // ")") "on_shell_limit =", on_shell_limit call prc_set%set_on_shell_limit (on_shell_limit) call prc_set%determine_on_shell_histories (1, i_array) call prc_set%compute_probabilities (prob_array) write (u, "(1x,A,9(1x,"// FMT_12 // "))") "resonant =", prob_array write (u, *) call prc_set%write (u, testflag=.true.) write (u, *) write (u, "(A)") "* Cleanup" call global%final () call syntax_phs_forest_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: restricted_subprocesses_3" end subroutine restricted_subprocesses_3 @ %def restricted_subprocesses_3 @ \subsubsection{Event transform} Prepare an actual process with resonant subprocesses. Prepare the resonance selector for a fixed event and apply the resonance-insertion event transform. <>= call test (restricted_subprocesses_4, "restricted_subprocesses_4", & "event transform", & u, results) <>= public :: restricted_subprocesses_4 <>= subroutine restricted_subprocesses_4 (u) integer, intent(in) :: u type(rt_data_t), target :: global class(model_t), pointer :: model class(model_data_t), pointer :: model_data type(string_t) :: libname, libname_res type(string_t) :: procname type(process_component_def_t), pointer :: process_component_def type(prclib_entry_t), pointer :: lib_entry type(process_library_t), pointer :: lib logical :: exist type(process_t), pointer :: process type(process_instance_t), target :: process_instance type(resonance_history_set_t), dimension(1) :: res_history_set type(resonant_subprocess_set_t) :: prc_set type(particle_set_t) :: pset real(default) :: sqrts, mw, pp real(default), dimension(3) :: p3 type(vector4_t), dimension(:), allocatable :: p real(default), dimension(:), allocatable :: m integer, dimension(:), allocatable :: pdg real(default) :: on_shell_limit type(evt_trivial_t), target :: evt_trivial type(evt_resonance_t), target :: evt_resonance real(default) :: probability integer :: i write (u, "(A)") "* Test output: restricted_subprocesses_4" write (u, "(A)") "* Purpose: employ event transform" write (u, "(A)") call syntax_model_file_init () call syntax_phs_forest_init () call global%global_init () call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%set_log (var_str ("?resonance_history"), & .true., is_known = .true.) call global%select_model (var_str ("SM")) allocate (model) call model%init_instance (global%model) model_data => model libname = "restricted_subprocesses_4_lib" libname_res = "restricted_subprocesses_4_lib_res" procname = "restricted_subprocesses_4_p" write (u, "(A)") "* Initialize process library and process" write (u, "(A)") allocate (lib_entry) call lib_entry%init (libname) lib => lib_entry%process_library_t call global%add_prclib (lib_entry) call prepare_resonance_test_library & (lib, libname, procname, model_data, global, u) call integrate_process (procname, global, & local_stack = .true., init_only = .true.) process => global%process_stack%get_process_ptr (procname) call process_instance%init (process) call process_instance%setup_event_data () write (u, "(A)") write (u, "(A)") "* Extract resonance history set" call process%extract_resonance_history_set & (res_history_set(1), include_trivial=.false., i_component=1) write (u, "(A)") write (u, "(A)") "* Build resonant-subprocess library" call prc_set%init (1) call prc_set%fill_resonances (res_history_set(1), 1) process_component_def => process%get_component_def_ptr (1) call prc_set%create_library (libname_res, global, exist) if (.not. exist) then call prc_set%add_to_library (1, & process_component_def%get_prt_spec_in (), & process_component_def%get_prt_spec_out (), & global) end if call prc_set%freeze_library (global) call prc_set%compile_library (global) write (u, "(A)") write (u, "(A)") "* Build particle set" write (u, "(A)") sqrts = global%get_rval (var_str ("sqrts")) mw = 80._default ! deliberately slightly different from true mw pp = sqrt (sqrts**2 - 4 * mw**2) / 2 allocate (pdg (5), p (5), m (5)) pdg(1) = -11 p(1) = vector4_moving (sqrts/2, sqrts/2, 3) m(1) = 0 pdg(2) = 11 p(2) = vector4_moving (sqrts/2,-sqrts/2, 3) m(2) = 0 pdg(3) = 1 p3(1) = pp/2 p3(2) = mw/2 p3(3) = 0 p(3) = vector4_moving (sqrts/4, vector3_moving (p3)) m(3) = 0 p3(2) = -mw/2 pdg(4) = -2 p(4) = vector4_moving (sqrts/4, vector3_moving (p3)) m(4) = 0 pdg(5) = 24 p(5) = vector4_moving (sqrts/2,-pp, 1) m(5) = mw call pset%init_direct (0, 2, 0, 0, 3, pdg, model) call pset%set_momentum (p, m**2) write (u, "(A)") "* Fill process instance" write (u, "(A)") ! workflow from event_recalculate call process_instance%choose_mci (1) call process_instance%set_trace (pset, 1) call process_instance%recover & (1, 1, update_sqme=.true., recover_phs=.false.) call process_instance%evaluate_event_data (weight = 1._default) write (u, "(A)") "* Prepare resonant subprocesses" write (u, "(A)") call prc_set%prepare_process_objects (global) call prc_set%prepare_process_instances (global) write (u, "(A)") "* Fill trivial event transform (deliberately w/o color)" write (u, "(A)") call evt_trivial%connect (process_instance, model) call evt_trivial%set_particle_set (pset, 1, 1) call evt_trivial%write (u) write (u, "(A)") write (u, "(A)") "* Initialize resonance-insertion event transform" write (u, "(A)") evt_trivial%next => evt_resonance evt_resonance%previous => evt_trivial call evt_resonance%set_resonance_data (res_history_set) call evt_resonance%select_component (1) call evt_resonance%connect (process_instance, model) call prc_set%connect_transform (evt_resonance) call evt_resonance%write (u) write (u, "(A)") write (u, "(A)") "* Compute probabilities for applicable resonances" write (u, "(A)") " and initialize the process selector" write (u, "(A)") on_shell_limit = 10._default write (u, "(1x,A,1x," // FMT_10 // ")") "on_shell_limit =", on_shell_limit call evt_resonance%set_on_shell_limit (on_shell_limit) write (u, "(A)") write (u, "(A)") "* Evaluate resonance-insertion event transform" write (u, "(A)") call evt_resonance%prepare_new_event (1, 1) call evt_resonance%generate_weighted (probability) call evt_resonance%make_particle_set (1, .false.) call evt_resonance%write (u, testflag=.true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () call syntax_phs_forest_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: restricted_subprocesses_4" end subroutine restricted_subprocesses_4 @ %def restricted_subprocesses_4 @ \subsubsection{Gaussian turnoff} Identical to the previous process, except that we apply a Gaussian turnoff to the resonance kinematics, which affects the subprocess selector. <>= call test (restricted_subprocesses_5, "restricted_subprocesses_5", & "event transform with gaussian turnoff", & u, results) <>= public :: restricted_subprocesses_5 <>= subroutine restricted_subprocesses_5 (u) integer, intent(in) :: u type(rt_data_t), target :: global class(model_t), pointer :: model class(model_data_t), pointer :: model_data type(string_t) :: libname, libname_res type(string_t) :: procname type(process_component_def_t), pointer :: process_component_def type(prclib_entry_t), pointer :: lib_entry type(process_library_t), pointer :: lib logical :: exist type(process_t), pointer :: process type(process_instance_t), target :: process_instance type(resonance_history_set_t), dimension(1) :: res_history_set type(resonant_subprocess_set_t) :: prc_set type(particle_set_t) :: pset real(default) :: sqrts, mw, pp real(default), dimension(3) :: p3 type(vector4_t), dimension(:), allocatable :: p real(default), dimension(:), allocatable :: m integer, dimension(:), allocatable :: pdg real(default) :: on_shell_limit real(default) :: on_shell_turnoff type(evt_trivial_t), target :: evt_trivial type(evt_resonance_t), target :: evt_resonance real(default) :: probability integer :: i write (u, "(A)") "* Test output: restricted_subprocesses_5" write (u, "(A)") "* Purpose: employ event transform & &with gaussian turnoff" write (u, "(A)") call syntax_model_file_init () call syntax_phs_forest_init () call global%global_init () call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%set_log (var_str ("?resonance_history"), & .true., is_known = .true.) call global%select_model (var_str ("SM")) allocate (model) call model%init_instance (global%model) model_data => model libname = "restricted_subprocesses_5_lib" libname_res = "restricted_subprocesses_5_lib_res" procname = "restricted_subprocesses_5_p" write (u, "(A)") "* Initialize process library and process" write (u, "(A)") allocate (lib_entry) call lib_entry%init (libname) lib => lib_entry%process_library_t call global%add_prclib (lib_entry) call prepare_resonance_test_library & (lib, libname, procname, model_data, global, u) call integrate_process (procname, global, & local_stack = .true., init_only = .true.) process => global%process_stack%get_process_ptr (procname) call process_instance%init (process) call process_instance%setup_event_data () write (u, "(A)") write (u, "(A)") "* Extract resonance history set" call process%extract_resonance_history_set & (res_history_set(1), include_trivial=.false., i_component=1) write (u, "(A)") write (u, "(A)") "* Build resonant-subprocess library" call prc_set%init (1) call prc_set%fill_resonances (res_history_set(1), 1) process_component_def => process%get_component_def_ptr (1) call prc_set%create_library (libname_res, global, exist) if (.not. exist) then call prc_set%add_to_library (1, & process_component_def%get_prt_spec_in (), & process_component_def%get_prt_spec_out (), & global) end if call prc_set%freeze_library (global) call prc_set%compile_library (global) write (u, "(A)") write (u, "(A)") "* Build particle set" write (u, "(A)") sqrts = global%get_rval (var_str ("sqrts")) mw = 80._default ! deliberately slightly different from true mw pp = sqrt (sqrts**2 - 4 * mw**2) / 2 allocate (pdg (5), p (5), m (5)) pdg(1) = -11 p(1) = vector4_moving (sqrts/2, sqrts/2, 3) m(1) = 0 pdg(2) = 11 p(2) = vector4_moving (sqrts/2,-sqrts/2, 3) m(2) = 0 pdg(3) = 1 p3(1) = pp/2 p3(2) = mw/2 p3(3) = 0 p(3) = vector4_moving (sqrts/4, vector3_moving (p3)) m(3) = 0 p3(2) = -mw/2 pdg(4) = -2 p(4) = vector4_moving (sqrts/4, vector3_moving (p3)) m(4) = 0 pdg(5) = 24 p(5) = vector4_moving (sqrts/2,-pp, 1) m(5) = mw call pset%init_direct (0, 2, 0, 0, 3, pdg, model) call pset%set_momentum (p, m**2) write (u, "(A)") "* Fill process instance" write (u, "(A)") ! workflow from event_recalculate call process_instance%choose_mci (1) call process_instance%set_trace (pset, 1) call process_instance%recover & (1, 1, update_sqme=.true., recover_phs=.false.) call process_instance%evaluate_event_data (weight = 1._default) write (u, "(A)") "* Prepare resonant subprocesses" write (u, "(A)") call prc_set%prepare_process_objects (global) call prc_set%prepare_process_instances (global) write (u, "(A)") "* Fill trivial event transform (deliberately w/o color)" write (u, "(A)") call evt_trivial%connect (process_instance, model) call evt_trivial%set_particle_set (pset, 1, 1) call evt_trivial%write (u) write (u, "(A)") write (u, "(A)") "* Initialize resonance-insertion event transform" write (u, "(A)") evt_trivial%next => evt_resonance evt_resonance%previous => evt_trivial call evt_resonance%set_resonance_data (res_history_set) call evt_resonance%select_component (1) call evt_resonance%connect (process_instance, model) call prc_set%connect_transform (evt_resonance) call evt_resonance%write (u) write (u, "(A)") write (u, "(A)") "* Compute probabilities for applicable resonances" write (u, "(A)") " and initialize the process selector" write (u, "(A)") on_shell_limit = 10._default write (u, "(1x,A,1x," // FMT_10 // ")") "on_shell_limit =", & on_shell_limit call evt_resonance%set_on_shell_limit (on_shell_limit) on_shell_turnoff = 1._default write (u, "(1x,A,1x," // FMT_10 // ")") "on_shell_turnoff =", & on_shell_turnoff call evt_resonance%set_on_shell_turnoff (on_shell_turnoff) write (u, "(A)") write (u, "(A)") "* Evaluate resonance-insertion event transform" write (u, "(A)") call evt_resonance%prepare_new_event (1, 1) call evt_resonance%generate_weighted (probability) call evt_resonance%make_particle_set (1, .false.) call evt_resonance%write (u, testflag=.true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () call syntax_phs_forest_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: restricted_subprocesses_5" end subroutine restricted_subprocesses_5 @ %def restricted_subprocesses_5 @ \subsubsection{Event transform} The same process and event again. This time, switch off the background contribution, so the selector becomes trivial. <>= call test (restricted_subprocesses_6, "restricted_subprocesses_6", & "event transform with background switched off", & u, results) <>= public :: restricted_subprocesses_6 <>= subroutine restricted_subprocesses_6 (u) integer, intent(in) :: u type(rt_data_t), target :: global class(model_t), pointer :: model class(model_data_t), pointer :: model_data type(string_t) :: libname, libname_res type(string_t) :: procname type(process_component_def_t), pointer :: process_component_def type(prclib_entry_t), pointer :: lib_entry type(process_library_t), pointer :: lib logical :: exist type(process_t), pointer :: process type(process_instance_t), target :: process_instance type(resonance_history_set_t), dimension(1) :: res_history_set type(resonant_subprocess_set_t) :: prc_set type(particle_set_t) :: pset real(default) :: sqrts, mw, pp real(default), dimension(3) :: p3 type(vector4_t), dimension(:), allocatable :: p real(default), dimension(:), allocatable :: m integer, dimension(:), allocatable :: pdg real(default) :: on_shell_limit real(default) :: background_factor type(evt_trivial_t), target :: evt_trivial type(evt_resonance_t), target :: evt_resonance real(default) :: probability integer :: i write (u, "(A)") "* Test output: restricted_subprocesses_6" write (u, "(A)") "* Purpose: employ event transform & &with background switched off" write (u, "(A)") call syntax_model_file_init () call syntax_phs_forest_init () call global%global_init () call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%set_log (var_str ("?resonance_history"), & .true., is_known = .true.) call global%select_model (var_str ("SM")) allocate (model) call model%init_instance (global%model) model_data => model libname = "restricted_subprocesses_6_lib" libname_res = "restricted_subprocesses_6_lib_res" procname = "restricted_subprocesses_6_p" write (u, "(A)") "* Initialize process library and process" write (u, "(A)") allocate (lib_entry) call lib_entry%init (libname) lib => lib_entry%process_library_t call global%add_prclib (lib_entry) call prepare_resonance_test_library & (lib, libname, procname, model_data, global, u) call integrate_process (procname, global, & local_stack = .true., init_only = .true.) process => global%process_stack%get_process_ptr (procname) call process_instance%init (process) call process_instance%setup_event_data () write (u, "(A)") write (u, "(A)") "* Extract resonance history set" call process%extract_resonance_history_set & (res_history_set(1), include_trivial=.false., i_component=1) write (u, "(A)") write (u, "(A)") "* Build resonant-subprocess library" call prc_set%init (1) call prc_set%fill_resonances (res_history_set(1), 1) process_component_def => process%get_component_def_ptr (1) call prc_set%create_library (libname_res, global, exist) if (.not. exist) then call prc_set%add_to_library (1, & process_component_def%get_prt_spec_in (), & process_component_def%get_prt_spec_out (), & global) end if call prc_set%freeze_library (global) call prc_set%compile_library (global) write (u, "(A)") write (u, "(A)") "* Build particle set" write (u, "(A)") sqrts = global%get_rval (var_str ("sqrts")) mw = 80._default ! deliberately slightly different from true mw pp = sqrt (sqrts**2 - 4 * mw**2) / 2 allocate (pdg (5), p (5), m (5)) pdg(1) = -11 p(1) = vector4_moving (sqrts/2, sqrts/2, 3) m(1) = 0 pdg(2) = 11 p(2) = vector4_moving (sqrts/2,-sqrts/2, 3) m(2) = 0 pdg(3) = 1 p3(1) = pp/2 p3(2) = mw/2 p3(3) = 0 p(3) = vector4_moving (sqrts/4, vector3_moving (p3)) m(3) = 0 p3(2) = -mw/2 pdg(4) = -2 p(4) = vector4_moving (sqrts/4, vector3_moving (p3)) m(4) = 0 pdg(5) = 24 p(5) = vector4_moving (sqrts/2,-pp, 1) m(5) = mw call pset%init_direct (0, 2, 0, 0, 3, pdg, model) call pset%set_momentum (p, m**2) write (u, "(A)") "* Fill process instance" write (u, "(A)") ! workflow from event_recalculate call process_instance%choose_mci (1) call process_instance%set_trace (pset, 1) call process_instance%recover & (1, 1, update_sqme=.true., recover_phs=.false.) call process_instance%evaluate_event_data (weight = 1._default) write (u, "(A)") "* Prepare resonant subprocesses" write (u, "(A)") call prc_set%prepare_process_objects (global) call prc_set%prepare_process_instances (global) write (u, "(A)") "* Fill trivial event transform (deliberately w/o color)" write (u, "(A)") call evt_trivial%connect (process_instance, model) call evt_trivial%set_particle_set (pset, 1, 1) call evt_trivial%write (u) write (u, "(A)") write (u, "(A)") "* Initialize resonance-insertion event transform" write (u, "(A)") evt_trivial%next => evt_resonance evt_resonance%previous => evt_trivial call evt_resonance%set_resonance_data (res_history_set) call evt_resonance%select_component (1) call evt_resonance%connect (process_instance, model) call prc_set%connect_transform (evt_resonance) call evt_resonance%write (u) write (u, "(A)") write (u, "(A)") "* Compute probabilities for applicable resonances" write (u, "(A)") " and initialize the process selector" write (u, "(A)") on_shell_limit = 10._default write (u, "(1x,A,1x," // FMT_10 // ")") & "on_shell_limit =", on_shell_limit call evt_resonance%set_on_shell_limit (on_shell_limit) background_factor = 0 write (u, "(1x,A,1x," // FMT_10 // ")") & "background_factor =", background_factor call evt_resonance%set_background_factor (background_factor) write (u, "(A)") write (u, "(A)") "* Evaluate resonance-insertion event transform" write (u, "(A)") call evt_resonance%prepare_new_event (1, 1) call evt_resonance%generate_weighted (probability) call evt_resonance%make_particle_set (1, .false.) call evt_resonance%write (u, testflag=.true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () call syntax_phs_forest_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: restricted_subprocesses_6" end subroutine restricted_subprocesses_6 @ %def restricted_subprocesses_6 @ \clearpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Simulation} This module manages simulation: event generation and reading/writing of event files. The [[simulation]] object is intended to be used (via a pointer) outside of \whizard, if events are generated individually by an external driver. <<[[simulations.f90]]>>= <> module simulations <> <> <> use io_units use format_utils, only: write_separator use format_defs, only: FMT_15, FMT_19 use os_interface use numeric_utils use string_utils, only: str use diagnostics use lorentz, only: vector4_t use sm_qcd use md5 use variables, only: var_list_t use eval_trees use model_data use flavors use particles use state_matrices, only: FM_IGNORE_HELICITY use beam_structures, only: beam_structure_t use beams use rng_base use rng_stream, only: rng_stream_t use selectors use resonances, only: resonance_history_set_t use process_libraries, only: process_library_t use process_libraries, only: process_component_def_t use prc_core ! TODO: (bcn 2016-09-13) should be ideally only pcm_base use pcm, only: pcm_nlo_t, pcm_instance_nlo_t ! TODO: (bcn 2016-09-13) details of process config should not be necessary here use process_config, only: COMP_REAL_FIN use process use instances use event_base + use event_handles, only: event_handle_t use events use event_transforms use shower use eio_data use eio_base use rt_data use dispatch_beams, only: dispatch_qcd use dispatch_rng, only: dispatch_rng_factory use dispatch_rng, only: update_rng_seed_in_var_list use dispatch_me_methods, only: dispatch_core_update, dispatch_core_restore use dispatch_transforms, only: dispatch_evt_isr_epa_handler use dispatch_transforms, only: dispatch_evt_resonance use dispatch_transforms, only: dispatch_evt_decay use dispatch_transforms, only: dispatch_evt_shower use dispatch_transforms, only: dispatch_evt_hadrons use dispatch_transforms, only: dispatch_evt_nlo use integrations use event_streams use restricted_subprocesses, only: resonant_subprocess_set_t use restricted_subprocesses, only: get_libname_res use evt_nlo <> <> <> <> <> contains <> end module simulations @ %def simulations @ \subsection{Event counting} In this object we collect statistical information about an event sample or sub-sample. <>= type :: counter_t integer :: total = 0 integer :: generated = 0 integer :: read = 0 integer :: positive = 0 integer :: negative = 0 integer :: zero = 0 integer :: excess = 0 integer :: dropped = 0 real(default) :: max_excess = 0 real(default) :: sum_excess = 0 logical :: reproduce_xsection = .false. real(default) :: mean = 0 real(default) :: varsq = 0 integer :: nlo_weight_counter = 0 contains <> end type counter_t @ %def simulation_counter_t @ Output. <>= procedure :: write => counter_write <>= subroutine counter_write (counter, unit) class(counter_t), intent(in) :: counter integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) 1 format (3x,A,I0) 2 format (5x,A,I0) 3 format (5x,A,ES19.12) write (u, 1) "Events total = ", counter%total write (u, 2) "generated = ", counter%generated write (u, 2) "read = ", counter%read write (u, 2) "positive weight = ", counter%positive write (u, 2) "negative weight = ", counter%negative write (u, 2) "zero weight = ", counter%zero write (u, 2) "excess weight = ", counter%excess if (counter%excess /= 0) then write (u, 3) "max excess = ", counter%max_excess write (u, 3) "avg excess = ", counter%sum_excess / counter%total end if write (u, 1) "Events dropped = ", counter%dropped end subroutine counter_write @ %def counter_write @ This is a screen message: if there was an excess, display statistics. <>= procedure :: show_excess => counter_show_excess <>= subroutine counter_show_excess (counter) class(counter_t), intent(in) :: counter if (counter%excess > 0) then write (msg_buffer, "(A,1x,I0,1x,A,1x,'(',F7.3,' %)')") & "Encountered events with excess weight:", counter%excess, & "events", 100 * counter%excess / real (counter%total) call msg_warning () write (msg_buffer, "(A,ES10.3)") & "Maximum excess weight =", counter%max_excess call msg_message () write (msg_buffer, "(A,ES10.3)") & "Average excess weight =", counter%sum_excess / counter%total call msg_message () end if end subroutine counter_show_excess @ %def counter_show_excess @ If events have been dropped during simulation of weighted events, issue a message here. If a fraction [[n_dropped / n_total]] of the events fail the cuts, we keep generating new ones until we have [[n_total]] events with [[weight > 0]]. Thus, the total sum of weights will be a fraction of [[n_dropped / n_total]] too large. However, we do not know how many events will pass or fail the cuts prior to generating them so we leave it to the user to correct for this factor. <>= procedure :: show_dropped => counter_show_dropped <>= subroutine counter_show_dropped (counter) class(counter_t), intent(in) :: counter if (counter%dropped > 0) then write (msg_buffer, "(A,1x,I0,1x,'(',A,1x,I0,')')") & "Dropped events (weight zero) =", & counter%dropped, "total", counter%dropped + counter%total call msg_message () write (msg_buffer, "(A,ES15.8)") & "All event weights must be rescaled by f =", & real (counter%total, default) & / real (counter%dropped + counter%total, default) call msg_warning () end if end subroutine counter_show_dropped @ %def counter_show_dropped @ <>= procedure :: show_mean_and_variance => counter_show_mean_and_variance <>= subroutine counter_show_mean_and_variance (counter) class(counter_t), intent(in) :: counter if (counter%reproduce_xsection .and. counter%nlo_weight_counter > 1) then print *, "Reconstructed cross-section from event weights: " print *, counter%mean, '+-', sqrt (counter%varsq / (counter%nlo_weight_counter - 1)) end if end subroutine counter_show_mean_and_variance @ %def counter_show_mean_and_variance @ Count an event. The weight and event source are optional; by default we assume that the event has been generated and has positive weight. The optional integer [[n_dropped]] counts weighted events with weight zero that were encountered while generating the current event, but dropped (because of their zero weight). Accumulating this number allows for renormalizing event weight sums in histograms, after the generation step has been completed. <>= procedure :: record => counter_record <>= subroutine counter_record (counter, weight, excess, n_dropped, from_file) class(counter_t), intent(inout) :: counter real(default), intent(in), optional :: weight, excess integer, intent(in), optional :: n_dropped logical, intent(in), optional :: from_file counter%total = counter%total + 1 if (present (from_file)) then if (from_file) then counter%read = counter%read + 1 else counter%generated = counter%generated + 1 end if else counter%generated = counter%generated + 1 end if if (present (weight)) then if (weight > 0) then counter%positive = counter%positive + 1 else if (weight < 0) then counter%negative = counter%negative + 1 else counter%zero = counter%zero + 1 end if else counter%positive = counter%positive + 1 end if if (present (excess)) then if (excess > 0) then counter%excess = counter%excess + 1 counter%max_excess = max (counter%max_excess, excess) counter%sum_excess = counter%sum_excess + excess end if end if if (present (n_dropped)) then counter%dropped = counter%dropped + n_dropped end if end subroutine counter_record @ %def counter_record <>= procedure :: allreduce_record => counter_allreduce_record <>= subroutine counter_allreduce_record (counter) class(counter_t), intent(inout) :: counter integer :: read, generated integer :: positive, negative, zero, excess, dropped real(default) :: max_excess, sum_excess read = counter%read generated = counter%generated positive = counter%positive negative = counter%negative zero = counter%zero excess = counter%excess max_excess = counter%max_excess sum_excess = counter%sum_excess dropped = counter%dropped call MPI_ALLREDUCE (read, counter%read, 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD) call MPI_ALLREDUCE (generated, counter%generated, 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD) call MPI_ALLREDUCE (positive, counter%positive, 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD) call MPI_ALLREDUCE (negative, counter%negative, 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD) call MPI_ALLREDUCE (zero, counter%zero, 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD) call MPI_ALLREDUCE (excess, counter%excess, 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD) call MPI_ALLREDUCE (max_excess, counter%max_excess, 1, MPI_DOUBLE_PRECISION, MPI_MAX, MPI_COMM_WORLD) call MPI_ALLREDUCE (sum_excess, counter%sum_excess, 1, MPI_DOUBLE_PRECISION, MPI_SUM, MPI_COMM_WORLD) call MPI_ALLREDUCE (dropped, counter%dropped, 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD) !! \todo{sbrass - Implement allreduce of mean and variance, relevant for weighted events.} end subroutine counter_allreduce_record @ <>= procedure :: record_mean_and_variance => & counter_record_mean_and_variance <>= subroutine counter_record_mean_and_variance (counter, weight, i_nlo) class(counter_t), intent(inout) :: counter real(default), intent(in) :: weight integer, intent(in) :: i_nlo real(default), save :: weight_buffer = 0._default integer, save :: nlo_count = 1 if (.not. counter%reproduce_xsection) return if (i_nlo == 1) then call flush_weight_buffer (weight_buffer, nlo_count) weight_buffer = weight nlo_count = 1 else weight_buffer = weight_buffer + weight nlo_count = nlo_count + 1 end if contains subroutine flush_weight_buffer (w, n_nlo) real(default), intent(in) :: w integer, intent(in) :: n_nlo integer :: n real(default) :: mean_new counter%nlo_weight_counter = counter%nlo_weight_counter + 1 !!! Minus 1 to take into account offset from initialization n = counter%nlo_weight_counter - 1 if (n > 0) then mean_new = counter%mean + (w / n_nlo - counter%mean) / n if (n > 1) & counter%varsq = counter%varsq - counter%varsq / (n - 1) + & n * (mean_new - counter%mean)**2 counter%mean = mean_new end if end subroutine flush_weight_buffer end subroutine counter_record_mean_and_variance @ %def counter_record_mean_and_variance @ \subsection{Simulation: component sets} For each set of process components that share a MCI entry in the process configuration, we keep a separate event record. <>= type :: mci_set_t private integer :: n_components = 0 integer, dimension(:), allocatable :: i_component type(string_t), dimension(:), allocatable :: component_id logical :: has_integral = .false. real(default) :: integral = 0 real(default) :: error = 0 real(default) :: weight_mci = 0 type(counter_t) :: counter contains <> end type mci_set_t @ %def mci_set_t @ Output. <>= procedure :: write => mci_set_write <>= subroutine mci_set_write (object, unit, pacified) class(mci_set_t), intent(in) :: object integer, intent(in), optional :: unit logical, intent(in), optional :: pacified logical :: pacify integer :: u, i u = given_output_unit (unit) pacify = .false.; if (present (pacified)) pacify = pacified write (u, "(3x,A)") "Components:" do i = 1, object%n_components write (u, "(5x,I0,A,A,A)") object%i_component(i), & ": '", char (object%component_id(i)), "'" end do if (object%has_integral) then if (pacify) then write (u, "(3x,A," // FMT_15 // ")") "Integral = ", object%integral write (u, "(3x,A," // FMT_15 // ")") "Error = ", object%error write (u, "(3x,A,F9.6)") "Weight =", object%weight_mci else write (u, "(3x,A," // FMT_19 // ")") "Integral = ", object%integral write (u, "(3x,A," // FMT_19 // ")") "Error = ", object%error write (u, "(3x,A,F13.10)") "Weight =", object%weight_mci end if else write (u, "(3x,A)") "Integral = [undefined]" end if call object%counter%write (u) end subroutine mci_set_write @ %def mci_set_write @ Initialize: Get the indices and names for the process components that will contribute to this set. <>= procedure :: init => mci_set_init <>= subroutine mci_set_init (object, i_mci, process) class(mci_set_t), intent(out) :: object integer, intent(in) :: i_mci type(process_t), intent(in), target :: process integer :: i call process%get_i_component (i_mci, object%i_component) object%n_components = size (object%i_component) allocate (object%component_id (object%n_components)) do i = 1, size (object%component_id) object%component_id(i) = & process%get_component_id (object%i_component(i)) end do if (process%has_integral (i_mci)) then object%integral = process%get_integral (i_mci) object%error = process%get_error (i_mci) object%has_integral = .true. end if end subroutine mci_set_init @ %def mci_set_init @ \subsection{Process-core Safe} This is an object that temporarily holds a process core object. We need this while rescanning a process with modified parameters. After the rescan, we want to restore the original state. <>= type :: core_safe_t class(prc_core_t), allocatable :: core end type core_safe_t @ %def core_safe_t @ \subsection{Process Object} The simulation works on process objects. This subroutine makes a process object available for simulation. The process is in the process stack. [[use_process]] implies that the process should already exist as an object in the process stack. If integration is not yet done, do it. Any generated process object should be put on the global stack, if it is separate from the local one. <>= subroutine prepare_process & (process, process_id, use_process, integrate, local, global) type(process_t), pointer, intent(out) :: process type(string_t), intent(in) :: process_id logical, intent(in) :: use_process, integrate type(rt_data_t), intent(inout), target :: local type(rt_data_t), intent(inout), optional, target :: global type(rt_data_t), pointer :: current if (debug_on) call msg_debug (D_CORE, "prepare_process") if (debug_on) call msg_debug (D_CORE, "global present", present (global)) if (present (global)) then current => global else current => local end if process => current%process_stack%get_process_ptr (process_id) if (debug_on) call msg_debug (D_CORE, "use_process", use_process) if (debug_on) call msg_debug (D_CORE, "associated process", associated (process)) if (use_process .and. .not. associated (process)) then if (integrate) then call msg_message ("Simulate: process '" & // char (process_id) // "' needs integration") else call msg_message ("Simulate: process '" & // char (process_id) // "' needs initialization") end if if (present (global)) then call integrate_process (process_id, local, global, & init_only = .not. integrate) else call integrate_process (process_id, local, & local_stack = .true., init_only = .not. integrate) end if if (signal_is_pending ()) return process => current%process_stack%get_process_ptr (process_id) if (associated (process)) then if (integrate) then call msg_message ("Simulate: integration done") call current%process_stack%fill_result_vars (process_id) else call msg_message ("Simulate: process initialization done") end if else call msg_fatal ("Simulate: process '" & // char (process_id) // "' could not be initialized: aborting") end if else if (.not. associated (process)) then if (present (global)) then call integrate_process (process_id, local, global, & init_only = .true.) else call integrate_process (process_id, local, & local_stack = .true., init_only = .true.) end if process => current%process_stack%get_process_ptr (process_id) call msg_message & ("Simulate: process '" & // char (process_id) // "': enabled for rescan only") end if end subroutine prepare_process @ %def prepare_process @ -\subsection{Simulation entry} +\subsection{Simulation-entry object} For each process that we consider for event generation, we need a separate entry. The entry separately records the process ID and run ID. The [[weight_mci]] array is used for selecting a component set (which shares an MCI record inside the process container) when generating an event for the current process. The simulation entry is an extension of the [[event_t]] event record. This core object contains configuration data, pointers to the process and process instance, the expressions, flags and values that are evaluated at runtime, and the resulting particle set. The entry explicitly allocates the [[process_instance]], which becomes the process-specific workspace for the event record. If entries with differing environments are present simultaneously, we may need to switch QCD parameters and/or the model event by event. In this case, the [[qcd]] and/or [[model]] components are present. For the purpose of NLO events, [[entry_t]] contains a pointer list to other simulation-entries. This is due to the fact that we have to associate an event for each component of the fixed order simulation, i.e. one $N$-particle event and $N_\text{phs}$ $N+1$-particle events. However, all entries share the same event transforms. <>= type, extends (event_t) :: entry_t private type(string_t) :: process_id type(string_t) :: library type(string_t) :: run_id logical :: has_integral = .false. real(default) :: integral = 0 real(default) :: error = 0 real(default) :: process_weight = 0 logical :: valid = .false. type(counter_t) :: counter integer :: n_in = 0 integer :: n_mci = 0 type(mci_set_t), dimension(:), allocatable :: mci_sets type(selector_t) :: mci_selector logical :: has_resonant_subprocess_set = .false. type(resonant_subprocess_set_t) :: resonant_subprocess_set type(core_safe_t), dimension(:), allocatable :: core_safe class(model_data_t), pointer :: model => null () type(qcd_t) :: qcd type(entry_t), pointer :: first => null () type(entry_t), pointer :: next => null () class(evt_t), pointer :: evt_powheg => null () contains <> end type entry_t @ %def entry_t @ Output. Write just the configuration, the event is written by a separate routine. The [[verbose]] option is unused, it is required by the interface of the base-object method. <>= procedure :: write_config => entry_write_config <>= subroutine entry_write_config (object, unit, pacified) class(entry_t), intent(in) :: object integer, intent(in), optional :: unit logical, intent(in), optional :: pacified logical :: pacify integer :: u, i u = given_output_unit (unit) pacify = .false.; if (present (pacified)) pacify = pacified write (u, "(3x,A,A,A)") "Process = '", char (object%process_id), "'" write (u, "(3x,A,A,A)") "Library = '", char (object%library), "'" write (u, "(3x,A,A,A)") "Run = '", char (object%run_id), "'" write (u, "(3x,A,L1)") "is valid = ", object%valid if (object%has_integral) then if (pacify) then write (u, "(3x,A," // FMT_15 // ")") "Integral = ", object%integral write (u, "(3x,A," // FMT_15 // ")") "Error = ", object%error write (u, "(3x,A,F9.6)") "Weight =", object%process_weight else write (u, "(3x,A," // FMT_19 // ")") "Integral = ", object%integral write (u, "(3x,A," // FMT_19 // ")") "Error = ", object%error write (u, "(3x,A,F13.10)") "Weight =", object%process_weight end if else write (u, "(3x,A)") "Integral = [undefined]" end if write (u, "(3x,A,I0)") "MCI sets = ", object%n_mci call object%counter%write (u) do i = 1, size (object%mci_sets) write (u, "(A)") write (u, "(1x,A,I0,A)") "MCI set #", i, ":" call object%mci_sets(i)%write (u, pacified) end do if (object%resonant_subprocess_set%is_active ()) then write (u, "(A)") call object%write_resonant_subprocess_data (u) end if if (allocated (object%core_safe)) then do i = 1, size (object%core_safe) write (u, "(1x,A,I0,A)") "Saved process-component core #", i, ":" call object%core_safe(i)%core%write (u) end do end if end subroutine entry_write_config @ %def entry_write_config @ Finalizer. The [[instance]] pointer component of the [[event_t]] base type points to a target which we did explicitly allocate in the [[entry_init]] procedure. Therefore, we finalize and explicitly deallocate it here. Then we call the finalizer of the base type. <>= procedure :: final => entry_final <>= subroutine entry_final (object) class(entry_t), intent(inout) :: object integer :: i if (associated (object%instance)) then do i = 1, object%n_mci call object%instance%final_simulation (i) end do call object%instance%final () deallocate (object%instance) end if call object%event_t%final () end subroutine entry_final @ %def entry_final @ Copy the content of an entry into another one, except for the next-pointer <>= procedure :: copy_entry => entry_copy_entry <>= subroutine entry_copy_entry (entry1, entry2) class(entry_t), intent(in), target :: entry1 type(entry_t), intent(inout), target :: entry2 call entry1%event_t%clone (entry2%event_t) entry2%process_id = entry1%process_id entry2%library = entry1%library entry2%run_id = entry1%run_id entry2%has_integral = entry1%has_integral entry2%integral = entry1%integral entry2%error = entry1%error entry2%process_weight = entry1%process_weight entry2%valid = entry1%valid entry2%counter = entry1%counter entry2%n_in = entry1%n_in entry2%n_mci = entry1%n_mci if (allocated (entry1%mci_sets)) then allocate (entry2%mci_sets (size (entry1%mci_sets))) entry2%mci_sets = entry1%mci_sets end if entry2%mci_selector = entry1%mci_selector if (allocated (entry1%core_safe)) then allocate (entry2%core_safe (size (entry1%core_safe))) entry2%core_safe = entry1%core_safe end if entry2%model => entry1%model entry2%qcd = entry1%qcd end subroutine entry_copy_entry @ %def entry_copy_entry -@ Initialization. Search for a process entry and allocate a process +@ +\subsubsection{Simulation-entry initialization} +Search for a process entry and allocate a process instance as an anonymous object, temporarily accessible via the [[process_instance]] pointer. Assign data by looking at the process object and at the environment. If [[n_alt]] is set, we prepare for additional alternate sqme and weight entries. The [[compile]] flag is only false if we do not need the Whizard process at all, just its definition. In that case, we skip process initialization. Otherwise, and if the process object is not found initially: if [[integrate]] is set, attempt an integration pass and try again. Otherwise, just initialize the object. If [[generate]] is set, prepare the MCI objects for generating new events. For pure rescanning, this is not necessary. If [[resonance_history]] is set, we create a separate process library which contains all possible restricted subprocesses with distinct resonance histories. These processes will not be integrated, but their matrix element codes are used for determining probabilities of resonance histories. Note that this can work only if the process method is OMega, and the phase-space method is 'wood'. When done, we assign the [[instance]] and [[process]] pointers of the base type by the [[connect]] method, so we can reference them later. TODO: In case of NLO event generation, copying the configuration from the master process is rather intransparent. For instance, we override the process var list by the global var list. <>= procedure :: init => entry_init <>= subroutine entry_init & (entry, process_id, & use_process, integrate, generate, update_sqme, & support_resonance_history, & local, global, n_alt) class(entry_t), intent(inout), target :: entry type(string_t), intent(in) :: process_id logical, intent(in) :: use_process, integrate, generate, update_sqme logical, intent(in) :: support_resonance_history type(rt_data_t), intent(inout), target :: local type(rt_data_t), intent(inout), optional, target :: global integer, intent(in), optional :: n_alt type(process_t), pointer :: process, master_process type(process_instance_t), pointer :: process_instance type(process_library_t), pointer :: prclib_saved integer :: i logical :: res_include_trivial logical :: combined_integration integer :: selected_mci selected_mci = 0 if (debug_on) call msg_debug (D_CORE, "entry_init") if (debug_on) call msg_debug (D_CORE, "process_id", process_id) call prepare_process & (master_process, process_id, use_process, integrate, local, global) if (signal_is_pending ()) return if (associated (master_process)) then if (.not. master_process%has_matrix_element ()) then entry%has_integral = .true. entry%process_id = process_id entry%valid = .false. return end if else call entry%basic_init (local%var_list) entry%has_integral = .false. entry%process_id = process_id call entry%import_process_def_characteristics (local%prclib, process_id) entry%valid = .true. return end if call entry%basic_init (local%var_list, n_alt) entry%process_id = process_id if (generate .or. integrate) then entry%run_id = master_process%get_run_id () process => master_process else call local%set_log (var_str ("?rebuild_phase_space"), & .false., is_known = .true.) call local%set_log (var_str ("?check_phs_file"), & .false., is_known = .true.) call local%set_log (var_str ("?rebuild_grids"), & .false., is_known = .true.) entry%run_id = & local%var_list%get_sval (var_str ("$run_id")) if (update_sqme) then call prepare_local_process (process, process_id, local) else process => master_process end if end if call entry%import_process_characteristics (process) allocate (entry%mci_sets (entry%n_mci)) do i = 1, size (entry%mci_sets) call entry%mci_sets(i)%init (i, master_process) end do call entry%import_process_results (master_process) call entry%prepare_expressions (local) if (process%is_nlo_calculation ()) then call process%init_nlo_settings (global%var_list) end if combined_integration = local%get_lval (var_str ("?combined_nlo_integration")) if (.not. combined_integration & .and. local%get_lval (var_str ("?fixed_order_nlo_events"))) & selected_mci = process%extract_active_component_mci () call prepare_process_instance (process_instance, process, local%model, & local = local) if (generate) then if (selected_mci > 0) then call process%prepare_simulation (selected_mci) call process_instance%init_simulation (selected_mci, entry%config%safety_factor, & local%get_lval (var_str ("?keep_failed_events"))) else do i = 1, entry%n_mci call process%prepare_simulation (i) call process_instance%init_simulation (i, entry%config%safety_factor, & local%get_lval (var_str ("?keep_failed_events"))) end do end if end if if (support_resonance_history) then prclib_saved => local%prclib call entry%setup_resonant_subprocesses (local, process) if (entry%has_resonant_subprocess_set) then if (signal_is_pending ()) return call entry%compile_resonant_subprocesses (local) if (signal_is_pending ()) return call entry%prepare_resonant_subprocesses (local, global) if (signal_is_pending ()) return call entry%prepare_resonant_subprocess_instances (local) end if if (signal_is_pending ()) return if (associated (prclib_saved)) call local%update_prclib (prclib_saved) end if call entry%setup_event_transforms (process, local) call dispatch_qcd (entry%qcd, local%get_var_list_ptr (), local%os_data) call entry%connect_qcd () select type (pcm => process_instance%pcm) class is (pcm_instance_nlo_t) select type (config => pcm%config) type is (pcm_nlo_t) if (config%settings%fixed_order_nlo) & call pcm%set_fixed_order_event_mode () end select end select if (present (global)) then call entry%connect (process_instance, local%model, global%process_stack) else call entry%connect (process_instance, local%model, local%process_stack) end if call entry%setup_expressions () entry%model => process%get_model_ptr () entry%valid = .true. end subroutine entry_init @ %def entry_init @ <>= procedure :: set_active_real_components => entry_set_active_real_components <>= subroutine entry_set_active_real_components (entry) class(entry_t), intent(inout) :: entry integer :: i_active_real select type (pcm => entry%instance%pcm) class is (pcm_instance_nlo_t) i_active_real = entry%instance%get_real_of_mci () if (debug_on) call msg_debug2 (D_CORE, "i_active_real", i_active_real) if (associated (entry%evt_powheg)) then select type (evt => entry%evt_powheg) type is (evt_shower_t) if (entry%process%get_component_type(i_active_real) == COMP_REAL_FIN) then if (debug_on) call msg_debug (D_CORE, "Disabling Powheg matching for ", i_active_real) call evt%disable_powheg_matching () else if (debug_on) call msg_debug (D_CORE, "Enabling Powheg matching for ", i_active_real) call evt%enable_powheg_matching () end if class default call msg_fatal ("powheg-evt should be evt_shower_t!") end select end if end select end subroutine entry_set_active_real_components @ %def entry_set_active_real_components @ Part of simulation-entry initialization: set up a process object for local use. <>= subroutine prepare_local_process (process, process_id, local) type(process_t), pointer, intent(inout) :: process type(string_t), intent(in) :: process_id type(rt_data_t), intent(inout), target :: local type(integration_t) :: intg call intg%create_process (process_id) call intg%init_process (local) call intg%setup_process (local, verbose=.false.) process => intg%get_process_ptr () end subroutine prepare_local_process @ %def prepare_local_process @ Part of simulation-entry initialization: set up a process instance matching the selected process object. The model that we can provide as an extra argument can modify particle settings (polarization) in the density matrices that will be constructed. It does not affect parameters. <>= subroutine prepare_process_instance & (process_instance, process, model, local) type(process_instance_t), pointer, intent(inout) :: process_instance type(process_t), intent(inout), target :: process class(model_data_t), intent(in), optional :: model type(rt_data_t), intent(in), optional, target :: local allocate (process_instance) call process_instance%init (process) if (process%is_nlo_calculation ()) then select type (pcm => process_instance%pcm) type is (pcm_instance_nlo_t) select type (config => pcm%config) type is (pcm_nlo_t) if (.not. config%settings%combined_integration) & call pcm%set_radiation_event () end select end select call process%prepare_any_external_code () end if call process_instance%setup_event_data (model) end subroutine prepare_process_instance @ %def prepare_process_instance @ Part of simulation-entry initialization: query the process for basic information. <>= procedure, private :: import_process_characteristics & => entry_import_process_characteristics <>= subroutine entry_import_process_characteristics (entry, process) class(entry_t), intent(inout) :: entry type(process_t), intent(in), target :: process entry%library = process%get_library_name () entry%n_in = process%get_n_in () entry%n_mci = process%get_n_mci () end subroutine entry_import_process_characteristics @ %def entry_import_process_characteristics @ This is the alternative form which applies if there is no process entry, but just a process definition which we take from the provided [[prclib]] definition library. <>= procedure, private :: import_process_def_characteristics & => entry_import_process_def_characteristics <>= subroutine entry_import_process_def_characteristics (entry, prclib, id) class(entry_t), intent(inout) :: entry type(process_library_t), intent(in), target :: prclib type(string_t), intent(in) :: id entry%library = prclib%get_name () entry%n_in = prclib%get_n_in (id) end subroutine entry_import_process_def_characteristics @ %def entry_import_process_def_characteristics @ Part of simulation-entry initialization: query the process for integration results. <>= procedure, private :: import_process_results & => entry_import_process_results <>= subroutine entry_import_process_results (entry, process) class(entry_t), intent(inout) :: entry type(process_t), intent(in), target :: process if (process%has_integral ()) then entry%integral = process%get_integral () entry%error = process%get_error () call entry%set_sigma (entry%integral) entry%has_integral = .true. end if end subroutine entry_import_process_results @ %def entry_import_process_characteristics @ Part of simulation-entry initialization: create expression factory objects and store them. <>= procedure, private :: prepare_expressions & => entry_prepare_expressions <>= subroutine entry_prepare_expressions (entry, local) class(entry_t), intent(inout) :: entry type(rt_data_t), intent(in), target :: local type(eval_tree_factory_t) :: expr_factory call expr_factory%init (local%pn%selection_lexpr) call entry%set_selection (expr_factory) call expr_factory%init (local%pn%reweight_expr) call entry%set_reweight (expr_factory) call expr_factory%init (local%pn%analysis_lexpr) call entry%set_analysis (expr_factory) end subroutine entry_prepare_expressions @ %def entry_prepare_expressions -@ Initializes the list of additional NLO entries. The routine gets the +@ +\subsubsection{Extra (NLO) entries} +Initializes the list of additional NLO entries. The routine gets the information about how many entries to associate from [[region_data]]. <>= procedure :: setup_additional_entries => entry_setup_additional_entries <>= subroutine entry_setup_additional_entries (entry) class(entry_t), intent(inout), target :: entry type(entry_t), pointer :: current_entry integer :: i, n_phs type(evt_nlo_t), pointer :: evt integer :: mode evt => null () select type (pcm => entry%instance%pcm) class is (pcm_instance_nlo_t) select type (config => pcm%config) type is (pcm_nlo_t) n_phs = config%region_data%n_phs end select end select select type (entry) type is (entry_t) current_entry => entry current_entry%first => entry call get_nlo_evt_ptr (current_entry, evt, mode) if (mode > EVT_NLO_SEPARATE_BORNLIKE) then allocate (evt%particle_set_radiated (n_phs + 1)) evt%event_deps%n_phs = n_phs evt%qcd = entry%qcd do i = 1, n_phs allocate (current_entry%next) current_entry%next%first => current_entry%first current_entry => current_entry%next call entry%copy_entry (current_entry) current_entry%i_event = i end do else allocate (evt%particle_set_radiated (1)) end if end select contains subroutine get_nlo_evt_ptr (entry, evt, mode) type(entry_t), intent(in), target :: entry type(evt_nlo_t), intent(out), pointer :: evt integer, intent(out) :: mode class(evt_t), pointer :: current_evt evt => null () current_evt => entry%transform_first do select type (current_evt) type is (evt_nlo_t) evt => current_evt mode = evt%mode exit end select if (associated (current_evt%next)) then current_evt => current_evt%next else call msg_fatal ("evt_nlo not in list of event transforms") end if end do end subroutine get_nlo_evt_ptr end subroutine entry_setup_additional_entries @ %def entry_setup_additional_entries @ <>= procedure :: get_first => entry_get_first <>= function entry_get_first (entry) result (entry_out) class(entry_t), intent(in), target :: entry type(entry_t), pointer :: entry_out entry_out => null () select type (entry) type is (entry_t) if (entry%is_nlo ()) then entry_out => entry%first else entry_out => entry end if end select end function entry_get_first @ %def entry_get_first @ <>= procedure :: get_next => entry_get_next <>= function entry_get_next (entry) result (next_entry) class(entry_t), intent(in) :: entry type(entry_t), pointer :: next_entry next_entry => null () if (associated (entry%next)) then next_entry => entry%next else call msg_fatal ("Get next entry: No next entry") end if end function entry_get_next @ %def entry_get_next @ <>= procedure :: count_nlo_entries => entry_count_nlo_entries <>= function entry_count_nlo_entries (entry) result (n) class(entry_t), intent(in), target :: entry integer :: n type(entry_t), pointer :: current_entry n = 1 if (.not. associated (entry%next)) then return else current_entry => entry%next do n = n + 1 if (.not. associated (current_entry%next)) exit current_entry => current_entry%next end do end if end function entry_count_nlo_entries @ %def entry_count_nlo_entries @ <>= procedure :: reset_nlo_counter => entry_reset_nlo_counter <>= subroutine entry_reset_nlo_counter (entry) class(entry_t), intent(inout) :: entry class(evt_t), pointer :: evt evt => entry%transform_first do select type (evt) type is (evt_nlo_t) evt%i_evaluation = 0 exit end select if (associated (evt%next)) evt => evt%next end do end subroutine entry_reset_nlo_counter @ %def entry_reset_nlo_counter @ <>= procedure :: determine_if_powheg_matching => entry_determine_if_powheg_matching <>= subroutine entry_determine_if_powheg_matching (entry) class(entry_t), intent(inout) :: entry class(evt_t), pointer :: current_transform if (associated (entry%transform_first)) then current_transform => entry%transform_first do select type (current_transform) type is (evt_shower_t) if (current_transform%contains_powheg_matching ()) & entry%evt_powheg => current_transform exit end select if (associated (current_transform%next)) then current_transform => current_transform%next else exit end if end do end if end subroutine entry_determine_if_powheg_matching @ %def entry_determine_if_powheg_matching -@ Part of simulation-entry initialization: dispatch event transforms +@ +\subsubsection{Event-transform initialization} +Part of simulation-entry initialization: dispatch event transforms (decay, shower) as requested. If a transform is not applicable or switched off via some variable, it will be skipped. Regarding resonances/decays: these two transforms are currently mutually exclusive. Resonance insertion will not be applied if there is an unstable particle in the game. <>= procedure, private :: setup_event_transforms & => entry_setup_event_transforms <>= subroutine entry_setup_event_transforms (entry, process, local) class(entry_t), intent(inout) :: entry type(process_t), intent(inout), target :: process type(rt_data_t), intent(in), target :: local class(evt_t), pointer :: evt type(var_list_t), pointer :: var_list logical :: enable_isr_handler logical :: enable_epa_handler logical :: enable_fixed_order logical :: enable_shower character(len=7) :: sample_normalization var_list => local%get_var_list_ptr () enable_isr_handler = local%get_lval (var_str ("?isr_handler")) enable_epa_handler = local%get_lval (var_str ("?epa_handler")) if (enable_isr_handler .or. enable_epa_handler) then call dispatch_evt_isr_epa_handler (evt, local%var_list) if (associated (evt)) call entry%import_transform (evt) end if if (process%contains_unstable (local%model)) then call dispatch_evt_decay (evt, local%var_list) if (associated (evt)) call entry%import_transform (evt) else if (entry%resonant_subprocess_set%is_active ()) then call dispatch_evt_resonance (evt, local%var_list, & entry%resonant_subprocess_set%get_resonance_history_set (), & entry%resonant_subprocess_set%get_libname ()) if (associated (evt)) then call entry%resonant_subprocess_set%connect_transform (evt) call entry%resonant_subprocess_set%set_on_shell_limit & (local%get_rval (var_str ("resonance_on_shell_limit"))) call entry%resonant_subprocess_set%set_on_shell_turnoff & (local%get_rval (var_str ("resonance_on_shell_turnoff"))) call entry%resonant_subprocess_set%set_background_factor & (local%get_rval (var_str ("resonance_background_factor"))) call entry%import_transform (evt) end if end if enable_fixed_order = local%get_lval (var_str ("?fixed_order_nlo_events")) if (enable_fixed_order) then if (local%get_lval (var_str ("?unweighted"))) & call msg_fatal ("NLO Fixed Order events have to be generated with & &?unweighted = false") sample_normalization = local%get_sval (var_str ("$sample_normalization")) if ( sample_normalization /= "sigma" .and. sample_normalization /= "auto" ) & call msg_fatal ('For NLO Fixed Order events only $sample_normalization = & &"sigma" is supported.') call dispatch_evt_nlo (evt, local%get_lval (var_str ("?keep_failed_events"))) call entry%import_transform (evt) end if enable_shower = local%get_lval (var_str ("?allow_shower")) .and. & (local%get_lval (var_str ("?ps_isr_active")) & .or. local%get_lval (var_str ("?ps_fsr_active")) & .or. local%get_lval (var_str ("?muli_active")) & .or. local%get_lval (var_str ("?mlm_matching")) & .or. local%get_lval (var_str ("?ckkw_matching")) & .or. local%get_lval (var_str ("?powheg_matching"))) if (enable_shower) then call dispatch_evt_shower (evt, var_list, local%model, & local%fallback_model, local%os_data, local%beam_structure, & process) call entry%import_transform (evt) end if if (local%get_lval (var_str ("?hadronization_active"))) then call dispatch_evt_hadrons (evt, var_list, local%fallback_model) call entry%import_transform (evt) end if end subroutine entry_setup_event_transforms @ %def entry_setup_event_transforms -@ Compute weights. The integral in the argument is the sum of integrals for +@ +\subsubsection{Process/MCI selector} +Compute weights. The integral in the argument is the sum of integrals for all processes in the sample. After computing the process weights, we repeat the normalization procedure for the process components. <>= procedure :: init_mci_selector => entry_init_mci_selector <>= subroutine entry_init_mci_selector (entry, negative_weights) class(entry_t), intent(inout), target :: entry logical, intent(in), optional :: negative_weights type(entry_t), pointer :: current_entry integer :: i, j, k if (debug_on) call msg_debug (D_CORE, "entry_init_mci_selector") if (entry%has_integral) then select type (entry) type is (entry_t) current_entry => entry do j = 1, current_entry%count_nlo_entries () if (j > 1) current_entry => current_entry%get_next () do k = 1, size(current_entry%mci_sets%integral) if (debug_on) call msg_debug (D_CORE, "current_entry%mci_sets(k)%integral", & current_entry%mci_sets(k)%integral) end do call current_entry%mci_selector%init & (current_entry%mci_sets%integral, negative_weights) do i = 1, current_entry%n_mci current_entry%mci_sets(i)%weight_mci = & current_entry%mci_selector%get_weight (i) end do end do end select end if end subroutine entry_init_mci_selector @ %def entry_init_mci_selector @ Select a MCI entry, using the embedded random-number generator. <>= procedure :: select_mci => entry_select_mci <>= function entry_select_mci (entry) result (i_mci) class(entry_t), intent(inout) :: entry integer :: i_mci if (debug_on) call msg_debug2 (D_CORE, "entry_select_mci") i_mci = entry%process%extract_active_component_mci () if (i_mci == 0) call entry%mci_selector%generate (entry%rng, i_mci) if (debug_on) call msg_debug2 (D_CORE, "i_mci", i_mci) end function entry_select_mci @ %def entry_select_mci -@ Record an event for this entry, i.e., increment the appropriate counters. +@ +\subsubsection{Entries: event-wise updates} +Record an event for this entry, i.e., increment the appropriate counters. <>= procedure :: record => entry_record <>= subroutine entry_record (entry, i_mci, from_file) class(entry_t), intent(inout) :: entry integer, intent(in) :: i_mci logical, intent(in), optional :: from_file real(default) :: weight, excess integer :: n_dropped weight = entry%get_weight_prc () excess = entry%get_excess_prc () n_dropped = entry%get_n_dropped () call entry%counter%record (weight, excess, n_dropped, from_file) if (i_mci > 0) then call entry%mci_sets(i_mci)%counter%record (weight, excess) end if end subroutine entry_record @ %def entry_record @ Update and restore the process core that this entry accesses, when parameters change. If explicit arguments [[model]], [[qcd]], or [[helicity_selection]] are provided, use those. Otherwise use the parameters stored in the process object. These two procedures come with a caching mechanism which guarantees that the current core object is saved when calling [[update_process]], and restored by calling [[restore_process]]. If the flag [[saved]] is unset, saving is skipped, and the [[restore]] procedure should not be called. <>= procedure :: update_process => entry_update_process procedure :: restore_process => entry_restore_process <>= subroutine entry_update_process & (entry, model, qcd, helicity_selection, saved) class(entry_t), intent(inout) :: entry class(model_data_t), intent(in), optional, target :: model type(qcd_t), intent(in), optional :: qcd type(helicity_selection_t), intent(in), optional :: helicity_selection logical, intent(in), optional :: saved type(process_t), pointer :: process class(prc_core_t), allocatable :: core integer :: i, n_terms class(model_data_t), pointer :: model_local type(qcd_t) :: qcd_local logical :: use_saved if (present (model)) then model_local => model else model_local => entry%model end if if (present (qcd)) then qcd_local = qcd else qcd_local = entry%qcd end if use_saved = .true.; if (present (saved)) use_saved = saved process => entry%get_process_ptr () n_terms = process%get_n_terms () if (use_saved) allocate (entry%core_safe (n_terms)) do i = 1, n_terms if (process%has_matrix_element (i, is_term_index = .true.)) then call process%extract_core (i, core) if (use_saved) then call dispatch_core_update (core, & model_local, helicity_selection, qcd_local, & entry%core_safe(i)%core) else call dispatch_core_update (core, & model_local, helicity_selection, qcd_local) end if call process%restore_core (i, core) end if end do end subroutine entry_update_process subroutine entry_restore_process (entry) class(entry_t), intent(inout) :: entry type(process_t), pointer :: process class(prc_core_t), allocatable :: core integer :: i, n_terms process => entry%get_process_ptr () n_terms = process%get_n_terms () do i = 1, n_terms if (process%has_matrix_element (i, is_term_index = .true.)) then call process%extract_core (i, core) call dispatch_core_restore (core, entry%core_safe(i)%core) call process%restore_core (i, core) end if end do deallocate (entry%core_safe) end subroutine entry_restore_process @ %def entry_update_process @ %def entry_restore_process <>= procedure :: connect_qcd => entry_connect_qcd <>= subroutine entry_connect_qcd (entry) class(entry_t), intent(inout), target :: entry class(evt_t), pointer :: evt evt => entry%transform_first do while (associated (evt)) select type (evt) type is (evt_shower_t) evt%qcd = entry%qcd if (allocated (evt%matching)) then evt%matching%qcd = entry%qcd end if end select evt => evt%next end do end subroutine entry_connect_qcd @ %def entry_connect_qcd @ \subsection{Handling resonant subprocesses} Resonant subprocesses are required if we want to determine resonance histories when generating events. The feature is optional, to be switched on by the user. This procedure initializes a new, separate process library that contains copies of the current process, restricted to the relevant resonance histories. (If this library exists already, it is just kept.) The histories can be extracted from the process object. The code has to match the assignments in [[create_resonant_subprocess_library]]. The library may already exist -- in that case, here it will be recovered without recompilation. <>= procedure :: setup_resonant_subprocesses & => entry_setup_resonant_subprocesses <>= subroutine entry_setup_resonant_subprocesses (entry, global, process) class(entry_t), intent(inout) :: entry type(rt_data_t), intent(inout), target :: global type(process_t), intent(in), target :: process type(string_t) :: libname type(resonance_history_set_t) :: res_history_set type(process_library_t), pointer :: lib type(process_component_def_t), pointer :: process_component_def logical :: req_resonant, library_exist integer :: i_component libname = process%get_library_name () lib => global%prclib_stack%get_library_ptr (libname) entry%has_resonant_subprocess_set = lib%req_resonant (process%get_id ()) if (entry%has_resonant_subprocess_set) then libname = get_libname_res (process%get_id ()) call entry%resonant_subprocess_set%init (process%get_n_components ()) call entry%resonant_subprocess_set%create_library & (libname, global, library_exist) do i_component = 1, process%get_n_components () call process%extract_resonance_history_set & (res_history_set, i_component = i_component) call entry%resonant_subprocess_set%fill_resonances & (res_history_set, i_component) if (.not. library_exist) then process_component_def & => process%get_component_def_ptr (i_component) call entry%resonant_subprocess_set%add_to_library & (i_component, & process_component_def%get_prt_spec_in (), & process_component_def%get_prt_spec_out (), & global) end if end do call entry%resonant_subprocess_set%freeze_library (global) end if end subroutine entry_setup_resonant_subprocesses @ %def entry_setup_resonant_subprocesses @ Compile the resonant-subprocesses library. The library is assumed to be the current library in the [[global]] object. This is a simple wrapper. <>= procedure :: compile_resonant_subprocesses & => entry_compile_resonant_subprocesses <>= subroutine entry_compile_resonant_subprocesses (entry, global) class(entry_t), intent(inout) :: entry type(rt_data_t), intent(inout), target :: global call entry%resonant_subprocess_set%compile_library (global) end subroutine entry_compile_resonant_subprocesses @ %def entry_compile_resonant_subprocesses @ Prepare process objects for the resonant-subprocesses library. The process objects are appended to the global process stack. We initialize the processes, such that we can evaluate matrix elements, but we do not need to integrate them. <>= procedure :: prepare_resonant_subprocesses & => entry_prepare_resonant_subprocesses <>= subroutine entry_prepare_resonant_subprocesses (entry, local, global) class(entry_t), intent(inout) :: entry type(rt_data_t), intent(inout), target :: local type(rt_data_t), intent(inout), optional, target :: global call entry%resonant_subprocess_set%prepare_process_objects (local, global) end subroutine entry_prepare_resonant_subprocesses @ %def entry_prepare_resonant_subprocesses @ Prepare process instances. They are linked to their corresponding process objects. Both, process and instance objects, are allocated as anonymous targets inside the [[resonant_subprocess_set]] component. NOTE: those anonymous object are likely forgotten during finalization of the parent [[event_t]] (extended as [[entry_t]]) object. This should be checked! The memory leak is probably harmless as long as the event object is created once per run, not once per event. <>= procedure :: prepare_resonant_subprocess_instances & => entry_prepare_resonant_subprocess_instances <>= subroutine entry_prepare_resonant_subprocess_instances (entry, global) class(entry_t), intent(inout) :: entry type(rt_data_t), intent(in), target :: global call entry%resonant_subprocess_set%prepare_process_instances (global) end subroutine entry_prepare_resonant_subprocess_instances @ %def entry_prepare_resonant_subprocess_instances @ Display the resonant subprocesses. This includes, upon request, the resonance set that defines those subprocess, and a short or long account of the process objects themselves. <>= procedure :: write_resonant_subprocess_data & => entry_write_resonant_subprocess_data <>= subroutine entry_write_resonant_subprocess_data (entry, unit) class(entry_t), intent(in) :: entry integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit) call entry%resonant_subprocess_set%write (unit) write (u, "(1x,A,I0)") "Resonant subprocesses refer to & &process component #", 1 end subroutine entry_write_resonant_subprocess_data @ %def entry_write_resonant_subprocess_data @ Display of the master process for the current event, for diagnostics. <>= procedure :: write_process_data => entry_write_process_data <>= subroutine entry_write_process_data & (entry, unit, show_process, show_instance, verbose) class(entry_t), intent(in) :: entry integer, intent(in), optional :: unit logical, intent(in), optional :: show_process logical, intent(in), optional :: show_instance logical, intent(in), optional :: verbose integer :: u, i logical :: s_proc, s_inst, verb type(process_t), pointer :: process type(process_instance_t), pointer :: instance u = given_output_unit (unit) s_proc = .false.; if (present (show_process)) s_proc = show_process s_inst = .false.; if (present (show_instance)) s_inst = show_instance verb = .false.; if (present (verbose)) verb = verbose if (s_proc .or. s_inst) then write (u, "(1x,A,':')") "Process data" if (s_proc) then process => entry%process if (associated (process)) then if (verb) then call write_separator (u, 2) call process%write (.false., u) else call process%show (u, verbose=.false.) end if else write (u, "(3x,A)") "[not associated]" end if end if if (s_inst) then instance => entry%instance if (associated (instance)) then if (verb) then call instance%write (u) else call instance%write_header (u) end if else write (u, "(3x,A)") "Process instance: [not associated]" end if end if end if end subroutine entry_write_process_data @ %def entry_write_process_data @ \subsection{Entries for alternative environment} Entries for alternate environments. [No additional components anymore, so somewhat redundant.] <>= type, extends (entry_t) :: alt_entry_t contains <> end type alt_entry_t @ %def alt_entry_t - The alternative entries are there to re-evaluate the event, given +@ The alternative entries are there to re-evaluate the event, given momenta, in a different context. Therefore, we allocate a local process object and use this as the reference for the local process instance, when initializing the entry. We temporarily import the [[process]] object into an [[integration_t]] wrapper, to take advantage of the associated methods. The local process object is built in the context of the current environment, here called [[global]]. Then, we initialize the process instance. The [[master_process]] object contains the integration results to which we refer when recalculating an event. Therefore, we use this object instead of the locally built [[process]] when we extract the integration results. The locally built [[process]] object should be finalized when done. It remains accessible via the [[event_t]] base object of [[entry]], which contains pointers to the process and instance. <>= procedure :: init_alt => alt_entry_init <>= subroutine alt_entry_init (entry, process_id, master_process, local) class(alt_entry_t), intent(inout), target :: entry type(string_t), intent(in) :: process_id type(process_t), intent(in), target :: master_process type(rt_data_t), intent(inout), target :: local type(process_t), pointer :: process type(process_instance_t), pointer :: process_instance type(string_t) :: run_id integer :: i call msg_message ("Simulate: initializing alternate process setup ...") run_id = & local%var_list%get_sval (var_str ("$run_id")) call local%set_log (var_str ("?rebuild_phase_space"), & .false., is_known = .true.) call local%set_log (var_str ("?check_phs_file"), & .false., is_known = .true.) call local%set_log (var_str ("?rebuild_grids"), & .false., is_known = .true.) call entry%basic_init (local%var_list) call prepare_local_process (process, process_id, local) entry%process_id = process_id entry%run_id = run_id call entry%import_process_characteristics (process) allocate (entry%mci_sets (entry%n_mci)) do i = 1, size (entry%mci_sets) call entry%mci_sets(i)%init (i, master_process) end do call entry%import_process_results (master_process) call entry%prepare_expressions (local) call prepare_process_instance (process_instance, process, local%model) call entry%setup_event_transforms (process, local) call entry%connect (process_instance, local%model, local%process_stack) call entry%setup_expressions () entry%model => process%get_model_ptr () call msg_message ("... alternate process setup complete.") end subroutine alt_entry_init @ %def alt_entry_init @ Copy the particle set from the master entry to the alternate entry. This is the particle set of the hard process. <>= procedure :: fill_particle_set => entry_fill_particle_set <>= subroutine entry_fill_particle_set (alt_entry, entry) class(alt_entry_t), intent(inout) :: alt_entry class(entry_t), intent(in), target :: entry type(particle_set_t) :: pset call entry%get_hard_particle_set (pset) call alt_entry%set_hard_particle_set (pset) call pset%final () end subroutine entry_fill_particle_set @ %def particle_set_copy_prt @ -\subsection{The simulation type} +\subsection{The simulation object} Each simulation object corresponds to an event sample, identified by the [[sample_id]]. The simulation may cover several processes simultaneously. All process-specific data, including the event records, are stored in the [[entry]] subobjects. The [[current]] index indicates which record was selected last. [[version]] is foreseen to contain a tag on the \whizard\ event file version. It can be <>= public :: simulation_t <>= type :: simulation_t private type(rt_data_t), pointer :: local => null () type(string_t) :: sample_id logical :: unweighted = .true. logical :: negative_weights = .false. logical :: support_resonance_history = .false. logical :: respect_selection = .true. integer :: norm_mode = NORM_UNDEFINED logical :: update_sqme = .false. logical :: update_weight = .false. logical :: update_event = .false. logical :: recover_beams = .false. logical :: pacify = .false. integer :: n_max_tries = 10000 integer :: n_prc = 0 integer :: n_alt = 0 logical :: has_integral = .false. logical :: valid = .false. real(default) :: integral = 0 real(default) :: error = 0 integer :: version = 1 character(32) :: md5sum_prc = "" character(32) :: md5sum_cfg = "" character(32), dimension(:), allocatable :: md5sum_alt type(entry_t), dimension(:), allocatable :: entry type(alt_entry_t), dimension(:,:), allocatable :: alt_entry type(selector_t) :: process_selector integer :: n_evt_requested = 0 integer :: event_index_offset = 0 logical :: event_index_set = .false. integer :: event_index = 0 integer :: split_n_evt = 0 integer :: split_n_kbytes = 0 integer :: split_index = 0 type(counter_t) :: counter class(rng_t), allocatable :: rng integer :: i_prc = 0 integer :: i_mci = 0 real(default) :: weight = 0 real(default) :: excess = 0 integer :: n_dropped = 0 contains <> end type simulation_t @ %def simulation_t -@ Output. [[write_config]] writes just the configuration. [[write]] +@ +\subsubsection{Output of the simulation data} +[[write_config]] writes just the configuration. [[write]] as a method of the base type [[event_t]] writes the current event and process instance, depending on options. <>= procedure :: write => simulation_write <>= subroutine simulation_write (object, unit, testflag) class(simulation_t), intent(in) :: object integer, intent(in), optional :: unit logical, intent(in), optional :: testflag logical :: pacified integer :: u, i u = given_output_unit (unit) pacified = object%pacify; if (present (testflag)) pacified = testflag call write_separator (u, 2) write (u, "(1x,A,A,A)") "Event sample: '", char (object%sample_id), "'" write (u, "(3x,A,I0)") "Processes = ", object%n_prc if (object%n_alt > 0) then write (u, "(3x,A,I0)") "Alt.wgts = ", object%n_alt end if write (u, "(3x,A,L1)") "Unweighted = ", object%unweighted write (u, "(3x,A,A)") "Event norm = ", & char (event_normalization_string (object%norm_mode)) write (u, "(3x,A,L1)") "Neg. weights = ", object%negative_weights write (u, "(3x,A,L1)") "Res. history = ", object%support_resonance_history write (u, "(3x,A,L1)") "Respect sel. = ", object%respect_selection write (u, "(3x,A,L1)") "Update sqme = ", object%update_sqme write (u, "(3x,A,L1)") "Update wgt = ", object%update_weight write (u, "(3x,A,L1)") "Update event = ", object%update_event write (u, "(3x,A,L1)") "Recov. beams = ", object%recover_beams write (u, "(3x,A,L1)") "Pacify = ", object%pacify write (u, "(3x,A,I0)") "Max. tries = ", object%n_max_tries if (object%has_integral) then if (pacified) then write (u, "(3x,A," // FMT_15 // ")") & "Integral = ", object%integral write (u, "(3x,A," // FMT_15 // ")") & "Error = ", object%error else write (u, "(3x,A," // FMT_19 // ")") & "Integral = ", object%integral write (u, "(3x,A," // FMT_19 // ")") & "Error = ", object%error end if else write (u, "(3x,A)") "Integral = [undefined]" end if write (u, "(3x,A,L1)") "Sim. valid = ", object%valid write (u, "(3x,A,I0)") "Ev.file ver. = ", object%version if (object%md5sum_prc /= "") then write (u, "(3x,A,A,A)") "MD5 sum (proc) = '", object%md5sum_prc, "'" end if if (object%md5sum_cfg /= "") then write (u, "(3x,A,A,A)") "MD5 sum (config) = '", object%md5sum_cfg, "'" end if write (u, "(3x,A,I0)") "Events requested = ", object%n_evt_requested if (object%event_index_offset /= 0) then write (u, "(3x,A,I0)") "Event index offset= ", object%event_index_offset end if if (object%event_index_set) then write (u, "(3x,A,I0)") "Event index = ", object%event_index end if if (object%split_n_evt > 0 .or. object%split_n_kbytes > 0) then write (u, "(3x,A,I0)") "Events per file = ", object%split_n_evt write (u, "(3x,A,I0)") "KBytes per file = ", object%split_n_kbytes write (u, "(3x,A,I0)") "First file index = ", object%split_index end if call object%counter%write (u) call write_separator (u) if (object%i_prc /= 0) then write (u, "(1x,A)") "Current event:" write (u, "(3x,A,I0,A,A)") "Process #", & object%i_prc, ": ", & char (object%entry(object%i_prc)%process_id) write (u, "(3x,A,I0)") "MCI set #", object%i_mci write (u, "(3x,A," // FMT_19 // ")") "Weight = ", object%weight if (.not. vanishes (object%excess)) & write (u, "(3x,A," // FMT_19 // ")") "Excess = ", object%excess write (u, "(3x,A,I0)") "Zero-weight events dropped = ", object%n_dropped else write (u, "(1x,A,I0,A,A)") "Current event: [undefined]" end if call write_separator (u) if (allocated (object%rng)) then call object%rng%write (u) else write (u, "(3x,A)") "Random-number generator: [undefined]" end if if (allocated (object%entry)) then do i = 1, size (object%entry) if (i == 1) then call write_separator (u, 2) else call write_separator (u) end if write (u, "(1x,A,I0,A)") "Process #", i, ":" call object%entry(i)%write_config (u, pacified) end do end if call write_separator (u, 2) end subroutine simulation_write @ %def simulation_write @ Write the current event record. If an explicit index is given, write that event record. We implement writing to [[unit]] (event contents / debugging format) and writing to an [[eio]] event stream (storage). We include a [[testflag]] in order to suppress numerical noise in the testsuite. <>= generic :: write_event => write_event_unit procedure :: write_event_unit => simulation_write_event_unit <>= subroutine simulation_write_event_unit & (object, unit, i_prc, verbose, testflag) class(simulation_t), intent(in) :: object integer, intent(in), optional :: unit logical, intent(in), optional :: verbose integer, intent(in), optional :: i_prc logical, intent(in), optional :: testflag logical :: pacified integer :: current pacified = .false.; if (present(testflag)) pacified = testflag pacified = pacified .or. object%pacify if (present (i_prc)) then current = i_prc else current = object%i_prc end if if (current > 0) then call object%entry(current)%write (unit, verbose = verbose, & testflag = pacified) else call msg_fatal ("Simulation: write event: no process selected") end if end subroutine simulation_write_event_unit @ %def simulation_write_event @ This writes one of the alternate events, if allocated. <>= procedure :: write_alt_event => simulation_write_alt_event <>= subroutine simulation_write_alt_event (object, unit, j_alt, i_prc, & verbose, testflag) class(simulation_t), intent(in) :: object integer, intent(in), optional :: unit integer, intent(in), optional :: j_alt integer, intent(in), optional :: i_prc logical, intent(in), optional :: verbose logical, intent(in), optional :: testflag integer :: i, j if (present (j_alt)) then j = j_alt else j = 1 end if if (present (i_prc)) then i = i_prc else i = object%i_prc end if if (i > 0) then if (j> 0 .and. j <= object%n_alt) then call object%alt_entry(i,j)%write (unit, verbose = verbose, & testflag = testflag) else call msg_fatal ("Simulation: write alternate event: out of range") end if else call msg_fatal ("Simulation: write alternate event: no process selected") end if end subroutine simulation_write_alt_event @ %def simulation_write_alt_event @ This writes the contents of the resonant subprocess set in the current event record. <>= procedure :: write_resonant_subprocess_data & => simulation_write_resonant_subprocess_data <>= subroutine simulation_write_resonant_subprocess_data (object, unit, i_prc) class(simulation_t), intent(in) :: object integer, intent(in), optional :: unit integer, intent(in), optional :: i_prc integer :: i if (present (i_prc)) then i = i_prc else i = object%i_prc end if call object%entry(i)%write_resonant_subprocess_data (unit) end subroutine simulation_write_resonant_subprocess_data @ %def simulation_write_resonant_subprocess_data @ The same for the master process, as an additional debugging aid. <>= procedure :: write_process_data & => simulation_write_process_data <>= subroutine simulation_write_process_data & (object, unit, i_prc, & show_process, show_instance, verbose) class(simulation_t), intent(in) :: object integer, intent(in), optional :: unit integer, intent(in), optional :: i_prc logical, intent(in), optional :: show_process logical, intent(in), optional :: show_instance logical, intent(in), optional :: verbose integer :: i if (present (i_prc)) then i = i_prc else i = object%i_prc end if call object%entry(i)%write_process_data & (unit, show_process, show_instance, verbose) end subroutine simulation_write_process_data @ %def simulation_write_process_data -@ Finalizer. +@ Write the actual efficiency of the simulation run. We get the total +number of events stored in the simulation counter and compare this +with the total number of calls stored in the event entries. + +In order not to miscount samples that are partly read from file, use +the [[generated]] counter, not the [[total]] counter. +<>= + procedure :: show_efficiency => simulation_show_efficiency +<>= + subroutine simulation_show_efficiency (simulation) + class(simulation_t), intent(inout) :: simulation + integer :: n_events, n_calls + real(default) :: eff + n_events = simulation%counter%generated + n_calls = sum (simulation%entry%get_actual_calls_total ()) + if (n_calls > 0) then + eff = real (n_events, kind=default) / n_calls + write (msg_buffer, "(A,1x,F6.2,1x,A)") & + "Events: actual unweighting efficiency =", 100 * eff, "%" + call msg_message () + end if + end subroutine simulation_show_efficiency + +@ %def simulation_show_efficiency +@ Compute the checksum of the process set. We retrieve the MD5 sums +of all processes. This depends only on the process definitions, while +parameters are not considered. The configuration checksum is +retrieved from the MCI records in the process objects and furthermore +includes beams, parameters, integration results, etc., so matching the +latter should guarantee identical physics. +<>= + procedure :: compute_md5sum => simulation_compute_md5sum +<>= + subroutine simulation_compute_md5sum (simulation) + class(simulation_t), intent(inout) :: simulation + type(process_t), pointer :: process + type(string_t) :: buffer + integer :: j, i, n_mci, i_mci, n_component, i_component + if (simulation%md5sum_prc == "") then + buffer = "" + do i = 1, simulation%n_prc + if (.not. simulation%entry(i)%valid) cycle + process => simulation%entry(i)%get_process_ptr () + if (associated (process)) then + n_component = process%get_n_components () + do i_component = 1, n_component + if (process%has_matrix_element (i_component)) then + buffer = buffer // process%get_md5sum_prc (i_component) + end if + end do + end if + end do + simulation%md5sum_prc = md5sum (char (buffer)) + end if + if (simulation%md5sum_cfg == "") then + buffer = "" + do i = 1, simulation%n_prc + if (.not. simulation%entry(i)%valid) cycle + process => simulation%entry(i)%get_process_ptr () + if (associated (process)) then + n_mci = process%get_n_mci () + do i_mci = 1, n_mci + buffer = buffer // process%get_md5sum_mci (i_mci) + end do + end if + end do + simulation%md5sum_cfg = md5sum (char (buffer)) + end if + do j = 1, simulation%n_alt + if (simulation%md5sum_alt(j) == "") then + buffer = "" + do i = 1, simulation%n_prc + process => simulation%alt_entry(i,j)%get_process_ptr () + if (associated (process)) then + buffer = buffer // process%get_md5sum_cfg () + end if + end do + simulation%md5sum_alt(j) = md5sum (char (buffer)) + end if + end do + end subroutine simulation_compute_md5sum + +@ %def simulation_compute_md5sum +@ +\subsubsection{Simulation-object finalizer} <>= procedure :: final => simulation_final <>= subroutine simulation_final (object) class(simulation_t), intent(inout) :: object integer :: i, j if (allocated (object%entry)) then do i = 1, size (object%entry) call object%entry(i)%final () end do end if if (allocated (object%alt_entry)) then do j = 1, size (object%alt_entry, 2) do i = 1, size (object%alt_entry, 1) call object%alt_entry(i,j)%final () end do end do end if if (allocated (object%rng)) call object%rng%final () end subroutine simulation_final @ %def simulation_final -@ Initialization. We can deduce all data from the given list of +@ +\subsubsection{Simulation-object initialization} +We can deduce all data from the given list of process IDs and the global data set. The process objects are taken from the stack. Once the individual integrals are known, we add them (and the errors), to get the sample integral. If there are alternative environments, we suspend initialization for setting up alternative process objects, then restore the master process and its parameters. The generator or rescanner can then switch rapidly between processes. If [[integrate]] is set, we make sure that all affected processes are integrated before simulation. This is necessary if we want to actually generate events. If [[integrate]] is unset, we do not need the integral because we just rescan existing events. In that case, we just need compiled matrix elements. If [[generate]] is set, we prepare for actually generating events. Otherwise, we may only read and rescan events. <>= procedure :: init => simulation_init <>= subroutine simulation_init (simulation, & process_id, integrate, generate, local, global, alt_env) class(simulation_t), intent(out), target :: simulation type(string_t), dimension(:), intent(in) :: process_id logical, intent(in) :: integrate, generate type(rt_data_t), intent(inout), target :: local type(rt_data_t), intent(inout), optional, target :: global type(rt_data_t), dimension(:), intent(inout), optional, target :: alt_env class(rng_factory_t), allocatable :: rng_factory integer :: next_rng_seed type(string_t) :: norm_string, version_string logical :: use_process integer :: i, j type(string_t) :: sample_suffix - <> + <> sample_suffix = "" - <> + <> simulation%local => local simulation%sample_id = & - local%get_sval (var_str ("$sample")) // sample_suffix + local%get_sval (var_str ("$sample")) simulation%unweighted = & local%get_lval (var_str ("?unweighted")) simulation%negative_weights = & local%get_lval (var_str ("?negative_weights")) simulation%support_resonance_history = & local%get_lval (var_str ("?resonance_history")) simulation%respect_selection = & local%get_lval (var_str ("?sample_select")) version_string = & local%get_sval (var_str ("$event_file_version")) norm_string = & local%get_sval (var_str ("$sample_normalization")) simulation%norm_mode = & event_normalization_mode (norm_string, simulation%unweighted) simulation%pacify = & local%get_lval (var_str ("?sample_pacify")) simulation%event_index_offset = & local%get_ival (var_str ("event_index_offset")) simulation%n_max_tries = & local%get_ival (var_str ("sample_max_tries")) simulation%split_n_evt = & local%get_ival (var_str ("sample_split_n_evt")) simulation%split_n_kbytes = & local%get_ival (var_str ("sample_split_n_kbytes")) simulation%split_index = & local%get_ival (var_str ("sample_split_index")) simulation%update_sqme = & local%get_lval (var_str ("?update_sqme")) simulation%update_weight = & local%get_lval (var_str ("?update_weight")) simulation%update_event = & local%get_lval (var_str ("?update_event")) simulation%recover_beams = & local%get_lval (var_str ("?recover_beams")) simulation%counter%reproduce_xsection = & local%get_lval (var_str ("?check_event_weights_against_xsection")) use_process = & integrate .or. generate & .or. simulation%update_sqme & .or. simulation%update_weight & .or. simulation%update_event & .or. present (alt_env) select case (size (process_id)) case (0) call msg_error ("Simulation: no process selected") case (1) write (msg_buffer, "(A,A,A)") & "Starting simulation for process '", & char (process_id(1)), "'" call msg_message () case default write (msg_buffer, "(A,A,A)") & "Starting simulation for processes '", & char (process_id(1)), "' etc." call msg_message () end select select case (char (version_string)) case ("", "2.2.4") simulation%version = 2 case ("2.2") simulation%version = 1 case default simulation%version = 0 end select if (simulation%version == 0) then call msg_fatal ("Event file format '" & // char (version_string) & // "' is not compatible with this version.") end if simulation%n_prc = size (process_id) allocate (simulation%entry (simulation%n_prc)) if (present (alt_env)) then simulation%n_alt = size (alt_env) do i = 1, simulation%n_prc call simulation%entry(i)%init (process_id(i), & use_process, integrate, generate, & simulation%update_sqme, & simulation%support_resonance_history, & local, global, simulation%n_alt) if (signal_is_pending ()) return end do simulation%valid = any (simulation%entry%valid) if (.not. simulation%valid) then call msg_error ("Simulate: no process has a valid matrix element.") return end if call simulation%update_processes () allocate (simulation%alt_entry (simulation%n_prc, simulation%n_alt)) allocate (simulation%md5sum_alt (simulation%n_alt)) simulation%md5sum_alt = "" do j = 1, simulation%n_alt do i = 1, simulation%n_prc call simulation%alt_entry(i,j)%init_alt (process_id(i), & simulation%entry(i)%get_process_ptr (), alt_env(j)) if (signal_is_pending ()) return end do end do call simulation%restore_processes () else do i = 1, simulation%n_prc call simulation%entry(i)%init & (process_id(i), & use_process, integrate, generate, & simulation%update_sqme, & simulation%support_resonance_history, & local, global) call simulation%entry(i)%determine_if_powheg_matching () if (signal_is_pending ()) return if (simulation%entry(i)%is_nlo ()) & call simulation%entry(i)%setup_additional_entries () end do simulation%valid = any (simulation%entry%valid) if (.not. simulation%valid) then call msg_error ("Simulate: " & // "no process has a valid matrix element.") return end if end if !!! if this becomes conditional, some ref files will need update (seed change) ! if (generate) then call dispatch_rng_factory (rng_factory, local%var_list, next_rng_seed) call update_rng_seed_in_var_list (local%var_list, next_rng_seed) call rng_factory%make (simulation%rng) - <> + <> ! end if if (all (simulation%entry%has_integral)) then simulation%integral = sum (simulation%entry%integral) simulation%error = sqrt (sum (simulation%entry%error ** 2)) simulation%has_integral = .true. if (integrate .and. generate) then do i = 1, simulation%n_prc if (simulation%entry(i)%integral < 0 .and. .not. & simulation%negative_weights) then call msg_fatal ("Integral of process '" // & char (process_id (i)) // "'is negative.") end if end do end if else if (integrate .and. generate) & call msg_error ("Simulation contains undefined integrals.") end if if (simulation%integral > 0 .or. & (simulation%integral < 0 .and. simulation%negative_weights)) then simulation%valid = .true. else if (generate) then call msg_error ("Simulate: " & // "sum of process integrals must be positive; skipping.") simulation%valid = .false. else simulation%valid = .true. end if + if (simulation%sample_id == "") then + simulation%sample_id = simulation%get_default_sample_name () + end if + simulation%sample_id = simulation%sample_id // sample_suffix if (simulation%valid) call simulation%compute_md5sum () end subroutine simulation_init @ %def simulation_init -@ -<>= +@ The RNG initialization depends on serial/MPI mode. +<>= +<>= integer :: rank, n_size -@ -<>= +<>= +<>= call mpi_get_comm_id (n_size, rank) if (n_size > 1) then sample_suffix = var_str ("_") // str (rank) end if -@ -<>= +<>= +<>= do i = 2, rank + 1 select type (rng => simulation%rng) type is (rng_stream_t) call rng%next_substream () if (i == rank) & call msg_message ("Simulate: Advance RNG for parallel event generation") class default - call msg_bug ("Use of any random number generator & - &beside rng_stream for parallel event generation not supported.") + call rng%write () + call msg_bug ("Parallel event generation: random-number generator & + &must be 'rng_stream'.") end select end do -@ @ The number of events that we want to simulate is determined by the settings of [[n_events]], [[luminosity]], and [[?unweighted]]. For weighted events, we take [[n_events]] at face value as the number of matrix element calls. For unweighted events, if the process is a decay, [[n_events]] is the number of unweighted events. In these cases, the luminosity setting is ignored. For unweighted events with a scattering process, we calculate the event number that corresponds to the luminosity, given the current value of the integral. We then compare this with [[n_events]] and choose the larger number. <>= procedure :: compute_n_events => simulation_compute_n_events <>= - subroutine simulation_compute_n_events (simulation, n_events, var_list) + subroutine simulation_compute_n_events (simulation, n_events) class(simulation_t), intent(in) :: simulation integer, intent(out) :: n_events - type(var_list_t) :: var_list real(default) :: lumi, x_events_lumi integer :: n_events_lumi logical :: is_scattering n_events = & - var_list%get_ival (var_str ("n_events")) + simulation%local%get_ival (var_str ("n_events")) lumi = & - var_list%get_rval (var_str ("luminosity")) + simulation%local%get_rval (var_str ("luminosity")) if (simulation%unweighted) then is_scattering = simulation%entry(1)%n_in == 2 if (is_scattering) then x_events_lumi = abs (simulation%integral * lumi) if (x_events_lumi < huge (n_events)) then n_events_lumi = nint (x_events_lumi) else call msg_message ("Simulation: luminosity too large, & &limiting number of events") n_events_lumi = huge (n_events) end if if (n_events_lumi > n_events) then call msg_message ("Simulation: using n_events as computed from & &luminosity value") n_events = n_events_lumi else write (msg_buffer, "(A,1x,I0)") & "Simulation: requested number of events =", n_events call msg_message () if (.not. vanishes (simulation%integral)) then write (msg_buffer, "(A,1x,ES11.4)") & " corr. to luminosity [fb-1] = ", & n_events / simulation%integral call msg_message () end if end if end if end if end subroutine simulation_compute_n_events @ %def simulation_compute_n_events -@ Write the actual efficiency of the simulation run. We get the total -number of events stored in the simulation counter and compare this -with the total number of calls stored in the event entries. - -In order not to miscount samples that are partly read from file, use -the [[generated]] counter, not the [[total]] counter. +@ Configuration of the OpenMP parameters, in case OpenMP is active. We use +the settings accessible via the local environment. <>= - procedure :: show_efficiency => simulation_show_efficiency + procedure :: setup_openmp => simulation_setup_openmp <>= - subroutine simulation_show_efficiency (simulation) + subroutine simulation_setup_openmp (simulation) class(simulation_t), intent(inout) :: simulation - integer :: n_events, n_calls - real(default) :: eff - n_events = simulation%counter%generated - n_calls = sum (simulation%entry%get_actual_calls_total ()) - if (n_calls > 0) then - eff = real (n_events, kind=default) / n_calls - write (msg_buffer, "(A,1x,F6.2,1x,A)") & - "Events: actual unweighting efficiency =", 100 * eff, "%" - call msg_message () + + call openmp_set_num_threads_verbose & + (simulation%local%get_ival (var_str ("openmp_num_threads")), & + simulation%local%get_lval (var_str ("?openmp_logging"))) + + end subroutine simulation_setup_openmp + +@ %def simulation_setup_openmp +@ Configuration of the event-stream array -- i.e., the setup of +output file formats. +<>= + procedure :: prepare_event_streams => simulation_prepare_event_streams +<>= + subroutine simulation_prepare_event_streams (sim, es_array) + class(simulation_t), intent(inout) :: sim + type(event_stream_array_t), intent(out) :: es_array + + integer :: n_events + logical :: rebuild_events, read_raw, write_raw + integer :: checkpoint, callback + integer :: n_fmt + type(event_sample_data_t) :: data + type(string_t), dimension(:), allocatable :: sample_fmt + + n_events = & + sim%n_evt_requested + rebuild_events = & + sim%local%get_lval (var_str ("?rebuild_events")) + read_raw = & + sim%local%get_lval (var_str ("?read_raw")) .and. .not. rebuild_events + write_raw = & + sim%local%get_lval (var_str ("?write_raw")) + checkpoint = & + sim%local%get_ival (var_str ("checkpoint")) + callback = & + sim%local%get_ival (var_str ("event_callback_interval")) + if (read_raw) then + inquire (file = char (sim%sample_id) // ".evx", exist = read_raw) end if - end subroutine simulation_show_efficiency + if (allocated (sim%local%sample_fmt)) then + n_fmt = size (sim%local%sample_fmt) + else + n_fmt = 0 + end if + data = sim%get_data () + data%n_evt = n_events + data%nlo_multiplier = sim%get_n_nlo_entries (1) + if (read_raw) then + allocate (sample_fmt (n_fmt)) + if (n_fmt > 0) sample_fmt = sim%local%sample_fmt + call es_array%init (sim%sample_id, & + sample_fmt, sim%local, & + data = data, & + input = var_str ("raw"), & + allow_switch = write_raw, & + checkpoint = checkpoint, & + callback = callback) + else if (write_raw) then + allocate (sample_fmt (n_fmt + 1)) + if (n_fmt > 0) sample_fmt(:n_fmt) = sim%local%sample_fmt + sample_fmt(n_fmt+1) = var_str ("raw") + call es_array%init (sim%sample_id, & + sample_fmt, sim%local, & + data = data, & + checkpoint = checkpoint, & + callback = callback) + else if (allocated (sim%local%sample_fmt) & + .or. checkpoint > 0 & + .or. callback > 0) then + allocate (sample_fmt (n_fmt)) + if (n_fmt > 0) sample_fmt = sim%local%sample_fmt + call es_array%init (sim%sample_id, & + sample_fmt, sim%local, & + data = data, & + checkpoint = checkpoint, & + callback = callback) + end if + end subroutine simulation_prepare_event_streams -@ %def simulation_show_efficiency +@ %def simulation_prepare_event_streams @ <>= procedure :: get_n_nlo_entries => simulation_get_n_nlo_entries <>= function simulation_get_n_nlo_entries (simulation, i_prc) result (n_extra) class(simulation_t), intent(in) :: simulation integer, intent(in) :: i_prc integer :: n_extra n_extra = simulation%entry(i_prc)%count_nlo_entries () end function simulation_get_n_nlo_entries @ %def simulation_get_n_nlo_entries -@ Compute the checksum of the process set. We retrieve the MD5 sums -of all processes. This depends only on the process definitions, while -parameters are not considered. The configuration checksum is -retrieved from the MCI records in the process objects and furthermore -includes beams, parameters, integration results, etc., so matching the -latter should guarantee identical physics. -<>= - procedure :: compute_md5sum => simulation_compute_md5sum -<>= - subroutine simulation_compute_md5sum (simulation) - class(simulation_t), intent(inout) :: simulation - type(process_t), pointer :: process - type(string_t) :: buffer - integer :: j, i, n_mci, i_mci, n_component, i_component - if (simulation%md5sum_prc == "") then - buffer = "" - do i = 1, simulation%n_prc - if (.not. simulation%entry(i)%valid) cycle - process => simulation%entry(i)%get_process_ptr () - if (associated (process)) then - n_component = process%get_n_components () - do i_component = 1, n_component - if (process%has_matrix_element (i_component)) then - buffer = buffer // process%get_md5sum_prc (i_component) - end if - end do - end if - end do - simulation%md5sum_prc = md5sum (char (buffer)) - end if - if (simulation%md5sum_cfg == "") then - buffer = "" - do i = 1, simulation%n_prc - if (.not. simulation%entry(i)%valid) cycle - process => simulation%entry(i)%get_process_ptr () - if (associated (process)) then - n_mci = process%get_n_mci () - do i_mci = 1, n_mci - buffer = buffer // process%get_md5sum_mci (i_mci) - end do - end if - end do - simulation%md5sum_cfg = md5sum (char (buffer)) - end if - do j = 1, simulation%n_alt - if (simulation%md5sum_alt(j) == "") then - buffer = "" - do i = 1, simulation%n_prc - process => simulation%alt_entry(i,j)%get_process_ptr () - if (associated (process)) then - buffer = buffer // process%get_md5sum_cfg () - end if - end do - simulation%md5sum_alt(j) = md5sum (char (buffer)) - end if - end do - end subroutine simulation_compute_md5sum - -@ %def simulation_compute_md5sum @ Initialize the process selector, using the entry integrals as process weights. <>= procedure :: init_process_selector => simulation_init_process_selector <>= subroutine simulation_init_process_selector (simulation) class(simulation_t), intent(inout) :: simulation integer :: i if (simulation%has_integral) then call simulation%process_selector%init (simulation%entry%integral, & negative_weights = simulation%negative_weights) do i = 1, simulation%n_prc associate (entry => simulation%entry(i)) if (.not. entry%valid) then call msg_warning ("Process '" // char (entry%process_id) // & "': matrix element vanishes, no events can be generated.") cycle end if call entry%init_mci_selector (simulation%negative_weights) entry%process_weight = simulation%process_selector%get_weight (i) end associate end do end if end subroutine simulation_init_process_selector @ %def simulation_init_process_selector @ Select a process, using the random-number generator. <>= procedure :: select_prc => simulation_select_prc <>= function simulation_select_prc (simulation) result (i_prc) class(simulation_t), intent(inout) :: simulation integer :: i_prc call simulation%process_selector%generate (simulation%rng, i_prc) end function simulation_select_prc @ %def simulation_select_prc @ Select a MCI set for the selected process. <>= procedure :: select_mci => simulation_select_mci <>= function simulation_select_mci (simulation) result (i_mci) class(simulation_t), intent(inout) :: simulation integer :: i_mci i_mci = 0 if (simulation%i_prc /= 0) then i_mci = simulation%entry(simulation%i_prc)%select_mci () end if end function simulation_select_mci @ %def simulation_select_mci +@ +\subsubsection{Generate-event loop} +The requested number of events should be set by this, in time for the +event-array initializers that may use this number. <>= - procedure, private :: startup_message_generate => simulation_startup_message_generate + procedure :: set_n_events_requested => simulation_set_n_events_requested + procedure :: get_n_events_requested => simulation_get_n_events_requested +<>= + subroutine simulation_set_n_events_requested (simulation, n) + class(simulation_t), intent(inout) :: simulation + integer, intent(in) :: n + + simulation%n_evt_requested = n + + end subroutine simulation_set_n_events_requested + + function simulation_get_n_events_requested (simulation) result (n) + class(simulation_t), intent(in) :: simulation + integer :: n + + n = simulation%n_evt_requested + + end function simulation_get_n_events_requested + +@ %def simulation_set_n_events_requested +@ %def simulation_get_n_events_requested +@ Generate the number of events that has been set by +[[simulation_set_n_events_requested]]. First select a process and a component +set, then generate an event for that process and factorize the quantum state. +The pair of random numbers can be used for factorization. + +When generating events, we drop all configurations where the event is +marked as incomplete. This happens if the event fails cuts. In fact, +such events are dropped already by the sampler if unweighting is in +effect, so this can happen only for weighted events. By setting a +limit given by [[sample_max_tries]] (user parameter), we can avoid an +endless loop. + +The [[begin_it]] and [[end_it]] limits are equal to 1 and the number of +events, repspectively, in serial mode, but differ for MPI mode. + +TODO: When reading from file, event transforms cannot be applied because the +process instance will not be complete. (?) +<>= + procedure :: generate => simulation_generate +<>= + subroutine simulation_generate (simulation, es_array) + class(simulation_t), intent(inout), target :: simulation + type(event_stream_array_t), intent(inout), optional :: es_array + + integer :: begin_it, end_it + integer :: i, j, k + + call simulation%before_first_event (begin_it, end_it, es_array) + do i = begin_it, end_it + call simulation%next_event (es_array) + end do + call simulation%after_last_event (begin_it, end_it) + + end subroutine simulation_generate + +@ %def simulation_generate +@ The header of the event loop: with all necessary information present in the +[[simulation]] and [[es_array]] objects, and given a number of events [[n]] to +generate, we prepare for actually generating/reading/writing events. + +The procedure returns the real iteration bounds [[begin_it]] and [[end_it]] +for the event loop. This is nontrivial only for MPI; in serial mode those are +equal to 1 and to [[n_events]], respectively. +<>= + procedure :: before_first_event => simulation_before_first_event +<>= + subroutine simulation_before_first_event (simulation, begin_it, end_it, & + es_array) + class(simulation_t), intent(inout), target :: simulation + integer, intent(out) :: begin_it + integer, intent(out) :: end_it + type(event_stream_array_t), intent(inout), optional :: es_array + + integer :: n_evt_requested + logical :: has_input + integer :: n_events_print + logical :: is_leading_order + logical :: is_weighted + logical :: is_polarized + + n_evt_requested = simulation%n_evt_requested + n_events_print = n_evt_requested * simulation%get_n_nlo_entries (1) + is_leading_order = (n_events_print == n_evt_requested) + + has_input = .false. + if (present (es_array)) has_input = es_array%has_input () + + is_weighted = .not. simulation%entry(1)%config%unweighted + is_polarized = simulation%entry(1)%config%factorization_mode & + /= FM_IGNORE_HELICITY + + call simulation%startup_message_generate ( & + has_input = has_input, & + is_weighted = is_weighted, & + is_polarized = is_polarized, & + is_leading_order = is_leading_order, & + n_events = n_events_print) + + call simulation%entry%set_n (n_evt_requested) + if (simulation%n_alt > 0) call simulation%alt_entry%set_n (n_evt_requested) + call simulation%init_event_index () + + begin_it = 1 + end_it = n_evt_requested + <> + + end subroutine simulation_before_first_event + +@ %def simulation_before_first_event +@ Keep the user informed: +<>= + procedure, private :: startup_message_generate & + => simulation_startup_message_generate <>= subroutine simulation_startup_message_generate (simulation, & has_input, is_weighted, is_polarized, is_leading_order, n_events) class(simulation_t), intent(in) :: simulation logical, intent(in) :: has_input logical, intent(in) :: is_weighted logical, intent(in) :: is_polarized logical, intent(in) :: is_leading_order integer, intent(in) :: n_events + type(string_t) :: str1, str2, str3, str4 + if (has_input) then str1 = "Events: reading" else str1 = "Events: generating" end if if (is_weighted) then str2 = "weighted" else str2 = "unweighted" end if if (is_polarized) then str3 = ", polarized" else str3 = ", unpolarized" end if str4 = "" if (.not. is_leading_order) str4 = " NLO" + write (msg_buffer, "(A,1X,I0,1X,A,1X,A)") char (str1), n_events, & char (str2) // char(str3) // char(str4), "events ..." call msg_message () + write (msg_buffer, "(A,1x,A)") "Events: event normalization mode", & char (event_normalization_string (simulation%norm_mode)) call msg_message () - end subroutine simulation_startup_message_generate -@ Generate a predefined number of events. First select a process and -a component set, then generate an event for that process and factorize -the quantum state. The pair of random numbers can be used for -factorization. - -When generating events, we drop all configurations where the event is -marked as incomplete. This happens if the event fails cuts. In fact, -such events are dropped already by the sampler if unweighting is in -effect, so this can happen only for weighted events. By setting a -limit given by [[sample_max_tries]] (user parameter), we can avoid an -endless loop. + end subroutine simulation_startup_message_generate -NB: When reading from file, event transforms can't be applied because the -process instance will not be complete. This should be fixed. +@ %def simulation_startup_message_generate +@ +The body of the event loop: generate and process a single event. + +Optionally transfer the current event to one of the provided event handles, +for in and/or output streams. This works for any stream for which the I/O +stream type matches the event-handle type. <>= - procedure :: generate => simulation_generate + procedure :: next_event => simulation_next_event <>= - subroutine simulation_generate (simulation, n, es_array) - class(simulation_t), intent(inout), target :: simulation - integer, intent(in) :: n + subroutine simulation_next_event & + (simulation, es_array, event_handle_out, event_handle_in) + class(simulation_t), intent(inout) :: simulation type(event_stream_array_t), intent(inout), optional :: es_array - logical :: generate_new, passed - integer :: i, j, k, begin_it, end_it + class(event_handle_t), intent(inout), optional :: event_handle_out + class(event_handle_t), intent(inout), optional :: event_handle_in + type(entry_t), pointer :: current_entry - integer :: n_events_print - logical :: has_input, is_leading_order - has_input = .false.; if (present (es_array)) has_input = es_array%has_input () - n_events_print = n * simulation%get_n_nlo_entries (1) - is_leading_order = (n_events_print == n) - call simulation%startup_message_generate ( & - has_input = has_input, & - is_weighted = .not. simulation%entry(1)%config%unweighted, & - is_polarized = .not. (simulation%entry(1)%config%factorization_mode & - == FM_IGNORE_HELICITY), & - is_leading_order = is_leading_order, & - n_events = n_events_print) - simulation%n_evt_requested = n - call simulation%entry%set_n (n) - if (simulation%n_alt > 0) call simulation%alt_entry%set_n (n) - call simulation%init_event_index () - begin_it = 1; end_it = n - <> - do i = begin_it, end_it - call simulation%increment_event_index () - if (present (es_array)) then - call simulation%read_event (es_array, .true., generate_new) - else - generate_new = .true. - end if - if (generate_new) then - simulation%i_prc = simulation%select_prc () - simulation%i_mci = simulation%select_mci () - associate (entry => simulation%entry(simulation%i_prc)) - entry%instance%i_mci = simulation%i_mci - call entry%set_active_real_components () - current_entry => entry%get_first () - do k = 1, current_entry%count_nlo_entries () - if (k > 1) then - current_entry => current_entry%get_next () - current_entry%particle_set => current_entry%first%particle_set - current_entry%particle_set_is_valid & - = current_entry%first%particle_set_is_valid - end if - do j = 1, simulation%n_max_tries - if (.not. current_entry%valid) call msg_warning & - ("Process '" // char (current_entry%process_id) // "': " // & - "matrix element vanishes, no events can be generated.") - call current_entry%generate (simulation%i_mci, i_nlo = k) - if (signal_is_pending ()) return - call simulation%counter%record_mean_and_variance & - (current_entry%weight_prc, k) - if (current_entry%has_valid_particle_set ()) exit - end do - end do - if (entry%is_nlo ()) call entry%reset_nlo_counter () - if (.not. entry%has_valid_particle_set ()) then - write (msg_buffer, "(A,I0,A)") "Simulation: failed to & - &generate valid event after ", & - simulation%n_max_tries, " tries (sample_max_tries)" - call msg_fatal () + logical :: generate_new + logical :: passed + integer :: j, k + + call simulation%increment_event_index () + + if (present (es_array)) then + call simulation%read_event & + (es_array, .true., generate_new, event_handle_in) + else + generate_new = .true. + end if + + if (generate_new) then + simulation%i_prc = simulation%select_prc () + simulation%i_mci = simulation%select_mci () + + associate (entry => simulation%entry(simulation%i_prc)) + + entry%instance%i_mci = simulation%i_mci + call entry%set_active_real_components () + current_entry => entry%get_first () + + do k = 1, current_entry%count_nlo_entries () + if (k > 1) then + current_entry => current_entry%get_next () + current_entry%particle_set => current_entry%first%particle_set + current_entry%particle_set_is_valid & + = current_entry%first%particle_set_is_valid end if - current_entry => entry%get_first () - do k = 1, current_entry%count_nlo_entries () - if (k > 1) current_entry => current_entry%get_next () - call current_entry%set_index (simulation%get_event_index ()) - call current_entry%evaluate_expressions () + do j = 1, simulation%n_max_tries + if (.not. current_entry%valid) call msg_warning & + ("Process '" // char (current_entry%process_id) // "': " // & + "matrix element vanishes, no events can be generated.") + call current_entry%generate (simulation%i_mci, i_nlo = k) + if (signal_is_pending ()) return + call simulation%counter%record_mean_and_variance & + (current_entry%weight_prc, k) + if (current_entry%has_valid_particle_set ()) exit end do - if (signal_is_pending ()) return - simulation%n_dropped = entry%get_n_dropped () - if (entry%passed_selection ()) then - simulation%weight = entry%get_weight_ref () - simulation%excess = entry%get_excess_prc () - end if - call simulation%counter%record & - (simulation%weight, simulation%excess, simulation%n_dropped) - call entry%record (simulation%i_mci) - end associate - else - associate (entry => simulation%entry(simulation%i_prc)) - call simulation%set_event_index (entry%get_index ()) - call entry%accept_sqme_ref () - call entry%accept_weight_ref () - call entry%check () - call entry%evaluate_expressions () - if (signal_is_pending ()) return - simulation%n_dropped = entry%get_n_dropped () - if (entry%passed_selection ()) then - simulation%weight = entry%get_weight_ref () - simulation%excess = entry%get_excess_prc () - end if - call simulation%counter%record & - (simulation%weight, simulation%excess, simulation%n_dropped, from_file=.true.) - call entry%record (simulation%i_mci, from_file=.true.) - end associate - end if - call simulation%calculate_alt_entries () - if (signal_is_pending ()) return - if (simulation%pacify) call pacify (simulation) - if (simulation%respect_selection) then - passed = simulation%entry(simulation%i_prc)%passed_selection () - else - passed = .true. - end if - if (present (es_array)) then - call simulation%write_event (es_array, passed) - end if - end do + end do + if (entry%is_nlo ()) call entry%reset_nlo_counter () + + if (.not. entry%has_valid_particle_set ()) then + write (msg_buffer, "(A,I0,A)") "Simulation: failed to & + &generate valid event after ", & + simulation%n_max_tries, " tries (sample_max_tries)" + call msg_fatal () + end if + + current_entry => entry%get_first () + do k = 1, current_entry%count_nlo_entries () + if (k > 1) current_entry => current_entry%get_next () + call current_entry%set_index (simulation%get_event_index ()) + call current_entry%evaluate_expressions () + end do + if (signal_is_pending ()) return + + simulation%n_dropped = entry%get_n_dropped () + if (entry%passed_selection ()) then + simulation%weight = entry%get_weight_ref () + simulation%excess = entry%get_excess_prc () + end if + call simulation%counter%record & + (simulation%weight, simulation%excess, simulation%n_dropped) + call entry%record (simulation%i_mci) + + end associate + + else + + associate (entry => simulation%entry(simulation%i_prc)) + + call simulation%set_event_index (entry%get_index ()) + call entry%accept_sqme_ref () + call entry%accept_weight_ref () + call entry%check () + call entry%evaluate_expressions () + if (signal_is_pending ()) return + + simulation%n_dropped = entry%get_n_dropped () + if (entry%passed_selection ()) then + simulation%weight = entry%get_weight_ref () + simulation%excess = entry%get_excess_prc () + end if + call simulation%counter%record & + (simulation%weight, simulation%excess, simulation%n_dropped, & + from_file=.true.) + call entry%record (simulation%i_mci, from_file=.true.) + + end associate + + end if + + call simulation%calculate_alt_entries () + if (simulation%pacify) call pacify (simulation) + if (signal_is_pending ()) return + + if (simulation%respect_selection) then + passed = simulation%entry(simulation%i_prc)%passed_selection () + else + passed = .true. + end if + if (present (es_array)) then + call simulation%write_event (es_array, passed, event_handle_out) + end if + + end subroutine simulation_next_event + +@ %def simulation_next_event +@ Cleanup after last event: compute and show summary information. +<>= + procedure :: after_last_event => simulation_after_last_event +<>= + subroutine simulation_after_last_event (simulation, begin_it, end_it) + class(simulation_t), intent(inout) :: simulation + integer, intent(in) :: begin_it, end_it + call msg_message (" ... event sample complete.") - <> + <> + if (simulation%unweighted) call simulation%show_efficiency () call simulation%counter%show_excess () call simulation%counter%show_dropped () call simulation%counter%show_mean_and_variance () - end subroutine simulation_generate -@ %def simulation_generate -@ -<>= -@ -<>= - call simulation%init_event_loop (n, begin_it, end_it) -@ -<>= + end subroutine simulation_after_last_event + +@ %def simulation_after_last_event @ -<>= - call simulation%finalize_event_loop (n, begin_it, end_it) -@ We iterate over [[1:n]]. -However, for the MPI event generation this interval is split up into intervals of [[n_workers]]. +\subsubsection{MPI additions} +Below, we define code chunks that differ between the serial and MPI versions. + +Extra logging for MPI only. +<>= + procedure :: activate_extra_logging => simulation_activate_extra_logging +<>= + subroutine simulation_activate_extra_logging (simulation) + class(simulation_t), intent(in) :: simulation + <> + end subroutine simulation_activate_extra_logging + +<>= +<>= + logical :: mpi_logging + integer :: rank, n_size + call mpi_get_comm_id (n_size, rank) + mpi_logging = & + (simulation%local%get_sval (var_str ("$integration_method")) == "vamp2" & + .and. n_size > 1) & + .or. simulation%local%get_lval (var_str ("?mpi_logging")) + call mpi_set_logging (mpi_logging) +@ %def simulation_activate_extra_logging +@ +Extra subroutine to be called before the first event: +<>= +<>= + call simulation%init_event_loop_mpi (n_evt_requested, begin_it, end_it) +@ +Extra subroutine to be called after the last event: +<>= +<>= + call simulation%final_event_loop_mpi (begin_it, end_it) +@ +For MPI event generation, the event-loop interval (1\dots n) is split up +into intervals of [[n_workers]]. <>= - procedure, private :: init_event_loop => simulation_init_event_loop + procedure, private :: init_event_loop_mpi => simulation_init_event_loop_mpi <>= - subroutine simulation_init_event_loop (simulation, n_events, begin_it, end_it) + subroutine simulation_init_event_loop_mpi & + (simulation, n_events, begin_it, end_it) class(simulation_t), intent(inout) :: simulation integer, intent(in) :: n_events integer, intent(out) :: begin_it, end_it + integer :: rank, n_workers + call MPI_COMM_SIZE (MPI_COMM_WORLD, n_workers) if (n_workers < 2) then begin_it = 1; end_it = n_events return end if call MPI_COMM_RANK (MPI_COMM_WORLD, rank) if (rank == 0) then call compute_and_scatter_intervals (n_events, begin_it, end_it) else call retrieve_intervals (begin_it, end_it) end if + !! Event index starts by 0 (before incrementing when the first event gets generated/read in). !! Proof: event_index_offset in [0, N], start_it in [1, N]. simulation%event_index_offset = simulation%event_index_offset + (begin_it - 1) call simulation%init_event_index () write (msg_buffer, "(A,I0,A,I0,A)") & & "MPI: generate events [", begin_it, ":", end_it, "]" call msg_message () - contains + + contains + subroutine compute_and_scatter_intervals (n_events, begin_it, end_it) integer, intent(in) :: n_events integer, intent(out) :: begin_it, end_it + integer, dimension(:), allocatable :: all_begin_it, all_end_it integer :: rank, n_workers, n_events_per_worker + call MPI_COMM_RANK (MPI_COMM_WORLD, rank) call MPI_COMM_SIZE (MPI_COMM_WORLD, n_workers) allocate (all_begin_it (n_workers), source = 1) allocate (all_end_it (n_workers), source = n_events) n_events_per_worker = floor (real (n_events, default) / n_workers) all_begin_it = [(1 + rank * n_events_per_worker, rank = 0, n_workers - 1)] all_end_it = [(rank * n_events_per_worker, rank = 1, n_workers)] all_end_it(n_workers) = n_events call MPI_SCATTER (all_begin_it, 1, MPI_INTEGER, begin_it, 1, MPI_INTEGER, 0, MPI_COMM_WORLD) call MPI_SCATTER (all_end_it, 1, MPI_INTEGER, end_it, 1, MPI_INTEGER, 0, MPI_COMM_WORLD) + end subroutine compute_and_scatter_intervals subroutine retrieve_intervals (begin_it, end_it) integer, intent(out) :: begin_it, end_it + integer :: local_begin_it, local_end_it + call MPI_SCATTER (local_begin_it, 1, MPI_INTEGER, begin_it, 1, MPI_INTEGER, 0, MPI_COMM_WORLD) call MPI_SCATTER (local_end_it, 1, MPI_INTEGER, end_it, 1, MPI_INTEGER, 0, MPI_COMM_WORLD) + end subroutine retrieve_intervals - end subroutine simulation_init_event_loop -@ + end subroutine simulation_init_event_loop_mpi + +@ %def simulation_init_event_loop_mpi +@ +Synchronize, reduce and collect stuff after the event loop has completed. <>= - procedure, private :: finalize_event_loop => simulation_finalize_event_loop + procedure, private :: final_event_loop_mpi => simulation_final_event_loop_mpi <>= - subroutine simulation_finalize_event_loop (simulation, n_events, begin_it, end_it) + subroutine simulation_final_event_loop_mpi (simulation, begin_it, end_it) class(simulation_t), intent(inout) :: simulation - integer, intent(in) :: n_events integer, intent(in) :: begin_it, end_it + integer :: n_workers, n_events_local, n_events_global + call MPI_Barrier (MPI_COMM_WORLD) call MPI_COMM_SIZE (MPI_COMM_WORLD, n_workers) if (n_workers < 2) return n_events_local = end_it - begin_it + 1 call MPI_ALLREDUCE (n_events_local, n_events_global, 1, MPI_INTEGER, MPI_SUM,& & MPI_COMM_WORLD) write (msg_buffer, "(2(A,1X,I0))") & "MPI: Number of generated events locally", n_events_local, " and in world", n_events_global call msg_message () call simulation%counter%allreduce_record () - end subroutine simulation_finalize_event_loop + + end subroutine simulation_final_event_loop_mpi +@ %def simulation_final_event_loop_mpi @ -@ Compute the event matrix element and weight for all alternative +\subsubsection{Alternate environments} +Compute the event matrix element and weight for all alternative environments, given the current event and selected process. We first copy the particle set, then temporarily update the process core with local parameters, recalculate everything, and restore the process core. The event weight is obtained by rescaling the original event weight with the ratio of the new and old [[sqme]] values. (In particular, if the old value was zero, the weight will stay zero.) Note: this may turn out to be inefficient because we always replace all parameters and recalculate everything, once for each event and environment. However, a more fine-grained control requires more code. In any case, while we may keep multiple process cores (which stay constant for a simulation run), we still have to update the external matrix element parameters event by event. The matrix element ``object'' is present only once. <>= procedure :: calculate_alt_entries => simulation_calculate_alt_entries <>= subroutine simulation_calculate_alt_entries (simulation) class(simulation_t), intent(inout) :: simulation real(default) :: factor real(default), dimension(:), allocatable :: sqme_alt, weight_alt integer :: n_alt, i, j i = simulation%i_prc n_alt = simulation%n_alt if (n_alt == 0) return allocate (sqme_alt (n_alt), weight_alt (n_alt)) associate (entry => simulation%entry(i)) do j = 1, n_alt if (signal_is_pending ()) return factor = entry%get_kinematical_weight () associate (alt_entry => simulation%alt_entry(i,j)) call alt_entry%update_process (saved=.false.) call alt_entry%select & (entry%get_i_mci (), entry%get_i_term (), entry%get_channel ()) call alt_entry%fill_particle_set (entry) call alt_entry%recalculate & (update_sqme = .true., & recover_beams = simulation%recover_beams, & weight_factor = factor) if (signal_is_pending ()) return call alt_entry%accept_sqme_prc () call alt_entry%update_normalization () call alt_entry%accept_weight_prc () call alt_entry%check () call alt_entry%set_index (simulation%get_event_index ()) call alt_entry%evaluate_expressions () if (signal_is_pending ()) return sqme_alt(j) = alt_entry%get_sqme_ref () if (alt_entry%passed_selection ()) then weight_alt(j) = alt_entry%get_weight_ref () end if end associate end do call entry%update_process (saved=.false.) call entry%set (sqme_alt = sqme_alt, weight_alt = weight_alt) call entry%check () call entry%store_alt_values () end associate end subroutine simulation_calculate_alt_entries @ %def simulation_calculate_alt_entries -@ Rescan an undefined number of events. +@ +These routines take care of temporary parameter redefinitions that +we want to take effect while recalculating the matrix elements. We +extract the core(s) of the processes that we are simulating, apply the +changes, and make sure that the changes are actually used. This is +the duty of [[dispatch_core_update]]. When done, we restore the +original versions using [[dispatch_core_restore]]. +<>= + procedure :: update_processes => simulation_update_processes + procedure :: restore_processes => simulation_restore_processes +<>= + subroutine simulation_update_processes (simulation, & + model, qcd, helicity_selection) + class(simulation_t), intent(inout) :: simulation + class(model_data_t), intent(in), optional, target :: model + type(qcd_t), intent(in), optional :: qcd + type(helicity_selection_t), intent(in), optional :: helicity_selection + integer :: i + do i = 1, simulation%n_prc + call simulation%entry(i)%update_process & + (model, qcd, helicity_selection) + end do + end subroutine simulation_update_processes + + subroutine simulation_restore_processes (simulation) + class(simulation_t), intent(inout) :: simulation + integer :: i + do i = 1, simulation%n_prc + call simulation%entry(i)%restore_process () + end do + end subroutine simulation_restore_processes + +@ %def simulation_update_processes +@ %def simulation_restore_processes +@ +\subsubsection{Rescan-Events Loop} +Rescan an undefined number of events. If [[update_event]] or [[update_sqme]] is set, we have to recalculate the event, starting from the particle set. If the latter is set, this includes the squared matrix element (i.e., the amplitude is evaluated). Otherwise, only kinematics and observables derived from it are recovered. If any of the update flags is set, we will come up with separate [[sqme_prc]] and [[weight_prc]] values. (The latter is only distinct if [[update_weight]] is set.) Otherwise, we accept the reference values. <>= procedure :: rescan => simulation_rescan <>= subroutine simulation_rescan (simulation, n, es_array, global) class(simulation_t), intent(inout) :: simulation integer, intent(in) :: n type(event_stream_array_t), intent(inout) :: es_array type(rt_data_t), intent(inout) :: global type(qcd_t) :: qcd type(string_t) :: str1, str2, str3 logical :: complete str1 = "Rescanning" if (simulation%entry(1)%config%unweighted) then str2 = "unweighted" else str2 = "weighted" end if simulation%n_evt_requested = n call simulation%entry%set_n (n) if (simulation%update_sqme .or. simulation%update_weight) then call dispatch_qcd (qcd, global%get_var_list_ptr (), global%os_data) call simulation%update_processes & (global%model, qcd, global%get_helicity_selection ()) str3 = "(process parameters updated) " else str3 = "" end if write (msg_buffer, "(A,1x,A,1x,A,A,A)") char (str1), char (str2), & "events ", char (str3), "..." call msg_message () call simulation%init_event_index () do call simulation%increment_event_index () call simulation%read_event (es_array, .false., complete) if (complete) exit if (simulation%update_event & .or. simulation%update_sqme & .or. simulation%update_weight) then call simulation%recalculate () if (signal_is_pending ()) return associate (entry => simulation%entry(simulation%i_prc)) call entry%update_normalization () if (simulation%update_event) then call entry%evaluate_transforms () end if call entry%check () call entry%evaluate_expressions () if (signal_is_pending ()) return simulation%n_dropped = entry%get_n_dropped () simulation%weight = entry%get_weight_prc () call simulation%counter%record & (simulation%weight, n_dropped=simulation%n_dropped, from_file=.true.) call entry%record (simulation%i_mci, from_file=.true.) end associate else associate (entry => simulation%entry(simulation%i_prc)) call entry%accept_sqme_ref () call entry%accept_weight_ref () call entry%check () call entry%evaluate_expressions () if (signal_is_pending ()) return simulation%n_dropped = entry%get_n_dropped () simulation%weight = entry%get_weight_ref () call simulation%counter%record & (simulation%weight, n_dropped=simulation%n_dropped, from_file=.true.) call entry%record (simulation%i_mci, from_file=.true.) end associate end if call simulation%calculate_alt_entries () if (signal_is_pending ()) return call simulation%write_event (es_array) end do call simulation%counter%show_dropped () if (simulation%update_sqme .or. simulation%update_weight) then call simulation%restore_processes () end if end subroutine simulation_rescan @ %def simulation_rescan -@ Here we handle the event index that is kept in the simulation record. The +@ +\subsubsection{Event index} +Here we handle the event index that is kept in the simulation record. The event index is valid for the current sample. When generating or reading events, we initialize the index with the offset that the user provides (if any) and increment it for each event that is generated or read from file. The event index is stored in the event-entry that is current for the event. If an event on file comes with its own index, that index overwrites the predefined one and also resets the index within the simulation record. The event index is not connected to the [[counter]] object. The counter is supposed to collect statistical information. The event index is a user-level object that is visible in event records and analysis expressions. <>= procedure :: init_event_index => simulation_init_event_index procedure :: increment_event_index => simulation_increment_event_index procedure :: set_event_index => simulation_set_event_index procedure :: get_event_index => simulation_get_event_index <>= subroutine simulation_init_event_index (simulation) class(simulation_t), intent(inout) :: simulation call simulation%set_event_index (simulation%event_index_offset) end subroutine simulation_init_event_index subroutine simulation_increment_event_index (simulation) class(simulation_t), intent(inout) :: simulation if (simulation%event_index_set) then simulation%event_index = simulation%event_index + 1 end if end subroutine simulation_increment_event_index subroutine simulation_set_event_index (simulation, i) class(simulation_t), intent(inout) :: simulation integer, intent(in) :: i simulation%event_index = i simulation%event_index_set = .true. end subroutine simulation_set_event_index function simulation_get_event_index (simulation) result (i) class(simulation_t), intent(in) :: simulation integer :: i if (simulation%event_index_set) then i = simulation%event_index else i = 0 end if end function simulation_get_event_index @ %def simulation_init_event_index @ %def simulation_increment_event_index @ %def simulation_set_event_index @ %def simulation_get_event_index @ -@ These routines take care of temporary parameter redefinitions that -we want to take effect while recalculating the matrix elements. We -extract the core(s) of the processes that we are simulating, apply the -changes, and make sure that the changes are actually used. This is -the duty of [[dispatch_core_update]]. When done, we restore the -original versions using [[dispatch_core_restore]]. +\subsection{Direct event access} +If we want to retrieve event information, we should expose the currently +selected event [[entry]] within the simulation object. We recall that this is +an extension of the (generic) [[event]] type. Assuming that we will restrict +this to read access, we return a pointer. <>= - procedure :: update_processes => simulation_update_processes - procedure :: restore_processes => simulation_restore_processes + procedure :: get_process_index => simulation_get_process_index + procedure :: get_event_ptr => simulation_get_event_ptr <>= - subroutine simulation_update_processes (simulation, & - model, qcd, helicity_selection) - class(simulation_t), intent(inout) :: simulation - class(model_data_t), intent(in), optional, target :: model - type(qcd_t), intent(in), optional :: qcd - type(helicity_selection_t), intent(in), optional :: helicity_selection - integer :: i - do i = 1, simulation%n_prc - call simulation%entry(i)%update_process & - (model, qcd, helicity_selection) - end do - end subroutine simulation_update_processes - - subroutine simulation_restore_processes (simulation) - class(simulation_t), intent(inout) :: simulation - integer :: i - do i = 1, simulation%n_prc - call simulation%entry(i)%restore_process () - end do - end subroutine simulation_restore_processes - -@ %def simulation_update_processes -@ %def simulation_restore_processes + function simulation_get_process_index (simulation) result (i_prc) + class(simulation_t), intent(in), target :: simulation + integer :: i_prc + + i_prc = simulation%i_prc + + end function simulation_get_process_index + + function simulation_get_event_ptr (simulation) result (event) + class(simulation_t), intent(in), target :: simulation + class(event_t), pointer :: event + + event => simulation%entry(simulation%i_prc) + + end function simulation_get_event_ptr + +@ %def simulation_get_process_index +@ %def simulation_get_event_ptr @ \subsection{Event Stream I/O} Write an event to a generic [[eio]] event stream. The process index must be selected, or the current index must be available. <>= generic :: write_event => write_event_eio procedure :: write_event_eio => simulation_write_event_eio <>= subroutine simulation_write_event_eio (object, eio, i_prc) class(simulation_t), intent(in) :: object class(eio_t), intent(inout) :: eio integer, intent(in), optional :: i_prc logical :: increased integer :: current if (present (i_prc)) then current = i_prc else current = object%i_prc end if if (current > 0) then if (object%split_n_evt > 0 .and. object%counter%total > 1) then if (mod (object%counter%total, object%split_n_evt) == 1) then call eio%split_out () end if else if (object%split_n_kbytes > 0) then call eio%update_split_count (increased) if (increased) call eio%split_out () end if call eio%output (object%entry(current)%event_t, current, pacify = object%pacify) else call msg_fatal ("Simulation: write event: no process selected") end if end subroutine simulation_write_event_eio @ %def simulation_write_event @ Read an event from a generic [[eio]] event stream. The event stream element must specify the process within the sample ([[i_prc]]), the MC group for this process ([[i_mci]]), the selected term ([[i_term]]), the selected MC integration [[channel]], and the particle set of the event. We may encounter EOF, which we indicate by storing 0 for the process index [[i_prc]]. An I/O error will be reported, and we also abort reading. <>= generic :: read_event => read_event_eio procedure :: read_event_eio => simulation_read_event_eio <>= subroutine simulation_read_event_eio (object, eio) class(simulation_t), intent(inout) :: object class(eio_t), intent(inout) :: eio integer :: iostat, current call eio%input_i_prc (current, iostat) select case (iostat) case (0) object%i_prc = current call eio%input_event (object%entry(current)%event_t, iostat) end select select case (iostat) case (:-1) object%i_prc = 0 object%i_mci = 0 case (1:) call msg_error ("Reading events: I/O error, aborting read") object%i_prc = 0 object%i_mci = 0 case default object%i_mci = object%entry(current)%get_i_mci () end select end subroutine simulation_read_event_eio @ %def simulation_read_event @ \subsection{Event Stream Array} Write an event using an array of event I/O streams. The process index must be selected, or the current index must be available. <>= generic :: write_event => write_event_es_array procedure :: write_event_es_array => simulation_write_event_es_array <>= - subroutine simulation_write_event_es_array (object, es_array, passed) + subroutine simulation_write_event_es_array & + (object, es_array, passed, event_handle) class(simulation_t), intent(in), target :: object class(event_stream_array_t), intent(inout) :: es_array logical, intent(in), optional :: passed + class(event_handle_t), intent(inout), optional :: event_handle integer :: i_prc, event_index integer :: i type(entry_t), pointer :: current_entry i_prc = object%i_prc if (i_prc > 0) then event_index = object%counter%total current_entry => object%entry(i_prc)%get_first () do i = 1, current_entry%count_nlo_entries () if (i > 1) current_entry => current_entry%get_next () call es_array%output (current_entry%event_t, i_prc, & - event_index, passed = passed, pacify = object%pacify) + event_index, & + passed = passed, & + pacify = object%pacify, & + event_handle = event_handle) end do else call msg_fatal ("Simulation: write event: no process selected") end if end subroutine simulation_write_event_es_array @ %def simulation_write_event @ Read an event using an array of event I/O streams. Reading is successful if there is an input stream within the array, and if a valid event can be read from that stream. If there is a stream, but EOF is passed when reading the first item, we switch the channel to output and return failure but no error message, such that new events can be appended to that stream. <>= generic :: read_event => read_event_es_array procedure :: read_event_es_array => simulation_read_event_es_array <>= - subroutine simulation_read_event_es_array (object, es_array, enable_switch, & - fail) + subroutine simulation_read_event_es_array & + (object, es_array, enable_switch, fail, event_handle) class(simulation_t), intent(inout), target :: object class(event_stream_array_t), intent(inout), target :: es_array logical, intent(in) :: enable_switch logical, intent(out) :: fail + class(event_handle_t), intent(inout), optional :: event_handle integer :: iostat, i_prc type(entry_t), pointer :: current_entry => null () integer :: i if (es_array%has_input ()) then fail = .false. call es_array%input_i_prc (i_prc, iostat) select case (iostat) case (0) object%i_prc = i_prc current_entry => object%entry(i_prc) do i = 1, current_entry%count_nlo_entries () if (i > 1) then call es_array%skip_eio_entry (iostat) current_entry => current_entry%get_next () end if call current_entry%set_index (object%get_event_index ()) - call es_array%input_event (current_entry%event_t, iostat) + call es_array%input_event & + (current_entry%event_t, iostat, event_handle) end do case (:-1) write (msg_buffer, "(A,1x,I0,1x,A)") & "... event file terminates after", & object%counter%read, "events." call msg_message () if (enable_switch) then call es_array%switch_inout () write (msg_buffer, "(A,1x,I0,1x,A)") & "Generating remaining ", & object%n_evt_requested - object%counter%read, "events ..." call msg_message () end if fail = .true. return end select select case (iostat) case (0) object%i_mci = object%entry(i_prc)%get_i_mci () case default write (msg_buffer, "(A,1x,I0,1x,A)") & "Reading events: I/O error, aborting read after", & object%counter%read, "events." call msg_error () object%i_prc = 0 object%i_mci = 0 fail = .true. end select else fail = .true. end if end subroutine simulation_read_event_es_array @ %def simulation_read_event @ \subsection{Recover event} Recalculate the process instance contents, given an event with known particle set. The indices for MC, term, and channel must be already set. The [[recalculate]] method of the selected entry will import the result into [[sqme_prc]] and [[weight_prc]]. If [[recover_phs]] is set (and false), do not attempt any phase-space calculation. Useful if we need only matrix elements (esp. testing); this flag is not stored in the simulation record. <>= procedure :: recalculate => simulation_recalculate <>= subroutine simulation_recalculate (simulation, recover_phs) class(simulation_t), intent(inout) :: simulation logical, intent(in), optional :: recover_phs integer :: i_prc i_prc = simulation%i_prc associate (entry => simulation%entry(i_prc)) if (simulation%update_weight) then call entry%recalculate & (update_sqme = simulation%update_sqme, & recover_beams = simulation%recover_beams, & recover_phs = recover_phs, & weight_factor = entry%get_kinematical_weight ()) else call entry%recalculate & (update_sqme = simulation%update_sqme, & recover_beams = simulation%recover_beams, & recover_phs = recover_phs) end if end associate end subroutine simulation_recalculate @ %def simulation_recalculate @ -\subsection{Extract contents} +\subsection{Extract contents of the simulation object} Return the MD5 sum that summarizes configuration and integration (but not the event file). Used for initializing the event streams. <>= procedure :: get_md5sum_prc => simulation_get_md5sum_prc procedure :: get_md5sum_cfg => simulation_get_md5sum_cfg procedure :: get_md5sum_alt => simulation_get_md5sum_alt <>= function simulation_get_md5sum_prc (simulation) result (md5sum) class(simulation_t), intent(in) :: simulation character(32) :: md5sum md5sum = simulation%md5sum_prc end function simulation_get_md5sum_prc function simulation_get_md5sum_cfg (simulation) result (md5sum) class(simulation_t), intent(in) :: simulation character(32) :: md5sum md5sum = simulation%md5sum_cfg end function simulation_get_md5sum_cfg function simulation_get_md5sum_alt (simulation, i) result (md5sum) class(simulation_t), intent(in) :: simulation integer, intent(in) :: i character(32) :: md5sum md5sum = simulation%md5sum_alt(i) end function simulation_get_md5sum_alt @ %def simulation_get_md5sum_prc @ %def simulation_get_md5sum_cfg -@ Return data that may be useful for writing event files. +@ +Return data that may be useful for writing event files. Usually we can refer to a previously integrated process, for which we can fetch a process pointer. Occasionally, we do not have this because we are just rescanning an externally generated file without calculation. For that situation, we generate our local beam data object using the current enviroment, or, in simple cases, just fetch the necessary data from the process definition and environment. <>= procedure :: get_data => simulation_get_data <>= function simulation_get_data (simulation, alt) result (sdata) class(simulation_t), intent(in) :: simulation logical, intent(in), optional :: alt type(event_sample_data_t) :: sdata type(process_t), pointer :: process type(beam_data_t), pointer :: beam_data type(beam_structure_t), pointer :: beam_structure type(flavor_t), dimension(:), allocatable :: flv integer :: n, i logical :: enable_alt, construct_beam_data real(default) :: sqrts class(model_data_t), pointer :: model logical :: decay_rest_frame type(string_t) :: process_id enable_alt = .true.; if (present (alt)) enable_alt = alt if (debug_on) call msg_debug (D_CORE, "simulation_get_data") if (debug_on) call msg_debug (D_CORE, "alternative setup", enable_alt) if (enable_alt) then call sdata%init (simulation%n_prc, simulation%n_alt) do i = 1, simulation%n_alt sdata%md5sum_alt(i) = simulation%get_md5sum_alt (i) end do else call sdata%init (simulation%n_prc) end if sdata%unweighted = simulation%unweighted sdata%negative_weights = simulation%negative_weights sdata%norm_mode = simulation%norm_mode process => simulation%entry(1)%get_process_ptr () if (associated (process)) then beam_data => process%get_beam_data_ptr () construct_beam_data = .false. else n = simulation%entry(1)%n_in sqrts = simulation%local%get_sqrts () beam_structure => simulation%local%beam_structure call beam_structure%check_against_n_in (n, construct_beam_data) if (construct_beam_data) then allocate (beam_data) model => simulation%local%model decay_rest_frame = & simulation%local%get_lval (var_str ("?decay_rest_frame")) call beam_data%init_structure (beam_structure, & sqrts, model, decay_rest_frame) else beam_data => null () end if end if if (associated (beam_data)) then n = beam_data%get_n_in () sdata%n_beam = n allocate (flv (n)) flv = beam_data%get_flavor () sdata%pdg_beam(:n) = flv%get_pdg () sdata%energy_beam(:n) = beam_data%get_energy () if (construct_beam_data) deallocate (beam_data) else n = simulation%entry(1)%n_in sdata%n_beam = n process_id = simulation%entry(1)%process_id call simulation%local%prclib%get_pdg_in_1 & (process_id, sdata%pdg_beam(:n)) sdata%energy_beam(:n) = sqrts / n end if do i = 1, simulation%n_prc if (.not. simulation%entry(i)%valid) cycle process => simulation%entry(i)%get_process_ptr () if (associated (process)) then sdata%proc_num_id(i) = process%get_num_id () else process_id = simulation%entry(i)%process_id sdata%proc_num_id(i) = simulation%local%prclib%get_num_id (process_id) end if if (sdata%proc_num_id(i) == 0) sdata%proc_num_id(i) = i if (simulation%entry(i)%has_integral) then sdata%cross_section(i) = simulation%entry(i)%integral sdata%error(i) = simulation%entry(i)%error end if end do sdata%total_cross_section = sum (sdata%cross_section) sdata%md5sum_prc = simulation%get_md5sum_prc () sdata%md5sum_cfg = simulation%get_md5sum_cfg () if (simulation%split_n_evt > 0 .or. simulation%split_n_kbytes > 0) then sdata%split_n_evt = simulation%split_n_evt sdata%split_n_kbytes = simulation%split_n_kbytes sdata%split_index = simulation%split_index end if end function simulation_get_data @ %def simulation_get_data @ Return a default name for the current event sample. This is the process ID of the first process. <>= procedure :: get_default_sample_name => simulation_get_default_sample_name <>= function simulation_get_default_sample_name (simulation) result (sample) class(simulation_t), intent(in) :: simulation type(string_t) :: sample type(process_t), pointer :: process sample = "whizard" if (simulation%n_prc > 0) then process => simulation%entry(1)%get_process_ptr () if (associated (process)) then sample = process%get_id () end if end if end function simulation_get_default_sample_name @ %def simulation_get_default_sample_name @ <>= procedure :: is_valid => simulation_is_valid <>= function simulation_is_valid (simulation) result (valid) class(simulation_t), intent(inout) :: simulation logical :: valid valid = simulation%valid end function simulation_is_valid @ %def simulation_is_valid @ Return the hard-interaction particle set for event entry [[i_prc]]. <>= procedure :: get_hard_particle_set => simulation_get_hard_particle_set <>= function simulation_get_hard_particle_set (simulation, i_prc) result (pset) class(simulation_t), intent(in) :: simulation integer, intent(in) :: i_prc type(particle_set_t) :: pset call simulation%entry(i_prc)%get_hard_particle_set (pset) end function simulation_get_hard_particle_set @ %def simulation_get_hard_particle_set @ \subsection{Auxiliary} Call pacify: eliminate numerical noise. <>= public :: pacify <>= interface pacify module procedure pacify_simulation end interface <>= subroutine pacify_simulation (simulation) class(simulation_t), intent(inout) :: simulation integer :: i, j i = simulation%i_prc if (i > 0) then call pacify (simulation%entry(i)) do j = 1, simulation%n_alt call pacify (simulation%alt_entry(i,j)) end do end if end subroutine pacify_simulation @ %def pacify_simulation @ Manually evaluate expressions for the currently selected process. This is used only in the unit tests. <>= procedure :: evaluate_expressions => simulation_evaluate_expressions <>= subroutine simulation_evaluate_expressions (simulation) class(simulation_t), intent(inout) :: simulation call simulation%entry(simulation%i_prc)%evaluate_expressions () end subroutine simulation_evaluate_expressions @ %def simulation_evaluate_expressions @ Manually evaluate event transforms for the currently selected process. This is used only in the unit tests. <>= procedure :: evaluate_transforms => simulation_evaluate_transforms <>= subroutine simulation_evaluate_transforms (simulation) class(simulation_t), intent(inout) :: simulation associate (entry => simulation%entry(simulation%i_prc)) call entry%evaluate_transforms () end associate end subroutine simulation_evaluate_transforms @ %def simulation_evaluate_transforms @ \subsection{Unit tests} Test module, followed by the stand-alone unit-test procedures. <<[[simulations_ut.f90]]>>= <> module simulations_ut use unit_tests use simulations_uti <> <> contains <> end module simulations_ut @ %def simulations_ut @ <<[[simulations_uti.f90]]>>= <> module simulations_uti <> use kinds, only: i64 <> use io_units use format_defs, only: FMT_10, FMT_12 use ifiles use lexers use parser use lorentz use flavors use interactions, only: reset_interaction_counter use process_libraries, only: process_library_t use prclib_stacks use phs_forests use event_base, only: generic_event_t use event_base, only: event_callback_t use particles, only: particle_set_t use eio_data use eio_base use eio_direct, only: eio_direct_t use eio_raw use eio_ascii use eio_dump use eio_callback use eval_trees use model_data, only: model_data_t use models use rt_data use event_streams use decays_ut, only: prepare_testbed use process, only: process_t use process_stacks, only: process_entry_t use process_configurations_ut, only: prepare_test_library use compilations, only: compile_library use integrations, only: integrate_process use simulations use restricted_subprocesses_uti, only: prepare_resonance_test_library <> <> <> contains <> <> end module simulations_uti @ %def simulations_uti @ API: driver for the unit tests below. <>= public :: simulations_test <>= subroutine simulations_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine simulations_test @ %def simulations_test @ \subsubsection{Initialization} Initialize a [[simulation_t]] object, including the embedded event records. <>= call test (simulations_1, "simulations_1", & "initialization", & u, results) <>= public :: simulations_1 <>= subroutine simulations_1 (u) integer, intent(in) :: u type(string_t) :: libname, procname1, procname2 type(rt_data_t), target :: global type(simulation_t), target :: simulation write (u, "(A)") "* Test output: simulations_1" write (u, "(A)") "* Purpose: initialize simulation" write (u, "(A)") write (u, "(A)") "* Initialize processes" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) libname = "simulation_1a" procname1 = "simulation_1p" call prepare_test_library (global, libname, 1, [procname1]) call compile_library (libname, global) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("single"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_log (var_str ("?recover_beams"), & .false., is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%it_list%init ([1], [1000]) call global%set_string (var_str ("$run_id"), & var_str ("simulations1"), is_known = .true.) call integrate_process (procname1, global, local_stack=.true.) procname2 = "sim_extra" call prepare_test_library (global, libname, 1, [procname2]) call compile_library (libname, global) call global%set_string (var_str ("$run_id"), & var_str ("simulations2"), is_known = .true.) write (u, "(A)") "* Initialize event generation" write (u, "(A)") call global%set_string (var_str ("$sample"), & var_str ("sim1"), is_known = .true.) call integrate_process (procname2, global, local_stack=.true.) call simulation%init ([procname1, procname2], .false., .true., global) call simulation%init_process_selector () call simulation%write (u) write (u, "(A)") write (u, "(A)") "* Write the event record for the first process" write (u, "(A)") call simulation%write_event (u, i_prc = 1) write (u, "(A)") write (u, "(A)") "* Cleanup" call simulation%final () call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: simulations_1" end subroutine simulations_1 @ %def simulations_1 @ \subsubsection{Weighted events} Generate events for a single process. <>= call test (simulations_2, "simulations_2", & "weighted events", & u, results) <>= public :: simulations_2 <>= subroutine simulations_2 (u) integer, intent(in) :: u type(string_t) :: libname, procname1 type(rt_data_t), target :: global type(simulation_t), target :: simulation type(event_sample_data_t) :: data write (u, "(A)") "* Test output: simulations_2" write (u, "(A)") "* Purpose: generate events for a single process" write (u, "(A)") write (u, "(A)") "* Initialize processes" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) libname = "simulation_2a" procname1 = "simulation_2p" call prepare_test_library (global, libname, 1, [procname1]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_events"), .true., intrinsic = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("single"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_log (var_str ("?recover_beams"), & .false., is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%it_list%init ([1], [1000]) call global%set_string (var_str ("$run_id"), & var_str ("simulations1"), is_known = .true.) call integrate_process (procname1, global, local_stack=.true.) write (u, "(A)") "* Initialize event generation" write (u, "(A)") call global%set_log (var_str ("?unweighted"), & .false., is_known = .true.) call simulation%init ([procname1], .true., .true., global) call simulation%init_process_selector () data = simulation%get_data () call data%write (u) write (u, "(A)") write (u, "(A)") "* Generate three events" write (u, "(A)") - call simulation%generate (3) + call simulation%set_n_events_requested (3) + call simulation%generate () call simulation%write (u) write (u, "(A)") write (u, "(A)") "* Write the event record for the last event" write (u, "(A)") call simulation%write_event (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call simulation%final () call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: simulations_2" end subroutine simulations_2 @ %def simulations_2 @ \subsubsection{Unweighted events} Generate events for a single process. <>= call test (simulations_3, "simulations_3", & "unweighted events", & u, results) <>= public :: simulations_3 <>= subroutine simulations_3 (u) integer, intent(in) :: u type(string_t) :: libname, procname1 type(rt_data_t), target :: global type(simulation_t), target :: simulation type(event_sample_data_t) :: data write (u, "(A)") "* Test output: simulations_3" write (u, "(A)") "* Purpose: generate unweighted events & &for a single process" write (u, "(A)") write (u, "(A)") "* Initialize processes" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) libname = "simulation_3a" procname1 = "simulation_3p" call prepare_test_library (global, libname, 1, [procname1]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_events"), .true., intrinsic = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("single"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_log (var_str ("?recover_beams"), & .false., is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%it_list%init ([1], [1000]) call global%set_string (var_str ("$run_id"), & var_str ("simulations1"), is_known = .true.) call integrate_process (procname1, global, local_stack=.true.) write (u, "(A)") "* Initialize event generation" write (u, "(A)") call simulation%init ([procname1], .true., .true., global) call simulation%init_process_selector () data = simulation%get_data () call data%write (u) write (u, "(A)") write (u, "(A)") "* Generate three events" write (u, "(A)") - call simulation%generate (3) + call simulation%set_n_events_requested (3) + call simulation%generate () call simulation%write (u) write (u, "(A)") write (u, "(A)") "* Write the event record for the last event" write (u, "(A)") call simulation%write_event (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call simulation%final () call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: simulations_3" end subroutine simulations_3 @ %def simulations_3 @ \subsubsection{Simulating process with structure functions} Generate events for a single process. <>= call test (simulations_4, "simulations_4", & "process with structure functions", & u, results) <>= public :: simulations_4 <>= subroutine simulations_4 (u) integer, intent(in) :: u type(string_t) :: libname, procname1 type(rt_data_t), target :: global type(flavor_t) :: flv type(string_t) :: name type(simulation_t), target :: simulation type(event_sample_data_t) :: data write (u, "(A)") "* Test output: simulations_4" write (u, "(A)") "* Purpose: generate events for a single process & &with structure functions" write (u, "(A)") write (u, "(A)") "* Initialize processes" write (u, "(A)") call syntax_model_file_init () call syntax_phs_forest_init () call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) libname = "simulation_4a" procname1 = "simulation_4p" call prepare_test_library (global, libname, 1, [procname1]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_grids"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_events"), .true., intrinsic = .true.) call global%set_string (var_str ("$run_id"), & var_str ("r1"), is_known = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("wood"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("vamp"), is_known = .true.) call global%set_log (var_str ("?use_vamp_equivalences"),& .true., is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%model_set_real (var_str ("ms"), & 0._default) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_log (var_str ("?recover_beams"), & .false., is_known = .true.) call reset_interaction_counter () call flv%init (25, global%model) name = flv%get_name () call global%beam_structure%init_sf ([name, name], [1]) call global%beam_structure%set_sf (1, 1, var_str ("sf_test_1")) write (u, "(A)") "* Integrate" write (u, "(A)") call global%it_list%init ([1], [1000]) call global%set_string (var_str ("$run_id"), & var_str ("r1"), is_known = .true.) call integrate_process (procname1, global, local_stack=.true.) write (u, "(A)") "* Initialize event generation" write (u, "(A)") call global%set_log (var_str ("?unweighted"), & .false., is_known = .true.) call global%set_string (var_str ("$sample"), & var_str ("simulations4"), is_known = .true.) call simulation%init ([procname1], .true., .true., global) call simulation%init_process_selector () data = simulation%get_data () call data%write (u) write (u, "(A)") write (u, "(A)") "* Generate three events" write (u, "(A)") - call simulation%generate (3) + call simulation%set_n_events_requested (3) + call simulation%generate () call simulation%write (u) write (u, "(A)") write (u, "(A)") "* Write the event record for the last event" write (u, "(A)") call simulation%write_event (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call simulation%final () call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: simulations_4" end subroutine simulations_4 @ %def simulations_4 @ \subsubsection{Event I/O} Generate event for a test process, write to file and reread. <>= call test (simulations_5, "simulations_5", & "raw event I/O", & u, results) <>= public :: simulations_5 <>= subroutine simulations_5 (u) integer, intent(in) :: u type(string_t) :: libname, procname1, sample type(rt_data_t), target :: global class(eio_t), allocatable :: eio type(simulation_t), allocatable, target :: simulation write (u, "(A)") "* Test output: simulations_5" write (u, "(A)") "* Purpose: generate events for a single process" write (u, "(A)") "* write to file and reread" write (u, "(A)") write (u, "(A)") "* Initialize processes" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) libname = "simulation_5a" procname1 = "simulation_5p" call prepare_test_library (global, libname, 1, [procname1]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_events"), .true., intrinsic = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("single"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_log (var_str ("?recover_beams"), & .false., is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%it_list%init ([1], [1000]) call global%set_string (var_str ("$run_id"), & var_str ("simulations5"), is_known = .true.) call integrate_process (procname1, global, local_stack=.true.) write (u, "(A)") "* Initialize event generation" write (u, "(A)") call global%set_log (var_str ("?unweighted"), & .false., is_known = .true.) sample = "simulations5" call global%set_string (var_str ("$sample"), & sample, is_known = .true.) allocate (simulation) call simulation%init ([procname1], .true., .true., global) call simulation%init_process_selector () write (u, "(A)") "* Initialize raw event file" write (u, "(A)") allocate (eio_raw_t :: eio) call eio%init_out (sample) write (u, "(A)") "* Generate an event" write (u, "(A)") - call simulation%generate (1) + call simulation%set_n_events_requested (1) + call simulation%generate () call simulation%write_event (u) call simulation%write_event (eio) call eio%final () deallocate (eio) call simulation%final () deallocate (simulation) write (u, "(A)") write (u, "(A)") "* Re-read the event from file" write (u, "(A)") call global%set_log (var_str ("?update_sqme"), & .true., is_known = .true.) call global%set_log (var_str ("?update_weight"), & .true., is_known = .true.) call global%set_log (var_str ("?recover_beams"), & .false., is_known = .true.) allocate (simulation) call simulation%init ([procname1], .true., .true., global) call simulation%init_process_selector () allocate (eio_raw_t :: eio) call eio%init_in (sample) call simulation%read_event (eio) call simulation%write_event (u) write (u, "(A)") write (u, "(A)") "* Recalculate process instance" write (u, "(A)") call simulation%recalculate () call simulation%evaluate_expressions () call simulation%write_event (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio%final () call simulation%final () call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: simulations_5" end subroutine simulations_5 @ %def simulations_5 @ \subsubsection{Event I/O} Generate event for a real process with structure functions, write to file and reread. <>= call test (simulations_6, "simulations_6", & "raw event I/O with structure functions", & u, results) <>= public :: simulations_6 <>= subroutine simulations_6 (u) integer, intent(in) :: u type(string_t) :: libname, procname1, sample type(rt_data_t), target :: global class(eio_t), allocatable :: eio type(simulation_t), allocatable, target :: simulation type(flavor_t) :: flv type(string_t) :: name write (u, "(A)") "* Test output: simulations_6" write (u, "(A)") "* Purpose: generate events for a single process" write (u, "(A)") "* write to file and reread" write (u, "(A)") write (u, "(A)") "* Initialize process and integrate" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) libname = "simulation_6" procname1 = "simulation_6p" call prepare_test_library (global, libname, 1, [procname1]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_grids"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_events"), .true., intrinsic = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("wood"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("vamp"), is_known = .true.) call global%set_log (var_str ("?use_vamp_equivalences"),& .true., is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_log (var_str ("?recover_beams"), & .false., is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%model_set_real (var_str ("ms"), & 0._default) call flv%init (25, global%model) name = flv%get_name () call global%beam_structure%init_sf ([name, name], [1]) call global%beam_structure%set_sf (1, 1, var_str ("sf_test_1")) call global%it_list%init ([1], [1000]) call global%set_string (var_str ("$run_id"), & var_str ("r1"), is_known = .true.) call integrate_process (procname1, global, local_stack=.true.) write (u, "(A)") "* Initialize event generation" write (u, "(A)") call reset_interaction_counter () call global%set_log (var_str ("?unweighted"), & .false., is_known = .true.) sample = "simulations6" call global%set_string (var_str ("$sample"), & sample, is_known = .true.) allocate (simulation) call simulation%init ([procname1], .true., .true., global) call simulation%init_process_selector () write (u, "(A)") "* Initialize raw event file" write (u, "(A)") allocate (eio_raw_t :: eio) call eio%init_out (sample) write (u, "(A)") "* Generate an event" write (u, "(A)") - call simulation%generate (1) + call simulation%set_n_events_requested (1) + call simulation%generate () call pacify (simulation) call simulation%write_event (u, verbose = .true., testflag = .true.) call simulation%write_event (eio) call eio%final () deallocate (eio) call simulation%final () deallocate (simulation) write (u, "(A)") write (u, "(A)") "* Re-read the event from file" write (u, "(A)") call reset_interaction_counter () call global%set_log (var_str ("?update_sqme"), & .true., is_known = .true.) call global%set_log (var_str ("?update_weight"), & .true., is_known = .true.) allocate (simulation) call simulation%init ([procname1], .true., .true., global) call simulation%init_process_selector () allocate (eio_raw_t :: eio) call eio%init_in (sample) call simulation%read_event (eio) call simulation%write_event (u, verbose = .true., testflag = .true.) write (u, "(A)") write (u, "(A)") "* Recalculate process instance" write (u, "(A)") call simulation%recalculate () call simulation%evaluate_expressions () call simulation%write_event (u, verbose = .true., testflag = .true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio%final () call simulation%final () call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: simulations_6" end subroutine simulations_6 @ %def simulations_6 @ \subsubsection{Automatic Event I/O} Generate events with raw-format event file as cache: generate, reread, append. <>= call test (simulations_7, "simulations_7", & "automatic raw event I/O", & u, results) <>= public :: simulations_7 <>= subroutine simulations_7 (u) integer, intent(in) :: u type(string_t) :: libname, procname1, sample type(rt_data_t), target :: global type(string_t), dimension(0) :: empty_string_array type(event_sample_data_t) :: data type(event_stream_array_t) :: es_array type(simulation_t), allocatable, target :: simulation type(flavor_t) :: flv type(string_t) :: name write (u, "(A)") "* Test output: simulations_7" write (u, "(A)") "* Purpose: generate events for a single process" write (u, "(A)") "* write to file and reread" write (u, "(A)") write (u, "(A)") "* Initialize process and integrate" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%init_fallback_model & (var_str ("SM_hadrons"), var_str ("SM_hadrons.mdl")) call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) libname = "simulation_7" procname1 = "simulation_7p" call prepare_test_library (global, libname, 1, [procname1]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_grids"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_events"), .true., intrinsic = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("wood"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("vamp"), is_known = .true.) call global%set_log (var_str ("?use_vamp_equivalences"),& .true., is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_log (var_str ("?recover_beams"), & .false., is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%model_set_real (var_str ("ms"), & 0._default) call flv%init (25, global%model) name = flv%get_name () call global%beam_structure%init_sf ([name, name], [1]) call global%beam_structure%set_sf (1, 1, var_str ("sf_test_1")) call global%it_list%init ([1], [1000]) call global%set_string (var_str ("$run_id"), & var_str ("r1"), is_known = .true.) call integrate_process (procname1, global, local_stack=.true.) write (u, "(A)") "* Initialize event generation" write (u, "(A)") call reset_interaction_counter () call global%set_log (var_str ("?unweighted"), & .false., is_known = .true.) sample = "simulations7" call global%set_string (var_str ("$sample"), & sample, is_known = .true.) allocate (simulation) call simulation%init ([procname1], .true., .true., global) call simulation%init_process_selector () write (u, "(A)") "* Initialize raw event file" write (u, "(A)") data%md5sum_prc = simulation%get_md5sum_prc () data%md5sum_cfg = simulation%get_md5sum_cfg () call es_array%init (sample, [var_str ("raw")], global, data) write (u, "(A)") "* Generate an event" write (u, "(A)") - call simulation%generate (1, es_array) + call simulation%set_n_events_requested (1) + call simulation%generate (es_array) call es_array%final () call simulation%final () deallocate (simulation) write (u, "(A)") "* Re-read the event from file and generate another one" write (u, "(A)") call global%set_log (& var_str ("?rebuild_events"), .false., is_known = .true.) call reset_interaction_counter () allocate (simulation) call simulation%init ([procname1], .true., .true., global) call simulation%init_process_selector () data%md5sum_prc = simulation%get_md5sum_prc () data%md5sum_cfg = simulation%get_md5sum_cfg () call es_array%init (sample, empty_string_array, global, data, & input = var_str ("raw")) - call simulation%generate (2, es_array) + call simulation%set_n_events_requested (2) + call simulation%generate (es_array) call pacify (simulation) call simulation%write_event (u, verbose = .true.) call es_array%final () call simulation%final () deallocate (simulation) write (u, "(A)") write (u, "(A)") "* Re-read both events from file" write (u, "(A)") call reset_interaction_counter () allocate (simulation) call simulation%init ([procname1], .true., .true., global) call simulation%init_process_selector () data%md5sum_prc = simulation%get_md5sum_prc () data%md5sum_cfg = simulation%get_md5sum_cfg () call es_array%init (sample, empty_string_array, global, data, & input = var_str ("raw")) - call simulation%generate (2, es_array) + call simulation%set_n_events_requested (2) + call simulation%generate (es_array) call pacify (simulation) call simulation%write_event (u, verbose = .true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call es_array%final () call simulation%final () call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: simulations_7" end subroutine simulations_7 @ %def simulations_7 @ \subsubsection{Rescanning Events} Generate events and rescan the resulting raw event file. <>= call test (simulations_8, "simulations_8", & "rescan raw event file", & u, results) <>= public :: simulations_8 <>= subroutine simulations_8 (u) integer, intent(in) :: u type(string_t) :: libname, procname1, sample type(rt_data_t), target :: global type(string_t), dimension(0) :: empty_string_array type(event_sample_data_t) :: data type(event_stream_array_t) :: es_array type(simulation_t), allocatable, target :: simulation type(flavor_t) :: flv type(string_t) :: name write (u, "(A)") "* Test output: simulations_8" write (u, "(A)") "* Purpose: generate events for a single process" write (u, "(A)") "* write to file and rescan" write (u, "(A)") write (u, "(A)") "* Initialize process and integrate" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%init_fallback_model & (var_str ("SM_hadrons"), var_str ("SM_hadrons.mdl")) call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) libname = "simulation_8" procname1 = "simulation_8p" call prepare_test_library (global, libname, 1, [procname1]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_grids"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_events"), .true., intrinsic = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("wood"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("vamp"), is_known = .true.) call global%set_log (var_str ("?use_vamp_equivalences"),& .true., is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_log (var_str ("?recover_beams"), & .false., is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%model_set_real (var_str ("ms"), & 0._default) call flv%init (25, global%model) name = flv%get_name () call global%beam_structure%init_sf ([name, name], [1]) call global%beam_structure%set_sf (1, 1, var_str ("sf_test_1")) call global%it_list%init ([1], [1000]) call global%set_string (var_str ("$run_id"), & var_str ("r1"), is_known = .true.) call integrate_process (procname1, global, local_stack=.true.) write (u, "(A)") "* Initialize event generation" write (u, "(A)") call reset_interaction_counter () call global%set_log (var_str ("?unweighted"), & .false., is_known = .true.) sample = "simulations8" call global%set_string (var_str ("$sample"), & sample, is_known = .true.) allocate (simulation) call simulation%init ([procname1], .true., .true., global) call simulation%init_process_selector () write (u, "(A)") "* Initialize raw event file" write (u, "(A)") data%md5sum_prc = simulation%get_md5sum_prc () data%md5sum_cfg = simulation%get_md5sum_cfg () write (u, "(1x,A,A,A)") "MD5 sum (proc) = '", data%md5sum_prc, "'" write (u, "(1x,A,A,A)") "MD5 sum (config) = '", data%md5sum_cfg, "'" call es_array%init (sample, [var_str ("raw")], global, & data) write (u, "(A)") write (u, "(A)") "* Generate an event" write (u, "(A)") - call simulation%generate (1, es_array) + call simulation%set_n_events_requested (1) + call simulation%generate (es_array) call pacify (simulation) call simulation%write_event (u, verbose = .true., testflag = .true.) call es_array%final () call simulation%final () deallocate (simulation) write (u, "(A)") write (u, "(A)") "* Re-read the event from file" write (u, "(A)") call reset_interaction_counter () allocate (simulation) call simulation%init ([procname1], .false., .false., global) call simulation%init_process_selector () data%md5sum_prc = simulation%get_md5sum_prc () data%md5sum_cfg = "" write (u, "(1x,A,A,A)") "MD5 sum (proc) = '", data%md5sum_prc, "'" write (u, "(1x,A,A,A)") "MD5 sum (config) = '", data%md5sum_cfg, "'" call es_array%init (sample, empty_string_array, global, data, & input = var_str ("raw"), input_sample = sample, allow_switch = .false.) call simulation%rescan (1, es_array, global = global) write (u, "(A)") call pacify (simulation) call simulation%write_event (u, verbose = .true., testflag = .true.) call es_array%final () call simulation%final () deallocate (simulation) write (u, "(A)") write (u, "(A)") "* Re-read again and recalculate" write (u, "(A)") call reset_interaction_counter () call global%set_log (var_str ("?update_sqme"), & .true., is_known = .true.) call global%set_log (var_str ("?update_event"), & .true., is_known = .true.) allocate (simulation) call simulation%init ([procname1], .false., .false., global) call simulation%init_process_selector () data%md5sum_prc = simulation%get_md5sum_prc () data%md5sum_cfg = "" write (u, "(1x,A,A,A)") "MD5 sum (proc) = '", data%md5sum_prc, "'" write (u, "(1x,A,A,A)") "MD5 sum (config) = '", data%md5sum_cfg, "'" call es_array%init (sample, empty_string_array, global, data, & input = var_str ("raw"), input_sample = sample, allow_switch = .false.) call simulation%rescan (1, es_array, global = global) write (u, "(A)") call pacify (simulation) call simulation%write_event (u, verbose = .true., testflag = .true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call es_array%final () call simulation%final () call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: simulations_8" end subroutine simulations_8 @ %def simulations_8 @ \subsubsection{Rescanning Check} Generate events and rescan with process mismatch. <>= call test (simulations_9, "simulations_9", & "rescan mismatch", & u, results) <>= public :: simulations_9 <>= subroutine simulations_9 (u) integer, intent(in) :: u type(string_t) :: libname, procname1, sample type(rt_data_t), target :: global type(string_t), dimension(0) :: empty_string_array type(event_sample_data_t) :: data type(event_stream_array_t) :: es_array type(simulation_t), allocatable, target :: simulation type(flavor_t) :: flv type(string_t) :: name logical :: error write (u, "(A)") "* Test output: simulations_9" write (u, "(A)") "* Purpose: generate events for a single process" write (u, "(A)") "* write to file and rescan" write (u, "(A)") write (u, "(A)") "* Initialize process and integrate" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%init_fallback_model & (var_str ("SM_hadrons"), var_str ("SM_hadrons.mdl")) call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) libname = "simulation_9" procname1 = "simulation_9p" call prepare_test_library (global, libname, 1, [procname1]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_grids"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_events"), .true., intrinsic = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("wood"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("vamp"), is_known = .true.) call global%set_log (var_str ("?use_vamp_equivalences"),& .true., is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_log (var_str ("?recover_beams"), & .false., is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%model_set_real (var_str ("ms"), & 0._default) call flv%init (25, global%model) name = flv%get_name () call global%beam_structure%init_sf ([name, name], [1]) call global%beam_structure%set_sf (1, 1, var_str ("sf_test_1")) call global%it_list%init ([1], [1000]) call global%set_string (var_str ("$run_id"), & var_str ("r1"), is_known = .true.) call integrate_process (procname1, global, local_stack=.true.) write (u, "(A)") "* Initialize event generation" write (u, "(A)") call reset_interaction_counter () call global%set_log (var_str ("?unweighted"), & .false., is_known = .true.) sample = "simulations9" call global%set_string (var_str ("$sample"), & sample, is_known = .true.) allocate (simulation) call simulation%init ([procname1], .true., .true., global) call simulation%init_process_selector () call simulation%write (u) write (u, "(A)") write (u, "(A)") "* Initialize raw event file" write (u, "(A)") data%md5sum_prc = simulation%get_md5sum_prc () data%md5sum_cfg = simulation%get_md5sum_cfg () write (u, "(1x,A,A,A)") "MD5 sum (proc) = '", data%md5sum_prc, "'" write (u, "(1x,A,A,A)") "MD5 sum (config) = '", data%md5sum_cfg, "'" call es_array%init (sample, [var_str ("raw")], global, & data) write (u, "(A)") write (u, "(A)") "* Generate an event" write (u, "(A)") - call simulation%generate (1, es_array) + call simulation%set_n_events_requested (1) + call simulation%generate (es_array) call es_array%final () call simulation%final () deallocate (simulation) write (u, "(A)") "* Initialize event generation for different parameters" write (u, "(A)") call reset_interaction_counter () allocate (simulation) call simulation%init ([procname1, procname1], .false., .false., global) call simulation%init_process_selector () call simulation%write (u) write (u, "(A)") write (u, "(A)") "* Attempt to re-read the events (should fail)" write (u, "(A)") data%md5sum_prc = simulation%get_md5sum_prc () data%md5sum_cfg = "" write (u, "(1x,A,A,A)") "MD5 sum (proc) = '", data%md5sum_prc, "'" write (u, "(1x,A,A,A)") "MD5 sum (config) = '", data%md5sum_cfg, "'" call es_array%init (sample, empty_string_array, global, data, & input = var_str ("raw"), input_sample = sample, & allow_switch = .false., error = error) write (u, "(1x,A,L1)") "error = ", error call simulation%rescan (1, es_array, global = global) call es_array%final () call simulation%final () call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: simulations_9" end subroutine simulations_9 @ %def simulations_9 @ \subsubsection{Alternative weights} Generate an event for a single process and reweight it in a simultaneous calculation. <>= call test (simulations_10, "simulations_10", & "alternative weight", & u, results) <>= public :: simulations_10 <>= subroutine simulations_10 (u) integer, intent(in) :: u type(string_t) :: libname, procname1, expr_text type(rt_data_t), target :: global type(rt_data_t), dimension(1), target :: alt_env type(ifile_t) :: ifile type(stream_t) :: stream type(parse_tree_t) :: pt_weight type(simulation_t), target :: simulation type(event_sample_data_t) :: data write (u, "(A)") "* Test output: simulations_10" write (u, "(A)") "* Purpose: reweight event" write (u, "(A)") write (u, "(A)") "* Initialize processes" write (u, "(A)") call syntax_model_file_init () call syntax_pexpr_init () call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) libname = "simulation_10a" procname1 = "simulation_10p" call prepare_test_library (global, libname, 1, [procname1]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_grids"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_events"), .true., intrinsic = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("single"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_log (var_str ("?recover_beams"), & .false., is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%it_list%init ([1], [1000]) call global%set_string (var_str ("$run_id"), & var_str ("simulations1"), is_known = .true.) call integrate_process (procname1, global, local_stack=.true.) write (u, "(A)") "* Initialize alternative environment with custom weight" write (u, "(A)") call alt_env(1)%local_init (global) call alt_env(1)%activate () expr_text = "2" write (u, "(A,A)") "weight = ", char (expr_text) write (u, *) call ifile_clear (ifile) call ifile_append (ifile, expr_text) call stream_init (stream, ifile) call parse_tree_init_expr (pt_weight, stream, .true.) call stream_final (stream) alt_env(1)%pn%weight_expr => pt_weight%get_root_ptr () call alt_env(1)%write_expr (u) write (u, "(A)") write (u, "(A)") "* Initialize event generation" write (u, "(A)") call global%set_log (var_str ("?unweighted"), & .false., is_known = .true.) call simulation%init ([procname1], .true., .true., global, alt_env=alt_env) call simulation%init_process_selector () data = simulation%get_data () call data%write (u) write (u, "(A)") write (u, "(A)") "* Generate an event" write (u, "(A)") - call simulation%generate (1) + call simulation%set_n_events_requested (1) + call simulation%generate () call simulation%write (u) write (u, "(A)") write (u, "(A)") "* Write the event record for the last event" write (u, "(A)") call simulation%write_event (u) write (u, "(A)") write (u, "(A)") "* Write the event record for the alternative setup" write (u, "(A)") call simulation%write_alt_event (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call simulation%final () call global%final () call syntax_model_file_final () call syntax_pexpr_final () write (u, "(A)") write (u, "(A)") "* Test output end: simulations_10" end subroutine simulations_10 @ %def simulations_10 @ \subsubsection{Decays} Generate an event with subsequent partonic decays. <>= call test (simulations_11, "simulations_11", & "decay", & u, results) <>= public :: simulations_11 <>= subroutine simulations_11 (u) integer, intent(in) :: u type(rt_data_t), target :: global type(prclib_entry_t), pointer :: lib type(string_t) :: prefix, procname1, procname2 type(simulation_t), target :: simulation write (u, "(A)") "* Test output: simulations_11" write (u, "(A)") "* Purpose: apply decay" write (u, "(A)") write (u, "(A)") "* Initialize processes" write (u, "(A)") call syntax_model_file_init () call global%global_init () allocate (lib) call global%add_prclib (lib) call global%set_int (var_str ("seed"), & 0, is_known = .true.) call global%set_log (var_str ("?recover_beams"), & .false., is_known = .true.) prefix = "simulation_11" procname1 = prefix // "_p" procname2 = prefix // "_d" call prepare_testbed & (global%prclib, global%process_stack, & prefix, global%os_data, & scattering=.true., decay=.true.) call global%select_model (var_str ("Test")) call global%model%set_par (var_str ("ff"), 0.4_default) call global%model%set_par (var_str ("mf"), & global%model%get_real (var_str ("ff")) & * global%model%get_real (var_str ("ms"))) call global%model%set_unstable (25, [procname2]) write (u, "(A)") "* Initialize simulation object" write (u, "(A)") call simulation%init ([procname1], .true., .true., global) call simulation%init_process_selector () write (u, "(A)") "* Generate event" write (u, "(A)") - call simulation%generate (1) + call simulation%set_n_events_requested (1) + call simulation%generate () call simulation%write (u) write (u, *) call simulation%write_event (u) write (u, "(A)") write (u, "(A)") "* Cleanup" write (u, "(A)") call simulation%final () call global%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: simulations_11" end subroutine simulations_11 @ %def simulations_11 @ \subsubsection{Split Event Files} Generate event for a real process with structure functions and write to file, accepting a limit for the number of events per file. <>= call test (simulations_12, "simulations_12", & "split event files", & u, results) <>= public :: simulations_12 <>= subroutine simulations_12 (u) integer, intent(in) :: u type(string_t) :: libname, procname1, sample type(rt_data_t), target :: global class(eio_t), allocatable :: eio type(simulation_t), allocatable, target :: simulation type(flavor_t) :: flv integer :: i_evt write (u, "(A)") "* Test output: simulations_12" write (u, "(A)") "* Purpose: generate events for a single process" write (u, "(A)") "* and write to split event files" write (u, "(A)") write (u, "(A)") "* Initialize process and integrate" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) libname = "simulation_12" procname1 = "simulation_12p" call prepare_test_library (global, libname, 1, [procname1]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_grids"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_events"), .true., intrinsic = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("single"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_log (var_str ("?recover_beams"), & .false., is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%model_set_real (var_str ("ms"), & 0._default) call flv%init (25, global%model) call global%it_list%init ([1], [1000]) call global%set_string (var_str ("$run_id"), & var_str ("r1"), is_known = .true.) call integrate_process (procname1, global, local_stack=.true.) write (u, "(A)") "* Initialize event generation" write (u, "(A)") call global%set_log (var_str ("?unweighted"), & .false., is_known = .true.) sample = "simulations_12" call global%set_string (var_str ("$sample"), & sample, is_known = .true.) call global%set_int (var_str ("sample_split_n_evt"), & 2, is_known = .true.) call global%set_int (var_str ("sample_split_index"), & 42, is_known = .true.) allocate (simulation) call simulation%init ([procname1], .true., .true., global) call simulation%init_process_selector () call simulation%write (u) write (u, "(A)") write (u, "(A)") "* Initialize ASCII event file" write (u, "(A)") allocate (eio_ascii_short_t :: eio) select type (eio) class is (eio_ascii_t); call eio%set_parameters () end select call eio%init_out (sample, data = simulation%get_data ()) write (u, "(A)") "* Generate 5 events, distributed among three files" do i_evt = 1, 5 - call simulation%generate (1) + call simulation%set_n_events_requested (1) + call simulation%generate () call simulation%write_event (eio) end do call eio%final () deallocate (eio) call simulation%final () deallocate (simulation) write (u, *) call display_file ("simulations_12.42.short.evt", u) write (u, *) call display_file ("simulations_12.43.short.evt", u) write (u, *) call display_file ("simulations_12.44.short.evt", u) write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: simulations_12" end subroutine simulations_12 @ %def simulations_12 @ Auxiliary: display file contents. <>= public :: display_file <>= subroutine display_file (file, u) use io_units, only: free_unit character(*), intent(in) :: file integer, intent(in) :: u character(256) :: buffer integer :: u_file write (u, "(3A)") "* Contents of file '", file, "':" write (u, *) u_file = free_unit () open (u_file, file = file, action = "read", status = "old") do read (u_file, "(A)", end = 1) buffer write (u, "(A)") trim (buffer) end do 1 continue end subroutine display_file @ %def display_file @ \subsubsection{Callback} Generate events and execute a callback in place of event I/O. <>= call test (simulations_13, "simulations_13", & "callback", & u, results) <>= public :: simulations_13 <>= subroutine simulations_13 (u) integer, intent(in) :: u type(string_t) :: libname, procname1, sample type(rt_data_t), target :: global class(eio_t), allocatable :: eio type(simulation_t), allocatable, target :: simulation type(flavor_t) :: flv integer :: i_evt type(simulations_13_callback_t) :: event_callback write (u, "(A)") "* Test output: simulations_13" write (u, "(A)") "* Purpose: generate events for a single process" write (u, "(A)") "* and execute callback" write (u, "(A)") write (u, "(A)") "* Initialize process and integrate" write (u, "(A)") call syntax_model_file_init () call global%global_init () call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) libname = "simulation_13" procname1 = "simulation_13p" call prepare_test_library (global, libname, 1, [procname1]) call compile_library (libname, global) call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_grids"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_events"), .true., intrinsic = .true.) call global%set_string (var_str ("$method"), & var_str ("unit_test"), is_known = .true.) call global%set_string (var_str ("$phs_method"), & var_str ("single"), is_known = .true.) call global%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known = .true.) call global%set_log (var_str ("?vis_history"),& .false., is_known = .true.) call global%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%set_log (var_str ("?recover_beams"), & .false., is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call flv%init (25, global%model) call global%it_list%init ([1], [1000]) call global%set_string (var_str ("$run_id"), & var_str ("r1"), is_known = .true.) call integrate_process (procname1, global, local_stack=.true.) write (u, "(A)") "* Initialize event generation" write (u, "(A)") call global%set_log (var_str ("?unweighted"), & .false., is_known = .true.) sample = "simulations_13" call global%set_string (var_str ("$sample"), & sample, is_known = .true.) allocate (simulation) call simulation%init ([procname1], .true., .true., global) call simulation%init_process_selector () write (u, "(A)") "* Prepare callback object" write (u, "(A)") event_callback%u = u call global%set_event_callback (event_callback) write (u, "(A)") "* Initialize callback I/O object" write (u, "(A)") allocate (eio_callback_t :: eio) select type (eio) class is (eio_callback_t) call eio%set_parameters (callback = event_callback, & count_interval = 3) end select call eio%init_out (sample, data = simulation%get_data ()) write (u, "(A)") "* Generate 7 events, with callback every 3 events" write (u, "(A)") do i_evt = 1, 7 - call simulation%generate (1) + call simulation%set_n_events_requested (1) + call simulation%generate () call simulation%write_event (eio) end do call eio%final () deallocate (eio) call simulation%final () deallocate (simulation) write (u, "(A)") write (u, "(A)") "* Cleanup" call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: simulations_13" end subroutine simulations_13 @ %def simulations_13 @ The callback object and procedure. In the type extension, we can store the output channel [[u]] so we know where to write into. <>= type, extends (event_callback_t) :: simulations_13_callback_t integer :: u contains procedure :: write => simulations_13_callback_write procedure :: proc => simulations_13_callback end type simulations_13_callback_t @ %def simulations_13_callback_t <>= subroutine simulations_13_callback_write (event_callback, unit) class(simulations_13_callback_t), intent(in) :: event_callback integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A)") "Hello" end subroutine simulations_13_callback_write subroutine simulations_13_callback (event_callback, i, event) class(simulations_13_callback_t), intent(in) :: event_callback integer(i64), intent(in) :: i class(generic_event_t), intent(in) :: event write (event_callback%u, "(A,I0)") "hello event #", i end subroutine simulations_13_callback @ %def simulations_13_callback_write @ %def simulations_13_callback @ \subsubsection{Resonant subprocess setup} Prepare a process with resonances and enter resonant subprocesses in the simulation object. Select a kinematics configuration and compute probabilities for resonant subprocesses. The process and its initialization is taken from [[processes_18]], but we need a complete \oMega\ matrix element here. <>= call test (simulations_14, "simulations_14", & "resonant subprocesses evaluation", & u, results) <>= public :: simulations_14 <>= subroutine simulations_14 (u) integer, intent(in) :: u type(string_t) :: libname, libname_generated type(string_t) :: procname type(string_t) :: model_name type(rt_data_t), target :: global type(prclib_entry_t), pointer :: lib_entry type(process_library_t), pointer :: lib class(model_t), pointer :: model class(model_data_t), pointer :: model_data type(simulation_t), target :: simulation type(particle_set_t) :: pset type(eio_direct_t) :: eio_in type(eio_dump_t) :: eio_out real(default) :: sqrts, mw, pp real(default), dimension(3) :: p3 type(vector4_t), dimension(:), allocatable :: p real(default), dimension(:), allocatable :: m integer :: u_verbose, i real(default) :: sqme_proc real(default), dimension(:), allocatable :: sqme real(default) :: on_shell_limit integer, dimension(:), allocatable :: i_array real(default), dimension(:), allocatable :: prob_array write (u, "(A)") "* Test output: simulations_14" write (u, "(A)") "* Purpose: construct resonant subprocesses & &in the simulation object" write (u, "(A)") write (u, "(A)") "* Build and load a test library with one process" write (u, "(A)") call syntax_model_file_init () call syntax_phs_forest_init () libname = "simulations_14_lib" procname = "simulations_14_p" call global%global_init () call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_grids"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_events"), .true., intrinsic = .true.) call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%set_log (var_str ("?recover_beams"), & .false., is_known = .true.) call global%set_log (var_str ("?update_sqme"), & .true., is_known = .true.) call global%set_log (var_str ("?update_weight"), & .true., is_known = .true.) call global%set_log (var_str ("?update_event"), & .true., is_known = .true.) model_name = "SM" call global%select_model (model_name) allocate (model) call model%init_instance (global%model) model_data => model write (u, "(A)") "* Initialize process library and process" write (u, "(A)") allocate (lib_entry) call lib_entry%init (libname) lib => lib_entry%process_library_t call global%add_prclib (lib_entry) call prepare_resonance_test_library & (lib, libname, procname, model_data, global, u) write (u, "(A)") write (u, "(A)") "* Initialize simulation object & &with resonant subprocesses" write (u, "(A)") call global%set_log (var_str ("?resonance_history"), & .true., is_known = .true.) call global%set_real (var_str ("resonance_on_shell_limit"), & 10._default, is_known = .true.) call simulation%init ([procname], & integrate=.false., generate=.false., local=global) call simulation%write_resonant_subprocess_data (u, 1) write (u, "(A)") write (u, "(A)") "* Resonant subprocesses: generated library" write (u, "(A)") libname_generated = procname // "_R" lib => global%prclib_stack%get_library_ptr (libname_generated) if (associated (lib)) call lib%write (u, libpath=.false.) write (u, "(A)") write (u, "(A)") "* Generated process stack" write (u, "(A)") call global%process_stack%show (u) write (u, "(A)") write (u, "(A)") "* Particle set" write (u, "(A)") pset = simulation%get_hard_particle_set (1) call pset%write (u) write (u, "(A)") write (u, "(A)") "* Initialize object for direct access" write (u, "(A)") call eio_in%init_direct & (n_beam = 0, n_in = 2, n_rem = 0, n_vir = 0, n_out = 3, & pdg = [-11, 11, 1, -2, 24], model=global%model) call eio_in%set_selection_indices (1, 1, 1, 1) sqrts = global%get_rval (var_str ("sqrts")) mw = 80._default ! deliberately slightly different from true mw pp = sqrt (sqrts**2 - 4 * mw**2) / 2 allocate (p (5), m (5)) p(1) = vector4_moving (sqrts/2, sqrts/2, 3) m(1) = 0 p(2) = vector4_moving (sqrts/2,-sqrts/2, 3) m(2) = 0 p3(1) = pp/2 p3(2) = mw/2 p3(3) = 0 p(3) = vector4_moving (sqrts/4, vector3_moving (p3)) m(3) = 0 p3(2) = -mw/2 p(4) = vector4_moving (sqrts/4, vector3_moving (p3)) m(4) = 0 p(5) = vector4_moving (sqrts/2,-pp, 1) m(5) = mw call eio_in%set_momentum (p, m**2) call eio_in%write (u) write (u, "(A)") write (u, "(A)") "* Transfer and show particle set" write (u, "(A)") call simulation%read_event (eio_in) pset = simulation%get_hard_particle_set (1) call pset%write (u) write (u, "(A)") write (u, "(A)") "* (Re)calculate matrix element" write (u, "(A)") call simulation%recalculate (recover_phs = .false.) call simulation%evaluate_transforms () write (u, "(A)") "* Show event with sqme" write (u, "(A)") call eio_out%set_parameters (unit = u, & weights = .true., pacify = .true., compressed = .true.) call eio_out%init_out (var_str ("")) call simulation%write_event (eio_out) write (u, "(A)") write (u, "(A)") "* Write event to separate file & &'simulations_14_event_verbose.log'" u_verbose = free_unit () open (unit = u_verbose, file = "simulations_14_event_verbose.log", & status = "replace", action = "write") call simulation%write (u_verbose) write (u_verbose, *) call simulation%write_event (u_verbose, verbose =.true., testflag = .true.) close (u_verbose) write (u, "(A)") write (u, "(A)") "* Cleanup" call simulation%final () call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: simulations_14" end subroutine simulations_14 @ %def simulations_14 @ \subsubsection{Resonant subprocess simulation} Prepare a process with resonances and enter resonant subprocesses in the simulation object. Simulate events with selection of resonance histories. The process and its initialization is taken from [[processes_18]], but we need a complete \oMega\ matrix element here. <>= call test (simulations_15, "simulations_15", & "resonant subprocesses in simulation", & u, results) <>= public :: simulations_15 <>= subroutine simulations_15 (u) integer, intent(in) :: u type(string_t) :: libname, libname_generated type(string_t) :: procname type(string_t) :: model_name type(rt_data_t), target :: global type(prclib_entry_t), pointer :: lib_entry type(process_library_t), pointer :: lib class(model_t), pointer :: model class(model_data_t), pointer :: model_data type(simulation_t), target :: simulation real(default) :: sqrts type(eio_dump_t) :: eio_out integer :: u_verbose write (u, "(A)") "* Test output: simulations_15" write (u, "(A)") "* Purpose: generate event with resonant subprocess" write (u, "(A)") write (u, "(A)") "* Build and load a test library with one process" write (u, "(A)") call syntax_model_file_init () call syntax_phs_forest_init () libname = "simulations_15_lib" procname = "simulations_15_p" call global%global_init () call global%append_log (& var_str ("?rebuild_phase_space"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_grids"), .true., intrinsic = .true.) call global%append_log (& var_str ("?rebuild_events"), .true., intrinsic = .true.) call global%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) call global%set_int (var_str ("seed"), & 0, is_known = .true.) call global%set_real (var_str ("sqrts"),& 1000._default, is_known = .true.) call global%set_log (var_str ("?recover_beams"), & .false., is_known = .true.) call global%set_log (var_str ("?update_sqme"), & .true., is_known = .true.) call global%set_log (var_str ("?update_weight"), & .true., is_known = .true.) call global%set_log (var_str ("?update_event"), & .true., is_known = .true.) call global%set_log (var_str ("?resonance_history"), & .true., is_known = .true.) call global%set_real (var_str ("resonance_on_shell_limit"), & 10._default, is_known = .true.) model_name = "SM" call global%select_model (model_name) allocate (model) call model%init_instance (global%model) model_data => model write (u, "(A)") "* Initialize process library and process" write (u, "(A)") allocate (lib_entry) call lib_entry%init (libname) lib => lib_entry%process_library_t call global%add_prclib (lib_entry) call prepare_resonance_test_library & (lib, libname, procname, model_data, global, u) write (u, "(A)") write (u, "(A)") "* Initialize simulation object & &with resonant subprocesses" write (u, "(A)") call global%it_list%init ([1], [1000]) call simulation%init ([procname], & integrate=.true., generate=.true., local=global) call simulation%write_resonant_subprocess_data (u, 1) write (u, "(A)") write (u, "(A)") "* Generate event" write (u, "(A)") call simulation%init_process_selector () - call simulation%generate (1) + call simulation%set_n_events_requested (1) + call simulation%generate () call eio_out%set_parameters (unit = u, & weights = .true., pacify = .true., compressed = .true.) call eio_out%init_out (var_str ("")) call simulation%write_event (eio_out) write (u, "(A)") write (u, "(A)") "* Write event to separate file & &'simulations_15_event_verbose.log'" u_verbose = free_unit () open (unit = u_verbose, file = "simulations_15_event_verbose.log", & status = "replace", action = "write") call simulation%write (u_verbose) write (u_verbose, *) call simulation%write_event (u_verbose, verbose =.true., testflag = .true.) close (u_verbose) write (u, "(A)") write (u, "(A)") "* Cleanup" call simulation%final () call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: simulations_15" end subroutine simulations_15 @ %def simulations_15 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{More Unit Tests} This chapter collects some procedures for testing that can't be provided at the point where the corresponding modules are defined, because they use other modules of a different level. (We should move them back, collecting the high-level functionality in init/final hooks that we can set at runtime.) \section{Expression Testing} Expression objects are part of process and event objects, but the process and event object modules should not depend on the implementation of expressions. Here, we collect unit tests that depend on expression implementation. <<[[expr_tests_ut.f90]]>>= <> module expr_tests_ut use unit_tests use expr_tests_uti <> <> contains <> end module expr_tests_ut @ %def expr_tests_ut @ <<[[expr_tests_uti.f90]]>>= <> module expr_tests_uti <> <> use format_defs, only: FMT_12 use format_utils, only: write_separator use os_interface use sm_qcd use lorentz use ifiles use lexers use parser use model_data use interactions, only: reset_interaction_counter use process_libraries use subevents use subevt_expr use rng_base use mci_base use phs_base use variables, only: var_list_t use eval_trees use models use prc_core use prc_test use process, only: process_t use instances, only: process_instance_t use events use rng_base_ut, only: rng_test_factory_t use phs_base_ut, only: phs_test_config_t <> <> contains <> <> end module expr_tests_uti @ %def expr_tests_uti @ \subsection{Test} This is the master for calling self-test procedures. <>= public :: subevt_expr_test <>= subroutine subevt_expr_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine subevt_expr_test @ %def subevt_expr_test @ \subsubsection{Parton-event expressions} <>= call test (subevt_expr_1, "subevt_expr_1", & "parton-event expressions", & u, results) <>= public :: subevt_expr_1 <>= subroutine subevt_expr_1 (u) integer, intent(in) :: u type(string_t) :: expr_text type(ifile_t) :: ifile type(stream_t) :: stream type(parse_tree_t) :: pt_cuts, pt_scale, pt_fac_scale, pt_ren_scale type(parse_tree_t) :: pt_weight type(parse_node_t), pointer :: pn_cuts, pn_scale, pn_fac_scale, pn_ren_scale type(parse_node_t), pointer :: pn_weight type(eval_tree_factory_t) :: expr_factory type(os_data_t) :: os_data type(model_t), target :: model type(parton_expr_t), target :: expr real(default) :: E, Ex, m type(vector4_t), dimension(6) :: p integer :: i, pdg logical :: passed real(default) :: scale, fac_scale, ren_scale, weight write (u, "(A)") "* Test output: subevt_expr_1" write (u, "(A)") "* Purpose: Set up a subevt and associated & &process-specific expressions" write (u, "(A)") call syntax_pexpr_init () call syntax_model_file_init () call os_data%init () call model%read (var_str ("Test.mdl"), os_data) write (u, "(A)") "* Expression texts" write (u, "(A)") expr_text = "all Pt > 100 [s]" write (u, "(A,A)") "cuts = ", char (expr_text) call ifile_clear (ifile) call ifile_append (ifile, expr_text) call stream_init (stream, ifile) call parse_tree_init_lexpr (pt_cuts, stream, .true.) call stream_final (stream) pn_cuts => pt_cuts%get_root_ptr () expr_text = "sqrts" write (u, "(A,A)") "scale = ", char (expr_text) call ifile_clear (ifile) call ifile_append (ifile, expr_text) call stream_init (stream, ifile) call parse_tree_init_expr (pt_scale, stream, .true.) call stream_final (stream) pn_scale => pt_scale%get_root_ptr () expr_text = "sqrts_hat" write (u, "(A,A)") "fac_scale = ", char (expr_text) call ifile_clear (ifile) call ifile_append (ifile, expr_text) call stream_init (stream, ifile) call parse_tree_init_expr (pt_fac_scale, stream, .true.) call stream_final (stream) pn_fac_scale => pt_fac_scale%get_root_ptr () expr_text = "100" write (u, "(A,A)") "ren_scale = ", char (expr_text) call ifile_clear (ifile) call ifile_append (ifile, expr_text) call stream_init (stream, ifile) call parse_tree_init_expr (pt_ren_scale, stream, .true.) call stream_final (stream) pn_ren_scale => pt_ren_scale%get_root_ptr () expr_text = "n_tot - n_in - n_out" write (u, "(A,A)") "weight = ", char (expr_text) call ifile_clear (ifile) call ifile_append (ifile, expr_text) call stream_init (stream, ifile) call parse_tree_init_expr (pt_weight, stream, .true.) call stream_final (stream) pn_weight => pt_weight%get_root_ptr () call ifile_final (ifile) write (u, "(A)") write (u, "(A)") "* Initialize process expr" write (u, "(A)") call expr%setup_vars (1000._default) call expr%var_list%append_real (var_str ("tolerance"), 0._default) call expr%link_var_list (model%get_var_list_ptr ()) call expr_factory%init (pn_cuts) call expr%setup_selection (expr_factory) call expr_factory%init (pn_scale) call expr%setup_scale (expr_factory) call expr_factory%init (pn_fac_scale) call expr%setup_fac_scale (expr_factory) call expr_factory%init (pn_ren_scale) call expr%setup_ren_scale (expr_factory) call expr_factory%init (pn_weight) call expr%setup_weight (expr_factory) call write_separator (u) call expr%write (u) call write_separator (u) write (u, "(A)") write (u, "(A)") "* Fill subevt and evaluate expressions" write (u, "(A)") call subevt_init (expr%subevt_t, 6) E = 500._default Ex = 400._default m = 125._default pdg = 25 p(1) = vector4_moving (E, sqrt (E**2 - m**2), 3) p(2) = vector4_moving (E, -sqrt (E**2 - m**2), 3) p(3) = vector4_moving (Ex, sqrt (Ex**2 - m**2), 3) p(4) = vector4_moving (Ex, -sqrt (Ex**2 - m**2), 3) p(5) = vector4_moving (Ex, sqrt (Ex**2 - m**2), 1) p(6) = vector4_moving (Ex, -sqrt (Ex**2 - m**2), 1) call expr%reset_contents () do i = 1, 2 call subevt_set_beam (expr%subevt_t, i, pdg, p(i), m**2) end do do i = 3, 4 call subevt_set_incoming (expr%subevt_t, i, pdg, p(i), m**2) end do do i = 5, 6 call subevt_set_outgoing (expr%subevt_t, i, pdg, p(i), m**2) end do expr%sqrts_hat = subevt_get_sqrts_hat (expr%subevt_t) expr%n_in = 2 expr%n_out = 2 expr%n_tot = 4 expr%subevt_filled = .true. call expr%evaluate (passed, scale, fac_scale, ren_scale, weight) write (u, "(A,L1)") "Event has passed = ", passed write (u, "(A," // FMT_12 // ")") "Scale = ", scale write (u, "(A," // FMT_12 // ")") "Factorization scale = ", fac_scale write (u, "(A," // FMT_12 // ")") "Renormalization scale = ", ren_scale write (u, "(A," // FMT_12 // ")") "Weight = ", weight write (u, "(A)") call write_separator (u) call expr%write (u) call write_separator (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call expr%final () call model%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: subevt_expr_1" end subroutine subevt_expr_1 @ %def subevt_expr_1 @ \subsubsection{Parton-event expressions} <>= call test (subevt_expr_2, "subevt_expr_2", & "parton-event expressions", & u, results) <>= public :: subevt_expr_2 <>= subroutine subevt_expr_2 (u) integer, intent(in) :: u type(string_t) :: expr_text type(ifile_t) :: ifile type(stream_t) :: stream type(parse_tree_t) :: pt_selection type(parse_tree_t) :: pt_reweight, pt_analysis type(parse_node_t), pointer :: pn_selection type(parse_node_t), pointer :: pn_reweight, pn_analysis type(os_data_t) :: os_data type(model_t), target :: model type(eval_tree_factory_t) :: expr_factory type(event_expr_t), target :: expr real(default) :: E, Ex, m type(vector4_t), dimension(6) :: p integer :: i, pdg logical :: passed real(default) :: reweight logical :: analysis_flag write (u, "(A)") "* Test output: subevt_expr_2" write (u, "(A)") "* Purpose: Set up a subevt and associated & &process-specific expressions" write (u, "(A)") call syntax_pexpr_init () call syntax_model_file_init () call os_data%init () call model%read (var_str ("Test.mdl"), os_data) write (u, "(A)") "* Expression texts" write (u, "(A)") expr_text = "all Pt > 100 [s]" write (u, "(A,A)") "selection = ", char (expr_text) call ifile_clear (ifile) call ifile_append (ifile, expr_text) call stream_init (stream, ifile) call parse_tree_init_lexpr (pt_selection, stream, .true.) call stream_final (stream) pn_selection => pt_selection%get_root_ptr () expr_text = "n_tot - n_in - n_out" write (u, "(A,A)") "reweight = ", char (expr_text) call ifile_clear (ifile) call ifile_append (ifile, expr_text) call stream_init (stream, ifile) call parse_tree_init_expr (pt_reweight, stream, .true.) call stream_final (stream) pn_reweight => pt_reweight%get_root_ptr () expr_text = "true" write (u, "(A,A)") "analysis = ", char (expr_text) call ifile_clear (ifile) call ifile_append (ifile, expr_text) call stream_init (stream, ifile) call parse_tree_init_lexpr (pt_analysis, stream, .true.) call stream_final (stream) pn_analysis => pt_analysis%get_root_ptr () call ifile_final (ifile) write (u, "(A)") write (u, "(A)") "* Initialize process expr" write (u, "(A)") call expr%setup_vars (1000._default) call expr%link_var_list (model%get_var_list_ptr ()) call expr%var_list%append_real (var_str ("tolerance"), 0._default) call expr_factory%init (pn_selection) call expr%setup_selection (expr_factory) call expr_factory%init (pn_analysis) call expr%setup_analysis (expr_factory) call expr_factory%init (pn_reweight) call expr%setup_reweight (expr_factory) call write_separator (u) call expr%write (u) call write_separator (u) write (u, "(A)") write (u, "(A)") "* Fill subevt and evaluate expressions" write (u, "(A)") call subevt_init (expr%subevt_t, 6) E = 500._default Ex = 400._default m = 125._default pdg = 25 p(1) = vector4_moving (E, sqrt (E**2 - m**2), 3) p(2) = vector4_moving (E, -sqrt (E**2 - m**2), 3) p(3) = vector4_moving (Ex, sqrt (Ex**2 - m**2), 3) p(4) = vector4_moving (Ex, -sqrt (Ex**2 - m**2), 3) p(5) = vector4_moving (Ex, sqrt (Ex**2 - m**2), 1) p(6) = vector4_moving (Ex, -sqrt (Ex**2 - m**2), 1) call expr%reset_contents () do i = 1, 2 call subevt_set_beam (expr%subevt_t, i, pdg, p(i), m**2) end do do i = 3, 4 call subevt_set_incoming (expr%subevt_t, i, pdg, p(i), m**2) end do do i = 5, 6 call subevt_set_outgoing (expr%subevt_t, i, pdg, p(i), m**2) end do expr%sqrts_hat = subevt_get_sqrts_hat (expr%subevt_t) expr%n_in = 2 expr%n_out = 2 expr%n_tot = 4 expr%subevt_filled = .true. call expr%evaluate (passed, reweight, analysis_flag) write (u, "(A,L1)") "Event has passed = ", passed write (u, "(A," // FMT_12 // ")") "Reweighting factor = ", reweight write (u, "(A,L1)") "Analysis flag = ", analysis_flag write (u, "(A)") call write_separator (u) call expr%write (u) call write_separator (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call expr%final () call model%final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: subevt_expr_2" end subroutine subevt_expr_2 @ %def subevt_expr_2 @ \subsubsection{Processes: handle partonic cuts} Initialize a process and process instance, choose a sampling point and fill the process instance, evaluating a given cut configuration. We use the same trivial process as for the previous test. All momentum and state dependence is trivial, so we just test basic functionality. <>= call test (processes_5, "processes_5", & "handle cuts (partonic event)", & u, results) <>= public :: processes_5 <>= subroutine processes_5 (u) integer, intent(in) :: u type(string_t) :: cut_expr_text type(ifile_t) :: ifile type(stream_t) :: stream type(parse_tree_t) :: parse_tree type(eval_tree_factory_t) :: expr_factory type(process_library_t), target :: lib type(string_t) :: libname type(string_t) :: procname type(os_data_t) :: os_data type(model_t), pointer :: model_tmp type(model_t), pointer :: model type(var_list_t), target :: var_list type(process_t), allocatable, target :: process class(phs_config_t), allocatable :: phs_config_template real(default) :: sqrts type(process_instance_t), allocatable, target :: process_instance write (u, "(A)") "* Test output: processes_5" write (u, "(A)") "* Purpose: create a process & &and fill a process instance" write (u, "(A)") write (u, "(A)") "* Prepare a cut expression" write (u, "(A)") call syntax_pexpr_init () cut_expr_text = "all Pt > 100 [s]" call ifile_append (ifile, cut_expr_text) call stream_init (stream, ifile) call parse_tree_init_lexpr (parse_tree, stream, .true.) write (u, "(A)") "* Build and initialize a test process" write (u, "(A)") libname = "processes5" procname = libname call os_data%init () call prc_test_create_library (libname, lib) call syntax_model_file_init () allocate (model_tmp) call model_tmp%read (var_str ("Test.mdl"), os_data) call var_list%init_snapshot (model_tmp%get_var_list_ptr ()) model => model_tmp call reset_interaction_counter () call var_list%append_real (var_str ("tolerance"), 0._default) call var_list%append_log (var_str ("?alphas_is_fixed"), .true.) call var_list%append_int (var_str ("seed"), 0) allocate (process) call process%init (procname, lib, os_data, model, var_list) call var_list%final () allocate (phs_test_config_t :: phs_config_template) call process%setup_test_cores () call process%init_components (phs_config_template) write (u, "(A)") "* Prepare a trivial beam setup" write (u, "(A)") sqrts = 1000 call process%setup_beams_sqrts (sqrts, i_core = 1) call process%configure_phs () call process%setup_mci (dispatch_mci_empty) write (u, "(A)") "* Complete process initialization and set cuts" write (u, "(A)") call process%setup_terms () call expr_factory%init (parse_tree%get_root_ptr ()) call process%set_cuts (expr_factory) call process%write (.false., u, & show_var_list=.true., show_expressions=.true., show_os_data=.false.) write (u, "(A)") write (u, "(A)") "* Create a process instance" write (u, "(A)") allocate (process_instance) call process_instance%init (process) write (u, "(A)") write (u, "(A)") "* Inject a set of random numbers" write (u, "(A)") call process_instance%choose_mci (1) call process_instance%set_mcpar ([0._default, 0._default]) write (u, "(A)") write (u, "(A)") "* Set up kinematics and subevt, check cuts (should fail)" write (u, "(A)") call process_instance%select_channel (1) call process_instance%compute_seed_kinematics () call process_instance%compute_hard_kinematics () call process_instance%compute_eff_kinematics () call process_instance%evaluate_expressions () call process_instance%compute_other_channels () call process_instance%write (u) write (u, "(A)") write (u, "(A)") "* Evaluate for another set (should succeed)" write (u, "(A)") call process_instance%reset () call process_instance%set_mcpar ([0.5_default, 0.125_default]) call process_instance%select_channel (1) call process_instance%compute_seed_kinematics () call process_instance%compute_hard_kinematics () call process_instance%compute_eff_kinematics () call process_instance%evaluate_expressions () call process_instance%compute_other_channels () call process_instance%evaluate_trace () call process_instance%write (u) write (u, "(A)") write (u, "(A)") "* Evaluate for another set using convenience procedure & &(failure)" write (u, "(A)") call process_instance%evaluate_sqme (1, [0.0_default, 0.2_default]) call process_instance%write_header (u) write (u, "(A)") write (u, "(A)") "* Evaluate for another set using convenience procedure & &(success)" write (u, "(A)") call process_instance%evaluate_sqme (1, [0.1_default, 0.2_default]) call process_instance%write_header (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call process_instance%final () deallocate (process_instance) call process%final () deallocate (process) call parse_tree_final (parse_tree) call stream_final (stream) call ifile_final (ifile) call syntax_pexpr_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: processes_5" end subroutine processes_5 @ %def processes_5 @ Trivial for testing: do not allocate the MCI record. <>= subroutine dispatch_mci_empty (mci, var_list, process_id, is_nlo) class(mci_t), allocatable, intent(out) :: mci type(var_list_t), intent(in) :: var_list type(string_t), intent(in) :: process_id logical, intent(in), optional :: is_nlo end subroutine dispatch_mci_empty @ %def dispatch_mci_empty @ \subsubsection{Processes: scales and such} Initialize a process and process instance, choose a sampling point and fill the process instance, evaluating a given cut configuration. We use the same trivial process as for the previous test. All momentum and state dependence is trivial, so we just test basic functionality. <>= call test (processes_6, "processes_6", & "handle scales and weight (partonic event)", & u, results) <>= public :: processes_6 <>= subroutine processes_6 (u) integer, intent(in) :: u type(string_t) :: expr_text type(ifile_t) :: ifile type(stream_t) :: stream type(parse_tree_t) :: pt_scale, pt_fac_scale, pt_ren_scale, pt_weight type(process_library_t), target :: lib type(string_t) :: libname type(string_t) :: procname type(os_data_t) :: os_data type(model_t), pointer :: model_tmp type(model_t), pointer :: model type(var_list_t), target :: var_list type(process_t), allocatable, target :: process class(phs_config_t), allocatable :: phs_config_template real(default) :: sqrts type(process_instance_t), allocatable, target :: process_instance type(eval_tree_factory_t) :: expr_factory write (u, "(A)") "* Test output: processes_6" write (u, "(A)") "* Purpose: create a process & &and fill a process instance" write (u, "(A)") write (u, "(A)") "* Prepare expressions" write (u, "(A)") call syntax_pexpr_init () expr_text = "sqrts - 100 GeV" write (u, "(A,A)") "scale = ", char (expr_text) call ifile_clear (ifile) call ifile_append (ifile, expr_text) call stream_init (stream, ifile) call parse_tree_init_expr (pt_scale, stream, .true.) call stream_final (stream) expr_text = "sqrts_hat" write (u, "(A,A)") "fac_scale = ", char (expr_text) call ifile_clear (ifile) call ifile_append (ifile, expr_text) call stream_init (stream, ifile) call parse_tree_init_expr (pt_fac_scale, stream, .true.) call stream_final (stream) expr_text = "eval sqrt (M2) [collect [s]]" write (u, "(A,A)") "ren_scale = ", char (expr_text) call ifile_clear (ifile) call ifile_append (ifile, expr_text) call stream_init (stream, ifile) call parse_tree_init_expr (pt_ren_scale, stream, .true.) call stream_final (stream) expr_text = "n_tot * n_in * n_out * (eval Phi / pi [s])" write (u, "(A,A)") "weight = ", char (expr_text) call ifile_clear (ifile) call ifile_append (ifile, expr_text) call stream_init (stream, ifile) call parse_tree_init_expr (pt_weight, stream, .true.) call stream_final (stream) call ifile_final (ifile) write (u, "(A)") write (u, "(A)") "* Build and initialize a test process" write (u, "(A)") libname = "processes4" procname = libname call os_data%init () call prc_test_create_library (libname, lib) call syntax_model_file_init () allocate (model_tmp) call model_tmp%read (var_str ("Test.mdl"), os_data) call var_list%init_snapshot (model_tmp%get_var_list_ptr ()) model => model_tmp call var_list%append_log (var_str ("?alphas_is_fixed"), .true.) call var_list%append_int (var_str ("seed"), 0) call reset_interaction_counter () allocate (process) call process%init (procname, lib, os_data, model, var_list) call var_list%final () call process%setup_test_cores () allocate (phs_test_config_t :: phs_config_template) call process%init_components (phs_config_template) write (u, "(A)") "* Prepare a trivial beam setup" write (u, "(A)") sqrts = 1000 call process%setup_beams_sqrts (sqrts, i_core = 1) call process%configure_phs () call process%setup_mci (dispatch_mci_empty) write (u, "(A)") "* Complete process initialization and set cuts" write (u, "(A)") call process%setup_terms () call expr_factory%init (pt_scale%get_root_ptr ()) call process%set_scale (expr_factory) call expr_factory%init (pt_fac_scale%get_root_ptr ()) call process%set_fac_scale (expr_factory) call expr_factory%init (pt_ren_scale%get_root_ptr ()) call process%set_ren_scale (expr_factory) call expr_factory%init (pt_weight%get_root_ptr ()) call process%set_weight (expr_factory) call process%write (.false., u, show_expressions=.true.) write (u, "(A)") write (u, "(A)") "* Create a process instance and evaluate" write (u, "(A)") allocate (process_instance) call process_instance%init (process) call process_instance%choose_mci (1) call process_instance%evaluate_sqme (1, [0.5_default, 0.125_default]) call process_instance%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call process_instance%final () deallocate (process_instance) call process%final () deallocate (process) call parse_tree_final (pt_scale) call parse_tree_final (pt_fac_scale) call parse_tree_final (pt_ren_scale) call parse_tree_final (pt_weight) call syntax_pexpr_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: processes_6" end subroutine processes_6 @ %def processes_6 @ \subsubsection{Event expressions} After generating an event, fill the [[subevt]] and evaluate expressions for selection, reweighting, and analysis. <>= call test (events_3, "events_3", & "expression evaluation", & u, results) <>= public :: events_3 <>= subroutine events_3 (u) use processes_ut, only: prepare_test_process, cleanup_test_process integer, intent(in) :: u type(string_t) :: expr_text type(ifile_t) :: ifile type(stream_t) :: stream type(parse_tree_t) :: pt_selection, pt_reweight, pt_analysis type(eval_tree_factory_t) :: expr_factory type(event_t), allocatable, target :: event type(process_t), allocatable, target :: process type(process_instance_t), allocatable, target :: process_instance type(os_data_t) :: os_data type(model_t), pointer :: model type(var_list_t), target :: var_list write (u, "(A)") "* Test output: events_3" write (u, "(A)") "* Purpose: generate an event and evaluate expressions" write (u, "(A)") call syntax_pexpr_init () write (u, "(A)") "* Expression texts" write (u, "(A)") expr_text = "all Pt > 100 [s]" write (u, "(A,A)") "selection = ", char (expr_text) call ifile_clear (ifile) call ifile_append (ifile, expr_text) call stream_init (stream, ifile) call parse_tree_init_lexpr (pt_selection, stream, .true.) call stream_final (stream) expr_text = "1 + sqrts_hat / sqrts" write (u, "(A,A)") "reweight = ", char (expr_text) call ifile_clear (ifile) call ifile_append (ifile, expr_text) call stream_init (stream, ifile) call parse_tree_init_expr (pt_reweight, stream, .true.) call stream_final (stream) expr_text = "true" write (u, "(A,A)") "analysis = ", char (expr_text) call ifile_clear (ifile) call ifile_append (ifile, expr_text) call stream_init (stream, ifile) call parse_tree_init_lexpr (pt_analysis, stream, .true.) call stream_final (stream) call ifile_final (ifile) write (u, "(A)") write (u, "(A)") "* Initialize test process event" call os_data%init () call syntax_model_file_init () allocate (model) call model%read (var_str ("Test.mdl"), os_data) call var_list%init_snapshot (model%get_var_list_ptr ()) call var_list%append_log (var_str ("?alphas_is_fixed"), .true.) call var_list%append_int (var_str ("seed"), 0) allocate (process) allocate (process_instance) call prepare_test_process (process, process_instance, model, var_list) call var_list%final () call process_instance%setup_event_data () write (u, "(A)") write (u, "(A)") "* Initialize event object and set expressions" allocate (event) call event%basic_init () call expr_factory%init (pt_selection%get_root_ptr ()) call event%set_selection (expr_factory) call expr_factory%init (pt_reweight%get_root_ptr ()) call event%set_reweight (expr_factory) call expr_factory%init (pt_analysis%get_root_ptr ()) call event%set_analysis (expr_factory) call event%connect (process_instance, process%get_model_ptr ()) call event%expr%var_list%append_real (var_str ("tolerance"), 0._default) call event%setup_expressions () write (u, "(A)") write (u, "(A)") "* Generate test process event" call process_instance%generate_weighted_event (1) write (u, "(A)") write (u, "(A)") "* Fill event object and evaluate expressions" write (u, "(A)") call event%generate (1, [0.4_default, 0.4_default]) call event%set_index (42) call event%evaluate_expressions () call event%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call event%final () deallocate (event) call cleanup_test_process (process, process_instance) deallocate (process_instance) deallocate (process) call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: events_3" end subroutine events_3 @ %def events_3 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Top Level} The top level consists of \begin{description} \item[commands] Defines generic command-list and command objects, and all specific implementations. Each command type provides a specific functionality. Together with the modules that provide expressions and variables, this module defines the Sindarin language. \item[whizard] This module interprets streams of various kind in terms of the command language. It also contains the unit-test feature. We also define the externally visible procedures here, for the \whizard\ as a library. \item[main] The driver for \whizard\ as a stand-alone program. Contains the command-line interpreter. \item[whizard\_c\_interface] Alternative top-level procedures, for use in the context of a C-compatible caller program. \end{description} \clearpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Commands} This module defines the command language of the main input file. <<[[commands.f90]]>>= <> module commands <> <> <> use io_units use string_utils, only: lower_case, split_string, str use format_utils, only: write_indent use format_defs, only: FMT_14, FMT_19 use diagnostics use constants, only: one use physics_defs use sorting use sf_lhapdf, only: lhapdf_global_reset use os_interface use ifiles use lexers use syntax_rules use parser use analysis use pdg_arrays use variables, only: var_list_t, V_NONE, V_LOG, V_INT, V_REAL, V_CMPLX, V_STR, V_PDG use observables, only: var_list_check_observable use observables, only: var_list_check_result_var use eval_trees use models use auto_components use flavors use polarizations use particle_specifiers use process_libraries use process use instances use prclib_stacks use slha_interface use user_files use eio_data use rt_data use process_configurations use compilations, only: compile_library, compile_executable use integrations, only: integrate_process use restricted_subprocesses, only: get_libname_res use restricted_subprocesses, only: spawn_resonant_subprocess_libraries use event_streams use simulations use radiation_generator <> <> <> <> <> <> <> contains <> end module commands @ %def commands @ \subsection{The command type} The command type is a generic type that holds any command, compiled for execution. Each command may come with its own local environment. The command list that determines this environment is allocated as [[options]], if necessary. (It has to be allocated as a pointer because the type definition is recursive.) The local environment is available as a pointer which either points to the global environment, or is explicitly allocated and initialized. <>= type, abstract :: command_t type(parse_node_t), pointer :: pn => null () class(command_t), pointer :: next => null () type(parse_node_t), pointer :: pn_opt => null () type(command_list_t), pointer :: options => null () type(rt_data_t), pointer :: local => null () contains <> end type command_t @ %def command_t @ Finalizer: If there is an option list, finalize the option list and deallocate. If not, the local environment is just a pointer. <>= procedure :: final => command_final <>= recursive subroutine command_final (cmd) class(command_t), intent(inout) :: cmd if (associated (cmd%options)) then call cmd%options%final () deallocate (cmd%options) call cmd%local%local_final () deallocate (cmd%local) else cmd%local => null () end if end subroutine command_final @ %def command_final @ Allocate a command with the appropriate concrete type. Store the parse node pointer in the command object, so we can reference to it when compiling. <>= subroutine dispatch_command (command, pn) class(command_t), intent(inout), pointer :: command type(parse_node_t), intent(in), target :: pn select case (char (parse_node_get_rule_key (pn))) case ("cmd_model") allocate (cmd_model_t :: command) case ("cmd_library") allocate (cmd_library_t :: command) case ("cmd_process") allocate (cmd_process_t :: command) case ("cmd_nlo") allocate (cmd_nlo_t :: command) case ("cmd_compile") allocate (cmd_compile_t :: command) case ("cmd_exec") allocate (cmd_exec_t :: command) case ("cmd_num", "cmd_complex", "cmd_real", "cmd_int", & "cmd_log_decl", "cmd_log", "cmd_string", "cmd_string_decl", & "cmd_alias", "cmd_result") allocate (cmd_var_t :: command) case ("cmd_slha") allocate (cmd_slha_t :: command) case ("cmd_show") allocate (cmd_show_t :: command) case ("cmd_clear") allocate (cmd_clear_t :: command) case ("cmd_expect") allocate (cmd_expect_t :: command) case ("cmd_beams") allocate (cmd_beams_t :: command) case ("cmd_beams_pol_density") allocate (cmd_beams_pol_density_t :: command) case ("cmd_beams_pol_fraction") allocate (cmd_beams_pol_fraction_t :: command) case ("cmd_beams_momentum") allocate (cmd_beams_momentum_t :: command) case ("cmd_beams_theta") allocate (cmd_beams_theta_t :: command) case ("cmd_beams_phi") allocate (cmd_beams_phi_t :: command) case ("cmd_cuts") allocate (cmd_cuts_t :: command) case ("cmd_scale") allocate (cmd_scale_t :: command) case ("cmd_fac_scale") allocate (cmd_fac_scale_t :: command) case ("cmd_ren_scale") allocate (cmd_ren_scale_t :: command) case ("cmd_weight") allocate (cmd_weight_t :: command) case ("cmd_selection") allocate (cmd_selection_t :: command) case ("cmd_reweight") allocate (cmd_reweight_t :: command) case ("cmd_iterations") allocate (cmd_iterations_t :: command) case ("cmd_integrate") allocate (cmd_integrate_t :: command) case ("cmd_observable") allocate (cmd_observable_t :: command) case ("cmd_histogram") allocate (cmd_histogram_t :: command) case ("cmd_plot") allocate (cmd_plot_t :: command) case ("cmd_graph") allocate (cmd_graph_t :: command) case ("cmd_record") allocate (cmd_record_t :: command) case ("cmd_analysis") allocate (cmd_analysis_t :: command) case ("cmd_alt_setup") allocate (cmd_alt_setup_t :: command) case ("cmd_unstable") allocate (cmd_unstable_t :: command) case ("cmd_stable") allocate (cmd_stable_t :: command) case ("cmd_polarized") allocate (cmd_polarized_t :: command) case ("cmd_unpolarized") allocate (cmd_unpolarized_t :: command) case ("cmd_sample_format") allocate (cmd_sample_format_t :: command) case ("cmd_simulate") allocate (cmd_simulate_t :: command) case ("cmd_rescan") allocate (cmd_rescan_t :: command) case ("cmd_write_analysis") allocate (cmd_write_analysis_t :: command) case ("cmd_compile_analysis") allocate (cmd_compile_analysis_t :: command) case ("cmd_open_out") allocate (cmd_open_out_t :: command) case ("cmd_close_out") allocate (cmd_close_out_t :: command) case ("cmd_printf") allocate (cmd_printf_t :: command) case ("cmd_scan") allocate (cmd_scan_t :: command) case ("cmd_if") allocate (cmd_if_t :: command) case ("cmd_include") allocate (cmd_include_t :: command) case ("cmd_export") allocate (cmd_export_t :: command) case ("cmd_quit") allocate (cmd_quit_t :: command) case default print *, char (parse_node_get_rule_key (pn)) call msg_bug ("Command not implemented") end select command%pn => pn end subroutine dispatch_command @ %def dispatch_command @ Output. We allow for indentation so we can display a command tree. <>= procedure (command_write), deferred :: write <>= abstract interface subroutine command_write (cmd, unit, indent) import class(command_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent end subroutine command_write end interface @ %def command_write @ Compile a command. The command type is already fixed, so this is a deferred type-bound procedure. <>= procedure (command_compile), deferred :: compile <>= abstract interface subroutine command_compile (cmd, global) import class(command_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global end subroutine command_compile end interface @ %def command_compile @ Execute a command. This will use and/or modify the runtime data set. If the [[quit]] flag is set, the caller should terminate command execution. <>= procedure (command_execute), deferred :: execute <>= abstract interface subroutine command_execute (cmd, global) import class(command_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global end subroutine command_execute end interface @ %def command_execute @ \subsection{Options} The [[options]] command list is allocated, initialized, and executed, if the command is associated with an option text in curly braces. If present, a separate local runtime data set [[local]] will be allocated and initialized; otherwise, [[local]] becomes a pointer to the global dataset. For output, we indent the options list. <>= procedure :: write_options => command_write_options <>= recursive subroutine command_write_options (cmd, unit, indent) class(command_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: ind ind = 1; if (present (indent)) ind = indent + 1 if (associated (cmd%options)) call cmd%options%write (unit, ind) end subroutine command_write_options @ %def command_write_options @ Compile the options list, if any. This implies initialization of the local environment. Should be done once the [[pn_opt]] node has been assigned (if applicable), but before the actual command compilation. <>= procedure :: compile_options => command_compile_options <>= recursive subroutine command_compile_options (cmd, global) class(command_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global if (associated (cmd%pn_opt)) then allocate (cmd%local) call cmd%local%local_init (global) call global%copy_globals (cmd%local) allocate (cmd%options) call cmd%options%compile (cmd%pn_opt, cmd%local) call global%restore_globals (cmd%local) call cmd%local%deactivate () else cmd%local => global end if end subroutine command_compile_options @ %def command_compile_options @ Execute options. First prepare the local environment, then execute the command list. <>= procedure :: execute_options => cmd_execute_options <>= recursive subroutine cmd_execute_options (cmd, global) class(command_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global if (associated (cmd%options)) then call cmd%local%activate () call cmd%options%execute (cmd%local) end if end subroutine cmd_execute_options @ %def cmd_execute_options @ This must be called after the parent command has been executed, to undo temporary modifications to the environment. Note that some modifications to [[global]] can become permanent. <>= procedure :: reset_options => cmd_reset_options <>= subroutine cmd_reset_options (cmd, global) class(command_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global if (associated (cmd%options)) then call cmd%local%deactivate (global) end if end subroutine cmd_reset_options @ %def cmd_reset_options @ \subsection{Specific command types} \subsubsection{Model configuration} The command declares a model, looks for the specified file and loads it. <>= type, extends (command_t) :: cmd_model_t private type(string_t) :: name type(string_t) :: scheme logical :: ufo_model = .false. logical :: ufo_path_set = .false. type(string_t) :: ufo_path contains <> end type cmd_model_t @ %def cmd_model_t @ Output <>= procedure :: write => cmd_model_write <>= subroutine cmd_model_write (cmd, unit, indent) class(cmd_model_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A,1x,'""',A,'""')", advance="no") "model =", char (cmd%name) if (cmd%ufo_model) then if (cmd%ufo_path_set) then write (u, "(1x,A,A,A)") "(ufo (", char (cmd%ufo_path), "))" else write (u, "(1x,A)") "(ufo)" end if else if (cmd%scheme /= "") then write (u, "(1x,'(',A,')')") char (cmd%scheme) else write (u, *) end if end subroutine cmd_model_write @ %def cmd_model_write @ Compile. Get the model name and read the model from file, so it is readily available when the command list is executed. If the model has a scheme argument, take this into account. Assign the model pointer in the [[global]] record, so it can be used for (read-only) variable lookup while compiling further commands. <>= procedure :: compile => cmd_model_compile <>= subroutine cmd_model_compile (cmd, global) class(cmd_model_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_name, pn_arg, pn_scheme type(parse_node_t), pointer :: pn_ufo_arg, pn_path type(model_t), pointer :: model type(string_t) :: scheme pn_name => cmd%pn%get_sub_ptr (3) pn_arg => pn_name%get_next_ptr () if (associated (pn_arg)) then pn_scheme => pn_arg%get_sub_ptr () else pn_scheme => null () end if cmd%name = pn_name%get_string () if (associated (pn_scheme)) then select case (char (pn_scheme%get_rule_key ())) case ("ufo_spec") cmd%ufo_model = .true. pn_ufo_arg => pn_scheme%get_sub_ptr (2) if (associated (pn_ufo_arg)) then pn_path => pn_ufo_arg%get_sub_ptr () cmd%ufo_path_set = .true. cmd%ufo_path = pn_path%get_string () end if case default scheme = pn_scheme%get_string () select case (char (lower_case (scheme))) case ("ufo"); cmd%ufo_model = .true. case default; cmd%scheme = scheme end select end select if (cmd%ufo_model) then if (cmd%ufo_path_set) then call preload_ufo_model (model, cmd%name, cmd%ufo_path) else call preload_ufo_model (model, cmd%name) end if else call preload_model (model, cmd%name, cmd%scheme) end if else cmd%scheme = "" call preload_model (model, cmd%name) end if global%model => model if (associated (global%model)) then call global%model%link_var_list (global%var_list) end if contains subroutine preload_model (model, name, scheme) type(model_t), pointer, intent(out) :: model type(string_t), intent(in) :: name type(string_t), intent(in), optional :: scheme model => null () if (associated (global%model)) then if (global%model%matches (name, scheme)) then model => global%model end if end if if (.not. associated (model)) then if (global%model_list%model_exists (name, scheme)) then model => global%model_list%get_model_ptr (name, scheme) else call global%read_model (name, model, scheme) end if end if end subroutine preload_model subroutine preload_ufo_model (model, name, ufo_path) type(model_t), pointer, intent(out) :: model type(string_t), intent(in) :: name type(string_t), intent(in), optional :: ufo_path model => null () if (associated (global%model)) then if (global%model%matches (name, ufo=.true., ufo_path=ufo_path)) then model => global%model end if end if if (.not. associated (model)) then if (global%model_list%model_exists (name, & ufo=.true., ufo_path=ufo_path)) then model => global%model_list%get_model_ptr (name, & ufo=.true., ufo_path=ufo_path) else call global%read_ufo_model (name, model, ufo_path=ufo_path) end if end if end subroutine preload_ufo_model end subroutine cmd_model_compile @ %def cmd_model_compile @ Execute: Insert a pointer into the global data record and reassign the variable list. <>= procedure :: execute => cmd_model_execute <>= subroutine cmd_model_execute (cmd, global) class(cmd_model_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global if (cmd%ufo_model) then if (cmd%ufo_path_set) then call global%select_model (cmd%name, ufo=.true., ufo_path=cmd%ufo_path) else call global%select_model (cmd%name, ufo=.true.) end if else if (cmd%scheme /= "") then call global%select_model (cmd%name, cmd%scheme) else call global%select_model (cmd%name) end if if (.not. associated (global%model)) & call msg_fatal ("Switching to model '" & // char (cmd%name) // "': model not found") end subroutine cmd_model_execute @ %def cmd_model_execute @ \subsubsection{Library configuration} We configure a process library that should hold the subsequently defined processes. If the referenced library exists already, just make it the currently active one. <>= type, extends (command_t) :: cmd_library_t private type(string_t) :: name contains <> end type cmd_library_t @ %def cmd_library_t @ Output. <>= procedure :: write => cmd_library_write <>= subroutine cmd_library_write (cmd, unit, indent) class(cmd_library_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit) call write_indent (u, indent) write (u, "(1x,A,1x,'""',A,'""')") "library =", char (cmd%name) end subroutine cmd_library_write @ %def cmd_library_write @ Compile. Get the library name. <>= procedure :: compile => cmd_library_compile <>= subroutine cmd_library_compile (cmd, global) class(cmd_library_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_name pn_name => parse_node_get_sub_ptr (cmd%pn, 3) cmd%name = parse_node_get_string (pn_name) end subroutine cmd_library_compile @ %def cmd_library_compile @ Execute: Initialize a new library and push it on the library stack (if it does not yet exist). Insert a pointer to the library into the global data record. Then, try to load the library unless the [[rebuild]] flag is set. <>= procedure :: execute => cmd_library_execute <>= subroutine cmd_library_execute (cmd, global) class(cmd_library_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(prclib_entry_t), pointer :: lib_entry type(process_library_t), pointer :: lib logical :: rebuild_library lib => global%prclib_stack%get_library_ptr (cmd%name) rebuild_library = & global%var_list%get_lval (var_str ("?rebuild_library")) if (.not. (associated (lib))) then allocate (lib_entry) call lib_entry%init (cmd%name) lib => lib_entry%process_library_t call global%add_prclib (lib_entry) else call global%update_prclib (lib) end if if (associated (lib) .and. .not. rebuild_library) then call lib%update_status (global%os_data) end if end subroutine cmd_library_execute @ %def cmd_library_execute @ \subsubsection{Process configuration} We define a process-configuration command as a specific type. The incoming and outgoing particles are given evaluation-trees which we transform to PDG-code arrays. For transferring to \oMega, they are reconverted to strings. For the incoming particles, we store parse nodes individually. We do not yet resolve the outgoing state, so we store just a single parse node. This also includes the choice of method for the corresponding process: [[omega]] for \oMega\ matrix elements as Fortran code, [[ovm]] for \oMega\ matrix elements as a bytecode virtual machine, [[test]] for special processes, [[unit_test]] for internal test matrix elements generated by \whizard, [[template]] and [[template_unity]] for test matrix elements generated by \whizard\ as Fortran code similar to the \oMega\ code. If the one-loop program (OLP) \gosam\ is linked, also matrix elements from there (at leading and next-to-leading order) can be generated via [[gosam]]. <>= type, extends (command_t) :: cmd_process_t private type(string_t) :: id integer :: n_in = 0 type(parse_node_p), dimension(:), allocatable :: pn_pdg_in type(parse_node_t), pointer :: pn_out => null () contains <> end type cmd_process_t @ %def cmd_process_t @ Output. The particle expressions are not resolved, so we just list the number of incoming particles. <>= procedure :: write => cmd_process_write <>= subroutine cmd_process_write (cmd, unit, indent) class(cmd_process_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A,A,A,I0,A)") "process: ", char (cmd%id), " (", & size (cmd%pn_pdg_in), " -> X)" call cmd%write_options (u, indent) end subroutine cmd_process_write @ %def cmd_process_write @ Compile. Find and assign the parse nodes. <>= procedure :: compile => cmd_process_compile <>= subroutine cmd_process_compile (cmd, global) class(cmd_process_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_id, pn_in, pn_codes integer :: i pn_id => parse_node_get_sub_ptr (cmd%pn, 2) pn_in => parse_node_get_next_ptr (pn_id, 2) cmd%pn_out => parse_node_get_next_ptr (pn_in, 2) cmd%pn_opt => parse_node_get_next_ptr (cmd%pn_out) call cmd%compile_options (global) cmd%id = parse_node_get_string (pn_id) cmd%n_in = parse_node_get_n_sub (pn_in) pn_codes => parse_node_get_sub_ptr (pn_in) allocate (cmd%pn_pdg_in (cmd%n_in)) do i = 1, cmd%n_in cmd%pn_pdg_in(i)%ptr => pn_codes pn_codes => parse_node_get_next_ptr (pn_codes) end do end subroutine cmd_process_compile @ %def cmd_process_compile @ Command execution. Evaluate the subevents, transform PDG codes into strings, and add the current process configuration to the process library. The initial state will be unique (one or two particles). For the final state, we allow for expressions. The expressions will be expanded until we have a sum of final states. Each distinct final state will get its own process component. To identify equivalent final states, we transform the final state into an array of PDG codes, which we sort and compare. If a particle entry is actually a PDG array, only the first entry in the array is used for the comparison. The user should make sure that there is no overlap between different particles or arrays which would make the expansion ambiguous. There are two possibilities that a process contains more than one component: by an explicit component statement by the user for inclusive processes, or by having one process at NLO level. The first option is determined in the routine [[scan_components]], and determines [[n_components]]. <>= procedure :: execute => cmd_process_execute <>= subroutine cmd_process_execute (cmd, global) class(cmd_process_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(pdg_array_t) :: pdg_in, pdg_out type(pdg_array_t), dimension(:), allocatable :: pdg_out_tab type(string_t), dimension(:), allocatable :: prt_in type(string_t) :: prt_out, prt_out1 type(process_configuration_t) :: prc_config type(prt_expr_t) :: prt_expr_out type(prt_spec_t), dimension(:), allocatable :: prt_spec_in type(prt_spec_t), dimension(:), allocatable :: prt_spec_out type(var_list_t), pointer :: var_list integer, dimension(:), allocatable :: pdg integer, dimension(:), allocatable :: i_term integer, dimension(:), allocatable :: nlo_comp integer :: i, j, n_in, n_out, n_terms, n_components logical :: nlo_fixed_order logical :: qcd_corr, qed_corr type(string_t), dimension(:), allocatable :: prt_in_nlo, prt_out_nlo type(radiation_generator_t) :: radiation_generator type(pdg_list_t) :: pl_in, pl_out, pl_excluded_gauge_splittings type(string_t) :: method, born_me_method, loop_me_method, & correlation_me_method, real_tree_me_method, dglap_me_method integer, dimension(:), allocatable :: i_list logical :: use_real_finite logical :: gks_active logical :: initial_state_colored integer :: comp_mult integer :: gks_multiplicity integer :: n_components_init integer :: alpha_power, alphas_power logical :: requires_soft_mismatch, requires_dglap_remnants if (debug_on) call msg_debug (D_CORE, "cmd_process_execute") var_list => cmd%local%get_var_list_ptr () n_in = size (cmd%pn_pdg_in) allocate (prt_in (n_in), prt_spec_in (n_in)) do i = 1, n_in pdg_in = & eval_pdg_array (cmd%pn_pdg_in(i)%ptr, var_list) prt_in(i) = make_flavor_string (pdg_in, cmd%local%model) prt_spec_in(i) = new_prt_spec (prt_in(i)) end do call compile_prt_expr & (prt_expr_out, cmd%pn_out, var_list, cmd%local%model) call prt_expr_out%expand () call scan_components () allocate (nlo_comp (n_components)) nlo_fixed_order = cmd%local%nlo_fixed_order gks_multiplicity = var_list%get_ival (var_str ('gks_multiplicity')) gks_active = gks_multiplicity > 2 call check_for_nlo_corrections () method = var_list%get_sval (var_str ("$method")) born_me_method = var_list%get_sval (var_str ("$born_me_method")) if (born_me_method == var_str ("")) born_me_method = method use_real_finite = var_list%get_lval (var_str ('?nlo_use_real_partition')) if (nlo_fixed_order) then real_tree_me_method = & var_list%get_sval (var_str ("$real_tree_me_method")) if (real_tree_me_method == var_str ("")) & real_tree_me_method = method loop_me_method = var_list%get_sval (var_str ("$loop_me_method")) if (loop_me_method == var_str ("")) & loop_me_method = method correlation_me_method = & var_list%get_sval (var_str ("$correlation_me_method")) if (correlation_me_method == var_str ("")) & correlation_me_method = method dglap_me_method = var_list%get_sval (var_str ("$dglap_me_method")) if (dglap_me_method == var_str ("")) & dglap_me_method = method call check_nlo_options (cmd%local) end if call determine_needed_components () call prc_config%init (cmd%id, n_in, n_components_init, & cmd%local%model, cmd%local%var_list, & nlo_process = nlo_fixed_order) alpha_power = var_list%get_ival (var_str ("alpha_power")) alphas_power = var_list%get_ival (var_str ("alphas_power")) call prc_config%set_coupling_powers (alpha_power, alphas_power) call setup_components () call prc_config%record (cmd%local) contains <> end subroutine cmd_process_execute @ %def cmd_process_execute @ <>= elemental function is_threshold (method) logical :: is_threshold type(string_t), intent(in) :: method is_threshold = method == var_str ("threshold") end function is_threshold subroutine check_threshold_consistency () if (nlo_fixed_order .and. is_threshold (born_me_method)) then if (.not. (is_threshold (real_tree_me_method) .and. is_threshold (loop_me_method) & .and. is_threshold (correlation_me_method))) then print *, 'born: ', char (born_me_method) print *, 'real: ', char (real_tree_me_method) print *, 'loop: ', char (loop_me_method) print *, 'correlation: ', char (correlation_me_method) call msg_fatal ("Inconsistent methods: All components need to be threshold") end if end if end subroutine check_threshold_consistency @ %def check_threshold_consistency <>= subroutine check_for_nlo_corrections () type(string_t) :: nlo_correction_type type(pdg_array_t), dimension(:), allocatable :: pdg if (nlo_fixed_order .or. gks_active) then nlo_correction_type = & var_list%get_sval (var_str ('$nlo_correction_type')) select case (char(nlo_correction_type)) case ("QCD") qcd_corr = .true.; qed_corr = .false. case ("EW") qcd_corr = .false.; qed_corr = .true. case ("Full") qcd_corr =.true.; qed_corr = .true. case default call msg_fatal ("Invalid NLO correction type! " // & "Valid inputs are: QCD, EW, Full (default: QCD)") end select call check_for_excluded_gauge_boson_splitting_partners () call setup_radiation_generator () end if if (nlo_fixed_order) then call radiation_generator%find_splittings () if (debug2_active (D_CORE)) then print *, '' print *, 'Found (pdg) splittings: ' do i = 1, radiation_generator%if_table%get_length () call radiation_generator%if_table%get_pdg_out (i, pdg) call pdg_array_write_set (pdg) print *, '----------------' end do end if nlo_fixed_order = radiation_generator%contains_emissions () if (.not. nlo_fixed_order) call msg_warning & (arr = [var_str ("No NLO corrections found for process ") // & cmd%id // var_str("."), var_str ("Proceed with usual " // & "leading-order integration and simulation")]) end if end subroutine check_for_nlo_corrections @ %def check_for_nlo_corrections @ <>= subroutine check_for_excluded_gauge_boson_splitting_partners () type(string_t) :: str_excluded_partners type(string_t), dimension(:), allocatable :: excluded_partners type(pdg_list_t) :: pl_tmp, pl_anti integer :: i, n_anti str_excluded_partners = var_list%get_sval & (var_str ("$exclude_gauge_splittings")) if (str_excluded_partners == "") then return else call split_string (str_excluded_partners, & var_str (":"), excluded_partners) call pl_tmp%init (size (excluded_partners)) do i = 1, size (excluded_partners) call pl_tmp%set (i, & cmd%local%model%get_pdg (excluded_partners(i), .true.)) end do call pl_tmp%create_antiparticles (pl_anti, n_anti) call pl_excluded_gauge_splittings%init (pl_tmp%get_size () + n_anti) do i = 1, pl_tmp%get_size () call pl_excluded_gauge_splittings%set (i, pl_tmp%get(i)) end do do i = 1, n_anti j = i + pl_tmp%get_size () call pl_excluded_gauge_splittings%set (j, pl_anti%get(i)) end do end if end subroutine check_for_excluded_gauge_boson_splitting_partners @ %def check_for_excluded_gauge_boson_splitting_partners @ <>= subroutine determine_needed_components () type(string_t) :: fks_method comp_mult = 1 if (nlo_fixed_order) then fks_method = var_list%get_sval (var_str ('$fks_mapping_type')) call check_threshold_consistency () requires_soft_mismatch = fks_method == var_str ('resonances') comp_mult = needed_extra_components (requires_dglap_remnants, & use_real_finite, requires_soft_mismatch) allocate (i_list (comp_mult)) else if (gks_active) then call radiation_generator%generate_multiple & (gks_multiplicity, cmd%local%model) comp_mult = radiation_generator%get_n_gks_states () + 1 end if n_components_init = n_components * comp_mult end subroutine determine_needed_components @ %def determine_needed_components @ <>= subroutine setup_radiation_generator () call split_prt (prt_spec_in, n_in, pl_in) call split_prt (prt_spec_out, n_out, pl_out) call radiation_generator%init (pl_in, pl_out, & pl_excluded_gauge_splittings, qcd = qcd_corr, qed = qed_corr) call radiation_generator%set_n (n_in, n_out, 0) initial_state_colored = pdg_in%has_colored_particles () if ((n_in == 2 .and. initial_state_colored) .or. qed_corr) then requires_dglap_remnants = n_in == 2 .and. initial_state_colored call radiation_generator%set_initial_state_emissions () else requires_dglap_remnants = .false. end if call radiation_generator%set_constraints (.false., .false., .true., .true.) call radiation_generator%setup_if_table (cmd%local%model) end subroutine setup_radiation_generator @ %def setup_radiation_generator @ <>= subroutine scan_components () n_terms = prt_expr_out%get_n_terms () allocate (pdg_out_tab (n_terms)) allocate (i_term (n_terms), source = 0) n_components = 0 SCAN: do i = 1, n_terms if (allocated (pdg)) deallocate (pdg) call prt_expr_out%term_to_array (prt_spec_out, i) n_out = size (prt_spec_out) allocate (pdg (n_out)) do j = 1, n_out prt_out = prt_spec_out(j)%to_string () call split (prt_out, prt_out1, ":") pdg(j) = cmd%local%model%get_pdg (prt_out1) end do pdg_out = sort (pdg) do j = 1, n_components if (pdg_out == pdg_out_tab(j)) cycle SCAN end do n_components = n_components + 1 i_term(n_components) = i pdg_out_tab(n_components) = pdg_out end do SCAN end subroutine scan_components @ <>= subroutine split_prt (prt, n_out, pl) type(prt_spec_t), intent(in), dimension(:), allocatable :: prt integer, intent(in) :: n_out type(pdg_list_t), intent(out) :: pl type(pdg_array_t) :: pdg type(string_t) :: prt_string, prt_tmp integer, parameter :: max_particle_number = 25 integer, dimension(max_particle_number) :: i_particle integer :: i, j, n i_particle = 0 call pl%init (n_out) do i = 1, n_out n = 1 prt_string = prt(i)%to_string () do call split (prt_string, prt_tmp, ":") if (prt_tmp /= "") then i_particle(n) = cmd%local%model%get_pdg (prt_tmp) n = n + 1 else exit end if end do call pdg_array_init (pdg, n - 1) do j = 1, n - 1 call pdg%set (j, i_particle(j)) end do call pl%set (i, pdg) call pdg_array_delete (pdg) end do end subroutine split_prt @ %def split_prt @ <>= subroutine setup_components() integer :: k, i_comp, add_index i_comp = 0 add_index = 0 if (debug_on) call msg_debug (D_CORE, "setup_components") do i = 1, n_components call prt_expr_out%term_to_array (prt_spec_out, i_term(i)) if (nlo_fixed_order) then associate (selected_nlo_parts => cmd%local%selected_nlo_parts) if (debug_on) call msg_debug (D_CORE, "Setting up this NLO component:", & i_comp + 1) call prc_config%setup_component (i_comp + 1, & prt_spec_in, prt_spec_out, & cmd%local%model, var_list, BORN, & can_be_integrated = selected_nlo_parts (BORN)) call radiation_generator%generate_real_particle_strings & (prt_in_nlo, prt_out_nlo) if (debug_on) call msg_debug (D_CORE, "Setting up this NLO component:", & i_comp + 2) call prc_config%setup_component (i_comp + 2, & new_prt_spec (prt_in_nlo), new_prt_spec (prt_out_nlo), & cmd%local%model, var_list, NLO_REAL, & can_be_integrated = selected_nlo_parts (NLO_REAL)) if (debug_on) call msg_debug (D_CORE, "Setting up this NLO component:", & i_comp + 3) call prc_config%setup_component (i_comp + 3, & prt_spec_in, prt_spec_out, & cmd%local%model, var_list, NLO_VIRTUAL, & can_be_integrated = selected_nlo_parts (NLO_VIRTUAL)) if (debug_on) call msg_debug (D_CORE, "Setting up this NLO component:", & i_comp + 4) call prc_config%setup_component (i_comp + 4, & prt_spec_in, prt_spec_out, & cmd%local%model, var_list, NLO_SUBTRACTION, & can_be_integrated = selected_nlo_parts (NLO_SUBTRACTION)) do k = 1, 4 i_list(k) = i_comp + k end do if (requires_dglap_remnants) then if (debug_on) call msg_debug (D_CORE, "Setting up this NLO component:", & i_comp + 5) call prc_config%setup_component (i_comp + 5, & prt_spec_in, prt_spec_out, & cmd%local%model, var_list, NLO_DGLAP, & can_be_integrated = selected_nlo_parts (NLO_DGLAP)) i_list(5) = i_comp + 5 add_index = add_index + 1 end if if (use_real_finite) then if (debug_on) call msg_debug (D_CORE, "Setting up this NLO component:", & i_comp + 5 + add_index) call prc_config%setup_component (i_comp + 5 + add_index, & new_prt_spec (prt_in_nlo), new_prt_spec (prt_out_nlo), & cmd%local%model, var_list, NLO_REAL, & can_be_integrated = selected_nlo_parts (NLO_REAL)) i_list(5 + add_index) = i_comp + 5 + add_index add_index = add_index + 1 end if if (requires_soft_mismatch) then if (debug_on) call msg_debug (D_CORE, "Setting up this NLO component:", & i_comp + 5 + add_index) call prc_config%setup_component (i_comp + 5 + add_index, & prt_spec_in, prt_spec_out, & cmd%local%model, var_list, NLO_MISMATCH, & can_be_integrated = selected_nlo_parts (NLO_MISMATCH)) i_list(5 + add_index) = i_comp + 5 + add_index end if call prc_config%set_component_associations (i_list, & requires_dglap_remnants, use_real_finite, & requires_soft_mismatch) end associate else if (gks_active) then call prc_config%setup_component (i_comp + 1, prt_spec_in, & prt_spec_out, cmd%local%model, var_list, BORN, & can_be_integrated = .true.) call radiation_generator%reset_queue () do j = 1, comp_mult prt_out_nlo = radiation_generator%get_next_state () call prc_config%setup_component (i_comp + 1 + j, & new_prt_spec (prt_in), new_prt_spec (prt_out_nlo), & cmd%local%model, var_list, GKS, can_be_integrated = .false.) end do else call prc_config%setup_component (i, & prt_spec_in, prt_spec_out, & cmd%local%model, var_list, can_be_integrated = .true.) end if i_comp = i_comp + comp_mult end do end subroutine setup_components @ @ These three functions should be bundled with the logicals they depend on into an object (the pcm?). <>= subroutine check_nlo_options (local) type(rt_data_t), intent(in) :: local type(var_list_t), pointer :: var_list => null () real :: mult_real, mult_virt, mult_dglap logical :: nlo, combined, powheg logical :: case_lo_but_any_other logical :: case_nlo_powheg_but_not_combined logical :: vamp_equivalences_enabled logical :: fixed_order_nlo_events var_list => local%get_var_list_ptr () nlo = local%nlo_fixed_order combined = var_list%get_lval (var_str ('?combined_nlo_integration')) powheg = var_list%get_lval (var_str ('?powheg_matching')) case_lo_but_any_other = .not. nlo .and. any ([combined, powheg]) case_nlo_powheg_but_not_combined = & nlo .and. powheg .and. .not. combined if (case_lo_but_any_other) then call msg_fatal ("Option mismatch: Leading order process is selected & &but either powheg_matching or combined_nlo_integration & &is set to true.") else if (case_nlo_powheg_but_not_combined) then call msg_fatal ("POWHEG requires the 'combined_nlo_integration'-option & &to be set to true.") end if fixed_order_nlo_events = & var_list%get_lval (var_str ('?fixed_order_nlo_events')) if (fixed_order_nlo_events .and. .not. combined .and. & count (local%selected_nlo_parts) > 1) & call msg_fatal ("Option mismatch: Fixed order NLO events of multiple ", & [var_str ("components are requested, but ?combined_nlo_integration "), & var_str ("is false. You can either switch to the combined NLO "), & var_str ("integration mode for the full process or choose one "), & var_str ("individual NLO component to generate events with.")]) associate (nlo_parts => local%selected_nlo_parts) ! TODO (PS-2020-03-26): This technically leaves the possibility to skip this ! message by deactivating the dglap component for a proton collider process. ! To circumvent this, the selected_nlo_parts should be refactored. if (combined .and. .not. (nlo_parts(BORN) & .and. nlo_parts(NLO_VIRTUAL) .and. nlo_parts(NLO_REAL))) then call msg_fatal ("A combined integration of anything else than", & [var_str ("all NLO components together is not supported.")]) end if end associate mult_real = local%var_list%get_rval (var_str ("mult_call_real")) mult_virt = local%var_list%get_rval (var_str ("mult_call_virt")) mult_dglap = local%var_list%get_rval (var_str ("mult_call_dglap")) if (combined .and. (mult_real /= one .or. mult_virt /= one .or. mult_dglap /= one)) then call msg_warning ("mult_call_real, mult_call_virt and mult_call_dglap", & [var_str (" will be ignored because of ?combined_nlo_integration = true. ")]) end if vamp_equivalences_enabled = var_list%get_lval & (var_str ('?use_vamp_equivalences')) if (nlo .and. vamp_equivalences_enabled) & call msg_warning ("You have not disabled VAMP equivalences. ", & [var_str (" Note that they are automatically switched off "), & var_str (" for NLO calculations.")]) end subroutine check_nlo_options @ %def check_nlo_options @ There are four components for a general NLO process, namely Born, real, virtual and subtraction. There will be additional components for DGLAP remnant, in case real contributions are split into singular and finite pieces, and for resonance-aware FKS subtraction for the needed soft mismatch component. <>= pure function needed_extra_components (requires_dglap_remnant, & use_real_finite, requires_soft_mismatch) result (n) integer :: n logical, intent(in) :: requires_dglap_remnant, & use_real_finite, requires_soft_mismatch n = 4 if (requires_dglap_remnant) n = n + 1 if (use_real_finite) n = n + 1 if (requires_soft_mismatch) n = n + 1 end function needed_extra_components @ %def needed_extra_components @ This is a method of the eval tree, but cannot be coded inside the [[expressions]] module since it uses the [[model]] and [[flv]] types which are not available there. <>= function make_flavor_string (aval, model) result (prt) type(string_t) :: prt type(pdg_array_t), intent(in) :: aval type(model_t), intent(in), target :: model integer, dimension(:), allocatable :: pdg type(flavor_t), dimension(:), allocatable :: flv integer :: i pdg = aval allocate (flv (size (pdg))) call flv%init (pdg, model) if (size (pdg) /= 0) then prt = flv(1)%get_name () do i = 2, size (flv) prt = prt // ":" // flv(i)%get_name () end do else prt = "?" end if end function make_flavor_string @ %def make_flavor_string @ Create a pdg array from a particle-specification array <>= function make_pdg_array (prt, model) result (pdg_array) type(prt_spec_t), intent(in), dimension(:) :: prt type(model_t), intent(in) :: model integer, dimension(:), allocatable :: aval type(pdg_array_t) :: pdg_array type(flavor_t) :: flv integer :: k allocate (aval (size (prt))) do k = 1, size (prt) call flv%init (prt(k)%to_string (), model) aval (k) = flv%get_pdg () end do pdg_array = aval end function make_pdg_array @ %def make_pdg_array @ Compile a (possible nested) expression, to obtain a particle-specifier expression which we can process further. <>= recursive subroutine compile_prt_expr (prt_expr, pn, var_list, model) type(prt_expr_t), intent(out) :: prt_expr type(parse_node_t), intent(in), target :: pn type(var_list_t), intent(in), target :: var_list type(model_t), intent(in), target :: model type(parse_node_t), pointer :: pn_entry, pn_term, pn_addition type(pdg_array_t) :: pdg type(string_t) :: prt_string integer :: n_entry, n_term, i select case (char (parse_node_get_rule_key (pn))) case ("prt_state_list") n_entry = parse_node_get_n_sub (pn) pn_entry => parse_node_get_sub_ptr (pn) if (n_entry == 1) then call compile_prt_expr (prt_expr, pn_entry, var_list, model) else call prt_expr%init_list (n_entry) select type (x => prt_expr%x) type is (prt_spec_list_t) do i = 1, n_entry call compile_prt_expr (x%expr(i), pn_entry, var_list, model) pn_entry => parse_node_get_next_ptr (pn_entry) end do end select end if case ("prt_state_sum") n_term = parse_node_get_n_sub (pn) pn_term => parse_node_get_sub_ptr (pn) pn_addition => pn_term if (n_term == 1) then call compile_prt_expr (prt_expr, pn_term, var_list, model) else call prt_expr%init_sum (n_term) select type (x => prt_expr%x) type is (prt_spec_sum_t) do i = 1, n_term call compile_prt_expr (x%expr(i), pn_term, var_list, model) pn_addition => parse_node_get_next_ptr (pn_addition) if (associated (pn_addition)) & pn_term => parse_node_get_sub_ptr (pn_addition, 2) end do end select end if case ("cexpr") pdg = eval_pdg_array (pn, var_list) prt_string = make_flavor_string (pdg, model) call prt_expr%init_spec (new_prt_spec (prt_string)) case default call parse_node_write_rec (pn) call msg_bug ("compile prt expr: impossible syntax rule") end select end subroutine compile_prt_expr @ %def compile_prt_expr @ \subsubsection{Initiating a NLO calculation} <>= type, extends (command_t) :: cmd_nlo_t private integer, dimension(:), allocatable :: nlo_component contains <> end type cmd_nlo_t @ %def cmd_nlo_t @ <>= procedure :: write => cmd_nlo_write <>= subroutine cmd_nlo_write (cmd, unit, indent) class(cmd_nlo_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent end subroutine cmd_nlo_write @ %def cmd_nlo_write @ As it is, the NLO calculation is switched on by putting {nlo} behind the process definition. This should be made nicer in the future. <>= procedure :: compile => cmd_nlo_compile <>= subroutine cmd_nlo_compile (cmd, global) class(cmd_nlo_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_arg, pn_comp integer :: i, n_comp pn_arg => parse_node_get_sub_ptr (cmd%pn, 3) if (associated (pn_arg)) then n_comp = parse_node_get_n_sub (pn_arg) allocate (cmd%nlo_component (n_comp)) pn_comp => parse_node_get_sub_ptr (pn_arg) i = 0 do while (associated (pn_comp)) i = i + 1 cmd%nlo_component(i) = component_status & (parse_node_get_rule_key (pn_comp)) pn_comp => parse_node_get_next_ptr (pn_comp) end do else allocate (cmd%nlo_component (0)) end if end subroutine cmd_nlo_compile @ %def cmd_nlo_compile @ % TODO (PS-2020-03-26): This routine still needs to be adopted % to cope with more than 5 components. <>= procedure :: execute => cmd_nlo_execute <>= subroutine cmd_nlo_execute (cmd, global) class(cmd_nlo_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(string_t) :: string integer :: n, i, j logical, dimension(0:5) :: selected_nlo_parts if (debug_on) call msg_debug (D_CORE, "cmd_nlo_execute") selected_nlo_parts = .false. if (allocated (cmd%nlo_component)) then n = size (cmd%nlo_component) else n = 0 end if do i = 1, n select case (cmd%nlo_component (i)) case (BORN, NLO_VIRTUAL, NLO_MISMATCH, NLO_DGLAP, NLO_REAL) selected_nlo_parts(cmd%nlo_component (i)) = .true. case (NLO_FULL) selected_nlo_parts = .true. selected_nlo_parts (NLO_SUBTRACTION) = .false. case default string = var_str ("") do j = BORN, NLO_DGLAP string = string // component_status (j) // ", " end do string = string // component_status (NLO_FULL) call msg_fatal ("Invalid NLO mode. Valid modes are: " // & char (string)) end select end do global%nlo_fixed_order = any (selected_nlo_parts) global%selected_nlo_parts = selected_nlo_parts allocate (global%nlo_component (size (cmd%nlo_component))) global%nlo_component = cmd%nlo_component end subroutine cmd_nlo_execute @ %def cmd_nlo_execute @ \subsubsection{Process compilation} <>= type, extends (command_t) :: cmd_compile_t private type(string_t), dimension(:), allocatable :: libname logical :: make_executable = .false. type(string_t) :: exec_name contains <> end type cmd_compile_t @ %def cmd_compile_t @ Output: list all libraries to be compiled. <>= procedure :: write => cmd_compile_write <>= subroutine cmd_compile_write (cmd, unit, indent) class(cmd_compile_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u, i u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)", advance="no") "compile (" if (allocated (cmd%libname)) then do i = 1, size (cmd%libname) if (i > 1) write (u, "(A,1x)", advance="no") "," write (u, "('""',A,'""')", advance="no") char (cmd%libname(i)) end do end if write (u, "(A)") ")" end subroutine cmd_compile_write @ %def cmd_compile_write @ Compile the libraries specified in the argument. If the argument is empty, compile all libraries which can be found in the process library stack. <>= procedure :: compile => cmd_compile_compile <>= subroutine cmd_compile_compile (cmd, global) class(cmd_compile_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_cmd, pn_clause, pn_arg, pn_lib type(parse_node_t), pointer :: pn_exec_name_spec, pn_exec_name integer :: n_lib, i pn_cmd => parse_node_get_sub_ptr (cmd%pn) pn_clause => parse_node_get_sub_ptr (pn_cmd) pn_exec_name_spec => parse_node_get_sub_ptr (pn_clause, 2) if (associated (pn_exec_name_spec)) then pn_exec_name => parse_node_get_sub_ptr (pn_exec_name_spec, 2) else pn_exec_name => null () end if pn_arg => parse_node_get_next_ptr (pn_clause) cmd%pn_opt => parse_node_get_next_ptr (pn_cmd) call cmd%compile_options (global) if (associated (pn_arg)) then n_lib = parse_node_get_n_sub (pn_arg) else n_lib = 0 end if if (n_lib > 0) then allocate (cmd%libname (n_lib)) pn_lib => parse_node_get_sub_ptr (pn_arg) do i = 1, n_lib cmd%libname(i) = parse_node_get_string (pn_lib) pn_lib => parse_node_get_next_ptr (pn_lib) end do end if if (associated (pn_exec_name)) then cmd%make_executable = .true. cmd%exec_name = parse_node_get_string (pn_exec_name) end if end subroutine cmd_compile_compile @ %def cmd_compile_compile @ Command execution. Generate code, write driver, compile and link. Do this for all libraries in the list. If no library names have been given and stored while compiling this command, we collect all libraries from the current stack and compile those. As a bonus, a compiled library may be able to spawn new process libraries. For instance, a processes may ask for a set of resonant subprocesses which go into their own library, but this can be determined only after the process is available as a compiled object. Therefore, the compilation loop is implemented as a recursive internal subroutine. We can compile static libraries (which actually just loads them). However, we can't incorporate in a generated executable. <>= procedure :: execute => cmd_compile_execute <>= subroutine cmd_compile_execute (cmd, global) class(cmd_compile_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(string_t), dimension(:), allocatable :: libname, libname_static integer :: i, n_lib - <> - <> + <> + <> if (allocated (cmd%libname)) then allocate (libname (size (cmd%libname))) libname = cmd%libname else call cmd%local%prclib_stack%get_names (libname) end if n_lib = size (libname) if (cmd%make_executable) then call get_prclib_static (libname_static) do i = 1, n_lib if (any (libname_static == libname(i))) then call msg_fatal ("Compile: can't include static library '" & // char (libname(i)) // "'") end if end do call compile_executable (cmd%exec_name, libname, cmd%local) else call compile_libraries (libname) call global%update_prclib & (global%prclib_stack%get_library_ptr (libname(n_lib))) end if - <> + <> contains recursive subroutine compile_libraries (libname) type(string_t), dimension(:), intent(in) :: libname integer :: i type(string_t), dimension(:), allocatable :: libname_extra type(process_library_t), pointer :: lib_saved do i = 1, size (libname) call compile_library (libname(i), cmd%local) lib_saved => global%prclib call spawn_extra_libraries & (libname(i), cmd%local, global, libname_extra) call compile_libraries (libname_extra) call global%update_prclib (lib_saved) end do end subroutine compile_libraries end subroutine cmd_compile_execute @ %def cmd_compile_execute -<>= -@ -<>= -@ -<>= -@ +<>= +<>= +<>= @ The parallelization leads to undefined behavior while writing simultaneously to one file. The master worker has to initialize single-handed the corresponding library files. The slave worker will wait with a blocking [[MPI_BCAST]] until they receive a logical flag. -<>= +<>= logical :: compile_init integer :: rank, n_size -<>= +<>= if (debug_on) call msg_debug (D_MPI, "cmd_compile_execute") compile_init = .false. call mpi_get_comm_id (n_size, rank) if (debug_on) call msg_debug (D_MPI, "n_size", rank) if (debug_on) call msg_debug (D_MPI, "rank", rank) if (rank /= 0) then if (debug_on) call msg_debug (D_MPI, "wait for master") call MPI_bcast (compile_init, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD) else compile_init = .true. end if if (compile_init) then -<>= +<>= if (rank == 0) then if (debug_on) call msg_debug (D_MPI, "load slaves") call MPI_bcast (compile_init, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD) end if end if call MPI_barrier (MPI_COMM_WORLD) @ %def cmd_compile_execute_mpi @ This is the interface to the external procedure which returns the names of all static libraries which are part of the executable. (The default is none.) The routine must allocate the array. <>= public :: get_prclib_static <>= interface subroutine get_prclib_static (libname) import type(string_t), dimension(:), intent(inout), allocatable :: libname end subroutine get_prclib_static end interface @ %def get_prclib_static @ Spawn extra libraries. We can ask the processes within a compiled library, which we have available at this point, whether they need additional processes which should go into their own libraries. The current implementation only concerns resonant subprocesses. Note that the libraries should be created (source code), but not be compiled here. This is done afterwards. <>= subroutine spawn_extra_libraries (libname, local, global, libname_extra) type(string_t), intent(in) :: libname type(rt_data_t), intent(inout), target :: local type(rt_data_t), intent(inout), target :: global type(string_t), dimension(:), allocatable, intent(out) :: libname_extra type(string_t), dimension(:), allocatable :: libname_res allocate (libname_extra (0)) call spawn_resonant_subprocess_libraries & (libname, local, global, libname_res) if (allocated (libname_res)) libname_extra = [libname_extra, libname_res] end subroutine spawn_extra_libraries @ %def spawn_extra_libraries @ \subsubsection{Execute a shell command} The argument is a string expression. <>= type, extends (command_t) :: cmd_exec_t private type(parse_node_t), pointer :: pn_command => null () contains <> end type cmd_exec_t @ %def cmd_exec_t @ Simply tell the status. <>= procedure :: write => cmd_exec_write <>= subroutine cmd_exec_write (cmd, unit, indent) class(cmd_exec_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) if (associated (cmd%pn_command)) then write (u, "(1x,A)") "exec: [command associated]" else write (u, "(1x,A)") "exec: [undefined]" end if end subroutine cmd_exec_write @ %def cmd_exec_write @ Compile the exec command. <>= procedure :: compile => cmd_exec_compile <>= subroutine cmd_exec_compile (cmd, global) class(cmd_exec_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_arg, pn_command pn_arg => parse_node_get_sub_ptr (cmd%pn, 2) pn_command => parse_node_get_sub_ptr (pn_arg) cmd%pn_command => pn_command end subroutine cmd_exec_compile @ %def cmd_exec_compile @ Execute the specified shell command. <>= procedure :: execute => cmd_exec_execute <>= subroutine cmd_exec_execute (cmd, global) class(cmd_exec_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(string_t) :: command logical :: is_known integer :: status command = eval_string (cmd%pn_command, global%var_list, is_known=is_known) if (is_known) then if (command /= "") then call os_system_call (command, status, verbose=.true.) if (status /= 0) then write (msg_buffer, "(A,I0)") "Return code = ", status call msg_message () call msg_error ("System command returned with nonzero status code") end if end if end if end subroutine cmd_exec_execute @ %def cmd_exec_execute @ \subsubsection{Variable declaration} A variable can have various types. Hold the definition as an eval tree. There are intrinsic variables, user variables, and model variables. The latter are further divided in independent variables and dependent variables. Regarding model variables: When dealing with them, we always look at two variable lists in parallel. The global (or local) variable list contains the user-visible values. It includes variables that correspond to variables in the current model's list. These, in turn, are pointers to the model's parameter list, so the model is always in sync, internally. To keep the global variable list in sync with the model, the global variables carry the [[is_copy]] property and contain a separate pointer to the model variable. (The pointer is reassigned whenever the model changes.) Modifying the global variable changes two values simultaneously: the visible value and the model variable, via this extra pointer. After each modification, we update dependent parameters in the model variable list and re-synchronize the global variable list (again, using these pointers) with the model variable this. In the last step, modifications in the derived parameters become visible. When we integrate a process, we capture the current variable list of the current model in a separate model instance, which is stored in the process object. Thus, the model parameters associated to this process at this time are preserved for the lifetime of the process object. When we generate or rescan events, we can again capture a local model variable list in a model instance. This allows us to reweight event by event with different parameter sets simultaneously. <>= type, extends (command_t) :: cmd_var_t private type(string_t) :: name integer :: type = V_NONE type(parse_node_t), pointer :: pn_value => null () logical :: is_intrinsic = .false. logical :: is_model_var = .false. contains <> end type cmd_var_t @ %def cmd_var_t @ Output. We know name, type, and properties, but not the value. <>= procedure :: write => cmd_var_write <>= subroutine cmd_var_write (cmd, unit, indent) class(cmd_var_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A,A,A)", advance="no") "var: ", char (cmd%name), " (" select case (cmd%type) case (V_NONE) write (u, "(A)", advance="no") "[unknown]" case (V_LOG) write (u, "(A)", advance="no") "logical" case (V_INT) write (u, "(A)", advance="no") "int" case (V_REAL) write (u, "(A)", advance="no") "real" case (V_CMPLX) write (u, "(A)", advance="no") "complex" case (V_STR) write (u, "(A)", advance="no") "string" case (V_PDG) write (u, "(A)", advance="no") "alias" end select if (cmd%is_intrinsic) then write (u, "(A)", advance="no") ", intrinsic" end if if (cmd%is_model_var) then write (u, "(A)", advance="no") ", model" end if write (u, "(A)") ")" end subroutine cmd_var_write @ %def cmd_var_write @ Compile the lhs and determine the variable name and type. Check whether this variable can be created or modified as requested, and append the value to the variable list, if appropriate. The value is initially undefined. The rhs is assigned to a pointer, to be compiled and evaluated when the command is executed. <>= procedure :: compile => cmd_var_compile <>= subroutine cmd_var_compile (cmd, global) class(cmd_var_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_var, pn_name type(parse_node_t), pointer :: pn_result, pn_proc type(string_t) :: var_name type(var_list_t), pointer :: model_vars integer :: type logical :: new pn_result => null () new = .false. select case (char (parse_node_get_rule_key (cmd%pn))) case ("cmd_log_decl"); type = V_LOG pn_var => parse_node_get_sub_ptr (cmd%pn, 2) if (.not. associated (pn_var)) then ! handle masked syntax error cmd%type = V_NONE; return end if pn_name => parse_node_get_sub_ptr (pn_var, 2) new = .true. case ("cmd_log"); type = V_LOG pn_name => parse_node_get_sub_ptr (cmd%pn, 2) case ("cmd_int"); type = V_INT pn_name => parse_node_get_sub_ptr (cmd%pn, 2) new = .true. case ("cmd_real"); type = V_REAL pn_name => parse_node_get_sub_ptr (cmd%pn, 2) new = .true. case ("cmd_complex"); type = V_CMPLX pn_name => parse_node_get_sub_ptr (cmd%pn, 2) new = .true. case ("cmd_num"); type = V_NONE pn_name => parse_node_get_sub_ptr (cmd%pn) case ("cmd_string_decl"); type = V_STR pn_var => parse_node_get_sub_ptr (cmd%pn, 2) if (.not. associated (pn_var)) then ! handle masked syntax error cmd%type = V_NONE; return end if pn_name => parse_node_get_sub_ptr (pn_var, 2) new = .true. case ("cmd_string"); type = V_STR pn_name => parse_node_get_sub_ptr (cmd%pn, 2) case ("cmd_alias"); type = V_PDG pn_name => parse_node_get_sub_ptr (cmd%pn, 2) new = .true. case ("cmd_result"); type = V_REAL pn_name => parse_node_get_sub_ptr (cmd%pn) pn_result => parse_node_get_sub_ptr (pn_name) pn_proc => parse_node_get_next_ptr (pn_result) case default call parse_node_mismatch & ("logical|int|real|complex|?|$|alias|var_name", cmd%pn) ! $ end select if (.not. associated (pn_name)) then ! handle masked syntax error cmd%type = V_NONE; return end if if (.not. associated (pn_result)) then var_name = parse_node_get_string (pn_name) else var_name = parse_node_get_key (pn_result) & // "(" // parse_node_get_string (pn_proc) // ")" end if select case (type) case (V_LOG); var_name = "?" // var_name case (V_STR); var_name = "$" // var_name ! $ end select if (associated (global%model)) then model_vars => global%model%get_var_list_ptr () else model_vars => null () end if call var_list_check_observable (global%var_list, var_name, type) call var_list_check_result_var (global%var_list, var_name, type) call global%var_list%check_user_var (var_name, type, new) cmd%name = var_name cmd%pn_value => parse_node_get_next_ptr (pn_name, 2) if (global%var_list%contains (cmd%name, follow_link = .false.)) then ! local variable cmd%is_intrinsic = & global%var_list%is_intrinsic (cmd%name, follow_link = .false.) cmd%type = & global%var_list%get_type (cmd%name, follow_link = .false.) else if (new) cmd%type = type if (global%var_list%contains (cmd%name, follow_link = .true.)) then ! global variable cmd%is_intrinsic = & global%var_list%is_intrinsic (cmd%name, follow_link = .true.) if (cmd%type == V_NONE) then cmd%type = & global%var_list%get_type (cmd%name, follow_link = .true.) end if else if (associated (model_vars)) then ! check model variable cmd%is_model_var = & model_vars%contains (cmd%name) if (cmd%type == V_NONE) then cmd%type = & model_vars%get_type (cmd%name) end if end if if (cmd%type == V_NONE) then call msg_fatal ("Variable '" // char (cmd%name) // "' " & // "set without declaration") cmd%type = V_NONE; return end if if (cmd%is_model_var) then if (new) then call msg_fatal ("Model variable '" // char (cmd%name) // "' " & // "redeclared") else if (model_vars%is_locked (cmd%name)) then call msg_fatal ("Model variable '" // char (cmd%name) // "' " & // "is locked") end if else select case (cmd%type) case (V_LOG) call global%var_list%append_log (cmd%name, & intrinsic=cmd%is_intrinsic, user=.true.) case (V_INT) call global%var_list%append_int (cmd%name, & intrinsic=cmd%is_intrinsic, user=.true.) case (V_REAL) call global%var_list%append_real (cmd%name, & intrinsic=cmd%is_intrinsic, user=.true.) case (V_CMPLX) call global%var_list%append_cmplx (cmd%name, & intrinsic=cmd%is_intrinsic, user=.true.) case (V_PDG) call global%var_list%append_pdg_array (cmd%name, & intrinsic=cmd%is_intrinsic, user=.true.) case (V_STR) call global%var_list%append_string (cmd%name, & intrinsic=cmd%is_intrinsic, user=.true.) end select end if end if end subroutine cmd_var_compile @ %def cmd_var_compile @ Execute. Evaluate the definition and assign the variable value. If the variable is a model variable, take a snapshot of the model if necessary and set the variable in the local model. <>= procedure :: execute => cmd_var_execute <>= subroutine cmd_var_execute (cmd, global) class(cmd_var_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list real(default) :: rval logical :: is_known, pacified var_list => global%get_var_list_ptr () if (cmd%is_model_var) then pacified = var_list%get_lval (var_str ("?pacify")) rval = eval_real (cmd%pn_value, var_list, is_known=is_known) call global%model_set_real & (cmd%name, rval, verbose=.true., pacified=pacified) else if (cmd%type /= V_NONE) then call cmd%set_value (var_list, verbose=.true.) end if end subroutine cmd_var_execute @ %def cmd_var_execute @ Copy the value to the variable list, where the variable should already exist. <>= procedure :: set_value => cmd_var_set_value <>= subroutine cmd_var_set_value (var, var_list, verbose, model_name) class(cmd_var_t), intent(inout) :: var type(var_list_t), intent(inout), target :: var_list logical, intent(in), optional :: verbose type(string_t), intent(in), optional :: model_name logical :: lval, pacified integer :: ival real(default) :: rval complex(default) :: cval type(pdg_array_t) :: aval type(string_t) :: sval logical :: is_known pacified = var_list%get_lval (var_str ("?pacify")) select case (var%type) case (V_LOG) lval = eval_log (var%pn_value, var_list, is_known=is_known) call var_list%set_log (var%name, & lval, is_known, verbose=verbose, model_name=model_name) case (V_INT) ival = eval_int (var%pn_value, var_list, is_known=is_known) call var_list%set_int (var%name, & ival, is_known, verbose=verbose, model_name=model_name) case (V_REAL) rval = eval_real (var%pn_value, var_list, is_known=is_known) call var_list%set_real (var%name, & rval, is_known, verbose=verbose, & model_name=model_name, pacified = pacified) case (V_CMPLX) cval = eval_cmplx (var%pn_value, var_list, is_known=is_known) call var_list%set_cmplx (var%name, & cval, is_known, verbose=verbose, & model_name=model_name, pacified = pacified) case (V_PDG) aval = eval_pdg_array (var%pn_value, var_list, is_known=is_known) call var_list%set_pdg_array (var%name, & aval, is_known, verbose=verbose, model_name=model_name) case (V_STR) sval = eval_string (var%pn_value, var_list, is_known=is_known) call var_list%set_string (var%name, & sval, is_known, verbose=verbose, model_name=model_name) end select end subroutine cmd_var_set_value @ %def cmd_var_set_value @ \subsubsection{SLHA} Read a SLHA (SUSY Les Houches Accord) file to fill the appropriate model parameters. We do not access the current variable record, but directly work on the appropriate SUSY model, which is loaded if necessary. We may be in read or write mode. In the latter case, we may write just input parameters, or the complete spectrum, or the spectrum with all decays. <>= type, extends (command_t) :: cmd_slha_t private type(string_t) :: file logical :: write_mode = .false. contains <> end type cmd_slha_t @ %def cmd_slha_t @ Output. <>= procedure :: write => cmd_slha_write <>= subroutine cmd_slha_write (cmd, unit, indent) class(cmd_slha_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A,A)") "slha: file name = ", char (cmd%file) write (u, "(1x,A,L1)") "slha: write mode = ", cmd%write_mode end subroutine cmd_slha_write @ %def cmd_slha_write @ Compile. Read the filename and store it. <>= procedure :: compile => cmd_slha_compile <>= subroutine cmd_slha_compile (cmd, global) class(cmd_slha_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_key, pn_arg, pn_file pn_key => parse_node_get_sub_ptr (cmd%pn) pn_arg => parse_node_get_next_ptr (pn_key) pn_file => parse_node_get_sub_ptr (pn_arg) call cmd%compile_options (global) cmd%pn_opt => parse_node_get_next_ptr (pn_arg) select case (char (parse_node_get_key (pn_key))) case ("read_slha") cmd%write_mode = .false. case ("write_slha") cmd%write_mode = .true. case default call parse_node_mismatch ("read_slha|write_slha", cmd%pn) end select cmd%file = parse_node_get_string (pn_file) end subroutine cmd_slha_compile @ %def cmd_slha_compile @ Execute. Read or write the specified SLHA file. Behind the scenes, this will first read the WHIZARD model file, then read the SLHA file and assign the SLHA parameters as far as determined by [[dispatch_slha]]. Finally, the global variables are synchronized with the model. This is similar to executing [[cmd_model]]. <>= procedure :: execute => cmd_slha_execute <>= subroutine cmd_slha_execute (cmd, global) class(cmd_slha_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global logical :: input, spectrum, decays if (cmd%write_mode) then input = .true. spectrum = .false. decays = .false. if (.not. associated (cmd%local%model)) then call msg_fatal ("SLHA: local model not associated") return end if call slha_write_file & (cmd%file, cmd%local%model, & input = input, spectrum = spectrum, decays = decays) else if (.not. associated (global%model)) then call msg_fatal ("SLHA: global model not associated") return end if call dispatch_slha (cmd%local%var_list, & input = input, spectrum = spectrum, decays = decays) call global%ensure_model_copy () call slha_read_file & (cmd%file, cmd%local%os_data, global%model, & input = input, spectrum = spectrum, decays = decays) end if end subroutine cmd_slha_execute @ %def cmd_slha_execute @ \subsubsection{Show values} This command shows the current values of variables or other objects, in a suitably condensed form. <>= type, extends (command_t) :: cmd_show_t private type(string_t), dimension(:), allocatable :: name contains <> end type cmd_show_t @ %def cmd_show_t @ Output: list the object names, not values. <>= procedure :: write => cmd_show_write <>= subroutine cmd_show_write (cmd, unit, indent) class(cmd_show_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u, i u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)", advance="no") "show: " if (allocated (cmd%name)) then do i = 1, size (cmd%name) write (u, "(1x,A)", advance="no") char (cmd%name(i)) end do write (u, *) else write (u, "(5x,A)") "[undefined]" end if end subroutine cmd_show_write @ %def cmd_show_write @ Compile. Allocate an array which is filled with the names of the variables to show. <>= procedure :: compile => cmd_show_compile <>= subroutine cmd_show_compile (cmd, global) class(cmd_show_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_arg, pn_var, pn_prefix, pn_name type(string_t) :: key integer :: i, n_args pn_arg => parse_node_get_sub_ptr (cmd%pn, 2) if (associated (pn_arg)) then select case (char (parse_node_get_rule_key (pn_arg))) case ("show_arg") cmd%pn_opt => parse_node_get_next_ptr (pn_arg) case default cmd%pn_opt => pn_arg pn_arg => null () end select end if call cmd%compile_options (global) if (associated (pn_arg)) then n_args = parse_node_get_n_sub (pn_arg) allocate (cmd%name (n_args)) pn_var => parse_node_get_sub_ptr (pn_arg) i = 0 do while (associated (pn_var)) i = i + 1 select case (char (parse_node_get_rule_key (pn_var))) case ("model", "library", "beams", "iterations", & "cuts", "weight", "int", "real", "complex", & "scale", "factorization_scale", "renormalization_scale", & "selection", "reweight", "analysis", "pdg", & "stable", "unstable", "polarized", "unpolarized", & "results", "expect", "intrinsic", "string", "logical") cmd%name(i) = parse_node_get_key (pn_var) case ("result_var") pn_prefix => parse_node_get_sub_ptr (pn_var) pn_name => parse_node_get_next_ptr (pn_prefix) if (associated (pn_name)) then cmd%name(i) = parse_node_get_key (pn_prefix) & // "(" // parse_node_get_string (pn_name) // ")" else cmd%name(i) = parse_node_get_key (pn_prefix) end if case ("log_var", "string_var", "alias_var") pn_prefix => parse_node_get_sub_ptr (pn_var) pn_name => parse_node_get_next_ptr (pn_prefix) key = parse_node_get_key (pn_prefix) if (associated (pn_name)) then select case (char (parse_node_get_rule_key (pn_name))) case ("var_name") select case (char (key)) case ("?", "$") ! $ sign cmd%name(i) = key // parse_node_get_string (pn_name) case ("alias") cmd%name(i) = parse_node_get_string (pn_name) end select case default call parse_node_mismatch & ("var_name", pn_name) end select else cmd%name(i) = key end if case default cmd%name(i) = parse_node_get_string (pn_var) end select pn_var => parse_node_get_next_ptr (pn_var) end do else allocate (cmd%name (0)) end if end subroutine cmd_show_compile @ %def cmd_show_compile @ Execute. Scan the list of objects to show. <>= integer, parameter, public :: SHOW_BUFFER_SIZE = 4096 <>= procedure :: execute => cmd_show_execute <>= subroutine cmd_show_execute (cmd, global) class(cmd_show_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list, model_vars type(model_t), pointer :: model type(string_t) :: name integer :: n, pdg type(flavor_t) :: flv type(process_library_t), pointer :: prc_lib type(process_t), pointer :: process logical :: pacified character(SHOW_BUFFER_SIZE) :: buffer type(string_t) :: out_file integer :: i, j, u, u_log, u_out, u_ext u = free_unit () var_list => cmd%local%var_list if (associated (cmd%local%model)) then model_vars => cmd%local%model%get_var_list_ptr () else model_vars => null () end if pacified = var_list%get_lval (var_str ("?pacify")) out_file = var_list%get_sval (var_str ("$out_file")) if (file_list_is_open (global%out_files, out_file, action="write")) then call msg_message ("show: copying output to file '" & // char (out_file) // "'") u_ext = file_list_get_unit (global%out_files, out_file) else u_ext = -1 end if open (u, status = "scratch", action = "readwrite") if (associated (cmd%local%model)) then name = cmd%local%model%get_name () end if if (size (cmd%name) == 0) then if (associated (model_vars)) then call model_vars%write (model_name = name, & unit = u, pacified = pacified, follow_link = .false.) end if call var_list%write (unit = u, pacified = pacified) else do i = 1, size (cmd%name) select case (char (cmd%name(i))) case ("model") if (associated (cmd%local%model)) then call cmd%local%model%show (u) else write (u, "(A)") "Model: [undefined]" end if case ("library") if (associated (cmd%local%prclib)) then call cmd%local%prclib%show (u) else write (u, "(A)") "Process library: [undefined]" end if case ("beams") call cmd%local%show_beams (u) case ("iterations") call cmd%local%it_list%write (u) case ("results") call cmd%local%process_stack%show (u, fifo=.true.) case ("stable") call cmd%local%model%show_stable (u) case ("polarized") call cmd%local%model%show_polarized (u) case ("unpolarized") call cmd%local%model%show_unpolarized (u) case ("unstable") model => cmd%local%model call model%show_unstable (u) n = model%get_n_field () do j = 1, n pdg = model%get_pdg (j) call flv%init (pdg, model) if (.not. flv%is_stable ()) & call show_unstable (cmd%local, pdg, u) if (flv%has_antiparticle ()) then associate (anti => flv%anti ()) if (.not. anti%is_stable ()) & call show_unstable (cmd%local, -pdg, u) end associate end if end do case ("cuts", "weight", "scale", & "factorization_scale", "renormalization_scale", & "selection", "reweight", "analysis") call cmd%local%pn%show (cmd%name(i), u) case ("expect") call expect_summary (force = .true.) case ("intrinsic") call var_list%write (intrinsic=.true., unit=u, & pacified = pacified) case ("logical") if (associated (model_vars)) then call model_vars%write (only_type=V_LOG, & model_name = name, unit=u, pacified = pacified, & follow_link=.false.) end if call var_list%write (& only_type=V_LOG, unit=u, pacified = pacified) case ("int") if (associated (model_vars)) then call model_vars%write (only_type=V_INT, & model_name = name, unit=u, pacified = pacified, & follow_link=.false.) end if call var_list%write (only_type=V_INT, & unit=u, pacified = pacified) case ("real") if (associated (model_vars)) then call model_vars%write (only_type=V_REAL, & model_name = name, unit=u, pacified = pacified, & follow_link=.false.) end if call var_list%write (only_type=V_REAL, & unit=u, pacified = pacified) case ("complex") if (associated (model_vars)) then call model_vars%write (only_type=V_CMPLX, & model_name = name, unit=u, pacified = pacified, & follow_link=.false.) end if call var_list%write (only_type=V_CMPLX, & unit=u, pacified = pacified) case ("pdg") if (associated (model_vars)) then call model_vars%write (only_type=V_PDG, & model_name = name, unit=u, pacified = pacified, & follow_link=.false.) end if call var_list%write (only_type=V_PDG, & unit=u, pacified = pacified) case ("string") if (associated (model_vars)) then call model_vars%write (only_type=V_STR, & model_name = name, unit=u, pacified = pacified, & follow_link=.false.) end if call var_list%write (only_type=V_STR, & unit=u, pacified = pacified) case default if (analysis_exists (cmd%name(i))) then call analysis_write (cmd%name(i), u) else if (cmd%local%process_stack%exists (cmd%name(i))) then process => cmd%local%process_stack%get_process_ptr (cmd%name(i)) call process%show (u) else if (associated (cmd%local%prclib_stack%get_library_ptr & (cmd%name(i)))) then prc_lib => cmd%local%prclib_stack%get_library_ptr (cmd%name(i)) call prc_lib%show (u) else if (associated (model_vars)) then if (model_vars%contains (cmd%name(i), follow_link=.false.)) then call model_vars%write_var (cmd%name(i), & unit = u, model_name = name, pacified = pacified) else if (var_list%contains (cmd%name(i))) then call var_list%write_var (cmd%name(i), & unit = u, pacified = pacified) else call msg_error ("show: object '" // char (cmd%name(i)) & // "' not found") end if else if (var_list%contains (cmd%name(i))) then call var_list%write_var (cmd%name(i), & unit = u, pacified = pacified) else call msg_error ("show: object '" // char (cmd%name(i)) & // "' not found") end if end select end do end if rewind (u) u_log = logfile_unit () u_out = given_output_unit () do read (u, "(A)", end = 1) buffer if (u_log > 0) write (u_log, "(A)") trim (buffer) if (u_out > 0) write (u_out, "(A)") trim (buffer) if (u_ext > 0) write (u_ext, "(A)") trim (buffer) end do 1 close (u) if (u_log > 0) flush (u_log) if (u_out > 0) flush (u_out) if (u_ext > 0) flush (u_ext) end subroutine cmd_show_execute @ %def cmd_show_execute @ \subsubsection{Clear values} This command clears the current values of variables or other objects, where this makes sense. It parallels the [[show]] command. The objects are cleared, but not deleted. <>= type, extends (command_t) :: cmd_clear_t private type(string_t), dimension(:), allocatable :: name contains <> end type cmd_clear_t @ %def cmd_clear_t @ Output: list the names of the objects to be cleared. <>= procedure :: write => cmd_clear_write <>= subroutine cmd_clear_write (cmd, unit, indent) class(cmd_clear_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u, i u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)", advance="no") "clear: " if (allocated (cmd%name)) then do i = 1, size (cmd%name) write (u, "(1x,A)", advance="no") char (cmd%name(i)) end do write (u, *) else write (u, "(5x,A)") "[undefined]" end if end subroutine cmd_clear_write @ %def cmd_clear_write @ Compile. Allocate an array which is filled with the names of the objects to be cleared. Note: there is currently no need to account for options, but we prepare for that possibility. <>= procedure :: compile => cmd_clear_compile <>= subroutine cmd_clear_compile (cmd, global) class(cmd_clear_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_arg, pn_var, pn_prefix, pn_name type(string_t) :: key integer :: i, n_args pn_arg => parse_node_get_sub_ptr (cmd%pn, 2) if (associated (pn_arg)) then select case (char (parse_node_get_rule_key (pn_arg))) case ("clear_arg") cmd%pn_opt => parse_node_get_next_ptr (pn_arg) case default cmd%pn_opt => pn_arg pn_arg => null () end select end if call cmd%compile_options (global) if (associated (pn_arg)) then n_args = parse_node_get_n_sub (pn_arg) allocate (cmd%name (n_args)) pn_var => parse_node_get_sub_ptr (pn_arg) i = 0 do while (associated (pn_var)) i = i + 1 select case (char (parse_node_get_rule_key (pn_var))) case ("beams", "iterations", & "cuts", "weight", & "scale", "factorization_scale", "renormalization_scale", & "selection", "reweight", "analysis", & "unstable", "polarized", & "expect") cmd%name(i) = parse_node_get_key (pn_var) case ("log_var", "string_var") pn_prefix => parse_node_get_sub_ptr (pn_var) pn_name => parse_node_get_next_ptr (pn_prefix) key = parse_node_get_key (pn_prefix) if (associated (pn_name)) then select case (char (parse_node_get_rule_key (pn_name))) case ("var_name") select case (char (key)) case ("?", "$") ! $ sign cmd%name(i) = key // parse_node_get_string (pn_name) end select case default call parse_node_mismatch & ("var_name", pn_name) end select else cmd%name(i) = key end if case default cmd%name(i) = parse_node_get_string (pn_var) end select pn_var => parse_node_get_next_ptr (pn_var) end do else allocate (cmd%name (0)) end if end subroutine cmd_clear_compile @ %def cmd_clear_compile @ Execute. Scan the list of objects to clear. Objects that can be shown but not cleared: model, library, results <>= procedure :: execute => cmd_clear_execute <>= subroutine cmd_clear_execute (cmd, global) class(cmd_clear_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global integer :: i logical :: success type(var_list_t), pointer :: model_vars if (size (cmd%name) == 0) then call msg_warning ("clear: no object specified") else do i = 1, size (cmd%name) success = .true. select case (char (cmd%name(i))) case ("beams") call cmd%local%clear_beams () case ("iterations") call cmd%local%it_list%clear () case ("polarized") call cmd%local%model%clear_polarized () case ("unstable") call cmd%local%model%clear_unstable () case ("cuts", "weight", "scale", & "factorization_scale", "renormalization_scale", & "selection", "reweight", "analysis") call cmd%local%pn%clear (cmd%name(i)) case ("expect") call expect_clear () case default if (analysis_exists (cmd%name(i))) then call analysis_clear (cmd%name(i)) else if (cmd%local%var_list%contains (cmd%name(i))) then if (.not. cmd%local%var_list%is_locked (cmd%name(i))) then call cmd%local%var_list%unset (cmd%name(i)) else call msg_error ("clear: variable '" // char (cmd%name(i)) & // "' is locked and can't be cleared") success = .false. end if else if (associated (cmd%local%model)) then model_vars => cmd%local%model%get_var_list_ptr () if (model_vars%contains (cmd%name(i), follow_link=.false.)) then call msg_error ("clear: variable '" // char (cmd%name(i)) & // "' is a model variable and can't be cleared") else call msg_error ("clear: object '" // char (cmd%name(i)) & // "' not found") end if success = .false. else call msg_error ("clear: object '" // char (cmd%name(i)) & // "' not found") success = .false. end if end select if (success) call msg_message ("cleared: " // char (cmd%name(i))) end do end if end subroutine cmd_clear_execute @ %def cmd_clear_execute @ \subsubsection{Compare values of variables to expectation} The implementation is similar to the [[show]] command. There are just two arguments: two values that should be compared. For providing local values for the numerical tolerance, the command has a local argument list. If the expectation fails, an error condition is recorded. <>= type, extends (command_t) :: cmd_expect_t private type(parse_node_t), pointer :: pn_lexpr => null () contains <> end type cmd_expect_t @ %def cmd_expect_t @ Simply tell the status. <>= procedure :: write => cmd_expect_write <>= subroutine cmd_expect_write (cmd, unit, indent) class(cmd_expect_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) if (associated (cmd%pn_lexpr)) then write (u, "(1x,A)") "expect: [expression associated]" else write (u, "(1x,A)") "expect: [undefined]" end if end subroutine cmd_expect_write @ %def cmd_expect_write @ Compile. This merely assigns the parse node, the actual compilation is done at execution. This is necessary because the origin of variables (local/global) may change during execution. <>= procedure :: compile => cmd_expect_compile <>= subroutine cmd_expect_compile (cmd, global) class(cmd_expect_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_arg pn_arg => parse_node_get_sub_ptr (cmd%pn, 2) cmd%pn_opt => parse_node_get_next_ptr (pn_arg) cmd%pn_lexpr => parse_node_get_sub_ptr (pn_arg) call cmd%compile_options (global) end subroutine cmd_expect_compile @ %def cmd_expect_compile @ Execute. Evaluate both arguments, print them and their difference (if numerical), and whether they agree. Record the result. <>= procedure :: execute => cmd_expect_execute <>= subroutine cmd_expect_execute (cmd, global) class(cmd_expect_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list logical :: success, is_known var_list => cmd%local%get_var_list_ptr () success = eval_log (cmd%pn_lexpr, var_list, is_known=is_known) if (is_known) then if (success) then call msg_message ("expect: success") else call msg_error ("expect: failure") end if else call msg_error ("expect: undefined result") success = .false. end if call expect_record (success) end subroutine cmd_expect_execute @ %def cmd_expect_execute @ \subsubsection{Beams} The beam command includes both beam and structure-function definition. <>= type, extends (command_t) :: cmd_beams_t private integer :: n_in = 0 type(parse_node_p), dimension(:), allocatable :: pn_pdg integer :: n_sf_record = 0 integer, dimension(:), allocatable :: n_entry type(parse_node_p), dimension(:,:), allocatable :: pn_sf_entry contains <> end type cmd_beams_t @ %def cmd_beams_t @ Output. The particle expressions are not resolved. <>= procedure :: write => cmd_beams_write <>= subroutine cmd_beams_write (cmd, unit, indent) class(cmd_beams_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) select case (cmd%n_in) case (1) write (u, "(1x,A)") "beams: 1 [decay]" case (2) write (u, "(1x,A)") "beams: 2 [scattering]" case default write (u, "(1x,A)") "beams: [undefined]" end select if (allocated (cmd%n_entry)) then if (cmd%n_sf_record > 0) then write (u, "(1x,A,99(1x,I0))") "structure function entries:", & cmd%n_entry end if end if end subroutine cmd_beams_write @ %def cmd_beams_write @ Compile. Find and assign the parse nodes. Note: local environments are not yet supported. <>= procedure :: compile => cmd_beams_compile <>= subroutine cmd_beams_compile (cmd, global) class(cmd_beams_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_beam_def, pn_beam_spec type(parse_node_t), pointer :: pn_beam_list type(parse_node_t), pointer :: pn_codes type(parse_node_t), pointer :: pn_strfun_seq, pn_strfun_pair type(parse_node_t), pointer :: pn_strfun_def integer :: i pn_beam_def => parse_node_get_sub_ptr (cmd%pn, 3) pn_beam_spec => parse_node_get_sub_ptr (pn_beam_def) pn_strfun_seq => parse_node_get_next_ptr (pn_beam_spec) pn_beam_list => parse_node_get_sub_ptr (pn_beam_spec) call cmd%compile_options (global) cmd%n_in = parse_node_get_n_sub (pn_beam_list) allocate (cmd%pn_pdg (cmd%n_in)) pn_codes => parse_node_get_sub_ptr (pn_beam_list) do i = 1, cmd%n_in cmd%pn_pdg(i)%ptr => pn_codes pn_codes => parse_node_get_next_ptr (pn_codes) end do if (associated (pn_strfun_seq)) then cmd%n_sf_record = parse_node_get_n_sub (pn_beam_def) - 1 allocate (cmd%n_entry (cmd%n_sf_record), source = 1) allocate (cmd%pn_sf_entry (2, cmd%n_sf_record)) do i = 1, cmd%n_sf_record pn_strfun_pair => parse_node_get_sub_ptr (pn_strfun_seq, 2) pn_strfun_def => parse_node_get_sub_ptr (pn_strfun_pair) cmd%pn_sf_entry(1,i)%ptr => pn_strfun_def pn_strfun_def => parse_node_get_next_ptr (pn_strfun_def) cmd%pn_sf_entry(2,i)%ptr => pn_strfun_def if (associated (pn_strfun_def)) cmd%n_entry(i) = 2 pn_strfun_seq => parse_node_get_next_ptr (pn_strfun_seq) end do else allocate (cmd%n_entry (0)) allocate (cmd%pn_sf_entry (0, 0)) end if end subroutine cmd_beams_compile @ %def cmd_beams_compile @ Command execution: Determine beam particles and structure-function names, if any. The results are stored in the [[beam_structure]] component of the [[global]] data block. <>= procedure :: execute => cmd_beams_execute <>= subroutine cmd_beams_execute (cmd, global) class(cmd_beams_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list type(pdg_array_t) :: pdg_array integer, dimension(:), allocatable :: pdg type(flavor_t), dimension(:), allocatable :: flv type(parse_node_t), pointer :: pn_key type(string_t) :: sf_name integer :: i, j call lhapdf_global_reset () var_list => cmd%local%get_var_list_ptr () allocate (flv (cmd%n_in)) do i = 1, cmd%n_in pdg_array = eval_pdg_array (cmd%pn_pdg(i)%ptr, var_list) pdg = pdg_array select case (size (pdg)) case (1) call flv(i)%init ( pdg(1), cmd%local%model) case default call msg_fatal ("Beams: beam particles must be unique") end select end do select case (cmd%n_in) case (1) if (cmd%n_sf_record > 0) then call msg_fatal ("Beam setup: no structure functions allowed & &for decay") end if call global%beam_structure%init_sf (flv%get_name ()) case (2) call global%beam_structure%init_sf (flv%get_name (), cmd%n_entry) do i = 1, cmd%n_sf_record do j = 1, cmd%n_entry(i) pn_key => parse_node_get_sub_ptr (cmd%pn_sf_entry(j,i)%ptr) sf_name = parse_node_get_key (pn_key) call global%beam_structure%set_sf (i, j, sf_name) end do end do end select end subroutine cmd_beams_execute @ %def cmd_beams_execute @ \subsubsection{Density matrices for beam polarization} For holding beam polarization, we define a notation and a data structure for sparse matrices. The entries (and the index expressions) are numerical expressions, so we use evaluation trees. Each entry in the sparse matrix is an n-tuple of expressions. The first tuple elements represent index values, the last one is an arbitrary (complex) number. Absent expressions are replaced by default-value rules. Note: Here, and in some other commands, we would like to store an evaluation tree, not just a parse node pointer. However, the current expression handler wants all variables defined, so the evaluation tree can only be built by [[evaluate]], i.e., compiled just-in-time and evaluated immediately. <>= type :: sentry_expr_t type(parse_node_p), dimension(:), allocatable :: expr contains <> end type sentry_expr_t @ %def sentry_expr_t @ Compile parse nodes into evaluation trees. <>= procedure :: compile => sentry_expr_compile <>= subroutine sentry_expr_compile (sentry, pn) class(sentry_expr_t), intent(out) :: sentry type(parse_node_t), intent(in), target :: pn type(parse_node_t), pointer :: pn_expr, pn_extra integer :: n_expr, i n_expr = parse_node_get_n_sub (pn) allocate (sentry%expr (n_expr)) if (n_expr > 0) then i = 0 pn_expr => parse_node_get_sub_ptr (pn) pn_extra => parse_node_get_next_ptr (pn_expr) do i = 1, n_expr sentry%expr(i)%ptr => pn_expr if (associated (pn_extra)) then pn_expr => parse_node_get_sub_ptr (pn_extra, 2) pn_extra => parse_node_get_next_ptr (pn_extra) end if end do end if end subroutine sentry_expr_compile @ %def sentry_expr_compile @ Evaluate the expressions and return an index array of predefined length together with a complex value. If the value (as the last expression) is undefined, set it to unity. If index values are undefined, repeat the previous index value. <>= procedure :: evaluate => sentry_expr_evaluate <>= subroutine sentry_expr_evaluate (sentry, index, value, global) class(sentry_expr_t), intent(inout) :: sentry integer, dimension(:), intent(out) :: index complex(default), intent(out) :: value type(rt_data_t), intent(in), target :: global type(var_list_t), pointer :: var_list integer :: i, n_expr, n_index type(eval_tree_t) :: eval_tree var_list => global%get_var_list_ptr () n_expr = size (sentry%expr) n_index = size (index) if (n_expr <= n_index + 1) then do i = 1, min (n_expr, n_index) associate (expr => sentry%expr(i)) call eval_tree%init_expr (expr%ptr, var_list) call eval_tree%evaluate () if (eval_tree%is_known ()) then index(i) = eval_tree%get_int () else call msg_fatal ("Evaluating density matrix: undefined index") end if end associate end do do i = n_expr + 1, n_index index(i) = index(n_expr) end do if (n_expr == n_index + 1) then associate (expr => sentry%expr(n_expr)) call eval_tree%init_expr (expr%ptr, var_list) call eval_tree%evaluate () if (eval_tree%is_known ()) then value = eval_tree%get_cmplx () else call msg_fatal ("Evaluating density matrix: undefined index") end if call eval_tree%final () end associate else value = 1 end if else call msg_fatal ("Evaluating density matrix: index expression too long") end if end subroutine sentry_expr_evaluate @ %def sentry_expr_evaluate @ The sparse matrix itself consists of an arbitrary number of entries. <>= type :: smatrix_expr_t type(sentry_expr_t), dimension(:), allocatable :: entry contains <> end type smatrix_expr_t @ %def smatrix_expr_t @ Compile: assign sub-nodes to sentry-expressions and compile those. <>= procedure :: compile => smatrix_expr_compile <>= subroutine smatrix_expr_compile (smatrix_expr, pn) class(smatrix_expr_t), intent(out) :: smatrix_expr type(parse_node_t), intent(in), target :: pn type(parse_node_t), pointer :: pn_arg, pn_entry integer :: n_entry, i pn_arg => parse_node_get_sub_ptr (pn, 2) if (associated (pn_arg)) then n_entry = parse_node_get_n_sub (pn_arg) allocate (smatrix_expr%entry (n_entry)) pn_entry => parse_node_get_sub_ptr (pn_arg) do i = 1, n_entry call smatrix_expr%entry(i)%compile (pn_entry) pn_entry => parse_node_get_next_ptr (pn_entry) end do else allocate (smatrix_expr%entry (0)) end if end subroutine smatrix_expr_compile @ %def smatrix_expr_compile @ Evaluate the entries and build a new [[smatrix]] object, which contains just the numerical results. <>= procedure :: evaluate => smatrix_expr_evaluate <>= subroutine smatrix_expr_evaluate (smatrix_expr, smatrix, global) class(smatrix_expr_t), intent(inout) :: smatrix_expr type(smatrix_t), intent(out) :: smatrix type(rt_data_t), intent(in), target :: global integer, dimension(2) :: idx complex(default) :: value integer :: i, n_entry n_entry = size (smatrix_expr%entry) call smatrix%init (2, n_entry) do i = 1, n_entry call smatrix_expr%entry(i)%evaluate (idx, value, global) call smatrix%set_entry (i, idx, value) end do end subroutine smatrix_expr_evaluate @ %def smatrix_expr_evaluate @ \subsubsection{Beam polarization density} The beam polarization command defines spin density matrix for one or two beams (scattering or decay). <>= type, extends (command_t) :: cmd_beams_pol_density_t private integer :: n_in = 0 type(smatrix_expr_t), dimension(:), allocatable :: smatrix contains <> end type cmd_beams_pol_density_t @ %def cmd_beams_pol_density_t @ Output. <>= procedure :: write => cmd_beams_pol_density_write <>= subroutine cmd_beams_pol_density_write (cmd, unit, indent) class(cmd_beams_pol_density_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) select case (cmd%n_in) case (1) write (u, "(1x,A)") "beams polarization setup: 1 [decay]" case (2) write (u, "(1x,A)") "beams polarization setup: 2 [scattering]" case default write (u, "(1x,A)") "beams polarization setup: [undefined]" end select end subroutine cmd_beams_pol_density_write @ %def cmd_beams_pol_density_write @ Compile. Find and assign the parse nodes. Note: local environments are not yet supported. <>= procedure :: compile => cmd_beams_pol_density_compile <>= subroutine cmd_beams_pol_density_compile (cmd, global) class(cmd_beams_pol_density_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_pol_spec, pn_smatrix integer :: i pn_pol_spec => parse_node_get_sub_ptr (cmd%pn, 3) call cmd%compile_options (global) cmd%n_in = parse_node_get_n_sub (pn_pol_spec) allocate (cmd%smatrix (cmd%n_in)) pn_smatrix => parse_node_get_sub_ptr (pn_pol_spec) do i = 1, cmd%n_in call cmd%smatrix(i)%compile (pn_smatrix) pn_smatrix => parse_node_get_next_ptr (pn_smatrix) end do end subroutine cmd_beams_pol_density_compile @ %def cmd_beams_pol_density_compile @ Command execution: Fill polarization density matrices. No check yet, the matrices are checked and normalized when the actual beam object is created, just before integration. For intermediate storage, we use the [[beam_structure]] object in the [[global]] data set. <>= procedure :: execute => cmd_beams_pol_density_execute <>= subroutine cmd_beams_pol_density_execute (cmd, global) class(cmd_beams_pol_density_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(smatrix_t) :: smatrix integer :: i call global%beam_structure%init_pol (cmd%n_in) do i = 1, cmd%n_in call cmd%smatrix(i)%evaluate (smatrix, global) call global%beam_structure%set_smatrix (i, smatrix) end do end subroutine cmd_beams_pol_density_execute @ %def cmd_beams_pol_density_execute @ \subsubsection{Beam polarization fraction} In addition to the polarization density matrix, we can independently specify the polarization fraction for one or both beams. <>= type, extends (command_t) :: cmd_beams_pol_fraction_t private integer :: n_in = 0 type(parse_node_p), dimension(:), allocatable :: expr contains <> end type cmd_beams_pol_fraction_t @ %def cmd_beams_pol_fraction_t @ Output. <>= procedure :: write => cmd_beams_pol_fraction_write <>= subroutine cmd_beams_pol_fraction_write (cmd, unit, indent) class(cmd_beams_pol_fraction_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) select case (cmd%n_in) case (1) write (u, "(1x,A)") "beams polarization fraction: 1 [decay]" case (2) write (u, "(1x,A)") "beams polarization fraction: 2 [scattering]" case default write (u, "(1x,A)") "beams polarization fraction: [undefined]" end select end subroutine cmd_beams_pol_fraction_write @ %def cmd_beams_pol_fraction_write @ Compile. Find and assign the parse nodes. Note: local environments are not yet supported. <>= procedure :: compile => cmd_beams_pol_fraction_compile <>= subroutine cmd_beams_pol_fraction_compile (cmd, global) class(cmd_beams_pol_fraction_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_frac_spec, pn_expr integer :: i pn_frac_spec => parse_node_get_sub_ptr (cmd%pn, 3) call cmd%compile_options (global) cmd%n_in = parse_node_get_n_sub (pn_frac_spec) allocate (cmd%expr (cmd%n_in)) pn_expr => parse_node_get_sub_ptr (pn_frac_spec) do i = 1, cmd%n_in cmd%expr(i)%ptr => pn_expr pn_expr => parse_node_get_next_ptr (pn_expr) end do end subroutine cmd_beams_pol_fraction_compile @ %def cmd_beams_pol_fraction_compile @ Command execution: Retrieve the numerical values of the beam polarization fractions. The results are stored in the [[beam_structure]] component of the [[global]] data block. <>= procedure :: execute => cmd_beams_pol_fraction_execute <>= subroutine cmd_beams_pol_fraction_execute (cmd, global) class(cmd_beams_pol_fraction_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list real(default), dimension(:), allocatable :: pol_f type(eval_tree_t) :: expr integer :: i var_list => global%get_var_list_ptr () allocate (pol_f (cmd%n_in)) do i = 1, cmd%n_in call expr%init_expr (cmd%expr(i)%ptr, var_list) call expr%evaluate () if (expr%is_known ()) then pol_f(i) = expr%get_real () else call msg_fatal ("beams polarization fraction: undefined value") end if call expr%final () end do call global%beam_structure%set_pol_f (pol_f) end subroutine cmd_beams_pol_fraction_execute @ %def cmd_beams_pol_fraction_execute @ \subsubsection{Beam momentum} This is completely analogous to the previous command, hence we can use inheritance. <>= type, extends (cmd_beams_pol_fraction_t) :: cmd_beams_momentum_t contains <> end type cmd_beams_momentum_t @ %def cmd_beams_momentum_t @ Output. <>= procedure :: write => cmd_beams_momentum_write <>= subroutine cmd_beams_momentum_write (cmd, unit, indent) class(cmd_beams_momentum_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) select case (cmd%n_in) case (1) write (u, "(1x,A)") "beams momentum: 1 [decay]" case (2) write (u, "(1x,A)") "beams momentum: 2 [scattering]" case default write (u, "(1x,A)") "beams momentum: [undefined]" end select end subroutine cmd_beams_momentum_write @ %def cmd_beams_momentum_write @ Compile: inherited. Command execution: Not inherited, but just the error string and the final command are changed. <>= procedure :: execute => cmd_beams_momentum_execute <>= subroutine cmd_beams_momentum_execute (cmd, global) class(cmd_beams_momentum_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list real(default), dimension(:), allocatable :: p type(eval_tree_t) :: expr integer :: i var_list => global%get_var_list_ptr () allocate (p (cmd%n_in)) do i = 1, cmd%n_in call expr%init_expr (cmd%expr(i)%ptr, var_list) call expr%evaluate () if (expr%is_known ()) then p(i) = expr%get_real () else call msg_fatal ("beams momentum: undefined value") end if call expr%final () end do call global%beam_structure%set_momentum (p) end subroutine cmd_beams_momentum_execute @ %def cmd_beams_momentum_execute @ \subsubsection{Beam angles} Again, this is analogous. There are two angles, polar angle $\theta$ and azimuthal angle $\phi$, which can be set independently for both beams. <>= type, extends (cmd_beams_pol_fraction_t) :: cmd_beams_theta_t contains <> end type cmd_beams_theta_t type, extends (cmd_beams_pol_fraction_t) :: cmd_beams_phi_t contains <> end type cmd_beams_phi_t @ %def cmd_beams_theta_t @ %def cmd_beams_phi_t @ Output. <>= procedure :: write => cmd_beams_theta_write <>= procedure :: write => cmd_beams_phi_write <>= subroutine cmd_beams_theta_write (cmd, unit, indent) class(cmd_beams_theta_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) select case (cmd%n_in) case (1) write (u, "(1x,A)") "beams theta: 1 [decay]" case (2) write (u, "(1x,A)") "beams theta: 2 [scattering]" case default write (u, "(1x,A)") "beams theta: [undefined]" end select end subroutine cmd_beams_theta_write subroutine cmd_beams_phi_write (cmd, unit, indent) class(cmd_beams_phi_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) select case (cmd%n_in) case (1) write (u, "(1x,A)") "beams phi: 1 [decay]" case (2) write (u, "(1x,A)") "beams phi: 2 [scattering]" case default write (u, "(1x,A)") "beams phi: [undefined]" end select end subroutine cmd_beams_phi_write @ %def cmd_beams_theta_write @ %def cmd_beams_phi_write @ Compile: inherited. Command execution: Not inherited, but just the error string and the final command are changed. <>= procedure :: execute => cmd_beams_theta_execute <>= procedure :: execute => cmd_beams_phi_execute <>= subroutine cmd_beams_theta_execute (cmd, global) class(cmd_beams_theta_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list real(default), dimension(:), allocatable :: theta type(eval_tree_t) :: expr integer :: i var_list => global%get_var_list_ptr () allocate (theta (cmd%n_in)) do i = 1, cmd%n_in call expr%init_expr (cmd%expr(i)%ptr, var_list) call expr%evaluate () if (expr%is_known ()) then theta(i) = expr%get_real () else call msg_fatal ("beams theta: undefined value") end if call expr%final () end do call global%beam_structure%set_theta (theta) end subroutine cmd_beams_theta_execute subroutine cmd_beams_phi_execute (cmd, global) class(cmd_beams_phi_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list real(default), dimension(:), allocatable :: phi type(eval_tree_t) :: expr integer :: i var_list => global%get_var_list_ptr () allocate (phi (cmd%n_in)) do i = 1, cmd%n_in call expr%init_expr (cmd%expr(i)%ptr, var_list) call expr%evaluate () if (expr%is_known ()) then phi(i) = expr%get_real () else call msg_fatal ("beams phi: undefined value") end if call expr%final () end do call global%beam_structure%set_phi (phi) end subroutine cmd_beams_phi_execute @ %def cmd_beams_theta_execute @ %def cmd_beams_phi_execute @ \subsubsection{Cuts} Define a cut expression. We store the parse tree for the right-hand side instead of compiling it. Compilation is deferred to the process environment where the cut expression is used. <>= type, extends (command_t) :: cmd_cuts_t private type(parse_node_t), pointer :: pn_lexpr => null () contains <> end type cmd_cuts_t @ %def cmd_cuts_t @ Output. Do not print the parse tree, since this may get cluttered. Just a message that cuts have been defined. <>= procedure :: write => cmd_cuts_write <>= subroutine cmd_cuts_write (cmd, unit, indent) class(cmd_cuts_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)") "cuts: [defined]" end subroutine cmd_cuts_write @ %def cmd_cuts_write @ Compile. Simply store the parse (sub)tree. <>= procedure :: compile => cmd_cuts_compile <>= subroutine cmd_cuts_compile (cmd, global) class(cmd_cuts_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global cmd%pn_lexpr => parse_node_get_sub_ptr (cmd%pn, 3) end subroutine cmd_cuts_compile @ %def cmd_cuts_compile @ Instead of evaluating the cut expression, link the parse tree to the global data set, such that it is compiled and executed in the appropriate process context. <>= procedure :: execute => cmd_cuts_execute <>= subroutine cmd_cuts_execute (cmd, global) class(cmd_cuts_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global global%pn%cuts_lexpr => cmd%pn_lexpr end subroutine cmd_cuts_execute @ %def cmd_cuts_execute @ \subsubsection{General, Factorization and Renormalization Scales} Define a scale expression for either the renormalization or the factorization scale. We store the parse tree for the right-hand side instead of compiling it. Compilation is deferred to the process environment where the expression is used. <>= type, extends (command_t) :: cmd_scale_t private type(parse_node_t), pointer :: pn_expr => null () contains <> end type cmd_scale_t @ %def cmd_scale_t <>= type, extends (command_t) :: cmd_fac_scale_t private type(parse_node_t), pointer :: pn_expr => null () contains <> end type cmd_fac_scale_t @ %def cmd_fac_scale_t <>= type, extends (command_t) :: cmd_ren_scale_t private type(parse_node_t), pointer :: pn_expr => null () contains <> end type cmd_ren_scale_t @ %def cmd_ren_scale_t @ Output. Do not print the parse tree, since this may get cluttered. Just a message that scale, renormalization and factorization have been defined, respectively. <>= procedure :: write => cmd_scale_write <>= subroutine cmd_scale_write (cmd, unit, indent) class(cmd_scale_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)") "scale: [defined]" end subroutine cmd_scale_write @ %def cmd_scale_write @ <>= procedure :: write => cmd_fac_scale_write <>= subroutine cmd_fac_scale_write (cmd, unit, indent) class(cmd_fac_scale_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)") "factorization scale: [defined]" end subroutine cmd_fac_scale_write @ %def cmd_fac_scale_write @ <>= procedure :: write => cmd_ren_scale_write <>= subroutine cmd_ren_scale_write (cmd, unit, indent) class(cmd_ren_scale_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)") "renormalization scale: [defined]" end subroutine cmd_ren_scale_write @ %def cmd_ren_scale_write @ Compile. Simply store the parse (sub)tree. <>= procedure :: compile => cmd_scale_compile <>= subroutine cmd_scale_compile (cmd, global) class(cmd_scale_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global cmd%pn_expr => parse_node_get_sub_ptr (cmd%pn, 3) end subroutine cmd_scale_compile @ %def cmd_scale_compile @ <>= procedure :: compile => cmd_fac_scale_compile <>= subroutine cmd_fac_scale_compile (cmd, global) class(cmd_fac_scale_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global cmd%pn_expr => parse_node_get_sub_ptr (cmd%pn, 3) end subroutine cmd_fac_scale_compile @ %def cmd_fac_scale_compile @ <>= procedure :: compile => cmd_ren_scale_compile <>= subroutine cmd_ren_scale_compile (cmd, global) class(cmd_ren_scale_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global cmd%pn_expr => parse_node_get_sub_ptr (cmd%pn, 3) end subroutine cmd_ren_scale_compile @ %def cmd_ren_scale_compile @ Instead of evaluating the scale expression, link the parse tree to the global data set, such that it is compiled and executed in the appropriate process context. <>= procedure :: execute => cmd_scale_execute <>= subroutine cmd_scale_execute (cmd, global) class(cmd_scale_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global global%pn%scale_expr => cmd%pn_expr end subroutine cmd_scale_execute @ %def cmd_scale_execute @ <>= procedure :: execute => cmd_fac_scale_execute <>= subroutine cmd_fac_scale_execute (cmd, global) class(cmd_fac_scale_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global global%pn%fac_scale_expr => cmd%pn_expr end subroutine cmd_fac_scale_execute @ %def cmd_fac_scale_execute @ <>= procedure :: execute => cmd_ren_scale_execute <>= subroutine cmd_ren_scale_execute (cmd, global) class(cmd_ren_scale_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global global%pn%ren_scale_expr => cmd%pn_expr end subroutine cmd_ren_scale_execute @ %def cmd_ren_scale_execute @ \subsubsection{Weight} Define a weight expression. The weight is applied to a process to be integrated, event by event. We store the parse tree for the right-hand side instead of compiling it. Compilation is deferred to the process environment where the expression is used. <>= type, extends (command_t) :: cmd_weight_t private type(parse_node_t), pointer :: pn_expr => null () contains <> end type cmd_weight_t @ %def cmd_weight_t @ Output. Do not print the parse tree, since this may get cluttered. Just a message that scale, renormalization and factorization have been defined, respectively. <>= procedure :: write => cmd_weight_write <>= subroutine cmd_weight_write (cmd, unit, indent) class(cmd_weight_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)") "weight expression: [defined]" end subroutine cmd_weight_write @ %def cmd_weight_write @ Compile. Simply store the parse (sub)tree. <>= procedure :: compile => cmd_weight_compile <>= subroutine cmd_weight_compile (cmd, global) class(cmd_weight_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global cmd%pn_expr => parse_node_get_sub_ptr (cmd%pn, 3) end subroutine cmd_weight_compile @ %def cmd_weight_compile @ Instead of evaluating the expression, link the parse tree to the global data set, such that it is compiled and executed in the appropriate process context. <>= procedure :: execute => cmd_weight_execute <>= subroutine cmd_weight_execute (cmd, global) class(cmd_weight_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global global%pn%weight_expr => cmd%pn_expr end subroutine cmd_weight_execute @ %def cmd_weight_execute @ \subsubsection{Selection} Define a selection expression. This is to be applied upon simulation or event-file rescanning, event by event. We store the parse tree for the right-hand side instead of compiling it. Compilation is deferred to the environment where the expression is used. <>= type, extends (command_t) :: cmd_selection_t private type(parse_node_t), pointer :: pn_expr => null () contains <> end type cmd_selection_t @ %def cmd_selection_t @ Output. Do not print the parse tree, since this may get cluttered. Just a message that scale, renormalization and factorization have been defined, respectively. <>= procedure :: write => cmd_selection_write <>= subroutine cmd_selection_write (cmd, unit, indent) class(cmd_selection_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)") "selection expression: [defined]" end subroutine cmd_selection_write @ %def cmd_selection_write @ Compile. Simply store the parse (sub)tree. <>= procedure :: compile => cmd_selection_compile <>= subroutine cmd_selection_compile (cmd, global) class(cmd_selection_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global cmd%pn_expr => parse_node_get_sub_ptr (cmd%pn, 3) end subroutine cmd_selection_compile @ %def cmd_selection_compile @ Instead of evaluating the expression, link the parse tree to the global data set, such that it is compiled and executed in the appropriate process context. <>= procedure :: execute => cmd_selection_execute <>= subroutine cmd_selection_execute (cmd, global) class(cmd_selection_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global global%pn%selection_lexpr => cmd%pn_expr end subroutine cmd_selection_execute @ %def cmd_selection_execute @ \subsubsection{Reweight} Define a reweight expression. This is to be applied upon simulation or event-file rescanning, event by event. We store the parse tree for the right-hand side instead of compiling it. Compilation is deferred to the environment where the expression is used. <>= type, extends (command_t) :: cmd_reweight_t private type(parse_node_t), pointer :: pn_expr => null () contains <> end type cmd_reweight_t @ %def cmd_reweight_t @ Output. Do not print the parse tree, since this may get cluttered. Just a message that scale, renormalization and factorization have been defined, respectively. <>= procedure :: write => cmd_reweight_write <>= subroutine cmd_reweight_write (cmd, unit, indent) class(cmd_reweight_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)") "reweight expression: [defined]" end subroutine cmd_reweight_write @ %def cmd_reweight_write @ Compile. Simply store the parse (sub)tree. <>= procedure :: compile => cmd_reweight_compile <>= subroutine cmd_reweight_compile (cmd, global) class(cmd_reweight_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global cmd%pn_expr => parse_node_get_sub_ptr (cmd%pn, 3) end subroutine cmd_reweight_compile @ %def cmd_reweight_compile @ Instead of evaluating the expression, link the parse tree to the global data set, such that it is compiled and executed in the appropriate process context. <>= procedure :: execute => cmd_reweight_execute <>= subroutine cmd_reweight_execute (cmd, global) class(cmd_reweight_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global global%pn%reweight_expr => cmd%pn_expr end subroutine cmd_reweight_execute @ %def cmd_reweight_execute @ \subsubsection{Alternative Simulation Setups} Together with simulation, we can re-evaluate event weights in the context of alternative setups. The [[cmd_alt_setup_t]] object is designed to hold these setups, which are brace-enclosed command lists. Compilation is deferred to the simulation environment where the setup expression is used. <>= type, extends (command_t) :: cmd_alt_setup_t private type(parse_node_p), dimension(:), allocatable :: setup contains <> end type cmd_alt_setup_t @ %def cmd_alt_setup_t @ Output. Print just a message that the alternative setup list has been defined. <>= procedure :: write => cmd_alt_setup_write <>= subroutine cmd_alt_setup_write (cmd, unit, indent) class(cmd_alt_setup_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A,I0,A)") "alt_setup: ", size (cmd%setup), " entries" end subroutine cmd_alt_setup_write @ %def cmd_alt_setup_write @ Compile. Store the parse sub-trees in an array. <>= procedure :: compile => cmd_alt_setup_compile <>= subroutine cmd_alt_setup_compile (cmd, global) class(cmd_alt_setup_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_list, pn_setup integer :: i pn_list => parse_node_get_sub_ptr (cmd%pn, 3) if (associated (pn_list)) then allocate (cmd%setup (parse_node_get_n_sub (pn_list))) i = 1 pn_setup => parse_node_get_sub_ptr (pn_list) do while (associated (pn_setup)) cmd%setup(i)%ptr => pn_setup i = i + 1 pn_setup => parse_node_get_next_ptr (pn_setup) end do else allocate (cmd%setup (0)) end if end subroutine cmd_alt_setup_compile @ %def cmd_alt_setup_compile @ Execute. Transfer the array of command lists to the global environment. <>= procedure :: execute => cmd_alt_setup_execute <>= subroutine cmd_alt_setup_execute (cmd, global) class(cmd_alt_setup_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global if (allocated (global%pn%alt_setup)) deallocate (global%pn%alt_setup) allocate (global%pn%alt_setup (size (cmd%setup))) global%pn%alt_setup = cmd%setup end subroutine cmd_alt_setup_execute @ %def cmd_alt_setup_execute @ \subsubsection{Integration} Integrate several processes, consecutively with identical parameters. <>= type, extends (command_t) :: cmd_integrate_t private integer :: n_proc = 0 type(string_t), dimension(:), allocatable :: process_id contains <> end type cmd_integrate_t @ %def cmd_integrate_t @ Output: we know the process IDs. <>= procedure :: write => cmd_integrate_write <>= subroutine cmd_integrate_write (cmd, unit, indent) class(cmd_integrate_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u, i u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)", advance="no") "integrate (" do i = 1, cmd%n_proc if (i > 1) write (u, "(A,1x)", advance="no") "," write (u, "(A)", advance="no") char (cmd%process_id(i)) end do write (u, "(A)") ")" end subroutine cmd_integrate_write @ %def cmd_integrate_write @ Compile. <>= procedure :: compile => cmd_integrate_compile <>= subroutine cmd_integrate_compile (cmd, global) class(cmd_integrate_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_proclist, pn_proc integer :: i pn_proclist => parse_node_get_sub_ptr (cmd%pn, 2) cmd%pn_opt => parse_node_get_next_ptr (pn_proclist) call cmd%compile_options (global) cmd%n_proc = parse_node_get_n_sub (pn_proclist) allocate (cmd%process_id (cmd%n_proc)) pn_proc => parse_node_get_sub_ptr (pn_proclist) do i = 1, cmd%n_proc cmd%process_id(i) = parse_node_get_string (pn_proc) call global%process_stack%init_result_vars (cmd%process_id(i)) pn_proc => parse_node_get_next_ptr (pn_proc) end do end subroutine cmd_integrate_compile @ %def cmd_integrate_compile @ Command execution. Integrate the process(es) with the predefined number of passes, iterations and calls. For structure functions, cuts, weight and scale, use local definitions if present; by default, the local definitions are initialized with the global ones. The [[integrate]] procedure should take its input from the currently active local environment, but produce a process record in the stack of the global environment. Since the process acquires a snapshot of the variable list, so if the global list (or the local one) is deleted, this does no harm. This implies that later changes of the variable list do not affect the stored process. <>= procedure :: execute => cmd_integrate_execute <>= subroutine cmd_integrate_execute (cmd, global) class(cmd_integrate_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global integer :: i if (debug_on) call msg_debug (D_CORE, "cmd_integrate_execute") do i = 1, cmd%n_proc if (debug_on) call msg_debug (D_CORE, "cmd%process_id(i) ", cmd%process_id(i)) call integrate_process (cmd%process_id(i), cmd%local, global) call global%process_stack%fill_result_vars (cmd%process_id(i)) call global%process_stack%update_result_vars & (cmd%process_id(i), global%var_list) if (signal_is_pending ()) return end do end subroutine cmd_integrate_execute @ %def cmd_integrate_execute @ \subsubsection{Observables} Declare an observable. After the declaration, it can be used to record data, and at the end one can retrieve average and error. <>= type, extends (command_t) :: cmd_observable_t private type(string_t) :: id contains <> end type cmd_observable_t @ %def cmd_observable_t @ Output. We know the ID. <>= procedure :: write => cmd_observable_write <>= subroutine cmd_observable_write (cmd, unit, indent) class(cmd_observable_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A,A)") "observable: ", char (cmd%id) end subroutine cmd_observable_write @ %def cmd_observable_write @ Compile. Just record the observable ID. <>= procedure :: compile => cmd_observable_compile <>= subroutine cmd_observable_compile (cmd, global) class(cmd_observable_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_tag pn_tag => parse_node_get_sub_ptr (cmd%pn, 2) if (associated (pn_tag)) then cmd%pn_opt => parse_node_get_next_ptr (pn_tag) end if call cmd%compile_options (global) select case (char (parse_node_get_rule_key (pn_tag))) case ("analysis_id") cmd%id = parse_node_get_string (pn_tag) case default call msg_bug ("observable: name expression not implemented (yet)") end select end subroutine cmd_observable_compile @ %def cmd_observable_compile @ Command execution. This declares the observable and allocates it in the analysis store. <>= procedure :: execute => cmd_observable_execute <>= subroutine cmd_observable_execute (cmd, global) class(cmd_observable_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list type(graph_options_t) :: graph_options type(string_t) :: label, unit var_list => cmd%local%get_var_list_ptr () label = var_list%get_sval (var_str ("$obs_label")) unit = var_list%get_sval (var_str ("$obs_unit")) call graph_options_init (graph_options) call set_graph_options (graph_options, var_list) call analysis_init_observable (cmd%id, label, unit, graph_options) end subroutine cmd_observable_execute @ %def cmd_observable_execute @ \subsubsection{Histograms} Declare a histogram. At minimum, we have to set lower and upper bound and bin width. <>= type, extends (command_t) :: cmd_histogram_t private type(string_t) :: id type(parse_node_t), pointer :: pn_lower_bound => null () type(parse_node_t), pointer :: pn_upper_bound => null () type(parse_node_t), pointer :: pn_bin_width => null () contains <> end type cmd_histogram_t @ %def cmd_histogram_t @ Output. Just print the ID. <>= procedure :: write => cmd_histogram_write <>= subroutine cmd_histogram_write (cmd, unit, indent) class(cmd_histogram_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A,A)") "histogram: ", char (cmd%id) end subroutine cmd_histogram_write @ %def cmd_histogram_write @ Compile. Record the histogram ID and initialize lower, upper bound and bin width. <>= procedure :: compile => cmd_histogram_compile <>= subroutine cmd_histogram_compile (cmd, global) class(cmd_histogram_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_tag, pn_args, pn_arg1, pn_arg2, pn_arg3 character(*), parameter :: e_illegal_use = & "illegal usage of 'histogram': insufficient number of arguments" pn_tag => parse_node_get_sub_ptr (cmd%pn, 2) pn_args => parse_node_get_next_ptr (pn_tag) if (associated (pn_args)) then pn_arg1 => parse_node_get_sub_ptr (pn_args) if (.not. associated (pn_arg1)) call msg_fatal (e_illegal_use) pn_arg2 => parse_node_get_next_ptr (pn_arg1) if (.not. associated (pn_arg2)) call msg_fatal (e_illegal_use) pn_arg3 => parse_node_get_next_ptr (pn_arg2) cmd%pn_opt => parse_node_get_next_ptr (pn_args) end if call cmd%compile_options (global) select case (char (parse_node_get_rule_key (pn_tag))) case ("analysis_id") cmd%id = parse_node_get_string (pn_tag) case default call msg_bug ("histogram: name expression not implemented (yet)") end select cmd%pn_lower_bound => pn_arg1 cmd%pn_upper_bound => pn_arg2 cmd%pn_bin_width => pn_arg3 end subroutine cmd_histogram_compile @ %def cmd_histogram_compile @ Command execution. This declares the histogram and allocates it in the analysis store. <>= procedure :: execute => cmd_histogram_execute <>= subroutine cmd_histogram_execute (cmd, global) class(cmd_histogram_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list real(default) :: lower_bound, upper_bound, bin_width integer :: bin_number logical :: bin_width_is_used, normalize_bins type(string_t) :: obs_label, obs_unit type(graph_options_t) :: graph_options type(drawing_options_t) :: drawing_options var_list => cmd%local%get_var_list_ptr () lower_bound = eval_real (cmd%pn_lower_bound, var_list) upper_bound = eval_real (cmd%pn_upper_bound, var_list) if (associated (cmd%pn_bin_width)) then bin_width = eval_real (cmd%pn_bin_width, var_list) bin_width_is_used = .true. else if (var_list%is_known (var_str ("n_bins"))) then bin_number = & var_list%get_ival (var_str ("n_bins")) bin_width_is_used = .false. else call msg_error ("Cmd '" // char (cmd%id) // & "': neither bin width nor number is defined") end if normalize_bins = & var_list%get_lval (var_str ("?normalize_bins")) obs_label = & var_list%get_sval (var_str ("$obs_label")) obs_unit = & var_list%get_sval (var_str ("$obs_unit")) call graph_options_init (graph_options) call set_graph_options (graph_options, var_list) call drawing_options_init_histogram (drawing_options) call set_drawing_options (drawing_options, var_list) if (bin_width_is_used) then call analysis_init_histogram & (cmd%id, lower_bound, upper_bound, bin_width, & normalize_bins, & obs_label, obs_unit, & graph_options, drawing_options) else call analysis_init_histogram & (cmd%id, lower_bound, upper_bound, bin_number, & normalize_bins, & obs_label, obs_unit, & graph_options, drawing_options) end if end subroutine cmd_histogram_execute @ %def cmd_histogram_execute @ Set the graph options from a variable list. <>= subroutine set_graph_options (gro, var_list) type(graph_options_t), intent(inout) :: gro type(var_list_t), intent(in) :: var_list call graph_options_set (gro, title = & var_list%get_sval (var_str ("$title"))) call graph_options_set (gro, description = & var_list%get_sval (var_str ("$description"))) call graph_options_set (gro, x_label = & var_list%get_sval (var_str ("$x_label"))) call graph_options_set (gro, y_label = & var_list%get_sval (var_str ("$y_label"))) call graph_options_set (gro, width_mm = & var_list%get_ival (var_str ("graph_width_mm"))) call graph_options_set (gro, height_mm = & var_list%get_ival (var_str ("graph_height_mm"))) call graph_options_set (gro, x_log = & var_list%get_lval (var_str ("?x_log"))) call graph_options_set (gro, y_log = & var_list%get_lval (var_str ("?y_log"))) if (var_list%is_known (var_str ("x_min"))) & call graph_options_set (gro, x_min = & var_list%get_rval (var_str ("x_min"))) if (var_list%is_known (var_str ("x_max"))) & call graph_options_set (gro, x_max = & var_list%get_rval (var_str ("x_max"))) if (var_list%is_known (var_str ("y_min"))) & call graph_options_set (gro, y_min = & var_list%get_rval (var_str ("y_min"))) if (var_list%is_known (var_str ("y_max"))) & call graph_options_set (gro, y_max = & var_list%get_rval (var_str ("y_max"))) call graph_options_set (gro, gmlcode_bg = & var_list%get_sval (var_str ("$gmlcode_bg"))) call graph_options_set (gro, gmlcode_fg = & var_list%get_sval (var_str ("$gmlcode_fg"))) end subroutine set_graph_options @ %def set_graph_options @ Set the drawing options from a variable list. <>= subroutine set_drawing_options (dro, var_list) type(drawing_options_t), intent(inout) :: dro type(var_list_t), intent(in) :: var_list if (var_list%is_known (var_str ("?draw_histogram"))) then if (var_list%get_lval (var_str ("?draw_histogram"))) then call drawing_options_set (dro, with_hbars = .true.) else call drawing_options_set (dro, with_hbars = .false., & with_base = .false., fill = .false., piecewise = .false.) end if end if if (var_list%is_known (var_str ("?draw_base"))) then if (var_list%get_lval (var_str ("?draw_base"))) then call drawing_options_set (dro, with_base = .true.) else call drawing_options_set (dro, with_base = .false., fill = .false.) end if end if if (var_list%is_known (var_str ("?draw_piecewise"))) then if (var_list%get_lval (var_str ("?draw_piecewise"))) then call drawing_options_set (dro, piecewise = .true.) else call drawing_options_set (dro, piecewise = .false.) end if end if if (var_list%is_known (var_str ("?fill_curve"))) then if (var_list%get_lval (var_str ("?fill_curve"))) then call drawing_options_set (dro, fill = .true., with_base = .true.) else call drawing_options_set (dro, fill = .false.) end if end if if (var_list%is_known (var_str ("?draw_curve"))) then if (var_list%get_lval (var_str ("?draw_curve"))) then call drawing_options_set (dro, draw = .true.) else call drawing_options_set (dro, draw = .false.) end if end if if (var_list%is_known (var_str ("?draw_errors"))) then if (var_list%get_lval (var_str ("?draw_errors"))) then call drawing_options_set (dro, err = .true.) else call drawing_options_set (dro, err = .false.) end if end if if (var_list%is_known (var_str ("?draw_symbols"))) then if (var_list%get_lval (var_str ("?draw_symbols"))) then call drawing_options_set (dro, symbols = .true.) else call drawing_options_set (dro, symbols = .false.) end if end if if (var_list%is_known (var_str ("$fill_options"))) then call drawing_options_set (dro, fill_options = & var_list%get_sval (var_str ("$fill_options"))) end if if (var_list%is_known (var_str ("$draw_options"))) then call drawing_options_set (dro, draw_options = & var_list%get_sval (var_str ("$draw_options"))) end if if (var_list%is_known (var_str ("$err_options"))) then call drawing_options_set (dro, err_options = & var_list%get_sval (var_str ("$err_options"))) end if if (var_list%is_known (var_str ("$symbol"))) then call drawing_options_set (dro, symbol = & var_list%get_sval (var_str ("$symbol"))) end if if (var_list%is_known (var_str ("$gmlcode_bg"))) then call drawing_options_set (dro, gmlcode_bg = & var_list%get_sval (var_str ("$gmlcode_bg"))) end if if (var_list%is_known (var_str ("$gmlcode_fg"))) then call drawing_options_set (dro, gmlcode_fg = & var_list%get_sval (var_str ("$gmlcode_fg"))) end if end subroutine set_drawing_options @ %def set_drawing_options @ \subsubsection{Plots} Declare a plot. No mandatory arguments, just options. <>= type, extends (command_t) :: cmd_plot_t private type(string_t) :: id contains <> end type cmd_plot_t @ %def cmd_plot_t @ Output. Just print the ID. <>= procedure :: write => cmd_plot_write <>= subroutine cmd_plot_write (cmd, unit, indent) class(cmd_plot_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A,A)") "plot: ", char (cmd%id) end subroutine cmd_plot_write @ %def cmd_plot_write @ Compile. Record the plot ID and initialize lower, upper bound and bin width. <>= procedure :: compile => cmd_plot_compile <>= subroutine cmd_plot_compile (cmd, global) class(cmd_plot_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_tag pn_tag => parse_node_get_sub_ptr (cmd%pn, 2) cmd%pn_opt => parse_node_get_next_ptr (pn_tag) call cmd%init (pn_tag, global) end subroutine cmd_plot_compile @ %def cmd_plot_compile @ This init routine is separated because it is reused below for graph initialization. <>= procedure :: init => cmd_plot_init <>= subroutine cmd_plot_init (plot, pn_tag, global) class(cmd_plot_t), intent(inout) :: plot type(parse_node_t), intent(in), pointer :: pn_tag type(rt_data_t), intent(inout), target :: global call plot%compile_options (global) select case (char (parse_node_get_rule_key (pn_tag))) case ("analysis_id") plot%id = parse_node_get_string (pn_tag) case default call msg_bug ("plot: name expression not implemented (yet)") end select end subroutine cmd_plot_init @ %def cmd_plot_init @ Command execution. This declares the plot and allocates it in the analysis store. <>= procedure :: execute => cmd_plot_execute <>= subroutine cmd_plot_execute (cmd, global) class(cmd_plot_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list type(graph_options_t) :: graph_options type(drawing_options_t) :: drawing_options var_list => cmd%local%get_var_list_ptr () call graph_options_init (graph_options) call set_graph_options (graph_options, var_list) call drawing_options_init_plot (drawing_options) call set_drawing_options (drawing_options, var_list) call analysis_init_plot (cmd%id, graph_options, drawing_options) end subroutine cmd_plot_execute @ %def cmd_plot_execute @ \subsubsection{Graphs} Declare a graph. The graph is defined in terms of its contents. Both the graph and its contents may carry options. The graph object contains its own ID as well as the IDs of its elements. For the elements, we reuse the [[cmd_plot_t]] defined above. <>= type, extends (command_t) :: cmd_graph_t private type(string_t) :: id integer :: n_elements = 0 type(cmd_plot_t), dimension(:), allocatable :: el type(string_t), dimension(:), allocatable :: element_id contains <> end type cmd_graph_t @ %def cmd_graph_t @ Output. Just print the ID. <>= procedure :: write => cmd_graph_write <>= subroutine cmd_graph_write (cmd, unit, indent) class(cmd_graph_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A,A,A,I0,A)") "graph: ", char (cmd%id), & " (", cmd%n_elements, " entries)" end subroutine cmd_graph_write @ %def cmd_graph_write @ Compile. Record the graph ID and initialize lower, upper bound and bin width. For compiling the graph element syntax, we use part of the [[cmd_plot_t]] compiler. Note: currently, we do not respect options, therefore just IDs on the RHS. <>= procedure :: compile => cmd_graph_compile <>= subroutine cmd_graph_compile (cmd, global) class(cmd_graph_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_term, pn_tag, pn_def, pn_app integer :: i pn_term => parse_node_get_sub_ptr (cmd%pn, 2) pn_tag => parse_node_get_sub_ptr (pn_term) cmd%pn_opt => parse_node_get_next_ptr (pn_tag) call cmd%compile_options (global) select case (char (parse_node_get_rule_key (pn_tag))) case ("analysis_id") cmd%id = parse_node_get_string (pn_tag) case default call msg_bug ("graph: name expression not implemented (yet)") end select pn_def => parse_node_get_next_ptr (pn_term, 2) cmd%n_elements = parse_node_get_n_sub (pn_def) allocate (cmd%element_id (cmd%n_elements)) allocate (cmd%el (cmd%n_elements)) pn_term => parse_node_get_sub_ptr (pn_def) pn_tag => parse_node_get_sub_ptr (pn_term) cmd%el(1)%pn_opt => parse_node_get_next_ptr (pn_tag) call cmd%el(1)%init (pn_tag, global) cmd%element_id(1) = parse_node_get_string (pn_tag) pn_app => parse_node_get_next_ptr (pn_term) do i = 2, cmd%n_elements pn_term => parse_node_get_sub_ptr (pn_app, 2) pn_tag => parse_node_get_sub_ptr (pn_term) cmd%el(i)%pn_opt => parse_node_get_next_ptr (pn_tag) call cmd%el(i)%init (pn_tag, global) cmd%element_id(i) = parse_node_get_string (pn_tag) pn_app => parse_node_get_next_ptr (pn_app) end do end subroutine cmd_graph_compile @ %def cmd_graph_compile @ Command execution. This declares the graph, allocates it in the analysis store, and copies the graph elements. For the graph, we set graph and default drawing options. For the elements, we reset individual drawing options. This accesses internals of the contained elements of type [[cmd_plot_t]], see above. We might disentangle such an interdependency when this code is rewritten using proper type extension. <>= procedure :: execute => cmd_graph_execute <>= subroutine cmd_graph_execute (cmd, global) class(cmd_graph_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list type(graph_options_t) :: graph_options type(drawing_options_t) :: drawing_options integer :: i, type var_list => cmd%local%get_var_list_ptr () call graph_options_init (graph_options) call set_graph_options (graph_options, var_list) call analysis_init_graph (cmd%id, cmd%n_elements, graph_options) do i = 1, cmd%n_elements if (associated (cmd%el(i)%options)) then call cmd%el(i)%options%execute (cmd%el(i)%local) end if type = analysis_store_get_object_type (cmd%element_id(i)) select case (type) case (AN_HISTOGRAM) call drawing_options_init_histogram (drawing_options) case (AN_PLOT) call drawing_options_init_plot (drawing_options) end select call set_drawing_options (drawing_options, var_list) if (associated (cmd%el(i)%options)) then call set_drawing_options (drawing_options, cmd%el(i)%local%var_list) end if call analysis_fill_graph (cmd%id, i, cmd%element_id(i), drawing_options) end do end subroutine cmd_graph_execute @ %def cmd_graph_execute @ \subsubsection{Analysis} Hold the analysis ID either as a string or as an expression: <>= type :: analysis_id_t type(string_t) :: tag type(parse_node_t), pointer :: pn_sexpr => null () end type analysis_id_t @ %def analysis_id_t @ Define the analysis expression. We store the parse tree for the right-hand side instead of compiling it. Compilation is deferred to the process environment where the analysis expression is used. <>= type, extends (command_t) :: cmd_analysis_t private type(parse_node_t), pointer :: pn_lexpr => null () contains <> end type cmd_analysis_t @ %def cmd_analysis_t @ Output. Print just a message that analysis has been defined. <>= procedure :: write => cmd_analysis_write <>= subroutine cmd_analysis_write (cmd, unit, indent) class(cmd_analysis_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)") "analysis: [defined]" end subroutine cmd_analysis_write @ %def cmd_analysis_write @ Compile. Simply store the parse (sub)tree. <>= procedure :: compile => cmd_analysis_compile <>= subroutine cmd_analysis_compile (cmd, global) class(cmd_analysis_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global cmd%pn_lexpr => parse_node_get_sub_ptr (cmd%pn, 3) end subroutine cmd_analysis_compile @ %def cmd_analysis_compile @ Instead of evaluating the cut expression, link the parse tree to the global data set, such that it is compiled and executed in the appropriate process context. <>= procedure :: execute => cmd_analysis_execute <>= subroutine cmd_analysis_execute (cmd, global) class(cmd_analysis_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global global%pn%analysis_lexpr => cmd%pn_lexpr end subroutine cmd_analysis_execute @ %def cmd_analysis_execute @ \subsubsection{Write histograms and plots} The data type encapsulating the command: <>= type, extends (command_t) :: cmd_write_analysis_t private type(analysis_id_t), dimension(:), allocatable :: id type(string_t), dimension(:), allocatable :: tag contains <> end type cmd_write_analysis_t @ %def analysis_id_t @ %def cmd_write_analysis_t @ Output. Just the keyword. <>= procedure :: write => cmd_write_analysis_write <>= subroutine cmd_write_analysis_write (cmd, unit, indent) class(cmd_write_analysis_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)") "write_analysis" end subroutine cmd_write_analysis_write @ %def cmd_write_analysis_write @ Compile. <>= procedure :: compile => cmd_write_analysis_compile <>= subroutine cmd_write_analysis_compile (cmd, global) class(cmd_write_analysis_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_clause, pn_args, pn_id integer :: n, i pn_clause => parse_node_get_sub_ptr (cmd%pn) pn_args => parse_node_get_sub_ptr (pn_clause, 2) cmd%pn_opt => parse_node_get_next_ptr (pn_clause) call cmd%compile_options (global) if (associated (pn_args)) then n = parse_node_get_n_sub (pn_args) allocate (cmd%id (n)) do i = 1, n pn_id => parse_node_get_sub_ptr (pn_args, i) if (char (parse_node_get_rule_key (pn_id)) == "analysis_id") then cmd%id(i)%tag = parse_node_get_string (pn_id) else cmd%id(i)%pn_sexpr => pn_id end if end do else allocate (cmd%id (0)) end if end subroutine cmd_write_analysis_compile @ %def cmd_write_analysis_compile @ The output format for real data values: <>= character(*), parameter, public :: & DEFAULT_ANALYSIS_FILENAME = "whizard_analysis.dat" character(len=1), dimension(2), parameter, public :: & FORBIDDEN_ENDINGS1 = [ "o", "a" ] character(len=2), dimension(6), parameter, public :: & FORBIDDEN_ENDINGS2 = [ "mp", "ps", "vg", "pg", "lo", "la" ] character(len=3), dimension(18), parameter, public :: & FORBIDDEN_ENDINGS3 = [ "aux", "dvi", "evt", "evx", "f03", "f90", & "f95", "log", "ltp", "mpx", "olc", "olp", "pdf", "phs", "sin", & "tex", "vg2", "vgx" ] @ %def DEFAULT_ANALYSIS_FILENAME @ %def FORBIDDEN_ENDINGS1 @ %def FORBIDDEN_ENDINGS2 @ %def FORBIDDEN_ENDINGS3 @ As this contains a lot of similar code to [[cmd_compile_analysis_execute]] we outsource the main code to a subroutine. <>= procedure :: execute => cmd_write_analysis_execute <>= subroutine cmd_write_analysis_execute (cmd, global) class(cmd_write_analysis_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list var_list => cmd%local%get_var_list_ptr () call write_analysis_wrap (var_list, global%out_files, & cmd%id, tag = cmd%tag) end subroutine cmd_write_analysis_execute @ %def cmd_write_analysis_execute @ If the [[data_file]] optional argument is present, this is called from [[cmd_compile_analysis_execute]], which needs the file name for further processing, and requires the default format. For the moment, parameters and macros for custom data processing are disabled. <>= subroutine write_analysis_wrap (var_list, out_files, id, tag, data_file) type(var_list_t), intent(inout), target :: var_list type(file_list_t), intent(inout), target :: out_files type(analysis_id_t), dimension(:), intent(in), target :: id type(string_t), dimension(:), allocatable, intent(out) :: tag type(string_t), intent(out), optional :: data_file type(string_t) :: defaultfile, file integer :: i logical :: keep_open !, custom, header, columns type(string_t) :: extension !, comment_prefix, separator !!! JRR: WK please check (#542) ! integer :: type ! type(ifile_t) :: ifile logical :: one_file !, has_writer ! type(analysis_iterator_t) :: iterator ! type(rt_data_t), target :: sandbox ! type(command_list_t) :: writer defaultfile = var_list%get_sval (var_str ("$out_file")) if (present (data_file)) then if (defaultfile == "" .or. defaultfile == ".") then defaultfile = DEFAULT_ANALYSIS_FILENAME else if (scan (".", defaultfile) > 0) then call split (defaultfile, extension, ".", back=.true.) if (any (lower_case (char(extension)) == FORBIDDEN_ENDINGS1) .or. & any (lower_case (char(extension)) == FORBIDDEN_ENDINGS2) .or. & any (lower_case (char(extension)) == FORBIDDEN_ENDINGS3)) & call msg_fatal ("The ending " // char(extension) // & " is internal and not allowed as data file.") if (extension /= "") then if (defaultfile /= "") then defaultfile = defaultfile // "." // extension else defaultfile = "whizard_analysis." // extension end if else defaultfile = defaultfile // ".dat" endif else defaultfile = defaultfile // ".dat" end if end if data_file = defaultfile end if one_file = defaultfile /= "" if (one_file) then file = defaultfile keep_open = file_list_is_open (out_files, file, & action = "write") if (keep_open) then if (present (data_file)) then call msg_fatal ("Compiling analysis: File '" & // char (data_file) & // "' can't be used, it is already open.") else call msg_message ("Appending analysis data to file '" & // char (file) // "'") end if else call file_list_open (out_files, file, & action = "write", status = "replace", position = "asis") call msg_message ("Writing analysis data to file '" & // char (file) // "'") end if end if !!! JRR: WK please check. Custom data output. Ticket #542 ! if (present (data_file)) then ! custom = .false. ! else ! custom = var_list%get_lval (& ! var_str ("?out_custom")) ! end if ! comment_prefix = var_list%get_sval (& ! var_str ("$out_comment")) ! header = var_list%get_lval (& ! var_str ("?out_header")) ! write_yerr = var_list%get_lval (& ! var_str ("?out_yerr")) ! write_xerr = var_list%get_lval (& ! var_str ("?out_xerr")) call get_analysis_tags (tag, id, var_list) do i = 1, size (tag) call file_list_write_analysis & (out_files, file, tag(i)) end do if (one_file .and. .not. keep_open) then call file_list_close (out_files, file) end if contains subroutine get_analysis_tags (analysis_tag, id, var_list) type(string_t), dimension(:), intent(out), allocatable :: analysis_tag type(analysis_id_t), dimension(:), intent(in) :: id type(var_list_t), intent(in), target :: var_list if (size (id) /= 0) then allocate (analysis_tag (size (id))) do i = 1, size (id) if (associated (id(i)%pn_sexpr)) then analysis_tag(i) = eval_string (id(i)%pn_sexpr, var_list) else analysis_tag(i) = id(i)%tag end if end do else call analysis_store_get_ids (tag) end if end subroutine get_analysis_tags end subroutine write_analysis_wrap @ %def write_analysis_wrap \subsubsection{Compile analysis results} This command writes files in a form suitable for GAMELAN and executes the appropriate commands to compile them. The first part is identical to [[cmd_write_analysis]]. <>= type, extends (command_t) :: cmd_compile_analysis_t private type(analysis_id_t), dimension(:), allocatable :: id type(string_t), dimension(:), allocatable :: tag contains <> end type cmd_compile_analysis_t @ %def cmd_compile_analysis_t @ Output. Just the keyword. <>= procedure :: write => cmd_compile_analysis_write <>= subroutine cmd_compile_analysis_write (cmd, unit, indent) class(cmd_compile_analysis_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)") "compile_analysis" end subroutine cmd_compile_analysis_write @ %def cmd_compile_analysis_write @ Compile. <>= procedure :: compile => cmd_compile_analysis_compile <>= subroutine cmd_compile_analysis_compile (cmd, global) class(cmd_compile_analysis_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_clause, pn_args, pn_id integer :: n, i pn_clause => parse_node_get_sub_ptr (cmd%pn) pn_args => parse_node_get_sub_ptr (pn_clause, 2) cmd%pn_opt => parse_node_get_next_ptr (pn_clause) call cmd%compile_options (global) if (associated (pn_args)) then n = parse_node_get_n_sub (pn_args) allocate (cmd%id (n)) do i = 1, n pn_id => parse_node_get_sub_ptr (pn_args, i) if (char (parse_node_get_rule_key (pn_id)) == "analysis_id") then cmd%id(i)%tag = parse_node_get_string (pn_id) else cmd%id(i)%pn_sexpr => pn_id end if end do else allocate (cmd%id (0)) end if end subroutine cmd_compile_analysis_compile @ %def cmd_compile_analysis_compile @ First write the analysis data to file, then write a GAMELAN driver and produce MetaPost and \TeX\ output. <>= procedure :: execute => cmd_compile_analysis_execute <>= subroutine cmd_compile_analysis_execute (cmd, global) class(cmd_compile_analysis_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list type(string_t) :: file, basename, extension, driver_file, & makefile integer :: u_driver, u_makefile logical :: has_gmlcode, only_file var_list => cmd%local%get_var_list_ptr () call write_analysis_wrap (var_list, & global%out_files, cmd%id, tag = cmd%tag, & data_file = file) basename = file if (scan (".", basename) > 0) then call split (basename, extension, ".", back=.true.) else extension = "" end if driver_file = basename // ".tex" makefile = basename // "_ana.makefile" u_driver = free_unit () open (unit=u_driver, file=char(driver_file), & action="write", status="replace") if (allocated (cmd%tag)) then call analysis_write_driver (file, cmd%tag, unit=u_driver) has_gmlcode = analysis_has_plots (cmd%tag) else call analysis_write_driver (file, unit=u_driver) has_gmlcode = analysis_has_plots () end if close (u_driver) u_makefile = free_unit () open (unit=u_makefile, file=char(makefile), & action="write", status="replace") call analysis_write_makefile (basename, u_makefile, & has_gmlcode, global%os_data) close (u_makefile) call msg_message ("Compiling analysis results display in '" & // char (driver_file) // "'") call msg_message ("Providing analysis steering makefile '" & // char (makefile) // "'") only_file = global%var_list%get_lval & (var_str ("?analysis_file_only")) if (.not. only_file) call analysis_compile_tex & (basename, has_gmlcode, global%os_data) end subroutine cmd_compile_analysis_execute @ %def cmd_compile_analysis_execute @ \subsection{User-controlled output to data files} \subsubsection{Open file (output)} Open a file for output. <>= type, extends (command_t) :: cmd_open_out_t private type(parse_node_t), pointer :: file_expr => null () contains <> end type cmd_open_out_t @ %def cmd_open_out @ Finalizer for the embedded eval tree. <>= subroutine cmd_open_out_final (object) class(cmd_open_out_t), intent(inout) :: object end subroutine cmd_open_out_final @ %def cmd_open_out_final @ Output (trivial here). <>= procedure :: write => cmd_open_out_write <>= subroutine cmd_open_out_write (cmd, unit, indent) class(cmd_open_out_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)", advance="no") "open_out: " end subroutine cmd_open_out_write @ %def cmd_open_out_write @ Compile: create an eval tree for the filename expression. <>= procedure :: compile => cmd_open_out_compile <>= subroutine cmd_open_out_compile (cmd, global) class(cmd_open_out_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global cmd%file_expr => parse_node_get_sub_ptr (cmd%pn, 2) if (associated (cmd%file_expr)) then cmd%pn_opt => parse_node_get_next_ptr (cmd%file_expr) end if call cmd%compile_options (global) end subroutine cmd_open_out_compile @ %def cmd_open_out_compile @ Execute: append the file to the global list of open files. <>= procedure :: execute => cmd_open_out_execute <>= subroutine cmd_open_out_execute (cmd, global) class(cmd_open_out_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list type(eval_tree_t) :: file_expr type(string_t) :: file var_list => cmd%local%get_var_list_ptr () call file_expr%init_sexpr (cmd%file_expr, var_list) call file_expr%evaluate () if (file_expr%is_known ()) then file = file_expr%get_string () call file_list_open (global%out_files, file, & action = "write", status = "replace", position = "asis") else call msg_fatal ("open_out: file name argument evaluates to unknown") end if call file_expr%final () end subroutine cmd_open_out_execute @ %def cmd_open_out_execute \subsubsection{Open file (output)} Close an output file. Except for the [[execute]] method, everything is analogous to the open command, so we can just inherit. <>= type, extends (cmd_open_out_t) :: cmd_close_out_t private contains <> end type cmd_close_out_t @ %def cmd_close_out @ Execute: remove the file from the global list of output files. <>= procedure :: execute => cmd_close_out_execute <>= subroutine cmd_close_out_execute (cmd, global) class(cmd_close_out_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list type(eval_tree_t) :: file_expr type(string_t) :: file var_list => cmd%local%var_list call file_expr%init_sexpr (cmd%file_expr, var_list) call file_expr%evaluate () if (file_expr%is_known ()) then file = file_expr%get_string () call file_list_close (global%out_files, file) else call msg_fatal ("close_out: file name argument evaluates to unknown") end if call file_expr%final () end subroutine cmd_close_out_execute @ %def cmd_close_out_execute @ \subsection{Print custom-formatted values} <>= type, extends (command_t) :: cmd_printf_t private type(parse_node_t), pointer :: sexpr => null () type(parse_node_t), pointer :: sprintf_fun => null () type(parse_node_t), pointer :: sprintf_clause => null () type(parse_node_t), pointer :: sprintf => null () contains <> end type cmd_printf_t @ %def cmd_printf_t @ Finalize. <>= procedure :: final => cmd_printf_final <>= subroutine cmd_printf_final (cmd) class(cmd_printf_t), intent(inout) :: cmd call parse_node_final (cmd%sexpr, recursive = .false.) deallocate (cmd%sexpr) call parse_node_final (cmd%sprintf_fun, recursive = .false.) deallocate (cmd%sprintf_fun) call parse_node_final (cmd%sprintf_clause, recursive = .false.) deallocate (cmd%sprintf_clause) call parse_node_final (cmd%sprintf, recursive = .false.) deallocate (cmd%sprintf) end subroutine cmd_printf_final @ %def cmd_printf_final @ Output. Do not print the parse tree, since this may get cluttered. Just a message that cuts have been defined. <>= procedure :: write => cmd_printf_write <>= subroutine cmd_printf_write (cmd, unit, indent) class(cmd_printf_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)") "printf:" end subroutine cmd_printf_write @ %def cmd_printf_write @ Compile. We create a fake parse node (subtree) with a [[sprintf]] command with identical arguments which can then be handled by the corresponding evaluation procedure. <>= procedure :: compile => cmd_printf_compile <>= subroutine cmd_printf_compile (cmd, global) class(cmd_printf_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_cmd, pn_clause, pn_args, pn_format pn_cmd => parse_node_get_sub_ptr (cmd%pn) pn_clause => parse_node_get_sub_ptr (pn_cmd) pn_format => parse_node_get_sub_ptr (pn_clause, 2) pn_args => parse_node_get_next_ptr (pn_clause) cmd%pn_opt => parse_node_get_next_ptr (pn_cmd) call cmd%compile_options (global) allocate (cmd%sexpr) call parse_node_create_branch (cmd%sexpr, & syntax_get_rule_ptr (syntax_cmd_list, var_str ("sexpr"))) allocate (cmd%sprintf_fun) call parse_node_create_branch (cmd%sprintf_fun, & syntax_get_rule_ptr (syntax_cmd_list, var_str ("sprintf_fun"))) allocate (cmd%sprintf_clause) call parse_node_create_branch (cmd%sprintf_clause, & syntax_get_rule_ptr (syntax_cmd_list, var_str ("sprintf_clause"))) allocate (cmd%sprintf) call parse_node_create_key (cmd%sprintf, & syntax_get_rule_ptr (syntax_cmd_list, var_str ("sprintf"))) call parse_node_append_sub (cmd%sprintf_clause, cmd%sprintf) call parse_node_append_sub (cmd%sprintf_clause, pn_format) call parse_node_freeze_branch (cmd%sprintf_clause) call parse_node_append_sub (cmd%sprintf_fun, cmd%sprintf_clause) if (associated (pn_args)) then call parse_node_append_sub (cmd%sprintf_fun, pn_args) end if call parse_node_freeze_branch (cmd%sprintf_fun) call parse_node_append_sub (cmd%sexpr, cmd%sprintf_fun) call parse_node_freeze_branch (cmd%sexpr) end subroutine cmd_printf_compile @ %def cmd_printf_compile @ Execute. Evaluate the string (pretending this is a [[sprintf]] expression) and print it. <>= procedure :: execute => cmd_printf_execute <>= subroutine cmd_printf_execute (cmd, global) class(cmd_printf_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list type(string_t) :: string, file type(eval_tree_t) :: sprintf_expr logical :: advance var_list => cmd%local%get_var_list_ptr () advance = var_list%get_lval (& var_str ("?out_advance")) file = var_list%get_sval (& var_str ("$out_file")) call sprintf_expr%init_sexpr (cmd%sexpr, var_list) call sprintf_expr%evaluate () if (sprintf_expr%is_known ()) then string = sprintf_expr%get_string () if (len (file) == 0) then call msg_result (char (string)) else call file_list_write (global%out_files, file, string, advance) end if end if end subroutine cmd_printf_execute @ %def cmd_printf_execute @ \subsubsection{Record data} The expression syntax already contains a [[record]] keyword; this evaluates to a logical which is always true, but it has the side-effect of recording data into analysis objects. Here we define a command as an interface to this construct. <>= type, extends (command_t) :: cmd_record_t private type(parse_node_t), pointer :: pn_lexpr => null () contains <> end type cmd_record_t @ %def cmd_record_t @ Output. With the compile hack below, there is nothing of interest to print here. <>= procedure :: write => cmd_record_write <>= subroutine cmd_record_write (cmd, unit, indent) class(cmd_record_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)") "record" end subroutine cmd_record_write @ %def cmd_record_write @ Compile. This is a hack which transforms the [[record]] command into a [[record]] expression, which we handle in the [[expressions]] module. <>= procedure :: compile => cmd_record_compile <>= subroutine cmd_record_compile (cmd, global) class(cmd_record_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_lexpr, pn_lsinglet, pn_lterm, pn_record call parse_node_create_branch (pn_lexpr, & syntax_get_rule_ptr (syntax_cmd_list, var_str ("lexpr"))) call parse_node_create_branch (pn_lsinglet, & syntax_get_rule_ptr (syntax_cmd_list, var_str ("lsinglet"))) call parse_node_append_sub (pn_lexpr, pn_lsinglet) call parse_node_create_branch (pn_lterm, & syntax_get_rule_ptr (syntax_cmd_list, var_str ("lterm"))) call parse_node_append_sub (pn_lsinglet, pn_lterm) pn_record => parse_node_get_sub_ptr (cmd%pn) call parse_node_append_sub (pn_lterm, pn_record) cmd%pn_lexpr => pn_lexpr end subroutine cmd_record_compile @ %def cmd_record_compile @ Command execution. Again, transfer this to the embedded expression and just forget the logical result. <>= procedure :: execute => cmd_record_execute <>= subroutine cmd_record_execute (cmd, global) class(cmd_record_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list logical :: lval var_list => global%get_var_list_ptr () lval = eval_log (cmd%pn_lexpr, var_list) end subroutine cmd_record_execute @ %def cmd_record_execute @ \subsubsection{Unstable particles} Mark a particle as unstable. For each unstable particle, we store a number of decay channels and compute their respective BRs. <>= type, extends (command_t) :: cmd_unstable_t private integer :: n_proc = 0 type(string_t), dimension(:), allocatable :: process_id type(parse_node_t), pointer :: pn_prt_in => null () contains <> end type cmd_unstable_t @ %def cmd_unstable_t @ Output: we know the process IDs. <>= procedure :: write => cmd_unstable_write <>= subroutine cmd_unstable_write (cmd, unit, indent) class(cmd_unstable_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u, i u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A,1x,I0,1x,A)", advance="no") & "unstable:", 1, "(" do i = 1, cmd%n_proc if (i > 1) write (u, "(A,1x)", advance="no") "," write (u, "(A)", advance="no") char (cmd%process_id(i)) end do write (u, "(A)") ")" end subroutine cmd_unstable_write @ %def cmd_unstable_write @ Compile. Initiate an eval tree for the decaying particle and determine the decay channel process IDs. <>= procedure :: compile => cmd_unstable_compile <>= subroutine cmd_unstable_compile (cmd, global) class(cmd_unstable_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_list, pn_proc integer :: i cmd%pn_prt_in => parse_node_get_sub_ptr (cmd%pn, 2) pn_list => parse_node_get_next_ptr (cmd%pn_prt_in) if (associated (pn_list)) then select case (char (parse_node_get_rule_key (pn_list))) case ("unstable_arg") cmd%n_proc = parse_node_get_n_sub (pn_list) cmd%pn_opt => parse_node_get_next_ptr (pn_list) case default cmd%n_proc = 0 cmd%pn_opt => pn_list pn_list => null () end select end if call cmd%compile_options (global) if (associated (pn_list)) then allocate (cmd%process_id (cmd%n_proc)) pn_proc => parse_node_get_sub_ptr (pn_list) do i = 1, cmd%n_proc cmd%process_id(i) = parse_node_get_string (pn_proc) call cmd%local%process_stack%init_result_vars (cmd%process_id(i)) pn_proc => parse_node_get_next_ptr (pn_proc) end do else allocate (cmd%process_id (0)) end if end subroutine cmd_unstable_compile @ %def cmd_unstable_compile @ Command execution. Evaluate the decaying particle and mark the decays in the current model object. <>= procedure :: execute => cmd_unstable_execute <>= subroutine cmd_unstable_execute (cmd, global) class(cmd_unstable_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list logical :: auto_decays, auto_decays_radiative integer :: auto_decays_multiplicity logical :: isotropic_decay, diagonal_decay, polarized_decay integer :: decay_helicity type(pdg_array_t) :: pa_in integer :: pdg_in type(string_t) :: libname_cur, libname_dec type(string_t), dimension(:), allocatable :: auto_id, tmp_id integer :: n_proc_user integer :: i, u_tmp character(80) :: buffer var_list => cmd%local%get_var_list_ptr () auto_decays = & var_list%get_lval (var_str ("?auto_decays")) if (auto_decays) then auto_decays_multiplicity = & var_list%get_ival (var_str ("auto_decays_multiplicity")) auto_decays_radiative = & var_list%get_lval (var_str ("?auto_decays_radiative")) end if isotropic_decay = & var_list%get_lval (var_str ("?isotropic_decay")) if (isotropic_decay) then diagonal_decay = .false. polarized_decay = .false. else diagonal_decay = & var_list%get_lval (var_str ("?diagonal_decay")) if (diagonal_decay) then polarized_decay = .false. else polarized_decay = & var_list%is_known (var_str ("decay_helicity")) if (polarized_decay) then decay_helicity = var_list%get_ival (var_str ("decay_helicity")) end if end if end if pa_in = eval_pdg_array (cmd%pn_prt_in, var_list) if (pdg_array_get_length (pa_in) /= 1) & call msg_fatal ("Unstable: decaying particle must be unique") pdg_in = pdg_array_get (pa_in, 1) n_proc_user = cmd%n_proc if (auto_decays) then call create_auto_decays (pdg_in, & auto_decays_multiplicity, auto_decays_radiative, & libname_dec, auto_id, cmd%local) allocate (tmp_id (cmd%n_proc + size (auto_id))) tmp_id(:cmd%n_proc) = cmd%process_id tmp_id(cmd%n_proc+1:) = auto_id call move_alloc (from = tmp_id, to = cmd%process_id) cmd%n_proc = size (cmd%process_id) end if libname_cur = cmd%local%prclib%get_name () do i = 1, cmd%n_proc if (i == n_proc_user + 1) then call cmd%local%update_prclib & (cmd%local%prclib_stack%get_library_ptr (libname_dec)) end if if (.not. global%process_stack%exists (cmd%process_id(i))) then call var_list%set_log & (var_str ("?decay_rest_frame"), .false., is_known = .true.) call integrate_process (cmd%process_id(i), cmd%local, global) call global%process_stack%fill_result_vars (cmd%process_id(i)) end if end do call cmd%local%update_prclib & (cmd%local%prclib_stack%get_library_ptr (libname_cur)) if (cmd%n_proc > 0) then if (polarized_decay) then call global%modify_particle (pdg_in, stable = .false., & decay = cmd%process_id, & isotropic_decay = .false., & diagonal_decay = .false., & decay_helicity = decay_helicity, & polarized = .false.) else call global%modify_particle (pdg_in, stable = .false., & decay = cmd%process_id, & isotropic_decay = isotropic_decay, & diagonal_decay = diagonal_decay, & polarized = .false.) end if u_tmp = free_unit () open (u_tmp, status = "scratch", action = "readwrite") call show_unstable (global, pdg_in, u_tmp) rewind (u_tmp) do read (u_tmp, "(A)", end = 1) buffer write (msg_buffer, "(A)") trim (buffer) call msg_message () end do 1 continue close (u_tmp) else call err_unstable (global, pdg_in) end if end subroutine cmd_unstable_execute @ %def cmd_unstable_execute @ Show data for the current unstable particle. This is called both by the [[unstable]] and by the [[show]] command. To determine decay branching rations, we look at the decay process IDs and inspect the corresponding [[integral()]] result variables. <>= subroutine show_unstable (global, pdg, u) type(rt_data_t), intent(in), target :: global integer, intent(in) :: pdg, u type(flavor_t) :: flv type(string_t), dimension(:), allocatable :: decay real(default), dimension(:), allocatable :: br real(default) :: width type(process_t), pointer :: process type(process_component_def_t), pointer :: prc_def type(string_t), dimension(:), allocatable :: prt_out, prt_out_str integer :: i, j logical :: opened call flv%init (pdg, global%model) call flv%get_decays (decay) if (.not. allocated (decay)) return allocate (prt_out_str (size (decay))) allocate (br (size (decay))) do i = 1, size (br) process => global%process_stack%get_process_ptr (decay(i)) prc_def => process%get_component_def_ptr (1) call prc_def%get_prt_out (prt_out) prt_out_str(i) = prt_out(1) do j = 2, size (prt_out) prt_out_str(i) = prt_out_str(i) // ", " // prt_out(j) end do br(i) = global%get_rval ("integral(" // decay(i) // ")") end do if (all (br >= 0)) then if (any (br > 0)) then width = sum (br) br = br / sum (br) write (u, "(A)") "Unstable particle " & // char (flv%get_name ()) & // ": computed branching ratios:" do i = 1, size (br) write (u, "(2x,A,':'," // FMT_14 // ",3x,A)") & char (decay(i)), br(i), char (prt_out_str(i)) end do write (u, "(2x,'Total width ='," // FMT_14 // ",' GeV (computed)')") width write (u, "(2x,' ='," // FMT_14 // ",' GeV (preset)')") & flv%get_width () if (flv%decays_isotropically ()) then write (u, "(2x,A)") "Decay options: isotropic" else if (flv%decays_diagonal ()) then write (u, "(2x,A)") "Decay options: & &projection on diagonal helicity states" else if (flv%has_decay_helicity ()) then write (u, "(2x,A,1x,I0)") "Decay options: projection onto helicity =", & flv%get_decay_helicity () else write (u, "(2x,A)") "Decay options: helicity treated exactly" end if else inquire (unit = u, opened = opened) if (opened .and. .not. mask_fatal_errors) close (u) call msg_fatal ("Unstable particle " & // char (flv%get_name ()) & // ": partial width vanishes for all decay channels") end if else inquire (unit = u, opened = opened) if (opened .and. .not. mask_fatal_errors) close (u) call msg_fatal ("Unstable particle " & // char (flv%get_name ()) & // ": partial width is negative") end if end subroutine show_unstable @ %def show_unstable @ If no decays have been found, issue a non-fatal error. <>= subroutine err_unstable (global, pdg) type(rt_data_t), intent(in), target :: global integer, intent(in) :: pdg type(flavor_t) :: flv call flv%init (pdg, global%model) call msg_error ("Unstable: no allowed decays found for particle " & // char (flv%get_name ()) // ", keeping as stable") end subroutine err_unstable @ %def err_unstable @ Auto decays: create process IDs and make up process configurations, using the PDG codes generated by the [[ds_table]] make method. We allocate and use a self-contained process library that contains only the decay processes of the current particle. When done, we revert the global library pointer to the original library but return the name of the new one. The new library becomes part of the global library stack and can thus be referred to at any time. <>= subroutine create_auto_decays & (pdg_in, mult, rad, libname_dec, process_id, global) integer, intent(in) :: pdg_in integer, intent(in) :: mult logical, intent(in) :: rad type(string_t), intent(out) :: libname_dec type(string_t), dimension(:), allocatable, intent(out) :: process_id type(rt_data_t), intent(inout) :: global type(prclib_entry_t), pointer :: lib_entry type(process_library_t), pointer :: lib type(ds_table_t) :: ds_table type(split_constraints_t) :: constraints type(pdg_array_t), dimension(:), allocatable :: pa_out character(80) :: buffer character :: p_or_a type(string_t) :: process_string, libname_cur type(flavor_t) :: flv_in, flv_out type(string_t) :: prt_in type(string_t), dimension(:), allocatable :: prt_out type(process_configuration_t) :: prc_config integer :: i, j, k call flv_in%init (pdg_in, global%model) if (rad) then call constraints%init (2) else call constraints%init (3) call constraints%set (3, constrain_radiation ()) end if call constraints%set (1, constrain_n_tot (mult)) call constraints%set (2, & constrain_mass_sum (flv_in%get_mass (), margin = 0._default)) call ds_table%make (global%model, pdg_in, constraints) prt_in = flv_in%get_name () if (pdg_in > 0) then p_or_a = "p" else p_or_a = "a" end if if (ds_table%get_length () == 0) then call msg_warning ("Auto-decays: Particle " // char (prt_in) // ": " & // "no decays found") libname_dec = "" allocate (process_id (0)) else call msg_message ("Creating decay process library for particle " & // char (prt_in)) libname_cur = global%prclib%get_name () write (buffer, "(A,A,I0)") "_d", p_or_a, abs (pdg_in) libname_dec = libname_cur // trim (buffer) lib => global%prclib_stack%get_library_ptr (libname_dec) if (.not. (associated (lib))) then allocate (lib_entry) call lib_entry%init (libname_dec) lib => lib_entry%process_library_t call global%add_prclib (lib_entry) else call global%update_prclib (lib) end if allocate (process_id (ds_table%get_length ())) do i = 1, size (process_id) write (buffer, "(A,'_',A,I0,'_',I0)") & "decay", p_or_a, abs (pdg_in), i process_id(i) = trim (buffer) process_string = process_id(i) // ": " // prt_in // " =>" call ds_table%get_pdg_out (i, pa_out) allocate (prt_out (size (pa_out))) do j = 1, size (pa_out) do k = 1, pa_out(j)%get_length () call flv_out%init (pa_out(j)%get (k), global%model) if (k == 1) then prt_out(j) = flv_out%get_name () else prt_out(j) = prt_out(j) // ":" // flv_out%get_name () end if end do process_string = process_string // " " // prt_out(j) end do call msg_message (char (process_string)) call prc_config%init (process_id(i), 1, 1, & global%model, global%var_list, & nlo_process = global%nlo_fixed_order) call prc_config%setup_component (1, new_prt_spec ([prt_in]), & new_prt_spec (prt_out), global%model, global%var_list) call prc_config%record (global) deallocate (prt_out) deallocate (pa_out) end do lib => global%prclib_stack%get_library_ptr (libname_cur) call global%update_prclib (lib) end if call ds_table%final () end subroutine create_auto_decays @ %def create_auto_decays @ \subsubsection{(Stable particles} Revert the unstable declaration for a list of particles. <>= type, extends (command_t) :: cmd_stable_t private type(parse_node_p), dimension(:), allocatable :: pn_pdg contains <> end type cmd_stable_t @ %def cmd_stable_t @ Output: we know only the number of particles. <>= procedure :: write => cmd_stable_write <>= subroutine cmd_stable_write (cmd, unit, indent) class(cmd_stable_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A,1x,I0)") "stable:", size (cmd%pn_pdg) end subroutine cmd_stable_write @ %def cmd_stable_write @ Compile. Assign parse nodes for the particle IDs. <>= procedure :: compile => cmd_stable_compile <>= subroutine cmd_stable_compile (cmd, global) class(cmd_stable_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_list, pn_prt integer :: n, i pn_list => parse_node_get_sub_ptr (cmd%pn, 2) cmd%pn_opt => parse_node_get_next_ptr (pn_list) call cmd%compile_options (global) n = parse_node_get_n_sub (pn_list) allocate (cmd%pn_pdg (n)) pn_prt => parse_node_get_sub_ptr (pn_list) i = 1 do while (associated (pn_prt)) cmd%pn_pdg(i)%ptr => pn_prt pn_prt => parse_node_get_next_ptr (pn_prt) i = i + 1 end do end subroutine cmd_stable_compile @ %def cmd_stable_compile @ Execute: apply the modifications to the current model. <>= procedure :: execute => cmd_stable_execute <>= subroutine cmd_stable_execute (cmd, global) class(cmd_stable_t), intent(inout) :: cmd type(rt_data_t), target, intent(inout) :: global type(var_list_t), pointer :: var_list type(pdg_array_t) :: pa integer :: pdg type(flavor_t) :: flv integer :: i var_list => cmd%local%get_var_list_ptr () do i = 1, size (cmd%pn_pdg) pa = eval_pdg_array (cmd%pn_pdg(i)%ptr, var_list) if (pdg_array_get_length (pa) /= 1) & call msg_fatal ("Stable: listed particles must be unique") pdg = pdg_array_get (pa, 1) call global%modify_particle (pdg, stable = .true., & isotropic_decay = .false., & diagonal_decay = .false., & polarized = .false.) call flv%init (pdg, cmd%local%model) call msg_message ("Particle " & // char (flv%get_name ()) & // " declared as stable") end do end subroutine cmd_stable_execute @ %def cmd_stable_execute @ \subsubsection{Polarized particles} These commands mark particles as (un)polarized, to be applied in subsequent simulation passes. Since this is technically the same as the [[stable]] command, we take a shortcut and make this an extension, just overriding methods. <>= type, extends (cmd_stable_t) :: cmd_polarized_t contains <> end type cmd_polarized_t type, extends (cmd_stable_t) :: cmd_unpolarized_t contains <> end type cmd_unpolarized_t @ %def cmd_polarized_t cmd_unpolarized_t @ Output: we know only the number of particles. <>= procedure :: write => cmd_polarized_write <>= procedure :: write => cmd_unpolarized_write <>= subroutine cmd_polarized_write (cmd, unit, indent) class(cmd_polarized_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A,1x,I0)") "polarized:", size (cmd%pn_pdg) end subroutine cmd_polarized_write subroutine cmd_unpolarized_write (cmd, unit, indent) class(cmd_unpolarized_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A,1x,I0)") "unpolarized:", size (cmd%pn_pdg) end subroutine cmd_unpolarized_write @ %def cmd_polarized_write @ %def cmd_unpolarized_write @ Compile: accounted for by the base command. Execute: apply the modifications to the current model. <>= procedure :: execute => cmd_polarized_execute <>= procedure :: execute => cmd_unpolarized_execute <>= subroutine cmd_polarized_execute (cmd, global) class(cmd_polarized_t), intent(inout) :: cmd type(rt_data_t), target, intent(inout) :: global type(var_list_t), pointer :: var_list type(pdg_array_t) :: pa integer :: pdg type(flavor_t) :: flv integer :: i var_list => cmd%local%get_var_list_ptr () do i = 1, size (cmd%pn_pdg) pa = eval_pdg_array (cmd%pn_pdg(i)%ptr, var_list) if (pdg_array_get_length (pa) /= 1) & call msg_fatal ("Polarized: listed particles must be unique") pdg = pdg_array_get (pa, 1) call global%modify_particle (pdg, polarized = .true., & stable = .true., & isotropic_decay = .false., & diagonal_decay = .false.) call flv%init (pdg, cmd%local%model) call msg_message ("Particle " & // char (flv%get_name ()) & // " declared as polarized") end do end subroutine cmd_polarized_execute subroutine cmd_unpolarized_execute (cmd, global) class(cmd_unpolarized_t), intent(inout) :: cmd type(rt_data_t), target, intent(inout) :: global type(var_list_t), pointer :: var_list type(pdg_array_t) :: pa integer :: pdg type(flavor_t) :: flv integer :: i var_list => cmd%local%get_var_list_ptr () do i = 1, size (cmd%pn_pdg) pa = eval_pdg_array (cmd%pn_pdg(i)%ptr, var_list) if (pdg_array_get_length (pa) /= 1) & call msg_fatal ("Unpolarized: listed particles must be unique") pdg = pdg_array_get (pa, 1) call global%modify_particle (pdg, polarized = .false., & stable = .true., & isotropic_decay = .false., & diagonal_decay = .false.) call flv%init (pdg, cmd%local%model) call msg_message ("Particle " & // char (flv%get_name ()) & // " declared as unpolarized") end do end subroutine cmd_unpolarized_execute @ %def cmd_polarized_execute @ %def cmd_unpolarized_execute @ \subsubsection{Parameters: formats for event-sample output} Specify all event formats that are to be used for output files in the subsequent simulation run. (The raw format is on by default and can be turned off here.) <>= type, extends (command_t) :: cmd_sample_format_t private type(string_t), dimension(:), allocatable :: format contains <> end type cmd_sample_format_t @ %def cmd_sample_format_t @ Output: here, everything is known. <>= procedure :: write => cmd_sample_format_write <>= subroutine cmd_sample_format_write (cmd, unit, indent) class(cmd_sample_format_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u, i u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)", advance="no") "sample_format = " do i = 1, size (cmd%format) if (i > 1) write (u, "(A,1x)", advance="no") "," write (u, "(A)", advance="no") char (cmd%format(i)) end do write (u, "(A)") end subroutine cmd_sample_format_write @ %def cmd_sample_format_write @ Compile. Initialize evaluation trees. <>= procedure :: compile => cmd_sample_format_compile <>= subroutine cmd_sample_format_compile (cmd, global) class(cmd_sample_format_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_arg type(parse_node_t), pointer :: pn_format integer :: i, n_format pn_arg => parse_node_get_sub_ptr (cmd%pn, 3) if (associated (pn_arg)) then n_format = parse_node_get_n_sub (pn_arg) allocate (cmd%format (n_format)) pn_format => parse_node_get_sub_ptr (pn_arg) i = 0 do while (associated (pn_format)) i = i + 1 cmd%format(i) = parse_node_get_string (pn_format) pn_format => parse_node_get_next_ptr (pn_format) end do else allocate (cmd%format (0)) end if end subroutine cmd_sample_format_compile @ %def cmd_sample_format_compile @ Execute. Transfer the list of format specifications to the corresponding array in the runtime data set. <>= procedure :: execute => cmd_sample_format_execute <>= subroutine cmd_sample_format_execute (cmd, global) class(cmd_sample_format_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global if (allocated (global%sample_fmt)) deallocate (global%sample_fmt) allocate (global%sample_fmt (size (cmd%format)), source = cmd%format) end subroutine cmd_sample_format_execute @ %def cmd_sample_format_execute @ \subsubsection{The simulate command} This is the actual SINDARIN command. <>= type, extends (command_t) :: cmd_simulate_t ! not private anymore as required by the whizard-c-interface integer :: n_proc = 0 type(string_t), dimension(:), allocatable :: process_id contains <> end type cmd_simulate_t @ %def cmd_simulate_t @ Output: we know the process IDs. <>= procedure :: write => cmd_simulate_write <>= subroutine cmd_simulate_write (cmd, unit, indent) class(cmd_simulate_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u, i u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)", advance="no") "simulate (" do i = 1, cmd%n_proc if (i > 1) write (u, "(A,1x)", advance="no") "," write (u, "(A)", advance="no") char (cmd%process_id(i)) end do write (u, "(A)") ")" end subroutine cmd_simulate_write @ %def cmd_simulate_write @ Compile. In contrast to WHIZARD 1 the confusing option to give the number of unweighted events for weighted events as if unweighting were to take place has been abandoned. (We both use [[n_events]] for weighted and unweighted events, the variable [[n_calls]] from WHIZARD 1 has been discarded. <>= procedure :: compile => cmd_simulate_compile <>= subroutine cmd_simulate_compile (cmd, global) class(cmd_simulate_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_proclist, pn_proc integer :: i pn_proclist => parse_node_get_sub_ptr (cmd%pn, 2) cmd%pn_opt => parse_node_get_next_ptr (pn_proclist) call cmd%compile_options (global) cmd%n_proc = parse_node_get_n_sub (pn_proclist) allocate (cmd%process_id (cmd%n_proc)) pn_proc => parse_node_get_sub_ptr (pn_proclist) do i = 1, cmd%n_proc cmd%process_id(i) = parse_node_get_string (pn_proc) call global%process_stack%init_result_vars (cmd%process_id(i)) pn_proc => parse_node_get_next_ptr (pn_proc) end do end subroutine cmd_simulate_compile @ %def cmd_simulate_compile @ Execute command: Simulate events. This is done via a [[simulation_t]] object and its associated methods. Signal handling: the [[generate]] method may exit abnormally if there is a pending signal. The current logic ensures that the [[es_array]] output channels are closed before the [[execute]] routine returns. The program will terminate then in [[command_list_execute]]. <>= procedure :: execute => cmd_simulate_execute <>= subroutine cmd_simulate_execute (cmd, global) class(cmd_simulate_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list type(rt_data_t), dimension(:), allocatable, target :: alt_env - integer :: n_events, n_fmt - type(string_t) :: sample, sample_suffix - logical :: rebuild_events, read_raw, write_raw + integer :: n_events type(simulation_t), target :: sim - type(string_t), dimension(:), allocatable :: sample_fmt type(event_stream_array_t) :: es_array - type(event_sample_data_t) :: data integer :: i, checkpoint, callback - <> var_list => cmd%local%var_list if (cmd%local%nlo_fixed_order) then call check_nlo_options (cmd%local) end if if (allocated (cmd%local%pn%alt_setup)) then allocate (alt_env (size (cmd%local%pn%alt_setup))) do i = 1, size (alt_env) call build_alt_setup (alt_env(i), cmd%local, & cmd%local%pn%alt_setup(i)%ptr) end do call sim%init (cmd%process_id, .true., .true., cmd%local, global, & alt_env) else call sim%init (cmd%process_id, .true., .true., cmd%local, global) end if if (signal_is_pending ()) return if (sim%is_valid ()) then call sim%init_process_selector () - call openmp_set_num_threads_verbose & - (var_list%get_ival (var_str ("openmp_num_threads")), & - var_list%get_lval (var_str ("?openmp_logging"))) - call sim%compute_n_events (n_events, var_list) - sample_suffix = "" - <> - sample = var_list%get_sval (var_str ("$sample")) - if (sample == "") then - sample = sim%get_default_sample_name () // sample_suffix - else - sample = var_list%get_sval (var_str ("$sample")) // sample_suffix - end if - rebuild_events = & - var_list%get_lval (var_str ("?rebuild_events")) - read_raw = & - var_list%get_lval (var_str ("?read_raw")) & - .and. .not. rebuild_events - write_raw = & - var_list%get_lval (var_str ("?write_raw")) - checkpoint = & - var_list%get_ival (var_str ("checkpoint")) - callback = & - var_list%get_ival (var_str ("event_callback_interval")) - if (read_raw) then - inquire (file = char (sample) // ".evx", exist = read_raw) - end if - if (allocated (cmd%local%sample_fmt)) then - n_fmt = size (cmd%local%sample_fmt) - else - n_fmt = 0 - end if - data = sim%get_data () - data%n_evt = n_events - data%nlo_multiplier = sim%get_n_nlo_entries (1) - if (read_raw) then - allocate (sample_fmt (n_fmt)) - if (n_fmt > 0) sample_fmt = cmd%local%sample_fmt - call es_array%init (sample, & - sample_fmt, cmd%local, & - data = data, & - input = var_str ("raw"), & - allow_switch = write_raw, & - checkpoint = checkpoint, & - callback = callback) - call sim%generate (n_events, es_array) - call es_array%final () - else if (write_raw) then - allocate (sample_fmt (n_fmt + 1)) - if (n_fmt > 0) sample_fmt(:n_fmt) = cmd%local%sample_fmt - sample_fmt(n_fmt+1) = var_str ("raw") - call es_array%init (sample, & - sample_fmt, cmd%local, & - data = data, & - checkpoint = checkpoint, & - callback = callback) - call sim%generate (n_events, es_array) - call es_array%final () - else if (allocated (cmd%local%sample_fmt) & - .or. checkpoint > 0 & - .or. callback > 0) then - allocate (sample_fmt (n_fmt)) - if (n_fmt > 0) sample_fmt = cmd%local%sample_fmt - call es_array%init (sample, & - sample_fmt, cmd%local, & - data = data, & - checkpoint = checkpoint, & - callback = callback) - call sim%generate (n_events, es_array) - call es_array%final () + call sim%setup_openmp () + call sim%compute_n_events (n_events) + call sim%set_n_events_requested (n_events) + call sim%activate_extra_logging () + call sim%prepare_event_streams (es_array) + if (es_array%is_valid ()) then + call sim%generate (es_array) else - call sim%generate (n_events) + call sim%generate () end if + call es_array%final () if (allocated (alt_env)) then do i = 1, size (alt_env) call alt_env(i)%local_final () end do end if end if call sim%final () end subroutine cmd_simulate_execute @ %def cmd_simulate_execute -<>= -@ -<>= -@ -<>= - logical :: mpi_logging - integer :: rank, n_size -@ Append rank id to sample name. -<>= - call mpi_get_comm_id (n_size, rank) - if (n_size > 1) then - sample_suffix = var_str ("_") // str (rank) - end if - mpi_logging = (("vamp2" == char (var_list%get_sval (var_str ("$integration_method"))) & - & .and. (n_size > 1)) & - & .or. var_list%get_lval (var_str ("?mpi_logging"))) - call mpi_set_logging (mpi_logging) -@ @ Build an alternative setup: the parse tree is stored in the global environment. We create a temporary command list to compile and execute this; the result is an alternative local environment [[alt_env]] which we can hand over to the [[simulate]] command. <>= recursive subroutine build_alt_setup (alt_env, global, pn) type(rt_data_t), intent(inout), target :: alt_env type(rt_data_t), intent(inout), target :: global type(parse_node_t), intent(in), target :: pn type(command_list_t), allocatable :: alt_options allocate (alt_options) call alt_env%local_init (global) call alt_env%activate () call alt_options%compile (pn, alt_env) call alt_options%execute (alt_env) call alt_env%deactivate (global, keep_local = .true.) call alt_options%final () end subroutine build_alt_setup @ %def build_alt_setup @ \subsubsection{The rescan command} This is the actual SINDARIN command. <>= type, extends (command_t) :: cmd_rescan_t ! private type(parse_node_t), pointer :: pn_filename => null () integer :: n_proc = 0 type(string_t), dimension(:), allocatable :: process_id contains <> end type cmd_rescan_t @ %def cmd_rescan_t @ Output: we know the process IDs. <>= procedure :: write => cmd_rescan_write <>= subroutine cmd_rescan_write (cmd, unit, indent) class(cmd_rescan_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u, i u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)", advance="no") "rescan (" do i = 1, cmd%n_proc if (i > 1) write (u, "(A,1x)", advance="no") "," write (u, "(A)", advance="no") char (cmd%process_id(i)) end do write (u, "(A)") ")" end subroutine cmd_rescan_write @ %def cmd_rescan_write @ Compile. The command takes a suffix argument, namely the file name of requested event file. <>= procedure :: compile => cmd_rescan_compile <>= subroutine cmd_rescan_compile (cmd, global) class(cmd_rescan_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_filename, pn_proclist, pn_proc integer :: i pn_filename => parse_node_get_sub_ptr (cmd%pn, 2) pn_proclist => parse_node_get_next_ptr (pn_filename) cmd%pn_opt => parse_node_get_next_ptr (pn_proclist) call cmd%compile_options (global) cmd%pn_filename => pn_filename cmd%n_proc = parse_node_get_n_sub (pn_proclist) allocate (cmd%process_id (cmd%n_proc)) pn_proc => parse_node_get_sub_ptr (pn_proclist) do i = 1, cmd%n_proc cmd%process_id(i) = parse_node_get_string (pn_proc) pn_proc => parse_node_get_next_ptr (pn_proc) end do end subroutine cmd_rescan_compile @ %def cmd_rescan_compile @ Execute command: Rescan events. This is done via a [[simulation_t]] object and its associated methods. <>= procedure :: execute => cmd_rescan_execute <>= subroutine cmd_rescan_execute (cmd, global) class(cmd_rescan_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list type(rt_data_t), dimension(:), allocatable, target :: alt_env type(string_t) :: sample, sample_suffix logical :: exist, write_raw, update_event, update_sqme type(simulation_t), target :: sim type(event_sample_data_t) :: input_data, data type(string_t) :: input_sample integer :: n_fmt type(string_t), dimension(:), allocatable :: sample_fmt type(string_t) :: input_format, input_ext, input_file type(string_t) :: lhef_extension, extension_hepmc, extension_lcio type(event_stream_array_t) :: es_array integer :: i, n_events - <> + <> var_list => cmd%local%var_list if (allocated (cmd%local%pn%alt_setup)) then allocate (alt_env (size (cmd%local%pn%alt_setup))) do i = 1, size (alt_env) call build_alt_setup (alt_env(i), cmd%local, & cmd%local%pn%alt_setup(i)%ptr) end do call sim%init (cmd%process_id, .false., .false., cmd%local, global, & alt_env) else call sim%init (cmd%process_id, .false., .false., cmd%local, global) end if - call sim%compute_n_events (n_events, var_list) + call sim%compute_n_events (n_events) input_sample = eval_string (cmd%pn_filename, var_list) input_format = var_list%get_sval (& var_str ("$rescan_input_format")) sample_suffix = "" - <> + <> sample = var_list%get_sval (var_str ("$sample")) if (sample == "") then sample = sim%get_default_sample_name () // sample_suffix else sample = var_list%get_sval (var_str ("$sample")) // sample_suffix end if write_raw = var_list%get_lval (var_str ("?write_raw")) if (allocated (cmd%local%sample_fmt)) then n_fmt = size (cmd%local%sample_fmt) else n_fmt = 0 end if if (write_raw) then if (sample == input_sample) then call msg_error ("Rescan: ?write_raw = true: " & // "suppressing raw event output (filename clashes with input)") allocate (sample_fmt (n_fmt)) if (n_fmt > 0) sample_fmt = cmd%local%sample_fmt else allocate (sample_fmt (n_fmt + 1)) if (n_fmt > 0) sample_fmt(:n_fmt) = cmd%local%sample_fmt sample_fmt(n_fmt+1) = var_str ("raw") end if else allocate (sample_fmt (n_fmt)) if (n_fmt > 0) sample_fmt = cmd%local%sample_fmt end if update_event = & var_list%get_lval (var_str ("?update_event")) update_sqme = & var_list%get_lval (var_str ("?update_sqme")) if (update_event .or. update_sqme) then call msg_message ("Recalculating observables") if (update_sqme) then call msg_message ("Recalculating squared matrix elements") end if end if lhef_extension = & var_list%get_sval (var_str ("$lhef_extension")) extension_hepmc = & var_list%get_sval (var_str ("$extension_hepmc")) extension_lcio = & var_list%get_sval (var_str ("$extension_lcio")) select case (char (input_format)) case ("raw"); input_ext = "evx" call cmd%local%set_log & (var_str ("?recover_beams"), .false., is_known=.true.) case ("lhef"); input_ext = lhef_extension case ("hepmc"); input_ext = extension_hepmc case ("lcio"); input_ext = extension_lcio case default call msg_fatal ("rescan: input sample format '" // char (input_format) & // "' not supported") end select input_file = input_sample // "." // input_ext inquire (file = char (input_file), exist = exist) if (exist) then input_data = sim%get_data (alt = .false.) input_data%n_evt = n_events data = sim%get_data () data%n_evt = n_events input_data%md5sum_cfg = "" call es_array%init (sample, & sample_fmt, cmd%local, data, & input = input_format, input_sample = input_sample, & input_data = input_data, & allow_switch = .false.) call sim%rescan (n_events, es_array, global = cmd%local) call es_array%final () else call msg_fatal ("Rescan: event file '" & // char (input_file) // "' not found") end if if (allocated (alt_env)) then do i = 1, size (alt_env) call alt_env(i)%local_final () end do end if call sim%final () end subroutine cmd_rescan_execute @ %def cmd_rescan_execute -@ -<>= -@ -<>= -@ -<>= +@ MPI: Append rank id to sample name. +<>= +<>= logical :: mpi_logging integer :: rank, n_size -@ Append rank id to sample name. -<>= +<>= +<>= call mpi_get_comm_id (n_size, rank) if (n_size > 1) then sample_suffix = var_str ("_") // str (rank) end if mpi_logging = (("vamp2" == char (var_list%get_sval (var_str ("$integration_method"))) & & .and. (n_size > 1)) & & .or. var_list%get_lval (var_str ("?mpi_logging"))) call mpi_set_logging (mpi_logging) @ \subsubsection{Parameters: number of iterations} Specify number of iterations and number of calls for one integration pass. <>= type, extends (command_t) :: cmd_iterations_t private integer :: n_pass = 0 type(parse_node_p), dimension(:), allocatable :: pn_expr_n_it type(parse_node_p), dimension(:), allocatable :: pn_expr_n_calls type(parse_node_p), dimension(:), allocatable :: pn_sexpr_adapt contains <> end type cmd_iterations_t @ %def cmd_iterations_t @ Output. Display the number of passes, which is known after compilation. <>= procedure :: write => cmd_iterations_write <>= subroutine cmd_iterations_write (cmd, unit, indent) class(cmd_iterations_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) select case (cmd%n_pass) case (0) write (u, "(1x,A)") "iterations: [empty]" case (1) write (u, "(1x,A,I0,A)") "iterations: ", cmd%n_pass, " pass" case default write (u, "(1x,A,I0,A)") "iterations: ", cmd%n_pass, " passes" end select end subroutine cmd_iterations_write @ %def cmd_iterations_write @ Compile. Initialize evaluation trees. <>= procedure :: compile => cmd_iterations_compile <>= subroutine cmd_iterations_compile (cmd, global) class(cmd_iterations_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_arg, pn_n_it, pn_n_calls, pn_adapt type(parse_node_t), pointer :: pn_it_spec, pn_calls_spec, pn_adapt_spec integer :: i pn_arg => parse_node_get_sub_ptr (cmd%pn, 3) if (associated (pn_arg)) then cmd%n_pass = parse_node_get_n_sub (pn_arg) allocate (cmd%pn_expr_n_it (cmd%n_pass)) allocate (cmd%pn_expr_n_calls (cmd%n_pass)) allocate (cmd%pn_sexpr_adapt (cmd%n_pass)) pn_it_spec => parse_node_get_sub_ptr (pn_arg) i = 1 do while (associated (pn_it_spec)) pn_n_it => parse_node_get_sub_ptr (pn_it_spec) pn_calls_spec => parse_node_get_next_ptr (pn_n_it) pn_n_calls => parse_node_get_sub_ptr (pn_calls_spec, 2) pn_adapt_spec => parse_node_get_next_ptr (pn_calls_spec) if (associated (pn_adapt_spec)) then pn_adapt => parse_node_get_sub_ptr (pn_adapt_spec, 2) else pn_adapt => null () end if cmd%pn_expr_n_it(i)%ptr => pn_n_it cmd%pn_expr_n_calls(i)%ptr => pn_n_calls cmd%pn_sexpr_adapt(i)%ptr => pn_adapt i = i + 1 pn_it_spec => parse_node_get_next_ptr (pn_it_spec) end do else allocate (cmd%pn_expr_n_it (0)) allocate (cmd%pn_expr_n_calls (0)) end if end subroutine cmd_iterations_compile @ %def cmd_iterations_compile @ Execute. Evaluate the trees and transfer the results to the iteration list in the runtime data set. <>= procedure :: execute => cmd_iterations_execute <>= subroutine cmd_iterations_execute (cmd, global) class(cmd_iterations_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list integer, dimension(cmd%n_pass) :: n_it, n_calls logical, dimension(cmd%n_pass) :: custom_adapt type(string_t), dimension(cmd%n_pass) :: adapt_code integer :: i var_list => global%get_var_list_ptr () do i = 1, cmd%n_pass n_it(i) = eval_int (cmd%pn_expr_n_it(i)%ptr, var_list) n_calls(i) = & eval_int (cmd%pn_expr_n_calls(i)%ptr, var_list) if (associated (cmd%pn_sexpr_adapt(i)%ptr)) then adapt_code(i) = & eval_string (cmd%pn_sexpr_adapt(i)%ptr, & var_list, is_known = custom_adapt(i)) else custom_adapt(i) = .false. end if end do call global%it_list%init (n_it, n_calls, custom_adapt, adapt_code) end subroutine cmd_iterations_execute @ %def cmd_iterations_execute @ \subsubsection{Range expressions} We need a special type for storing and evaluating range expressions. <>= integer, parameter :: STEP_NONE = 0 integer, parameter :: STEP_ADD = 1 integer, parameter :: STEP_SUB = 2 integer, parameter :: STEP_MUL = 3 integer, parameter :: STEP_DIV = 4 integer, parameter :: STEP_COMP_ADD = 11 integer, parameter :: STEP_COMP_MUL = 13 @ There is an abstract base type and two implementations: scan over integers and scan over reals. <>= type, abstract :: range_t type(parse_node_t), pointer :: pn_expr => null () type(parse_node_t), pointer :: pn_term => null () type(parse_node_t), pointer :: pn_factor => null () type(parse_node_t), pointer :: pn_value => null () type(parse_node_t), pointer :: pn_literal => null () type(parse_node_t), pointer :: pn_beg => null () type(parse_node_t), pointer :: pn_end => null () type(parse_node_t), pointer :: pn_step => null () type(eval_tree_t) :: expr_beg type(eval_tree_t) :: expr_end type(eval_tree_t) :: expr_step integer :: step_mode = 0 integer :: n_step = 0 contains <> end type range_t @ %def range_t @ These are the implementations: <>= type, extends (range_t) :: range_int_t integer :: i_beg = 0 integer :: i_end = 0 integer :: i_step = 0 contains <> end type range_int_t type, extends (range_t) :: range_real_t real(default) :: r_beg = 0 real(default) :: r_end = 0 real(default) :: r_step = 0 real(default) :: lr_beg = 0 real(default) :: lr_end = 0 real(default) :: lr_step = 0 contains <> end type range_real_t @ %def range_int_t range_real_t @ Finalize the allocated dummy node. The other nodes are just pointers. <>= procedure :: final => range_final <>= subroutine range_final (object) class(range_t), intent(inout) :: object if (associated (object%pn_expr)) then call parse_node_final (object%pn_expr, recursive = .false.) call parse_node_final (object%pn_term, recursive = .false.) call parse_node_final (object%pn_factor, recursive = .false.) call parse_node_final (object%pn_value, recursive = .false.) call parse_node_final (object%pn_literal, recursive = .false.) deallocate (object%pn_expr) deallocate (object%pn_term) deallocate (object%pn_factor) deallocate (object%pn_value) deallocate (object%pn_literal) end if end subroutine range_final @ %def range_final @ Output. <>= procedure (range_write), deferred :: write procedure :: base_write => range_write <>= procedure :: write => range_int_write <>= procedure :: write => range_real_write <>= subroutine range_write (object, unit) class(range_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A)") "Range specification:" if (associated (object%pn_expr)) then write (u, "(1x,A)") "Dummy value:" call parse_node_write_rec (object%pn_expr, u) end if if (associated (object%pn_beg)) then write (u, "(1x,A)") "Initial value:" call parse_node_write_rec (object%pn_beg, u) call object%expr_beg%write (u) if (associated (object%pn_end)) then write (u, "(1x,A)") "Final value:" call parse_node_write_rec (object%pn_end, u) call object%expr_end%write (u) if (associated (object%pn_step)) then write (u, "(1x,A)") "Step value:" call parse_node_write_rec (object%pn_step, u) select case (object%step_mode) case (STEP_ADD); write (u, "(1x,A)") "Step mode: +" case (STEP_SUB); write (u, "(1x,A)") "Step mode: -" case (STEP_MUL); write (u, "(1x,A)") "Step mode: *" case (STEP_DIV); write (u, "(1x,A)") "Step mode: /" case (STEP_COMP_ADD); write (u, "(1x,A)") "Division mode: +" case (STEP_COMP_MUL); write (u, "(1x,A)") "Division mode: *" end select end if end if else write (u, "(1x,A)") "Expressions: [undefined]" end if end subroutine range_write subroutine range_int_write (object, unit) class(range_int_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) call object%base_write (unit) write (u, "(1x,A)") "Range parameters:" write (u, "(3x,A,I0)") "i_beg = ", object%i_beg write (u, "(3x,A,I0)") "i_end = ", object%i_end write (u, "(3x,A,I0)") "i_step = ", object%i_step write (u, "(3x,A,I0)") "n_step = ", object%n_step end subroutine range_int_write subroutine range_real_write (object, unit) class(range_real_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) call object%base_write (unit) write (u, "(1x,A)") "Range parameters:" write (u, "(3x,A," // FMT_19 // ")") "r_beg = ", object%r_beg write (u, "(3x,A," // FMT_19 // ")") "r_end = ", object%r_end write (u, "(3x,A," // FMT_19 // ")") "r_step = ", object%r_end write (u, "(3x,A,I0)") "n_step = ", object%n_step end subroutine range_real_write @ %def range_write @ Initialize, given a range expression parse node. This is common to the implementations. <>= procedure :: init => range_init <>= subroutine range_init (range, pn) class(range_t), intent(out) :: range type(parse_node_t), intent(in), target :: pn type(parse_node_t), pointer :: pn_spec, pn_end, pn_step_spec, pn_op select case (char (parse_node_get_rule_key (pn))) case ("expr") case ("range_expr") range%pn_beg => parse_node_get_sub_ptr (pn) pn_spec => parse_node_get_next_ptr (range%pn_beg) if (associated (pn_spec)) then pn_end => parse_node_get_sub_ptr (pn_spec, 2) range%pn_end => pn_end pn_step_spec => parse_node_get_next_ptr (pn_end) if (associated (pn_step_spec)) then pn_op => parse_node_get_sub_ptr (pn_step_spec) range%pn_step => parse_node_get_next_ptr (pn_op) select case (char (parse_node_get_rule_key (pn_op))) case ("/+"); range%step_mode = STEP_ADD case ("/-"); range%step_mode = STEP_SUB case ("/*"); range%step_mode = STEP_MUL case ("//"); range%step_mode = STEP_DIV case ("/+/"); range%step_mode = STEP_COMP_ADD case ("/*/"); range%step_mode = STEP_COMP_MUL case default call range%write () call msg_bug ("Range: step mode not implemented") end select else range%step_mode = STEP_ADD end if else range%step_mode = STEP_NONE end if call range%create_value_node () case default call msg_bug ("range expression: node type '" & // char (parse_node_get_rule_key (pn)) & // "' not implemented") end select end subroutine range_init @ %def range_init @ This method manually creates a parse node (actually, a cascade of parse nodes) that hold a constant value as a literal. The idea is that this node is inserted as the right-hand side of a fake variable assignment, which is prepended to each scan iteration. Before the variable assignment is compiled and executed, we can manually reset the value of the literal and thus pretend that the loop variable is assigned this value. <>= procedure :: create_value_node => range_create_value_node <>= subroutine range_create_value_node (range) class(range_t), intent(inout) :: range allocate (range%pn_literal) allocate (range%pn_value) select type (range) type is (range_int_t) call parse_node_create_value (range%pn_literal, & syntax_get_rule_ptr (syntax_cmd_list, var_str ("integer_literal")),& ival = 0) call parse_node_create_branch (range%pn_value, & syntax_get_rule_ptr (syntax_cmd_list, var_str ("integer_value"))) type is (range_real_t) call parse_node_create_value (range%pn_literal, & syntax_get_rule_ptr (syntax_cmd_list, var_str ("real_literal")),& rval = 0._default) call parse_node_create_branch (range%pn_value, & syntax_get_rule_ptr (syntax_cmd_list, var_str ("real_value"))) class default call msg_bug ("range: create value node: type not implemented") end select call parse_node_append_sub (range%pn_value, range%pn_literal) call parse_node_freeze_branch (range%pn_value) allocate (range%pn_factor) call parse_node_create_branch (range%pn_factor, & syntax_get_rule_ptr (syntax_cmd_list, var_str ("factor"))) call parse_node_append_sub (range%pn_factor, range%pn_value) call parse_node_freeze_branch (range%pn_factor) allocate (range%pn_term) call parse_node_create_branch (range%pn_term, & syntax_get_rule_ptr (syntax_cmd_list, var_str ("term"))) call parse_node_append_sub (range%pn_term, range%pn_factor) call parse_node_freeze_branch (range%pn_term) allocate (range%pn_expr) call parse_node_create_branch (range%pn_expr, & syntax_get_rule_ptr (syntax_cmd_list, var_str ("expr"))) call parse_node_append_sub (range%pn_expr, range%pn_term) call parse_node_freeze_branch (range%pn_expr) end subroutine range_create_value_node @ %def range_create_value_node @ Compile, given an environment. <>= procedure :: compile => range_compile <>= subroutine range_compile (range, global) class(range_t), intent(inout) :: range type(rt_data_t), intent(in), target :: global type(var_list_t), pointer :: var_list var_list => global%get_var_list_ptr () if (associated (range%pn_beg)) then call range%expr_beg%init_expr (range%pn_beg, var_list) if (associated (range%pn_end)) then call range%expr_end%init_expr (range%pn_end, var_list) if (associated (range%pn_step)) then call range%expr_step%init_expr (range%pn_step, var_list) end if end if end if end subroutine range_compile @ %def range_compile @ Evaluate: compute the actual bounds and parameters that determine the values that we can iterate. This is implementation-specific. <>= procedure (range_evaluate), deferred :: evaluate <>= abstract interface subroutine range_evaluate (range) import class(range_t), intent(inout) :: range end subroutine range_evaluate end interface @ %def range_evaluate @ The version for an integer variable. If the step is subtractive, we invert the sign and treat it as an additive step. For a multiplicative step, the step must be greater than one, and the initial and final values must be of same sign and strictly ordered. Analogously for a division step. <>= procedure :: evaluate => range_int_evaluate <>= subroutine range_int_evaluate (range) class(range_int_t), intent(inout) :: range integer :: ival if (associated (range%pn_beg)) then call range%expr_beg%evaluate () if (range%expr_beg%is_known ()) then range%i_beg = range%expr_beg%get_int () else call range%write () call msg_fatal & ("Range expression: initial value evaluates to unknown") end if if (associated (range%pn_end)) then call range%expr_end%evaluate () if (range%expr_end%is_known ()) then range%i_end = range%expr_end%get_int () if (associated (range%pn_step)) then call range%expr_step%evaluate () if (range%expr_step%is_known ()) then range%i_step = range%expr_step%get_int () select case (range%step_mode) case (STEP_SUB); range%i_step = - range%i_step end select else call range%write () call msg_fatal & ("Range expression: step value evaluates to unknown") end if else range%i_step = 1 end if else call range%write () call msg_fatal & ("Range expression: final value evaluates to unknown") end if else range%i_end = range%i_beg range%i_step = 1 end if select case (range%step_mode) case (STEP_NONE) range%n_step = 1 case (STEP_ADD, STEP_SUB) if (range%i_step /= 0) then if (range%i_beg == range%i_end) then range%n_step = 1 else if (sign (1, range%i_end - range%i_beg) & == sign (1, range%i_step)) then range%n_step = (range%i_end - range%i_beg) / range%i_step + 1 else range%n_step = 0 end if else call msg_fatal ("range evaluation (add): step value is zero") end if case (STEP_MUL) if (range%i_step > 1) then if (range%i_beg == range%i_end) then range%n_step = 1 else if (range%i_beg == 0) then call msg_fatal ("range evaluation (mul): initial value is zero") else if (sign (1, range%i_beg) == sign (1, range%i_end) & .and. abs (range%i_beg) < abs (range%i_end)) then range%n_step = 0 ival = range%i_beg do while (abs (ival) <= abs (range%i_end)) range%n_step = range%n_step + 1 ival = ival * range%i_step end do else range%n_step = 0 end if else call msg_fatal & ("range evaluation (mult): step value is one or less") end if case (STEP_DIV) if (range%i_step > 1) then if (range%i_beg == range%i_end) then range%n_step = 1 else if (sign (1, range%i_beg) == sign (1, range%i_end) & .and. abs (range%i_beg) > abs (range%i_end)) then range%n_step = 0 ival = range%i_beg do while (abs (ival) >= abs (range%i_end)) range%n_step = range%n_step + 1 if (ival == 0) exit ival = ival / range%i_step end do else range%n_step = 0 end if else call msg_fatal & ("range evaluation (div): step value is one or less") end if case (STEP_COMP_ADD) call msg_fatal ("range evaluation: & &step mode /+/ not allowed for integer variable") case (STEP_COMP_MUL) call msg_fatal ("range evaluation: & &step mode /*/ not allowed for integer variable") case default call range%write () call msg_bug ("range evaluation: step mode not implemented") end select end if end subroutine range_int_evaluate @ %def range_int_evaluate @ The version for a real variable. <>= procedure :: evaluate => range_real_evaluate <>= subroutine range_real_evaluate (range) class(range_real_t), intent(inout) :: range if (associated (range%pn_beg)) then call range%expr_beg%evaluate () if (range%expr_beg%is_known ()) then range%r_beg = range%expr_beg%get_real () else call range%write () call msg_fatal & ("Range expression: initial value evaluates to unknown") end if if (associated (range%pn_end)) then call range%expr_end%evaluate () if (range%expr_end%is_known ()) then range%r_end = range%expr_end%get_real () if (associated (range%pn_step)) then if (range%expr_step%is_known ()) then select case (range%step_mode) case (STEP_ADD, STEP_SUB, STEP_MUL, STEP_DIV) call range%expr_step%evaluate () range%r_step = range%expr_step%get_real () select case (range%step_mode) case (STEP_SUB); range%r_step = - range%r_step end select case (STEP_COMP_ADD, STEP_COMP_MUL) range%n_step = & max (range%expr_step%get_int (), 0) end select else call range%write () call msg_fatal & ("Range expression: step value evaluates to unknown") end if else call range%write () call msg_fatal & ("Range expression (real): step value must be provided") end if else call range%write () call msg_fatal & ("Range expression: final value evaluates to unknown") end if else range%r_end = range%r_beg range%r_step = 1 end if select case (range%step_mode) case (STEP_NONE) range%n_step = 1 case (STEP_ADD, STEP_SUB) if (range%r_step /= 0) then if (sign (1._default, range%r_end - range%r_beg) & == sign (1._default, range%r_step)) then range%n_step = & nint ((range%r_end - range%r_beg) / range%r_step + 1) else range%n_step = 0 end if else call msg_fatal ("range evaluation (add): step value is zero") end if case (STEP_MUL) if (range%r_step > 1) then if (range%r_beg == 0 .or. range%r_end == 0) then call msg_fatal ("range evaluation (mul): bound is zero") else if (sign (1._default, range%r_beg) & == sign (1._default, range%r_end) & .and. abs (range%r_beg) <= abs (range%r_end)) then range%lr_beg = log (abs (range%r_beg)) range%lr_end = log (abs (range%r_end)) range%lr_step = log (range%r_step) range%n_step = nint & (abs ((range%lr_end - range%lr_beg) / range%lr_step) + 1) else range%n_step = 0 end if else call msg_fatal & ("range evaluation (mult): step value is one or less") end if case (STEP_DIV) if (range%r_step > 1) then if (range%r_beg == 0 .or. range%r_end == 0) then call msg_fatal ("range evaluation (div): bound is zero") else if (sign (1._default, range%r_beg) & == sign (1._default, range%r_end) & .and. abs (range%r_beg) >= abs (range%r_end)) then range%lr_beg = log (abs (range%r_beg)) range%lr_end = log (abs (range%r_end)) range%lr_step = -log (range%r_step) range%n_step = nint & (abs ((range%lr_end - range%lr_beg) / range%lr_step) + 1) else range%n_step = 0 end if else call msg_fatal & ("range evaluation (mult): step value is one or less") end if case (STEP_COMP_ADD) ! Number of steps already known case (STEP_COMP_MUL) ! Number of steps already known if (range%r_beg == 0 .or. range%r_end == 0) then call msg_fatal ("range evaluation (mul): bound is zero") else if (sign (1._default, range%r_beg) & == sign (1._default, range%r_end)) then range%lr_beg = log (abs (range%r_beg)) range%lr_end = log (abs (range%r_end)) else range%n_step = 0 end if case default call range%write () call msg_bug ("range evaluation: step mode not implemented") end select end if end subroutine range_real_evaluate @ %def range_real_evaluate @ Return the number of iterations: <>= procedure :: get_n_iterations => range_get_n_iterations <>= function range_get_n_iterations (range) result (n) class(range_t), intent(in) :: range integer :: n n = range%n_step end function range_get_n_iterations @ %def range_get_n_iterations @ Compute the value for iteration [[i]] and store it in the embedded token. <>= procedure (range_set_value), deferred :: set_value <>= abstract interface subroutine range_set_value (range, i) import class(range_t), intent(inout) :: range integer, intent(in) :: i end subroutine range_set_value end interface @ %def range_set_value @ In the integer case, we compute the value directly for additive step. For multiplicative step, we perform a loop in the same way as above, where the number of iteration was determined. <>= procedure :: set_value => range_int_set_value <>= subroutine range_int_set_value (range, i) class(range_int_t), intent(inout) :: range integer, intent(in) :: i integer :: k, ival select case (range%step_mode) case (STEP_NONE) ival = range%i_beg case (STEP_ADD, STEP_SUB) ival = range%i_beg + (i - 1) * range%i_step case (STEP_MUL) ival = range%i_beg do k = 1, i - 1 ival = ival * range%i_step end do case (STEP_DIV) ival = range%i_beg do k = 1, i - 1 ival = ival / range%i_step end do case default call range%write () call msg_bug ("range iteration: step mode not implemented") end select call parse_node_set_value (range%pn_literal, ival = ival) end subroutine range_int_set_value @ %def range_int_set_value @ In the integer case, we compute the value directly for additive step. For multiplicative step, we perform a loop in the same way as above, where the number of iteration was determined. <>= procedure :: set_value => range_real_set_value <>= subroutine range_real_set_value (range, i) class(range_real_t), intent(inout) :: range integer, intent(in) :: i real(default) :: rval, x select case (range%step_mode) case (STEP_NONE) rval = range%r_beg case (STEP_ADD, STEP_SUB, STEP_COMP_ADD) if (range%n_step > 1) then x = real (i - 1, default) / (range%n_step - 1) else x = 1._default / 2 end if rval = x * range%r_end + (1 - x) * range%r_beg case (STEP_MUL, STEP_DIV, STEP_COMP_MUL) if (range%n_step > 1) then x = real (i - 1, default) / (range%n_step - 1) else x = 1._default / 2 end if rval = sign & (exp (x * range%lr_end + (1 - x) * range%lr_beg), range%r_beg) case default call range%write () call msg_bug ("range iteration: step mode not implemented") end select call parse_node_set_value (range%pn_literal, rval = rval) end subroutine range_real_set_value @ %def range_real_set_value @ \subsubsection{Scan over parameters and other objects} The scan command allocates a new parse node for the variable assignment (the lhs). The rhs of this parse node is assigned from the available rhs expressions in the scan list, one at a time, so the compiled parse node can be prepended to the scan body. <>= type, extends (command_t) :: cmd_scan_t private type(string_t) :: name integer :: n_values = 0 type(parse_node_p), dimension(:), allocatable :: scan_cmd class(range_t), dimension(:), allocatable :: range contains <> end type cmd_scan_t @ %def cmd_scan_t @ Finalizer. The auxiliary parse nodes that we have constructed have to be treated carefully: the embedded pointers all point to persistent objects somewhere else and should not be finalized, so we should not call the finalizer recursively. <>= procedure :: final => cmd_scan_final <>= recursive subroutine cmd_scan_final (cmd) class(cmd_scan_t), intent(inout) :: cmd type(parse_node_t), pointer :: pn_var_single, pn_decl_single type(string_t) :: key integer :: i if (allocated (cmd%scan_cmd)) then do i = 1, size (cmd%scan_cmd) pn_var_single => parse_node_get_sub_ptr (cmd%scan_cmd(i)%ptr) key = parse_node_get_rule_key (pn_var_single) select case (char (key)) case ("scan_string_decl", "scan_log_decl") pn_decl_single => parse_node_get_sub_ptr (pn_var_single, 2) call parse_node_final (pn_decl_single, recursive=.false.) deallocate (pn_decl_single) end select call parse_node_final (pn_var_single, recursive=.false.) deallocate (pn_var_single) end do deallocate (cmd%scan_cmd) end if if (allocated (cmd%range)) then do i = 1, size (cmd%range) call cmd%range(i)%final () end do end if end subroutine cmd_scan_final @ %def cmd_scan_final @ Output. <>= procedure :: write => cmd_scan_write <>= subroutine cmd_scan_write (cmd, unit, indent) class(cmd_scan_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A,1x,A,1x,'(',I0,')')") "scan:", char (cmd%name), & cmd%n_values end subroutine cmd_scan_write @ %def cmd_scan_write @ Compile the scan command. We construct a new parse node that implements the variable assignment for a single element on the rhs, instead of the whole list that we get from the original parse tree. By simply copying the node, we copy all pointers and inherit the targets from the original. During execution, we should replace the rhs by the stored rhs pointers (the list elements), one by one, then (re)compile the redefined node. <>= procedure :: compile => cmd_scan_compile <>= recursive subroutine cmd_scan_compile (cmd, global) class(cmd_scan_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list type(parse_node_t), pointer :: pn_var, pn_body, pn_body_first type(parse_node_t), pointer :: pn_decl, pn_name type(parse_node_t), pointer :: pn_arg, pn_scan_cmd, pn_rhs type(parse_node_t), pointer :: pn_decl_single, pn_var_single type(syntax_rule_t), pointer :: var_rule_decl, var_rule type(string_t) :: key integer :: var_type integer :: i if (debug_on) call msg_debug (D_CORE, "cmd_scan_compile") if (debug_active (D_CORE)) call parse_node_write_rec (cmd%pn) pn_var => parse_node_get_sub_ptr (cmd%pn, 2) pn_body => parse_node_get_next_ptr (pn_var) if (associated (pn_body)) then pn_body_first => parse_node_get_sub_ptr (pn_body) else pn_body_first => null () end if key = parse_node_get_rule_key (pn_var) select case (char (key)) case ("scan_num") pn_name => parse_node_get_sub_ptr (pn_var) cmd%name = parse_node_get_string (pn_name) var_rule => syntax_get_rule_ptr (syntax_cmd_list, var_str ("cmd_num")) pn_arg => parse_node_get_next_ptr (pn_name, 2) case ("scan_int") pn_name => parse_node_get_sub_ptr (pn_var, 2) cmd%name = parse_node_get_string (pn_name) var_rule => syntax_get_rule_ptr (syntax_cmd_list, var_str ("cmd_int")) pn_arg => parse_node_get_next_ptr (pn_name, 2) case ("scan_real") pn_name => parse_node_get_sub_ptr (pn_var, 2) cmd%name = parse_node_get_string (pn_name) var_rule => syntax_get_rule_ptr (syntax_cmd_list, var_str ("cmd_real")) pn_arg => parse_node_get_next_ptr (pn_name, 2) case ("scan_complex") pn_name => parse_node_get_sub_ptr (pn_var, 2) cmd%name = parse_node_get_string (pn_name) var_rule => syntax_get_rule_ptr (syntax_cmd_list, var_str("cmd_complex")) pn_arg => parse_node_get_next_ptr (pn_name, 2) case ("scan_alias") pn_name => parse_node_get_sub_ptr (pn_var, 2) cmd%name = parse_node_get_string (pn_name) var_rule => syntax_get_rule_ptr (syntax_cmd_list, var_str ("cmd_alias")) pn_arg => parse_node_get_next_ptr (pn_name, 2) case ("scan_string_decl") pn_decl => parse_node_get_sub_ptr (pn_var, 2) pn_name => parse_node_get_sub_ptr (pn_decl, 2) cmd%name = parse_node_get_string (pn_name) var_rule_decl => syntax_get_rule_ptr (syntax_cmd_list, & var_str ("cmd_string")) var_rule => syntax_get_rule_ptr (syntax_cmd_list, & var_str ("cmd_string_decl")) pn_arg => parse_node_get_next_ptr (pn_name, 2) case ("scan_log_decl") pn_decl => parse_node_get_sub_ptr (pn_var, 2) pn_name => parse_node_get_sub_ptr (pn_decl, 2) cmd%name = parse_node_get_string (pn_name) var_rule_decl => syntax_get_rule_ptr (syntax_cmd_list, & var_str ("cmd_log")) var_rule => syntax_get_rule_ptr (syntax_cmd_list, & var_str ("cmd_log_decl")) pn_arg => parse_node_get_next_ptr (pn_name, 2) case ("scan_cuts") var_rule => syntax_get_rule_ptr (syntax_cmd_list, & var_str ("cmd_cuts")) cmd%name = "cuts" pn_arg => parse_node_get_sub_ptr (pn_var, 3) case ("scan_weight") var_rule => syntax_get_rule_ptr (syntax_cmd_list, & var_str ("cmd_weight")) cmd%name = "weight" pn_arg => parse_node_get_sub_ptr (pn_var, 3) case ("scan_scale") var_rule => syntax_get_rule_ptr (syntax_cmd_list, & var_str ("cmd_scale")) cmd%name = "scale" pn_arg => parse_node_get_sub_ptr (pn_var, 3) case ("scan_ren_scale") var_rule => syntax_get_rule_ptr (syntax_cmd_list, & var_str ("cmd_ren_scale")) cmd%name = "renormalization_scale" pn_arg => parse_node_get_sub_ptr (pn_var, 3) case ("scan_fac_scale") var_rule => syntax_get_rule_ptr (syntax_cmd_list, & var_str ("cmd_fac_scale")) cmd%name = "factorization_scale" pn_arg => parse_node_get_sub_ptr (pn_var, 3) case ("scan_selection") var_rule => syntax_get_rule_ptr (syntax_cmd_list, & var_str ("cmd_selection")) cmd%name = "selection" pn_arg => parse_node_get_sub_ptr (pn_var, 3) case ("scan_reweight") var_rule => syntax_get_rule_ptr (syntax_cmd_list, & var_str ("cmd_reweight")) cmd%name = "reweight" pn_arg => parse_node_get_sub_ptr (pn_var, 3) case ("scan_analysis") var_rule => syntax_get_rule_ptr (syntax_cmd_list, & var_str ("cmd_analysis")) cmd%name = "analysis" pn_arg => parse_node_get_sub_ptr (pn_var, 3) case ("scan_model") var_rule => syntax_get_rule_ptr (syntax_cmd_list, & var_str ("cmd_model")) cmd%name = "model" pn_arg => parse_node_get_sub_ptr (pn_var, 3) case ("scan_library") var_rule => syntax_get_rule_ptr (syntax_cmd_list, & var_str ("cmd_library")) cmd%name = "library" pn_arg => parse_node_get_sub_ptr (pn_var, 3) case default call msg_bug ("scan: case '" // char (key) // "' not implemented") end select if (associated (pn_arg)) then cmd%n_values = parse_node_get_n_sub (pn_arg) end if var_list => global%get_var_list_ptr () allocate (cmd%scan_cmd (cmd%n_values)) select case (char (key)) case ("scan_num") var_type = & var_list%get_type (cmd%name) select case (var_type) case (V_INT) allocate (range_int_t :: cmd%range (cmd%n_values)) case (V_REAL) allocate (range_real_t :: cmd%range (cmd%n_values)) case (V_CMPLX) call msg_fatal ("scan over complex variable not implemented") case (V_NONE) call msg_fatal ("scan: variable '" // char (cmd%name) //"' undefined") case default call msg_bug ("scan: impossible variable type") end select case ("scan_int") allocate (range_int_t :: cmd%range (cmd%n_values)) case ("scan_real") allocate (range_real_t :: cmd%range (cmd%n_values)) case ("scan_complex") call msg_fatal ("scan over complex variable not implemented") end select i = 1 if (associated (pn_arg)) then pn_rhs => parse_node_get_sub_ptr (pn_arg) else pn_rhs => null () end if do while (associated (pn_rhs)) allocate (pn_scan_cmd) call parse_node_create_branch (pn_scan_cmd, & syntax_get_rule_ptr (syntax_cmd_list, var_str ("command_list"))) allocate (pn_var_single) pn_var_single = pn_var call parse_node_replace_rule (pn_var_single, var_rule) select case (char (key)) case ("scan_num", "scan_int", "scan_real", & "scan_complex", "scan_alias", & "scan_cuts", "scan_weight", & "scan_scale", "scan_ren_scale", "scan_fac_scale", & "scan_selection", "scan_reweight", "scan_analysis", & "scan_model", "scan_library") if (allocated (cmd%range)) then call cmd%range(i)%init (pn_rhs) call parse_node_replace_last_sub & (pn_var_single, cmd%range(i)%pn_expr) else call parse_node_replace_last_sub (pn_var_single, pn_rhs) end if case ("scan_string_decl", "scan_log_decl") allocate (pn_decl_single) pn_decl_single = pn_decl call parse_node_replace_rule (pn_decl_single, var_rule_decl) call parse_node_replace_last_sub (pn_decl_single, pn_rhs) call parse_node_freeze_branch (pn_decl_single) call parse_node_replace_last_sub (pn_var_single, pn_decl_single) case default call msg_bug ("scan: case '" // char (key) & // "' broken") end select call parse_node_freeze_branch (pn_var_single) call parse_node_append_sub (pn_scan_cmd, pn_var_single) call parse_node_append_sub (pn_scan_cmd, pn_body_first) call parse_node_freeze_branch (pn_scan_cmd) cmd%scan_cmd(i)%ptr => pn_scan_cmd i = i + 1 pn_rhs => parse_node_get_next_ptr (pn_rhs) end do if (debug_active (D_CORE)) then do i = 1, cmd%n_values print *, "scan command ", i call parse_node_write_rec (cmd%scan_cmd(i)%ptr) if (allocated (cmd%range)) call cmd%range(i)%write () end do print *, "original" call parse_node_write_rec (cmd%pn) end if end subroutine cmd_scan_compile @ %def cmd_scan_compile @ Execute the loop for all values in the step list. We use the parse trees with single variable assignment that we have stored, to iteratively create a local environment, execute the stored commands, and destroy it again. When we encounter a range object, we execute the commands for each value that this object provides. Computing this value has the side effect of modifying the rhs of the variable assignment that heads the local command list, directly in the local parse tree. <>= procedure :: execute => cmd_scan_execute <>= recursive subroutine cmd_scan_execute (cmd, global) class(cmd_scan_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(rt_data_t), allocatable :: local integer :: i, j do i = 1, cmd%n_values if (allocated (cmd%range)) then call cmd%range(i)%compile (global) call cmd%range(i)%evaluate () do j = 1, cmd%range(i)%get_n_iterations () call cmd%range(i)%set_value (j) allocate (local) call build_alt_setup (local, global, cmd%scan_cmd(i)%ptr) call local%local_final () deallocate (local) end do else allocate (local) call build_alt_setup (local, global, cmd%scan_cmd(i)%ptr) call local%local_final () deallocate (local) end if end do end subroutine cmd_scan_execute @ %def cmd_scan_execute @ \subsubsection{Conditionals} Conditionals are implemented as a list that is compiled and evaluated recursively; this allows for a straightforward representation of [[else if]] constructs. A [[cmd_if_t]] object can hold either an [[else_if]] clause which is another object of this type, or an [[else_body]], but not both. If- or else-bodies are no scoping units, so all data remain global and no copy-in copy-out is needed. <>= type, extends (command_t) :: cmd_if_t private type(parse_node_t), pointer :: pn_if_lexpr => null () type(command_list_t), pointer :: if_body => null () type(cmd_if_t), dimension(:), pointer :: elsif_cmd => null () type(command_list_t), pointer :: else_body => null () contains <> end type cmd_if_t @ %def cmd_if_t @ Finalizer. There are no local options, therefore we can simply override the default finalizer. <>= procedure :: final => cmd_if_final <>= recursive subroutine cmd_if_final (cmd) class(cmd_if_t), intent(inout) :: cmd integer :: i if (associated (cmd%if_body)) then call command_list_final (cmd%if_body) deallocate (cmd%if_body) end if if (associated (cmd%elsif_cmd)) then do i = 1, size (cmd%elsif_cmd) call cmd_if_final (cmd%elsif_cmd(i)) end do deallocate (cmd%elsif_cmd) end if if (associated (cmd%else_body)) then call command_list_final (cmd%else_body) deallocate (cmd%else_body) end if end subroutine cmd_if_final @ %def cmd_if_final @ Output. Recursively write the command lists. <>= procedure :: write => cmd_if_write <>= subroutine cmd_if_write (cmd, unit, indent) class(cmd_if_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u, ind, i u = given_output_unit (unit); if (u < 0) return ind = 0; if (present (indent)) ind = indent call write_indent (u, indent) write (u, "(A)") "if then" if (associated (cmd%if_body)) then call cmd%if_body%write (unit, ind + 1) end if if (associated (cmd%elsif_cmd)) then do i = 1, size (cmd%elsif_cmd) call write_indent (u, indent) write (u, "(A)") "elsif then" if (associated (cmd%elsif_cmd(i)%if_body)) then call cmd%elsif_cmd(i)%if_body%write (unit, ind + 1) end if end do end if if (associated (cmd%else_body)) then call write_indent (u, indent) write (u, "(A)") "else" call cmd%else_body%write (unit, ind + 1) end if end subroutine cmd_if_write @ %def cmd_if_write @ Compile the conditional. <>= procedure :: compile => cmd_if_compile <>= recursive subroutine cmd_if_compile (cmd, global) class(cmd_if_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_lexpr, pn_body type(parse_node_t), pointer :: pn_elsif_clauses, pn_cmd_elsif type(parse_node_t), pointer :: pn_else_clause, pn_cmd_else integer :: i, n_elsif pn_lexpr => parse_node_get_sub_ptr (cmd%pn, 2) cmd%pn_if_lexpr => pn_lexpr pn_body => parse_node_get_next_ptr (pn_lexpr, 2) select case (char (parse_node_get_rule_key (pn_body))) case ("command_list") allocate (cmd%if_body) call cmd%if_body%compile (pn_body, global) pn_elsif_clauses => parse_node_get_next_ptr (pn_body) case default pn_elsif_clauses => pn_body end select select case (char (parse_node_get_rule_key (pn_elsif_clauses))) case ("elsif_clauses") n_elsif = parse_node_get_n_sub (pn_elsif_clauses) allocate (cmd%elsif_cmd (n_elsif)) pn_cmd_elsif => parse_node_get_sub_ptr (pn_elsif_clauses) do i = 1, n_elsif pn_lexpr => parse_node_get_sub_ptr (pn_cmd_elsif, 2) cmd%elsif_cmd(i)%pn_if_lexpr => pn_lexpr pn_body => parse_node_get_next_ptr (pn_lexpr, 2) if (associated (pn_body)) then allocate (cmd%elsif_cmd(i)%if_body) call cmd%elsif_cmd(i)%if_body%compile (pn_body, global) end if pn_cmd_elsif => parse_node_get_next_ptr (pn_cmd_elsif) end do pn_else_clause => parse_node_get_next_ptr (pn_elsif_clauses) case default pn_else_clause => pn_elsif_clauses end select select case (char (parse_node_get_rule_key (pn_else_clause))) case ("else_clause") pn_cmd_else => parse_node_get_sub_ptr (pn_else_clause) pn_body => parse_node_get_sub_ptr (pn_cmd_else, 2) if (associated (pn_body)) then allocate (cmd%else_body) call cmd%else_body%compile (pn_body, global) end if end select end subroutine cmd_if_compile @ %def global @ (Recursively) execute the condition. Context remains global in all cases. <>= procedure :: execute => cmd_if_execute <>= recursive subroutine cmd_if_execute (cmd, global) class(cmd_if_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list logical :: lval, is_known integer :: i var_list => global%get_var_list_ptr () lval = eval_log (cmd%pn_if_lexpr, var_list, is_known=is_known) if (is_known) then if (lval) then if (associated (cmd%if_body)) then call cmd%if_body%execute (global) end if return end if else call error_undecided () return end if if (associated (cmd%elsif_cmd)) then SCAN_ELSIF: do i = 1, size (cmd%elsif_cmd) lval = eval_log (cmd%elsif_cmd(i)%pn_if_lexpr, var_list, & is_known=is_known) if (is_known) then if (lval) then if (associated (cmd%elsif_cmd(i)%if_body)) then call cmd%elsif_cmd(i)%if_body%execute (global) end if return end if else call error_undecided () return end if end do SCAN_ELSIF end if if (associated (cmd%else_body)) then call cmd%else_body%execute (global) end if contains subroutine error_undecided () call msg_error ("Undefined result of cmditional expression: " & // "neither branch will be executed") end subroutine error_undecided end subroutine cmd_if_execute @ %def cmd_if_execute @ \subsubsection{Include another command-list file} The include command allocates a local parse tree. This must not be deleted before the command object itself is deleted, since pointers may point to subobjects of it. <>= type, extends (command_t) :: cmd_include_t private type(string_t) :: file type(command_list_t), pointer :: command_list => null () type(parse_tree_t) :: parse_tree contains <> end type cmd_include_t @ %def cmd_include_t @ Finalizer: delete the command list. No options, so we can simply override the default finalizer. <>= procedure :: final => cmd_include_final <>= subroutine cmd_include_final (cmd) class(cmd_include_t), intent(inout) :: cmd call parse_tree_final (cmd%parse_tree) if (associated (cmd%command_list)) then call cmd%command_list%final () deallocate (cmd%command_list) end if end subroutine cmd_include_final @ %def cmd_include_final @ Write: display the command list as-is, if allocated. <>= procedure :: write => cmd_include_write <>= subroutine cmd_include_write (cmd, unit, indent) class(cmd_include_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u, ind u = given_output_unit (unit) ind = 0; if (present (indent)) ind = indent call write_indent (u, indent) write (u, "(A,A,A,A)") "include ", '"', char (cmd%file), '"' if (associated (cmd%command_list)) then call cmd%command_list%write (u, ind + 1) end if end subroutine cmd_include_write @ %def cmd_include_write @ Compile file contents: First parse the file, then immediately compile its contents. Use the global data set. <>= procedure :: compile => cmd_include_compile <>= subroutine cmd_include_compile (cmd, global) class(cmd_include_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_arg, pn_file type(string_t) :: file logical :: exist integer :: u type(stream_t), target :: stream type(lexer_t) :: lexer pn_arg => parse_node_get_sub_ptr (cmd%pn, 2) pn_file => parse_node_get_sub_ptr (pn_arg) file = parse_node_get_string (pn_file) inquire (file=char(file), exist=exist) if (exist) then cmd%file = file else cmd%file = global%os_data%whizard_cutspath // "/" // file inquire (file=char(cmd%file), exist=exist) if (.not. exist) then call msg_error ("Include file '" // char (file) // "' not found") return end if end if u = free_unit () call lexer_init_cmd_list (lexer, global%lexer) call stream_init (stream, char (cmd%file)) call lexer_assign_stream (lexer, stream) call parse_tree_init (cmd%parse_tree, syntax_cmd_list, lexer) call stream_final (stream) call lexer_final (lexer) close (u) allocate (cmd%command_list) call cmd%command_list%compile (cmd%parse_tree%get_root_ptr (), & global) end subroutine cmd_include_compile @ %def cmd_include_compile @ Execute file contents in the global context. <>= procedure :: execute => cmd_include_execute <>= subroutine cmd_include_execute (cmd, global) class(cmd_include_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global if (associated (cmd%command_list)) then call msg_message & ("Including Sindarin from '" // char (cmd%file) // "'") call cmd%command_list%execute (global) call msg_message & ("End of included '" // char (cmd%file) // "'") end if end subroutine cmd_include_execute @ %def cmd_include_execute @ \subsubsection{Export values} This command exports the current values of variables or other objects to the surrounding scope. By default, a scope enclosed by braces keeps all objects local to it. The [[export]] command exports the values that are generated within the scope to the corresponding object in the outer scope. The allowed set of exportable objects is, in principle, the same as the set of objects that the [[show]] command supports. This includes some convenience abbreviations. TODO: The initial implementation inherits syntax from [[show]], but supports only the [[results]] pseudo-object. The results (i.e., the process stack) is appended to the outer process stack instead of being discarded. The behavior of the [[export]] command for other object kinds is to be defined on a case-by-case basis. It may involve replacing the outer value or, instead, doing some sort of appending or reduction. <>= type, extends (command_t) :: cmd_export_t private type(string_t), dimension(:), allocatable :: name contains <> end type cmd_export_t @ %def cmd_export_t @ Output: list the object names, not values. <>= procedure :: write => cmd_export_write <>= subroutine cmd_export_write (cmd, unit, indent) class(cmd_export_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u, i u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A)", advance="no") "export: " if (allocated (cmd%name)) then do i = 1, size (cmd%name) write (u, "(1x,A)", advance="no") char (cmd%name(i)) end do write (u, *) else write (u, "(5x,A)") "[undefined]" end if end subroutine cmd_export_write @ %def cmd_export_write @ Compile. Allocate an array which is filled with the names of the variables to export. <>= procedure :: compile => cmd_export_compile <>= subroutine cmd_export_compile (cmd, global) class(cmd_export_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_arg, pn_var, pn_prefix, pn_name type(string_t) :: key integer :: i, n_args pn_arg => parse_node_get_sub_ptr (cmd%pn, 2) if (associated (pn_arg)) then select case (char (parse_node_get_rule_key (pn_arg))) case ("show_arg") cmd%pn_opt => parse_node_get_next_ptr (pn_arg) case default cmd%pn_opt => pn_arg pn_arg => null () end select end if call cmd%compile_options (global) if (associated (pn_arg)) then n_args = parse_node_get_n_sub (pn_arg) allocate (cmd%name (n_args)) pn_var => parse_node_get_sub_ptr (pn_arg) i = 0 do while (associated (pn_var)) i = i + 1 select case (char (parse_node_get_rule_key (pn_var))) case ("model", "library", "beams", "iterations", & "cuts", "weight", "int", "real", "complex", & "scale", "factorization_scale", "renormalization_scale", & "selection", "reweight", "analysis", "pdg", & "stable", "unstable", "polarized", "unpolarized", & "results", "expect", "intrinsic", "string", "logical") cmd%name(i) = parse_node_get_key (pn_var) case ("result_var") pn_prefix => parse_node_get_sub_ptr (pn_var) pn_name => parse_node_get_next_ptr (pn_prefix) if (associated (pn_name)) then cmd%name(i) = parse_node_get_key (pn_prefix) & // "(" // parse_node_get_string (pn_name) // ")" else cmd%name(i) = parse_node_get_key (pn_prefix) end if case ("log_var", "string_var", "alias_var") pn_prefix => parse_node_get_sub_ptr (pn_var) pn_name => parse_node_get_next_ptr (pn_prefix) key = parse_node_get_key (pn_prefix) if (associated (pn_name)) then select case (char (parse_node_get_rule_key (pn_name))) case ("var_name") select case (char (key)) case ("?", "$") ! $ sign cmd%name(i) = key // parse_node_get_string (pn_name) case ("alias") cmd%name(i) = parse_node_get_string (pn_name) end select case default call parse_node_mismatch & ("var_name", pn_name) end select else cmd%name(i) = key end if case default cmd%name(i) = parse_node_get_string (pn_var) end select !!! restriction imposed by current lack of implementation select case (char (parse_node_get_rule_key (pn_var))) case ("results") case default call msg_fatal ("export: object (type) '" & // char (parse_node_get_rule_key (pn_var)) & // "' not supported yet") end select pn_var => parse_node_get_next_ptr (pn_var) end do else allocate (cmd%name (0)) end if end subroutine cmd_export_compile @ %def cmd_export_compile @ Execute. Scan the list of objects to export. <>= procedure :: execute => cmd_export_execute <>= subroutine cmd_export_execute (cmd, global) class(cmd_export_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global call global%append_exports (cmd%name) end subroutine cmd_export_execute @ %def cmd_export_execute @ \subsubsection{Quit command execution} The code is the return code of the whole program if it is terminated by this command. <>= type, extends (command_t) :: cmd_quit_t private logical :: has_code = .false. type(parse_node_t), pointer :: pn_code_expr => null () contains <> end type cmd_quit_t @ %def cmd_quit_t @ Output. <>= procedure :: write => cmd_quit_write <>= subroutine cmd_quit_write (cmd, unit, indent) class(cmd_quit_t), intent(in) :: cmd integer, intent(in), optional :: unit, indent integer :: u u = given_output_unit (unit); if (u < 0) return call write_indent (u, indent) write (u, "(1x,A,L1)") "quit: has_code = ", cmd%has_code end subroutine cmd_quit_write @ %def cmd_quit_write @ Compile: allocate a [[quit]] object which serves as a placeholder. <>= procedure :: compile => cmd_quit_compile <>= subroutine cmd_quit_compile (cmd, global) class(cmd_quit_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_arg pn_arg => parse_node_get_sub_ptr (cmd%pn, 2) if (associated (pn_arg)) then cmd%pn_code_expr => parse_node_get_sub_ptr (pn_arg) cmd%has_code = .true. end if end subroutine cmd_quit_compile @ %def cmd_quit_compile @ Execute: The quit command does not execute anything, it just stops command execution. This is achieved by setting quit flag and quit code in the global variable list. However, the return code, if present, is an expression which has to be evaluated. <>= procedure :: execute => cmd_quit_execute <>= subroutine cmd_quit_execute (cmd, global) class(cmd_quit_t), intent(inout) :: cmd type(rt_data_t), intent(inout), target :: global type(var_list_t), pointer :: var_list logical :: is_known var_list => global%get_var_list_ptr () if (cmd%has_code) then global%quit_code = eval_int (cmd%pn_code_expr, var_list, & is_known=is_known) if (.not. is_known) then call msg_error ("Undefined return code of quit/exit command") end if end if global%quit = .true. end subroutine cmd_quit_execute @ %def cmd_quit_execute @ \subsection{The command list} The command list holds a list of commands and relevant global data. <>= public :: command_list_t <>= type :: command_list_t ! not private anymore as required by the whizard-c-interface class(command_t), pointer :: first => null () class(command_t), pointer :: last => null () contains <> end type command_list_t @ %def command_list_t @ Output. <>= procedure :: write => command_list_write <>= recursive subroutine command_list_write (cmd_list, unit, indent) class(command_list_t), intent(in) :: cmd_list integer, intent(in), optional :: unit, indent class(command_t), pointer :: cmd cmd => cmd_list%first do while (associated (cmd)) call cmd%write (unit, indent) cmd => cmd%next end do end subroutine command_list_write @ %def command_list_write @ Append a new command to the list and free the original pointer. <>= procedure :: append => command_list_append <>= subroutine command_list_append (cmd_list, command) class(command_list_t), intent(inout) :: cmd_list class(command_t), intent(inout), pointer :: command if (associated (cmd_list%last)) then cmd_list%last%next => command else cmd_list%first => command end if cmd_list%last => command command => null () end subroutine command_list_append @ %def command_list_append @ Finalize. <>= procedure :: final => command_list_final <>= recursive subroutine command_list_final (cmd_list) class(command_list_t), intent(inout) :: cmd_list class(command_t), pointer :: command do while (associated (cmd_list%first)) command => cmd_list%first cmd_list%first => cmd_list%first%next call command%final () deallocate (command) end do cmd_list%last => null () end subroutine command_list_final @ %def command_list_final @ \subsection{Compiling the parse tree} Transform a parse tree into a command list. Initialization is assumed to be done. After each command, we set a breakpoint. <>= procedure :: compile => command_list_compile <>= recursive subroutine command_list_compile (cmd_list, pn, global) class(command_list_t), intent(inout), target :: cmd_list type(parse_node_t), intent(in), target :: pn type(rt_data_t), intent(inout), target :: global type(parse_node_t), pointer :: pn_cmd class(command_t), pointer :: command integer :: i pn_cmd => parse_node_get_sub_ptr (pn) do i = 1, parse_node_get_n_sub (pn) call dispatch_command (command, pn_cmd) call command%compile (global) call cmd_list%append (command) call terminate_now_if_signal () pn_cmd => parse_node_get_next_ptr (pn_cmd) end do end subroutine command_list_compile @ %def command_list_compile @ \subsection{Executing the command list} Before executing a command we should execute its options (if any). After that, reset the options, i.e., remove temporary effects from the global state. Also here, after each command we set a breakpoint. <>= procedure :: execute => command_list_execute <>= recursive subroutine command_list_execute (cmd_list, global) class(command_list_t), intent(in) :: cmd_list type(rt_data_t), intent(inout), target :: global class(command_t), pointer :: command command => cmd_list%first COMMAND_COND: do while (associated (command)) call command%execute_options (global) call command%execute (global) call command%reset_options (global) call terminate_now_if_signal () if (global%quit) exit COMMAND_COND command => command%next end do COMMAND_COND end subroutine command_list_execute @ %def command_list_execute @ \subsection{Command list syntax} <>= public :: syntax_cmd_list <>= type(syntax_t), target, save :: syntax_cmd_list @ %def syntax_cmd_list <>= public :: syntax_cmd_list_init <>= subroutine syntax_cmd_list_init () type(ifile_t) :: ifile call define_cmd_list_syntax (ifile) call syntax_init (syntax_cmd_list, ifile) call ifile_final (ifile) end subroutine syntax_cmd_list_init @ %def syntax_cmd_list_init <>= public :: syntax_cmd_list_final <>= subroutine syntax_cmd_list_final () call syntax_final (syntax_cmd_list) end subroutine syntax_cmd_list_final @ %def syntax_cmd_list_final <>= public :: syntax_cmd_list_write <>= subroutine syntax_cmd_list_write (unit) integer, intent(in), optional :: unit call syntax_write (syntax_cmd_list, unit) end subroutine syntax_cmd_list_write @ %def syntax_cmd_list_write <>= subroutine define_cmd_list_syntax (ifile) type(ifile_t), intent(inout) :: ifile call ifile_append (ifile, "SEQ command_list = command*") call ifile_append (ifile, "ALT command = " & // "cmd_model | cmd_library | cmd_iterations | cmd_sample_format | " & // "cmd_var | cmd_slha | " & // "cmd_show | cmd_clear | " & // "cmd_expect | " & // "cmd_cuts | cmd_scale | cmd_fac_scale | cmd_ren_scale | " & // "cmd_weight | cmd_selection | cmd_reweight | " & // "cmd_beams | cmd_beams_pol_density | cmd_beams_pol_fraction | " & // "cmd_beams_momentum | cmd_beams_theta | cmd_beams_phi | " & // "cmd_integrate | " & // "cmd_observable | cmd_histogram | cmd_plot | cmd_graph | " & // "cmd_record | " & // "cmd_analysis | cmd_alt_setup | " & // "cmd_unstable | cmd_stable | cmd_simulate | cmd_rescan | " & // "cmd_process | cmd_compile | cmd_exec | " & // "cmd_scan | cmd_if | cmd_include | cmd_quit | " & // "cmd_export | " & // "cmd_polarized | cmd_unpolarized | " & // "cmd_open_out | cmd_close_out | cmd_printf | " & // "cmd_write_analysis | cmd_compile_analysis | cmd_nlo | cmd_components") call ifile_append (ifile, "GRO options = '{' local_command_list '}'") call ifile_append (ifile, "SEQ local_command_list = local_command*") call ifile_append (ifile, "ALT local_command = " & // "cmd_model | cmd_library | cmd_iterations | cmd_sample_format | " & // "cmd_var | cmd_slha | " & // "cmd_show | " & // "cmd_expect | " & // "cmd_cuts | cmd_scale | cmd_fac_scale | cmd_ren_scale | " & // "cmd_weight | cmd_selection | cmd_reweight | " & // "cmd_beams | cmd_beams_pol_density | cmd_beams_pol_fraction | " & // "cmd_beams_momentum | cmd_beams_theta | cmd_beams_phi | " & // "cmd_observable | cmd_histogram | cmd_plot | cmd_graph | " & // "cmd_clear | cmd_record | " & // "cmd_analysis | cmd_alt_setup | " & // "cmd_open_out | cmd_close_out | cmd_printf | " & // "cmd_write_analysis | cmd_compile_analysis | cmd_nlo | cmd_components") call ifile_append (ifile, "SEQ cmd_model = model '=' model_name model_arg?") call ifile_append (ifile, "KEY model") call ifile_append (ifile, "ALT model_name = model_id | string_literal") call ifile_append (ifile, "IDE model_id") call ifile_append (ifile, "ARG model_arg = ( model_scheme? )") call ifile_append (ifile, "ALT model_scheme = " & // "ufo_spec | scheme_id | string_literal") call ifile_append (ifile, "SEQ ufo_spec = ufo ufo_arg?") call ifile_append (ifile, "KEY ufo") call ifile_append (ifile, "ARG ufo_arg = ( string_literal )") call ifile_append (ifile, "IDE scheme_id") call ifile_append (ifile, "SEQ cmd_library = library '=' lib_name") call ifile_append (ifile, "KEY library") call ifile_append (ifile, "ALT lib_name = lib_id | string_literal") call ifile_append (ifile, "IDE lib_id") call ifile_append (ifile, "ALT cmd_var = " & // "cmd_log_decl | cmd_log | " & // "cmd_int | cmd_real | cmd_complex | cmd_num | " & // "cmd_string_decl | cmd_string | cmd_alias | " & // "cmd_result") call ifile_append (ifile, "SEQ cmd_log_decl = logical cmd_log") call ifile_append (ifile, "SEQ cmd_log = '?' var_name '=' lexpr") call ifile_append (ifile, "SEQ cmd_int = int var_name '=' expr") call ifile_append (ifile, "SEQ cmd_real = real var_name '=' expr") call ifile_append (ifile, "SEQ cmd_complex = complex var_name '=' expr") call ifile_append (ifile, "SEQ cmd_num = var_name '=' expr") call ifile_append (ifile, "SEQ cmd_string_decl = string cmd_string") call ifile_append (ifile, "SEQ cmd_string = " & // "'$' var_name '=' sexpr") ! $ call ifile_append (ifile, "SEQ cmd_alias = alias var_name '=' cexpr") call ifile_append (ifile, "SEQ cmd_result = result '=' expr") call ifile_append (ifile, "SEQ cmd_slha = slha_action slha_arg options?") call ifile_append (ifile, "ALT slha_action = " & // "read_slha | write_slha") call ifile_append (ifile, "KEY read_slha") call ifile_append (ifile, "KEY write_slha") call ifile_append (ifile, "ARG slha_arg = ( string_literal )") call ifile_append (ifile, "SEQ cmd_show = show show_arg options?") call ifile_append (ifile, "KEY show") call ifile_append (ifile, "ARG show_arg = ( showable* )") call ifile_append (ifile, "ALT showable = " & // "model | library | beams | iterations | " & // "cuts | weight | logical | string | pdg | " & // "scale | factorization_scale | renormalization_scale | " & // "selection | reweight | analysis | " & // "stable | unstable | polarized | unpolarized | " & // "expect | intrinsic | int | real | complex | " & // "alias_var | string | results | result_var | " & // "log_var | string_var | var_name") call ifile_append (ifile, "KEY results") call ifile_append (ifile, "KEY intrinsic") call ifile_append (ifile, "SEQ alias_var = alias var_name") call ifile_append (ifile, "SEQ result_var = result_key result_arg?") call ifile_append (ifile, "SEQ log_var = '?' var_name") call ifile_append (ifile, "SEQ string_var = '$' var_name") ! $ call ifile_append (ifile, "SEQ cmd_clear = clear clear_arg options?") call ifile_append (ifile, "KEY clear") call ifile_append (ifile, "ARG clear_arg = ( clearable* )") call ifile_append (ifile, "ALT clearable = " & // "beams | iterations | " & // "cuts | weight | " & // "scale | factorization_scale | renormalization_scale | " & // "selection | reweight | analysis | " & // "unstable | polarized | " & // "expect | " & // "log_var | string_var | var_name") call ifile_append (ifile, "SEQ cmd_expect = expect expect_arg options?") call ifile_append (ifile, "KEY expect") call ifile_append (ifile, "ARG expect_arg = ( lexpr )") call ifile_append (ifile, "SEQ cmd_cuts = cuts '=' lexpr") call ifile_append (ifile, "SEQ cmd_scale = scale '=' expr") call ifile_append (ifile, "SEQ cmd_fac_scale = " & // "factorization_scale '=' expr") call ifile_append (ifile, "SEQ cmd_ren_scale = " & // "renormalization_scale '=' expr") call ifile_append (ifile, "SEQ cmd_weight = weight '=' expr") call ifile_append (ifile, "SEQ cmd_selection = selection '=' lexpr") call ifile_append (ifile, "SEQ cmd_reweight = reweight '=' expr") call ifile_append (ifile, "KEY cuts") call ifile_append (ifile, "KEY scale") call ifile_append (ifile, "KEY factorization_scale") call ifile_append (ifile, "KEY renormalization_scale") call ifile_append (ifile, "KEY weight") call ifile_append (ifile, "KEY selection") call ifile_append (ifile, "KEY reweight") call ifile_append (ifile, "SEQ cmd_process = process process_id '=' " & // "process_prt '=>' prt_state_list options?") call ifile_append (ifile, "KEY process") call ifile_append (ifile, "KEY '=>'") call ifile_append (ifile, "LIS process_prt = cexpr+") call ifile_append (ifile, "LIS prt_state_list = prt_state_sum+") call ifile_append (ifile, "SEQ prt_state_sum = " & // "prt_state prt_state_addition*") call ifile_append (ifile, "SEQ prt_state_addition = '+' prt_state") call ifile_append (ifile, "ALT prt_state = grouped_prt_state_list | cexpr") call ifile_append (ifile, "GRO grouped_prt_state_list = " & // "( prt_state_list )") call ifile_append (ifile, "SEQ cmd_compile = compile_cmd options?") call ifile_append (ifile, "SEQ compile_cmd = compile_clause compile_arg?") call ifile_append (ifile, "SEQ compile_clause = compile exec_name_spec?") call ifile_append (ifile, "KEY compile") call ifile_append (ifile, "SEQ exec_name_spec = as exec_name") call ifile_append (ifile, "KEY as") call ifile_append (ifile, "ALT exec_name = exec_id | string_literal") call ifile_append (ifile, "IDE exec_id") call ifile_append (ifile, "ARG compile_arg = ( lib_name* )") call ifile_append (ifile, "SEQ cmd_exec = exec exec_arg") call ifile_append (ifile, "KEY exec") call ifile_append (ifile, "ARG exec_arg = ( sexpr )") call ifile_append (ifile, "SEQ cmd_beams = beams '=' beam_def") call ifile_append (ifile, "KEY beams") call ifile_append (ifile, "SEQ beam_def = beam_spec strfun_seq*") call ifile_append (ifile, "SEQ beam_spec = beam_list") call ifile_append (ifile, "LIS beam_list = cexpr, cexpr?") call ifile_append (ifile, "SEQ cmd_beams_pol_density = " & // "beams_pol_density '=' beams_pol_spec") call ifile_append (ifile, "KEY beams_pol_density") call ifile_append (ifile, "LIS beams_pol_spec = smatrix, smatrix?") call ifile_append (ifile, "SEQ smatrix = '@' smatrix_arg") ! call ifile_append (ifile, "KEY '@'") !!! Key already exists call ifile_append (ifile, "ARG smatrix_arg = ( sentry* )") call ifile_append (ifile, "SEQ sentry = expr extra_sentry*") call ifile_append (ifile, "SEQ extra_sentry = ':' expr") call ifile_append (ifile, "SEQ cmd_beams_pol_fraction = " & // "beams_pol_fraction '=' beams_par_spec") call ifile_append (ifile, "KEY beams_pol_fraction") call ifile_append (ifile, "SEQ cmd_beams_momentum = " & // "beams_momentum '=' beams_par_spec") call ifile_append (ifile, "KEY beams_momentum") call ifile_append (ifile, "SEQ cmd_beams_theta = " & // "beams_theta '=' beams_par_spec") call ifile_append (ifile, "KEY beams_theta") call ifile_append (ifile, "SEQ cmd_beams_phi = " & // "beams_phi '=' beams_par_spec") call ifile_append (ifile, "KEY beams_phi") call ifile_append (ifile, "LIS beams_par_spec = expr, expr?") call ifile_append (ifile, "SEQ strfun_seq = '=>' strfun_pair") call ifile_append (ifile, "LIS strfun_pair = strfun_def, strfun_def?") call ifile_append (ifile, "SEQ strfun_def = strfun_id") call ifile_append (ifile, "ALT strfun_id = " & // "none | lhapdf | lhapdf_photon | pdf_builtin | pdf_builtin_photon | " & // "isr | epa | ewa | circe1 | circe2 | energy_scan | " & // "gaussian | beam_events") call ifile_append (ifile, "KEY none") call ifile_append (ifile, "KEY lhapdf") call ifile_append (ifile, "KEY lhapdf_photon") call ifile_append (ifile, "KEY pdf_builtin") call ifile_append (ifile, "KEY pdf_builtin_photon") call ifile_append (ifile, "KEY isr") call ifile_append (ifile, "KEY epa") call ifile_append (ifile, "KEY ewa") call ifile_append (ifile, "KEY circe1") call ifile_append (ifile, "KEY circe2") call ifile_append (ifile, "KEY energy_scan") call ifile_append (ifile, "KEY gaussian") call ifile_append (ifile, "KEY beam_events") call ifile_append (ifile, "SEQ cmd_integrate = " & // "integrate proc_arg options?") call ifile_append (ifile, "KEY integrate") call ifile_append (ifile, "ARG proc_arg = ( proc_id* )") call ifile_append (ifile, "IDE proc_id") call ifile_append (ifile, "SEQ cmd_iterations = " & // "iterations '=' iterations_list") call ifile_append (ifile, "KEY iterations") call ifile_append (ifile, "LIS iterations_list = iterations_spec+") call ifile_append (ifile, "ALT iterations_spec = it_spec") call ifile_append (ifile, "SEQ it_spec = expr calls_spec adapt_spec?") call ifile_append (ifile, "SEQ calls_spec = ':' expr") call ifile_append (ifile, "SEQ adapt_spec = ':' sexpr") call ifile_append (ifile, "SEQ cmd_components = " & // "active '=' component_list") call ifile_append (ifile, "KEY active") call ifile_append (ifile, "LIS component_list = sexpr+") call ifile_append (ifile, "SEQ cmd_sample_format = " & // "sample_format '=' event_format_list") call ifile_append (ifile, "KEY sample_format") call ifile_append (ifile, "LIS event_format_list = event_format+") call ifile_append (ifile, "IDE event_format") call ifile_append (ifile, "SEQ cmd_observable = " & // "observable analysis_tag options?") call ifile_append (ifile, "KEY observable") call ifile_append (ifile, "SEQ cmd_histogram = " & // "histogram analysis_tag histogram_arg " & // "options?") call ifile_append (ifile, "KEY histogram") call ifile_append (ifile, "ARG histogram_arg = (expr, expr, expr?)") call ifile_append (ifile, "SEQ cmd_plot = plot analysis_tag options?") call ifile_append (ifile, "KEY plot") call ifile_append (ifile, "SEQ cmd_graph = graph graph_term '=' graph_def") call ifile_append (ifile, "KEY graph") call ifile_append (ifile, "SEQ graph_term = analysis_tag options?") call ifile_append (ifile, "SEQ graph_def = graph_term graph_append*") call ifile_append (ifile, "SEQ graph_append = '&' graph_term") call ifile_append (ifile, "SEQ cmd_analysis = analysis '=' lexpr") call ifile_append (ifile, "KEY analysis") call ifile_append (ifile, "SEQ cmd_alt_setup = " & // "alt_setup '=' option_list_expr") call ifile_append (ifile, "KEY alt_setup") call ifile_append (ifile, "ALT option_list_expr = " & // "grouped_option_list | option_list") call ifile_append (ifile, "GRO grouped_option_list = ( option_list_expr )") call ifile_append (ifile, "LIS option_list = options+") call ifile_append (ifile, "SEQ cmd_open_out = open_out open_arg options?") call ifile_append (ifile, "SEQ cmd_close_out = close_out open_arg options?") call ifile_append (ifile, "KEY open_out") call ifile_append (ifile, "KEY close_out") call ifile_append (ifile, "ARG open_arg = (sexpr)") call ifile_append (ifile, "SEQ cmd_printf = printf_cmd options?") call ifile_append (ifile, "SEQ printf_cmd = printf_clause sprintf_args?") call ifile_append (ifile, "SEQ printf_clause = printf sexpr") call ifile_append (ifile, "KEY printf") call ifile_append (ifile, "SEQ cmd_record = record_cmd") call ifile_append (ifile, "SEQ cmd_unstable = " & // "unstable cexpr unstable_arg options?") call ifile_append (ifile, "KEY unstable") call ifile_append (ifile, "ARG unstable_arg = ( proc_id* )") call ifile_append (ifile, "SEQ cmd_stable = stable stable_list options?") call ifile_append (ifile, "KEY stable") call ifile_append (ifile, "LIS stable_list = cexpr+") call ifile_append (ifile, "KEY polarized") call ifile_append (ifile, "SEQ cmd_polarized = polarized polarized_list options?") call ifile_append (ifile, "LIS polarized_list = cexpr+") call ifile_append (ifile, "KEY unpolarized") call ifile_append (ifile, "SEQ cmd_unpolarized = unpolarized unpolarized_list options?") call ifile_append (ifile, "LIS unpolarized_list = cexpr+") call ifile_append (ifile, "SEQ cmd_simulate = " & // "simulate proc_arg options?") call ifile_append (ifile, "KEY simulate") call ifile_append (ifile, "SEQ cmd_rescan = " & // "rescan sexpr proc_arg options?") call ifile_append (ifile, "KEY rescan") call ifile_append (ifile, "SEQ cmd_scan = scan scan_var scan_body?") call ifile_append (ifile, "KEY scan") call ifile_append (ifile, "ALT scan_var = " & // "scan_log_decl | scan_log | " & // "scan_int | scan_real | scan_complex | scan_num | " & // "scan_string_decl | scan_string | scan_alias | " & // "scan_cuts | scan_weight | " & // "scan_scale | scan_ren_scale | scan_fac_scale | " & // "scan_selection | scan_reweight | scan_analysis | " & // "scan_model | scan_library") call ifile_append (ifile, "SEQ scan_log_decl = logical scan_log") call ifile_append (ifile, "SEQ scan_log = '?' var_name '=' scan_log_arg") call ifile_append (ifile, "ARG scan_log_arg = ( lexpr* )") call ifile_append (ifile, "SEQ scan_int = int var_name '=' scan_num_arg") call ifile_append (ifile, "SEQ scan_real = real var_name '=' scan_num_arg") call ifile_append (ifile, "SEQ scan_complex = " & // "complex var_name '=' scan_num_arg") call ifile_append (ifile, "SEQ scan_num = var_name '=' scan_num_arg") call ifile_append (ifile, "ARG scan_num_arg = ( range* )") call ifile_append (ifile, "ALT range = grouped_range | range_expr") call ifile_append (ifile, "GRO grouped_range = ( range_expr )") call ifile_append (ifile, "SEQ range_expr = expr range_spec?") call ifile_append (ifile, "SEQ range_spec = '=>' expr step_spec?") call ifile_append (ifile, "SEQ step_spec = step_op expr") call ifile_append (ifile, "ALT step_op = " & // "'/+' | '/-' | '/*' | '//' | '/+/' | '/*/'") call ifile_append (ifile, "KEY '/+'") call ifile_append (ifile, "KEY '/-'") call ifile_append (ifile, "KEY '/*'") call ifile_append (ifile, "KEY '//'") call ifile_append (ifile, "KEY '/+/'") call ifile_append (ifile, "KEY '/*/'") call ifile_append (ifile, "SEQ scan_string_decl = string scan_string") call ifile_append (ifile, "SEQ scan_string = " & // "'$' var_name '=' scan_string_arg") call ifile_append (ifile, "ARG scan_string_arg = ( sexpr* )") call ifile_append (ifile, "SEQ scan_alias = " & // "alias var_name '=' scan_alias_arg") call ifile_append (ifile, "ARG scan_alias_arg = ( cexpr* )") call ifile_append (ifile, "SEQ scan_cuts = cuts '=' scan_lexpr_arg") call ifile_append (ifile, "ARG scan_lexpr_arg = ( lexpr* )") call ifile_append (ifile, "SEQ scan_scale = scale '=' scan_expr_arg") call ifile_append (ifile, "ARG scan_expr_arg = ( expr* )") call ifile_append (ifile, "SEQ scan_fac_scale = " & // "factorization_scale '=' scan_expr_arg") call ifile_append (ifile, "SEQ scan_ren_scale = " & // "renormalization_scale '=' scan_expr_arg") call ifile_append (ifile, "SEQ scan_weight = weight '=' scan_expr_arg") call ifile_append (ifile, "SEQ scan_selection = selection '=' scan_lexpr_arg") call ifile_append (ifile, "SEQ scan_reweight = reweight '=' scan_expr_arg") call ifile_append (ifile, "SEQ scan_analysis = analysis '=' scan_lexpr_arg") call ifile_append (ifile, "SEQ scan_model = model '=' scan_model_arg") call ifile_append (ifile, "ARG scan_model_arg = ( model_name* )") call ifile_append (ifile, "SEQ scan_library = library '=' scan_library_arg") call ifile_append (ifile, "ARG scan_library_arg = ( lib_name* )") call ifile_append (ifile, "GRO scan_body = '{' command_list '}'") call ifile_append (ifile, "SEQ cmd_if = " & // "if lexpr then command_list elsif_clauses else_clause endif") call ifile_append (ifile, "SEQ elsif_clauses = cmd_elsif*") call ifile_append (ifile, "SEQ cmd_elsif = elsif lexpr then command_list") call ifile_append (ifile, "SEQ else_clause = cmd_else?") call ifile_append (ifile, "SEQ cmd_else = else command_list") call ifile_append (ifile, "SEQ cmd_include = include include_arg") call ifile_append (ifile, "KEY include") call ifile_append (ifile, "ARG include_arg = ( string_literal )") call ifile_append (ifile, "SEQ cmd_quit = quit_cmd quit_arg?") call ifile_append (ifile, "ALT quit_cmd = quit | exit") call ifile_append (ifile, "KEY quit") call ifile_append (ifile, "KEY exit") call ifile_append (ifile, "ARG quit_arg = ( expr )") call ifile_append (ifile, "SEQ cmd_export = export show_arg options?") call ifile_append (ifile, "KEY export") call ifile_append (ifile, "SEQ cmd_write_analysis = " & // "write_analysis_clause options?") call ifile_append (ifile, "SEQ cmd_compile_analysis = " & // "compile_analysis_clause options?") call ifile_append (ifile, "SEQ write_analysis_clause = " & // "write_analysis write_analysis_arg?") call ifile_append (ifile, "SEQ compile_analysis_clause = " & // "compile_analysis write_analysis_arg?") call ifile_append (ifile, "KEY write_analysis") call ifile_append (ifile, "KEY compile_analysis") call ifile_append (ifile, "ARG write_analysis_arg = ( analysis_tag* )") call ifile_append (ifile, "SEQ cmd_nlo = " & // "nlo_calculation '=' nlo_calculation_list") call ifile_append (ifile, "KEY nlo_calculation") call ifile_append (ifile, "LIS nlo_calculation_list = nlo_comp+") call ifile_append (ifile, "ALT nlo_comp = " // & "full | born | real | virtual | dglap | subtraction | " // & "mismatch | GKS") call ifile_append (ifile, "KEY full") call ifile_append (ifile, "KEY born") call ifile_append (ifile, "KEY virtual") call ifile_append (ifile, "KEY dglap") call ifile_append (ifile, "KEY subtraction") call ifile_append (ifile, "KEY mismatch") call ifile_append (ifile, "KEY GKS") call define_expr_syntax (ifile, particles=.true., analysis=.true.) end subroutine define_cmd_list_syntax @ %def define_cmd_list_syntax <>= public :: lexer_init_cmd_list <>= subroutine lexer_init_cmd_list (lexer, parent_lexer) type(lexer_t), intent(out) :: lexer type(lexer_t), intent(in), optional, target :: parent_lexer call lexer_init (lexer, & comment_chars = "#!", & quote_chars = '"', & quote_match = '"', & single_chars = "()[]{},;:&%?$@", & special_class = [ "+-*/^", "<>=~ " ] , & keyword_list = syntax_get_keyword_list_ptr (syntax_cmd_list), & parent = parent_lexer) end subroutine lexer_init_cmd_list @ %def lexer_init_cmd_list @ \subsection{Unit Tests} Test module, followed by the corresponding implementation module. <<[[commands_ut.f90]]>>= <> module commands_ut use unit_tests use commands_uti <> <> contains <> end module commands_ut @ %def commands_ut @ <<[[commands_uti.f90]]>>= <> module commands_uti <> use kinds, only: i64 <> use io_units use ifiles use parser use interactions, only: reset_interaction_counter use prclib_stacks use analysis use variables, only: var_list_t use models use slha_interface use rt_data use event_base, only: generic_event_t, event_callback_t use commands <> <> <> contains <> <> end module commands_uti @ %def commands_uti @ API: driver for the unit tests below. <>= public :: commands_test <>= subroutine commands_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine commands_test @ %def commands_test @ \subsubsection{Prepare Sindarin code} This routine parses an internal file, prints the parse tree, and returns a parse node to the root. We use the routine in the tests below. <>= public :: parse_ifile <>= subroutine parse_ifile (ifile, pn_root, u) use ifiles use lexers use parser use commands type(ifile_t), intent(in) :: ifile type(parse_node_t), pointer, intent(out) :: pn_root integer, intent(in), optional :: u type(stream_t), target :: stream type(lexer_t), target :: lexer type(parse_tree_t) :: parse_tree call lexer_init_cmd_list (lexer) call stream_init (stream, ifile) call lexer_assign_stream (lexer, stream) call parse_tree_init (parse_tree, syntax_cmd_list, lexer) if (present (u)) call parse_tree_write (parse_tree, u) pn_root => parse_tree%get_root_ptr () call stream_final (stream) call lexer_final (lexer) end subroutine parse_ifile @ %def parse_ifile @ \subsubsection{Empty command list} Compile and execute an empty command list. Should do nothing but test the integrity of the workflow. <>= call test (commands_1, "commands_1", & "empty command list", & u, results) <>= public :: commands_1 <>= subroutine commands_1 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_1" write (u, "(A)") "* Purpose: compile and execute empty command list" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () write (u, "(A)") "* Parse empty file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" if (associated (pn_root)) then call command_list%compile (pn_root, global) end if write (u, "(A)") write (u, "(A)") "* Execute command list" call global%activate () call command_list%execute (global) call global%deactivate () write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call syntax_cmd_list_final () call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_1" end subroutine commands_1 @ %def commands_1 @ \subsubsection{Read model} Execute a [[model]] assignment. <>= call test (commands_2, "commands_2", & "model", & u, results) <>= public :: commands_2 <>= subroutine commands_2 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_2" write (u, "(A)") "* Purpose: set model" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call syntax_model_file_init () call global%global_init () write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'model = "Test"') call ifile_write (ifile, u) write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_2" end subroutine commands_2 @ %def commands_2 @ \subsubsection{Declare Process} Read a model, then declare a process. The process library is allocated explicitly. For the process definition, We take the default ([[omega]]) method. Since we do not compile, \oMega\ is not actually called. <>= call test (commands_3, "commands_3", & "process declaration", & u, results) <>= public :: commands_3 <>= subroutine commands_3 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root type(prclib_entry_t), pointer :: lib write (u, "(A)") "* Test output: commands_3" write (u, "(A)") "* Purpose: define process" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call syntax_model_file_init () call global%global_init () call global%var_list%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) allocate (lib) call lib%init (var_str ("lib_cmd3")) call global%add_prclib (lib) write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'model = "Test"') call ifile_append (ifile, 'process t3 = s, s => s, s') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) call global%prclib_stack%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_3" end subroutine commands_3 @ %def commands_3 @ \subsubsection{Compile Process} Read a model, then declare a process and compile the library. The process library is allocated explicitly. For the process definition, We take the default ([[unit_test]]) method. There is no external code, so compilation of the library is merely a formal status change. <>= call test (commands_4, "commands_4", & "compilation", & u, results) <>= public :: commands_4 <>= subroutine commands_4 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root type(prclib_entry_t), pointer :: lib write (u, "(A)") "* Test output: commands_4" write (u, "(A)") "* Purpose: define process and compile library" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call syntax_model_file_init () call global%global_init () call global%var_list%set_string (var_str ("$method"), & var_str ("unit_test"), is_known=.true.) allocate (lib) call lib%init (var_str ("lib_cmd4")) call global%add_prclib (lib) write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'model = "Test"') call ifile_append (ifile, 'process t4 = s, s => s, s') call ifile_append (ifile, 'compile ("lib_cmd4")') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) call global%prclib_stack%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_4" end subroutine commands_4 @ %def commands_4 @ \subsubsection{Integrate Process} Read a model, then declare a process, compile the library, and integrate over phase space. We take the default ([[unit_test]]) method and use the simplest methods of phase-space parameterization and integration. <>= call test (commands_5, "commands_5", & "integration", & u, results) <>= public :: commands_5 <>= subroutine commands_5 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root type(prclib_entry_t), pointer :: lib write (u, "(A)") "* Test output: commands_5" write (u, "(A)") "* Purpose: define process, iterations, and integrate" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call syntax_model_file_init () call global%global_init () call global%var_list%set_string (var_str ("$method"), & var_str ("unit_test"), is_known=.true.) call global%var_list%set_string (var_str ("$phs_method"), & var_str ("single"), is_known=.true.) call global%var_list%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known=.true.) call global%var_list%set_log (var_str ("?vis_history"),& .false., is_known=.true.) call global%var_list%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%var_list%set_real (var_str ("sqrts"), & 1000._default, is_known=.true.) call global%var_list%set_int (var_str ("seed"), 0, is_known=.true.) allocate (lib) call lib%init (var_str ("lib_cmd5")) call global%add_prclib (lib) write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'model = "Test"') call ifile_append (ifile, 'process t5 = s, s => s, s') call ifile_append (ifile, 'compile') call ifile_append (ifile, 'iterations = 1:1000') call ifile_append (ifile, 'integrate (t5)') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call reset_interaction_counter () call command_list%execute (global) call global%it_list%write (u) write (u, "(A)") call global%process_stack%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_5" end subroutine commands_5 @ %def commands_5 @ \subsubsection{Variables} Set intrinsic and user-defined variables. <>= call test (commands_6, "commands_6", & "variables", & u, results) <>= public :: commands_6 <>= subroutine commands_6 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_6" write (u, "(A)") "* Purpose: define and set variables" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () call global%write_vars (u, [ & var_str ("$run_id"), & var_str ("?unweighted"), & var_str ("sqrts")]) write (u, "(A)") write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, '$run_id = "run1"') call ifile_append (ifile, '?unweighted = false') call ifile_append (ifile, 'sqrts = 1000') call ifile_append (ifile, 'int j = 10') call ifile_append (ifile, 'real x = 1000.') call ifile_append (ifile, 'complex z = 5') call ifile_append (ifile, 'string $text = "abcd"') call ifile_append (ifile, 'logical ?flag = true') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) call global%write_vars (u, [ & var_str ("$run_id"), & var_str ("?unweighted"), & var_str ("sqrts"), & var_str ("j"), & var_str ("x"), & var_str ("z"), & var_str ("$text"), & var_str ("?flag")]) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call syntax_cmd_list_final () call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_6" end subroutine commands_6 @ %def commands_6 @ \subsubsection{Process library} Open process libraries explicitly. <>= call test (commands_7, "commands_7", & "process library", & u, results) <>= public :: commands_7 <>= subroutine commands_7 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_7" write (u, "(A)") "* Purpose: declare process libraries" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () call global%var_list%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) global%os_data%fc = "Fortran-compiler" global%os_data%fcflags = "Fortran-flags" write (u, "(A)") write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'library = "lib_cmd7_1"') call ifile_append (ifile, 'library = "lib_cmd7_2"') call ifile_append (ifile, 'library = "lib_cmd7_1"') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) call global%write_libraries (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call syntax_cmd_list_final () call global%final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_7" end subroutine commands_7 @ %def commands_7 @ \subsubsection{Generate events} Read a model, then declare a process, compile the library, and generate weighted events. We take the default ([[unit_test]]) method and use the simplest methods of phase-space parameterization and integration. <>= call test (commands_8, "commands_8", & "event generation", & u, results) <>= public :: commands_8 <>= subroutine commands_8 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root type(prclib_entry_t), pointer :: lib write (u, "(A)") "* Test output: commands_8" write (u, "(A)") "* Purpose: define process, integrate, generate events" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call syntax_model_file_init () call global%global_init () call global%init_fallback_model & (var_str ("SM_hadrons"), var_str ("SM_hadrons.mdl")) call global%var_list%set_string (var_str ("$method"), & var_str ("unit_test"), is_known=.true.) call global%var_list%set_string (var_str ("$phs_method"), & var_str ("single"), is_known=.true.) call global%var_list%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known=.true.) call global%var_list%set_log (var_str ("?vis_history"),& .false., is_known=.true.) call global%var_list%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%var_list%set_real (var_str ("sqrts"), & 1000._default, is_known=.true.) allocate (lib) call lib%init (var_str ("lib_cmd8")) call global%add_prclib (lib) write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'model = "Test"') call ifile_append (ifile, 'process commands_8_p = s, s => s, s') call ifile_append (ifile, 'compile') call ifile_append (ifile, 'iterations = 1:1000') call ifile_append (ifile, 'integrate (commands_8_p)') call ifile_append (ifile, '?unweighted = false') call ifile_append (ifile, 'n_events = 3') call ifile_append (ifile, '?read_raw = false') call ifile_append (ifile, 'simulate (commands_8_p)') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" call command_list%execute (global) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_8" end subroutine commands_8 @ %def commands_8 @ \subsubsection{Define cuts} Declare a cut expression. <>= call test (commands_9, "commands_9", & "cuts", & u, results) <>= public :: commands_9 <>= subroutine commands_9 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root type(string_t), dimension(0) :: no_vars write (u, "(A)") "* Test output: commands_9" write (u, "(A)") "* Purpose: define cuts" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'cuts = all Pt > 0 [particle]') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) call global%write (u, vars = no_vars) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_9" end subroutine commands_9 @ %def commands_9 @ \subsubsection{Beams} Define beam setup. <>= call test (commands_10, "commands_10", & "beams", & u, results) <>= public :: commands_10 <>= subroutine commands_10 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_10" write (u, "(A)") "* Purpose: define beams" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call syntax_model_file_init () call global%global_init () write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'model = QCD') call ifile_append (ifile, 'sqrts = 1000') call ifile_append (ifile, 'beams = p, p') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) call global%write_beams (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_10" end subroutine commands_10 @ %def commands_10 @ \subsubsection{Structure functions} Define beam setup with structure functions <>= call test (commands_11, "commands_11", & "structure functions", & u, results) <>= public :: commands_11 <>= subroutine commands_11 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_11" write (u, "(A)") "* Purpose: define beams with structure functions" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call syntax_model_file_init () call global%global_init () write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'model = QCD') call ifile_append (ifile, 'sqrts = 1100') call ifile_append (ifile, 'beams = p, p => lhapdf => pdf_builtin, isr') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) call global%write_beams (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_11" end subroutine commands_11 @ %def commands_11 @ \subsubsection{Rescan events} Read a model, then declare a process, compile the library, and generate weighted events. We take the default ([[unit_test]]) method and use the simplest methods of phase-space parameterization and integration. Then, rescan the generated event sample. <>= call test (commands_12, "commands_12", & "event rescanning", & u, results) <>= public :: commands_12 <>= subroutine commands_12 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root type(prclib_entry_t), pointer :: lib write (u, "(A)") "* Test output: commands_12" write (u, "(A)") "* Purpose: generate events and rescan" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call syntax_model_file_init () call global%global_init () call global%var_list%append_log (& var_str ("?rebuild_phase_space"), .false., & intrinsic=.true.) call global%var_list%append_log (& var_str ("?rebuild_grids"), .false., & intrinsic=.true.) call global%init_fallback_model & (var_str ("SM_hadrons"), var_str ("SM_hadrons.mdl")) call global%var_list%set_string (var_str ("$method"), & var_str ("unit_test"), is_known=.true.) call global%var_list%set_string (var_str ("$phs_method"), & var_str ("single"), is_known=.true.) call global%var_list%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known=.true.) call global%var_list%set_log (var_str ("?vis_history"),& .false., is_known=.true.) call global%var_list%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%var_list%set_real (var_str ("sqrts"), & 1000._default, is_known=.true.) allocate (lib) call lib%init (var_str ("lib_cmd12")) call global%add_prclib (lib) write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'model = "Test"') call ifile_append (ifile, 'process commands_12_p = s, s => s, s') call ifile_append (ifile, 'compile') call ifile_append (ifile, 'iterations = 1:1000') call ifile_append (ifile, 'integrate (commands_12_p)') call ifile_append (ifile, '?unweighted = false') call ifile_append (ifile, 'n_events = 3') call ifile_append (ifile, '?read_raw = false') call ifile_append (ifile, 'simulate (commands_12_p)') call ifile_append (ifile, '?write_raw = false') call ifile_append (ifile, 'rescan "commands_12_p" (commands_12_p)') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" call command_list%execute (global) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_12" end subroutine commands_12 @ %def commands_12 @ \subsubsection{Event Files} Set output formats for event files. <>= call test (commands_13, "commands_13", & "event output formats", & u, results) <>= public :: commands_13 <>= subroutine commands_13 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root type(prclib_entry_t), pointer :: lib logical :: exist write (u, "(A)") "* Test output: commands_13" write (u, "(A)") "* Purpose: generate events and rescan" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call syntax_model_file_init () call global%global_init () call global%init_fallback_model & (var_str ("SM_hadrons"), var_str ("SM_hadrons.mdl")) call global%var_list%set_string (var_str ("$method"), & var_str ("unit_test"), is_known=.true.) call global%var_list%set_string (var_str ("$phs_method"), & var_str ("single"), is_known=.true.) call global%var_list%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known=.true.) call global%var_list%set_real (var_str ("sqrts"), & 1000._default, is_known=.true.) call global%var_list%set_log (var_str ("?vis_history"),& .false., is_known=.true.) call global%var_list%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) allocate (lib) call lib%init (var_str ("lib_cmd13")) call global%add_prclib (lib) write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'model = "Test"') call ifile_append (ifile, 'process commands_13_p = s, s => s, s') call ifile_append (ifile, 'compile') call ifile_append (ifile, 'iterations = 1:1000') call ifile_append (ifile, 'integrate (commands_13_p)') call ifile_append (ifile, '?unweighted = false') call ifile_append (ifile, 'n_events = 1') call ifile_append (ifile, '?read_raw = false') call ifile_append (ifile, 'sample_format = weight_stream') call ifile_append (ifile, 'simulate (commands_13_p)') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" call command_list%execute (global) write (u, "(A)") write (u, "(A)") "* Verify output files" write (u, "(A)") inquire (file = "commands_13_p.evx", exist = exist) if (exist) write (u, "(1x,A)") "raw" inquire (file = "commands_13_p.weights.dat", exist = exist) if (exist) write (u, "(1x,A)") "weight_stream" write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_13" end subroutine commands_13 @ %def commands_13 @ \subsubsection{Compile Empty Libraries} (This is a regression test:) Declare two empty libraries and compile them. <>= call test (commands_14, "commands_14", & "empty libraries", & u, results) <>= public :: commands_14 <>= subroutine commands_14 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_14" write (u, "(A)") "* Purpose: define and compile empty libraries" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_model_file_init () call syntax_cmd_list_init () call global%global_init () write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'model = "Test"') call ifile_append (ifile, 'library = "lib1"') call ifile_append (ifile, 'library = "lib2"') call ifile_append (ifile, 'compile ()') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) call global%prclib_stack%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_14" end subroutine commands_14 @ %def commands_14 @ \subsubsection{Compile Process} Read a model, then declare a process and compile the library. The process library is allocated explicitly. For the process definition, We take the default ([[unit_test]]) method. There is no external code, so compilation of the library is merely a formal status change. <>= call test (commands_15, "commands_15", & "compilation", & u, results) <>= public :: commands_15 <>= subroutine commands_15 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root type(prclib_entry_t), pointer :: lib write (u, "(A)") "* Test output: commands_15" write (u, "(A)") "* Purpose: define process and compile library" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call syntax_model_file_init () call global%global_init () call global%var_list%set_string (var_str ("$method"), & var_str ("unit_test"), is_known=.true.) call global%var_list%set_string (var_str ("$phs_method"), & var_str ("single"), is_known=.true.) call global%var_list%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known=.true.) call global%var_list%set_real (var_str ("sqrts"), & 1000._default, is_known=.true.) call global%var_list%set_log (var_str ("?vis_history"),& .false., is_known=.true.) call global%var_list%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) allocate (lib) call lib%init (var_str ("lib_cmd15")) call global%add_prclib (lib) write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'model = "Test"') call ifile_append (ifile, 'process t15 = s, s => s, s') call ifile_append (ifile, 'iterations = 1:1000') call ifile_append (ifile, 'integrate (t15)') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) call global%prclib_stack%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_15" end subroutine commands_15 @ %def commands_15 @ \subsubsection{Observable} Declare an observable, fill it and display. <>= call test (commands_16, "commands_16", & "observables", & u, results) <>= public :: commands_16 <>= subroutine commands_16 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_16" write (u, "(A)") "* Purpose: declare an observable" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, '$obs_label = "foo"') call ifile_append (ifile, '$obs_unit = "cm"') call ifile_append (ifile, '$title = "Observable foo"') call ifile_append (ifile, '$description = "This is observable foo"') call ifile_append (ifile, 'observable foo') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) write (u, "(A)") "* Record two data items" write (u, "(A)") call analysis_record_data (var_str ("foo"), 1._default) call analysis_record_data (var_str ("foo"), 3._default) write (u, "(A)") "* Display analysis store" write (u, "(A)") call analysis_write (u, verbose=.true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call analysis_final () call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_16" end subroutine commands_16 @ %def commands_16 @ \subsubsection{Histogram} Declare a histogram, fill it and display. <>= call test (commands_17, "commands_17", & "histograms", & u, results) <>= public :: commands_17 <>= subroutine commands_17 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root type(string_t), dimension(3) :: name integer :: i write (u, "(A)") "* Test output: commands_17" write (u, "(A)") "* Purpose: declare histograms" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, '$obs_label = "foo"') call ifile_append (ifile, '$obs_unit = "cm"') call ifile_append (ifile, '$title = "Histogram foo"') call ifile_append (ifile, '$description = "This is histogram foo"') call ifile_append (ifile, 'histogram foo (0,5,1)') call ifile_append (ifile, '$title = "Histogram bar"') call ifile_append (ifile, '$description = "This is histogram bar"') call ifile_append (ifile, 'n_bins = 2') call ifile_append (ifile, 'histogram bar (0,5)') call ifile_append (ifile, '$title = "Histogram gee"') call ifile_append (ifile, '$description = "This is histogram gee"') call ifile_append (ifile, '?normalize_bins = true') call ifile_append (ifile, 'histogram gee (0,5)') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) write (u, "(A)") "* Record two data items" write (u, "(A)") name(1) = "foo" name(2) = "bar" name(3) = "gee" do i = 1, 3 call analysis_record_data (name(i), 0.1_default, & weight = 0.25_default) call analysis_record_data (name(i), 3.1_default) call analysis_record_data (name(i), 4.1_default, & excess = 0.5_default) call analysis_record_data (name(i), 7.1_default) end do write (u, "(A)") "* Display analysis store" write (u, "(A)") call analysis_write (u, verbose=.true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call analysis_final () call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_17" end subroutine commands_17 @ %def commands_17 @ \subsubsection{Plot} Declare a plot, fill it and display contents. <>= call test (commands_18, "commands_18", & "plots", & u, results) <>= public :: commands_18 <>= subroutine commands_18 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_18" write (u, "(A)") "* Purpose: declare a plot" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, '$obs_label = "foo"') call ifile_append (ifile, '$obs_unit = "cm"') call ifile_append (ifile, '$title = "Plot foo"') call ifile_append (ifile, '$description = "This is plot foo"') call ifile_append (ifile, '$x_label = "x axis"') call ifile_append (ifile, '$y_label = "y axis"') call ifile_append (ifile, '?x_log = false') call ifile_append (ifile, '?y_log = true') call ifile_append (ifile, 'x_min = -1') call ifile_append (ifile, 'x_max = 1') call ifile_append (ifile, 'y_min = 0.1') call ifile_append (ifile, 'y_max = 1000') call ifile_append (ifile, 'plot foo') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) write (u, "(A)") "* Record two data items" write (u, "(A)") call analysis_record_data (var_str ("foo"), 0._default, 20._default, & xerr = 0.25_default) call analysis_record_data (var_str ("foo"), 0.5_default, 0.2_default, & yerr = 0.07_default) call analysis_record_data (var_str ("foo"), 3._default, 2._default) write (u, "(A)") "* Display analysis store" write (u, "(A)") call analysis_write (u, verbose=.true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call analysis_final () call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_18" end subroutine commands_18 @ %def commands_18 @ \subsubsection{Graph} Combine two (empty) plots to a graph. <>= call test (commands_19, "commands_19", & "graphs", & u, results) <>= public :: commands_19 <>= subroutine commands_19 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_19" write (u, "(A)") "* Purpose: combine two plots to a graph" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'plot a') call ifile_append (ifile, 'plot b') call ifile_append (ifile, '$title = "Graph foo"') call ifile_append (ifile, '$description = "This is graph foo"') call ifile_append (ifile, 'graph foo = a & b') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) write (u, "(A)") "* Display analysis object" write (u, "(A)") call analysis_write (var_str ("foo"), u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call analysis_final () call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_19" end subroutine commands_19 @ %def commands_19 @ \subsubsection{Record Data} Record data in previously allocated analysis objects. <>= call test (commands_20, "commands_20", & "record data", & u, results) <>= public :: commands_20 <>= subroutine commands_20 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_20" write (u, "(A)") "* Purpose: record data" write (u, "(A)") write (u, "(A)") "* Initialization: create observable, histogram, plot" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () call analysis_init_observable (var_str ("o")) call analysis_init_histogram (var_str ("h"), 0._default, 1._default, 3, & normalize_bins = .false.) call analysis_init_plot (var_str ("p")) write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'record o (1.234)') call ifile_append (ifile, 'record h (0.5)') call ifile_append (ifile, 'record p (1, 2)') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) write (u, "(A)") "* Display analysis object" write (u, "(A)") call analysis_write (u, verbose = .true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call analysis_final () call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_20" end subroutine commands_20 @ %def commands_20 @ \subsubsection{Analysis} Declare an analysis expression and use it to fill an observable during event generation. <>= call test (commands_21, "commands_21", & "analysis expression", & u, results) <>= public :: commands_21 <>= subroutine commands_21 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root type(prclib_entry_t), pointer :: lib write (u, "(A)") "* Test output: commands_21" write (u, "(A)") "* Purpose: create and use analysis expression" write (u, "(A)") write (u, "(A)") "* Initialization: create observable" write (u, "(A)") call syntax_cmd_list_init () call syntax_model_file_init () call global%global_init () call global%init_fallback_model & (var_str ("SM_hadrons"), var_str ("SM_hadrons.mdl")) call global%var_list%set_string (var_str ("$method"), & var_str ("unit_test"), is_known=.true.) call global%var_list%set_string (var_str ("$phs_method"), & var_str ("single"), is_known=.true.) call global%var_list%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known=.true.) call global%var_list%set_log (var_str ("?vis_history"),& .false., is_known=.true.) call global%var_list%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) call global%var_list%set_real (var_str ("sqrts"), & 1000._default, is_known=.true.) allocate (lib) call lib%init (var_str ("lib_cmd8")) call global%add_prclib (lib) call analysis_init_observable (var_str ("m")) write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'model = "Test"') call ifile_append (ifile, 'process commands_21_p = s, s => s, s') call ifile_append (ifile, 'compile') call ifile_append (ifile, 'iterations = 1:100') call ifile_append (ifile, 'integrate (commands_21_p)') call ifile_append (ifile, '?unweighted = true') call ifile_append (ifile, 'n_events = 3') call ifile_append (ifile, '?read_raw = false') call ifile_append (ifile, 'observable m') call ifile_append (ifile, 'analysis = record m (eval M [s])') call ifile_append (ifile, 'simulate (commands_21_p)') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) write (u, "(A)") "* Display analysis object" write (u, "(A)") call analysis_write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call analysis_final () call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_21" end subroutine commands_21 @ %def commands_21 @ \subsubsection{Write Analysis} Write accumulated analysis data to file. <>= call test (commands_22, "commands_22", & "write analysis", & u, results) <>= public :: commands_22 <>= subroutine commands_22 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root integer :: u_file, iostat logical :: exist character(80) :: buffer write (u, "(A)") "* Test output: commands_22" write (u, "(A)") "* Purpose: write analysis data" write (u, "(A)") write (u, "(A)") "* Initialization: create observable" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () call analysis_init_observable (var_str ("m")) call analysis_record_data (var_str ("m"), 125._default) write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, '$out_file = "commands_22.dat"') call ifile_append (ifile, 'write_analysis') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) write (u, "(A)") "* Display analysis data" write (u, "(A)") inquire (file = "commands_22.dat", exist = exist) if (.not. exist) then write (u, "(A)") "ERROR: File commands_22.dat not found" return end if u_file = free_unit () open (u_file, file = "commands_22.dat", & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call analysis_final () call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_22" end subroutine commands_22 @ %def commands_22 @ \subsubsection{Compile Analysis} Write accumulated analysis data to file and compile. <>= call test (commands_23, "commands_23", & "compile analysis", & u, results) <>= public :: commands_23 <>= subroutine commands_23 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root integer :: u_file, iostat character(256) :: buffer logical :: exist type(graph_options_t) :: graph_options write (u, "(A)") "* Test output: commands_23" write (u, "(A)") "* Purpose: write and compile analysis data" write (u, "(A)") write (u, "(A)") "* Initialization: create and fill histogram" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () call graph_options_init (graph_options) call graph_options_set (graph_options, & title = var_str ("Histogram for test: commands 23"), & description = var_str ("This is a test."), & width_mm = 125, height_mm = 85) call analysis_init_histogram (var_str ("h"), & 0._default, 10._default, 2._default, .false., & graph_options = graph_options) call analysis_record_data (var_str ("h"), 1._default) call analysis_record_data (var_str ("h"), 1._default) call analysis_record_data (var_str ("h"), 1._default) call analysis_record_data (var_str ("h"), 1._default) call analysis_record_data (var_str ("h"), 3._default) call analysis_record_data (var_str ("h"), 3._default) call analysis_record_data (var_str ("h"), 3._default) call analysis_record_data (var_str ("h"), 5._default) call analysis_record_data (var_str ("h"), 7._default) call analysis_record_data (var_str ("h"), 7._default) call analysis_record_data (var_str ("h"), 7._default) call analysis_record_data (var_str ("h"), 7._default) call analysis_record_data (var_str ("h"), 9._default) call analysis_record_data (var_str ("h"), 9._default) call analysis_record_data (var_str ("h"), 9._default) call analysis_record_data (var_str ("h"), 9._default) call analysis_record_data (var_str ("h"), 9._default) call analysis_record_data (var_str ("h"), 9._default) call analysis_record_data (var_str ("h"), 9._default) write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, '$out_file = "commands_23.dat"') call ifile_append (ifile, 'compile_analysis') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Delete Postscript output" write (u, "(A)") inquire (file = "commands_23.ps", exist = exist) if (exist) then u_file = free_unit () open (u_file, file = "commands_23.ps", action = "write", status = "old") close (u_file, status = "delete") end if inquire (file = "commands_23.ps", exist = exist) write (u, "(1x,A,L1)") "Postcript output exists = ", exist write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) write (u, "(A)") "* TeX file" write (u, "(A)") inquire (file = "commands_23.tex", exist = exist) if (.not. exist) then write (u, "(A)") "ERROR: File commands_23.tex not found" return end if u_file = free_unit () open (u_file, file = "commands_23.tex", & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, *) inquire (file = "commands_23.ps", exist = exist) write (u, "(1x,A,L1)") "Postcript output exists = ", exist write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call analysis_final () call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_23" end subroutine commands_23 @ %def commands_23 @ \subsubsection{Histogram} Declare a histogram, fill it and display. <>= call test (commands_24, "commands_24", & "drawing options", & u, results) <>= public :: commands_24 <>= subroutine commands_24 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_24" write (u, "(A)") "* Purpose: check graph and drawing options" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, '$title = "Title"') call ifile_append (ifile, '$description = "Description"') call ifile_append (ifile, '$x_label = "X Label"') call ifile_append (ifile, '$y_label = "Y Label"') call ifile_append (ifile, 'graph_width_mm = 111') call ifile_append (ifile, 'graph_height_mm = 222') call ifile_append (ifile, 'x_min = -11') call ifile_append (ifile, 'x_max = 22') call ifile_append (ifile, 'y_min = -33') call ifile_append (ifile, 'y_max = 44') call ifile_append (ifile, '$gmlcode_bg = "GML Code BG"') call ifile_append (ifile, '$gmlcode_fg = "GML Code FG"') call ifile_append (ifile, '$fill_options = "Fill Options"') call ifile_append (ifile, '$draw_options = "Draw Options"') call ifile_append (ifile, '$err_options = "Error Options"') call ifile_append (ifile, '$symbol = "Symbol"') call ifile_append (ifile, 'histogram foo (0,1)') call ifile_append (ifile, 'plot bar') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) write (u, "(A)") "* Display analysis store" write (u, "(A)") call analysis_write (u, verbose=.true.) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call analysis_final () call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_24" end subroutine commands_24 @ %def commands_24 @ \subsubsection{Local Environment} Declare a local environment. <>= call test (commands_25, "commands_25", & "local process environment", & u, results) <>= public :: commands_25 <>= subroutine commands_25 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_25" write (u, "(A)") "* Purpose: declare local environment for process" write (u, "(A)") call syntax_model_file_init () call syntax_cmd_list_init () call global%global_init () call global%var_list%set_log (var_str ("?omega_openmp"), & .false., is_known = .true.) write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'library = "commands_25_lib"') call ifile_append (ifile, 'model = "Test"') call ifile_append (ifile, 'process commands_25_p1 = g, g => g, g & &{ model = "QCD" }') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) call global%write_libraries (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_25" end subroutine commands_25 @ %def commands_25 @ \subsubsection{Alternative Setups} Declare a list of alternative setups. <>= call test (commands_26, "commands_26", & "alternative setups", & u, results) <>= public :: commands_26 <>= subroutine commands_26 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_26" write (u, "(A)") "* Purpose: declare alternative setups for simulation" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'int i = 0') call ifile_append (ifile, 'alt_setup = ({ i = 1 }, { i = 2 })') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) call global%write_expr (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_26" end subroutine commands_26 @ %def commands_26 @ \subsubsection{Unstable Particle} Define decay processes and declare a particle as unstable. Also check the commands stable, polarized, unpolarized. <>= call test (commands_27, "commands_27", & "unstable and polarized particles", & u, results) <>= public :: commands_27 <>= subroutine commands_27 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root type(prclib_entry_t), pointer :: lib write (u, "(A)") "* Test output: commands_27" write (u, "(A)") "* Purpose: modify particle properties" write (u, "(A)") call syntax_cmd_list_init () call syntax_model_file_init () call global%global_init () call global%var_list%set_string (var_str ("$method"), & var_str ("unit_test"), is_known=.true.) call global%var_list%set_string (var_str ("$phs_method"), & var_str ("single"), is_known=.true.) call global%var_list%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known=.true.) call global%var_list%set_log (var_str ("?vis_history"),& .false., is_known=.true.) call global%var_list%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) allocate (lib) call lib%init (var_str ("commands_27_lib")) call global%add_prclib (lib) write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'model = "Test"') call ifile_append (ifile, 'ff = 0.4') call ifile_append (ifile, 'process d1 = s => f, fbar') call ifile_append (ifile, 'unstable s (d1)') call ifile_append (ifile, 'polarized f, fbar') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) write (u, "(A)") "* Show model" write (u, "(A)") call global%model%write (u) write (u, "(A)") write (u, "(A)") "* Extra Input" write (u, "(A)") call ifile_final (ifile) call ifile_append (ifile, '?diagonal_decay = true') call ifile_append (ifile, 'unstable s (d1)') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%final () call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) write (u, "(A)") "* Show model" write (u, "(A)") call global%model%write (u) write (u, "(A)") write (u, "(A)") "* Extra Input" write (u, "(A)") call ifile_final (ifile) call ifile_append (ifile, '?isotropic_decay = true') call ifile_append (ifile, 'unstable s (d1)') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%final () call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) write (u, "(A)") "* Show model" write (u, "(A)") call global%model%write (u) write (u, "(A)") write (u, "(A)") "* Extra Input" write (u, "(A)") call ifile_final (ifile) call ifile_append (ifile, 'stable s') call ifile_append (ifile, 'unpolarized f') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%final () call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) write (u, "(A)") "* Show model" write (u, "(A)") call global%model%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_model_file_init () call syntax_cmd_list_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_27" end subroutine commands_27 @ %def commands_27 @ \subsubsection{Quit the program} Quit the program. <>= call test (commands_28, "commands_28", & "quit", & u, results) <>= public :: commands_28 <>= subroutine commands_28 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root1, pn_root2 type(string_t), dimension(0) :: no_vars write (u, "(A)") "* Test output: commands_28" write (u, "(A)") "* Purpose: quit the program" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () write (u, "(A)") "* Input file: quit without code" write (u, "(A)") call ifile_append (ifile, 'quit') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root1, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root1, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) call global%write (u, vars = no_vars) write (u, "(A)") write (u, "(A)") "* Input file: quit with code" write (u, "(A)") call ifile_final (ifile) call command_list%final () call ifile_append (ifile, 'quit ( 3 + 4 )') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root2, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root2, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) call global%write (u, vars = no_vars) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_28" end subroutine commands_28 @ %def commands_28 @ \subsubsection{SLHA interface} Testing commands steering the SLHA interface. <>= call test (commands_29, "commands_29", & "SLHA interface", & u, results) <>= public :: commands_29 <>= subroutine commands_29 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(var_list_t), pointer :: model_vars type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_29" write (u, "(A)") "* Purpose: test SLHA interface" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call syntax_model_file_init () call syntax_slha_init () call global%global_init () write (u, "(A)") "* Model MSSM, read SLHA file" write (u, "(A)") call ifile_append (ifile, 'model = "MSSM"') call ifile_append (ifile, '?slha_read_decays = true') call ifile_append (ifile, 'read_slha ("sps1ap_decays.slha")') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Model MSSM, default values:" write (u, "(A)") call global%model%write (u, verbose = .false., & show_vertices = .false., show_particles = .false.) write (u, "(A)") write (u, "(A)") "* Selected global variables" write (u, "(A)") model_vars => global%model%get_var_list_ptr () call model_vars%write_var (var_str ("mch1"), u) call model_vars%write_var (var_str ("wch1"), u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) write (u, "(A)") "* Model MSSM, values from SLHA file" write (u, "(A)") call global%model%write (u, verbose = .false., & show_vertices = .false., show_particles = .false.) write (u, "(A)") write (u, "(A)") "* Selected global variables" write (u, "(A)") model_vars => global%model%get_var_list_ptr () call model_vars%write_var (var_str ("mch1"), u) call model_vars%write_var (var_str ("wch1"), u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_slha_final () call syntax_model_file_final () call syntax_cmd_list_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_29" end subroutine commands_29 @ %def commands_29 @ \subsubsection{Expressions for scales} Declare a scale, factorization scale or factorization scale expression. <>= call test (commands_30, "commands_30", & "scales", & u, results) <>= public :: commands_30 <>= subroutine commands_30 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_30" write (u, "(A)") "* Purpose: define scales" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'scale = 200 GeV') call ifile_append (ifile, & 'factorization_scale = eval Pt [particle]') call ifile_append (ifile, & 'renormalization_scale = eval E [particle]') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) call global%write_expr (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_30" end subroutine commands_30 @ %def commands_30 @ \subsubsection{Weight and reweight expressions} Declare an expression for event weights and reweighting. <>= call test (commands_31, "commands_31", & "event weights/reweighting", & u, results) <>= public :: commands_31 <>= subroutine commands_31 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_31" write (u, "(A)") "* Purpose: define weight/reweight" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'weight = eval Pz [particle]') call ifile_append (ifile, 'reweight = eval M2 [particle]') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) call global%write_expr (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_31" end subroutine commands_31 @ %def commands_31 @ \subsubsection{Selecting events} Declare an expression for selecting events in an analysis. <>= call test (commands_32, "commands_32", & "event selection", & u, results) <>= public :: commands_32 <>= subroutine commands_32 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root write (u, "(A)") "* Test output: commands_32" write (u, "(A)") "* Purpose: define selection" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'selection = any PDG == 13 [particle]') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) call global%write_expr (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_32" end subroutine commands_32 @ %def commands_32 @ \subsubsection{Executing shell commands} Execute a shell command. <>= call test (commands_33, "commands_33", & "execute shell command", & u, results) <>= public :: commands_33 <>= subroutine commands_33 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root integer :: u_file, iostat character(3) :: buffer write (u, "(A)") "* Test output: commands_33" write (u, "(A)") "* Purpose: execute shell command" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'exec ("echo foo >> bar")') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root, u) write (u, "(A)") write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) u_file = free_unit () open (u_file, file = "bar", & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (iostat /= 0) exit end do write (u, "(A,A)") "should be 'foo': ", trim (buffer) close (u_file) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call command_list%final () call global%final () call syntax_cmd_list_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_33" end subroutine commands_33 @ %def commands_33 @ \subsubsection{Callback} Instead of an explicit write, use the callback feature to write the analysis file during event generation. We generate 4 events and arrange that the callback is executed while writing the 3rd event. <>= call test (commands_34, "commands_34", & "analysis via callback", & u, results) <>= public :: commands_34 <>= subroutine commands_34 (u) integer, intent(in) :: u type(ifile_t) :: ifile type(command_list_t), target :: command_list type(rt_data_t), target :: global type(parse_node_t), pointer :: pn_root type(prclib_entry_t), pointer :: lib type(event_callback_34_t) :: event_callback write (u, "(A)") "* Test output: commands_34" write (u, "(A)") "* Purpose: write analysis data" write (u, "(A)") write (u, "(A)") "* Initialization: create observable" write (u, "(A)") call syntax_cmd_list_init () call global%global_init () call syntax_model_file_init () call global%global_init () call global%init_fallback_model & (var_str ("SM_hadrons"), var_str ("SM_hadrons.mdl")) call global%var_list%set_string (var_str ("$method"), & var_str ("unit_test"), is_known=.true.) call global%var_list%set_string (var_str ("$phs_method"), & var_str ("single"), is_known=.true.) call global%var_list%set_string (var_str ("$integration_method"),& var_str ("midpoint"), is_known=.true.) call global%var_list%set_real (var_str ("sqrts"), & 1000._default, is_known=.true.) call global%var_list%set_log (var_str ("?vis_history"),& .false., is_known=.true.) call global%var_list%set_log (var_str ("?integration_timer"),& .false., is_known = .true.) allocate (lib) call lib%init (var_str ("lib_cmd34")) call global%add_prclib (lib) write (u, "(A)") "* Prepare callback for writing analysis to I/O unit" write (u, "(A)") event_callback%u = u call global%set_event_callback (event_callback) write (u, "(A)") "* Input file" write (u, "(A)") call ifile_append (ifile, 'model = "Test"') call ifile_append (ifile, 'process commands_34_p = s, s => s, s') call ifile_append (ifile, 'compile') call ifile_append (ifile, 'iterations = 1:1000') call ifile_append (ifile, 'integrate (commands_34_p)') call ifile_append (ifile, 'observable sq') call ifile_append (ifile, 'analysis = record sq (sqrts)') call ifile_append (ifile, 'n_events = 4') call ifile_append (ifile, 'event_callback_interval = 3') call ifile_append (ifile, 'simulate (commands_34_p)') call ifile_write (ifile, u) write (u, "(A)") write (u, "(A)") "* Parse file" write (u, "(A)") call parse_ifile (ifile, pn_root) write (u, "(A)") "* Compile command list" write (u, "(A)") call command_list%compile (pn_root, global) call command_list%write (u) write (u, "(A)") write (u, "(A)") "* Execute command list" write (u, "(A)") call command_list%execute (global) write (u, "(A)") write (u, "(A)") "* Cleanup" call ifile_final (ifile) call analysis_final () call command_list%final () call global%final () call syntax_cmd_list_final () call syntax_model_file_final () write (u, "(A)") write (u, "(A)") "* Test output end: commands_34" end subroutine commands_34 @ %def commands_34 @ For this test, we invent a callback object which simply writes the analysis file, using the standard call for this. Here we rely on the fact that the analysis data are stored as a global entity, otherwise we would have to access them via the event object. <>= type, extends (event_callback_t) :: event_callback_34_t private integer :: u = 0 contains procedure :: write => event_callback_34_write procedure :: proc => event_callback_34 end type event_callback_34_t @ %def event_callback_t @ The output routine is unused. The actual callback should write the analysis data to the output unit that we have injected into the callback object. <>= subroutine event_callback_34_write (event_callback, unit) class(event_callback_34_t), intent(in) :: event_callback integer, intent(in), optional :: unit end subroutine event_callback_34_write subroutine event_callback_34 (event_callback, i, event) class(event_callback_34_t), intent(in) :: event_callback integer(i64), intent(in) :: i class(generic_event_t), intent(in) :: event call analysis_write (event_callback%u) end subroutine event_callback_34 @ %def event_callback_34_write @ %def event_callback_34 @ \clearpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Toplevel module WHIZARD} <<[[whizard.f90]]>>= <> module whizard use io_units <> use system_defs, only: VERSION_STRING use system_defs, only: EOF, BACKSLASH use diagnostics use os_interface use ifiles use lexers use parser use eval_trees use models use phs_forests use prclib_stacks use slha_interface use blha_config use rt_data use commands <> <> <> +<> + save contains <> end module whizard @ %def whizard @ \subsection{Options} Here we introduce a wrapper that holds various user options, so they can transparently be passed from the main program to the [[whizard]] object. Most parameters are used for initializing the [[global]] state. <>= public :: whizard_options_t <>= type :: whizard_options_t type(string_t) :: job_id type(string_t), dimension(:), allocatable :: pack_args type(string_t), dimension(:), allocatable :: unpack_args type(string_t) :: preload_model type(string_t) :: default_lib type(string_t) :: preload_libraries logical :: rebuild_library = .false. logical :: recompile_library = .false. logical :: rebuild_phs = .false. logical :: rebuild_grids = .false. logical :: rebuild_events = .false. end type whizard_options_t @ %def whizard_options_t @ \subsection{Parse tree stack} We collect all parse trees that we generate in the [[whizard]] object. To this end, we create a stack of parse trees. They must not be finalized before the [[global]] object is finalized, because items such as a cut definition may contain references to the parse tree from which they were generated. <>= type, extends (parse_tree_t) :: pt_entry_t type(pt_entry_t), pointer :: previous => null () end type pt_entry_t @ %def pt_entry_t @ This is the stack. Since we always prepend, we just need the [[last]] pointer. <>= type :: pt_stack_t type(pt_entry_t), pointer :: last => null () contains <> end type pt_stack_t @ %def pt_stack_t @ The finalizer is called at the very end. <>= procedure :: final => pt_stack_final <>= subroutine pt_stack_final (pt_stack) class(pt_stack_t), intent(inout) :: pt_stack type(pt_entry_t), pointer :: current do while (associated (pt_stack%last)) current => pt_stack%last pt_stack%last => current%previous call parse_tree_final (current%parse_tree_t) deallocate (current) end do end subroutine pt_stack_final @ %def pt_stack_final @ Create and push a new entry, keeping the previous ones. <>= procedure :: push => pt_stack_push <>= subroutine pt_stack_push (pt_stack, parse_tree) class(pt_stack_t), intent(inout) :: pt_stack type(parse_tree_t), intent(out), pointer :: parse_tree type(pt_entry_t), pointer :: current allocate (current) parse_tree => current%parse_tree_t current%previous => pt_stack%last pt_stack%last => current end subroutine pt_stack_push @ %def pt_stack_push @ \subsection{The [[whizard]] object} An object of type [[whizard_t]] is the top-level wrapper for a \whizard\ instance. The object holds various default settings and the current state of the generator, the [[global]] object of type [[rt_data_t]]. This object contains, for instance, the list of variables and the process libraries. Since components of the [[global]] subobject are frequently used as targets, the [[whizard]] object should also consistently carry the [[target]] attribute. The various self-tests do no not use this object. They initialize only specific subsets of the system, according to their needs. Note: we intend to allow several concurrent instances. In the current implementation, there are still a few obstacles to this: the model library and the syntax tables are global variables, and the error handling uses global state. This should be improved. <>= public :: whizard_t <>= type :: whizard_t type(whizard_options_t) :: options type(rt_data_t) :: global type(pt_stack_t) :: pt_stack contains <> end type whizard_t @ %def whizard_t @ \subsection{Initialization and finalization} <>= procedure :: init => whizard_init <>= subroutine whizard_init (whizard, options, paths, logfile) class(whizard_t), intent(out), target :: whizard type(whizard_options_t), intent(in) :: options type(paths_t), intent(in), optional :: paths type(string_t), intent(in), optional :: logfile call init_syntax_tables () whizard%options = options call whizard%global%global_init (paths, logfile) call whizard%init_job_id () call whizard%init_rebuild_flags () call whizard%unpack_files () call whizard%preload_model () call whizard%preload_library () call whizard%global%init_fallback_model & (var_str ("SM_hadrons"), var_str ("SM_hadrons.mdl")) end subroutine whizard_init @ %def whizard_init @ Apart from the global data which have been initialized above, the process and model lists need to be finalized. <>= procedure :: final => whizard_final <>= subroutine whizard_final (whizard) class(whizard_t), intent(inout), target :: whizard call whizard%global%final () call whizard%pt_stack%final () call whizard%pack_files () call final_syntax_tables () end subroutine whizard_final @ %def whizard_final @ Set the job ID, if nonempty. If the ID string is empty, the value remains undefined. <>= procedure :: init_job_id => whizard_init_job_id <>= subroutine whizard_init_job_id (whizard) class(whizard_t), intent(inout), target :: whizard associate (var_list => whizard%global%var_list, options => whizard%options) if (options%job_id /= "") then call var_list%set_string (var_str ("$job_id"), & options%job_id, is_known=.true.) end if end associate end subroutine whizard_init_job_id @ %def whizard_init_job_id @ Set the rebuild flags. They can be specified on the command line and set the initial value for the associated logical variables. <>= procedure :: init_rebuild_flags => whizard_init_rebuild_flags <>= subroutine whizard_init_rebuild_flags (whizard) class(whizard_t), intent(inout), target :: whizard associate (var_list => whizard%global%var_list, options => whizard%options) call var_list%append_log (var_str ("?rebuild_library"), & options%rebuild_library, intrinsic=.true.) call var_list%append_log (var_str ("?recompile_library"), & options%recompile_library, intrinsic=.true.) call var_list%append_log (var_str ("?rebuild_phase_space"), & options%rebuild_phs, intrinsic=.true.) call var_list%append_log (var_str ("?rebuild_grids"), & options%rebuild_grids, intrinsic=.true.) call var_list%append_log (var_str ("?powheg_rebuild_grids"), & options%rebuild_grids, intrinsic=.true.) call var_list%append_log (var_str ("?rebuild_events"), & options%rebuild_events, intrinsic=.true.) end associate end subroutine whizard_init_rebuild_flags @ %def whizard_init_rebuild_flags @ Pack/unpack files in the working directory, if requested. <>= procedure :: pack_files => whizard_pack_files procedure :: unpack_files => whizard_unpack_files <>= subroutine whizard_pack_files (whizard) class(whizard_t), intent(in), target :: whizard logical :: exist integer :: i type(string_t) :: file if (allocated (whizard%options%pack_args)) then do i = 1, size (whizard%options%pack_args) file = whizard%options%pack_args(i) call msg_message ("Packing file/dir '" // char (file) // "'") exist = os_file_exist (file) .or. os_dir_exist (file) if (exist) then call os_pack_file (whizard%options%pack_args(i), & whizard%global%os_data) else call msg_error ("File/dir '" // char (file) // "' not found") end if end do end if end subroutine whizard_pack_files subroutine whizard_unpack_files (whizard) class(whizard_t), intent(in), target :: whizard logical :: exist integer :: i type(string_t) :: file if (allocated (whizard%options%unpack_args)) then do i = 1, size (whizard%options%unpack_args) file = whizard%options%unpack_args(i) call msg_message ("Unpacking file '" // char (file) // "'") exist = os_file_exist (file) if (exist) then call os_unpack_file (whizard%options%unpack_args(i), & whizard%global%os_data) else call msg_error ("File '" // char (file) // "' not found") end if end do end if end subroutine whizard_unpack_files @ %def whizard_pack_files @ %def whizard_unpack_files @ This procedure preloads a model, if a model name is given. <>= procedure :: preload_model => whizard_preload_model <>= subroutine whizard_preload_model (whizard) class(whizard_t), intent(inout), target :: whizard type(string_t) :: model_name model_name = whizard%options%preload_model if (model_name /= "") then call whizard%global%read_model (model_name, whizard%global%preload_model) whizard%global%model => whizard%global%preload_model if (associated (whizard%global%model)) then call whizard%global%model%link_var_list (whizard%global%var_list) + call whizard%global%var_list%set_string (var_str ("$model_name"), & + model_name, is_known = .true.) call msg_message ("Preloaded model: " & // char (model_name)) else call msg_fatal ("Preloading model " // char (model_name) & // " failed") end if else call msg_message ("No model preloaded") end if end subroutine whizard_preload_model @ %def whizard_preload_model @ This procedure preloads a library, if a library name is given. Note: This version just opens a new library with that name. It does not load (yet) an existing library on file, as previous \whizard\ versions would do. <>= procedure :: preload_library => whizard_preload_library <>= subroutine whizard_preload_library (whizard) class(whizard_t), intent(inout), target :: whizard type(string_t) :: library_name, libs type(string_t), dimension(:), allocatable :: libname_static type(prclib_entry_t), pointer :: lib_entry integer :: i call get_prclib_static (libname_static) do i = 1, size (libname_static) allocate (lib_entry) call lib_entry%init_static (libname_static(i)) call whizard%global%add_prclib (lib_entry) end do libs = adjustl (whizard%options%preload_libraries) if (libs == "" .and. whizard%options%default_lib /= "") then - allocate (lib_entry) - call lib_entry%init (whizard%options%default_lib) - call whizard%global%add_prclib (lib_entry) - call msg_message ("Preloaded library: " // & - char (whizard%options%default_lib)) - end if + allocate (lib_entry) + call lib_entry%init (whizard%options%default_lib) + call whizard%global%add_prclib (lib_entry) + call msg_message ("Preloaded library: " // & + char (whizard%options%default_lib)) + end if SCAN_LIBS: do while (libs /= "") call split (libs, library_name, " ") if (library_name /= "") then allocate (lib_entry) call lib_entry%init (library_name) call whizard%global%add_prclib (lib_entry) call msg_message ("Preloaded library: " // char (library_name)) end if end do SCAN_LIBS end subroutine whizard_preload_library @ %def whizard_preload_library @ -\subsection{Initialization and finalization (old version)} -These procedures initialize and finalize global variables. Most of -them are collected in the [[global]] data record located here, the -others are syntax tables located in various modules, which do not -change during program execution. Furthermore, there is a global model -list and a global process store, which get filled during program -execution but are finalized here. - -During initialization, we can preload a default model and initialize a -default library for setting up processes. The default library is -loaded if requested by the setup. Further libraries can be loaded as -specified by command-line flags. -@ Initialize/finalize the syntax tables used by WHIZARD: +\subsection{Initialization and finalization: syntax tables} +Initialize/finalize the syntax tables used by WHIZARD. These are effectively +singleton objects. We introduce a module variable that tracks the +initialization status. + +Without syntax tables, essentially nothing will work. Any initializer has to +call this. +<>= + logical :: syntax_tables_exist = .false. +@ %def syntax_tables_exist +@ <>= public :: init_syntax_tables public :: final_syntax_tables <>= subroutine init_syntax_tables () - call syntax_model_file_init () - call syntax_phs_forest_init () - call syntax_pexpr_init () - call syntax_slha_init () - call syntax_cmd_list_init () + if (.not. syntax_tables_exist) then + call syntax_model_file_init () + call syntax_phs_forest_init () + call syntax_pexpr_init () + call syntax_slha_init () + call syntax_cmd_list_init () + syntax_tables_exist = .true. + end if end subroutine init_syntax_tables subroutine final_syntax_tables () - call syntax_model_file_final () - call syntax_phs_forest_final () - call syntax_pexpr_final () - call syntax_slha_final () - call syntax_cmd_list_final () + if (syntax_tables_exist) then + call syntax_model_file_final () + call syntax_phs_forest_final () + call syntax_pexpr_final () + call syntax_slha_final () + call syntax_cmd_list_final () + syntax_tables_exist = .false. + end if end subroutine final_syntax_tables @ %def init_syntax_tables @ %def final_syntax_tables @ Write the syntax tables to external files. <>= public :: write_syntax_tables <>= subroutine write_syntax_tables () integer :: unit character(*), parameter :: file_model = "whizard.model_file.syntax" character(*), parameter :: file_phs = "whizard.phase_space_file.syntax" character(*), parameter :: file_pexpr = "whizard.prt_expressions.syntax" character(*), parameter :: file_slha = "whizard.slha.syntax" character(*), parameter :: file_sindarin = "whizard.sindarin.syntax" + if (.not. syntax_tables_exist) call init_syntax_tables () unit = free_unit () print *, "Writing file '" // file_model // "'" open (unit=unit, file=file_model, status="replace", action="write") write (unit, "(A)") VERSION_STRING write (unit, "(A)") "Syntax definition file: " // file_model call syntax_model_file_write (unit) close (unit) print *, "Writing file '" // file_phs // "'" open (unit=unit, file=file_phs, status="replace", action="write") write (unit, "(A)") VERSION_STRING write (unit, "(A)") "Syntax definition file: " // file_phs call syntax_phs_forest_write (unit) close (unit) print *, "Writing file '" // file_pexpr // "'" open (unit=unit, file=file_pexpr, status="replace", action="write") write (unit, "(A)") VERSION_STRING write (unit, "(A)") "Syntax definition file: " // file_pexpr call syntax_pexpr_write (unit) close (unit) print *, "Writing file '" // file_slha // "'" open (unit=unit, file=file_slha, status="replace", action="write") write (unit, "(A)") VERSION_STRING write (unit, "(A)") "Syntax definition file: " // file_slha call syntax_slha_write (unit) close (unit) print *, "Writing file '" // file_sindarin // "'" open (unit=unit, file=file_sindarin, status="replace", action="write") write (unit, "(A)") VERSION_STRING write (unit, "(A)") "Syntax definition file: " // file_sindarin call syntax_cmd_list_write (unit) close (unit) end subroutine write_syntax_tables @ %def write_syntax_tables @ \subsection{Execute command lists} Process commands given on the command line, stored as an [[ifile]]. The whole input is read, compiled and executed as a whole. <>= procedure :: process_ifile => whizard_process_ifile <>= subroutine whizard_process_ifile (whizard, ifile, quit, quit_code) class(whizard_t), intent(inout), target :: whizard type(ifile_t), intent(in) :: ifile logical, intent(out) :: quit integer, intent(out) :: quit_code type(lexer_t), target :: lexer type(stream_t), target :: stream call msg_message ("Reading commands given on the command line") call lexer_init_cmd_list (lexer) call stream_init (stream, ifile) call whizard%process_stream (stream, lexer, quit, quit_code) call stream_final (stream) call lexer_final (lexer) end subroutine whizard_process_ifile @ %def whizard_process_ifile @ Process standard input as a command list. The whole input is read, compiled and executed as a whole. <>= procedure :: process_stdin => whizard_process_stdin <>= subroutine whizard_process_stdin (whizard, quit, quit_code) class(whizard_t), intent(inout), target :: whizard logical, intent(out) :: quit integer, intent(out) :: quit_code type(lexer_t), target :: lexer type(stream_t), target :: stream call msg_message ("Reading commands from standard input") call lexer_init_cmd_list (lexer) call stream_init (stream, 5) call whizard%process_stream (stream, lexer, quit, quit_code) call stream_final (stream) call lexer_final (lexer) end subroutine whizard_process_stdin @ %def whizard_process_stdin @ Process a file as a command list. <>= procedure :: process_file => whizard_process_file <>= subroutine whizard_process_file (whizard, file, quit, quit_code) class(whizard_t), intent(inout), target :: whizard type(string_t), intent(in) :: file logical, intent(out) :: quit integer, intent(out) :: quit_code type(lexer_t), target :: lexer type(stream_t), target :: stream logical :: exist call msg_message ("Reading commands from file '" // char (file) // "'") inquire (file=char(file), exist=exist) if (exist) then call lexer_init_cmd_list (lexer) call stream_init (stream, char (file)) call whizard%process_stream (stream, lexer, quit, quit_code) call stream_final (stream) call lexer_final (lexer) else call msg_error ("File '" // char (file) // "' not found") end if end subroutine whizard_process_file @ %def whizard_process_file @ <>= procedure :: process_stream => whizard_process_stream <>= subroutine whizard_process_stream (whizard, stream, lexer, quit, quit_code) class(whizard_t), intent(inout), target :: whizard type(stream_t), intent(inout), target :: stream type(lexer_t), intent(inout), target :: lexer logical, intent(out) :: quit integer, intent(out) :: quit_code type(parse_tree_t), pointer :: parse_tree type(command_list_t), target :: command_list call lexer_assign_stream (lexer, stream) call whizard%pt_stack%push (parse_tree) call parse_tree_init (parse_tree, syntax_cmd_list, lexer) if (associated (parse_tree%get_root_ptr ())) then whizard%global%lexer => lexer call command_list%compile (parse_tree%get_root_ptr (), & whizard%global) end if call whizard%global%activate () call command_list%execute (whizard%global) call command_list%final () quit = whizard%global%quit quit_code = whizard%global%quit_code end subroutine whizard_process_stream @ %def whizard_process_stream @ \subsection{The WHIZARD shell} This procedure implements interactive mode. One line is processed at a time. <>= procedure :: shell => whizard_shell <>= subroutine whizard_shell (whizard, quit_code) class(whizard_t), intent(inout), target :: whizard integer, intent(out) :: quit_code type(lexer_t), target :: lexer type(stream_t), target :: stream type(string_t) :: prompt1 type(string_t) :: prompt2 type(string_t) :: input type(string_t) :: extra integer :: last integer :: iostat logical :: mask_tmp logical :: quit call msg_message ("Launching interactive shell") call lexer_init_cmd_list (lexer) prompt1 = "whish? " prompt2 = " > " COMMAND_LOOP: do call put (6, prompt1) call get (5, input, iostat=iostat) if (iostat > 0 .or. iostat == EOF) exit COMMAND_LOOP CONTINUE_INPUT: do last = len_trim (input) if (extract (input, last, last) /= BACKSLASH) exit CONTINUE_INPUT call put (6, prompt2) call get (5, extra, iostat=iostat) if (iostat > 0) exit COMMAND_LOOP input = replace (input, last, extra) end do CONTINUE_INPUT call stream_init (stream, input) mask_tmp = mask_fatal_errors mask_fatal_errors = .true. call whizard%process_stream (stream, lexer, quit, quit_code) msg_count = 0 mask_fatal_errors = mask_tmp call stream_final (stream) if (quit) exit COMMAND_LOOP end do COMMAND_LOOP print * call lexer_final (lexer) end subroutine whizard_shell @ %def whizard_shell @ \clearpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{Tools for the command line} - -We do not intent to be very smart here, but this module provides a few -small tools that simplify dealing with the command line. - -The [[unquote_value]] subroutine handles an option value that begins with a -single/double quote character. It swallows extra option strings until it -finds a value that ends with another quote character. The returned string -consists of all argument strings between quotes, concatenated by blanks (with -a leading blank). Note that more complex patterns, such as quoted or embedded -quotes, or multiple blanks, are not accounted for. -<<[[cmdline_options.f90]]>>= -<> - -module cmdline_options - -<> - use diagnostics - -<> - - public :: init_options - public :: no_option_value - public :: get_option_value - -<> - - abstract interface - subroutine msg - end subroutine msg - end interface - - procedure (msg), pointer :: print_usage => null () - -contains - - subroutine init_options (usage_msg) - procedure (msg) :: usage_msg - print_usage => usage_msg - end subroutine init_options - - subroutine no_option_value (option, value) - type(string_t), intent(in) :: option, value - if (value /= "") then - call msg_error (" Option '" // char (option) // "' should have no value") - end if - end subroutine no_option_value - - function get_option_value (i, option, value) result (string) - type(string_t) :: string - integer, intent(inout) :: i - type(string_t), intent(in) :: option - type(string_t), intent(in), optional :: value - character(CMDLINE_ARG_LEN) :: arg_value - integer :: arg_len, arg_status - logical :: has_value - if (present (value)) then - has_value = value /= "" - else - has_value = .false. - end if - if (has_value) then - call unquote_value (i, option, value, string) - else - i = i + 1 - call get_command_argument (i, arg_value, arg_len, arg_status) - select case (arg_status) - case (0) - case (-1) - call msg_error (" Option value truncated: '" // arg_value // "'") - case default - call print_usage () - call msg_fatal (" Option '" // char (option) // "' needs a value") - end select - select case (arg_value(1:1)) - case ("-") - call print_usage () - call msg_fatal (" Option '" // char (option) // "' needs a value") - end select - call unquote_value (i, option, var_str (trim (arg_value)), string) - end if - end function get_option_value - - subroutine unquote_value (i, option, value, string) - integer, intent(inout) :: i - type(string_t), intent(in) :: option - type(string_t), intent(in) :: value - type(string_t), intent(out) :: string - character(1) :: quote - character(CMDLINE_ARG_LEN) :: arg_value - integer :: arg_len, arg_status - quote = extract (value, 1, 1) - select case (quote) - case ("'", '"') - string = "" - arg_value = extract (value, 2) - arg_len = len_trim (value) - APPEND_QUOTED: do - if (extract (arg_value, arg_len, arg_len) == quote) then - string = string // " " // extract (arg_value, 1, arg_len-1) - exit APPEND_QUOTED - else - string = string // " " // trim (arg_value) - i = i + 1 - call get_command_argument (i, arg_value, arg_len, arg_status) - select case (arg_status) - case (0) - case (-1) - call msg_error (" Quoted option value truncated: '" & - // char (string) // "'") - case default - call print_usage () - call msg_fatal (" Option '" // char (option) & - // "': unterminated quoted value") - end select - end if - end do APPEND_QUOTED - case default - string = value - end select - end subroutine unquote_value - -end module cmdline_options - -@ %def init_options -@ %def no_option_value -@ %def get_option_value -@ %def cmdline_options -@ -\clearpage -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Query Feature Support} This module accesses the various optional features (modules) that WHIZARD can support and repors on their availability. <<[[features.f90]]>>= module features use string_utils, only: lower_case use system_dependencies, only: WHIZARD_VERSION <> <> <> contains <> end module features @ %def features @ \subsection{Output} <>= public :: print_features <>= subroutine print_features () print "(A)", "WHIZARD " // WHIZARD_VERSION print "(A)", "Build configuration:" <> print "(A)", "Optional features available in this build:" <> end subroutine print_features @ %def print_features @ \subsection{Query function} <>= subroutine check (feature, recognized, result, help) character(*), intent(in) :: feature logical, intent(out) :: recognized character(*), intent(out) :: result, help recognized = .true. result = "no" select case (lower_case (trim (feature))) <> case default recognized = .false. end select end subroutine check @ %def check @ Print this result: <>= subroutine print_check (feature) character(*), intent(in) :: feature character(16) :: f logical :: recognized character(10) :: result character(48) :: help call check (feature, recognized, result, help) if (.not. recognized) then result = "unknown" help = "" end if f = feature print "(2x,A,1x,A,'(',A,')')", f, result, trim (help) end subroutine print_check @ %def print_check @ \subsection{Basic configuration} <>= call print_check ("precision") <>= use kinds, only: default <>= case ("precision") write (result, "(I0)") precision (1._default) help = "significant decimals of real/complex numbers" @ \subsection{Optional features case by case} <>= call print_check ("OpenMP") <>= use system_dependencies, only: openmp_is_active <>= case ("openmp") if (openmp_is_active ()) then result = "yes" end if help = "OpenMP parallel execution" @ <>= call print_check ("GoSam") <>= use system_dependencies, only: GOSAM_AVAILABLE <>= case ("gosam") if (GOSAM_AVAILABLE) then result = "yes" end if help = "external NLO matrix element provider" @ <>= call print_check ("OpenLoops") <>= use system_dependencies, only: OPENLOOPS_AVAILABLE <>= case ("openloops") if (OPENLOOPS_AVAILABLE) then result = "yes" end if help = "external NLO matrix element provider" @ <>= call print_check ("Recola") <>= use system_dependencies, only: RECOLA_AVAILABLE <>= case ("recola") if (RECOLA_AVAILABLE) then result = "yes" end if help = "external NLO matrix element provider" @ <>= call print_check ("LHAPDF") <>= use system_dependencies, only: LHAPDF5_AVAILABLE use system_dependencies, only: LHAPDF6_AVAILABLE <>= case ("lhapdf") if (LHAPDF5_AVAILABLE) then result = "v5" else if (LHAPDF6_AVAILABLE) then result = "v6" end if help = "PDF library" @ <>= call print_check ("HOPPET") <>= use system_dependencies, only: HOPPET_AVAILABLE <>= case ("hoppet") if (HOPPET_AVAILABLE) then result = "yes" end if help = "PDF evolution package" @ <>= call print_check ("fastjet") <>= use jets, only: fastjet_available <>= case ("fastjet") if (fastjet_available ()) then result = "yes" end if help = "jet-clustering package" @ <>= call print_check ("Pythia6") <>= use system_dependencies, only: PYTHIA6_AVAILABLE <>= case ("pythia6") if (PYTHIA6_AVAILABLE) then result = "yes" end if help = "direct access for shower/hadronization" @ <>= call print_check ("Pythia8") <>= use system_dependencies, only: PYTHIA8_AVAILABLE <>= case ("pythia8") if (PYTHIA8_AVAILABLE) then result = "yes" end if help = "direct access for shower/hadronization" @ <>= call print_check ("StdHEP") <>= case ("stdhep") result = "yes" help = "event I/O format" @ <>= call print_check ("HepMC") <>= use hepmc_interface, only: hepmc_is_available <>= case ("hepmc") if (hepmc_is_available ()) then result = "yes" end if help = "event I/O format" @ <>= call print_check ("LCIO") <>= use lcio_interface, only: lcio_is_available <>= case ("lcio") if (lcio_is_available ()) then result = "yes" end if help = "event I/O format" @ <>= call print_check ("MetaPost") <>= use system_dependencies, only: EVENT_ANALYSIS <>= case ("metapost") result = EVENT_ANALYSIS help = "graphical event analysis via LaTeX/MetaPost" -@ -@ -\clearpage +@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{Driver program} -The main program handles command options, initializes the environment, -and runs WHIZARD in a particular mode (interactive, file, standard -input). - -This is also used in the C interface: -<>= - integer, parameter :: CMDLINE_ARG_LEN = 1000 -@ %def CMDLINE_ARG_LEN -@ -The actual main program: -<<[[main.f90]]>>= -<> - -program main - -<> - use system_dependencies - use diagnostics - use ifiles - use os_interface - use rt_data, only: show_description_of_string, show_tex_descriptions - use whizard - - use cmdline_options - use features - -<> - - implicit none - -<> - -!!! (WK 02/2016) Interface for the separate external routine below - interface - subroutine print_usage () - end subroutine print_usage - end interface - -! Main program variable declarations - character(CMDLINE_ARG_LEN) :: arg - character(2) :: option - type(string_t) :: long_option, value - integer :: i, j, arg_len, arg_status - logical :: look_for_options - logical :: interactive - logical :: banner - type(string_t) :: job_id, files, this, model, default_lib, library, libraries - type(string_t) :: logfile, query_string - type(paths_t) :: paths - type(string_t) :: pack_arg, unpack_arg - type(string_t), dimension(:), allocatable :: pack_args, unpack_args - type(string_t), dimension(:), allocatable :: tmp_strings - logical :: rebuild_library - logical :: rebuild_phs, rebuild_grids, rebuild_events - logical :: recompile_library - type(ifile_t) :: commands - type(string_t) :: command, cmdfile - integer :: cmdfile_unit - logical :: cmdfile_exists - - type(whizard_options_t), allocatable :: options - type(whizard_t), allocatable, target :: whizard_instance - - ! Exit status - logical :: quit = .false. - integer :: quit_code = 0 - - ! Initial values - look_for_options = .true. - interactive = .false. - job_id = "" - files = "" - model = "SM" - default_lib = "default_lib" - library = "" - libraries = "" - banner = .true. - logging = .true. - msg_level = RESULT - logfile = "whizard.log" - rebuild_library = .false. - rebuild_phs = .false. - rebuild_grids = .false. - rebuild_events = .false. - recompile_library = .false. - call paths_init (paths) - -<> - - ! Read and process options - call init_options (print_usage) - i = 0 - SCAN_CMDLINE: do - i = i + 1 - call get_command_argument (i, arg, arg_len, arg_status) - select case (arg_status) - case (0) - case (-1) - call msg_error (" Command argument truncated: '" // arg // "'") - case default - exit SCAN_CMDLINE - end select - if (look_for_options) then - select case (arg(1:2)) - case ("--") - value = trim (arg) - call split (value, long_option, "=") - select case (char (long_option)) - case ("--version") - call no_option_value (long_option, value) - call print_version (); stop - case ("--help") - call no_option_value (long_option, value) - call print_usage (); stop - case ("--prefix") - paths%prefix = get_option_value (i, long_option, value) - cycle scan_cmdline - case ("--exec-prefix") - paths%exec_prefix = get_option_value (i, long_option, value) - cycle SCAN_CMDLINE - case ("--bindir") - paths%bindir = get_option_value (i, long_option, value) - cycle SCAN_CMDLINE - case ("--libdir") - paths%libdir = get_option_value (i, long_option, value) - cycle SCAN_CMDLINE - case ("--includedir") - paths%includedir = get_option_value (i, long_option, value) - cycle SCAN_CMDLINE - case ("--datarootdir") - paths%datarootdir = get_option_value (i, long_option, value) - cycle SCAN_CMDLINE - case ("--libtool") - paths%libtool = get_option_value (i, long_option, value) - cycle SCAN_CMDLINE - case ("--lhapdfdir") - paths%lhapdfdir = get_option_value (i, long_option, value) - cycle SCAN_CMDLINE - case ("--check") - call print_usage () - call msg_fatal ("Option --check not supported & - &(for unit tests, run whizard_ut instead)") - case ("--show-config") - call no_option_value (long_option, value) - call print_features (); stop - case ("--execute") - command = get_option_value (i, long_option, value) - call ifile_append (commands, command) - cycle SCAN_CMDLINE - case ("--file") - cmdfile = get_option_value (i, long_option, value) - inquire (file=char(cmdfile), exist=cmdfile_exists) - if (cmdfile_exists) then - open (newunit=cmdfile_unit, file=char(cmdfile), & - action="read", status="old") - call ifile_append (commands, cmdfile_unit) - close (cmdfile_unit) - else - call msg_error & - ("Sindarin file '" // char (cmdfile) // "' not found") - end if - cycle SCAN_CMDLINE - case ("--interactive") - call no_option_value (long_option, value) - interactive = .true. - cycle SCAN_CMDLINE - case ("--job-id") - job_id = get_option_value (i, long_option, value) - cycle SCAN_CMDLINE - case ("--library") - library = get_option_value (i, long_option, value) - libraries = libraries // " " // library - cycle SCAN_CMDLINE - case ("--no-library") - call no_option_value (long_option, value) - default_lib = "" - library = "" - libraries = "" - cycle SCAN_CMDLINE - case ("--localprefix") - paths%localprefix = get_option_value (i, long_option, value) - cycle SCAN_CMDLINE - case ("--logfile") - logfile = get_option_value (i, long_option, value) - cycle SCAN_CMDLINE - case ("--no-logfile") - call no_option_value (long_option, value) - logfile = "" - cycle SCAN_CMDLINE - case ("--logging") - call no_option_value (long_option, value) - logging = .true. - cycle SCAN_CMDLINE - case ("--no-logging") - call no_option_value (long_option, value) - logging = .false. - cycle SCAN_CMDLINE - case ("--query") - call no_option_value (long_option, value) - query_string = get_option_value (i, long_option, value) - call show_description_of_string (query_string) - call exit (0) - case ("--generate-variables-tex") - call no_option_value (long_option, value) - call show_tex_descriptions () - call exit (0) - case ("--debug") - call no_option_value (long_option, value) - call set_debug_levels (get_option_value (i, long_option, value)) - cycle SCAN_CMDLINE - case ("--debug2") - call no_option_value (long_option, value) - call set_debug2_levels (get_option_value (i, long_option, value)) - cycle SCAN_CMDLINE - case ("--single-event") - call no_option_value (long_option, value) - single_event = .true. - cycle SCAN_CMDLINE - case ("--banner") - call no_option_value (long_option, value) - banner = .true. - cycle SCAN_CMDLINE - case ("--no-banner") - call no_option_value (long_option, value) - banner = .false. - cycle SCAN_CMDLINE - case ("--pack") - pack_arg = get_option_value (i, long_option, value) - if (allocated (pack_args)) then - call move_alloc (from=pack_args, to=tmp_strings) - allocate (pack_args (size (tmp_strings)+1)) - pack_args(1:size(tmp_strings)) = tmp_strings - else - allocate (pack_args (1)) - end if - pack_args(size(pack_args)) = pack_arg - cycle SCAN_CMDLINE - case ("--unpack") - unpack_arg = get_option_value (i, long_option, value) - if (allocated (unpack_args)) then - call move_alloc (from=unpack_args, to=tmp_strings) - allocate (unpack_args (size (tmp_strings)+1)) - unpack_args(1:size(tmp_strings)) = tmp_strings - else - allocate (unpack_args (1)) - end if - unpack_args(size(unpack_args)) = unpack_arg - cycle SCAN_CMDLINE - case ("--model") - model = get_option_value (i, long_option, value) - cycle SCAN_CMDLINE - case ("--no-model") - call no_option_value (long_option, value) - model = "" - cycle SCAN_CMDLINE - case ("--rebuild") - call no_option_value (long_option, value) - rebuild_library = .true. - rebuild_phs = .true. - rebuild_grids = .true. - rebuild_events = .true. - cycle SCAN_CMDLINE - case ("--no-rebuild") - call no_option_value (long_option, value) - rebuild_library = .false. - recompile_library = .false. - rebuild_phs = .false. - rebuild_grids = .false. - rebuild_events = .false. - cycle SCAN_CMDLINE - case ("--rebuild-library") - call no_option_value (long_option, value) - rebuild_library = .true. - cycle SCAN_CMDLINE - case ("--rebuild-phase-space") - call no_option_value (long_option, value) - rebuild_phs = .true. - cycle SCAN_CMDLINE - case ("--rebuild-grids") - call no_option_value (long_option, value) - rebuild_grids = .true. - cycle SCAN_CMDLINE - case ("--rebuild-events") - call no_option_value (long_option, value) - rebuild_events = .true. - cycle SCAN_CMDLINE - case ("--recompile") - call no_option_value (long_option, value) - recompile_library = .true. - rebuild_grids = .true. - cycle SCAN_CMDLINE - case ("--write-syntax-tables") - call no_option_value (long_option, value) - call init_syntax_tables () - call write_syntax_tables () - call final_syntax_tables () - stop - cycle SCAN_CMDLINE - case default - call print_usage () - call msg_fatal ("Option '" // trim (arg) // "' not recognized") - end select - end select - select case (arg(1:1)) - case ("-") - j = 1 - if (len_trim (arg) == 1) then - look_for_options = .false. - else - SCAN_SHORT_OPTIONS: do - j = j + 1 - if (j > len_trim (arg)) exit SCAN_SHORT_OPTIONS - option = "-" // arg(j:j) - select case (option) - case ("-V") - call print_version (); stop - case ("-?", "-h") - call print_usage (); stop - case ("-e") - command = get_option_value (i, var_str (option)) - call ifile_append (commands, command) - cycle SCAN_CMDLINE - case ("-f") - cmdfile = get_option_value (i, var_str (option)) - inquire (file=char(cmdfile), exist=cmdfile_exists) - if (cmdfile_exists) then - open (newunit=cmdfile_unit, file=char(cmdfile), & - action="read", status="old") - call ifile_append (commands, cmdfile_unit) - close (cmdfile_unit) - else - call msg_error ("Sindarin file '" & - // char (cmdfile) // "' not found") - end if - cycle SCAN_CMDLINE - case ("-i") - interactive = .true. - cycle SCAN_SHORT_OPTIONS - case ("-J") - if (j == len_trim (arg)) then - job_id = get_option_value (i, var_str (option)) - else - job_id = trim (arg(j+1:)) - end if - cycle SCAN_CMDLINE - case ("-l") - if (j == len_trim (arg)) then - library = get_option_value (i, var_str (option)) - else - library = trim (arg(j+1:)) - end if - libraries = libraries // " " // library - cycle SCAN_CMDLINE - case ("-L") - if (j == len_trim (arg)) then - logfile = get_option_value (i, var_str (option)) - else - logfile = trim (arg(j+1:)) - end if - cycle SCAN_CMDLINE - case ("-m") - if (j < len_trim (arg)) call msg_fatal & - ("Option '" // option // "' needs a value") - model = get_option_value (i, var_str (option)) - cycle SCAN_CMDLINE - case ("-q") - call no_option_value (long_option, value) - query_string = get_option_value (i, long_option, value) - call show_description_of_string (query_string) - call exit (0) - case ("-r") - rebuild_library = .true. - rebuild_phs = .true. - rebuild_grids = .true. - rebuild_events = .true. - cycle SCAN_SHORT_OPTIONS - case default - call print_usage () - call msg_fatal & - ("Option '" // option // "' not recognized") - end select - end do SCAN_SHORT_OPTIONS - end if - case default - files = files // " " // trim (arg) - end select - else - files = files // " " // trim (arg) - end if - end do SCAN_CMDLINE - - ! Overall initialization - if (logfile /= "") call logfile_init (logfile) - if (banner) call msg_banner () - - allocate (options) - allocate (whizard_instance) - - if (.not. quit) then - - ! Set options and initialize the whizard object - options%job_id = job_id - if (allocated (pack_args)) then - options%pack_args = pack_args - else - allocate (options%pack_args (0)) - end if - if (allocated (unpack_args)) then - options%unpack_args = unpack_args - else - allocate (options%unpack_args (0)) - end if - options%preload_model = model - options%default_lib = default_lib - options%preload_libraries = libraries - options%rebuild_library = rebuild_library - options%recompile_library = recompile_library - options%rebuild_phs = rebuild_phs - options%rebuild_grids = rebuild_grids - options%rebuild_events = rebuild_events - <> - - call whizard_instance%init (options, paths, logfile) - - call mask_term_signals () - - end if - - ! Run commands given on the command line - if (.not. quit .and. ifile_get_length (commands) > 0) then - call whizard_instance%process_ifile (commands, quit, quit_code) - end if - - if (.not. quit) then - ! Process commands from standard input - if (.not. interactive .and. files == "") then - call whizard_instance%process_stdin (quit, quit_code) - - ! ... or process commands from file - else - files = trim (adjustl (files)) - SCAN_FILES: do while (files /= "") - call split (files, this, " ") - call whizard_instance%process_file (this, quit, quit_code) - if (quit) exit SCAN_FILES - end do SCAN_FILES - - end if - end if - - ! Enter an interactive shell if requested - if (.not. quit .and. interactive) then - call whizard_instance%shell (quit_code) - end if - - ! Overall finalization - call ifile_final (commands) - - deallocate (options) - - call whizard_instance%final () - deallocate (whizard_instance) - -<> - - call terminate_now_if_signal () - call release_term_signals () - call msg_terminate (quit_code = quit_code) - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -contains - - subroutine print_version () - print "(A)", "WHIZARD " // WHIZARD_VERSION - print "(A)", "Copyright (C) 1999-2020 Wolfgang Kilian, Thorsten Ohl, Juergen Reuter" - print "(A)", " --------------------------------------- " - print "(A)", "This is free software; see the source for copying conditions. There is NO" - print "(A)", "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - print * - end subroutine print_version - -end program main - -!!! (WK 02/2016) -!!! Separate subroutine, because this becomes a procedure pointer target -!!! Internal procedures as targets are not supported by some compilers. - - subroutine print_usage () - use system_dependencies, only: WHIZARD_VERSION - print "(A)", "WHIZARD " // WHIZARD_VERSION - print "(A)", "Usage: whizard [OPTIONS] [FILE]" - print "(A)", "Run WHIZARD with the command list taken from FILE(s)" - print "(A)", "Options for resetting default directories and tools" & - // "(GNU naming conventions):" - print "(A)", " --prefix DIR" - print "(A)", " --exec-prefix DIR" - print "(A)", " --bindir DIR" - print "(A)", " --libdir DIR" - print "(A)", " --includedir DIR" - print "(A)", " --datarootdir DIR" - print "(A)", " --libtool LOCAL_LIBTOOL" - print "(A)", " --lhapdfdir DIR (PDF sets directory)" - print "(A)", "Other options:" - print "(A)", "-h, --help display this help and exit" - print "(A)", " --banner display banner at startup (default)" - print "(A)", " --debug AREA switch on debug output for AREA." - print "(A)", " AREA can be one of Whizard's src dirs or 'all'" - print "(A)", " --debug2 AREA switch on more verbose debug output for AREA." - print "(A)", " --single-event only compute one phase-space point (for debugging)" - print "(A)", "-e, --execute CMDS execute SINDARIN CMDS before reading FILE(s)" - print "(A)", "-f, --file CMDFILE execute SINDARIN from CMDFILE before reading FILE(s)" - print "(A)", "-i, --interactive run interactively after reading FILE(s)" - print "(A)", "-J, --job-id STRING set job ID to STRING (default: empty)" - print "(A)", "-l, --library LIB preload process library NAME" - print "(A)", " --localprefix DIR" - print "(A)", " search in DIR for local models (default: ~/.whizard)" - print "(A)", "-L, --logfile FILE write log to FILE (default: 'whizard.log'" - print "(A)", " --logging switch on logging at startup (default)" - print "(A)", "-m, --model NAME preload model NAME (default: 'SM')" - print "(A)", " --no-banner do not display banner at startup" - print "(A)", " --no-library do not preload process library" - print "(A)", " --no-logfile do not write a logfile" - print "(A)", " --no-logging switch off logging at startup" - print "(A)", " --no-model do not preload a model" - print "(A)", " --no-rebuild do not force rebuilding" - print "(A)", " --pack DIR tar/gzip DIR after job" - print "(A)", "-q, --query VARIABLE display documentation of VARIABLE" - print "(A)", "-r, --rebuild rebuild all (see below)" - print "(A)", " --rebuild-library" - print "(A)", " rebuild process code library" - print "(A)", " --rebuild-user rebuild user-provided code" - print "(A)", " --rebuild-phase-space" - print "(A)", " rebuild phase-space configuration" - print "(A)", " --rebuild-grids rebuild integration grids" - print "(A)", " --rebuild-events rebuild event samples" - print "(A)", " --recompile recompile process code" - print "(A)", " --show-config show build-time configuration" - print "(A)", " --unpack FILE untar/gunzip FILE before job" - print "(A)", "-V, --version output version information and exit" - print "(A)", " --write-syntax-tables" - print "(A)", " write the internal syntax tables to files and exit" - print "(A)", "- further options are taken as filenames" - print * - print "(A)", "With no FILE, read standard input." - end subroutine print_usage - -@ %def main -@ -\clearpage -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{Driver program for the unit tests} -This is a variant of the above main program that takes unit-test names -as command-line options and runs those tests. -<<[[main_ut.f90]]>>= -<> - -program main_ut - -<> - use unit_tests - use io_units - use system_dependencies - use diagnostics - use os_interface - - use cmdline_options - - use model_testbed !NODEP! -<> - -<> - - implicit none - -<> - -!!! (WK 02/2016) Interface for the separate external routine below - interface - subroutine print_usage () - end subroutine print_usage - end interface - - ! Main program variable declarations - character(CMDLINE_ARG_LEN) :: arg - character(2) :: option - type(string_t) :: long_option, value - integer :: i, j, arg_len, arg_status - logical :: look_for_options - logical :: banner - type(string_t) :: check, checks - type(test_results_t) :: test_results - logical :: success - - ! Exit status - integer :: quit_code = 0 - - ! Initial values - look_for_options = .true. - banner = .true. - logging = .false. - msg_level = RESULT - check = "" - checks = "" - -<> - - ! Read and process options - call init_options (print_usage) - i = 0 - SCAN_CMDLINE: do - i = i + 1 - call get_command_argument (i, arg, arg_len, arg_status) - select case (arg_status) - case (0) - case (-1) - call msg_error (" Command argument truncated: '" // arg // "'") - case default - exit SCAN_CMDLINE - end select - if (look_for_options) then - select case (arg(1:2)) - case ("--") - value = trim (arg) - call split (value, long_option, "=") - select case (char (long_option)) - case ("--version") - call no_option_value (long_option, value) - call print_version (); stop - case ("--help") - call no_option_value (long_option, value) - call print_usage (); stop - case ("--banner") - call no_option_value (long_option, value) - banner = .true. - cycle SCAN_CMDLINE - case ("--no-banner") - call no_option_value (long_option, value) - banner = .false. - cycle SCAN_CMDLINE - case ("--check") - check = get_option_value (i, long_option, value) - checks = checks // " " // check - cycle SCAN_CMDLINE - case ("--debug") - call no_option_value (long_option, value) - call set_debug_levels (get_option_value (i, long_option, value)) - cycle SCAN_CMDLINE - case ("--debug2") - call no_option_value (long_option, value) - call set_debug2_levels (get_option_value (i, long_option, value)) - cycle SCAN_CMDLINE - case default - call print_usage () - call msg_fatal ("Option '" // trim (arg) // "' not recognized") - end select - end select - select case (arg(1:1)) - case ("-") - j = 1 - if (len_trim (arg) == 1) then - look_for_options = .false. - else - SCAN_SHORT_OPTIONS: do - j = j + 1 - if (j > len_trim (arg)) exit SCAN_SHORT_OPTIONS - option = "-" // arg(j:j) - select case (option) - case ("-V") - call print_version (); stop - case ("-?", "-h") - call print_usage (); stop - case default - call print_usage () - call msg_fatal & - ("Option '" // option // "' not recognized") - end select - end do SCAN_SHORT_OPTIONS - end if - case default - call print_usage () - call msg_fatal ("Option '" // trim (arg) // "' not recognized") - end select - else - call print_usage () - call msg_fatal ("Option '" // trim (arg) // "' not recognized") - end if - end do SCAN_CMDLINE - - ! Overall initialization - if (banner) call msg_banner () - - ! Run any self-checks (and no commands) - if (checks /= "") then - checks = trim (adjustl (checks)) - RUN_CHECKS: do while (checks /= "") - call split (checks, check, " ") - call whizard_check (check, test_results) - end do RUN_CHECKS - call test_results%wrapup (6, success) - if (.not. success) quit_code = 7 - end if - - <> - - call msg_terminate (quit_code = quit_code) - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -contains - - subroutine print_version () - print "(A)", "WHIZARD " // WHIZARD_VERSION // " (unit test driver)" - print "(A)", "Copyright (C) 1999-2020 Wolfgang Kilian, Thorsten Ohl, Juergen Reuter" - print "(A)", " --------------------------------------- " - print "(A)", "This is free software; see the source for copying conditions. There is NO" - print "(A)", "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - print * - end subroutine print_version - -<> - -end program main_ut - -!!! (WK 02/2016) -!!! Separate subroutine, because this becomes a procedure pointer target -!!! Internal procedures as targets are not supported by some compilers. - - subroutine print_usage () - use system_dependencies, only: WHIZARD_VERSION - print "(A)", "WHIZARD " // WHIZARD_VERSION // " (unit test driver)" - print "(A)", "Usage: whizard_ut [OPTIONS] [FILE]" - print "(A)", "Run WHIZARD unit tests as given on the command line" - print "(A)", "Options:" - print "(A)", "-h, --help display this help and exit" - print "(A)", " --banner display banner at startup (default)" - print "(A)", " --no-banner do not display banner at startup" - print "(A)", " --debug AREA switch on debug output for AREA." - print "(A)", " AREA can be one of Whizard's src dirs or 'all'" - print "(A)", " --debug2 AREA switch on more verbose debug output for AREA." - print "(A)", "-V, --version output version information and exit" - print "(A)", " --check TEST run unit test TEST" - end subroutine print_usage -@ %def main_ut -@ -<>= -@ -<>= -@ -@ MPI init. -<>= - call MPI_init () -<>= - call MPI_finalize () -@ %def MPI_init MPI_finalize -<>= -@ -Every rebuild action is forbidden for the slave workers except -[[rebuild_grids]], which is handled correctly inside the corresponding -integration object. -<>= - if (.not. mpi_is_comm_master ()) then - options%rebuild_library = .false. - options%recompile_library = .false. - options%rebuild_phs = .false. - options%rebuild_events = .false. - end if -@ -\subsection{Self-tests} -For those self-tests, we need some auxiliary routines that provide an -enviroment. The environment depends on things that are not available at the -level of the module that we want to test. - -\subsubsection{Testbed for event I/O} -This subroutine prepares a test process with a single event. All objects are -allocated via anonymous pointers, because we want to recover the pointers and -delete the objects in a separate procedure. -<>= - subroutine prepare_eio_test (event, unweighted, n_alt, sample_norm) - use variables, only: var_list_t - use model_data - use process, only: process_t - use instances, only: process_instance_t - use processes_ut, only: prepare_test_process - use event_base - use events - - class(generic_event_t), intent(inout), pointer :: event - logical, intent(in), optional :: unweighted - integer, intent(in), optional :: n_alt - type(string_t), intent(in), optional :: sample_norm - type(model_data_t), pointer :: model - type(var_list_t) :: var_list - type(string_t) :: sample_normalization - type(process_t), pointer :: proc - type(process_instance_t), pointer :: process_instance - - allocate (model) - call model%init_test () - - allocate (proc) - allocate (process_instance) - - call prepare_test_process (proc, process_instance, model, & - run_id = var_str ("run_test")) - call process_instance%setup_event_data () - - call model%final () - deallocate (model) - - allocate (event_t :: event) - select type (event) - type is (event_t) - if (present (unweighted)) then - call var_list%append_log (& - var_str ("?unweighted"), unweighted, & - intrinsic = .true.) - else - call var_list%append_log (& - var_str ("?unweighted"), .true., & - intrinsic = .true.) - end if - if (present (sample_norm)) then - sample_normalization = sample_norm - else - sample_normalization = var_str ("auto") - end if - call var_list%append_string (& - var_str ("$sample_normalization"), & - sample_normalization, intrinsic = .true.) - call event%basic_init (var_list, n_alt) - call event%connect (process_instance, proc%get_model_ptr ()) - call var_list%final () - end select - - end subroutine prepare_eio_test - -@ %def prepare_eio_test_event -@ Recover those pointers, finalize the objects and deallocate. -<>= - subroutine cleanup_eio_test (event) - use model_data - use process, only: process_t - use instances, only: process_instance_t - use processes_ut, only: cleanup_test_process - use event_base - use events - - class(generic_event_t), intent(inout), pointer :: event - type(process_t), pointer :: proc - type(process_instance_t), pointer :: process_instance - - select type (event) - type is (event_t) - proc => event%get_process_ptr () - process_instance => event%get_process_instance_ptr () - call cleanup_test_process (proc, process_instance) - deallocate (process_instance) - deallocate (proc) - call event%final () - end select - deallocate (event) - - end subroutine cleanup_eio_test - -@ %def cleanup_eio_test_event -@ Assign those procedures to appropriate pointers (module variables) in the -[[eio_base]] module, so they can be called as if they were module procedures. -<>= - use eio_base_ut, only: eio_prepare_test - use eio_base_ut, only: eio_cleanup_test -<>= - eio_prepare_test => prepare_eio_test - eio_cleanup_test => cleanup_eio_test -@ -\subsubsection{Any Model} -This procedure reads any model from file and, optionally, assigns a -var-list pointer. If the model pointer is still null, we allocate the model -object first, with concrete type [[model_t]]. This is a service for modules -which do just have access to the [[model_data_t]] base type. -<>= - subroutine prepare_whizard_model (model, name, vars) - <> - use os_interface - use model_data - use var_base - use models - class(model_data_t), intent(inout), pointer :: model - type(string_t), intent(in) :: name - class(vars_t), pointer, intent(out), optional :: vars - type(os_data_t) :: os_data - call syntax_model_file_init () - call os_data%init () - if (.not. associated (model)) allocate (model_t :: model) - select type (model) - type is (model_t) - call model%read (name // ".mdl", os_data) - if (present (vars)) then - vars => model%get_var_list_ptr () - end if - end select - end subroutine prepare_whizard_model - -@ %def prepare_whizard_model -@ Cleanup after use. Includes deletion of the model-file syntax. -<>= - subroutine cleanup_whizard_model (model) - use model_data - use models - class(model_data_t), intent(inout), target :: model - call model%final () - call syntax_model_file_final () - end subroutine cleanup_whizard_model - -@ %def cleanup_whizard_model -@ Assign those procedures to appropriate pointers (module variables) in the -[[model_testbed]] module, so they can be called as if they were module -procedures. -<>= - prepare_model => prepare_whizard_model - cleanup_model => cleanup_whizard_model -@ -\subsubsection{Fallback model: hadrons} -Some event format tests require the hadronic SM implementation, which -has to be read from file. We provide the functionality here, so the -tests do not depend on model I/O. -<>= - subroutine prepare_fallback_model (model) - use model_data - class(model_data_t), intent(inout), pointer :: model - call prepare_whizard_model (model, var_str ("SM_hadrons")) - end subroutine prepare_fallback_model - -@ %def prepare_fallback_model -@ Assign those procedures to appropriate pointers (module variables) in the -[[eio_base]] module, so they can be called as if they were module procedures. -<>= - use eio_base_ut, only: eio_prepare_fallback_model - use eio_base_ut, only: eio_cleanup_fallback_model -<>= - eio_prepare_fallback_model => prepare_fallback_model - eio_cleanup_fallback_model => cleanup_model -@ -\subsubsection{Access to the test random-number generator} -This generator is not normally available for the dispatcher. We assign an -additional dispatch routine to the hook in the [[dispatch]] module -which will be checked before the default rule. -<>= - use dispatch_rng, only: dispatch_rng_factory_fallback - use dispatch_rng_ut, only: dispatch_rng_factory_test -<>= - dispatch_rng_factory_fallback => dispatch_rng_factory_test -@ -\subsubsection{Access to the test structure functions} -These are not normally available for the dispatcher. We assign an -additional dispatch routine to the hook in the [[dispatch]] module -which will be checked before the default rule. -<>= - use dispatch_beams, only: dispatch_sf_data_extra - use dispatch_ut, only: dispatch_sf_data_test -<>= - dispatch_sf_data_extra => dispatch_sf_data_test -@ -\subsubsection{Procedure for Checking} -This is for developers only, but needs a well-defined interface. -<>= - subroutine whizard_check (check, results) - type(string_t), intent(in) :: check - type(test_results_t), intent(inout) :: results - type(os_data_t) :: os_data - integer :: u - call os_data%init () - u = free_unit () - open (u, file="whizard_check." // char (check) // ".log", & - action="write", status="replace") - call msg_message (repeat ('=', 76), 0) - call msg_message ("Running self-test: " // char (check), 0) - call msg_message (repeat ('-', 76), 0) - <> - select case (char (check)) - <> - case ("all") - <> - case default - call msg_fatal ("Self-test '" // char (check) // "' not implemented.") - end select - close (u) - end subroutine whizard_check - -@ %def whizard_check -@ -\subsection{Unit test references} -\subsubsection{Formats} -<>= - use formats_ut, only: format_test -<>= - case ("formats") - call format_test (u, results) -<>= - call format_test (u, results) -@ -\subsubsection{MD5} -<>= - use md5_ut, only: md5_test -<>= - case ("md5") - call md5_test (u, results) -<>= - call md5_test (u, results) -@ -\subsubsection{OS Interface} -<>= - use os_interface_ut, only: os_interface_test -<>= - case ("os_interface") - call os_interface_test (u, results) -<>= - call os_interface_test (u, results) -@ -\subsubsection{Sorting} -<>= - use sorting_ut, only: sorting_test -<>= - case ("sorting") - call sorting_test (u, results) -<>= - call sorting_test (u, results) -@ -\subsubsection{Grids} -<>= - use grids_ut, only: grids_test -<>= - case ("grids") - call grids_test (u, results) -<>= - call grids_test (u, results) -@ -\subsubsection{Solver} -<>= - use solver_ut, only: solver_test -<>= - case ("solver") - call solver_test (u, results) -<>= - call solver_test (u, results) -@ -\subsubsection{CPU Time} -<>= - use cputime_ut, only: cputime_test -<>= - case ("cputime") - call cputime_test (u, results) -<>= - call cputime_test (u, results) -@ -\subsubsection{SM QCD} -<>= - use sm_qcd_ut, only: sm_qcd_test -<>= - case ("sm_qcd") - call sm_qcd_test (u, results) -<>= - call sm_qcd_test (u, results) -@ -\subsubsection{SM physics} -<>= - use sm_physics_ut, only: sm_physics_test -<>= - case ("sm_physics") - call sm_physics_test (u, results) -<>= - call sm_physics_test (u, results) -@ -\subsubsection{Lexers} -<>= - use lexers_ut, only: lexer_test -<>= - case ("lexers") - call lexer_test (u, results) -<>= - call lexer_test (u, results) -@ -\subsubsection{Parser} -<>= - use parser_ut, only: parse_test -<>= - case ("parser") - call parse_test (u, results) -<>= - call parse_test (u, results) -@ -\subsubsection{XML} -<>= - use xml_ut, only: xml_test -<>= - case ("xml") - call xml_test (u, results) -<>= - call xml_test (u, results) -@ -\subsubsection{Colors} -<>= - use colors_ut, only: color_test -<>= - case ("colors") - call color_test (u, results) -<>= - call color_test (u, results) -@ -\subsubsection{State matrices} -<>= - use state_matrices_ut, only: state_matrix_test -<>= - case ("state_matrices") - call state_matrix_test (u, results) -<>= - call state_matrix_test (u, results) -@ -\subsubsection{Analysis} -<>= - use analysis_ut, only: analysis_test -<>= - case ("analysis") - call analysis_test (u, results) -<>= - call analysis_test (u, results) -@ -\subsubsection{Particles} -<>= - use particles_ut, only: particles_test -<>= - case ("particles") - call particles_test (u, results) -<>= - call particles_test (u, results) -@ -\subsubsection{Models} -<>= - use models_ut, only: models_test -<>= - case ("models") - call models_test (u, results) -<>= - call models_test (u, results) -@ -\subsubsection{Auto Components} -<>= - use auto_components_ut, only: auto_components_test -<>= - case ("auto_components") - call auto_components_test (u, results) -<>= - call auto_components_test (u, results) -@ -\subsubsection{Radiation Generator} -<>= - use radiation_generator_ut, only: radiation_generator_test -<>= - case ("radiation_generator") - call radiation_generator_test (u, results) -<>= - call radiation_generator_test (u, results) -@ -\subsection{BLHA} -<>= - use blha_ut, only: blha_test -<>= - case ("blha") - call blha_test (u, results) -<>= - call blha_test (u, results) -@ -\subsubsection{Evaluators} -<>= - use evaluators_ut, only: evaluator_test -<>= - case ("evaluators") - call evaluator_test (u, results) -<>= - call evaluator_test (u, results) -@ -\subsubsection{Expressions} -<>= - use eval_trees_ut, only: expressions_test -<>= - case ("expressions") - call expressions_test (u, results) -<>= - call expressions_test (u, results) -@ -\subsubsection{Resonances} -<>= - use resonances_ut, only: resonances_test -<>= - case ("resonances") - call resonances_test (u, results) -<>= - call resonances_test (u, results) -@ -\subsubsection{PHS Trees} -<>= - use phs_trees_ut, only: phs_trees_test -<>= - case ("phs_trees") - call phs_trees_test (u, results) -<>= - call phs_trees_test (u, results) -@ -\subsubsection{PHS Forests} -<>= - use phs_forests_ut, only: phs_forests_test -<>= - case ("phs_forests") - call phs_forests_test (u, results) -<>= - call phs_forests_test (u, results) -@ -\subsubsection{Beams} -<>= - use beams_ut, only: beams_test -<>= - case ("beams") - call beams_test (u, results) -<>= - call beams_test (u, results) -@ -\subsubsection{$su(N)$ Algebra} -<>= - use su_algebra_ut, only: su_algebra_test -<>= - case ("su_algebra") - call su_algebra_test (u, results) -<>= - call su_algebra_test (u, results) -@ -\subsubsection{Bloch Vectors} -<>= - use bloch_vectors_ut, only: bloch_vectors_test -<>= - case ("bloch_vectors") - call bloch_vectors_test (u, results) -<>= - call bloch_vectors_test (u, results) -@ -\subsubsection{Polarizations} -<>= - use polarizations_ut, only: polarizations_test -<>= - case ("polarizations") - call polarizations_test (u, results) -<>= - call polarizations_test (u, results) -@ -\subsubsection{SF Aux} -<>= - use sf_aux_ut, only: sf_aux_test -<>= - case ("sf_aux") - call sf_aux_test (u, results) -<>= - call sf_aux_test (u, results) -@ -\subsubsection{SF Mappings} -<>= - use sf_mappings_ut, only: sf_mappings_test -<>= - case ("sf_mappings") - call sf_mappings_test (u, results) -<>= - call sf_mappings_test (u, results) -@ -\subsubsection{SF Base} -<>= - use sf_base_ut, only: sf_base_test -<>= - case ("sf_base") - call sf_base_test (u, results) -<>= - call sf_base_test (u, results) -@ -\subsubsection{SF PDF Builtin} -<>= - use sf_pdf_builtin_ut, only: sf_pdf_builtin_test -<>= - case ("sf_pdf_builtin") - call sf_pdf_builtin_test (u, results) -<>= - call sf_pdf_builtin_test (u, results) -@ -\subsubsection{SF LHAPDF} -<>= - use sf_lhapdf_ut, only: sf_lhapdf_test -<>= - case ("sf_lhapdf") - call sf_lhapdf_test (u, results) -<>= - call sf_lhapdf_test (u, results) -@ -\subsubsection{SF ISR} -<>= - use sf_isr_ut, only: sf_isr_test -<>= - case ("sf_isr") - call sf_isr_test (u, results) -<>= - call sf_isr_test (u, results) -@ -\subsubsection{SF EPA} -<>= - use sf_epa_ut, only: sf_epa_test -<>= - case ("sf_epa") - call sf_epa_test (u, results) -<>= - call sf_epa_test (u, results) -@ -\subsubsection{SF EWA} -<>= - use sf_ewa_ut, only: sf_ewa_test -<>= - case ("sf_ewa") - call sf_ewa_test (u, results) -<>= - call sf_ewa_test (u, results) -@ -\subsubsection{SF CIRCE1} -<>= - use sf_circe1_ut, only: sf_circe1_test -<>= - case ("sf_circe1") - call sf_circe1_test (u, results) -<>= - call sf_circe1_test (u, results) -@ -\subsubsection{SF CIRCE2} -<>= - use sf_circe2_ut, only: sf_circe2_test -<>= - case ("sf_circe2") - call sf_circe2_test (u, results) -<>= - call sf_circe2_test (u, results) -@ -\subsubsection{SF Gaussian} -<>= - use sf_gaussian_ut, only: sf_gaussian_test -<>= - case ("sf_gaussian") - call sf_gaussian_test (u, results) -<>= - call sf_gaussian_test (u, results) -@ -\subsubsection{SF Beam Events} -<>= - use sf_beam_events_ut, only: sf_beam_events_test -<>= - case ("sf_beam_events") - call sf_beam_events_test (u, results) -<>= - call sf_beam_events_test (u, results) -@ -\subsubsection{SF EScan} -<>= - use sf_escan_ut, only: sf_escan_test -<>= - case ("sf_escan") - call sf_escan_test (u, results) -<>= - call sf_escan_test (u, results) -@ -\subsubsection{PHS Base} -<>= - use phs_base_ut, only: phs_base_test -<>= - case ("phs_base") - call phs_base_test (u, results) -<>= - call phs_base_test (u, results) -@ -\subsubsection{PHS None} -<>= - use phs_none_ut, only: phs_none_test -<>= - case ("phs_none") - call phs_none_test (u, results) -<>= - call phs_none_test (u, results) -@ -\subsubsection{PHS Single} -<>= - use phs_single_ut, only: phs_single_test -<>= - case ("phs_single") - call phs_single_test (u, results) -<>= - call phs_single_test (u, results) -@ -\subsubsection{PHS Rambo} -<>= - use phs_rambo_ut, only: phs_rambo_test -<>= - case ("phs_rambo") - call phs_rambo_test (u, results) -<>= - call phs_rambo_test (u, results) -@ -\subsubsection{PHS Wood} -<>= - use phs_wood_ut, only: phs_wood_test - use phs_wood_ut, only: phs_wood_vis_test -<>= - case ("phs_wood") - call phs_wood_test (u, results) - case ("phs_wood_vis") - call phs_wood_vis_test (u, results) -<>= - call phs_wood_test (u, results) - call phs_wood_vis_test (u, results) -@ -\subsubsection{PHS FKS Generator} -<>= - use phs_fks_ut, only: phs_fks_generator_test -<>= - case ("phs_fks_generator") - call phs_fks_generator_test (u, results) -<>= - call phs_fks_generator_test (u, results) -@ -\subsubsection{FKS regions} -<>= - use fks_regions_ut, only: fks_regions_test -<>= - case ("fks_regions") - call fks_regions_test (u, results) -<>= - call fks_regions_test (u, results) -@ -\subsubsection{Real subtraction} -<>= - use real_subtraction_ut, only: real_subtraction_test -<>= - case ("real_subtraction") - call real_subtraction_test (u, results) -<>= - call real_subtraction_test (u, results) -@ -\subsubsection{RECOLA} -<>= - use prc_recola_ut, only: prc_recola_test -<>= - case ("prc_recola") - call prc_recola_test (u, results) -<>= - call prc_recola_test (u, results) -@ -\subsubsection{RNG Base} -<>= - use rng_base_ut, only: rng_base_test -<>= - case ("rng_base") - call rng_base_test (u, results) -<>= - call rng_base_test (u, results) -@ -\subsubsection{RNG Tao} -<>= - use rng_tao_ut, only: rng_tao_test -<>= - case ("rng_tao") - call rng_tao_test (u, results) -<>= - call rng_tao_test (u, results) -@ -\subsubsection{RNG Stream} -<>= - use rng_stream_ut, only: rng_stream_test -<>= - case ("rng_stream") - call rng_stream_test (u, results) -<>= - call rng_stream_test (u, results) -@ -\subsubsection{Selectors} -<>= - use selectors_ut, only: selectors_test -<>= - case ("selectors") - call selectors_test (u, results) -<>= - call selectors_test (u, results) -@ -\subsubsection{VEGAS} -<>= - use vegas_ut, only: vegas_test -<>= - case ("vegas") - call vegas_test (u, results) -<>= - call vegas_test (u, results) -@ -\subsubsection{VAMP2} -<>= - use vamp2_ut, only: vamp2_test -<>= - case ("vamp2") - call vamp2_test (u, results) -<>= - call vamp2_test (u, results) -@ -\subsubsection{MCI Base} -<>= - use mci_base_ut, only: mci_base_test -<>= - case ("mci_base") - call mci_base_test (u, results) -<>= - call mci_base_test (u, results) -@ -\subsubsection{MCI None} -<>= - use mci_none_ut, only: mci_none_test -<>= - case ("mci_none") - call mci_none_test (u, results) -<>= - call mci_none_test (u, results) -@ -\subsubsection{MCI Midpoint} -<>= - use mci_midpoint_ut, only: mci_midpoint_test -<>= - case ("mci_midpoint") - call mci_midpoint_test (u, results) -<>= - call mci_midpoint_test (u, results) -@ -\subsubsection{MCI VAMP} -<>= - use mci_vamp_ut, only: mci_vamp_test -<>= - case ("mci_vamp") - call mci_vamp_test (u, results) -<>= - call mci_vamp_test (u, results) -@ -\subsubsection{MCI VAMP2} -<>= - use mci_vamp2_ut, only: mci_vamp2_test -<>= - case ("mci_vamp2") - call mci_vamp2_test (u, results) -<>= - call mci_vamp2_test (u, results) -@ -\subsubsection{Integration Results} -<>= - use integration_results_ut, only: integration_results_test -<>= - case ("integration_results") - call integration_results_test (u, results) -<>= - call integration_results_test (u, results) -@ -\subsubsection{PRCLib Interfaces} -<>= - use prclib_interfaces_ut, only: prclib_interfaces_test -<>= - case ("prclib_interfaces") - call prclib_interfaces_test (u, results) -<>= - call prclib_interfaces_test (u, results) -@ -\subsubsection{Particle Specifiers} -<>= - use particle_specifiers_ut, only: particle_specifiers_test -<>= - case ("particle_specifiers") - call particle_specifiers_test (u, results) -<>= - call particle_specifiers_test (u, results) -@ -\subsubsection{Process Libraries} -<>= - use process_libraries_ut, only: process_libraries_test -<>= - case ("process_libraries") - call process_libraries_test (u, results) -<>= - call process_libraries_test (u, results) -@ -\subsubsection{PRCLib Stacks} -<>= - use prclib_stacks_ut, only: prclib_stacks_test -<>= - case ("prclib_stacks") - call prclib_stacks_test (u, results) -<>= - call prclib_stacks_test (u, results) -@ -\subsubsection{HepMC} -<>= - use hepmc_interface_ut, only: hepmc_interface_test -<>= - case ("hepmc") - call hepmc_interface_test (u, results) -<>= - call hepmc_interface_test (u, results) -@ -\subsubsection{LCIO} -<>= - use lcio_interface_ut, only: lcio_interface_test -<>= - case ("lcio") - call lcio_interface_test (u, results) -<>= - call lcio_interface_test (u, results) -@ -\subsubsection{Jets} -<>= - use jets_ut, only: jets_test -<>= - case ("jets") - call jets_test (u, results) -<>= - call jets_test (u, results) -@ -\subsection{LHA User Process WHIZARD} -<>= - use whizard_lha_ut, only: whizard_lha_test -<>= - case ("whizard_lha") - call whizard_lha_test (u, results) -<>= - call whizard_lha_test (u, results) -@ -\subsection{Pythia8} -<>= - use pythia8_ut, only: pythia8_test -<>= - case ("pythia8") - call pythia8_test (u, results) -<>= - call pythia8_test (u, results) -@ -\subsubsection{PDG Arrays} -<>= - use pdg_arrays_ut, only: pdg_arrays_test -<>= - case ("pdg_arrays") - call pdg_arrays_test (u, results) -<>= - call pdg_arrays_test (u, results) -@ -\subsubsection{interactions} -<>= - use interactions_ut, only: interaction_test -<>= - case ("interactions") - call interaction_test (u, results) -<>= - call interaction_test (u, results) -@ -\subsubsection{SLHA} -<>= - use slha_interface_ut, only: slha_test -<>= - case ("slha_interface") - call slha_test (u, results) -<>= - call slha_test (u, results) -@ -\subsubsection{Cascades} -<>= - use cascades_ut, only: cascades_test -<>= - case ("cascades") - call cascades_test (u, results) -<>= - call cascades_test (u, results) -@ -\subsubsection{Cascades2 lexer} -<>= - use cascades2_lexer_ut, only: cascades2_lexer_test -<>= - case ("cascades2_lexer") - call cascades2_lexer_test (u, results) -<>= - call cascades2_lexer_test (u, results) -@ -\subsubsection{Cascades2} -<>= - use cascades2_ut, only: cascades2_test -<>= - case ("cascades2") - call cascades2_test (u, results) -<>= - call cascades2_test (u, results) -@ -\subsubsection{PRC Test} -<>= - use prc_test_ut, only: prc_test_test -<>= - case ("prc_test") - call prc_test_test (u, results) -<>= - call prc_test_test (u, results) -@ -\subsubsection{PRC Template ME} -<>= - use prc_template_me_ut, only: prc_template_me_test -<>= - case ("prc_template_me") - call prc_template_me_test (u, results) -<>= - call prc_template_me_test (u, results) -@ -\subsubsection{PRC OMega} -<>= - use prc_omega_ut, only: prc_omega_test - use prc_omega_ut, only: prc_omega_diags_test -<>= - case ("prc_omega") - call prc_omega_test (u, results) - case ("prc_omega_diags") - call prc_omega_diags_test (u, results) -<>= - call prc_omega_test (u, results) - call prc_omega_diags_test (u, results) -@ -\subsubsection{Parton States} -<>= - use parton_states_ut, only: parton_states_test -<>= - case ("parton_states") - call parton_states_test (u, results) -<>= - call parton_states_test (u, results) -@ -\subsubsection{Subevt Expr} -<>= - use expr_tests_ut, only: subevt_expr_test -<>= - case ("subevt_expr") - call subevt_expr_test (u, results) -<>= - call subevt_expr_test (u, results) -@ -\subsubsection{Processes} -<>= - use processes_ut, only: processes_test -<>= - case ("processes") - call processes_test (u, results) -<>= - call processes_test (u, results) -@ -\subsubsection{Process Stacks} -<>= - use process_stacks_ut, only: process_stacks_test -<>= - case ("process_stacks") - call process_stacks_test (u, results) -<>= - call process_stacks_test (u, results) -@ -\subsubsection{Event Transforms} -<>= - use event_transforms_ut, only: event_transforms_test -<>= - case ("event_transforms") - call event_transforms_test (u, results) -<>= - call event_transforms_test (u, results) -@ -\subsubsection{Resonance Insertion Transform} -<>= - use resonance_insertion_ut, only: resonance_insertion_test -<>= - case ("resonance_insertion") - call resonance_insertion_test (u, results) -<>= - call resonance_insertion_test (u, results) -@ -\subsubsection{Recoil Kinematics} -<>= - use recoil_kinematics_ut, only: recoil_kinematics_test -<>= - case ("recoil_kinematics") - call recoil_kinematics_test (u, results) -<>= - call recoil_kinematics_test (u, results) -@ -\subsubsection{ISR Handler} -<>= - use isr_epa_handler_ut, only: isr_handler_test -<>= - case ("isr_handler") - call isr_handler_test (u, results) -<>= - call isr_handler_test (u, results) -@ -\subsubsection{EPA Handler} -<>= - use isr_epa_handler_ut, only: epa_handler_test -<>= - case ("epa_handler") - call epa_handler_test (u, results) -<>= - call epa_handler_test (u, results) -@ -\subsubsection{Decays} -<>= - use decays_ut, only: decays_test -<>= - case ("decays") - call decays_test (u, results) -<>= - call decays_test (u, results) -@ -\subsubsection{Shower} -<>= - use shower_ut, only: shower_test -<>= - case ("shower") - call shower_test (u, results) -<>= - call shower_test (u, results) -@ -\subsubsection{Events} -<>= - use events_ut, only: events_test -<>= - case ("events") - call events_test (u, results) -<>= - call events_test (u, results) -@ -\subsubsection{HEP Events} -<>= - use hep_events_ut, only: hep_events_test -<>= - case ("hep_events") - call hep_events_test (u, results) -<>= - call hep_events_test (u, results) -@ -\subsubsection{EIO Data} -<>= - use eio_data_ut, only: eio_data_test -<>= - case ("eio_data") - call eio_data_test (u, results) -<>= - call eio_data_test (u, results) -@ -\subsubsection{EIO Base} -<>= - use eio_base_ut, only: eio_base_test -<>= - case ("eio_base") - call eio_base_test (u, results) -<>= - call eio_base_test (u, results) -@ -\subsubsection{EIO Direct} -<>= - use eio_direct_ut, only: eio_direct_test -<>= - case ("eio_direct") - call eio_direct_test (u, results) -<>= - call eio_direct_test (u, results) -@ -\subsubsection{EIO Raw} -<>= - use eio_raw_ut, only: eio_raw_test -<>= - case ("eio_raw") - call eio_raw_test (u, results) -<>= - call eio_raw_test (u, results) -@ -\subsubsection{EIO Checkpoints} -<>= - use eio_checkpoints_ut, only: eio_checkpoints_test -<>= - case ("eio_checkpoints") - call eio_checkpoints_test (u, results) -<>= - call eio_checkpoints_test (u, results) -@ -\subsubsection{EIO LHEF} -<>= - use eio_lhef_ut, only: eio_lhef_test -<>= - case ("eio_lhef") - call eio_lhef_test (u, results) -<>= - call eio_lhef_test (u, results) -@ -\subsubsection{EIO HepMC} -<>= - use eio_hepmc_ut, only: eio_hepmc_test -<>= - case ("eio_hepmc") - call eio_hepmc_test (u, results) -<>= - call eio_hepmc_test (u, results) -@ -\subsubsection{EIO LCIO} -<>= - use eio_lcio_ut, only: eio_lcio_test -<>= - case ("eio_lcio") - call eio_lcio_test (u, results) -<>= - call eio_lcio_test (u, results) -@ -\subsubsection{EIO StdHEP} -<>= - use eio_stdhep_ut, only: eio_stdhep_test -<>= - case ("eio_stdhep") - call eio_stdhep_test (u, results) -<>= - call eio_stdhep_test (u, results) -@ -\subsubsection{EIO ASCII} -<>= - use eio_ascii_ut, only: eio_ascii_test -<>= - case ("eio_ascii") - call eio_ascii_test (u, results) -<>= - call eio_ascii_test (u, results) -@ -\subsubsection{EIO Weights} -<>= - use eio_weights_ut, only: eio_weights_test -<>= - case ("eio_weights") - call eio_weights_test (u, results) -<>= - call eio_weights_test (u, results) -@ -\subsubsection{EIO Dump} -<>= - use eio_dump_ut, only: eio_dump_test -<>= - case ("eio_dump") - call eio_dump_test (u, results) -<>= - call eio_dump_test (u, results) -@ -\subsubsection{Iterations} -<>= - use iterations_ut, only: iterations_test -<>= - case ("iterations") - call iterations_test (u, results) -<>= - call iterations_test (u, results) -@ -\subsubsection{Beam Structures} -<>= - use beam_structures_ut, only: beam_structures_test -<>= - case ("beam_structures") - call beam_structures_test (u, results) -<>= - call beam_structures_test (u, results) -@ -\subsubsection{RT Data} -<>= - use rt_data_ut, only: rt_data_test -<>= - case ("rt_data") - call rt_data_test (u, results) -<>= - call rt_data_test (u, results) -@ -\subsubsection{Dispatch} -<>= - use dispatch_ut, only: dispatch_test -<>= - case ("dispatch") - call dispatch_test (u, results) -<>= - call dispatch_test (u, results) -@ -\subsubsection{Dispatch RNG} -<>= - use dispatch_rng_ut, only: dispatch_rng_test -<>= - case ("dispatch_rng") - call dispatch_rng_test (u, results) -<>= - call dispatch_rng_test (u, results) -@ -\subsubsection{Dispatch MCI} -<>= - use dispatch_mci_ut, only: dispatch_mci_test -<>= - case ("dispatch_mci") - call dispatch_mci_test (u, results) -<>= - call dispatch_mci_test (u, results) -@ -\subsubsection{Dispatch PHS} -<>= - use dispatch_phs_ut, only: dispatch_phs_test -<>= - case ("dispatch_phs") - call dispatch_phs_test (u, results) -<>= - call dispatch_phs_test (u, results) -@ -\subsubsection{Dispatch transforms} -<>= - use dispatch_transforms_ut, only: dispatch_transforms_test -<>= - case ("dispatch_transforms") - call dispatch_transforms_test (u, results) -<>= - call dispatch_transforms_test (u, results) -@ -\subsubsection{Shower partons} -<>= - use shower_base_ut, only: shower_base_test -<>= - case ("shower_base") - call shower_base_test (u, results) -<>= - call shower_base_test (u, results) -@ -\subsubsection{Process Configurations} -<>= - use process_configurations_ut, only: process_configurations_test -<>= - case ("process_configurations") - call process_configurations_test (u, results) -<>= - call process_configurations_test (u, results) -@ -\subsubsection{Compilations} -<>= - use compilations_ut, only: compilations_test - use compilations_ut, only: compilations_static_test -<>= - case ("compilations") - call compilations_test (u, results) - case ("compilations_static") - call compilations_static_test (u, results) -<>= - call compilations_test (u, results) - call compilations_static_test (u, results) -@ -\subsubsection{Integrations} -<>= - use integrations_ut, only: integrations_test - use integrations_ut, only: integrations_history_test -<>= - case ("integrations") - call integrations_test (u, results) - case ("integrations_history") - call integrations_history_test (u, results) -<>= - call integrations_test (u, results) - call integrations_history_test (u, results) -@ -\subsubsection{Event Streams} -<>= - use event_streams_ut, only: event_streams_test -<>= - case ("event_streams") - call event_streams_test (u, results) -<>= - call event_streams_test (u, results) -@ -\subsubsection{Restricted Subprocesses} -<>= - use restricted_subprocesses_ut, only: restricted_subprocesses_test -<>= - case ("restricted_subprocesses") - call restricted_subprocesses_test (u, results) -<>= - call restricted_subprocesses_test (u, results) -@ -\subsubsection{Simulations} -<>= - use simulations_ut, only: simulations_test -<>= - case ("simulations") - call simulations_test (u, results) -<>= - call simulations_test (u, results) -@ -\subsubsection{Commands} -<>= - use commands_ut, only: commands_test -<>= - case ("commands") - call commands_test (u, results) -<>= - call commands_test (u, results) -@ -\subsubsection{$ttV$ formfactors} -<>= - use ttv_formfactors_ut, only: ttv_formfactors_test -<>= - case ("ttv_formfactors") - call ttv_formfactors_test (u, results) -<>= - call ttv_formfactors_test (u, results) -@ -\clearpage -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{Whizard-C-Interface} -<<[[whizard-c-interface.f90]]>>= -<> - -<> -<> -<> -<> - -@ -<>= - subroutine c_whizard_convert_string (c_string, f_string) - use, intrinsic :: iso_c_binding - use iso_varying_string, string_t => varying_string !NODEP! - - implicit none - - character(kind=c_char), intent(in) :: c_string(*) - type(string_t), intent(inout) :: f_string - character(len=1) :: dummy_char - integer :: dummy_i = 1 - - f_string = "" - do - if (c_string(dummy_i) == c_null_char) then - exit - else if (c_string(dummy_i) == c_new_line) then - dummy_char = CHAR(13) - f_string = f_string // dummy_char - dummy_char = CHAR(10) - else - dummy_char = c_string (dummy_i) - end if - f_string = f_string // dummy_char - dummy_i = dummy_i + 1 - end do - dummy_i = 1 - end subroutine c_whizard_convert_string - - subroutine c_whizard_commands (w_c_instance, cmds) - use, intrinsic :: iso_c_binding - use iso_varying_string, string_t => varying_string !NODEP! - use commands - use diagnostics - use lexers - use models - use parser - use whizard - - type(c_ptr), intent(inout) :: w_c_instance - type(whizard_t), pointer :: whizard_instance - type(string_t) :: cmds - type(parse_tree_t) :: parse_tree - type(parse_node_t), pointer :: pn_root - type(stream_t), target :: stream - type(lexer_t) :: lexer - type(command_list_t), target :: cmd_list - - call c_f_pointer (w_c_instance, whizard_instance) - call lexer_init_cmd_list (lexer) - call syntax_cmd_list_init () - - call stream_init (stream, cmds) - call lexer_assign_stream (lexer, stream) - call parse_tree_init (parse_tree, syntax_cmd_list, lexer) - pn_root => parse_tree%get_root_ptr () - - if (associated (pn_root)) then - call cmd_list%compile (pn_root, whizard_instance%global) - end if - call whizard_instance%global%activate () - call cmd_list%execute (whizard_instance%global) - call cmd_list%final () - - call parse_tree_final (parse_tree) - call stream_final (stream) - call lexer_final (lexer) - call syntax_cmd_list_final () - end subroutine c_whizard_commands - -@ -<>= - subroutine c_whizard_init (w_c_instance) bind(C) - use, intrinsic :: iso_c_binding - use iso_varying_string, string_t => varying_string !NODEP! - use system_dependencies - use diagnostics - use ifiles - use os_interface - use whizard - - implicit none - - <> - - type(c_ptr), intent(out) :: w_c_instance - logical :: banner - type(string_t) :: files, model, default_lib, library, libraries -! type(string_t) :: check, checks - type(string_t) :: logfile - type(paths_t) :: paths - logical :: rebuild_library - logical :: rebuild_phs, rebuild_grids, rebuild_events - - type(whizard_options_t), allocatable :: options - type(whizard_t), pointer :: whizard_instance - - - ! Initial values - files = "" - model = "SM" - default_lib = "default_lib" - library = "" - libraries = "" - banner = .true. - logging = .true. - logfile = "whizard.log" -! check = "" -! checks = "" - rebuild_library = .false. - rebuild_phs = .false. - rebuild_grids = .false. - rebuild_events = .false. - call paths_init (paths) - - ! Overall initialization - if (logfile /= "") call logfile_init (logfile) - call mask_term_signals () - if (banner) call msg_banner () - - ! Set options and initialize the whizard object - allocate (options) - options%preload_model = model - options%default_lib = default_lib - options%preload_libraries = libraries - options%rebuild_library = rebuild_library - options%rebuild_phs = rebuild_phs - options%rebuild_grids = rebuild_grids - options%rebuild_events = rebuild_events - - allocate (whizard_instance) - call whizard_instance%init (options, paths) - -! if (checks /= "") then -! checks = trim (adjustl (checks)) -! RUN_CHECKS: do while (checks /= "") -! call split (checks, check, " ") -! call whizard_check (check, test_results) -! end do RUN_CHECKS -! call test_results%wrapup (6, success) -! if (.not. success) quit_code = 7 -! quit = .true. -! end if - - w_c_instance = c_loc (whizard_instance) - - end subroutine c_whizard_init - - subroutine c_whizard_finalize (w_c_instance) bind(C) - use, intrinsic :: iso_c_binding - use system_dependencies - use diagnostics - use ifiles - use os_interface - use whizard - - type(c_ptr), intent(in) :: w_c_instance - type(whizard_t), pointer :: whizard_instance - integer :: quit_code = 0 - - call c_f_pointer (w_c_instance, whizard_instance) - call whizard_instance%final () - deallocate (whizard_instance) - call terminate_now_if_signal () - call release_term_signals () - call msg_terminate (quit_code = quit_code) - end subroutine c_whizard_finalize - - subroutine c_whizard_process_string (w_c_instance, c_cmds_in) bind(C) - use, intrinsic :: iso_c_binding - use iso_varying_string, string_t => varying_string !NODEP! - - implicit none - - type(c_ptr), intent(inout) :: w_c_instance - character(kind=c_char) :: c_cmds_in(*) - type(string_t) :: f_cmds - - call c_whizard_convert_string (c_cmds_in, f_cmds) - call c_whizard_commands (w_c_instance, f_cmds) - end subroutine c_whizard_process_string - -@ -<>= - subroutine c_whizard_model (w_c_instance, c_model) bind(C) - use, intrinsic :: iso_c_binding - use iso_varying_string, string_t => varying_string !NODEP! - - implicit none - - type(c_ptr), intent(inout) :: w_c_instance - character(kind=c_char) :: c_model(*) - type(string_t) :: model, mdl_str - - call c_whizard_convert_string (c_model, model) - mdl_str = "model = " // model - call c_whizard_commands (w_c_instance, mdl_str) - end subroutine c_whizard_model - - subroutine c_whizard_library (w_c_instance, c_library) bind(C) - use, intrinsic :: iso_c_binding - use iso_varying_string, string_t => varying_string !NODEP! - - implicit none - - type(c_ptr), intent(inout) :: w_c_instance - character(kind=c_char) :: c_library(*) - type(string_t) :: library, lib_str - - call c_whizard_convert_string(c_library, library) - lib_str = "library = " // library - call c_whizard_commands (w_c_instance, lib_str) - end subroutine c_whizard_library - - subroutine c_whizard_process (w_c_instance, c_id, c_in, c_out) bind(C) - use, intrinsic :: iso_c_binding - use iso_varying_string, string_t => varying_string !NODEP! - - implicit none - - type(c_ptr), intent(inout) :: w_c_instance - character(kind=c_char) :: c_id(*), c_in(*), c_out(*) - type(string_t) :: proc_str, id, in, out - - call c_whizard_convert_string (c_id, id) - call c_whizard_convert_string (c_in, in) - call c_whizard_convert_string (c_out, out) - proc_str = "process " // id // " = " // in // " => " // out - call c_whizard_commands (w_c_instance, proc_str) - end subroutine c_whizard_process - - subroutine c_whizard_compile (w_c_instance) bind(C) - use, intrinsic :: iso_c_binding - use iso_varying_string, string_t => varying_string !NODEP! - - type(c_ptr), intent(inout) :: w_c_instance - type(string_t) :: cmp_str - cmp_str = "compile" - call c_whizard_commands (w_c_instance, cmp_str) - end subroutine c_whizard_compile - - subroutine c_whizard_beams (w_c_instance, c_specs) bind(C) - use, intrinsic :: iso_c_binding - use iso_varying_string, string_t => varying_string !NODEP! - - implicit none - - type(c_ptr), intent(inout) :: w_c_instance - character(kind=c_char) :: c_specs(*) - type(string_t) :: specs, beam_str - - call c_whizard_convert_string (c_specs, specs) - beam_str = "beams = " // specs - call c_whizard_commands (w_c_instance, beam_str) - end subroutine c_whizard_beams - - subroutine c_whizard_integrate (w_c_instance, c_process) bind(C) - use, intrinsic :: iso_c_binding - use iso_varying_string, string_t => varying_string !NODEP! - - implicit none - - type(c_ptr), intent(inout) :: w_c_instance - character(kind=c_char) :: c_process(*) - type(string_t) :: process, int_str - - call c_whizard_convert_string (c_process, process) - int_str = "integrate (" // process //")" - call c_whizard_commands (w_c_instance, int_str) - end subroutine c_whizard_integrate - - subroutine c_whizard_matrix_element_test & - (w_c_instance, c_process, n_calls) bind(C) - use, intrinsic :: iso_c_binding - use iso_varying_string, string_t => varying_string !NODEP! - - implicit none - - type(c_ptr), intent(inout) :: w_c_instance - integer(kind=c_int) :: n_calls - character(kind=c_char) :: c_process(*) - type(string_t) :: process, me_str - character(len=8) :: buffer - - call c_whizard_convert_string (c_process, process) - write (buffer, "(I0)") n_calls - me_str = "integrate (" // process // ") { ?phs_only = true" // & - " n_calls_test = " // trim (buffer) - call c_whizard_commands (w_c_instance, me_str) - end subroutine c_whizard_matrix_element_test - - subroutine c_whizard_simulate (w_c_instance, c_id) bind(C) - use, intrinsic :: iso_c_binding - use iso_varying_string, string_t => varying_string !NODEP! - - implicit none - - type(c_ptr), intent(inout) :: w_c_instance - character(kind=c_char) :: c_id(*) - type(string_t) :: sim_str, id - - call c_whizard_convert_string(c_id, id) - sim_str = "simulate (" // id // ")" - call c_whizard_commands (w_c_instance, sim_str) - end subroutine c_whizard_simulate - - subroutine c_whizard_sqrts (w_c_instance, c_value, c_unit) bind(C) - use, intrinsic :: iso_c_binding - use iso_varying_string, string_t => varying_string !NODEP! - - implicit none - - type(c_ptr), intent(inout) :: w_c_instance - character(kind=c_char) :: c_unit(*) - integer(kind=c_int) :: c_value - integer :: f_value - character(len=8) :: f_val - type(string_t) :: val, unit, sqrts_str - - f_value = c_value - write (f_val,'(i8)') f_value - val = f_val - call c_whizard_convert_string (c_unit, unit) - sqrts_str = "sqrts =" // val // unit - call c_whizard_commands (w_c_instance, sqrts_str) - end subroutine c_whizard_sqrts - -@ -<>= - type(c_ptr) function c_whizard_hepmc_test & - (w_c_instance, c_id, c_proc_id, c_event_id) bind(C) - use, intrinsic :: iso_c_binding - use iso_varying_string, string_t => varying_string !NODEP! - use commands - use diagnostics - use events - use hepmc_interface - use lexers - use models - use parser - use instances - use rt_data - use simulations - use whizard - use os_interface - - implicit none - - type(c_ptr), intent(inout) :: w_c_instance - type(string_t) :: sim_str - type(parse_tree_t) :: parse_tree - type(parse_node_t), pointer :: pn_root - type(stream_t), target :: stream - type(lexer_t) :: lexer - type(command_list_t), pointer :: cmd_list - type(whizard_t), pointer :: whizard_instance - - type(simulation_t), target :: sim - - character(kind=c_char), intent(in) :: c_id(*) - type(string_t) :: id - integer(kind=c_int), value :: c_proc_id, c_event_id - integer :: proc_id - - type(hepmc_event_t), pointer :: hepmc_event - - call c_f_pointer (w_c_instance, whizard_instance) - - call c_whizard_convert_string (c_id, id) - sim_str = "simulate (" // id // ")" - - proc_id = c_proc_id - - allocate (hepmc_event) - call hepmc_event_init (hepmc_event, c_proc_id, c_event_id) - - call syntax_cmd_list_init () - call lexer_init_cmd_list (lexer) - - call stream_init (stream, sim_str) - call lexer_assign_stream (lexer, stream) - call parse_tree_init (parse_tree, syntax_cmd_list, lexer) - pn_root => parse_tree%get_root_ptr () - - allocate (cmd_list) - if (associated (pn_root)) then - call cmd_list%compile (pn_root, whizard_instance%global) - end if - - call sim%init ([id], .true., .true., whizard_instance%global) - - !!! This should generate a HepMC event as hepmc_event_t type - call msg_message ("Not enabled for the moment.") - - call sim%final () - - call cmd_list%final () - - call parse_tree_final (parse_tree) - call stream_final (stream) - call lexer_final (lexer) - call syntax_cmd_list_final () - - c_whizard_hepmc_test = c_loc(hepmc_event) - return - end function c_whizard_hepmc_test -@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Index: trunk/src/matrix_elements/Makefile.am =================================================================== --- trunk/src/matrix_elements/Makefile.am (revision 8428) +++ trunk/src/matrix_elements/Makefile.am (revision 8429) @@ -1,209 +1,210 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement quantum field theory concepts ## such as model representation and quantum numbers. ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libmatrix_elements.la check_LTLIBRARIES = libmatrix_elements_ut.la libmatrix_elements_la_SOURCES = \ process_constants.f90 \ prclib_interfaces.f90 \ prc_core_def.f90 \ process_libraries.f90 \ prclib_stacks.f90 \ prc_test.f90 libmatrix_elements_ut_la_SOURCES = \ prclib_interfaces_uti.f90 prclib_interfaces_ut.f90 \ process_libraries_uti.f90 process_libraries_ut.f90 \ prclib_stacks_uti.f90 prclib_stacks_ut.f90 \ prc_test_uti.f90 prc_test_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = matrix_elements.nw +# Modules and installation +# Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libmatrix_elements_la_SOURCES:.f90=.$(FCMOD)} + # Dump module names into file Modules libmatrix_elements_Modules = \ ${libmatrix_elements_la_SOURCES:.f90=} \ ${libmatrix_elements_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libmatrix_elements_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../combinatorics/Modules \ ../parsing/Modules \ ../qft/Modules \ ../types/Modules \ ../physics/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libmatrix_elements_la_SOURCES) \ $(libmatrix_elements_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libmatrix_elements_la_SOURCES) \ $(libmatrix_elements_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../parsing -I../physics -I../qft -I../types ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -execmoddir = $(pkglibdir)/mod/matrix_elements -nodist_execmod_HEADERS = \ - prclib_interfaces.$(FC_MODULE_EXT) - ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw matrix_elements.stamp: $(PRELUDE) $(srcdir)/matrix_elements.nw $(POSTLUDE) @rm -f matrix_elements.tmp @touch matrix_elements.tmp for src in \ $(libmatrix_elements_la_SOURCES) \ $(libmatrix_elements_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f matrix_elements.tmp matrix_elements.stamp $(libmatrix_elements_la_SOURCES) $(libmatrix_elements_ut_la_SOURCES): matrix_elements.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f matrix_elements.stamp; \ $(MAKE) $(AM_MAKEFLAGS) matrix_elements.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f matrix_elements.stamp matrix_elements.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/qed_pdf/Makefile.am =================================================================== --- trunk/src/qed_pdf/Makefile.am (revision 8428) +++ trunk/src/qed_pdf/Makefile.am (revision 8429) @@ -1,179 +1,184 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory handle unit tests in Fortran. ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libqed_pdf.la libqed_pdf_la_SOURCES = \ electron_pdfs.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = qed_pdf.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libqed_pdf_la_SOURCES:.f90=.$(FCMOD)} + libqed_pdf_Modules = ${libqed_pdf_la_SOURCES:.f90=} Modules: Makefile @for module in $(libqed_pdf_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../physics/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libqed_pdf_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libqed_pdf_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../system -I../physics ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw qed_pdf.stamp: $(PRELUDE) $(srcdir)/qed_pdf.nw $(POSTLUDE) @rm -f qed_pdf.tmp @touch qed_pdf.tmp for src in $(libqed_pdf_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f qed_pdf.tmp qed_pdf.stamp $(libqed_pdf_la_SOURCES): qed_pdf.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f qed_pdf.stamp; \ $(MAKE) $(AM_MAKEFLAGS) qed_pdf.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f qed_pdf.stamp qed_pdf.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/events/events.nw =================================================================== --- trunk/src/events/events.nw (revision 8428) +++ trunk/src/events/events.nw (revision 8429) @@ -1,17123 +1,17311 @@ %% -*- ess-noweb-default-code-mode: f90-mode; noweb-default-code-mode: f90-mode; -*- % WHIZARD code as NOWEB source: event handling objects %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Generic Event Handling} \includemodulegraph{events} Event records allow the MC to communicate with the outside world. The event record should exhibit the observable contents of a physical event. We should be able to read and write events. The actual implementation of the event need not be defined yet, for that purpose. We have the following basic modules: \begin{description} \item[event\_base] Abstract base type for event records. The base type contains a reference to a [[particle_set_t]] object as the event core, and it holds some data that we should always expect, such as the squared matrix element and event weight. \item[eio\_data] Transparent container for the metadata of an event sample. \item[eio\_base] Abstract base type for event-record input and output. The implementations of this base type represent specific event I/O formats. \end{description} These are the implementation modules: \begin{description} \item[eio\_checkpoints] Auxiliary output format. The only purpose is to provide screen diagnostics during event output. \item[eio\_callback] Auxiliary output format. The only purpose is to execute a callback procedure, so we have a hook for external access during event output. \item[eio\_weights] Print some event summary data, no details. The main use if for testing purposes. \item[eio\_dump] Dump the contents of WHIZARD's [[particle_set]] internal record, using the [[write]] method of that record as-is. The main use if for testing purposes. \item[hep\_common] Implements traditional HEP common blocks that are (still) used by some of the event I/O formats below. \item[hepmc\_interface] Access particle objects of the HepMC package. Functional only if this package is linked. The interface is working both for HepMC2 and HepMC3. \item[lcio\_interface] Access objects of the LCIO package. Functional only if this package is linked. \item[hep\_events] Interface between the event record and the common blocks. \item[eio\_ascii] Collection of event output formats that write ASCII files. \item[eio\_lhef] LHEF for input and output. \item[eio\_stdhep] Support for the StdHEP format (binary, machine-independent). \item[eio\_hepmc] Support for the HepMC format (C++). \item[eio\_lcio] Support for the LCIO format (C++). \end{description} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Generic Event Handling} We introduce events first in form of an abstract type, together with some utilities. Abstract events can be used by other modules, in particular event I/O, without introducing an explicit dependency on the event implementation. <<[[event_base.f90]]>>= <> module event_base <> use kinds, only: i64 <> use io_units use string_utils, only: lower_case use diagnostics use model_data use particles <> <> <> <> <> contains <> end module event_base @ %def event_base @ \subsection{generic event type} <>= public :: generic_event_t <>= type, abstract :: generic_event_t !private logical :: particle_set_is_valid = .false. type(particle_set_t), pointer :: particle_set => null () logical :: sqme_ref_known = .false. real(default) :: sqme_ref = 0 logical :: sqme_prc_known = .false. real(default) :: sqme_prc = 0 logical :: weight_ref_known = .false. real(default) :: weight_ref = 0 logical :: weight_prc_known = .false. real(default) :: weight_prc = 0 logical :: excess_prc_known = .false. real(default) :: excess_prc = 0 logical :: n_dropped_known = .false. integer :: n_dropped = 0 integer :: n_alt = 0 logical :: sqme_alt_known = .false. real(default), dimension(:), allocatable :: sqme_alt logical :: weight_alt_known = .false. real(default), dimension(:), allocatable :: weight_alt contains <> end type generic_event_t @ %def generic_event_t @ \subsection{Initialization} This determines the number of alternate weights and sqme values. <>= procedure :: base_init => generic_event_init <>= subroutine generic_event_init (event, n_alt) class(generic_event_t), intent(out) :: event integer, intent(in) :: n_alt event%n_alt = n_alt allocate (event%sqme_alt (n_alt)) allocate (event%weight_alt (n_alt)) end subroutine generic_event_init @ %def generic_event_init @ \subsection{Access particle set} The particle set is the core of the event. We allow access to it via a pointer, and we maintain the information whether the particle set is valid, i.e., has been filled with meaningful data. <>= procedure :: has_valid_particle_set => generic_event_has_valid_particle_set procedure :: accept_particle_set => generic_event_accept_particle_set procedure :: discard_particle_set => generic_event_discard_particle_set <>= function generic_event_has_valid_particle_set (event) result (flag) class(generic_event_t), intent(in) :: event logical :: flag flag = event%particle_set_is_valid end function generic_event_has_valid_particle_set subroutine generic_event_accept_particle_set (event) class(generic_event_t), intent(inout) :: event event%particle_set_is_valid = .true. end subroutine generic_event_accept_particle_set subroutine generic_event_discard_particle_set (event) class(generic_event_t), intent(inout) :: event event%particle_set_is_valid = .false. end subroutine generic_event_discard_particle_set @ %def generic_event_has_valid_particle_set @ %def generic_event_accept_particle_set @ %def generic_event_discard_particle_set @ These procedures deal with the particle set directly. Return the pointer: <>= procedure :: get_particle_set_ptr => generic_event_get_particle_set_ptr <>= function generic_event_get_particle_set_ptr (event) result (ptr) class(generic_event_t), intent(in) :: event type(particle_set_t), pointer :: ptr ptr => event%particle_set end function generic_event_get_particle_set_ptr @ %def generic_event_get_particle_set_ptr @ Let it point to some existing particle set: <>= procedure :: link_particle_set => generic_event_link_particle_set <>= subroutine generic_event_link_particle_set (event, particle_set) class(generic_event_t), intent(inout) :: event type(particle_set_t), intent(in), target :: particle_set event%particle_set => particle_set call event%accept_particle_set () end subroutine generic_event_link_particle_set @ %def generic_event_link_particle_set @ \subsection{Access sqme and weight} There are several incarnations: the current value, a reference value, alternate values. <>= procedure :: sqme_prc_is_known => generic_event_sqme_prc_is_known procedure :: sqme_ref_is_known => generic_event_sqme_ref_is_known procedure :: sqme_alt_is_known => generic_event_sqme_alt_is_known procedure :: weight_prc_is_known => generic_event_weight_prc_is_known procedure :: weight_ref_is_known => generic_event_weight_ref_is_known procedure :: weight_alt_is_known => generic_event_weight_alt_is_known procedure :: excess_prc_is_known => generic_event_excess_prc_is_known <>= function generic_event_sqme_prc_is_known (event) result (flag) class(generic_event_t), intent(in) :: event logical :: flag flag = event%sqme_prc_known end function generic_event_sqme_prc_is_known function generic_event_sqme_ref_is_known (event) result (flag) class(generic_event_t), intent(in) :: event logical :: flag flag = event%sqme_ref_known end function generic_event_sqme_ref_is_known function generic_event_sqme_alt_is_known (event) result (flag) class(generic_event_t), intent(in) :: event logical :: flag flag = event%sqme_alt_known end function generic_event_sqme_alt_is_known function generic_event_weight_prc_is_known (event) result (flag) class(generic_event_t), intent(in) :: event logical :: flag flag = event%weight_prc_known end function generic_event_weight_prc_is_known function generic_event_weight_ref_is_known (event) result (flag) class(generic_event_t), intent(in) :: event logical :: flag flag = event%weight_ref_known end function generic_event_weight_ref_is_known function generic_event_weight_alt_is_known (event) result (flag) class(generic_event_t), intent(in) :: event logical :: flag flag = event%weight_alt_known end function generic_event_weight_alt_is_known function generic_event_excess_prc_is_known (event) result (flag) class(generic_event_t), intent(in) :: event logical :: flag flag = event%excess_prc_known end function generic_event_excess_prc_is_known @ %def generic_event_sqme_prc_is_known @ %def generic_event_sqme_ref_is_known @ %def generic_event_sqme_alt_is_known @ %def generic_event_weight_prc_is_known @ %def generic_event_weight_ref_is_known @ %def generic_event_weight_alt_is_known @ %def generic_event_excess_prc_is_known @ <>= procedure :: get_n_alt => generic_event_get_n_alt <>= function generic_event_get_n_alt (event) result (n) class(generic_event_t), intent(in) :: event integer :: n n = event%n_alt end function generic_event_get_n_alt @ %def generic_event_get_n_alt @ <>= procedure :: get_sqme_prc => generic_event_get_sqme_prc procedure :: get_sqme_ref => generic_event_get_sqme_ref generic :: get_sqme_alt => & generic_event_get_sqme_alt_0, generic_event_get_sqme_alt_1 procedure :: generic_event_get_sqme_alt_0 procedure :: generic_event_get_sqme_alt_1 procedure :: get_weight_prc => generic_event_get_weight_prc procedure :: get_weight_ref => generic_event_get_weight_ref generic :: get_weight_alt => & generic_event_get_weight_alt_0, generic_event_get_weight_alt_1 procedure :: generic_event_get_weight_alt_0 procedure :: generic_event_get_weight_alt_1 procedure :: get_n_dropped => generic_event_get_n_dropped procedure :: get_excess_prc => generic_event_get_excess_prc <>= function generic_event_get_sqme_prc (event) result (sqme) class(generic_event_t), intent(in) :: event real(default) :: sqme if (event%sqme_prc_known) then sqme = event%sqme_prc else sqme = 0 end if end function generic_event_get_sqme_prc function generic_event_get_sqme_ref (event) result (sqme) class(generic_event_t), intent(in) :: event real(default) :: sqme if (event%sqme_ref_known) then sqme = event%sqme_ref else sqme = 0 end if end function generic_event_get_sqme_ref function generic_event_get_sqme_alt_0 (event, i) result (sqme) class(generic_event_t), intent(in) :: event integer, intent(in) :: i real(default) :: sqme if (event%sqme_alt_known) then sqme = event%sqme_alt(i) else sqme = 0 end if end function generic_event_get_sqme_alt_0 function generic_event_get_sqme_alt_1 (event) result (sqme) class(generic_event_t), intent(in) :: event real(default), dimension(event%n_alt) :: sqme sqme = event%sqme_alt end function generic_event_get_sqme_alt_1 function generic_event_get_weight_prc (event) result (weight) class(generic_event_t), intent(in) :: event real(default) :: weight if (event%weight_prc_known) then weight = event%weight_prc else weight = 0 end if end function generic_event_get_weight_prc function generic_event_get_weight_ref (event) result (weight) class(generic_event_t), intent(in) :: event real(default) :: weight if (event%weight_ref_known) then weight = event%weight_ref else weight = 0 end if end function generic_event_get_weight_ref function generic_event_get_weight_alt_0 (event, i) result (weight) class(generic_event_t), intent(in) :: event integer, intent(in) :: i real(default) :: weight if (event%weight_alt_known) then weight = event%weight_alt(i) else weight = 0 end if end function generic_event_get_weight_alt_0 function generic_event_get_weight_alt_1 (event) result (weight) class(generic_event_t), intent(in) :: event real(default), dimension(event%n_alt) :: weight weight = event%weight_alt end function generic_event_get_weight_alt_1 function generic_event_get_excess_prc (event) result (excess) class(generic_event_t), intent(in) :: event real(default) :: excess if (event%excess_prc_known) then excess = event%excess_prc else excess = 0 end if end function generic_event_get_excess_prc function generic_event_get_n_dropped (event) result (n_dropped) class(generic_event_t), intent(in) :: event integer :: n_dropped if (event%n_dropped_known) then n_dropped = event%n_dropped else n_dropped = 0 end if end function generic_event_get_n_dropped @ %def generic_event_get_sqme_prc @ %def generic_event_get_sqme_ref @ %def generic_event_get_sqme_alt @ %def generic_event_get_weight_prc @ %def generic_event_get_weight_ref @ %def generic_event_get_weight_alt @ %def generic_event_get_n_dropped @ %def generic_event_get_excess_prc @ <>= procedure :: set_sqme_prc => generic_event_set_sqme_prc procedure :: set_sqme_ref => generic_event_set_sqme_ref procedure :: set_sqme_alt => generic_event_set_sqme_alt procedure :: set_weight_prc => generic_event_set_weight_prc procedure :: set_weight_ref => generic_event_set_weight_ref procedure :: set_weight_alt => generic_event_set_weight_alt procedure :: set_excess_prc => generic_event_set_excess_prc procedure :: set_n_dropped => generic_event_set_n_dropped <>= subroutine generic_event_set_sqme_prc (event, sqme) class(generic_event_t), intent(inout) :: event real(default), intent(in) :: sqme event%sqme_prc = sqme event%sqme_prc_known = .true. end subroutine generic_event_set_sqme_prc subroutine generic_event_set_sqme_ref (event, sqme) class(generic_event_t), intent(inout) :: event real(default), intent(in) :: sqme event%sqme_ref = sqme event%sqme_ref_known = .true. end subroutine generic_event_set_sqme_ref subroutine generic_event_set_sqme_alt (event, sqme) class(generic_event_t), intent(inout) :: event real(default), dimension(:), intent(in) :: sqme event%sqme_alt = sqme event%sqme_alt_known = .true. end subroutine generic_event_set_sqme_alt subroutine generic_event_set_weight_prc (event, weight) class(generic_event_t), intent(inout) :: event real(default), intent(in) :: weight event%weight_prc = weight event%weight_prc_known = .true. end subroutine generic_event_set_weight_prc subroutine generic_event_set_weight_ref (event, weight) class(generic_event_t), intent(inout) :: event real(default), intent(in) :: weight event%weight_ref = weight event%weight_ref_known = .true. end subroutine generic_event_set_weight_ref subroutine generic_event_set_weight_alt (event, weight) class(generic_event_t), intent(inout) :: event real(default), dimension(:), intent(in) :: weight event%weight_alt = weight event%weight_alt_known = .true. end subroutine generic_event_set_weight_alt subroutine generic_event_set_excess_prc (event, excess) class(generic_event_t), intent(inout) :: event real(default), intent(in) :: excess event%excess_prc = excess event%excess_prc_known = .true. end subroutine generic_event_set_excess_prc subroutine generic_event_set_n_dropped (event, n_dropped) class(generic_event_t), intent(inout) :: event integer, intent(in) :: n_dropped event%n_dropped = n_dropped event%n_dropped_known = .true. end subroutine generic_event_set_n_dropped @ %def generic_event_set_sqme_prc @ %def generic_event_set_sqme_ref @ %def generic_event_set_sqme_alt @ %def generic_event_set_weight_prc @ %def generic_event_set_weight_ref @ %def generic_event_set_weight_alt @ %def generic_event_set_n_dropped @ Set the appropriate entry directly. <>= procedure :: set => generic_event_set <>= subroutine generic_event_set (event, & weight_ref, weight_prc, weight_alt, & excess_prc, n_dropped, & sqme_ref, sqme_prc, sqme_alt) class(generic_event_t), intent(inout) :: event real(default), intent(in), optional :: weight_ref, weight_prc real(default), intent(in), optional :: sqme_ref, sqme_prc real(default), dimension(:), intent(in), optional :: sqme_alt, weight_alt real(default), intent(in), optional :: excess_prc integer, intent(in), optional :: n_dropped if (present (sqme_prc)) then call event%set_sqme_prc (sqme_prc) end if if (present (sqme_ref)) then call event%set_sqme_ref (sqme_ref) end if if (present (sqme_alt)) then call event%set_sqme_alt (sqme_alt) end if if (present (weight_prc)) then call event%set_weight_prc (weight_prc) end if if (present (weight_ref)) then call event%set_weight_ref (weight_ref) end if if (present (weight_alt)) then call event%set_weight_alt (weight_alt) end if if (present (excess_prc)) then call event%set_excess_prc (excess_prc) end if if (present (n_dropped)) then call event%set_n_dropped (n_dropped) end if end subroutine generic_event_set @ %def generic_event_set @ \subsection{Pure Virtual Methods} These procedures can only implemented in the concrete implementation. Output (verbose, depending on parameters). <>= procedure (generic_event_write), deferred :: write <>= abstract interface subroutine generic_event_write (object, unit, & show_process, show_transforms, & show_decay, verbose, testflag) import class(generic_event_t), intent(in) :: object integer, intent(in), optional :: unit logical, intent(in), optional :: show_process logical, intent(in), optional :: show_transforms logical, intent(in), optional :: show_decay logical, intent(in), optional :: verbose logical, intent(in), optional :: testflag end subroutine generic_event_write end interface @ %def generic_event_write @ Generate an event, based on a selector index [[i_mci]], and optionally on an extra set of random numbers [[r]]. For the main bunch of random numbers that the generator needs, the event object should contain its own generator. <>= procedure (generic_event_generate), deferred :: generate <>= abstract interface subroutine generic_event_generate (event, i_mci, r, i_nlo) import class(generic_event_t), intent(inout) :: event integer, intent(in) :: i_mci real(default), dimension(:), intent(in), optional :: r integer, intent(in), optional :: i_nlo end subroutine generic_event_generate end interface @ %def event_generate @ Alternative : inject a particle set that is supposed to represent the hard process. How this determines the event, is dependent on the event structure, therefore this is a deferred method. <>= procedure (generic_event_set_hard_particle_set), deferred :: & set_hard_particle_set <>= abstract interface subroutine generic_event_set_hard_particle_set (event, particle_set) import class(generic_event_t), intent(inout) :: event type(particle_set_t), intent(in) :: particle_set end subroutine generic_event_set_hard_particle_set end interface @ %def generic_event_set_hard_particle_set @ Event index handlers. <>= procedure (generic_event_set_index), deferred :: set_index procedure (generic_event_handler), deferred :: reset_index procedure (generic_event_increment_index), deferred :: increment_index @ <>= abstract interface subroutine generic_event_set_index (event, index) import class(generic_event_t), intent(inout) :: event integer, intent(in) :: index end subroutine generic_event_set_index end interface abstract interface subroutine generic_event_handler (event) import class(generic_event_t), intent(inout) :: event end subroutine generic_event_handler end interface abstract interface subroutine generic_event_increment_index (event, offset) import class(generic_event_t), intent(inout) :: event integer, intent(in), optional :: offset end subroutine generic_event_increment_index end interface @ %def generic_event_set_index @ %def generic_event_increment_index @ %def generic_event_handler @ Evaluate any expressions associated with the event. No argument needed. <>= procedure (generic_event_handler), deferred :: evaluate_expressions @ Select internal parameters <>= procedure (generic_event_select), deferred :: select <>= abstract interface subroutine generic_event_select (event, i_mci, i_term, channel) import class(generic_event_t), intent(inout) :: event integer, intent(in) :: i_mci, i_term, channel end subroutine generic_event_select end interface @ %def generic_event_select @ Return a pointer to the model for the currently active process. <>= procedure (generic_event_get_model_ptr), deferred :: get_model_ptr <>= abstract interface function generic_event_get_model_ptr (event) result (model) import class(generic_event_t), intent(in) :: event class(model_data_t), pointer :: model end function generic_event_get_model_ptr end interface @ %def generic_event_get_model_ptr @ Return data used by external event formats. <>= procedure (generic_event_has_index), deferred :: has_index procedure (generic_event_get_index), deferred :: get_index procedure (generic_event_get_fac_scale), deferred :: get_fac_scale procedure (generic_event_get_alpha_s), deferred :: get_alpha_s procedure (generic_event_get_sqrts), deferred :: get_sqrts procedure (generic_event_get_polarization), deferred :: get_polarization procedure (generic_event_get_beam_file), deferred :: get_beam_file procedure (generic_event_get_process_name), deferred :: & get_process_name <>= abstract interface function generic_event_has_index (event) result (flag) import class(generic_event_t), intent(in) :: event logical :: flag end function generic_event_has_index end interface abstract interface function generic_event_get_index (event) result (index) import class(generic_event_t), intent(in) :: event integer :: index end function generic_event_get_index end interface abstract interface function generic_event_get_fac_scale (event) result (fac_scale) import class(generic_event_t), intent(in) :: event real(default) :: fac_scale end function generic_event_get_fac_scale end interface abstract interface function generic_event_get_alpha_s (event) result (alpha_s) import class(generic_event_t), intent(in) :: event real(default) :: alpha_s end function generic_event_get_alpha_s end interface abstract interface function generic_event_get_sqrts (event) result (sqrts) import class(generic_event_t), intent(in) :: event real(default) :: sqrts end function generic_event_get_sqrts end interface abstract interface function generic_event_get_polarization (event) result (pol) import class(generic_event_t), intent(in) :: event real(default), dimension(2) :: pol end function generic_event_get_polarization end interface abstract interface function generic_event_get_beam_file (event) result (file) import class(generic_event_t), intent(in) :: event type(string_t) :: file end function generic_event_get_beam_file end interface abstract interface function generic_event_get_process_name (event) result (name) import class(generic_event_t), intent(in) :: event type(string_t) :: name end function generic_event_get_process_name end interface @ %def generic_event_get_index @ %def generic_event_get_fac_scale @ %def generic_event_get_alpha_s @ %def generic_event_get_sqrts @ %def generic_event_get_polarization @ %def generic_event_get_beam_file @ %def generic_event_get_process_name @ Set data used by external event formats. <>= procedure (generic_event_set_alpha_qcd_forced), deferred :: & set_alpha_qcd_forced procedure (generic_event_set_scale_forced), deferred :: & set_scale_forced <>= abstract interface subroutine generic_event_set_alpha_qcd_forced (event, alpha_qcd) import class(generic_event_t), intent(inout) :: event real(default), intent(in) :: alpha_qcd end subroutine generic_event_set_alpha_qcd_forced end interface abstract interface subroutine generic_event_set_scale_forced (event, scale) import class(generic_event_t), intent(inout) :: event real(default), intent(in) :: scale end subroutine generic_event_set_scale_forced end interface @ %def generic_event_set_alpha_qcd_forced @ %def generic_event_set_scale_forced @ \subsection{Utilities} Applying this, current event contents are marked as incomplete but are not deleted. In particular, the initialization is kept. <>= procedure :: reset_contents => generic_event_reset_contents procedure :: base_reset_contents => generic_event_reset_contents <>= subroutine generic_event_reset_contents (event) class(generic_event_t), intent(inout) :: event call event%discard_particle_set () event%sqme_ref_known = .false. event%sqme_prc_known = .false. event%sqme_alt_known = .false. event%weight_ref_known = .false. event%weight_prc_known = .false. event%weight_alt_known = .false. event%excess_prc_known = .false. end subroutine generic_event_reset_contents @ %def generic_event_reset_contents @ Pacify particle set. <>= procedure :: pacify_particle_set => generic_event_pacify_particle_set <>= subroutine generic_event_pacify_particle_set (event) class(generic_event_t), intent(inout) :: event if (event%has_valid_particle_set ()) call pacify (event%particle_set) end subroutine generic_event_pacify_particle_set @ %def generic_event_pacify_particle_set @ \subsection{Event normalization} The parameters for event normalization. For unweighted events, [[NORM_UNIT]] is intended as default, while for weighted events, it is [[NORM_SIGMA]]. Note: the unit test for this is in [[eio_data_2]] below. <>= integer, parameter, public :: NORM_UNDEFINED = 0 integer, parameter, public :: NORM_UNIT = 1 integer, parameter, public :: NORM_N_EVT = 2 integer, parameter, public :: NORM_SIGMA = 3 integer, parameter, public :: NORM_S_N = 4 @ %def NORM_UNDEFINED NORM_UNIT NORM_N_EVT NORM_SIGMA NORM_S_N @ These functions translate between the user representation and the internal one. <>= public :: event_normalization_mode public :: event_normalization_string <>= function event_normalization_mode (string, unweighted) result (mode) integer :: mode type(string_t), intent(in) :: string logical, intent(in) :: unweighted select case (lower_case (char (string))) case ("auto") if (unweighted) then mode = NORM_UNIT else mode = NORM_SIGMA end if case ("1") mode = NORM_UNIT case ("1/n") mode = NORM_N_EVT case ("sigma") mode = NORM_SIGMA case ("sigma/n") mode = NORM_S_N case default call msg_fatal ("Event normalization: unknown value '" & // char (string) // "'") end select end function event_normalization_mode function event_normalization_string (norm_mode) result (string) integer, intent(in) :: norm_mode type(string_t) :: string select case (norm_mode) case (NORM_UNDEFINED); string = "[undefined]" case (NORM_UNIT); string = "'1'" case (NORM_N_EVT); string = "'1/n'" case (NORM_SIGMA); string = "'sigma'" case (NORM_S_N); string = "'sigma/n'" case default; string = "???" end select end function event_normalization_string @ %def event_normalization_mode @ %def event_normalization_string @ We place this here as a generic helper, so we can update event weights whenever we need, not just in connection with an event sample data object. <>= public :: event_normalization_update <>= subroutine event_normalization_update (weight, sigma, n, mode_new, mode_old) real(default), intent(inout) :: weight real(default), intent(in) :: sigma integer, intent(in) :: n integer, intent(in) :: mode_new, mode_old if (mode_new /= mode_old) then if (sigma > 0 .and. n > 0) then weight = weight / factor (mode_old) * factor (mode_new) else call msg_fatal ("Event normalization update: null sample") end if end if contains function factor (mode) real(default) :: factor integer, intent(in) :: mode select case (mode) case (NORM_UNIT); factor = 1._default case (NORM_N_EVT); factor = 1._default / n case (NORM_SIGMA); factor = sigma case (NORM_S_N); factor = sigma / n case default call msg_fatal ("Event normalization update: undefined mode") end select end function factor end subroutine event_normalization_update @ %def event_normalization_update @ \subsection{Callback container} This derived type contains a callback procedure that can be executed during event I/O. The callback procedure is given the event object (with class [[generic_event]]) and an event index. This is a simple wrapper. The object is abstract, so the the actual procedure is introduced by overriding the deferred one. We use the PASS attribute, so we may supplement runtime data in the callback object if desired. <>= public :: event_callback_t <>= type, abstract :: event_callback_t private contains procedure(event_callback_write), deferred :: write procedure(event_callback_proc), deferred :: proc end type event_callback_t @ %def event_callback_t @ Identify the callback procedure in output <>= abstract interface subroutine event_callback_write (event_callback, unit) import class(event_callback_t), intent(in) :: event_callback integer, intent(in), optional :: unit end subroutine event_callback_write end interface @ %def event_callback_write @ This is the procedure interface. <>= abstract interface subroutine event_callback_proc (event_callback, i, event) import class(event_callback_t), intent(in) :: event_callback integer(i64), intent(in) :: i class(generic_event_t), intent(in) :: event end subroutine event_callback_proc end interface @ %def event_callback_proc @ A dummy implementation for testing and fallback. <>= public :: event_callback_nop_t <>= type, extends (event_callback_t) :: event_callback_nop_t private contains procedure :: write => event_callback_nop_write procedure :: proc => event_callback_nop end type event_callback_nop_t @ %def event_callback_t <>= subroutine event_callback_nop_write (event_callback, unit) class(event_callback_nop_t), intent(in) :: event_callback integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A)") "NOP" end subroutine event_callback_nop_write subroutine event_callback_nop (event_callback, i, event) class(event_callback_nop_t), intent(in) :: event_callback integer(i64), intent(in) :: i class(generic_event_t), intent(in) :: event end subroutine event_callback_nop @ %def event_callback_nop_write @ %def event_callback_nop @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Event Handle} +This module defines an abstract base type that allows us to communicate any +type of event record within the program. The concrete extensions are expected +to consist of pointers, such as the C pointers for HepMC or LCIO events, so +the communication object is a very light-weight one. +<<[[event_handles.f90]]>>= +<> + +module event_handles + +<> + +<> + +<> + +end module event_handles +@ %def event_handles +@ +There is only one abstract type. +<>= + public :: event_handle_t +<>= + type, abstract :: event_handle_t + end type event_handle_t + +@ %def event_handle_t +@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Event Sample Data} We define a simple and transparent container for (meta)data that are associated with an event sample. <<[[eio_data.f90]]>>= <> module eio_data <> <> use io_units use numeric_utils use diagnostics use event_base <> <> <> contains <> end module eio_data @ %def eio_data @ \subsection{Event Sample Data} These are data that apply to an event sample as a whole. They are given in an easily portable form (no fancy structure) and are used for initializing event formats. There are two MD5 sums here. [[md5sum_proc]] depends only on the definition of the contributing processes. A sample with matching checksum can be rescanned with modified model parameters, beam structure etc, to recalculate observables. [[md5sum_config]] includes all relevant data. Rescanning a sample with matching checksum will produce identical observables. (A third checksum might be added which depends on the event sample itself. This is not needed, so far.) If alternate weights are part of the event sample ([[n_alt]] nonzero), there is a configuration MD5 sum for each of them. <>= public :: event_sample_data_t <>= type :: event_sample_data_t character(32) :: md5sum_prc = "" character(32) :: md5sum_cfg = "" logical :: unweighted = .true. logical :: negative_weights = .false. integer :: norm_mode = NORM_UNDEFINED integer :: n_beam = 0 integer, dimension(2) :: pdg_beam = 0 real(default), dimension(2) :: energy_beam = 0 integer :: n_proc = 0 integer :: n_evt = 0 integer :: nlo_multiplier = 1 integer :: split_n_evt = 0 integer :: split_n_kbytes = 0 integer :: split_index = 0 real(default) :: total_cross_section = 0 integer, dimension(:), allocatable :: proc_num_id integer :: n_alt = 0 character(32), dimension(:), allocatable :: md5sum_alt real(default), dimension(:), allocatable :: cross_section real(default), dimension(:), allocatable :: error contains <> end type event_sample_data_t @ %def event_sample_data_t @ Initialize: allocate for the number of processes <>= procedure :: init => event_sample_data_init <>= subroutine event_sample_data_init (data, n_proc, n_alt) class(event_sample_data_t), intent(out) :: data integer, intent(in) :: n_proc integer, intent(in), optional :: n_alt data%n_proc = n_proc allocate (data%proc_num_id (n_proc), source = 0) allocate (data%cross_section (n_proc), source = 0._default) allocate (data%error (n_proc), source = 0._default) if (present (n_alt)) then data%n_alt = n_alt allocate (data%md5sum_alt (n_alt)) data%md5sum_alt = "" end if end subroutine event_sample_data_init @ %def event_sample_data_init @ Output. <>= procedure :: write => event_sample_data_write <>= subroutine event_sample_data_write (data, unit) class(event_sample_data_t), intent(in) :: data integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit) write (u, "(1x,A)") "Event sample properties:" write (u, "(3x,A,A,A)") "MD5 sum (proc) = '", data%md5sum_prc, "'" write (u, "(3x,A,A,A)") "MD5 sum (config) = '", data%md5sum_cfg, "'" write (u, "(3x,A,L1)") "unweighted = ", data%unweighted write (u, "(3x,A,L1)") "negative weights = ", data%negative_weights write (u, "(3x,A,A)") "normalization = ", & char (event_normalization_string (data%norm_mode)) write (u, "(3x,A,I0)") "number of beams = ", data%n_beam write (u, "(5x,A,2(1x,I19))") "PDG = ", & data%pdg_beam(:data%n_beam) write (u, "(5x,A,2(1x,ES19.12))") "Energy = ", & data%energy_beam(:data%n_beam) if (data%n_evt > 0) then write (u, "(3x,A,I0)") "number of events = ", data%n_evt end if if (.not. vanishes (data%total_cross_section)) then write (u, "(3x,A,ES19.12)") "total cross sec. = ", & data%total_cross_section end if write (u, "(3x,A,I0)") "num of processes = ", data%n_proc do i = 1, data%n_proc write (u, "(3x,A,I0)") "Process #", data%proc_num_id (i) select case (data%n_beam) case (1) write (u, "(5x,A,ES19.12)") "Width = ", data%cross_section(i) case (2) write (u, "(5x,A,ES19.12)") "CSec = ", data%cross_section(i) end select write (u, "(5x,A,ES19.12)") "Error = ", data%error(i) end do if (data%n_alt > 0) then write (u, "(3x,A,I0)") "num of alt wgt = ", data%n_alt do i = 1, data%n_alt write (u, "(5x,A,A,A,1x,I0)") "MD5 sum (cfg) = '", & data%md5sum_alt(i), "'", i end do end if end subroutine event_sample_data_write @ %def event_sample_data_write @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[eio_data_ut.f90]]>>= <> module eio_data_ut use unit_tests use eio_data_uti <> <> contains <> end module eio_data_ut @ %def eio_data_ut @ <<[[eio_data_uti.f90]]>>= <> module eio_data_uti <> <> use event_base use eio_data <> <> contains <> end module eio_data_uti @ %def eio_data_ut @ API: driver for the unit tests below. <>= public :: eio_data_test <>= subroutine eio_data_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine eio_data_test @ %def eio_data_test @ \subsubsection{Event Sample Data} Print the contents of a sample data block. <>= call test (eio_data_1, "eio_data_1", & "event sample data", & u, results) <>= public :: eio_data_1 <>= subroutine eio_data_1 (u) integer, intent(in) :: u type(event_sample_data_t) :: data write (u, "(A)") "* Test output: eio_data_1" write (u, "(A)") "* Purpose: display event sample data" write (u, "(A)") write (u, "(A)") "* Decay process, one component" write (u, "(A)") call data%init (1, 1) data%n_beam = 1 data%pdg_beam(1) = 25 data%energy_beam(1) = 125 data%norm_mode = NORM_UNIT data%proc_num_id = [42] data%cross_section = [1.23e-4_default] data%error = 5e-6_default data%md5sum_prc = "abcdefghijklmnopabcdefghijklmnop" data%md5sum_cfg = "12345678901234561234567890123456" data%md5sum_alt(1) = "uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu" call data%write (u) write (u, "(A)") write (u, "(A)") "* Scattering process, two components" write (u, "(A)") call data%init (2) data%n_beam = 2 data%pdg_beam = [2212, -2212] data%energy_beam = [8._default, 10._default] data%norm_mode = NORM_SIGMA data%proc_num_id = [12, 34] data%cross_section = [100._default, 88._default] data%error = [1._default, 0.1_default] call data%write (u) write (u, "(A)") write (u, "(A)") "* Test output end: eio_data_1" end subroutine eio_data_1 @ %def eio_data_1 @ \subsubsection{Event Normalization} Check the functions for translating modes and updating weights. <>= call test (eio_data_2, "eio_data_2", & "event normalization", & u, results) <>= public :: eio_data_2 <>= subroutine eio_data_2 (u) integer, intent(in) :: u type(string_t) :: s logical :: unweighted real(default) :: w, w0, sigma integer :: n write (u, "(A)") "* Test output: eio_data_2" write (u, "(A)") "* Purpose: handle event normalization" write (u, "(A)") write (u, "(A)") "* Normalization strings" write (u, "(A)") s = "auto" unweighted = .true. write (u, "(1x,A,1x,L1,1x,A)") char (s), unweighted, & char (event_normalization_string & (event_normalization_mode (s, unweighted))) s = "AUTO" unweighted = .false. write (u, "(1x,A,1x,L1,1x,A)") char (s), unweighted, & char (event_normalization_string & (event_normalization_mode (s, unweighted))) unweighted = .true. s = "1" write (u, "(2(1x,A))") char (s), char (event_normalization_string & (event_normalization_mode (s, unweighted))) s = "1/n" write (u, "(2(1x,A))") char (s), char (event_normalization_string & (event_normalization_mode (s, unweighted))) s = "Sigma" write (u, "(2(1x,A))") char (s), char (event_normalization_string & (event_normalization_mode (s, unweighted))) s = "sigma/N" write (u, "(2(1x,A))") char (s), char (event_normalization_string & (event_normalization_mode (s, unweighted))) write (u, "(A)") write (u, "(A)") "* Normalization update" write (u, "(A)") sigma = 5 n = 2 w0 = 1 w = w0 call event_normalization_update (w, sigma, n, NORM_UNIT, NORM_UNIT) write (u, "(2(F6.3))") w0, w w = w0 call event_normalization_update (w, sigma, n, NORM_N_EVT, NORM_UNIT) write (u, "(2(F6.3))") w0, w w = w0 call event_normalization_update (w, sigma, n, NORM_SIGMA, NORM_UNIT) write (u, "(2(F6.3))") w0, w w = w0 call event_normalization_update (w, sigma, n, NORM_S_N, NORM_UNIT) write (u, "(2(F6.3))") w0, w write (u, *) w0 = 0.5 w = w0 call event_normalization_update (w, sigma, n, NORM_UNIT, NORM_N_EVT) write (u, "(2(F6.3))") w0, w w = w0 call event_normalization_update (w, sigma, n, NORM_N_EVT, NORM_N_EVT) write (u, "(2(F6.3))") w0, w w = w0 call event_normalization_update (w, sigma, n, NORM_SIGMA, NORM_N_EVT) write (u, "(2(F6.3))") w0, w w = w0 call event_normalization_update (w, sigma, n, NORM_S_N, NORM_N_EVT) write (u, "(2(F6.3))") w0, w write (u, *) w0 = 5.0 w = w0 call event_normalization_update (w, sigma, n, NORM_UNIT, NORM_SIGMA) write (u, "(2(F6.3))") w0, w w = w0 call event_normalization_update (w, sigma, n, NORM_N_EVT, NORM_SIGMA) write (u, "(2(F6.3))") w0, w w = w0 call event_normalization_update (w, sigma, n, NORM_SIGMA, NORM_SIGMA) write (u, "(2(F6.3))") w0, w w = w0 call event_normalization_update (w, sigma, n, NORM_S_N, NORM_SIGMA) write (u, "(2(F6.3))") w0, w write (u, *) w0 = 2.5 w = w0 call event_normalization_update (w, sigma, n, NORM_UNIT, NORM_S_N) write (u, "(2(F6.3))") w0, w w = w0 call event_normalization_update (w, sigma, n, NORM_N_EVT, NORM_S_N) write (u, "(2(F6.3))") w0, w w = w0 call event_normalization_update (w, sigma, n, NORM_SIGMA, NORM_S_N) write (u, "(2(F6.3))") w0, w w = w0 call event_normalization_update (w, sigma, n, NORM_S_N, NORM_S_N) write (u, "(2(F6.3))") w0, w write (u, "(A)") write (u, "(A)") "* Test output end: eio_data_2" end subroutine eio_data_2 @ %def eio_data_2 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Abstract I/O Handler} This module defines an abstract object for event I/O and the associated methods. There are [[output]] and [[input]] methods which write or read a single event from/to the I/O stream, respectively. The I/O stream itself may be a file, a common block, or an externally linked structure, depending on the concrete implementation. A [[write]] method prints the current content of the implementation-dependent event record in human-readable form. The [[init_in]]/[[init_out]] and [[final]] prepare and finalize the I/O stream, respectively. There is also a [[switch_inout]] method which turns an input stream into an output stream where events can be appended. Optionally, output files can be split in chunks of well-defined size. The [[split_out]] method takes care of this. <<[[eio_base.f90]]>>= <> module eio_base use kinds, only: i64 <> use io_units use diagnostics use model_data use event_base + use event_handles, only: event_handle_t use eio_data <> <> <> <> contains <> end module eio_base @ %def eio_base @ \subsection{Type} We can assume that most implementations will need the file extension as a fixed string and, if they support file splitting, the current file index. The fallback model is useful for implementations that are able to read unknown files which may contain hadrons etc., not in the current hard-interaction model. <>= public :: eio_t <>= type, abstract :: eio_t type(string_t) :: sample type(string_t) :: extension type(string_t) :: filename logical :: has_file = .false. logical :: split = .false. integer :: split_n_evt = 0 integer :: split_n_kbytes = 0 integer :: split_index = 0 integer :: split_count = 0 class(model_data_t), pointer :: fallback_model => null () contains <> end type eio_t @ %def eio_t @ Write to screen. If possible, this should display the contents of the current event, i.e., the last one that was written or read. <>= procedure (eio_write), deferred :: write <>= abstract interface subroutine eio_write (object, unit) import class(eio_t), intent(in) :: object integer, intent(in), optional :: unit end subroutine eio_write end interface @ %def eio_write @ Finalize. This should write/read footer data and close input/output channels. <>= procedure (eio_final), deferred :: final <>= abstract interface subroutine eio_final (object) import class(eio_t), intent(inout) :: object end subroutine eio_final end interface @ %def eio_final @ Determine splitting parameters from the event sample data. <>= procedure :: set_splitting => eio_set_splitting <>= subroutine eio_set_splitting (eio, data) class(eio_t), intent(inout) :: eio type(event_sample_data_t), intent(in) :: data eio%split = data%split_n_evt > 0 .or. data%split_n_kbytes > 0 if (eio%split) then eio%split_n_evt = data%split_n_evt eio%split_n_kbytes = data%split_n_kbytes eio%split_index = data%split_index eio%split_count = 0 end if end subroutine eio_set_splitting @ %def eio_set_splitting @ Update the byte count and check if it has increased. We use integer division to determine the number of [[n_kbytes]] blocks that are in the event file. <>= procedure :: update_split_count => eio_update_split_count <>= subroutine eio_update_split_count (eio, increased) class(eio_t), intent(inout) :: eio logical, intent(out) :: increased integer :: split_count_old if (eio%split_n_kbytes > 0) then split_count_old = eio%split_count eio%split_count = eio%file_size_kbytes () / eio%split_n_kbytes increased = eio%split_count > split_count_old end if end subroutine eio_update_split_count @ %def eio_update_split_count @ Generate a filename, taking a possible split index into account. <>= procedure :: set_filename => eio_set_filename <>= subroutine eio_set_filename (eio) class(eio_t), intent(inout) :: eio character(32) :: buffer if (eio%split) then write (buffer, "(I0,'.')") eio%split_index eio%filename = eio%sample // "." // trim (buffer) // eio%extension eio%has_file = .true. else eio%filename = eio%sample // "." // eio%extension eio%has_file = .true. end if end subroutine eio_set_filename @ %def eio_set_filename @ Set the fallback model. <>= procedure :: set_fallback_model => eio_set_fallback_model <>= subroutine eio_set_fallback_model (eio, model) class(eio_t), intent(inout) :: eio class(model_data_t), intent(in), target :: model eio%fallback_model => model end subroutine eio_set_fallback_model @ %def eio_set_fallback_model @ Initialize for output. We provide process names. This should open an event file if appropriate and write header data. Some methods may require event sample data. <>= procedure (eio_init_out), deferred :: init_out <>= abstract interface subroutine eio_init_out (eio, sample, data, success, extension) import class(eio_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(event_sample_data_t), intent(in), optional :: data logical, intent(out), optional :: success type(string_t), intent(in), optional :: extension end subroutine eio_init_out end interface @ %def eio_init_out @ Initialize for input. We provide process names. This should open an event file if appropriate and read header data. The [[md5sum]] can be used to check the integrity of the configuration, it it provides a checksum to compare with. In case the extension has changed the extension is also given as an argument. The [[data]] argument is [[intent(inout)]]: we may read part of it and keep other parts and/or check them against the data in the file. <>= procedure (eio_init_in), deferred :: init_in <>= abstract interface subroutine eio_init_in (eio, sample, data, success, extension) import class(eio_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(event_sample_data_t), intent(inout), optional :: data logical, intent(out), optional :: success type(string_t), intent(in), optional :: extension end subroutine eio_init_in end interface @ %def eio_init_in @ Re-initialize for output. This should change the status of any event file from input to output and position it for appending new events. <>= procedure (eio_switch_inout), deferred :: switch_inout <>= abstract interface subroutine eio_switch_inout (eio, success) import class(eio_t), intent(inout) :: eio logical, intent(out), optional :: success end subroutine eio_switch_inout end interface @ %def eio_switch_inout @ This is similar: split the output, i.e., close the current file and open a new one. The default implementation does nothing. For the feature to work, an implementation must override this. <>= procedure :: split_out => eio_split_out <>= subroutine eio_split_out (eio) class(eio_t), intent(inout) :: eio end subroutine eio_split_out @ %def eio_split_out @ Determine the file size in kilobytes. More exactly, determine the size in units of 1024 storage units, as returned by the INQUIRE statement. The implementation returns zero if there is no file. The [[has_file]] flag is set by the [[set_filename]] method, so we can be confident that the [[inquire]] call is meaningful. If this algorithm doesn't apply for a particular format, we still can override the procedure. <>= procedure :: file_size_kbytes => eio_file_size_kbytes <>= function eio_file_size_kbytes (eio) result (kbytes) class(eio_t), intent(in) :: eio integer :: kbytes integer(i64) :: bytes if (eio%has_file) then inquire (file = char (eio%filename), size = bytes) if (bytes > 0) then kbytes = bytes / 1024 else kbytes = 0 end if else kbytes = 0 end if end function eio_file_size_kbytes @ %def eio_file_size_kbytes @ Output an event. All data can be taken from the [[event]] record. The index [[i_prc]] identifies the process among the processes that are contained in the current sample. The [[reading]] flag, if present, indicates that the event was read from file, not generated. The [[passed]] flag tells us that this event has passed the selection criteria. Depending on the event format, we may choose to skip events that have not passed. <>= procedure (eio_output), deferred :: output <>= abstract interface - subroutine eio_output (eio, event, i_prc, reading, passed, pacify) + subroutine eio_output & + (eio, event, i_prc, reading, passed, pacify, event_handle) import class(eio_t), intent(inout) :: eio class(generic_event_t), intent(in), target :: event integer, intent(in) :: i_prc logical, intent(in), optional :: reading, passed, pacify + class(event_handle_t), intent(inout), optional :: event_handle end subroutine eio_output end interface @ %def eio_output @ Input an event. This should fill all event data that cannot be inferred from the associated process. The input is broken down into two parts. First we read the [[i_prc]] index. So we know which process to expect in the subsequent event. If we have reached end of file, we also will know. Then, we read the event itself. The parameter [[iostat]] is supposed to be set as the Fortran standard requires, negative for EOF and positive for error. <>= procedure (eio_input_i_prc), deferred :: input_i_prc procedure (eio_input_event), deferred :: input_event <>= abstract interface subroutine eio_input_i_prc (eio, i_prc, iostat) import class(eio_t), intent(inout) :: eio integer, intent(out) :: i_prc integer, intent(out) :: iostat end subroutine eio_input_i_prc end interface abstract interface - subroutine eio_input_event (eio, event, iostat) + subroutine eio_input_event (eio, event, iostat, event_handle) import class(eio_t), intent(inout) :: eio class(generic_event_t), intent(inout), target :: event integer, intent(out) :: iostat + class(event_handle_t), intent(inout), optional :: event_handle end subroutine eio_input_event end interface @ %def eio_input @ <>= procedure (eio_skip), deferred :: skip <>= abstract interface subroutine eio_skip (eio, iostat) import class(eio_t), intent(inout) :: eio integer, intent(out) :: iostat end subroutine eio_skip end interface @ %def eio_skip @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[eio_base_ut.f90]]>>= <> module eio_base_ut use unit_tests use eio_base_uti <> <> <> contains <> end module eio_base_ut @ %def eio_base_ut @ <<[[eio_base_uti.f90]]>>= <> module eio_base_uti <> <> use io_units use lorentz use model_data use particles use event_base + use event_handles, only: event_handle_t use eio_data use eio_base <> <> <> <> <> contains <> <> end module eio_base_uti @ %def eio_base_ut @ API: driver for the unit tests below. <>= public :: eio_base_test <>= subroutine eio_base_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine eio_base_test @ %def eio_base_test @ The caller has to provide procedures that prepare and cleanup the test environment. They depend on modules that are not available here. <>= abstract interface subroutine eio_prepare_event (event, unweighted, n_alt, sample_norm) import class(generic_event_t), intent(inout), pointer :: event logical, intent(in), optional :: unweighted integer, intent(in), optional :: n_alt type(string_t), intent(in), optional :: sample_norm end subroutine eio_prepare_event end interface abstract interface subroutine eio_cleanup_event (event) import class(generic_event_t), intent(inout), pointer :: event end subroutine eio_cleanup_event end interface @ We store pointers to the test-environment handlers as module variables. This allows us to call them from the test routines themselves, which don't allow for extra arguments. <>= public :: eio_prepare_test, eio_cleanup_test <>= procedure(eio_prepare_event), pointer :: eio_prepare_test => null () procedure(eio_cleanup_event), pointer :: eio_cleanup_test => null () @ %def eio_prepare_test eio_cleanup_test @ Similarly, for the fallback (hadron) model that some eio tests require: <>= abstract interface subroutine eio_prepare_model (model) import class(model_data_t), intent(inout), pointer :: model end subroutine eio_prepare_model end interface abstract interface subroutine eio_cleanup_model (model) import class(model_data_t), intent(inout), target :: model end subroutine eio_cleanup_model end interface <>= public :: eio_prepare_fallback_model, eio_cleanup_fallback_model <>= procedure(eio_prepare_model), pointer :: eio_prepare_fallback_model => null () procedure(eio_cleanup_model), pointer :: eio_cleanup_fallback_model => null () @ %def eio_prepare_fallback_model eio_cleanup_fallback_model @ \subsubsection{Test type for event I/O} The contents simulate the contents of an external file. We have the [[sample]] string as the file name and the array of momenta [[event_p]] as the list of events. The second index is the event index. The [[event_i]] component is the pointer to the current event, [[event_n]] is the total number of stored events. <>= type, extends (eio_t) :: eio_test_t integer :: event_n = 0 integer :: event_i = 0 integer :: i_prc = 0 type(vector4_t), dimension(:,:), allocatable :: event_p contains <> end type eio_test_t @ %def eio_test_t @ Write to screen. Pretend that this is an actual event format. <>= procedure :: write => eio_test_write <>= subroutine eio_test_write (object, unit) class(eio_test_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit) write (u, "(1x,A)") "Test event stream" if (object%event_i /= 0) then write (u, "(1x,A,I0,A)") "Event #", object%event_i, ":" do i = 1, size (object%event_p, 1) call vector4_write (object%event_p(i, object%event_i), u) end do end if end subroutine eio_test_write @ %def eio_test_write @ Finalizer. For the test case, we just reset the event count, but keep the stored ``events''. For the real implementations, the events would be stored on an external medium, so we would delete the object contents. <>= procedure :: final => eio_test_final <>= subroutine eio_test_final (object) class(eio_test_t), intent(inout) :: object object%event_i = 0 end subroutine eio_test_final @ %def eio_test_final @ Initialization: We store the process IDs and the energy from the beam-data object. We also allocate the momenta (i.e., the simulated event record) for a fixed maximum size of 10 events, 2 momenta each. There is only a single process. <>= procedure :: init_out => eio_test_init_out <>= subroutine eio_test_init_out (eio, sample, data, success, extension) class(eio_test_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(event_sample_data_t), intent(in), optional :: data logical, intent(out), optional :: success type(string_t), intent(in), optional :: extension eio%sample = sample eio%event_n = 0 eio%event_i = 0 allocate (eio%event_p (2, 10)) if (present (success)) success = .true. end subroutine eio_test_init_out @ %def eio_test_init_out @ Initialization for input. Nothing to do for the test type. <>= procedure :: init_in => eio_test_init_in <>= subroutine eio_test_init_in (eio, sample, data, success, extension) class(eio_test_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(event_sample_data_t), intent(inout), optional :: data logical, intent(out), optional :: success type(string_t), intent(in), optional :: extension if (present (success)) success = .true. end subroutine eio_test_init_in @ %def eio_test_init_in @ Switch from output to input. Again, nothing to do for the test type. <>= procedure :: switch_inout => eio_test_switch_inout <>= subroutine eio_test_switch_inout (eio, success) class(eio_test_t), intent(inout) :: eio logical, intent(out), optional :: success if (present (success)) success = .true. end subroutine eio_test_switch_inout @ %def eio_test_switch_inout @ Output. Increment the event counter and store the momenta of the current event. <>= procedure :: output => eio_test_output <>= - subroutine eio_test_output (eio, event, i_prc, reading, passed, pacify) + subroutine eio_test_output & + (eio, event, i_prc, reading, passed, pacify, event_handle) class(eio_test_t), intent(inout) :: eio class(generic_event_t), intent(in), target :: event logical, intent(in), optional :: reading, passed, pacify + class(event_handle_t), intent(inout), optional :: event_handle integer, intent(in) :: i_prc type(particle_set_t), pointer :: pset type(particle_t) :: prt eio%event_n = eio%event_n + 1 eio%event_i = eio%event_n eio%i_prc = i_prc pset => event%get_particle_set_ptr () prt = pset%get_particle (3) eio%event_p(1, eio%event_i) = prt%get_momentum () prt = pset%get_particle (4) eio%event_p(2, eio%event_i) = prt%get_momentum () end subroutine eio_test_output @ %def eio_test_output @ Input. Increment the event counter and retrieve the momenta of the current event. For the test case, we do not actually modify the current event. <>= procedure :: input_i_prc => eio_test_input_i_prc procedure :: input_event => eio_test_input_event <>= subroutine eio_test_input_i_prc (eio, i_prc, iostat) class(eio_test_t), intent(inout) :: eio integer, intent(out) :: i_prc integer, intent(out) :: iostat i_prc = eio%i_prc iostat = 0 end subroutine eio_test_input_i_prc - subroutine eio_test_input_event (eio, event, iostat) + subroutine eio_test_input_event (eio, event, iostat, event_handle) class(eio_test_t), intent(inout) :: eio class(generic_event_t), intent(inout), target :: event integer, intent(out) :: iostat + class(event_handle_t), intent(inout), optional :: event_handle eio%event_i = eio%event_i + 1 iostat = 0 end subroutine eio_test_input_event @ %def eio_test_input_i_prc @ %def eio_test_input_event @ <>= procedure :: skip => eio_test_skip <>= subroutine eio_test_skip (eio, iostat) class(eio_test_t), intent(inout) :: eio integer, intent(out) :: iostat iostat = 0 end subroutine eio_test_skip @ %def eio_test_skip @ \subsubsection{Test I/O methods} <>= call test (eio_base_1, "eio_base_1", & "read and write event contents", & u, results) <>= public :: eio_base_1 <>= subroutine eio_base_1 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event class(eio_t), allocatable :: eio integer :: i_prc, iostat type(string_t) :: sample write (u, "(A)") "* Test output: eio_base_1" write (u, "(A)") "* Purpose: generate and read/write an event" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_test1" allocate (eio_test_t :: eio) call eio%init_out (sample) call event%generate (1, [0._default, 0._default]) call eio%output (event, 42) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* Re-read the event" write (u, "(A)") call eio%init_in (sample) call eio%input_i_prc (i_prc, iostat) call eio%input_event (event, iostat) call eio%write (u) write (u, "(A)") write (u, "(1x,A,I0)") "i = ", i_prc write (u, "(A)") write (u, "(A)") "* Generate and append another event" write (u, "(A)") call eio%switch_inout () call event%generate (1, [0._default, 0._default]) call eio%output (event, 5) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* Re-read both events" write (u, "(A)") call eio%init_in (sample) call eio%input_i_prc (i_prc, iostat) call eio%input_event (event, iostat) call eio%input_i_prc (i_prc, iostat) call eio%input_event (event, iostat) call eio%write (u) write (u, "(A)") write (u, "(1x,A,I0)") "i = ", i_prc write (u, "(A)") write (u, "(A)") "* Cleanup" call eio%final () deallocate (eio) call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_base_1" end subroutine eio_base_1 @ %def eio_base_1 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Direct Event Access} As a convenient application of the base type, we construct an event handler that allows us of setting and retrieving events just in the same way as an file I/O format, but directly dealing with particle data and momenta. This is an input and output format, but we do not care about counting events. <<[[eio_direct.f90]]>>= <> module eio_direct <> <> use io_units use diagnostics use cputime use lorentz, only: vector4_t use particles, only: particle_set_t use model_data, only: model_data_t use event_base + use event_handles, only: event_handle_t use eio_data use eio_base <> <> <> contains <> end module eio_direct @ %def eio_direct @ \subsection{Type} <>= public :: eio_direct_t <>= type, extends (eio_t) :: eio_direct_t private logical :: i_evt_set = .false. integer :: i_evt = 0 integer :: i_prc = 0 integer :: i_mci = 0 integer :: i_term = 0 integer :: channel = 0 logical :: passed_set = .false. logical :: passed = .true. type(particle_set_t) :: pset contains <> end type eio_direct_t @ %def eio_direct_t @ \subsection{Common Methods} Output. <>= procedure :: write => eio_direct_write <>= subroutine eio_direct_write (object, unit) class(eio_direct_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A)") "Event direct access:" if (object%i_evt_set) then write (u, "(3x,A,1x,I0)") "i_evt =", object%i_evt else write (u, "(3x,A)") "i_evt = [undefined]" end if write (u, "(3x,A,1x,I0)") "i_prc =", object%i_prc write (u, "(3x,A,1x,I0)") "i_mci =", object%i_prc write (u, "(3x,A,1x,I0)") "i_term =", object%i_prc write (u, "(3x,A,1x,I0)") "channel =", object%i_prc if (object%passed_set) then write (u, "(3x,A,1x,L1)") "passed =", object%passed else write (u, "(3x,A)") "passed = [N/A]" end if call object%pset%write (u) end subroutine eio_direct_write @ %def eio_direct_write @ Finalizer: trivial. <>= procedure :: final => eio_direct_final <>= subroutine eio_direct_final (object) class(eio_direct_t), intent(inout) :: object call object%pset%final () end subroutine eio_direct_final @ %def eio_direct_final @ Initialize for input and/or output, both are identical <>= procedure :: init_out => eio_direct_init_out <>= subroutine eio_direct_init_out (eio, sample, data, success, extension) class(eio_direct_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(in), optional :: data logical, intent(out), optional :: success if (present (success)) success = .true. end subroutine eio_direct_init_out @ %def eio_direct_init_out @ <>= procedure :: init_in => eio_direct_init_in <>= subroutine eio_direct_init_in (eio, sample, data, success, extension) class(eio_direct_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(inout), optional :: data logical, intent(out), optional :: success if (present (success)) success = .true. end subroutine eio_direct_init_in @ %def eio_direct_init_in @ Switch from input to output: no-op <>= procedure :: switch_inout => eio_direct_switch_inout <>= subroutine eio_direct_switch_inout (eio, success) class(eio_direct_t), intent(inout) :: eio logical, intent(out), optional :: success if (present (success)) success = .true. end subroutine eio_direct_switch_inout @ %def eio_direct_switch_inout @ Output: transfer event contents from the [[event]] object to the [[eio]] object. Note that finalization of the particle set is not (yet) automatic. <>= procedure :: output => eio_direct_output <>= - subroutine eio_direct_output (eio, event, i_prc, reading, passed, pacify) + subroutine eio_direct_output & + (eio, event, i_prc, reading, passed, pacify, event_handle) class(eio_direct_t), intent(inout) :: eio class(generic_event_t), intent(in), target :: event integer, intent(in) :: i_prc logical, intent(in), optional :: reading, passed, pacify + class(event_handle_t), intent(inout), optional :: event_handle type(particle_set_t), pointer :: pset_ptr call eio%pset%final () if (event%has_index ()) then call eio%set_event_index (event%get_index ()) else call eio%reset_event_index () end if if (present (passed)) then eio%passed = passed eio%passed_set = .true. else eio%passed_set = .false. end if pset_ptr => event%get_particle_set_ptr () if (associated (pset_ptr)) then eio%i_prc = i_prc eio%pset = pset_ptr end if end subroutine eio_direct_output @ %def eio_direct_output @ Input: transfer event contents from the [[eio]] object to the [[event]] object. The [[i_prc]] parameter has been stored inside the [[eio]] record before. <>= procedure :: input_i_prc => eio_direct_input_i_prc procedure :: input_event => eio_direct_input_event <>= subroutine eio_direct_input_i_prc (eio, i_prc, iostat) class(eio_direct_t), intent(inout) :: eio integer, intent(out) :: i_prc integer, intent(out) :: iostat i_prc = eio%i_prc iostat = 0 end subroutine eio_direct_input_i_prc - subroutine eio_direct_input_event (eio, event, iostat) + subroutine eio_direct_input_event (eio, event, iostat, event_handle) class(eio_direct_t), intent(inout) :: eio class(generic_event_t), intent(inout), target :: event integer, intent(out) :: iostat + class(event_handle_t), intent(inout), optional :: event_handle call event%select (eio%i_mci, eio%i_term, eio%channel) if (eio%has_event_index ()) then call event%set_index (eio%get_event_index ()) else call event%reset_index () end if call event%set_hard_particle_set (eio%pset) end subroutine eio_direct_input_event @ %def eio_direct_input_i_prc @ %def eio_direct_input_event @ No-op. <>= procedure :: skip => eio_direct_skip <>= subroutine eio_direct_skip (eio, iostat) class(eio_direct_t), intent(inout) :: eio integer, intent(out) :: iostat iostat = 0 end subroutine eio_direct_skip @ %def eio_direct_skip @ \subsection{Retrieve individual contents} <>= procedure :: has_event_index => eio_direct_has_event_index procedure :: get_event_index => eio_direct_get_event_index procedure :: passed_known => eio_direct_passed_known procedure :: has_passed => eio_direct_has_passed procedure :: get_n_in => eio_direct_get_n_in procedure :: get_n_out => eio_direct_get_n_out procedure :: get_n_tot => eio_direct_get_n_tot <>= function eio_direct_has_event_index (eio) result (flag) class(eio_direct_t), intent(in) :: eio logical :: flag flag = eio%i_evt_set end function eio_direct_has_event_index function eio_direct_get_event_index (eio) result (index) class(eio_direct_t), intent(in) :: eio integer :: index if (eio%has_event_index ()) then index = eio%i_evt else index = 0 end if end function eio_direct_get_event_index function eio_direct_passed_known (eio) result (flag) class(eio_direct_t), intent(in) :: eio logical :: flag flag = eio%passed_set end function eio_direct_passed_known function eio_direct_has_passed (eio) result (flag) class(eio_direct_t), intent(in) :: eio logical :: flag if (eio%passed_known ()) then flag = eio%passed else flag = .true. end if end function eio_direct_has_passed function eio_direct_get_n_in (eio) result (n_in) class(eio_direct_t), intent(in) :: eio integer :: n_in n_in = eio%pset%get_n_in () end function eio_direct_get_n_in function eio_direct_get_n_out (eio) result (n_out) class(eio_direct_t), intent(in) :: eio integer :: n_out n_out = eio%pset%get_n_out () end function eio_direct_get_n_out function eio_direct_get_n_tot (eio) result (n_tot) class(eio_direct_t), intent(in) :: eio integer :: n_tot n_tot = eio%pset%get_n_tot () end function eio_direct_get_n_tot @ %def eio_direct_has_event_index @ %def eio_direct_get_event_index @ %def eio_direct_passed_known @ %def eio_direct_has_passed @ %def eio_direct_get_n_in @ %def eio_direct_get_n_out @ %def eio_direct_get_n_tot @ All momenta as a single allocatable array. <>= procedure :: get_momentum_array => eio_direct_get_momentum_array <>= subroutine eio_direct_get_momentum_array (eio, p) class(eio_direct_t), intent(in) :: eio type(vector4_t), dimension(:), allocatable, intent(out) :: p integer :: n n = eio%get_n_tot () allocate (p (n)) p(:) = eio%pset%get_momenta () end subroutine eio_direct_get_momentum_array @ %def eio_direct_get_momentum_array @ \subsection{Manual access} Build the contained particle set from scratch. <>= procedure :: init_direct => eio_direct_init_direct <>= subroutine eio_direct_init_direct & (eio, n_beam, n_in, n_rem, n_vir, n_out, pdg, model) class(eio_direct_t), intent(out) :: eio integer, intent(in) :: n_beam integer, intent(in) :: n_in integer, intent(in) :: n_rem integer, intent(in) :: n_vir integer, intent(in) :: n_out integer, dimension(:), intent(in) :: pdg class(model_data_t), intent(in), target :: model call eio%pset%init_direct (n_beam, n_in, n_rem, n_vir, n_out, pdg, model) end subroutine eio_direct_init_direct @ %def eio_direct_init_direct @ Set/reset the event index, which is optional. <>= procedure :: set_event_index => eio_direct_set_event_index procedure :: reset_event_index => eio_direct_reset_event_index <>= subroutine eio_direct_set_event_index (eio, index) class(eio_direct_t), intent(inout) :: eio integer, intent(in) :: index eio%i_evt = index eio%i_evt_set = .true. end subroutine eio_direct_set_event_index subroutine eio_direct_reset_event_index (eio) class(eio_direct_t), intent(inout) :: eio eio%i_evt_set = .false. end subroutine eio_direct_reset_event_index @ %def eio_direct_set_event_index @ %def eio_direct_reset_event_index @ Set the selection indices. This is supposed to select the [[i_prc]], [[i_mci]], [[i_term]], and [[channel]] entries of the event where the momentum set has to be stored, respectively. The selection indices determine the process, MCI set, calculation term, and phase-space channel is to be used for recalculation. The index values must not be zero, even if the do not apply. <>= procedure :: set_selection_indices => eio_direct_set_selection_indices <>= subroutine eio_direct_set_selection_indices & (eio, i_prc, i_mci, i_term, channel) class(eio_direct_t), intent(inout) :: eio integer, intent(in) :: i_prc integer, intent(in) :: i_mci integer, intent(in) :: i_term integer, intent(in) :: channel eio%i_prc = i_prc eio%i_mci = i_mci eio%i_term = i_term eio%channel = channel end subroutine eio_direct_set_selection_indices @ %def eio_direct_set_i_prc @ Set momentum (or momenta -- elemental). <>= generic :: set_momentum => set_momentum_single generic :: set_momentum => set_momentum_all procedure :: set_momentum_single => eio_direct_set_momentum_single procedure :: set_momentum_all => eio_direct_set_momentum_all <>= subroutine eio_direct_set_momentum_single (eio, i, p, p2, on_shell) class(eio_direct_t), intent(inout) :: eio integer, intent(in) :: i type(vector4_t), intent(in) :: p real(default), intent(in), optional :: p2 logical, intent(in), optional :: on_shell call eio%pset%set_momentum (i, p, p2, on_shell) end subroutine eio_direct_set_momentum_single subroutine eio_direct_set_momentum_all (eio, p, p2, on_shell) class(eio_direct_t), intent(inout) :: eio type(vector4_t), dimension(:), intent(in) :: p real(default), dimension(:), intent(in), optional :: p2 logical, intent(in), optional :: on_shell call eio%pset%set_momentum (p, p2, on_shell) end subroutine eio_direct_set_momentum_all @ %def eio_direct_set_momentum @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[eio_direct_ut.f90]]>>= <> module eio_direct_ut use unit_tests use eio_direct_uti <> <> contains <> end module eio_direct_ut @ %def eio_direct_ut @ <<[[eio_direct_uti.f90]]>>= <> module eio_direct_uti <> <> use lorentz, only: vector4_t use model_data, only: model_data_t use event_base use eio_data use eio_base use eio_direct use eio_base_ut, only: eio_prepare_test, eio_cleanup_test <> <> contains <> end module eio_direct_uti @ %def eio_direct_ut @ API: driver for the unit tests below. <>= public :: eio_direct_test <>= subroutine eio_direct_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine eio_direct_test @ %def eio_direct_test @ \subsubsection{Test I/O methods} We test the implementation of all I/O methods. <>= call test (eio_direct_1, "eio_direct_1", & "read and write event contents", & u, results) <>= public :: eio_direct_1 <>= subroutine eio_direct_1 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event class(eio_t), allocatable :: eio type(event_sample_data_t) :: data type(string_t) :: sample type(vector4_t), dimension(:), allocatable :: p class(model_data_t), pointer :: model integer :: i, n_events, iostat, i_prc write (u, "(A)") "* Test output: eio_direct_1" write (u, "(A)") "* Purpose: generate and read/write an event" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) write (u, "(A)") write (u, "(A)") "* Initial state" write (u, "(A)") allocate (eio_direct_t :: eio) call eio%write (u) write (u, "(A)") write (u, "(A)") "* Extract an empty event" write (u, "(A)") call eio%output (event, 1) call eio%write (u) write (u, "(A)") write (u, "(A)") "* Retrieve contents" write (u, "(A)") select type (eio) class is (eio_direct_t) if (eio%has_event_index ()) write (u, "(A,1x,I0)") "index =", eio%get_event_index () if (eio%passed_known ()) write (u, "(A,1x,L1)") "passed =", eio%has_passed () write (u, "(A,1x,I0)") "n_in =", eio%get_n_in () write (u, "(A,1x,I0)") "n_out =", eio%get_n_out () end select write (u, "(A)") write (u, "(A)") "* Generate and extract an event" write (u, "(A)") call event%generate (1, [0._default, 0._default]) call event%set_index (42) model => event%get_model_ptr () sample = "" call eio%init_out (sample) call eio%output (event, 1, passed = .true.) call eio%write (u) write (u, "(A)") write (u, "(A)") "* Retrieve contents" write (u, "(A)") select type (eio) class is (eio_direct_t) if (eio%has_event_index ()) write (u, "(A,1x,I0)") "index =", eio%get_event_index () if (eio%passed_known ()) write (u, "(A,1x,L1)") "passed =", eio%has_passed () write (u, "(A,1x,I0)") "n_in =", eio%get_n_in () write (u, "(A,1x,I0)") "n_out =", eio%get_n_out () end select select type (eio) class is (eio_direct_t) call eio%get_momentum_array (p) if (allocated (p)) then write (u, "(A)") "p[3] =" call p(3)%write (u) end if end select write (u, "(A)") write (u, "(A)") "* Re-create an eio event record: initialization" write (u, "(A)") call eio%final () select type (eio) class is (eio_direct_t) call eio%init_direct ( & n_beam = 0, n_in = 2, n_rem = 0, n_vir = 0, n_out = 2, & pdg = [25, 25, 25, 25], model = model) call eio%set_event_index (42) call eio%set_selection_indices (1, 1, 1, 1) call eio%write (u) end select write (u, "(A)") write (u, "(A)") "* Re-create an eio event record: & &set momenta, interchanged" write (u, "(A)") select type (eio) class is (eio_direct_t) call eio%set_momentum (p([1,2,4,3]), on_shell=.true.) call eio%write (u) end select write (u, "(A)") write (u, "(A)") "* 'read' i_prc" write (u, "(A)") call eio%input_i_prc (i_prc, iostat) write (u, "(1x,A,1x,I0)") "i_prc =", i_prc write (u, "(1x,A,1x,I0)") "iostat =", iostat write (u, "(A)") write (u, "(A)") "* 'read' (fill) event" write (u, "(A)") call eio%input_event (event, iostat) write (u, "(1x,A,1x,I0)") "iostat =", iostat write (u, "(A)") call event%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio%final () deallocate (eio) call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_direct_1" end subroutine eio_direct_1 @ %def eio_direct_1 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Event Generation Checkpoints} This is an output-only format. Its only use is to write screen messages every $n$ events, to inform the user about progress. <<[[eio_checkpoints.f90]]>>= <> module eio_checkpoints <> use io_units use diagnostics use cputime use event_base + use event_handles, only: event_handle_t use eio_data use eio_base <> <> <> <> contains <> end module eio_checkpoints @ %def eio_checkpoints @ \subsection{Type} <>= public :: eio_checkpoints_t <>= type, extends (eio_t) :: eio_checkpoints_t logical :: active = .false. logical :: running = .false. integer :: val = 0 integer :: n_events = 0 integer :: n_read = 0 integer :: i_evt = 0 logical :: blank = .false. type(timer_t) :: timer contains <> end type eio_checkpoints_t @ %def eio_checkpoints_t @ \subsection{Specific Methods} Set parameters that are specifically used for checkpointing. <>= procedure :: set_parameters => eio_checkpoints_set_parameters <>= subroutine eio_checkpoints_set_parameters (eio, checkpoint, blank) class(eio_checkpoints_t), intent(inout) :: eio integer, intent(in) :: checkpoint logical, intent(in), optional :: blank eio%val = checkpoint if (present (blank)) eio%blank = blank end subroutine eio_checkpoints_set_parameters @ %def eio_checkpoints_set_parameters @ \subsection{Common Methods} Output. This is not the actual event format, but a readable account of the current status. <>= procedure :: write => eio_checkpoints_write <>= subroutine eio_checkpoints_write (object, unit) class(eio_checkpoints_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) if (object%active) then write (u, "(1x,A)") "Event-sample checkpoints: active" write (u, "(3x,A,I0)") "interval = ", object%val write (u, "(3x,A,I0)") "n_events = ", object%n_events write (u, "(3x,A,I0)") "n_read = ", object%n_read write (u, "(3x,A,I0)") "n_current = ", object%i_evt write (u, "(3x,A,L1)") "blanking = ", object%blank call object%timer%write (u) else write (u, "(1x,A)") "Event-sample checkpoints: off" end if end subroutine eio_checkpoints_write @ %def eio_checkpoints_write @ Finalizer: trivial. <>= procedure :: final => eio_checkpoints_final <>= subroutine eio_checkpoints_final (object) class(eio_checkpoints_t), intent(inout) :: object object%active = .false. end subroutine eio_checkpoints_final @ %def eio_checkpoints_final @ Activate checkpointing for event generation or writing. <>= procedure :: init_out => eio_checkpoints_init_out <>= subroutine eio_checkpoints_init_out (eio, sample, data, success, extension) class(eio_checkpoints_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(in), optional :: data logical, intent(out), optional :: success if (present (data)) then if (eio%val > 0) then eio%active = .true. eio%i_evt = 0 eio%n_read = 0 eio%n_events = data%n_evt * data%nlo_multiplier end if end if if (present (success)) success = .true. end subroutine eio_checkpoints_init_out @ %def eio_checkpoints_init_out @ No checkpointing for event reading. <>= procedure :: init_in => eio_checkpoints_init_in <>= subroutine eio_checkpoints_init_in (eio, sample, data, success, extension) class(eio_checkpoints_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(inout), optional :: data logical, intent(out), optional :: success call msg_bug ("Event checkpoints: event input not supported") if (present (success)) success = .false. end subroutine eio_checkpoints_init_in @ %def eio_checkpoints_init_in @ Switch from input to output: also not supported. <>= procedure :: switch_inout => eio_checkpoints_switch_inout <>= subroutine eio_checkpoints_switch_inout (eio, success) class(eio_checkpoints_t), intent(inout) :: eio logical, intent(out), optional :: success call msg_bug ("Event checkpoints: in-out switch not supported") if (present (success)) success = .false. end subroutine eio_checkpoints_switch_inout @ %def eio_checkpoints_switch_inout @ Checkpoints: display progress for the current event, if applicable. <>= procedure :: output => eio_checkpoints_output <>= - subroutine eio_checkpoints_output (eio, event, i_prc, reading, passed, pacify) + subroutine eio_checkpoints_output & + (eio, event, i_prc, reading, passed, pacify, event_handle) class(eio_checkpoints_t), intent(inout) :: eio class(generic_event_t), intent(in), target :: event integer, intent(in) :: i_prc logical, intent(in), optional :: reading, passed, pacify + class(event_handle_t), intent(inout), optional :: event_handle logical :: rd rd = .false.; if (present (reading)) rd = reading if (eio%active) then if (.not. eio%running) call eio%startup () if (eio%running) then eio%i_evt = eio%i_evt + 1 if (rd) then eio%n_read = eio%n_read + 1 else if (mod (eio%i_evt, eio%val) == 0) then call eio%message (eio%blank) end if if (eio%i_evt == eio%n_events) call eio%shutdown () end if end if end subroutine eio_checkpoints_output @ %def eio_checkpoints_output @ When the first event is called, we have to initialize the screen output. <>= procedure :: startup => eio_checkpoints_startup <>= subroutine eio_checkpoints_startup (eio) class(eio_checkpoints_t), intent(inout) :: eio if (eio%active .and. eio%i_evt < eio%n_events) then call msg_message ("") call msg_message (checkpoint_bar) call msg_message (checkpoint_head) call msg_message (checkpoint_bar) write (msg_buffer, checkpoint_fmt) 0., 0, eio%n_events - eio%i_evt, "???" call msg_message () eio%running = .true. call eio%timer%start () end if end subroutine eio_checkpoints_startup @ %def eio_checkpoints_startup @ This message is printed at every checkpoint. <>= procedure :: message => eio_checkpoints_message <>= subroutine eio_checkpoints_message (eio, testflag) class(eio_checkpoints_t), intent(inout) :: eio logical, intent(in), optional :: testflag real :: t type(time_t) :: time_remaining type(string_t) :: time_string call eio%timer%stop () t = eio%timer call eio%timer%restart () time_remaining = & nint (t / (eio%i_evt - eio%n_read) * (eio%n_events - eio%i_evt)) time_string = time_remaining%to_string_ms (blank = testflag) write (msg_buffer, checkpoint_fmt) & 100 * (eio%i_evt - eio%n_read) / real (eio%n_events - eio%n_read), & eio%i_evt - eio%n_read, & eio%n_events - eio%i_evt, & char (time_string) call msg_message () end subroutine eio_checkpoints_message @ %def eio_checkpoints_message @ When the last event is called, wrap up. <>= procedure :: shutdown => eio_checkpoints_shutdown <>= subroutine eio_checkpoints_shutdown (eio) class(eio_checkpoints_t), intent(inout) :: eio if (mod (eio%i_evt, eio%val) /= 0) then write (msg_buffer, checkpoint_fmt) & 100., eio%i_evt - eio%n_read, 0, "0m:00s" call msg_message () end if call msg_message (checkpoint_bar) call msg_message ("") eio%running = .false. end subroutine eio_checkpoints_shutdown @ %def eio_checkpoints_shutdown <>= procedure :: input_i_prc => eio_checkpoints_input_i_prc procedure :: input_event => eio_checkpoints_input_event <>= subroutine eio_checkpoints_input_i_prc (eio, i_prc, iostat) class(eio_checkpoints_t), intent(inout) :: eio integer, intent(out) :: i_prc integer, intent(out) :: iostat call msg_bug ("Event checkpoints: event input not supported") i_prc = 0 iostat = 1 end subroutine eio_checkpoints_input_i_prc - subroutine eio_checkpoints_input_event (eio, event, iostat) + subroutine eio_checkpoints_input_event (eio, event, iostat, event_handle) class(eio_checkpoints_t), intent(inout) :: eio class(generic_event_t), intent(inout), target :: event integer, intent(out) :: iostat + class(event_handle_t), intent(inout), optional :: event_handle call msg_bug ("Event checkpoints: event input not supported") iostat = 1 end subroutine eio_checkpoints_input_event @ %def eio_checkpoints_input_i_prc @ %def eio_checkpoints_input_event @ <>= procedure :: skip => eio_checkpoints_skip <>= subroutine eio_checkpoints_skip (eio, iostat) class(eio_checkpoints_t), intent(inout) :: eio integer, intent(out) :: iostat iostat = 0 end subroutine eio_checkpoints_skip @ %def eio_checkpoints_skip @ \subsection{Message header} <>= character(*), parameter :: & checkpoint_head = "| % complete | events generated | events remaining & &| time remaining" character(*), parameter :: & checkpoint_bar = "|==================================================& &=================|" character(*), parameter :: & checkpoint_fmt = "(' ',F5.1,T16,I9,T35,I9,T58,A)" @ %def checkpoint_head @ %def checkpoint_bar @ %def checkpoint_fmt @ %def checkpointing_t @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[eio_checkpoints_ut.f90]]>>= <> module eio_checkpoints_ut use unit_tests use eio_checkpoints_uti <> <> contains <> end module eio_checkpoints_ut @ %def eio_checkpoints_ut @ <<[[eio_checkpoints_uti.f90]]>>= <> module eio_checkpoints_uti <> <> use event_base use eio_data use eio_base use eio_checkpoints use eio_base_ut, only: eio_prepare_test, eio_cleanup_test <> <> contains <> end module eio_checkpoints_uti @ %def eio_checkpoints_ut @ API: driver for the unit tests below. <>= public :: eio_checkpoints_test <>= subroutine eio_checkpoints_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine eio_checkpoints_test @ %def eio_checkpoints_test @ \subsubsection{Test I/O methods} We test the implementation of all I/O methods. <>= call test (eio_checkpoints_1, "eio_checkpoints_1", & "read and write event contents", & u, results) <>= public :: eio_checkpoints_1 <>= subroutine eio_checkpoints_1 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event class(eio_t), allocatable :: eio type(event_sample_data_t) :: data type(string_t) :: sample integer :: i, n_events write (u, "(A)") "* Test output: eio_checkpoints_1" write (u, "(A)") "* Purpose: generate a number of events & &with screen output" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event) write (u, "(A)") write (u, "(A)") "* Generate events" write (u, "(A)") sample = "eio_checkpoints_1" allocate (eio_checkpoints_t :: eio) n_events = 10 call data%init (1, 0) data%n_evt = n_events select type (eio) type is (eio_checkpoints_t) call eio%set_parameters (checkpoint = 4) end select call eio%init_out (sample, data) do i = 1, n_events call event%generate (1, [0._default, 0._default]) call eio%output (event, i_prc = 0) end do write (u, "(A)") "* Checkpointing status" write (u, "(A)") call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_checkpoints_1" end subroutine eio_checkpoints_1 @ %def eio_checkpoints_1 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Event Generation Callback} This is an output-only format. Its only use is to write screen messages every $n$ events, to inform the user about progress. <<[[eio_callback.f90]]>>= <> module eio_callback use kinds, only: i64 <> use io_units use diagnostics use cputime use event_base + use event_handles, only: event_handle_t use eio_data use eio_base <> <> <> contains <> end module eio_callback @ %def eio_callback @ \subsection{Type} <>= public :: eio_callback_t <>= type, extends (eio_t) :: eio_callback_t class(event_callback_t), allocatable :: callback integer(i64) :: i_evt = 0 integer :: i_interval = 0 integer :: n_interval = 0 ! type(timer_t) :: timer contains <> end type eio_callback_t @ %def eio_callback_t @ \subsection{Specific Methods} Set parameters that are specifically used for callback: the procedure and the number of events to wait until the procedure is called (again). <>= procedure :: set_parameters => eio_callback_set_parameters <>= subroutine eio_callback_set_parameters (eio, callback, count_interval) class(eio_callback_t), intent(inout) :: eio class(event_callback_t), intent(in) :: callback integer, intent(in) :: count_interval allocate (eio%callback, source = callback) eio%n_interval = count_interval end subroutine eio_callback_set_parameters @ %def eio_callback_set_parameters @ \subsection{Common Methods} Output. This is not the actual event format, but a readable account of the current status. <>= procedure :: write => eio_callback_write <>= subroutine eio_callback_write (object, unit) class(eio_callback_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A)") "Event-sample callback:" write (u, "(3x,A,I0)") "interval = ", object%n_interval write (u, "(3x,A,I0)") "evt count = ", object%i_evt ! call object%timer%write (u) end subroutine eio_callback_write @ %def eio_callback_write @ Finalizer: trivial. <>= procedure :: final => eio_callback_final <>= subroutine eio_callback_final (object) class(eio_callback_t), intent(inout) :: object end subroutine eio_callback_final @ %def eio_callback_final @ Activate checkpointing for event generation or writing. <>= procedure :: init_out => eio_callback_init_out <>= subroutine eio_callback_init_out (eio, sample, data, success, extension) class(eio_callback_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(in), optional :: data logical, intent(out), optional :: success eio%i_evt = 0 eiO%i_interval = 0 if (present (success)) success = .true. end subroutine eio_callback_init_out @ %def eio_callback_init_out @ No callback for event reading. <>= procedure :: init_in => eio_callback_init_in <>= subroutine eio_callback_init_in (eio, sample, data, success, extension) class(eio_callback_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(inout), optional :: data logical, intent(out), optional :: success call msg_bug ("Event callback: event input not supported") if (present (success)) success = .false. end subroutine eio_callback_init_in @ %def eio_callback_init_in @ Switch from input to output: also not supported. <>= procedure :: switch_inout => eio_callback_switch_inout <>= subroutine eio_callback_switch_inout (eio, success) class(eio_callback_t), intent(inout) :: eio logical, intent(out), optional :: success call msg_bug ("Event callback: in-out switch not supported") if (present (success)) success = .false. end subroutine eio_callback_switch_inout @ %def eio_callback_switch_inout @ The actual callback. First increment counters, then call the procedure if the counter hits the interval. <>= procedure :: output => eio_callback_output <>= - subroutine eio_callback_output (eio, event, i_prc, reading, passed, pacify) + subroutine eio_callback_output & + (eio, event, i_prc, reading, passed, pacify, event_handle) class(eio_callback_t), intent(inout) :: eio class(generic_event_t), intent(in), target :: event integer, intent(in) :: i_prc logical, intent(in), optional :: reading, passed, pacify + class(event_handle_t), intent(inout), optional :: event_handle eio%i_evt = eio%i_evt + 1 if (eio%n_interval > 0) then eio%i_interval = eio%i_interval + 1 if (eio%i_interval >= eio%n_interval) then call eio%callback%proc (eio%i_evt, event) eio%i_interval = 0 end if end if end subroutine eio_callback_output @ %def eio_callback_output @ No input. <>= procedure :: input_i_prc => eio_callback_input_i_prc procedure :: input_event => eio_callback_input_event <>= subroutine eio_callback_input_i_prc (eio, i_prc, iostat) class(eio_callback_t), intent(inout) :: eio integer, intent(out) :: i_prc integer, intent(out) :: iostat call msg_bug ("Event callback: event input not supported") i_prc = 0 iostat = 1 end subroutine eio_callback_input_i_prc - subroutine eio_callback_input_event (eio, event, iostat) + subroutine eio_callback_input_event (eio, event, iostat, event_handle) class(eio_callback_t), intent(inout) :: eio class(generic_event_t), intent(inout), target :: event integer, intent(out) :: iostat + class(event_handle_t), intent(inout), optional :: event_handle call msg_bug ("Event callback: event input not supported") iostat = 1 end subroutine eio_callback_input_event @ %def eio_callback_input_i_prc @ %def eio_callback_input_event @ <>= procedure :: skip => eio_callback_skip <>= subroutine eio_callback_skip (eio, iostat) class(eio_callback_t), intent(inout) :: eio integer, intent(out) :: iostat iostat = 0 end subroutine eio_callback_skip @ %def eio_callback_skip @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Event Weight Output} This is an output-only format. For each event, we print the indices that identify process, process part (MCI group), and term. As numerical information we print the squared matrix element (trace) and the event weight. <<[[eio_weights.f90]]>>= <> module eio_weights <> <> use io_units use diagnostics use event_base + use event_handles, only: event_handle_t use eio_data use eio_base <> <> <> contains <> end module eio_weights @ %def eio_weights @ \subsection{Type} <>= public :: eio_weights_t <>= type, extends (eio_t) :: eio_weights_t logical :: writing = .false. integer :: unit = 0 logical :: pacify = .false. contains <> end type eio_weights_t @ %def eio_weights_t @ \subsection{Specific Methods} Set pacify flags. <>= procedure :: set_parameters => eio_weights_set_parameters <>= subroutine eio_weights_set_parameters (eio, pacify) class(eio_weights_t), intent(inout) :: eio logical, intent(in), optional :: pacify if (present (pacify)) eio%pacify = pacify eio%extension = "weights.dat" end subroutine eio_weights_set_parameters @ %def eio_weights_set_parameters @ \subsection{Common Methods} @ Output. This is not the actual event format, but a readable account of the current object status. <>= procedure :: write => eio_weights_write <>= subroutine eio_weights_write (object, unit) class(eio_weights_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A)") "Weight stream:" if (object%writing) then write (u, "(3x,A,A)") "Writing to file = ", char (object%filename) write (u, "(3x,A,L1)") "Reduced I/O prec. = ", object%pacify else write (u, "(3x,A)") "[closed]" end if end subroutine eio_weights_write @ %def eio_weights_write @ Finalizer: close any open file. <>= procedure :: final => eio_weights_final <>= subroutine eio_weights_final (object) class(eio_weights_t), intent(inout) :: object if (object%writing) then write (msg_buffer, "(A,A,A)") "Events: closing weight stream file '", & char (object%filename), "'" call msg_message () close (object%unit) object%writing = .false. end if end subroutine eio_weights_final @ %def eio_weights_final @ Initialize event writing. <>= procedure :: init_out => eio_weights_init_out <>= subroutine eio_weights_init_out (eio, sample, data, success, extension) class(eio_weights_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(in), optional :: data logical, intent(out), optional :: success if (present(extension)) then eio%extension = extension else eio%extension = "weights.dat" end if eio%filename = sample // "." // eio%extension eio%unit = free_unit () write (msg_buffer, "(A,A,A)") "Events: writing to weight stream file '", & char (eio%filename), "'" call msg_message () eio%writing = .true. open (eio%unit, file = char (eio%filename), & action = "write", status = "replace") if (present (success)) success = .true. end subroutine eio_weights_init_out @ %def eio_weights_init_out @ Initialize event reading. <>= procedure :: init_in => eio_weights_init_in <>= subroutine eio_weights_init_in (eio, sample, data, success, extension) class(eio_weights_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(inout), optional :: data logical, intent(out), optional :: success call msg_bug ("Weight stream: event input not supported") if (present (success)) success = .false. end subroutine eio_weights_init_in @ %def eio_weights_init_in @ Switch from input to output: reopen the file for reading. <>= procedure :: switch_inout => eio_weights_switch_inout <>= subroutine eio_weights_switch_inout (eio, success) class(eio_weights_t), intent(inout) :: eio logical, intent(out), optional :: success call msg_bug ("Weight stream: in-out switch not supported") if (present (success)) success = .false. end subroutine eio_weights_switch_inout @ %def eio_weights_switch_inout @ Output an event. Write first the event indices, then weight and two values of the squared matrix element: [[sqme_ref]] is the value stored in the event record, and [[sqme_prc]] is the one stored in the process instance. (They can differ: when recalculating, the former is read from file and the latter is the result of the new calculation.) For the alternative entries, the [[sqme]] value is always obtained by a new calculation, and thus qualifies as [[sqme_prc]]. Don't write the file if the [[passed]] flag is set and false. <>= procedure :: output => eio_weights_output <>= - subroutine eio_weights_output (eio, event, i_prc, reading, passed, pacify) + subroutine eio_weights_output & + (eio, event, i_prc, reading, passed, pacify, event_handle) class(eio_weights_t), intent(inout) :: eio class(generic_event_t), intent(in), target :: event integer, intent(in) :: i_prc logical, intent(in), optional :: reading, passed, pacify + class(event_handle_t), intent(inout), optional :: event_handle integer :: n_alt, i real(default) :: weight, sqme_ref, sqme_prc logical :: evt_pacify, evt_passed evt_pacify = eio%pacify; if (present (pacify)) evt_pacify = pacify evt_passed = .true.; if (present (passed)) evt_passed = passed if (eio%writing) then if (evt_passed) then weight = event%get_weight_prc () sqme_ref = event%get_sqme_ref () sqme_prc = event%get_sqme_prc () n_alt = event%get_n_alt () 1 format (I0,3(1x,ES17.10),3(1x,I0)) 2 format (I0,3(1x,ES15.8),3(1x,I0)) if (evt_pacify) then write (eio%unit, 2) 0, weight, sqme_prc, sqme_ref, & i_prc else write (eio%unit, 1) 0, weight, sqme_prc, sqme_ref, & i_prc end if do i = 1, n_alt weight = event%get_weight_alt(i) sqme_prc = event%get_sqme_alt(i) if (evt_pacify) then write (eio%unit, 2) i, weight, sqme_prc else write (eio%unit, 1) i, weight, sqme_prc end if end do end if else call eio%write () call msg_fatal ("Weight stream file is not open for writing") end if end subroutine eio_weights_output @ %def eio_weights_output @ Input an event. <>= procedure :: input_i_prc => eio_weights_input_i_prc procedure :: input_event => eio_weights_input_event <>= subroutine eio_weights_input_i_prc (eio, i_prc, iostat) class(eio_weights_t), intent(inout) :: eio integer, intent(out) :: i_prc integer, intent(out) :: iostat call msg_bug ("Weight stream: event input not supported") i_prc = 0 iostat = 1 end subroutine eio_weights_input_i_prc - subroutine eio_weights_input_event (eio, event, iostat) + subroutine eio_weights_input_event (eio, event, iostat, event_handle) class(eio_weights_t), intent(inout) :: eio class(generic_event_t), intent(inout), target :: event integer, intent(out) :: iostat + class(event_handle_t), intent(inout), optional :: event_handle call msg_bug ("Weight stream: event input not supported") iostat = 1 end subroutine eio_weights_input_event @ %def eio_weights_input_i_prc @ %def eio_weights_input_event @ <>= procedure :: skip => eio_weights_skip <>= subroutine eio_weights_skip (eio, iostat) class(eio_weights_t), intent(inout) :: eio integer, intent(out) :: iostat iostat = 0 end subroutine eio_weights_skip @ %def eio_weights_skip @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[eio_weights_ut.f90]]>>= <> module eio_weights_ut use unit_tests use eio_weights_uti <> <> contains <> end module eio_weights_ut @ %def eio_weights_ut @ <<[[eio_weights_uti.f90]]>>= <> module eio_weights_uti <> <> use io_units use event_base use eio_data use eio_base use eio_weights use eio_base_ut, only: eio_prepare_test, eio_cleanup_test <> <> contains <> end module eio_weights_uti @ %def eio_weights_ut @ API: driver for the unit tests below. <>= public :: eio_weights_test <>= subroutine eio_weights_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine eio_weights_test @ %def eio_weights_test @ \subsubsection{Simple event} We test the implementation of all I/O methods. <>= call test (eio_weights_1, "eio_weights_1", & "read and write event contents", & u, results) <>= public :: eio_weights_1 <>= subroutine eio_weights_1 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file character(80) :: buffer write (u, "(A)") "* Test output: eio_weights_1" write (u, "(A)") "* Purpose: generate an event and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_weights_1" allocate (eio_weights_t :: eio) call eio%init_out (sample) call event%generate (1, [0._default, 0._default]) call eio%output (event, i_prc = 42) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents: & &(weight, sqme(evt), sqme(prc), i_prc)" write (u, "(A)") u_file = free_unit () open (u_file, file = "eio_weights_1.weights.dat", & action = "read", status = "old") read (u_file, "(A)") buffer write (u, "(A)") trim (buffer) close (u_file) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_weights_1" end subroutine eio_weights_1 @ %def eio_weights_1 @ \subsubsection{Multiple weights} Event with several weight entries set. <>= call test (eio_weights_2, "eio_weights_2", & "multiple weights", & u, results) <>= public :: eio_weights_2 <>= subroutine eio_weights_2 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, i character(80) :: buffer write (u, "(A)") "* Test output: eio_weights_2" write (u, "(A)") "* Purpose: generate an event and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false., n_alt = 2) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_weights_2" allocate (eio_weights_t :: eio) call eio%init_out (sample) select type (eio) type is (eio_weights_t) call eio%set_parameters (pacify = .true.) end select call event%generate (1, [0._default, 0._default]) call event%set (sqme_alt = [2._default, 3._default]) call event%set (weight_alt = & [2 * event%get_weight_prc (), 3 * event%get_weight_prc ()]) call eio%output (event, i_prc = 42) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents: & &(weight, sqme(evt), sqme(prc), i_prc)" write (u, "(A)") u_file = free_unit () open (u_file, file = "eio_weights_2.weights.dat", & action = "read", status = "old") do i = 1, 3 read (u_file, "(A)") buffer write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_weights_2" end subroutine eio_weights_2 @ %def eio_weights_2 @ \subsubsection{Multiple events} Events with [[passed]] flag switched on/off. <>= call test (eio_weights_3, "eio_weights_3", & "check passed-flag", & u, results) <>= public :: eio_weights_3 <>= subroutine eio_weights_3 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(80) :: buffer write (u, "(A)") "* Test output: eio_weights_3" write (u, "(A)") "* Purpose: generate three events and write to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) write (u, "(A)") write (u, "(A)") "* Generate and write events" write (u, "(A)") sample = "eio_weights_3" allocate (eio_weights_t :: eio) select type (eio) type is (eio_weights_t) call eio%set_parameters (pacify = .true.) end select call eio%init_out (sample) call event%generate (1, [0._default, 0._default]) call eio%output (event, i_prc = 1) call event%generate (1, [0.1_default, 0._default]) call eio%output (event, i_prc = 1, passed = .false.) call event%generate (1, [0.2_default, 0._default]) call eio%output (event, i_prc = 1, passed = .true.) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents: & &(weight, sqme(evt), sqme(prc), i_prc), should be just two entries" write (u, "(A)") u_file = free_unit () open (u_file, file = "eio_weights_3.weights.dat", & action = "read", status = "old") do read (u_file, "(A)", iostat=iostat) buffer if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_weights_3" end subroutine eio_weights_3 @ %def eio_weights_3 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Event Dump Output} This is an output-only format. We simply dump the contents of the [[particle_set]], using the [[write]] method of that type. The event-format options are the options of that procedure. <<[[eio_dump.f90]]>>= <> module eio_dump use, intrinsic :: iso_fortran_env, only: output_unit use kinds, only: i64 <> use format_utils, only: write_separator use format_utils, only: pac_fmt use format_defs, only: FMT_16, FMT_19 use io_units use diagnostics use event_base + use event_handles, only: event_handle_t use eio_data use eio_base <> <> <> contains <> end module eio_dump @ %def eio_dump @ \subsection{Type} <>= public :: eio_dump_t <>= type, extends (eio_t) :: eio_dump_t integer(i64) :: count = 0 integer :: unit = 0 logical :: writing = .false. logical :: screen = .false. logical :: pacify = .false. logical :: weights = .false. logical :: compressed = .false. logical :: summary = .false. contains <> end type eio_dump_t @ %def eio_dump_t @ \subsection{Specific Methods} Set control parameters. We may provide a [[unit]] for input or output; this will be taken if the sample file name is empty. In that case, the unit is assumed to be open and will be kept open; no messages will be issued. <>= procedure :: set_parameters => eio_dump_set_parameters <>= subroutine eio_dump_set_parameters (eio, extension, & pacify, weights, compressed, summary, screen, unit) class(eio_dump_t), intent(inout) :: eio type(string_t), intent(in), optional :: extension logical, intent(in), optional :: pacify logical, intent(in), optional :: weights logical, intent(in), optional :: compressed logical, intent(in), optional :: summary logical, intent(in), optional :: screen integer, intent(in), optional :: unit if (present (pacify)) eio%pacify = pacify if (present (weights)) eio%weights = weights if (present (compressed)) eio%compressed = compressed if (present (summary)) eio%summary = summary if (present (screen)) eio%screen = screen if (present (unit)) eio%unit = unit eio%extension = "pset.dat" if (present (extension)) eio%extension = extension end subroutine eio_dump_set_parameters @ %def eio_dump_set_parameters @ \subsection{Common Methods} @ Output. This is not the actual event format, but a readable account of the current object status. <>= procedure :: write => eio_dump_write <>= subroutine eio_dump_write (object, unit) class(eio_dump_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) write (u, "(1x,A)") "Dump event stream:" if (object%writing) then write (u, "(3x,A,L1)") "Screen output = ", object%screen write (u, "(3x,A,A,A)") "Writing to file = '", char (object%filename), "'" write (u, "(3x,A,L1)") "Reduced I/O prec. = ", object%pacify write (u, "(3x,A,L1)") "Show weights/sqme = ", object%weights write (u, "(3x,A,L1)") "Compressed = ", object%compressed write (u, "(3x,A,L1)") "Summary = ", object%summary else write (u, "(3x,A)") "[closed]" end if end subroutine eio_dump_write @ %def eio_dump_write @ Finalizer: close any open file. <>= procedure :: final => eio_dump_final <>= subroutine eio_dump_final (object) class(eio_dump_t), intent(inout) :: object if (object%screen) then write (msg_buffer, "(A,A,A)") "Events: display complete" call msg_message () object%screen = .false. end if if (object%writing) then if (object%filename /= "") then write (msg_buffer, "(A,A,A)") "Events: closing event dump file '", & char (object%filename), "'" call msg_message () close (object%unit) end if object%writing = .false. end if end subroutine eio_dump_final @ %def eio_dump_final @ Initialize event writing. <>= procedure :: init_out => eio_dump_init_out <>= subroutine eio_dump_init_out (eio, sample, data, success, extension) class(eio_dump_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(in), optional :: data logical, intent(out), optional :: success if (present(extension)) then eio%extension = extension else eio%extension = "pset.dat" end if if (sample == "" .and. eio%unit /= 0) then eio%filename = "" eio%writing = .true. else if (sample /= "") then eio%filename = sample // "." // eio%extension eio%unit = free_unit () write (msg_buffer, "(A,A,A)") "Events: writing to event dump file '", & char (eio%filename), "'" call msg_message () eio%writing = .true. open (eio%unit, file = char (eio%filename), & action = "write", status = "replace") end if if (eio%screen) then write (msg_buffer, "(A,A,A)") "Events: display on standard output" call msg_message () end if eio%count = 0 if (present (success)) success = .true. end subroutine eio_dump_init_out @ %def eio_dump_init_out @ Initialize event reading. <>= procedure :: init_in => eio_dump_init_in <>= subroutine eio_dump_init_in (eio, sample, data, success, extension) class(eio_dump_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(inout), optional :: data logical, intent(out), optional :: success call msg_bug ("Event dump: event input not supported") if (present (success)) success = .false. end subroutine eio_dump_init_in @ %def eio_dump_init_in @ Switch from input to output: reopen the file for reading. <>= procedure :: switch_inout => eio_dump_switch_inout <>= subroutine eio_dump_switch_inout (eio, success) class(eio_dump_t), intent(inout) :: eio logical, intent(out), optional :: success call msg_bug ("Event dump: in-out switch not supported") if (present (success)) success = .false. end subroutine eio_dump_switch_inout @ %def eio_dump_switch_inout @ Output an event. Delegate the output call to the [[write]] method of the current particle set, if valid. Output both to file (if defined) and to screen (if requested). <>= procedure :: output => eio_dump_output <>= - subroutine eio_dump_output (eio, event, i_prc, reading, passed, pacify) + subroutine eio_dump_output & + (eio, event, i_prc, reading, passed, pacify, event_handle) class(eio_dump_t), intent(inout) :: eio class(generic_event_t), intent(in), target :: event integer, intent(in) :: i_prc logical, intent(in), optional :: reading, passed, pacify + class(event_handle_t), intent(inout), optional :: event_handle character(len=7) :: fmt eio%count = eio%count + 1 if (present (pacify)) then call pac_fmt (fmt, FMT_19, FMT_16, pacify) else call pac_fmt (fmt, FMT_19, FMT_16, eio%pacify) end if if (eio%writing) call dump (eio%unit) if (eio%screen) then call dump (output_unit) if (logfile_unit () > 0) call dump (logfile_unit ()) end if contains subroutine dump (u) integer, intent(in) :: u integer :: i call write_separator (u, 2) write (u, "(1x,A,I0)", advance="no") "Event" if (event%has_index ()) then write (u, "(1x,'#',I0)") event%get_index () else write (u, *) end if call write_separator (u, 2) write (u, "(1x,A,1x,I0)") "count =", eio%count if (present (passed)) then write (u, "(1x,A,1x,L1)") "passed =", passed else write (u, "(1x,A)") "passed = [N/A]" end if write (u, "(1x,A,1x,I0)") "prc id =", i_prc if (eio%weights) then call write_separator (u) if (event%sqme_ref_known) then write (u, "(1x,A," // fmt // ")") "sqme (ref) = ", & event%sqme_ref else write (u, "(1x,A)") "sqme (ref) = [undefined]" end if if (event%sqme_prc_known) then write (u, "(1x,A," // fmt // ")") "sqme (prc) = ", & event%sqme_prc else write (u, "(1x,A)") "sqme (prc) = [undefined]" end if if (event%weight_ref_known) then write (u, "(1x,A," // fmt // ")") "weight (ref) = ", & event%weight_ref else write (u, "(1x,A)") "weight (ref) = [undefined]" end if if (event%weight_prc_known) then write (u, "(1x,A," // fmt // ")") "weight (prc) = ", & event%weight_prc else write (u, "(1x,A)") "weight (prc) = [undefined]" end if if (event%excess_prc_known) then write (u, "(1x,A," // fmt // ")") "excess (prc) = ", & event%excess_prc else write (u, "(1x,A)") "excess (prc) = [undefined]" end if do i = 1, event%n_alt if (event%sqme_ref_known) then write (u, "(1x,A,I0,A," // fmt // ")") "sqme (", i, ") = ",& event%sqme_prc else write (u, "(1x,A,I0,A)") "sqme (", i, ") = [undefined]" end if if (event%weight_prc_known) then write (u, "(1x,A,I0,A," // fmt // ")") "weight (", i, ") = ",& event%weight_prc else write (u, "(1x,A,I0,A)") "weight (", i, ") = [undefined]" end if end do end if call write_separator (u) if (event%particle_set_is_valid) then call event%particle_set%write (unit = u, & summary = eio%summary, compressed = eio%compressed, & testflag = eio%pacify) else write (u, "(1x,A)") "Particle set: [invalid]" end if end subroutine dump end subroutine eio_dump_output @ %def eio_dump_output @ Input an event. <>= procedure :: input_i_prc => eio_dump_input_i_prc procedure :: input_event => eio_dump_input_event <>= subroutine eio_dump_input_i_prc (eio, i_prc, iostat) class(eio_dump_t), intent(inout) :: eio integer, intent(out) :: i_prc integer, intent(out) :: iostat call msg_bug ("Dump stream: event input not supported") i_prc = 0 iostat = 1 end subroutine eio_dump_input_i_prc - subroutine eio_dump_input_event (eio, event, iostat) + subroutine eio_dump_input_event (eio, event, iostat, event_handle) class(eio_dump_t), intent(inout) :: eio class(generic_event_t), intent(inout), target :: event integer, intent(out) :: iostat + class(event_handle_t), intent(inout), optional :: event_handle call msg_bug ("Dump stream: event input not supported") iostat = 1 end subroutine eio_dump_input_event @ %def eio_dump_input_i_prc @ %def eio_dump_input_event @ <>= procedure :: skip => eio_dump_skip <>= subroutine eio_dump_skip (eio, iostat) class(eio_dump_t), intent(inout) :: eio integer, intent(out) :: iostat iostat = 0 end subroutine eio_dump_skip @ %def eio_dump_skip @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[eio_dump_ut.f90]]>>= <> module eio_dump_ut use unit_tests use eio_dump_uti <> <> contains <> end module eio_dump_ut @ %def eio_dump_ut @ <<[[eio_dump_uti.f90]]>>= <> module eio_dump_uti <> <> use io_units use event_base use eio_data use eio_base use eio_dump use eio_base_ut, only: eio_prepare_test, eio_cleanup_test <> <> contains <> end module eio_dump_uti @ %def eio_dump_ut @ API: driver for the unit tests below. <>= public :: eio_dump_test <>= subroutine eio_dump_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine eio_dump_test @ %def eio_dump_test @ \subsubsection{Test I/O methods} We test the implementation of all I/O methods. <>= call test (eio_dump_1, "eio_dump_1", & "write event contents", & u, results) <>= public :: eio_dump_1 <>= subroutine eio_dump_1 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event class(eio_t), allocatable :: eio integer :: i_prc integer :: u_file write (u, "(A)") "* Test output: eio_dump_1" write (u, "(A)") "* Purpose: generate events and write essentials to output" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) write (u, "(A)") write (u, "(A)") "* Generate and write three events (two passed)" write (u, "(A)") allocate (eio_dump_t :: eio) select type (eio) type is (eio_dump_t) call eio%set_parameters (unit = u, weights = .true., pacify = .true.) end select i_prc = 42 call eio%init_out (var_str ("")) call event%generate (1, [0._default, 0._default]) call eio%output (event, i_prc = i_prc) call event%generate (1, [0.1_default, 0._default]) call event%set_index (99) call eio%output (event, i_prc = i_prc, passed = .false.) call event%generate (1, [0.2_default, 0._default]) call event%increment_index () call eio%output (event, i_prc = i_prc, passed = .true.) write (u, "(A)") write (u, "(A)") "* Contents of eio_dump object" write (u, "(A)") call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" select type (eio) type is (eio_dump_t) eio%writing = .false. end select call eio%final () call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_dump_1" end subroutine eio_dump_1 @ %def eio_dump_1 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{ASCII File Formats} Here, we implement several ASCII file formats. It is possible to switch between them using flags. <<[[eio_ascii.f90]]>>= <> module eio_ascii <> use io_units use diagnostics use event_base + use event_handles, only: event_handle_t use eio_data use eio_base use hep_common use hep_events <> <> <> contains <> end module eio_ascii @ %def eio_ascii @ \subsection{Type} <>= public :: eio_ascii_t <>= type, abstract, extends (eio_t) :: eio_ascii_t logical :: writing = .false. integer :: unit = 0 logical :: keep_beams = .false. logical :: keep_remnants = .true. logical :: ensure_order = .false. contains <> end type eio_ascii_t @ %def eio_ascii_t @ <>= public :: eio_ascii_ascii_t <>= type, extends (eio_ascii_t) :: eio_ascii_ascii_t end type eio_ascii_ascii_t @ %def eio_ascii_ascii_t @ <>= public :: eio_ascii_athena_t <>= type, extends (eio_ascii_t) :: eio_ascii_athena_t end type eio_ascii_athena_t @ %def eio_ascii_athena_t @ The debug format has a few options that can be controlled by Sindarin variables. <>= public :: eio_ascii_debug_t <>= type, extends (eio_ascii_t) :: eio_ascii_debug_t logical :: show_process = .true. logical :: show_transforms = .true. logical :: show_decay = .true. logical :: verbose = .true. end type eio_ascii_debug_t @ %def eio_ascii_debug_t @ <>= public :: eio_ascii_hepevt_t <>= type, extends (eio_ascii_t) :: eio_ascii_hepevt_t end type eio_ascii_hepevt_t @ %def eio_ascii_hepevt_t @ <>= public :: eio_ascii_hepevt_verb_t <>= type, extends (eio_ascii_t) :: eio_ascii_hepevt_verb_t end type eio_ascii_hepevt_verb_t @ %def eio_ascii_hepevt_verb_t @ <>= public :: eio_ascii_lha_t <>= type, extends (eio_ascii_t) :: eio_ascii_lha_t end type eio_ascii_lha_t @ %def eio_ascii_lha_t @ <>= public :: eio_ascii_lha_verb_t <>= type, extends (eio_ascii_t) :: eio_ascii_lha_verb_t end type eio_ascii_lha_verb_t @ %def eio_ascii_lha_verb_t @ <>= public :: eio_ascii_long_t <>= type, extends (eio_ascii_t) :: eio_ascii_long_t end type eio_ascii_long_t @ %def eio_ascii_long_t @ <>= public :: eio_ascii_mokka_t <>= type, extends (eio_ascii_t) :: eio_ascii_mokka_t end type eio_ascii_mokka_t @ %def eio_ascii_mokka_t @ <>= public :: eio_ascii_short_t <>= type, extends (eio_ascii_t) :: eio_ascii_short_t end type eio_ascii_short_t @ %def eio_ascii_short_t @ \subsection{Specific Methods} Set parameters that are specifically used with ASCII file formats. In particular, this is the file extension. <>= procedure :: set_parameters => eio_ascii_set_parameters <>= subroutine eio_ascii_set_parameters (eio, & keep_beams, keep_remnants, ensure_order, extension, & show_process, show_transforms, show_decay, verbose) class(eio_ascii_t), intent(inout) :: eio logical, intent(in), optional :: keep_beams logical, intent(in), optional :: keep_remnants logical, intent(in), optional :: ensure_order type(string_t), intent(in), optional :: extension logical, intent(in), optional :: show_process, show_transforms, show_decay logical, intent(in), optional :: verbose if (present (keep_beams)) eio%keep_beams = keep_beams if (present (keep_remnants)) eio%keep_remnants = keep_remnants if (present (ensure_order)) eio%ensure_order = ensure_order if (present (extension)) then eio%extension = extension else select type (eio) type is (eio_ascii_ascii_t) eio%extension = "evt" type is (eio_ascii_athena_t) eio%extension = "athena.evt" type is (eio_ascii_debug_t) eio%extension = "debug" type is (eio_ascii_hepevt_t) eio%extension = "hepevt" type is (eio_ascii_hepevt_verb_t) eio%extension = "hepevt.verb" type is (eio_ascii_lha_t) eio%extension = "lha" type is (eio_ascii_lha_verb_t) eio%extension = "lha.verb" type is (eio_ascii_long_t) eio%extension = "long.evt" type is (eio_ascii_mokka_t) eio%extension = "mokka.evt" type is (eio_ascii_short_t) eio%extension = "short.evt" end select end if select type (eio) type is (eio_ascii_debug_t) if (present (show_process)) eio%show_process = show_process if (present (show_transforms)) eio%show_transforms = show_transforms if (present (show_decay)) eio%show_decay = show_decay if (present (verbose)) eio%verbose = verbose end select end subroutine eio_ascii_set_parameters @ %def eio_ascii_set_parameters @ \subsection{Common Methods} Output. This is not the actual event format, but a readable account of the current object status. <>= procedure :: write => eio_ascii_write <>= subroutine eio_ascii_write (object, unit) class(eio_ascii_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u u = given_output_unit (unit) select type (object) type is (eio_ascii_ascii_t) write (u, "(1x,A)") "ASCII event stream (default format):" type is (eio_ascii_athena_t) write (u, "(1x,A)") "ASCII event stream (ATHENA format):" type is (eio_ascii_debug_t) write (u, "(1x,A)") "ASCII event stream (Debugging format):" type is (eio_ascii_hepevt_t) write (u, "(1x,A)") "ASCII event stream (HEPEVT format):" type is (eio_ascii_hepevt_verb_t) write (u, "(1x,A)") "ASCII event stream (verbose HEPEVT format):" type is (eio_ascii_lha_t) write (u, "(1x,A)") "ASCII event stream (LHA format):" type is (eio_ascii_lha_verb_t) write (u, "(1x,A)") "ASCII event stream (verbose LHA format):" type is (eio_ascii_long_t) write (u, "(1x,A)") "ASCII event stream (long format):" type is (eio_ascii_mokka_t) write (u, "(1x,A)") "ASCII event stream (MOKKA format):" type is (eio_ascii_short_t) write (u, "(1x,A)") "ASCII event stream (short format):" end select if (object%writing) then write (u, "(3x,A,A)") "Writing to file = ", char (object%filename) else write (u, "(3x,A)") "[closed]" end if write (u, "(3x,A,L1)") "Keep beams = ", object%keep_beams write (u, "(3x,A,L1)") "Keep remnants = ", object%keep_remnants select type (object) type is (eio_ascii_debug_t) write (u, "(3x,A,L1)") "Show process = ", object%show_process write (u, "(3x,A,L1)") "Show transforms = ", object%show_transforms write (u, "(3x,A,L1)") "Show decay tree = ", object%show_decay write (u, "(3x,A,L1)") "Verbose output = ", object%verbose end select end subroutine eio_ascii_write @ %def eio_ascii_write @ Finalizer: close any open file. <>= procedure :: final => eio_ascii_final <>= subroutine eio_ascii_final (object) class(eio_ascii_t), intent(inout) :: object if (object%writing) then write (msg_buffer, "(A,A,A)") "Events: closing ASCII file '", & char (object%filename), "'" call msg_message () close (object%unit) object%writing = .false. end if end subroutine eio_ascii_final @ %def eio_ascii_final @ Initialize event writing. Check weight normalization. This applies to all ASCII-type files that use the HEPRUP common block. We can't allow normalization conventions that are not covered by the HEPRUP definition. <>= procedure :: init_out => eio_ascii_init_out <>= subroutine eio_ascii_init_out (eio, sample, data, success, extension) class(eio_ascii_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(in), optional :: data logical, intent(out), optional :: success integer :: i if (.not. present (data)) & call msg_bug ("ASCII initialization: missing data") if (data%n_beam /= 2) & call msg_fatal ("ASCII: defined for scattering processes only") eio%sample = sample call eio%check_normalization (data) call eio%set_splitting (data) call eio%set_filename () eio%unit = free_unit () write (msg_buffer, "(A,A,A)") "Events: writing to ASCII file '", & char (eio%filename), "'" call msg_message () eio%writing = .true. open (eio%unit, file = char (eio%filename), & action = "write", status = "replace") select type (eio) type is (eio_ascii_lha_t) call heprup_init( & data%pdg_beam, & data%energy_beam, & n_processes = data%n_proc, & unweighted = data%unweighted, & negative_weights = data%negative_weights) do i = 1, data%n_proc call heprup_set_process_parameters (i = i, & process_id = data%proc_num_id(i), & cross_section = data%cross_section(i), & error = data%error(i)) end do call heprup_write_ascii (eio%unit) type is (eio_ascii_lha_verb_t) call heprup_init( & data%pdg_beam, & data%energy_beam, & n_processes = data%n_proc, & unweighted = data%unweighted, & negative_weights = data%negative_weights) do i = 1, data%n_proc call heprup_set_process_parameters (i = i, & process_id = data%proc_num_id(i), & cross_section = data%cross_section(i), & error = data%error(i)) end do call heprup_write_verbose (eio%unit) end select if (present (success)) success = .true. end subroutine eio_ascii_init_out @ %def eio_ascii_init_out @ Some event properties do not go well with some output formats. In particular, many formats require unweighted events. <>= procedure :: check_normalization => eio_ascii_check_normalization <>= subroutine eio_ascii_check_normalization (eio, data) class(eio_ascii_t), intent(in) :: eio type(event_sample_data_t), intent(in) :: data if (data%unweighted) then else select type (eio) type is (eio_ascii_athena_t); call msg_fatal & ("Event output (Athena format): events must be unweighted.") type is (eio_ascii_hepevt_t); call msg_fatal & ("Event output (HEPEVT format): events must be unweighted.") type is (eio_ascii_hepevt_verb_t); call msg_fatal & ("Event output (HEPEVT format): events must be unweighted.") end select select case (data%norm_mode) case (NORM_SIGMA) case default select type (eio) type is (eio_ascii_lha_t) call msg_fatal & ("Event output (LHA): normalization for weighted events & &must be 'sigma'") type is (eio_ascii_lha_verb_t) call msg_fatal & ("Event output (LHA): normalization for weighted events & &must be 'sigma'") end select end select end if end subroutine eio_ascii_check_normalization @ %def check_normalization @ Initialize event reading. <>= procedure :: init_in => eio_ascii_init_in <>= subroutine eio_ascii_init_in (eio, sample, data, success, extension) class(eio_ascii_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(inout), optional :: data logical, intent(out), optional :: success call msg_bug ("ASCII: event input not supported") if (present (success)) success = .false. end subroutine eio_ascii_init_in @ %def eio_ascii_init_in @ Switch from input to output: reopen the file for reading. <>= procedure :: switch_inout => eio_ascii_switch_inout <>= subroutine eio_ascii_switch_inout (eio, success) class(eio_ascii_t), intent(inout) :: eio logical, intent(out), optional :: success call msg_bug ("ASCII: in-out switch not supported") if (present (success)) success = .false. end subroutine eio_ascii_switch_inout @ %def eio_ascii_switch_inout @ Split event file: increment the counter, close the current file, open a new one. If the file needs a header, repeat it for the new file. (We assume that the common block contents are still intact.) <>= procedure :: split_out => eio_ascii_split_out <>= subroutine eio_ascii_split_out (eio) class(eio_ascii_t), intent(inout) :: eio if (eio%split) then eio%split_index = eio%split_index + 1 call eio%set_filename () write (msg_buffer, "(A,A,A)") "Events: writing to ASCII file '", & char (eio%filename), "'" call msg_message () close (eio%unit) open (eio%unit, file = char (eio%filename), & action = "write", status = "replace") select type (eio) type is (eio_ascii_lha_t) call heprup_write_ascii (eio%unit) type is (eio_ascii_lha_verb_t) call heprup_write_verbose (eio%unit) end select end if end subroutine eio_ascii_split_out @ %def eio_ascii_split_out @ Output an event. Write first the event indices, then weight and squared matrix element, then the particle set. Events that did not pass the selection are skipped. The exceptions are the [[ascii]] and [[debug]] formats. These are the formats that contain the [[passed]] flag in their output, and should be most useful for debugging purposes. <>= procedure :: output => eio_ascii_output <>= - subroutine eio_ascii_output (eio, event, i_prc, reading, passed, pacify) + subroutine eio_ascii_output & + (eio, event, i_prc, reading, passed, pacify, event_handle) class(eio_ascii_t), intent(inout) :: eio class(generic_event_t), intent(in), target :: event integer, intent(in) :: i_prc logical, intent(in), optional :: reading, passed, pacify + class(event_handle_t), intent(inout), optional :: event_handle if (present (passed)) then if (.not. passed) then select type (eio) type is (eio_ascii_debug_t) type is (eio_ascii_ascii_t) class default return end select end if end if if (eio%writing) then select type (eio) type is (eio_ascii_lha_t) call hepeup_from_event (event, & process_index = i_prc, & keep_beams = eio%keep_beams, & keep_remnants = eio%keep_remnants) call hepeup_write_lha (eio%unit) type is (eio_ascii_lha_verb_t) call hepeup_from_event (event, & process_index = i_prc, & keep_beams = eio%keep_beams, & keep_remnants = eio%keep_remnants) call hepeup_write_verbose (eio%unit) type is (eio_ascii_ascii_t) call event%write (eio%unit, & show_process = .false., & show_transforms = .false., & show_decay = .false., & verbose = .false., testflag = pacify) type is (eio_ascii_athena_t) call hepevt_from_event (event, & keep_beams = eio%keep_beams, & keep_remnants = eio%keep_remnants, & ensure_order = eio%ensure_order) call hepevt_write_athena (eio%unit) type is (eio_ascii_debug_t) call event%write (eio%unit, & show_process = eio%show_process, & show_transforms = eio%show_transforms, & show_decay = eio%show_decay, & verbose = eio%verbose, & testflag = pacify) type is (eio_ascii_hepevt_t) call hepevt_from_event (event, & keep_beams = eio%keep_beams, & keep_remnants = eio%keep_remnants, & ensure_order = eio%ensure_order) call hepevt_write_hepevt (eio%unit) type is (eio_ascii_hepevt_verb_t) call hepevt_from_event (event, & keep_beams = eio%keep_beams, & keep_remnants = eio%keep_remnants, & ensure_order = eio%ensure_order) call hepevt_write_verbose (eio%unit) type is (eio_ascii_long_t) call hepevt_from_event (event, & keep_beams = eio%keep_beams, & keep_remnants = eio%keep_remnants, & ensure_order = eio%ensure_order) call hepevt_write_ascii (eio%unit, .true.) type is (eio_ascii_mokka_t) call hepevt_from_event (event, & keep_beams = eio%keep_beams, & keep_remnants = eio%keep_remnants, & ensure_order = eio%ensure_order) call hepevt_write_mokka (eio%unit) type is (eio_ascii_short_t) call hepevt_from_event (event, & keep_beams = eio%keep_beams, & keep_remnants = eio%keep_remnants, & ensure_order = eio%ensure_order) call hepevt_write_ascii (eio%unit, .false.) end select else call eio%write () call msg_fatal ("ASCII file is not open for writing") end if end subroutine eio_ascii_output @ %def eio_ascii_output @ Input an event. <>= procedure :: input_i_prc => eio_ascii_input_i_prc procedure :: input_event => eio_ascii_input_event <>= subroutine eio_ascii_input_i_prc (eio, i_prc, iostat) class(eio_ascii_t), intent(inout) :: eio integer, intent(out) :: i_prc integer, intent(out) :: iostat call msg_bug ("ASCII: event input not supported") i_prc = 0 iostat = 1 end subroutine eio_ascii_input_i_prc - subroutine eio_ascii_input_event (eio, event, iostat) + subroutine eio_ascii_input_event (eio, event, iostat, event_handle) class(eio_ascii_t), intent(inout) :: eio class(generic_event_t), intent(inout), target :: event integer, intent(out) :: iostat + class(event_handle_t), intent(inout), optional :: event_handle call msg_bug ("ASCII: event input not supported") iostat = 1 end subroutine eio_ascii_input_event @ %def eio_ascii_input_i_prc @ %def eio_ascii_input_event @ <>= procedure :: skip => eio_ascii_skip <>= subroutine eio_ascii_skip (eio, iostat) class(eio_ascii_t), intent(inout) :: eio integer, intent(out) :: iostat iostat = 0 end subroutine eio_ascii_skip @ %def eio_asciii_skip @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[eio_ascii_ut.f90]]>>= <> module eio_ascii_ut use unit_tests use eio_ascii_uti <> <> contains <> end module eio_ascii_ut @ %def eio_ascii_ut @ <<[[eio_ascii_uti.f90]]>>= <> module eio_ascii_uti <> <> use io_units use lorentz use model_data use event_base use particles use eio_data use eio_base use eio_ascii use eio_base_ut, only: eio_prepare_test, eio_cleanup_test <> <> contains <> end module eio_ascii_uti @ %def eio_ascii_uti @ API: driver for the unit tests below. <>= public :: eio_ascii_test <>= subroutine eio_ascii_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine eio_ascii_test @ %def eio_ascii_test @ \subsubsection{Test I/O methods} We test the implementation of all I/O methods, method [[ascii]]: <>= call test (eio_ascii_1, "eio_ascii_1", & "read and write event contents, format [ascii]", & u, results) <>= public :: eio_ascii_1 <>= subroutine eio_ascii_1 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(80) :: buffer write (u, "(A)") "* Test output: eio_ascii_1" write (u, "(A)") "* Purpose: generate an event in ASCII ascii format" write (u, "(A)") "* and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) call data%init (1) data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_ascii_1" allocate (eio_ascii_ascii_t :: eio) select type (eio) class is (eio_ascii_t); call eio%set_parameters () end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%set_index (42) call event%evaluate_expressions () call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents:" write (u, "(A)") u_file = free_unit () open (u_file, file = char (sample // ".evt"), & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (buffer(1:21) == " ") buffer = "[...]" if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Reset data" write (u, "(A)") deallocate (eio) allocate (eio_ascii_ascii_t :: eio) select type (eio) type is (eio_ascii_ascii_t) call eio%set_parameters (keep_beams = .true.) end select call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_ascii_1" end subroutine eio_ascii_1 @ %def eio_ascii_1 @ We test the implementation of all I/O methods, method [[athena]]: <>= call test (eio_ascii_2, "eio_ascii_2", & "read and write event contents, format [athena]", & u, results) <>= public :: eio_ascii_2 <>= subroutine eio_ascii_2 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(80) :: buffer write (u, "(A)") "* Test output: eio_ascii_2" write (u, "(A)") "* Purpose: generate an event in ASCII athena format" write (u, "(A)") "* and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) call data%init (1) data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_ascii_2" allocate (eio_ascii_athena_t :: eio) select type (eio) class is (eio_ascii_t); call eio%set_parameters () end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%set_index (42) call event%evaluate_expressions () call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents:" write (u, "(A)") u_file = free_unit () open (u_file, file = char(sample // ".athena.evt"), & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (buffer(1:21) == " ") buffer = "[...]" if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Reset data" write (u, "(A)") deallocate (eio) allocate (eio_ascii_athena_t :: eio) select type (eio) type is (eio_ascii_athena_t) call eio%set_parameters (keep_beams = .true.) end select call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_ascii_2" end subroutine eio_ascii_2 @ %def eio_ascii_2 @ We test the implementation of all I/O methods, method [[debug]]: <>= call test (eio_ascii_3, "eio_ascii_3", & "read and write event contents, format [debug]", & u, results) <>= public :: eio_ascii_3 <>= subroutine eio_ascii_3 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(80) :: buffer write (u, "(A)") "* Test output: eio_ascii_3" write (u, "(A)") "* Purpose: generate an event in ASCII debug format" write (u, "(A)") "* and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) call data%init (1) data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_ascii_3" allocate (eio_ascii_debug_t :: eio) select type (eio) class is (eio_ascii_t); call eio%set_parameters () end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%increment_index () call event%evaluate_expressions () call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents:" write (u, "(A)") u_file = free_unit () open (u_file, file = char (sample // ".debug"), & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (buffer(1:21) == " ") buffer = "[...]" if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Reset data" write (u, "(A)") deallocate (eio) allocate (eio_ascii_debug_t :: eio) select type (eio) type is (eio_ascii_debug_t) call eio%set_parameters (keep_beams = .true.) end select call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_ascii_3" end subroutine eio_ascii_3 @ %def eio_ascii_3 @ We test the implementation of all I/O methods, method [[hepevt]]: <>= call test (eio_ascii_4, "eio_ascii_4", & "read and write event contents, format [hepevt]", & u, results) <>= public :: eio_ascii_4 <>= subroutine eio_ascii_4 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(80) :: buffer write (u, "(A)") "* Test output: eio_ascii_4" write (u, "(A)") "* Purpose: generate an event in ASCII hepevt format" write (u, "(A)") "* and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) call data%init (1) data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_ascii_4" allocate (eio_ascii_hepevt_t :: eio) select type (eio) class is (eio_ascii_t); call eio%set_parameters () end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%increment_index () call event%evaluate_expressions () call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents:" write (u, "(A)") u_file = free_unit () open (u_file, file = char (sample // ".hepevt"), & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (buffer(1:21) == " ") buffer = "[...]" if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Reset data" write (u, "(A)") deallocate (eio) allocate (eio_ascii_hepevt_t :: eio) select type (eio) type is (eio_ascii_hepevt_t) call eio%set_parameters (keep_beams = .true.) end select call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_ascii_4" end subroutine eio_ascii_4 @ %def eio_ascii_4 @ We test the implementation of all I/O methods, method [[lha]] (old LHA): <>= call test (eio_ascii_5, "eio_ascii_5", & "read and write event contents, format [lha]", & u, results) <>= public :: eio_ascii_5 <>= subroutine eio_ascii_5 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(80) :: buffer write (u, "(A)") "* Test output: eio_ascii_5" write (u, "(A)") "* Purpose: generate an event in ASCII LHA format" write (u, "(A)") "* and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) call data%init (1) data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_ascii_5" allocate (eio_ascii_lha_t :: eio) select type (eio) class is (eio_ascii_t); call eio%set_parameters () end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%increment_index () call event%evaluate_expressions () call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents:" write (u, "(A)") u_file = free_unit () open (u_file, file = char (sample // ".lha"), & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (buffer(1:21) == " ") buffer = "[...]" if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Reset data" write (u, "(A)") deallocate (eio) allocate (eio_ascii_lha_t :: eio) select type (eio) type is (eio_ascii_lha_t) call eio%set_parameters (keep_beams = .true.) end select call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_ascii_5" end subroutine eio_ascii_5 @ %def eio_ascii_5 @ We test the implementation of all I/O methods, method [[long]]: <>= call test (eio_ascii_6, "eio_ascii_6", & "read and write event contents, format [long]", & u, results) <>= public :: eio_ascii_6 <>= subroutine eio_ascii_6 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(80) :: buffer write (u, "(A)") "* Test output: eio_ascii_6" write (u, "(A)") "* Purpose: generate an event in ASCII long format" write (u, "(A)") "* and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) call data%init (1) data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_ascii_6" allocate (eio_ascii_long_t :: eio) select type (eio) class is (eio_ascii_t); call eio%set_parameters () end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%increment_index () call event%evaluate_expressions () call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents:" write (u, "(A)") u_file = free_unit () open (u_file, file = char (sample // ".long.evt"), & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (buffer(1:21) == " ") buffer = "[...]" if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Reset data" write (u, "(A)") deallocate (eio) allocate (eio_ascii_long_t :: eio) select type (eio) type is (eio_ascii_long_t) call eio%set_parameters (keep_beams = .true.) end select call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_ascii_6" end subroutine eio_ascii_6 @ %def eio_ascii_6 @ We test the implementation of all I/O methods, method [[mokka]]: <>= call test (eio_ascii_7, "eio_ascii_7", & "read and write event contents, format [mokka]", & u, results) <>= public :: eio_ascii_7 <>= subroutine eio_ascii_7 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(80) :: buffer write (u, "(A)") "* Test output: eio_ascii_7" write (u, "(A)") "* Purpose: generate an event in ASCII mokka format" write (u, "(A)") "* and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) call data%init (1) data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_ascii_7" allocate (eio_ascii_mokka_t :: eio) select type (eio) class is (eio_ascii_t); call eio%set_parameters () end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%increment_index () call event%evaluate_expressions () call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents:" write (u, "(A)") u_file = free_unit () open (u_file, file = char (sample // ".mokka.evt"), & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (buffer(1:21) == " ") buffer = "[...]" if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Reset data" write (u, "(A)") deallocate (eio) allocate (eio_ascii_mokka_t :: eio) select type (eio) type is (eio_ascii_mokka_t) call eio%set_parameters (keep_beams = .true.) end select call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_ascii_7" end subroutine eio_ascii_7 @ %def eio_ascii_7 @ We test the implementation of all I/O methods, method [[short]]: <>= call test (eio_ascii_8, "eio_ascii_8", & "read and write event contents, format [short]", & u, results) <>= public :: eio_ascii_8 <>= subroutine eio_ascii_8 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(80) :: buffer write (u, "(A)") "* Test output: eio_ascii_8" write (u, "(A)") "* Purpose: generate an event in ASCII short format" write (u, "(A)") "* and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) call data%init (1) data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_ascii_8" allocate (eio_ascii_short_t :: eio) select type (eio) class is (eio_ascii_t); call eio%set_parameters () end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%increment_index () call event%evaluate_expressions () call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents:" write (u, "(A)") u_file = free_unit () open (u_file, file = char (sample // ".short.evt"), & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (buffer(1:21) == " ") buffer = "[...]" if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Reset data" write (u, "(A)") deallocate (eio) allocate (eio_ascii_short_t :: eio) select type (eio) type is (eio_ascii_short_t) call eio%set_parameters (keep_beams = .true.) end select call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_ascii_8" end subroutine eio_ascii_8 @ %def eio_ascii_8 @ We test the implementation of all I/O methods, method [[lha]] (old LHA) in verbose version: <>= call test (eio_ascii_9, "eio_ascii_9", & "read and write event contents, format [lha_verb]", & u, results) <>= public :: eio_ascii_9 <>= subroutine eio_ascii_9 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(80) :: buffer write (u, "(A)") "* Test output: eio_ascii_9" write (u, "(A)") "* Purpose: generate an event in ASCII LHA verbose format" write (u, "(A)") "* and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) call data%init (1) data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_ascii_9" allocate (eio_ascii_lha_verb_t :: eio) select type (eio) class is (eio_ascii_t); call eio%set_parameters () end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%increment_index () call event%evaluate_expressions () call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents:" write (u, "(A)") u_file = free_unit () open (u_file, file = char (sample // ".lha.verb"), & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (buffer(1:21) == " ") buffer = "[...]" if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Reset data" write (u, "(A)") deallocate (eio) allocate (eio_ascii_lha_verb_t :: eio) select type (eio) type is (eio_ascii_lha_verb_t) call eio%set_parameters (keep_beams = .true.) end select call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_ascii_9" end subroutine eio_ascii_9 @ %def eio_ascii_9 @ We test the implementation of all I/O methods, method [[hepevt_verb]]: <>= call test (eio_ascii_10, "eio_ascii_10", & "read and write event contents, format [hepevt_verb]", & u, results) <>= public :: eio_ascii_10 <>= subroutine eio_ascii_10 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(80) :: buffer write (u, "(A)") "* Test output: eio_ascii_10" write (u, "(A)") "* Purpose: generate an event in ASCII hepevt verbose format" write (u, "(A)") "* and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) call data%init (1) data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_ascii_10" allocate (eio_ascii_hepevt_verb_t :: eio) select type (eio) class is (eio_ascii_t); call eio%set_parameters () end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%increment_index () call event%evaluate_expressions () call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents:" write (u, "(A)") u_file = free_unit () open (u_file, file = char (sample // ".hepevt.verb"), & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (buffer(1:21) == " ") buffer = "[...]" if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Reset data" write (u, "(A)") deallocate (eio) allocate (eio_ascii_hepevt_verb_t :: eio) select type (eio) type is (eio_ascii_hepevt_verb_t) call eio%set_parameters (keep_beams = .true.) end select call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_ascii_10" end subroutine eio_ascii_10 @ %def eio_ascii_10 @ We test the implementation of all I/O methods, method [[mokka]]: <>= call test (eio_ascii_11, "eio_ascii_11", & "read and write event contents, format [mokka], tiny value", & u, results) <>= public :: eio_ascii_11 <>= subroutine eio_ascii_11 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(particle_set_t), pointer :: pset type(vector4_t) :: pnew type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(128) :: buffer real(default), parameter :: tval = 1.e-111_default write (u, "(A)") "* Test output: eio_ascii_11" write (u, "(A)") "* Purpose: generate an event in ASCII mokka format" write (u, "(A)") "* and write weight to file" write (u, "(A)") "* with low-value cutoff" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) call data%init (1) data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_ascii_11" allocate (eio_ascii_mokka_t :: eio) select type (eio) class is (eio_ascii_t); call eio%set_parameters () end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%increment_index () call event%evaluate_expressions () ! Manipulate values in the event record pset => event%get_particle_set_ptr () call pset%set_momentum (3, & vector4_moving (-tval, vector3_moving ([-tval, -tval, -tval])), & -tval**2) call pset%set_momentum (4, & vector4_moving (tval, vector3_moving ([tval, tval, tval])), & tval**2) call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents:" write (u, "(A)") u_file = free_unit () open (u_file, file = char (sample // ".mokka.evt"), & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (buffer(1:21) == " ") buffer = "[...]" if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_ascii_11" end subroutine eio_ascii_11 @ %def eio_ascii_11 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{HEP Common Blocks} Long ago, to transfer data between programs one had to set up a common block and link both programs as libraries to the main executable. The HEP community standardizes several of those common blocks. The modern way of data exchange uses data files with standard formats. However, the LHEF standard data format derives from a common block (actually, two). \whizard\ used to support those common blocks, and LHEF was implemented via writing/reading blocks. We still keep this convention, but intend to eliminate common blocks (or any other static storage) from the workflow in the future. This will gain flexibility towards concurrent running of program images. We encapsulate everything here in a module. The module holds the variables which are part of the common block. To access the common block variables, we just have to [[use]] this module. (They are nevertheless in the common block, since external software may access it in this way.) Note: This code is taken essentially unchanged from \whizard\ 2.1 and does not (yet) provide unit tests. <<[[hep_common.f90]]>>= <> module hep_common <> use kinds, only: double use constants <> <> use io_units use diagnostics use numeric_utils use format_utils, only: refmt_tiny use physics_defs, only: HADRON_REMNANT use physics_defs, only: HADRON_REMNANT_SINGLET use physics_defs, only: HADRON_REMNANT_TRIPLET use physics_defs, only: HADRON_REMNANT_OCTET use physics_defs, only: pb_per_fb use xml use lorentz use flavors use colors use polarizations use model_data use particles use subevents, only: PRT_BEAM, PRT_INCOMING, PRT_OUTGOING use subevents, only: PRT_UNDEFINED use subevents, only: PRT_VIRTUAL, PRT_RESONANT, PRT_BEAM_REMNANT <> <> <> <> <> <> contains <> end module hep_common @ %def hep_common @ \subsection{Event characteristics} The maximal number of particles in an event record. <>= integer, parameter, public :: MAXNUP = 500 @ %def MAXNUP @ The number of particles in this event. <>= integer, public :: NUP @ %def NUP @ The process ID for this event. <>= integer, public :: IDPRUP @ %def IDPRUP @ The weight of this event ($\pm 1$ for unweighted events). <>= double precision, public :: XWGTUP @ %def XWGTUP @ The factorization scale that is used for PDF calculation ($-1$ if undefined). <>= double precision, public :: SCALUP @ %def SCALUP @ The QED and QCD couplings $\alpha$ used for this event ($-1$ if undefined). <>= double precision, public :: AQEDUP double precision, public :: AQCDUP @ %def AQEDUP AQCDUP @ \subsection{Particle characteristics} The PDG code: <>= integer, dimension(MAXNUP), public :: IDUP @ %def IDUP @ The status code. Incoming: $-1$, outgoing: $+1$. Intermediate t-channel propagator: $-2$ (currently not used by WHIZARD). Intermediate resonance whose mass should be preserved: $2$. Intermediate resonance for documentation: $3$ (currently not used). Beam particles: $-9$. <>= integer, dimension(MAXNUP), public :: ISTUP @ %def ISTUP @ Index of first and last mother. <>= integer, dimension(2,MAXNUP), public :: MOTHUP @ %def MOTHUP @ Color line index of the color and anticolor entry for the particle. The standard recommends using large numbers; we start from MAXNUP+1. <>= integer, dimension(2,MAXNUP), public :: ICOLUP @ %def ICOLUP @ Momentum, energy, and invariant mass: $(p_x,p_y,p_z,E,M)$. For space-like particles, $M$ is the negative square root of the absolute value of the invariant mass. <>= double precision, dimension(5,MAXNUP), public :: PUP @ %def PUP @ Invariant lifetime (distance) from production to decay in mm. <>= double precision, dimension(MAXNUP), public :: VTIMUP @ %def VTIMUP @ Cosine of the angle between the spin-vector and a particle and the 3-momentum of its mother, given in the lab frame. If undefined/unpolarized: $9$. <>= double precision, dimension(MAXNUP), public :: SPINUP @ %def SPINUP @ \subsection{The HEPRUP common block} This common block is filled once per run. \subsubsection{Run characteristics} The maximal number of different processes. <>= integer, parameter, public :: MAXPUP = 100 @ %def MAXPUP @ The beam PDG codes. <>= integer, dimension(2), public :: IDBMUP @ %def IDBMUP @ The beam energies in GeV. <>= double precision, dimension(2), public :: EBMUP @ %def EBMUP @ The PDF group and set for the two beams. (Undefined: use $-1$; LHAPDF: use group = $0$). <>= integer, dimension(2), public :: PDFGUP integer, dimension(2), public :: PDFSUP @ %def PDFGUP PDFSUP @ The (re)weighting model. 1: events are weighted, the shower generator (SHG) selects processes according to the maximum weight (in pb) and unweights events. 2: events are weighted, the SHG selects processes according to their cross section (in pb) and unweights events. 3: events are unweighted and simply run through the SHG. 4: events are weighted, and the SHG keeps the weight. Negative numbers: negative weights are allowed (and are reweighted to $\pm 1$ by the SHG, if allowed). \whizard\ only supports modes 3 and 4, as the SHG is not given control over process selection. This is consistent with writing events to file, for offline showering. <>= integer, public :: IDWTUP @ %def IDWTUP @ The number of different processes. <>= integer, public :: NPRUP @ %def NPRUP @ \subsubsection{Process characteristics} Cross section and error in pb. (Cross section is needed only for $[[IDWTUP]] = 2$, so here both values are given for informational purposes only.) <>= double precision, dimension(MAXPUP), public :: XSECUP double precision, dimension(MAXPUP), public :: XERRUP @ %def XSECUP XERRUP @ Maximum weight, i.e., the maximum value that [[XWGTUP]] can take. Also unused for the supported weighting models. It is $\pm 1$ for unweighted events. <>= double precision, dimension(MAXPUP), public :: XMAXUP @ %def XMAXUP @ Internal ID of the selected process, matches [[IDPRUP]] below. <>= integer, dimension(MAXPUP), public :: LPRUP @ %def LPRUP @ \subsubsection{The common block} <>= common /HEPRUP/ & IDBMUP, EBMUP, PDFGUP, PDFSUP, IDWTUP, NPRUP, & XSECUP, XERRUP, XMAXUP, LPRUP save /HEPRUP/ @ %def HEPRUP @ Fill the run characteristics of the common block. The initialization sets the beam properties, number of processes, and weighting model. <>= public :: heprup_init <>= subroutine heprup_init & (beam_pdg, beam_energy, n_processes, unweighted, negative_weights) integer, dimension(2), intent(in) :: beam_pdg real(default), dimension(2), intent(in) :: beam_energy integer, intent(in) :: n_processes logical, intent(in) :: unweighted logical, intent(in) :: negative_weights IDBMUP = beam_pdg EBMUP = beam_energy PDFGUP = -1 PDFSUP = -1 if (unweighted) then IDWTUP = 3 else IDWTUP = 4 end if if (negative_weights) IDWTUP = - IDWTUP NPRUP = n_processes end subroutine heprup_init @ %def heprup_init The HEPRUP (event) common block is needed for the interface to the shower. Filling of it is triggered by some output file formats. If these are not present, the common block is filled with some dummy information. Be generous with the number of processes in HEPRUP so that PYTHIA only rarely needs to be reinitialized in case events with higher process ids are generated. <>= public :: assure_heprup <>= subroutine assure_heprup (pset) type(particle_set_t), intent(in) :: pset integer :: i, num_id integer, parameter :: min_processes = 10 num_id = 1 if (LPRUP (num_id) /= 0) return call heprup_init ( & [pset%prt(1)%get_pdg (), pset%prt(2)%get_pdg ()] , & [pset%prt(1)%p%p(0), pset%prt(2)%p%p(0)], & num_id, .false., .false.) do i = 1, (num_id / min_processes + 1) * min_processes call heprup_set_process_parameters (i = i, process_id = & i, cross_section = 1._default, error = 1._default) end do end subroutine assure_heprup @ %def assure_heprup @ Read in the LHE file opened in unit [[u]] and add the final particles to the [[particle_set]], the outgoing particles of the existing [[particle_set]] are compared to the particles that are read in. When they are equal in flavor and momenta, they are erased and their mother-daughter relations are transferred to the existing particles. <>= public :: combine_lhef_with_particle_set <>= subroutine combine_lhef_with_particle_set & (particle_set, u, model_in, model_hadrons) type(particle_set_t), intent(inout) :: particle_set integer, intent(in) :: u class(model_data_t), intent(in), target :: model_in class(model_data_t), intent(in), target :: model_hadrons type(flavor_t) :: flv type(color_t) :: col class(model_data_t), pointer :: model type(particle_t), dimension(:), allocatable :: prt_tmp, prt integer :: i, j type(vector4_t) :: mom, d_mom integer, PARAMETER :: MAXLEN=200 character(len=maxlen) :: string integer :: ibeg, n_tot, n_entries integer, dimension(:), allocatable :: relations, mothers, tbd INTEGER :: NUP,IDPRUP,IDUP,ISTUP real(kind=double) :: XWGTUP,SCALUP,AQEDUP,AQCDUP,VTIMUP,SPINUP integer :: MOTHUP(1:2), ICOLUP(1:2) real(kind=double) :: PUP(1:5) real(kind=default) :: pup_dum(1:5) character(len=5) :: buffer character(len=6) :: strfmt logical :: not_found logical :: debug_lhef = .false. STRFMT='(A000)' WRITE (STRFMT(3:5),'(I3)') MAXLEN if (debug_lhef) call particle_set%write () rewind (u) do read (u,*, END=501, ERR=502) STRING IBEG = 0 do if (signal_is_pending ()) return IBEG = IBEG + 1 ! Allow indentation. IF (STRING (IBEG:IBEG) .EQ. ' ' .and. IBEG < MAXLEN-6) cycle exit end do IF (string(IBEG:IBEG+6) /= '' .and. & string(IBEG:IBEG+6) /= ' number of entries read (u, *, END=503, ERR=504) NUP, IDPRUP, XWGTUP, SCALUP, AQEDUP, AQCDUP n_tot = particle_set%get_n_tot () allocate (prt_tmp (1:n_tot+NUP)) allocate (relations (1:NUP), mothers (1:NUP), tbd(1:NUP)) do i = 1, n_tot if (signal_is_pending ()) return prt_tmp (i) = particle_set%get_particle (i) end do !!! transfer particles from lhef to particle_set !!!...Read NUP subsequent lines with information on each particle. n_entries = 1 mothers = 0 relations = 0 PARTICLE_LOOP: do I = 1, NUP read (u,*, END=200, ERR=505) IDUP, ISTUP, MOTHUP(1), MOTHUP(2), & ICOLUP(1), ICOLUP(2), (PUP (J),J=1,5), VTIMUP, SPINUP if (model_in%test_field (IDUP)) then model => model_in else if (model_hadrons%test_field (IDUP)) then model => model_hadrons else write (buffer, "(I5)") IDUP call msg_error ("Parton " // buffer // & " found neither in given model file nor in SM_hadrons") return end if if (debug_lhef) then print *, "IDUP, ISTUP, MOTHUP, PUP = ", IDUP, ISTUP, MOTHUP(1), & MOTHUP(2), PUP end if call flv%init (IDUP, model) if (IABS(IDUP) == 2212 .or. IABS(IDUP) == 2112) then ! PYTHIA sometimes sets color indices for protons and neutrons (?) ICOLUP (1) = 0 ICOLUP (2) = 0 end if call col%init_col_acl (ICOLUP (1), ICOLUP (2)) !!! Settings for unpolarized particles ! particle_set%prt (oldsize+i)%hel = ?? ! particle_set%prt (oldsize+i)%pol = ?? if (MOTHUP(1) /= 0) then mothers(i) = MOTHUP(1) end if pup_dum = PUP if (pup_dum(4) < 1E-10_default) cycle mom = vector4_moving (pup_dum (4), & vector3_moving ([pup_dum (1), pup_dum (2), pup_dum (3)])) not_found = .true. SCAN_PARTICLES: do j = 1, n_tot d_mom = prt_tmp(j)%get_momentum () if (all (nearly_equal & (mom%p, d_mom%p, abs_smallness = 1.E-4_default)) .and. & (prt_tmp(j)%get_pdg () == IDUP)) then if (.not. prt_tmp(j)%get_status () == PRT_BEAM .or. & .not. prt_tmp(j)%get_status () == PRT_BEAM_REMNANT) & relations(i) = j not_found = .false. end if end do SCAN_PARTICLES if (not_found) then if (debug_lhef) & print *, "Not found: adding particle" call prt_tmp(n_tot+n_entries)%set_flavor (flv) call prt_tmp(n_tot+n_entries)%set_color (col) call prt_tmp(n_tot+n_entries)%set_momentum (mom) if (MOTHUP(1) /= 0) then if (relations(MOTHUP(1)) /= 0) then call prt_tmp(n_tot+n_entries)%set_parents & ([relations(MOTHUP(1))]) call prt_tmp(relations(MOTHUP(1)))%add_child (n_tot+n_entries) if (prt_tmp(relations(MOTHUP(1)))%get_status () & == PRT_OUTGOING) & call prt_tmp(relations(MOTHUP(1)))%reset_status & (PRT_VIRTUAL) end if end if call prt_tmp(n_tot+n_entries)%set_status (PRT_OUTGOING) if (debug_lhef) call prt_tmp(n_tot+n_entries)%write () n_entries = n_entries + 1 end if end do PARTICLE_LOOP do i = 1, n_tot if (prt_tmp(i)%get_status () == PRT_OUTGOING .and. & prt_tmp(i)%get_n_children () /= 0) then call prt_tmp(i)%reset_status (PRT_VIRTUAL) end if end do allocate (prt (1:n_tot+n_entries-1)) prt = prt_tmp (1:n_tot+n_entries-1) ! transfer to particle_set call particle_set%replace (prt) deallocate (prt, prt_tmp) if (debug_lhef) then call particle_set%write () print *, "combine_lhef_with_particle_set" ! stop end if 200 continue return 501 write(*,*) "READING LHEF failed 501" return 502 write(*,*) "READING LHEF failed 502" return 503 write(*,*) "READING LHEF failed 503" return 504 write(*,*) "READING LHEF failed 504" return 505 write(*,*) "READING LHEF failed 505" return end subroutine combine_lhef_with_particle_set @ %def combine_lhef_with_particle_set @ <>= public :: w2p_write_lhef_event <>= subroutine w2p_write_lhef_event (unit) integer, intent(in) :: unit type(xml_tag_t), allocatable :: tag_lhef, tag_head, tag_init, & tag_event, tag_gen_n, tag_gen_v if (debug_on) call msg_debug (D_EVENTS, "w2p_write_lhef_event") allocate (tag_lhef, tag_head, tag_init, tag_event, & tag_gen_n, tag_gen_v) call tag_lhef%init (var_str ("LesHouchesEvents"), & [xml_attribute (var_str ("version"), var_str ("1.0"))], .true.) call tag_head%init (var_str ("header"), .true.) call tag_init%init (var_str ("init"), .true.) call tag_event%init (var_str ("event"), .true.) call tag_gen_n%init (var_str ("generator_name"), .true.) call tag_gen_v%init (var_str ("generator_version"), .true.) call tag_lhef%write (unit); write (unit, *) call tag_head%write (unit); write (unit, *) write (unit, "(2x)", advance = "no") call tag_gen_n%write (var_str ("WHIZARD"), unit) write (unit, *) write (unit, "(2x)", advance = "no") call tag_gen_v%write (var_str ("<>"), unit) write (unit, *) call tag_head%close (unit); write (unit, *) call tag_init%write (unit); write (unit, *) call heprup_write_lhef (unit) call tag_init%close (unit); write (unit, *) call tag_event%write (unit); write (unit, *) call hepeup_write_lhef (unit) call tag_event%close (unit); write (unit, *) call tag_lhef%close (unit); write (unit, *) deallocate (tag_lhef, tag_head, tag_init, tag_event, & tag_gen_n, tag_gen_v) end subroutine w2p_write_lhef_event @ %def w2p_write_lhef_event @ Extract parameters from the common block. We leave it to the caller to specify which parameters it actually needs. [[PDFGUP]] and [[PDFSUP]] are not extracted. [[IDWTUP=1,2]] are not supported by \whizard, but correspond to weighted events. <>= public :: heprup_get_run_parameters <>= subroutine heprup_get_run_parameters & (beam_pdg, beam_energy, n_processes, unweighted, negative_weights) integer, dimension(2), intent(out), optional :: beam_pdg real(default), dimension(2), intent(out), optional :: beam_energy integer, intent(out), optional :: n_processes logical, intent(out), optional :: unweighted logical, intent(out), optional :: negative_weights if (present (beam_pdg)) beam_pdg = IDBMUP if (present (beam_energy)) beam_energy = EBMUP if (present (n_processes)) n_processes = NPRUP if (present (unweighted)) then select case (abs (IDWTUP)) case (3) unweighted = .true. case (4) unweighted = .false. case (1,2) !!! not supported by WHIZARD unweighted = .false. case default call msg_fatal ("HEPRUP: unsupported IDWTUP value") end select end if if (present (negative_weights)) then negative_weights = IDWTUP < 0 end if end subroutine heprup_get_run_parameters @ %def heprup_get_run_parameters @ Specify PDF set info. Since we support only LHAPDF, the group entry is zero. <>= public :: heprup_set_lhapdf_id <>= subroutine heprup_set_lhapdf_id (i_beam, pdf_id) integer, intent(in) :: i_beam, pdf_id PDFGUP(i_beam) = 0 PDFSUP(i_beam) = pdf_id end subroutine heprup_set_lhapdf_id @ %def heprup_set_lhapdf_id @ Fill the characteristics for a particular process. Only the process ID is mandatory. Note that \whizard\ computes cross sections in fb, so we have to rescale to pb. The maximum weight is meaningless for unweighted events. <>= public :: heprup_set_process_parameters <>= subroutine heprup_set_process_parameters & (i, process_id, cross_section, error, max_weight) integer, intent(in) :: i, process_id real(default), intent(in), optional :: cross_section, error, max_weight LPRUP(i) = process_id if (present (cross_section)) then XSECUP(i) = cross_section * pb_per_fb else XSECUP(i) = 0 end if if (present (error)) then XERRUP(i) = error * pb_per_fb else XERRUP(i) = 0 end if select case (IDWTUP) case (3); XMAXUP(i) = 1 case (4) if (present (max_weight)) then XMAXUP(i) = max_weight * pb_per_fb else XMAXUP(i) = 0 end if end select end subroutine heprup_set_process_parameters @ %def heprup_set_process_parameters @ Extract the process parameters, as far as needed. <>= public :: heprup_get_process_parameters <>= subroutine heprup_get_process_parameters & (i, process_id, cross_section, error, max_weight) integer, intent(in) :: i integer, intent(out), optional :: process_id real(default), intent(out), optional :: cross_section, error, max_weight if (present (process_id)) process_id = LPRUP(i) if (present (cross_section)) then cross_section = XSECUP(i) / pb_per_fb end if if (present (error)) then error = XERRUP(i) / pb_per_fb end if if (present (max_weight)) then select case (IDWTUP) case (3) max_weight = 1 case (4) max_weight = XMAXUP(i) / pb_per_fb case (1,2) !!! not supported by WHIZARD max_weight = 0 case default call msg_fatal ("HEPRUP: unsupported IDWTUP value") end select end if end subroutine heprup_get_process_parameters @ %def heprup_get_process_parameters @ \subsection{Run parameter output (verbose)} This is a verbose output of the HEPRUP block. <>= public :: heprup_write_verbose <>= subroutine heprup_write_verbose (unit) integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit); if (u < 0) return write (u, "(A)") "HEPRUP Common Block" write (u, "(3x,A6,' = ',I9,3x,1x,I9,3x,8x,A)") "IDBMUP", IDBMUP, & "PDG code of beams" write (u, "(3x,A6,' = ',G12.5,1x,G12.5,8x,A)") "EBMUP ", EBMUP, & "Energy of beams in GeV" write (u, "(3x,A6,' = ',I9,3x,1x,I9,3x,8x,A)") "PDFGUP", PDFGUP, & "PDF author group [-1 = undefined]" write (u, "(3x,A6,' = ',I9,3x,1x,I9,3x,8x,A)") "PDFSUP", PDFSUP, & "PDF set ID [-1 = undefined]" write (u, "(3x,A6,' = ',I9,3x,1x,9x,3x,8x,A)") "IDWTUP", IDWTUP, & "LHA code for event weight mode" write (u, "(3x,A6,' = ',I9,3x,1x,9x,3x,8x,A)") "NPRUP ", NPRUP, & "Number of user subprocesses" do i = 1, NPRUP write (u, "(1x,A,I0)") "Subprocess #", i write (u, "(3x,A6,' = ',ES12.5,1x,12x,8x,A)") "XSECUP", XSECUP(i), & "Cross section in pb" write (u, "(3x,A6,' = ',ES12.5,1x,12x,8x,A)") "XERRUP", XERRUP(i), & "Cross section error in pb" write (u, "(3x,A6,' = ',ES12.5,1x,12x,8x,A)") "XMAXUP", XMAXUP(i), & "Maximum event weight (cf. IDWTUP)" write (u, "(3x,A6,' = ',I9,3x,1x,12x,8x,A)") "LPRUP ", LPRUP(i), & "Subprocess ID" end do end subroutine heprup_write_verbose @ %def heprup_write_verbose @ \subsection{Run parameter output (other formats)} This routine writes the initialization block according to the LHEF standard. It uses the current contents of the HEPRUP block. <>= public :: heprup_write_lhef <>= subroutine heprup_write_lhef (unit) integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit); if (u < 0) return write (u, "(2(1x,I0),2(1x,ES17.10),6(1x,I0))") & IDBMUP, EBMUP, PDFGUP, PDFSUP, IDWTUP, NPRUP do i = 1, NPRUP write (u, "(3(1x,ES17.10),1x,I0)") & XSECUP(i), XERRUP(i), XMAXUP(i), LPRUP(i) end do end subroutine heprup_write_lhef @ %def heprup_write_lhef @ This routine is a complete dummy at the moment. It uses the current contents of the HEPRUP block. At the end, it should depend on certain input flags for the different ASCII event formats. <>= public :: heprup_write_ascii <>= subroutine heprup_write_ascii (unit) integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit); if (u < 0) return write (u, "(2(1x,I0),2(1x,ES17.10),6(1x,I0))") & IDBMUP, EBMUP, PDFGUP, PDFSUP, IDWTUP, NPRUP do i = 1, NPRUP write (u, "(3(1x,ES17.10),1x,I0)") & XSECUP(i), XERRUP(i), XMAXUP(i), LPRUP(i) end do end subroutine heprup_write_ascii @ %def heprup_write_ascii @ \subsubsection{Run parameter input (LHEF)} In a LHEF file, the parameters are written in correct order on separate lines, but we should not count on the precise format. List-directed input should just work. <>= public :: heprup_read_lhef <>= subroutine heprup_read_lhef (u) integer, intent(in) :: u integer :: i read (u, *) & IDBMUP, EBMUP, PDFGUP, PDFSUP, IDWTUP, NPRUP do i = 1, NPRUP read (u, *) & XSECUP(i), XERRUP(i), XMAXUP(i), LPRUP(i) end do end subroutine heprup_read_lhef @ %def heprup_read_lhef @ \subsection{The HEPEUP common block} <>= common /HEPEUP/ & NUP, IDPRUP, XWGTUP, SCALUP, AQEDUP, AQCDUP, & IDUP, ISTUP, MOTHUP, ICOLUP, PUP, VTIMUP, SPINUP save /HEPEUP/ @ %def HEPEUP @ \subsubsection{Initialization} Fill the event characteristics of the common block. The initialization sets only the number of particles and initializes the rest with default values. The other routine sets the optional parameters. <>= public :: hepeup_init public :: hepeup_set_event_parameters <>= subroutine hepeup_init (n_tot) integer, intent(in) :: n_tot NUP = n_tot IDPRUP = 0 XWGTUP = 1 SCALUP = -1 AQEDUP = -1 AQCDUP = -1 end subroutine hepeup_init subroutine hepeup_set_event_parameters & (proc_id, weight, scale, alpha_qed, alpha_qcd) integer, intent(in), optional :: proc_id real(default), intent(in), optional :: weight, scale, alpha_qed, alpha_qcd if (present (proc_id)) IDPRUP = proc_id if (present (weight)) XWGTUP = weight if (present (scale)) SCALUP = scale if (present (alpha_qed)) AQEDUP = alpha_qed if (present (alpha_qcd)) AQCDUP = alpha_qcd end subroutine hepeup_set_event_parameters @ %def hepeup_init hepeup_set_event_parameters @ Extract event information. The caller determines the parameters. <>= public :: hepeup_get_event_parameters <>= subroutine hepeup_get_event_parameters & (proc_id, weight, scale, alpha_qed, alpha_qcd) integer, intent(out), optional :: proc_id real(default), intent(out), optional :: weight, scale, alpha_qed, alpha_qcd if (present (proc_id)) proc_id = IDPRUP if (present (weight)) weight = XWGTUP if (present (scale)) scale = SCALUP if (present (alpha_qed)) alpha_qed = AQEDUP if (present (alpha_qcd)) alpha_qcd = AQCDUP end subroutine hepeup_get_event_parameters @ %def hepeup_get_event_parameters @ \subsubsection{Particle data} Below we need the particle status codes which are actually defined in the [[subevents]] module. Set the entry for a specific particle. All parameters are set with the exception of lifetime and spin, where default values are stored. <>= public :: hepeup_set_particle <>= subroutine hepeup_set_particle (i, pdg, status, parent, col, p, m2) integer, intent(in) :: i integer, intent(in) :: pdg, status integer, dimension(:), intent(in) :: parent type(vector4_t), intent(in) :: p integer, dimension(2), intent(in) :: col real(default), intent(in) :: m2 if (i > MAXNUP) then call msg_error (arr=[ & var_str ("Too many particles in HEPEUP common block. " // & "If this happened "), & var_str ("during event output, your events will be " // & "invalid; please consider "), & var_str ("switching to a modern event format like HEPMC. " // & "If you are not "), & var_str ("using an old, HEPEUP based format and " // & "nevertheless get this error,"), & var_str ("please notify the WHIZARD developers,") ]) return end if IDUP(i) = pdg select case (status) case (PRT_BEAM); ISTUP(i) = -9 case (PRT_INCOMING); ISTUP(i) = -1 case (PRT_BEAM_REMNANT); ISTUP(i) = 3 case (PRT_OUTGOING); ISTUP(i) = 1 case (PRT_RESONANT); ISTUP(i) = 2 case (PRT_VIRTUAL); ISTUP(i) = 3 case default; ISTUP(i) = 0 end select select case (size (parent)) case (0); MOTHUP(:,i) = 0 case (1); MOTHUP(1,i) = parent(1); MOTHUP(2,i) = 0 case default; MOTHUP(:,i) = [ parent(1), parent(size (parent)) ] end select if (col(1) > 0) then ICOLUP(1,i) = 500 + col(1) else ICOLUP(1,i) = 0 end if if (col(2) > 0) then ICOLUP(2,i) = 500 + col(2) else ICOLUP(2,i) = 0 end if PUP(1:3,i) = refmt_tiny (vector3_get_components (space_part (p))) PUP(4,i) = refmt_tiny (energy (p)) PUP(5,i) = refmt_tiny (sign (sqrt (abs (m2)), m2)) VTIMUP(i) = 0 SPINUP(i) = 9 end subroutine hepeup_set_particle @ %def hepeup_set_particle @ Set the lifetime, actually $c\tau$ measured im mm, where $\tau$ is the invariant lifetime. <>= public :: hepeup_set_particle_lifetime <>= subroutine hepeup_set_particle_lifetime (i, lifetime) integer, intent(in) :: i real(default), intent(in) :: lifetime VTIMUP(i) = lifetime end subroutine hepeup_set_particle_lifetime @ %def hepeup_set_particle_lifetime @ Set the particle spin entry. We need the cosine of the angle of the spin axis with respect to the three-momentum of the parent particle. If the particle has a full polarization density matrix given, we need the particle momentum and polarization as well as the mother-particle momentum. The polarization is transformed into a spin vector (which is sensible only for spin-1/2 or massless particles), which then is transformed into the lab frame (by a rotation of the 3-axis to the particle momentum axis). Finally, we compute the scalar product of this vector with the mother-particle three-momentum. This puts severe restrictions on the applicability of this definition, and Lorentz invariance is lost. Unfortunately, the Les Houches Accord requires this computation. <>= public :: hepeup_set_particle_spin <>= interface hepeup_set_particle_spin module procedure hepeup_set_particle_spin_pol end interface <>= subroutine hepeup_set_particle_spin_pol (i, p, pol, p_mother) integer, intent(in) :: i type(vector4_t), intent(in) :: p type(polarization_t), intent(in) :: pol type(vector4_t), intent(in) :: p_mother type(vector3_t) :: s3, p3 type(vector4_t) :: s4 s3 = vector3_moving (pol%get_axis ()) p3 = space_part (p) s4 = rotation_to_2nd (3, p3) * vector4_moving (0._default, s3) SPINUP(i) = enclosed_angle_ct (s4, p_mother) end subroutine hepeup_set_particle_spin_pol @ %def hepeup_set_particle_spin @ Extract particle data. The caller decides which ones to retrieve. Status codes: beam remnants share the status code with virtual particles. However, for the purpose of WHIZARD we should identify them. We use the PDG code for this. <>= public :: hepeup_get_particle <>= subroutine hepeup_get_particle (i, pdg, status, parent, col, p, m2) integer, intent(in) :: i integer, intent(out), optional :: pdg, status integer, dimension(:), intent(out), optional :: parent type(vector4_t), intent(out), optional :: p integer, dimension(2), intent(out), optional :: col real(default), dimension(5,MAXNUP) :: pup_def real(default), intent(out), optional :: m2 if (present (pdg)) pdg = IDUP(i) if (present (status)) then select case (ISTUP(i)) case (-9); status = PRT_BEAM case (-1); status = PRT_INCOMING case (1); status = PRT_OUTGOING case (2); status = PRT_RESONANT case (3); select case (abs (IDUP(i))) case (HADRON_REMNANT, HADRON_REMNANT_SINGLET, & HADRON_REMNANT_TRIPLET, HADRON_REMNANT_OCTET) status = PRT_BEAM_REMNANT case default status = PRT_VIRTUAL end select case default status = PRT_UNDEFINED end select end if if (present (parent)) then select case (size (parent)) case (0) case (1); parent(1) = MOTHUP(1,i) case (2); parent = MOTHUP(:,i) end select end if if (present (col)) then col = ICOLUP(:,i) end if if (present (p)) then pup_def = PUP p = vector4_moving (pup_def(4,i), vector3_moving (pup_def(1:3,i))) end if if (present (m2)) then m2 = sign (PUP(5,i) ** 2, PUP(5,i)) end if end subroutine hepeup_get_particle @ %def hepeup_get_particle @ \subsection{The HEPEVT and HEPEV4 common block} For the LEP Monte Carlos, a standard common block has been proposed in AKV89. We strongly recommend its use. (The description is an abbreviated transcription of AKV89, Vol. 3, pp. 327-330). [[NMXHEP]] is the maximum number of entries: <>= integer, parameter :: NMXHEP = 4000 @ %def NMXHEP @ [[NEVHEP]] is normally the event number, but may take special values as follows: 0 the program does not keep track of event numbers. -1 a special initialization record. -2 a special final record. <>= integer :: NEVHEP @ %def NEVHEP @ [[NHEP]] holds the number of entries for this event. <>= integer, public :: NHEP @ %def NHEP @ The entry [[ISTHEP(N)]] gives the status code for the [[N]]th entry, with the following semantics: 0 a null entry. 1 an existing entry, which has not decayed or fragmented. 2 a decayed or fragmented entry, which is retained for event history information. 3 documentation line. 4- 10 reserved for future standards. 11-200 at the disposal of each model builder. 201- at the disposal of users. <>= integer, dimension(NMXHEP), public :: ISTHEP @ %def ISTHEP @ The Particle Data Group has proposed standard particle codes, which are to be stored in [[IDHEP(N)]]. <>= integer, dimension(NMXHEP), public :: IDHEP @ %def IDHEP @ [[JMOHEP(1,N)]] points to the mother of the [[N]]th entry, if any. It is set to zero for initial entries. [[JMOHEP(2,N)]] points to the second mother, if any. <>= integer, dimension(2, NMXHEP), public :: JMOHEP @ %def JMOHEP @ [[JDAHEP(1,N)]] and [[JDAHEP(2,N)]] point to the first and last daughter of the [[N]]th entry, if any. These are zero for entries which have not yet decayed. The other daughters are stored in between these two. <>= integer, dimension(2, NMXHEP), public :: JDAHEP @ %def JDAHEP @ In [[PHEP]] we store the momentum of the particle, more specifically this means that [[PHEP(1,N)]], [[PHEP(2,N)]], and [[PHEP(3,N)]] contain the momentum in the $x$, $y$, and $z$ direction (as defined by the machine people), measured in GeV/c. [[PHEP(4,N)]] contains the energy in GeV and [[PHEP(5,N)]] the mass in GeV$/c^2$. The latter may be negative for spacelike partons. <>= double precision, dimension(5, NMXHEP), public :: PHEP @ %def PHEP @ Finally [[VHEP]] is the place to store the position of the production vertex. [[VHEP(1,N)]], [[VHEP(2,N)]], and [[VHEP(3,N)]] contain the $x$, $y$, and $z$ coordinate (as defined by the machine people), measured in mm. [[VHEP(4,N)]] contains the production time in mm/c. <>= double precision, dimension(4, NMXHEP) :: VHEP @ %def VHEP @ As an amendment to the proposed standard common block HEPEVT, we also have a polarisation common block HEPSPN, as described in AKV89. [[SHEP(1,N)]], [[SHEP(2,N)]], and [[SHEP(3,N)]] give the $x$, $y$, and $z$ component of the spinvector $s$ of a fermion in the fermions restframe. Furthermore, we add the polarization of the corresponding outgoing particles: <>= integer, dimension(NMXHEP) :: hepevt_pol @ %def hepevt_pol @ By this variable the identity of the current process is given, defined via the LPRUP codes. <>= integer, public :: idruplh @ %def idruplh This is the event weight, i.e. the cross section divided by the total number of generated events for the output of the parton shower programs. <>= double precision, public :: eventweightlh @ %def eventweightlh @ There are the values for the electromagnetic and the strong coupling constants, $\alpha_{em}$ and $\alpha_s$. <>= double precision, public :: alphaqedlh, alphaqcdlh @ %def alphaqedlh, alphaqcdlh @ This is the squared scale $Q$ of the event. <>= double precision, dimension(10), public :: scalelh @ %def scalelh @ Finally, these variables contain the spin information and the color/anticolor flow of the particles. <>= double precision, dimension (3,NMXHEP), public :: spinlh integer, dimension (2,NMXHEP), public :: icolorflowlh @ %def spinlh icolorflowlh By convention, [[SHEP(4,N)]] is always 1. All this is taken from StdHep 4.06 manual and written using Fortran90 conventions. <>= common /HEPEVT/ & NEVHEP, NHEP, ISTHEP, IDHEP, & JMOHEP, JDAHEP, PHEP, VHEP save /HEPEVT/ @ %def HEPEVT @ Here we store HEPEVT parameters of the WHIZARD 1 realization which are not part of the HEPEVT common block. <>= integer :: hepevt_n_out, hepevt_n_remnants @ %def hepevt_n_out, hepevt_n_remnants @ <>= double precision :: hepevt_weight, hepevt_function_value double precision :: hepevt_function_ratio @ %def hepevt_weight hepevt_function_value @ The HEPEV4 common block is an extension of the HEPEVT common block to allow for partonic colored events, including especially the color flow etc. <>= common /HEPEV4/ & eventweightlh, alphaqedlh, alphaqcdlh, scalelh, & spinlh, icolorflowlh, idruplh save /HEPEV4/ @ %def HEPEV4 @ Filling HEPEVT: If the event count is not provided, set [[NEVHEP]] to zero. If the event count is [[-1]] or [[-2]], the record corresponds to initialization and finalization, and the event is irrelevant. Note that the event count may be larger than $2^{31}$ (2 GEvents). In that case, cut off the upper bits since [[NEVHEP]] is probably limited to default integer. For the HEPEV4 common block, it is unclear why the [[scalelh]] variable is 10-dimensional. We choose to only set the first value of the array. <>= public :: hepevt_init public :: hepevt_set_event_parameters <>= subroutine hepevt_init (n_tot, n_out) integer, intent(in) :: n_tot, n_out NHEP = n_tot NEVHEP = 0 idruplh = 0 hepevt_n_out = n_out hepevt_n_remnants = 0 hepevt_weight = 1 eventweightlh = 1 hepevt_function_value = 0 hepevt_function_ratio = 1 alphaqcdlh = -1 alphaqedlh = -1 scalelh = -1 end subroutine hepevt_init subroutine hepevt_set_event_parameters & (proc_id, weight, function_value, function_ratio, & alpha_qcd, alpha_qed, scale, i_evt) integer, intent(in), optional :: proc_id integer, intent(in), optional :: i_evt real(default), intent(in), optional :: weight, function_value, & function_ratio, alpha_qcd, alpha_qed, scale if (present (proc_id)) idruplh = proc_id if (present (i_evt)) NEVHEP = i_evt if (present (weight)) then hepevt_weight = weight eventweightlh = weight end if if (present (function_value)) hepevt_function_value = & function_value if (present (function_ratio)) hepevt_function_ratio = & function_ratio if (present (alpha_qcd)) alphaqcdlh = alpha_qcd if (present (alpha_qed)) alphaqedlh = alpha_qed if (present (scale)) scalelh(1) = scale if (present (i_evt)) NEVHEP = i_evt end subroutine hepevt_set_event_parameters @ %def hepevt_init hepevt_set_event_parameters @ Set the entry for a specific particle. All parameters are set with the exception of lifetime and spin, where default values are stored. <>= public :: hepevt_set_particle <>= subroutine hepevt_set_particle & (i, pdg, status, parent, child, p, m2, hel, vtx, & col, pol_status, pol, fill_hepev4) integer, intent(in) :: i integer, intent(in) :: pdg, status integer, dimension(:), intent(in) :: parent integer, dimension(:), intent(in) :: child logical, intent(in), optional :: fill_hepev4 type(vector4_t), intent(in) :: p real(default), intent(in) :: m2 integer, dimension(2), intent(in) :: col integer, intent(in) :: pol_status integer, intent(in) :: hel type(polarization_t), intent(in), optional :: pol type(vector4_t), intent(in) :: vtx logical :: hepev4 hepev4 = .false.; if (present (fill_hepev4)) hepev4 = fill_hepev4 IDHEP(i) = pdg select case (status) case (PRT_BEAM); ISTHEP(i) = 2 case (PRT_INCOMING); ISTHEP(i) = 2 case (PRT_OUTGOING); ISTHEP(i) = 1 case (PRT_VIRTUAL); ISTHEP(i) = 2 case (PRT_RESONANT); ISTHEP(i) = 2 case default; ISTHEP(i) = 0 end select select case (size (parent)) case (0); JMOHEP(:,i) = 0 case (1); JMOHEP(1,i) = parent(1); JMOHEP(2,i) = 0 case default; JMOHEP(:,i) = [ parent(1), parent(size (parent)) ] end select select case (size (child)) case (0); JDAHEP(:,i) = 0 case (1); JDAHEP(:,i) = child(1) case default; JDAHEP(:,i) = [ child(1), child(size (child)) ] end select PHEP(1:3,i) = refmt_tiny (vector3_get_components (space_part (p))) PHEP(4,i) = refmt_tiny (energy (p)) PHEP(5,i) = refmt_tiny (sign (sqrt (abs (m2)), m2)) VHEP(1:3,i) = vtx%p(1:3) VHEP(4,i) = vtx%p(0) hepevt_pol(i) = hel if (hepev4) then if (col(1) > 0) then icolorflowlh(1,i) = 500 + col(1) else icolorflowlh(1,i) = 0 end if if (col(2) > 0) then icolorflowlh(2,i) = 500 + col(2) else icolorflowlh(2,i) = 0 end if if (present (pol) .and. & pol_status == PRT_GENERIC_POLARIZATION) then if (pol%is_polarized ()) & spinlh(:,i) = pol%get_axis () else spinlh(:,i) = zero spinlh(3,i) = hel end if end if end subroutine hepevt_set_particle @ %def hepevt_set_particle @ \subsection{Event output} This is a verbose output of the HEPEVT block. <>= public :: hepevt_write_verbose <>= subroutine hepevt_write_verbose (unit) integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit); if (u < 0) return write (u, "(A)") "HEPEVT Common Block" write (u, "(3x,A6,' = ',I9,3x,1x,20x,A)") "NEVHEP", NEVHEP, & "Event number" write (u, "(3x,A6,' = ',I9,3x,1x,20x,A)") "NHEP ", NHEP, & "Number of particles in event" do i = 1, NHEP write (u, "(1x,A,I0)") "Particle #", i write (u, "(3x,A6,' = ',I9,3x,1x,20x,A)", advance="no") & "ISTHEP", ISTHEP(i), "Status code: " select case (ISTHEP(i)) case ( 0); write (u, "(A)") "null entry" case ( 1); write (u, "(A)") "outgoing" case ( 2); write (u, "(A)") "decayed" case ( 3); write (u, "(A)") "documentation" case (4:10); write (u, "(A)") "[unspecified]" case (11:200); write (u, "(A)") "[model-specific]" case (201:); write (u, "(A)") "[user-defined]" case default; write (u, "(A)") "[undefined]" end select write (u, "(3x,A6,' = ',I9,3x,1x,20x,A)") "IDHEP ", IDHEP(i), & "PDG code of particle" write (u, "(3x,A6,' = ',I9,3x,1x,I9,3x,8x,A)") "JMOHEP", JMOHEP(:,i), & "Index of first/second mother" write (u, "(3x,A6,' = ',I9,3x,1x,I9,3x,8x,A)") "JDAHEP", JDAHEP(:,i), & "Index of first/last daughter" write (u, "(3x,A6,' = ',ES12.5,1x,ES12.5,8x,A)") "PHEP12", & PHEP(1:2,i), "Transversal momentum (x/y) in GeV" write (u, "(3x,A6,' = ',ES12.5,1x,12x,8x,A)") "PHEP3 ", PHEP(3,i), & "Longitudinal momentum (z) in GeV" write (u, "(3x,A6,' = ',ES12.5,1x,12x,8x,A)") "PHEP4 ", PHEP(4,i), & "Energy in GeV" write (u, "(3x,A6,' = ',ES12.5,1x,12x,8x,A)") "PHEP5 ", PHEP(5,i), & "Invariant mass in GeV" write (u, "(3x,A6,' = ',ES12.5,1x,ES12.5,8x,A)") "VHEP12", VHEP(1:2,i), & "Transversal displacement (xy) in mm" write (u, "(3x,A6,' = ',ES12.5,1x,12x,8x,A)") "VHEP3 ", VHEP(3,i), & "Longitudinal displacement (z) in mm" write (u, "(3x,A6,' = ',ES12.5,1x,12x,8x,A)") "VHEP4 ", VHEP(4,i), & "Production time in mm" end do end subroutine hepevt_write_verbose @ %def hepevt_write_verbose @ This is a verbose output of the HEPEUP block. <>= public :: hepeup_write_verbose <>= subroutine hepeup_write_verbose (unit) integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit); if (u < 0) return write (u, "(A)") "HEPEUP Common Block" write (u, "(3x,A6,' = ',I9,3x,1x,20x,A)") "NUP ", NUP, & "Number of particles in event" write (u, "(3x,A6,' = ',I9,3x,1x,20x,A)") "IDPRUP", IDPRUP, & "Subprocess ID" write (u, "(3x,A6,' = ',ES12.5,1x,20x,A)") "XWGTUP", XWGTUP, & "Event weight" write (u, "(3x,A6,' = ',ES12.5,1x,20x,A)") "SCALUP", SCALUP, & "Event energy scale in GeV" write (u, "(3x,A6,' = ',ES12.5,1x,20x,A)") "AQEDUP", AQEDUP, & "QED coupling [-1 = undefined]" write (u, "(3x,A6,' = ',ES12.5,1x,20x,A)") "AQCDUP", AQCDUP, & "QCD coupling [-1 = undefined]" do i = 1, NUP write (u, "(1x,A,I0)") "Particle #", i write (u, "(3x,A6,' = ',I9,3x,1x,20x,A)") "IDUP ", IDUP(i), & "PDG code of particle" write (u, "(3x,A6,' = ',I9,3x,1x,20x,A)", advance="no") & "ISTUP ", ISTUP(i), "Status code: " select case (ISTUP(i)) case (-1); write (u, "(A)") "incoming" case ( 1); write (u, "(A)") "outgoing" case (-2); write (u, "(A)") "spacelike" case ( 2); write (u, "(A)") "resonance" case ( 3); write (u, "(A)") "resonance (doc)" case (-9); write (u, "(A)") "beam" case default; write (u, "(A)") "[undefined]" end select write (u, "(3x,A6,' = ',I9,3x,1x,I9,3x,8x,A)") "MOTHUP", MOTHUP(:,i), & "Index of first/last mother" write (u, "(3x,A6,' = ',I9,3x,1x,I9,3x,8x,A)") "ICOLUP", ICOLUP(:,i), & "Color/anticolor flow index" write (u, "(3x,A6,' = ',ES12.5,1x,ES12.5,8x,A)") "PUP1/2", PUP(1:2,i), & "Transversal momentum (x/y) in GeV" write (u, "(3x,A6,' = ',ES12.5,1x,12x,8x,A)") "PUP3 ", PUP(3,i), & "Longitudinal momentum (z) in GeV" write (u, "(3x,A6,' = ',ES12.5,1x,12x,8x,A)") "PUP4 ", PUP(4,i), & "Energy in GeV" write (u, "(3x,A6,' = ',ES12.5,1x,12x,8x,A)") "PUP5 ", PUP(5,i), & "Invariant mass in GeV" write (u, "(3x,A6,' = ',ES12.5,1x,12x,8x,A)") "VTIMUP", VTIMUP(i), & "Invariant lifetime in mm" write (u, "(3x,A6,' = ',ES12.5,1x,12x,8x,A)") "SPINUP", SPINUP(i), & "cos(spin angle) [9 = undefined]" end do end subroutine hepeup_write_verbose @ %def hepeup_write_verbose @ \subsection{Event output in various formats} This routine writes event output according to the LHEF standard. It uses the current contents of the HEPEUP block. <>= public :: hepeup_write_lhef public :: hepeup_write_lha <>= subroutine hepeup_write_lhef (unit) integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit); if (u < 0) return if (debug_on) call msg_debug (D_EVENTS, "hepeup_write_lhef") if (debug_on) call msg_debug2 (D_EVENTS, "ID IST MOTH ICOL P VTIM SPIN") write (u, "(2(1x,I0),4(1x,ES17.10))") & NUP, IDPRUP, XWGTUP, SCALUP, AQEDUP, AQCDUP do i = 1, NUP write (u, "(6(1x,I0),7(1x,ES17.10))") & IDUP(i), ISTUP(i), MOTHUP(:,i), ICOLUP(:,i), & PUP(:,i), VTIMUP(i), SPINUP(i) if (debug2_active (D_EVENTS)) then write (msg_buffer, "(6(1x,I0),7(1x,ES17.10))") & IDUP(i), ISTUP(i), MOTHUP(:,i), ICOLUP(:,i), & PUP(:,i), VTIMUP(i), SPINUP(i) call msg_message () end if end do end subroutine hepeup_write_lhef subroutine hepeup_write_lha (unit) integer, intent(in), optional :: unit integer :: u, i integer, dimension(MAXNUP) :: spin_up spin_up = int(SPINUP) u = given_output_unit (unit); if (u < 0) return write (u, "(2(1x,I5),1x,ES17.10,3(1x,ES13.6))") & NUP, IDPRUP, XWGTUP, SCALUP, AQEDUP, AQCDUP write (u, "(500(1x,I5))") IDUP(:NUP) write (u, "(500(1x,I5))") MOTHUP(1,:NUP) write (u, "(500(1x,I5))") MOTHUP(2,:NUP) write (u, "(500(1x,I5))") ICOLUP(1,:NUP) write (u, "(500(1x,I5))") ICOLUP(2,:NUP) write (u, "(500(1x,I5))") ISTUP(:NUP) write (u, "(500(1x,I5))") spin_up(:NUP) do i = 1, NUP write (u, "(1x,I5,4(1x,ES17.10))") i, PUP([ 4,1,2,3 ], i) end do end subroutine hepeup_write_lha @ %def hepeup_write_lhef hepeup_write_lha @ This routine writes event output according to the HEPEVT standard. It uses the current contents of the HEPEVT block and some additional parameters according to the standard in WHIZARD 1. For the long ASCII format, the value of the sample function (i.e. the product of squared matrix element, structure functions and phase space factor is printed out). The option of reweighting matrix elements with respect to some reference cross section is not implemented in WHIZARD 2 for this event format, therefore the second entry in the long ASCII format (the function ratio) is always one. The ATHENA format is an implementation of the HEPEVT format that is readable by the ATLAS ATHENA software framework. It is very similar to the WHIZARD 1 HEPEVT format, except that it contains an event counter, a particle counter inside the event, and has the HEPEVT [[ISTHEP]] status before the PDG code. The MOKKA format is a special ASCII format that contains the information to be parsed to the MOKKA LC fast simulation software. <>= public :: hepevt_write_hepevt public :: hepevt_write_ascii public :: hepevt_write_athena public :: hepevt_write_mokka <>= subroutine hepevt_write_hepevt (unit) integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit); if (u < 0) return write (u, "(3(1x,I0),(1x,ES17.10))") & NHEP, hepevt_n_out, hepevt_n_remnants, hepevt_weight do i = 1, NHEP write (u, "(7(1x,I0))") & ISTHEP(i), IDHEP(i), JMOHEP(:,i), JDAHEP(:,i), hepevt_pol(i) write (u, "(5(1x,ES17.10))") PHEP(:,i) write (u, "(5(1x,ES17.10))") VHEP(:,i), 0.d0 end do end subroutine hepevt_write_hepevt subroutine hepevt_write_ascii (unit, long) integer, intent(in), optional :: unit logical, intent(in) :: long integer :: u, i u = given_output_unit (unit); if (u < 0) return write (u, "(3(1x,I0),(1x,ES17.10))") & NHEP, hepevt_n_out, hepevt_n_remnants, hepevt_weight do i = 1, NHEP if (ISTHEP(i) /= 1) cycle write (u, "(2(1x,I0))") IDHEP(i), hepevt_pol(i) write (u, "(5(1x,ES17.10))") PHEP(:,i) end do if (long) then write (u, "(2(1x,ES17.10))") & hepevt_function_value, hepevt_function_ratio end if end subroutine hepevt_write_ascii subroutine hepevt_write_athena (unit) integer, intent(in), optional :: unit integer :: u, i, num_event num_event = 0 u = given_output_unit (unit); if (u < 0) return write (u, "(2(1x,I0))") NEVHEP, NHEP do i = 1, NHEP write (u, "(7(1x,I0))") & i, ISTHEP(i), IDHEP(i), JMOHEP(:,i), JDAHEP(:,i) write (u, "(5(1x,ES17.10))") PHEP(:,i) write (u, "(5(1x,ES17.10))") VHEP(1:4,i) end do end subroutine hepevt_write_athena subroutine hepevt_write_mokka (unit) integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit); if (u < 0) return write (u, "(3(1x,I0),(1x,ES17.10))") & NHEP, hepevt_n_out, hepevt_n_remnants, hepevt_weight do i = 1, NHEP write (u, "(4(1x,I0),4(1x,ES17.10))") & ISTHEP(i), IDHEP(i), JDAHEP(1,i), JDAHEP(2,i), & PHEP(1:3,i), PHEP(5,i) end do end subroutine hepevt_write_mokka @ %def hepevt_write_hepevt hepevt_write_ascii @ %def hepevt_write_athena @ \subsection{Event input in various formats} This routine writes event output according to the LHEF standard. It uses the current contents of the HEPEUP block. <>= public :: hepeup_read_lhef <>= subroutine hepeup_read_lhef (u) integer, intent(in) :: u integer :: i read (u, *) & NUP, IDPRUP, XWGTUP, SCALUP, AQEDUP, AQCDUP do i = 1, NUP read (u, *) & IDUP(i), ISTUP(i), MOTHUP(:,i), ICOLUP(:,i), & PUP(:,i), VTIMUP(i), SPINUP(i) end do end subroutine hepeup_read_lhef @ %def hepeup_read_lhef @ \subsection{Data Transfer: particle sets} The \whizard\ format for handling particle data in events is [[particle_set_t]]. We have to interface this to the common blocks. We first create a new particle set that contains only the particles that are supported by the LHEF format. These are: beam, incoming, resonant, outgoing. We drop particles with unknown, virtual or beam-remnant status. From this set we fill the common block. Event information such as process ID and weight is not transferred here; this has to be done by the caller. The spin information is set only if the particle has a unique mother, and if its polarization is fully defined. We use this routine also to hand over information to Pythia which lets Tauola access SPINUP. Tauola expects in SPINUP the helicity and not the LHA convention. We switch to this mode with [[tauola_convention]]. <>= public :: hepeup_from_particle_set <>= subroutine hepeup_from_particle_set (pset_in, & keep_beams, keep_remnants, tauola_convention) type(particle_set_t), intent(in) :: pset_in type(particle_set_t), target :: pset logical, intent(in), optional :: keep_beams logical, intent(in), optional :: keep_remnants logical, intent(in), optional :: tauola_convention integer :: i, n_parents, status, n_tot integer, dimension(1) :: i_mother logical :: kr, tc kr = .true.; if (present (keep_remnants)) kr = keep_remnants tc = .false.; if (present (tauola_convention)) tc = tauola_convention call pset_in%filter_particles (pset, real_parents = .true. , & keep_beams = keep_beams, keep_virtuals = .false.) n_tot = pset%get_n_tot () call hepeup_init (n_tot) do i = 1, n_tot associate (prt => pset%prt(i)) status = prt%get_status () if (kr .and. status == PRT_BEAM_REMNANT & .and. prt%get_n_children () == 0) & status = PRT_OUTGOING call hepeup_set_particle (i, & prt%get_pdg (), & status, & prt%get_parents (), & prt%get_color (), & prt%get_momentum (), & prt%get_p2 ()) n_parents = prt%get_n_parents () call hepeup_set_particle_lifetime (i, & prt%get_lifetime ()) if (.not. tc) then if (n_parents == 1) then i_mother = prt%get_parents () select case (prt%get_polarization_status ()) case (PRT_GENERIC_POLARIZATION) call hepeup_set_particle_spin (i, & prt%get_momentum (), & prt%get_polarization (), & pset%prt(i_mother(1))%get_momentum ()) end select end if else select case (prt%get_polarization_status ()) case (PRT_DEFINITE_HELICITY) SPINUP(i) = prt%get_helicity() end select end if end associate end do end subroutine hepeup_from_particle_set @ %def hepeup_from_particle_set @ Input. The particle set should be allocated properly, but we replace the particle contents. If there are no beam particles in the event, we try to reconstruct beam particles and beam remnants. We assume for simplicity that the beam particles, if any, are the first two particles. If they are absent, the first two particles should be the incoming partons. <>= public :: hepeup_to_particle_set <>= subroutine hepeup_to_particle_set & (particle_set, recover_beams, model, alt_model) type(particle_set_t), intent(inout), target :: particle_set logical, intent(in), optional :: recover_beams class(model_data_t), intent(in), target :: model, alt_model type(particle_t), dimension(:), allocatable :: prt integer, dimension(2) :: parent integer, dimension(:), allocatable :: child integer :: i, j, k, pdg, status type(flavor_t) :: flv type(color_t) :: col integer, dimension(2) :: c type(vector4_t) :: p real(default) :: p2 logical :: reconstruct integer :: off if (present (recover_beams)) then reconstruct = recover_beams .and. .not. all (ISTUP(1:2) == PRT_BEAM) else reconstruct = .false. end if if (reconstruct) then off = 4 else off = 0 end if allocate (prt (NUP + off), child (NUP + off)) do i = 1, NUP k = i + off call hepeup_get_particle (i, pdg, status, col = c, p = p, m2 = p2) call flv%init (pdg, model, alt_model) call prt(k)%set_flavor (flv) call prt(k)%reset_status (status) call col%init (c) call prt(k)%set_color (col) call prt(k)%set_momentum (p, p2) where (MOTHUP(:,i) /= 0) parent = MOTHUP(:,i) + off elsewhere parent = 0 end where call prt(k)%set_parents (parent) child = [(j, j = 1 + off, NUP + off)] where (MOTHUP(1,:NUP) /= i .and. MOTHUP(2,:NUP) /= i) child = 0 call prt(k)%set_children (child) end do if (reconstruct) then do k = 1, 2 call prt(k)%reset_status (PRT_BEAM) call prt(k)%set_children ([k+2,k+4]) end do do k = 3, 4 call prt(k)%reset_status (PRT_BEAM_REMNANT) call prt(k)%set_parents ([k-2]) end do do k = 5, 6 call prt(k)%set_parents ([k-4]) end do end if call particle_set%replace (prt) end subroutine hepeup_to_particle_set @ %def hepeup_to_particle_set @ The HEPEVT common block is quite similar, but does contain less information, e.g. no color flows (it was LEP time). The spin information is set only if the particle has a unique mother, and if its polarization is fully defined. <>= public :: hepevt_from_particle_set <>= subroutine hepevt_from_particle_set & (particle_set, keep_beams, keep_remnants, ensure_order, fill_hepev4) type(particle_set_t), intent(in) :: particle_set type(particle_set_t), target :: pset_hepevt, pset_tmp logical, intent(in), optional :: keep_beams logical, intent(in), optional :: keep_remnants logical, intent(in), optional :: ensure_order logical, intent(in), optional :: fill_hepev4 integer :: i, status, n_tot logical :: activate_remnants, ensure activate_remnants = .true. if (present (keep_remnants)) activate_remnants = keep_remnants ensure = .false. if (present (ensure_order)) ensure = ensure_order call particle_set%filter_particles (pset_tmp, real_parents = .true., & keep_virtuals = .false., keep_beams = keep_beams) if (ensure) then call pset_tmp%to_hepevt_form (pset_hepevt) else pset_hepevt = pset_tmp end if n_tot = pset_hepevt%get_n_tot () call hepevt_init (n_tot, pset_hepevt%get_n_out ()) do i = 1, n_tot associate (prt => pset_hepevt%prt(i)) status = prt%get_status () if (activate_remnants & .and. status == PRT_BEAM_REMNANT & .and. prt%get_n_children () == 0) & status = PRT_OUTGOING select case (prt%get_polarization_status ()) case (PRT_GENERIC_POLARIZATION) call hepevt_set_particle (i, & prt%get_pdg (), status, & prt%get_parents (), & prt%get_children (), & prt%get_momentum (), & prt%get_p2 (), & prt%get_helicity (), & prt%get_vertex (), & prt%get_color (), & prt%get_polarization_status (), & pol = prt%get_polarization (), & fill_hepev4 = fill_hepev4) case default call hepevt_set_particle (i, & prt%get_pdg (), status, & prt%get_parents (), & prt%get_children (), & prt%get_momentum (), & prt%get_p2 (), & prt%get_helicity (), & prt%get_vertex (), & prt%get_color (), & prt%get_polarization_status (), & fill_hepev4 = fill_hepev4) end select end associate end do call pset_hepevt%final () end subroutine hepevt_from_particle_set @ %def hepevt_from_particle_set @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{HepMC events} This section provides the interface to the HepMC C++ library for handling Monte-Carlo events. Each C++ class of HepMC that we use is mirrored by a Fortran type, which contains as its only component the C pointer to the C++ object. Each C++ method of HepMC that we use has a C wrapper function. This function takes a pointer to the host object as its first argument. Further arguments are either C pointers, or in the case of simple types (integer, real), interoperable C/Fortran objects. The C wrapper functions have explicit interfaces in the Fortran module. They are called by Fortran wrapper procedures. These are treated as methods of the corresponding Fortran type. <<[[hepmc_interface.f90]]>>= <> module hepmc_interface use, intrinsic :: iso_c_binding !NODEP! <> <> use constants, only: PI use physics_defs, only: pb_per_fb use system_dependencies, only: HEPMC2_AVAILABLE use system_dependencies, only: HEPMC3_AVAILABLE use diagnostics use lorentz use flavors use colors use helicities use polarizations + use event_handles, only: event_handle_t <> <> <> <> <> contains <> end module hepmc_interface @ %def hepmc_interface @ \subsection{Interface check} This function can be called in order to verify that we are using the actual HepMC library, and not the dummy version. <>= interface logical(c_bool) function hepmc_available () bind(C) import end function hepmc_available end interface <>= public :: hepmc_is_available <>= function hepmc_is_available () result (flag) logical :: flag flag = hepmc_available () end function hepmc_is_available @ %def hepmc_is_available @ \subsection{FourVector} The C version of four-vectors is often transferred by value, and the associated procedures are all inlined. The wrapper needs to transfer by reference, so we create FourVector objects on the heap which have to be deleted explicitly. The input is a [[vector4_t]] or [[vector3_t]] object from the [[lorentz]] module. <>= public :: hepmc_four_vector_t <>= type :: hepmc_four_vector_t private type(c_ptr) :: obj end type hepmc_four_vector_t @ %def hepmc_four_vector_t @ In the C constructor, the zero-component (fourth argument) is optional; if missing, it is set to zero. The Fortran version has initializer form and takes either a three-vector or a four-vector. A further version extracts the four-vector from a HepMC particle object. <>= interface type(c_ptr) function new_four_vector_xyz (x, y, z) bind(C) import real(c_double), value :: x, y, z end function new_four_vector_xyz end interface interface type(c_ptr) function new_four_vector_xyzt (x, y, z, t) bind(C) import real(c_double), value :: x, y, z, t end function new_four_vector_xyzt end interface @ %def new_four_vector_xyz new_four_vector_xyzt <>= public :: hepmc_four_vector_init <>= interface hepmc_four_vector_init module procedure hepmc_four_vector_init_v4 module procedure hepmc_four_vector_init_v3 module procedure hepmc_four_vector_init_hepmc_prt end interface <>= subroutine hepmc_four_vector_init_v4 (pp, p) type(hepmc_four_vector_t), intent(out) :: pp type(vector4_t), intent(in) :: p real(default), dimension(0:3) :: pa pa = vector4_get_components (p) pp%obj = new_four_vector_xyzt & (real (pa(1), c_double), & real (pa(2), c_double), & real (pa(3), c_double), & real (pa(0), c_double)) end subroutine hepmc_four_vector_init_v4 subroutine hepmc_four_vector_init_v3 (pp, p) type(hepmc_four_vector_t), intent(out) :: pp type(vector3_t), intent(in) :: p real(default), dimension(3) :: pa pa = vector3_get_components (p) pp%obj = new_four_vector_xyz & (real (pa(1), c_double), & real (pa(2), c_double), & real (pa(3), c_double)) end subroutine hepmc_four_vector_init_v3 subroutine hepmc_four_vector_init_hepmc_prt (pp, prt) type(hepmc_four_vector_t), intent(out) :: pp type(hepmc_particle_t), intent(in) :: prt pp%obj = gen_particle_momentum (prt%obj) end subroutine hepmc_four_vector_init_hepmc_prt @ %def hepmc_four_vector_init @ Here, the destructor is explicitly needed. <>= interface subroutine four_vector_delete (p_obj) bind(C) import type(c_ptr), value :: p_obj end subroutine four_vector_delete end interface @ %def four_vector_delete <>= public :: hepmc_four_vector_final <>= subroutine hepmc_four_vector_final (p) type(hepmc_four_vector_t), intent(inout) :: p call four_vector_delete (p%obj) end subroutine hepmc_four_vector_final @ %def hepmc_four_vector_final @ Convert to a Lorentz vector. <>= interface function four_vector_px (p_obj) result (px) bind(C) import real(c_double) :: px type(c_ptr), value :: p_obj end function four_vector_px end interface interface function four_vector_py (p_obj) result (py) bind(C) import real(c_double) :: py type(c_ptr), value :: p_obj end function four_vector_py end interface interface function four_vector_pz (p_obj) result (pz) bind(C) import real(c_double) :: pz type(c_ptr), value :: p_obj end function four_vector_pz end interface interface function four_vector_e (p_obj) result (e) bind(C) import real(c_double) :: e type(c_ptr), value :: p_obj end function four_vector_e end interface @ %def four_vector_px four_vector_py four_vector_pz four_vector_e <>= public :: hepmc_four_vector_to_vector4 <>= subroutine hepmc_four_vector_to_vector4 (pp, p) type(hepmc_four_vector_t), intent(in) :: pp type(vector4_t), intent(out) :: p real(default) :: E real(default), dimension(3) :: p3 E = four_vector_e (pp%obj) p3(1) = four_vector_px (pp%obj) p3(2) = four_vector_py (pp%obj) p3(3) = four_vector_pz (pp%obj) p = vector4_moving (E, vector3_moving (p3)) end subroutine hepmc_four_vector_to_vector4 @ %def hepmc_four_vector_to_vector4 @ \subsection{Polarization} Polarization objects are temporarily used for assigning particle polarization. We add a flag [[polarized]]. If this is false, the polarization is not set and should not be transferred to [[hepmc_particle]] objects. <>= public :: hepmc_polarization_t <>= type :: hepmc_polarization_t private logical :: polarized = .false. type(c_ptr) :: obj end type hepmc_polarization_t @ %def hepmc_polarization_t @ Constructor. The C wrapper takes polar and azimuthal angle as arguments. The Fortran version allows for either a complete polarization density matrix, or for a definite (diagonal) helicity. \emph{HepMC does not allow to specify the degree of polarization, therefore we have to map it to either 0 or 1. We choose 0 for polarization less than $0.5$ and 1 for polarization greater than $0.5$. Even this simplification works only for spin-1/2 and for massless particles; massive vector bosons cannot be treated this way. In particular, zero helicity is always translated as unpolarized.} \emph{For massive vector bosons, we arbitrarily choose the convention that the longitudinal (zero) helicity state is mapped to the theta angle $\pi/2$. This works under the condition that helicity is projected onto one of the basis states.} <>= interface type(c_ptr) function new_polarization (theta, phi) bind(C) import real(c_double), value :: theta, phi end function new_polarization end interface @ %def new_polarization <>= public :: hepmc_polarization_init <>= interface hepmc_polarization_init module procedure hepmc_polarization_init_pol module procedure hepmc_polarization_init_hel module procedure hepmc_polarization_init_int end interface <>= subroutine hepmc_polarization_init_pol (hpol, pol) type(hepmc_polarization_t), intent(out) :: hpol type(polarization_t), intent(in) :: pol real(default) :: r, theta, phi if (pol%is_polarized ()) then call pol%to_angles (r, theta, phi) if (r >= 0.5) then hpol%polarized = .true. hpol%obj = new_polarization & (real (theta, c_double), real (phi, c_double)) end if end if end subroutine hepmc_polarization_init_pol subroutine hepmc_polarization_init_hel (hpol, hel) type(hepmc_polarization_t), intent(out) :: hpol type(helicity_t), intent(in) :: hel integer, dimension(2) :: h if (hel%is_defined ()) then h = hel%to_pair () select case (h(1)) case (1:) hpol%polarized = .true. hpol%obj = new_polarization (0._c_double, 0._c_double) case (:-1) hpol%polarized = .true. hpol%obj = new_polarization (real (pi, c_double), 0._c_double) case (0) hpol%polarized = .true. hpol%obj = new_polarization (real (pi/2, c_double), 0._c_double) end select end if end subroutine hepmc_polarization_init_hel subroutine hepmc_polarization_init_int (hpol, hel) type(hepmc_polarization_t), intent(out) :: hpol integer, intent(in) :: hel select case (hel) case (1:) hpol%polarized = .true. hpol%obj = new_polarization (0._c_double, 0._c_double) case (:-1) hpol%polarized = .true. hpol%obj = new_polarization (real (pi, c_double), 0._c_double) case (0) hpol%polarized = .true. hpol%obj = new_polarization (real (pi/2, c_double), 0._c_double) end select end subroutine hepmc_polarization_init_int @ %def hepmc_polarization_init @ Destructor. The C object is deallocated only if the [[polarized]] flag is set. <>= interface subroutine polarization_delete (pol_obj) bind(C) import type(c_ptr), value :: pol_obj end subroutine polarization_delete end interface @ %def polarization_delete <>= public :: hepmc_polarization_final <>= subroutine hepmc_polarization_final (hpol) type(hepmc_polarization_t), intent(inout) :: hpol if (hpol%polarized) call polarization_delete (hpol%obj) end subroutine hepmc_polarization_final @ %def hepmc_polarization_final @ Recover polarization from HepMC polarization object (with the abovementioned deficiencies). <>= interface function polarization_theta (pol_obj) result (theta) bind(C) import real(c_double) :: theta type(c_ptr), value :: pol_obj end function polarization_theta end interface interface function polarization_phi (pol_obj) result (phi) bind(C) import real(c_double) :: phi type(c_ptr), value :: pol_obj end function polarization_phi end interface @ %def polarization_theta polarization_phi <>= public :: hepmc_polarization_to_pol <>= subroutine hepmc_polarization_to_pol (hpol, flv, pol) type(hepmc_polarization_t), intent(in) :: hpol type(flavor_t), intent(in) :: flv type(polarization_t), intent(out) :: pol real(default) :: theta, phi theta = polarization_theta (hpol%obj) phi = polarization_phi (hpol%obj) call pol%init_angles (flv, 1._default, theta, phi) end subroutine hepmc_polarization_to_pol @ %def hepmc_polarization_to_pol @ Recover helicity. Here, $\phi$ is ignored and only the sign of $\cos\theta$ is relevant, mapped to positive/negative helicity. <>= public :: hepmc_polarization_to_hel <>= subroutine hepmc_polarization_to_hel (hpol, flv, hel) type(hepmc_polarization_t), intent(in) :: hpol type(flavor_t), intent(in) :: flv type(helicity_t), intent(out) :: hel real(default) :: theta integer :: hmax theta = polarization_theta (hpol%obj) hmax = flv%get_spin_type () / 2 call hel%init (sign (hmax, nint (cos (theta)))) end subroutine hepmc_polarization_to_hel @ %def hepmc_polarization_to_hel @ \subsection{GenParticle} Particle objects have the obvious meaning. <>= public :: hepmc_particle_t <>= type :: hepmc_particle_t private type(c_ptr) :: obj end type hepmc_particle_t @ %def hepmc_particle_t @ Constructor. The C version takes a FourVector object, which in the Fortran wrapper is created on the fly from a [[vector4]] Lorentz vector. No destructor is needed as long as all particles are entered into vertex containers. <>= interface type(c_ptr) function new_gen_particle (prt_obj, pdg_id, status) bind(C) import type(c_ptr), value :: prt_obj integer(c_int), value :: pdg_id, status end function new_gen_particle end interface @ %def new_gen_particle <>= public :: hepmc_particle_init <>= subroutine hepmc_particle_init (prt, p, pdg, status) type(hepmc_particle_t), intent(out) :: prt type(vector4_t), intent(in) :: p integer, intent(in) :: pdg, status type(hepmc_four_vector_t) :: pp call hepmc_four_vector_init (pp, p) prt%obj = new_gen_particle (pp%obj, int (pdg, c_int), int (status, c_int)) call hepmc_four_vector_final (pp) end subroutine hepmc_particle_init @ %def hepmc_particle_init @ Set the particle color flow. <>= interface subroutine gen_particle_set_flow (prt_obj, code_index, code) bind(C) import type(c_ptr), value :: prt_obj integer(c_int), value :: code_index, code end subroutine gen_particle_set_flow end interface @ %def gen_particle_set_flow @ Set the particle color. Either from a [[color_t]] object or directly from a pair of integers. <>= interface hepmc_particle_set_color module procedure hepmc_particle_set_color_col module procedure hepmc_particle_set_color_int end interface hepmc_particle_set_color <>= public :: hepmc_particle_set_color <>= subroutine hepmc_particle_set_color_col (prt, col) type(hepmc_particle_t), intent(inout) :: prt type(color_t), intent(in) :: col integer(c_int) :: c c = col%get_col () if (c /= 0) call gen_particle_set_flow (prt%obj, 1_c_int, c) c = col%get_acl () if (c /= 0) call gen_particle_set_flow (prt%obj, 2_c_int, c) end subroutine hepmc_particle_set_color_col subroutine hepmc_particle_set_color_int (prt, col) type(hepmc_particle_t), intent(inout) :: prt integer, dimension(2), intent(in) :: col integer(c_int) :: c c = col(1) if (c /= 0) call gen_particle_set_flow (prt%obj, 1_c_int, c) c = col(2) if (c /= 0) call gen_particle_set_flow (prt%obj, 2_c_int, c) end subroutine hepmc_particle_set_color_int @ %def hepmc_particle_set_color @ Set the particle polarization. For the restrictions on particle polarization in HepMC, see above [[hepmc_polarization_init]]. <>= interface subroutine gen_particle_set_polarization (prt_obj, pol_obj) bind(C) import type(c_ptr), value :: prt_obj, pol_obj end subroutine gen_particle_set_polarization end interface @ %def gen_particle_set_polarization <>= public :: hepmc_particle_set_polarization <>= interface hepmc_particle_set_polarization module procedure hepmc_particle_set_polarization_pol module procedure hepmc_particle_set_polarization_hel module procedure hepmc_particle_set_polarization_int end interface <>= subroutine hepmc_particle_set_polarization_pol (prt, pol) type(hepmc_particle_t), intent(inout) :: prt type(polarization_t), intent(in) :: pol type(hepmc_polarization_t) :: hpol call hepmc_polarization_init (hpol, pol) if (hpol%polarized) call gen_particle_set_polarization (prt%obj, hpol%obj) call hepmc_polarization_final (hpol) end subroutine hepmc_particle_set_polarization_pol subroutine hepmc_particle_set_polarization_hel (prt, hel) type(hepmc_particle_t), intent(inout) :: prt type(helicity_t), intent(in) :: hel type(hepmc_polarization_t) :: hpol call hepmc_polarization_init (hpol, hel) if (hpol%polarized) call gen_particle_set_polarization (prt%obj, hpol%obj) call hepmc_polarization_final (hpol) end subroutine hepmc_particle_set_polarization_hel subroutine hepmc_particle_set_polarization_int (prt, hel) type(hepmc_particle_t), intent(inout) :: prt integer, intent(in) :: hel type(hepmc_polarization_t) :: hpol call hepmc_polarization_init (hpol, hel) if (hpol%polarized) call gen_particle_set_polarization (prt%obj, hpol%obj) call hepmc_polarization_final (hpol) end subroutine hepmc_particle_set_polarization_int @ %def hepmc_particle_set_polarization @ Return the HepMC barcode (unique integer ID) of the particle. <>= interface function gen_particle_barcode (prt_obj) result (barcode) bind(C) import integer(c_int) :: barcode type(c_ptr), value :: prt_obj end function gen_particle_barcode end interface @ %def gen_particle_barcode <>= public :: hepmc_particle_get_barcode <>= function hepmc_particle_get_barcode (prt) result (barcode) integer :: barcode type(hepmc_particle_t), intent(in) :: prt barcode = gen_particle_barcode (prt%obj) end function hepmc_particle_get_barcode @ %def hepmc_particle_get_barcode @ Return the four-vector component of the particle object as a [[vector4_t]] Lorentz vector. <>= interface type(c_ptr) function gen_particle_momentum (prt_obj) bind(C) import type(c_ptr), value :: prt_obj end function gen_particle_momentum end interface @ %def gen_particle_momentum <>= public :: hepmc_particle_get_momentum <>= function hepmc_particle_get_momentum (prt) result (p) type(vector4_t) :: p type(hepmc_particle_t), intent(in) :: prt type(hepmc_four_vector_t) :: pp call hepmc_four_vector_init (pp, prt) call hepmc_four_vector_to_vector4 (pp, p) call hepmc_four_vector_final (pp) end function hepmc_particle_get_momentum @ %def hepmc_particle_get_momentum @ Return the invariant mass squared of the particle object. HepMC stores the signed invariant mass (no squaring). <>= interface function gen_particle_generated_mass (prt_obj) result (mass) bind(C) import real(c_double) :: mass type(c_ptr), value :: prt_obj end function gen_particle_generated_mass end interface @ %def gen_particle_generated_mass <>= public :: hepmc_particle_get_mass_squared <>= function hepmc_particle_get_mass_squared (prt) result (m2) real(default) :: m2 type(hepmc_particle_t), intent(in) :: prt real(default) :: m m = gen_particle_generated_mass (prt%obj) m2 = sign (m**2, m) end function hepmc_particle_get_mass_squared @ %def hepmc_particle_get_mass_squared @ Return the PDG ID: <>= interface function gen_particle_pdg_id (prt_obj) result (pdg_id) bind(C) import integer(c_int) :: pdg_id type(c_ptr), value :: prt_obj end function gen_particle_pdg_id end interface @ %def gen_particle_pdg_id <>= public :: hepmc_particle_get_pdg <>= function hepmc_particle_get_pdg (prt) result (pdg) integer :: pdg type(hepmc_particle_t), intent(in) :: prt pdg = gen_particle_pdg_id (prt%obj) end function hepmc_particle_get_pdg @ %def hepmc_particle_get_pdg @ Return the status code: <>= interface function gen_particle_status (prt_obj) result (status) bind(C) import integer(c_int) :: status type(c_ptr), value :: prt_obj end function gen_particle_status end interface @ %def gen_particle_status <>= public :: hepmc_particle_get_status <>= function hepmc_particle_get_status (prt) result (status) integer :: status type(hepmc_particle_t), intent(in) :: prt status = gen_particle_status (prt%obj) end function hepmc_particle_get_status @ %def hepmc_particle_get_status <>= interface function gen_particle_is_beam (prt_obj) result (is_beam) bind(C) import logical(c_bool) :: is_beam type(c_ptr), value :: prt_obj end function gen_particle_is_beam end interface @ %def gen_particle_is_beam @ Determine whether a particle is a beam particle. <>= public :: hepmc_particle_is_beam <>= function hepmc_particle_is_beam (prt) result (is_beam) logical :: is_beam type(hepmc_particle_t), intent(in) :: prt is_beam = gen_particle_is_beam (prt%obj) end function hepmc_particle_is_beam @ %def hepmc_particle_is_beam @ Return the production/decay vertex (as a pointer, no finalization necessary). <>= interface type(c_ptr) function gen_particle_production_vertex (prt_obj) bind(C) import type(c_ptr), value :: prt_obj end function gen_particle_production_vertex end interface interface type(c_ptr) function gen_particle_end_vertex (prt_obj) bind(C) import type(c_ptr), value :: prt_obj end function gen_particle_end_vertex end interface @ %def gen_particle_production_vertex gen_particle_end_vertex <>= public :: hepmc_particle_get_production_vertex public :: hepmc_particle_get_decay_vertex <>= function hepmc_particle_get_production_vertex (prt) result (v) type(hepmc_vertex_t) :: v type(hepmc_particle_t), intent(in) :: prt v%obj = gen_particle_production_vertex (prt%obj) end function hepmc_particle_get_production_vertex function hepmc_particle_get_decay_vertex (prt) result (v) type(hepmc_vertex_t) :: v type(hepmc_particle_t), intent(in) :: prt v%obj = gen_particle_end_vertex (prt%obj) end function hepmc_particle_get_decay_vertex @ %def hepmc_particle_get_production_vertex hepmc_particle_get_decay_vertex @ Convenience function: Return the array of parent particles for a given HepMC particle. The contents are HepMC barcodes that still have to be mapped to the particle indices. <>= public :: hepmc_particle_get_parent_barcodes public :: hepmc_particle_get_child_barcodes <>= function hepmc_particle_get_parent_barcodes (prt) result (parent_barcode) type(hepmc_particle_t), intent(in) :: prt integer, dimension(:), allocatable :: parent_barcode type(hepmc_vertex_t) :: v type(hepmc_vertex_particle_in_iterator_t) :: it integer :: i v = hepmc_particle_get_production_vertex (prt) if (hepmc_vertex_is_valid (v)) then allocate (parent_barcode (hepmc_vertex_get_n_in (v))) if (size (parent_barcode) /= 0) then if (HEPMC2_AVAILABLE) then call hepmc_vertex_particle_in_iterator_init (it, v) do i = 1, size (parent_barcode) parent_barcode(i) = hepmc_particle_get_barcode & (hepmc_vertex_particle_in_iterator_get (it)) call hepmc_vertex_particle_in_iterator_advance (it) end do call hepmc_vertex_particle_in_iterator_final (it) else if (HEPMC3_AVAILABLE) then do i = 1, size (parent_barcode) parent_barcode(i) = hepmc_particle_get_barcode & (hepmc_vertex_get_nth_particle_in (v, i)) end do end if end if else allocate (parent_barcode (0)) end if end function hepmc_particle_get_parent_barcodes function hepmc_particle_get_child_barcodes (prt) result (child_barcode) type(hepmc_particle_t), intent(in) :: prt integer, dimension(:), allocatable :: child_barcode type(hepmc_vertex_t) :: v type(hepmc_vertex_particle_out_iterator_t) :: it integer :: i v = hepmc_particle_get_decay_vertex (prt) if (hepmc_vertex_is_valid (v)) then allocate (child_barcode (hepmc_vertex_get_n_out (v))) if (size (child_barcode) /= 0) then if (HEPMC2_AVAILABLE) then call hepmc_vertex_particle_out_iterator_init (it, v) do i = 1, size (child_barcode) child_barcode(i) = hepmc_particle_get_barcode & (hepmc_vertex_particle_out_iterator_get (it)) call hepmc_vertex_particle_out_iterator_advance (it) end do call hepmc_vertex_particle_out_iterator_final (it) else if (HEPMC3_AVAILABLE) then do i = 1, size (child_barcode) child_barcode(i) = hepmc_particle_get_barcode & (hepmc_vertex_get_nth_particle_out (v, i)) end do end if end if else allocate (child_barcode (0)) end if end function hepmc_particle_get_child_barcodes @ %def hepmc_particle_get_parent_barcodes hepmc_particle_get_child_barcodes @ Return the polarization (assuming that the particle is completely polarized). Note that the generated polarization object needs finalization. <>= interface type(c_ptr) function gen_particle_polarization (prt_obj) bind(C) import type(c_ptr), value :: prt_obj end function gen_particle_polarization end interface @ %def gen_particle_polarization <>= public :: hepmc_particle_get_polarization <>= function hepmc_particle_get_polarization (prt) result (pol) type(hepmc_polarization_t) :: pol type(hepmc_particle_t), intent(in) :: prt pol%obj = gen_particle_polarization (prt%obj) end function hepmc_particle_get_polarization @ %def hepmc_particle_get_polarization @ Return the particle color as a two-dimensional array (color, anticolor). <>= interface function gen_particle_flow (prt_obj, code_index) result (code) bind(C) import integer(c_int) :: code type(c_ptr), value :: prt_obj integer(c_int), value :: code_index end function gen_particle_flow end interface @ %def gen_particle_flow <>= public :: hepmc_particle_get_color <>= function hepmc_particle_get_color (prt) result (col) integer, dimension(2) :: col type(hepmc_particle_t), intent(in) :: prt col(1) = gen_particle_flow (prt%obj, 1) col(2) = - gen_particle_flow (prt%obj, 2) end function hepmc_particle_get_color @ %def hepmc_particle_get_color @ <>= interface function gen_vertex_pos_x (v_obj) result (x) bind(C) import type(c_ptr), value :: v_obj real(c_double) :: x end function gen_vertex_pos_x end interface interface function gen_vertex_pos_y (v_obj) result (y) bind(C) import type(c_ptr), value :: v_obj real(c_double) :: y end function gen_vertex_pos_y end interface interface function gen_vertex_pos_z (v_obj) result (z) bind(C) import type(c_ptr), value :: v_obj real(c_double) :: z end function gen_vertex_pos_z end interface interface function gen_vertex_time (v_obj) result (t) bind(C) import type(c_ptr), value :: v_obj real(c_double) :: t end function gen_vertex_time end interface @ <>= public :: hepmc_vertex_to_vertex <>= function hepmc_vertex_to_vertex (vtx) result (v) type(hepmc_vertex_t), intent(in) :: vtx type(vector4_t) :: v real(default) :: t, vx, vy, vz if (hepmc_vertex_is_valid (vtx)) then t = gen_vertex_time (vtx%obj) vx = gen_vertex_pos_x (vtx%obj) vy = gen_vertex_pos_y (vtx%obj) vz = gen_vertex_pos_z (vtx%obj) v = vector4_moving (t, & vector3_moving ([vx, vy, vz])) end if end function hepmc_vertex_to_vertex @ %def hepmc_vertex_to_vertex @ \subsection{GenVertex} Vertices are made of particles (incoming and outgoing). <>= public :: hepmc_vertex_t <>= type :: hepmc_vertex_t private type(c_ptr) :: obj end type hepmc_vertex_t @ %def hepmc_vertex_t @ Constructor. Two versions, one plain, one with the position in space and time (measured in mm) as argument. The Fortran version has initializer form, and the vertex position is an optional argument. A destructor is unnecessary as long as all vertices are entered into an event container. <>= interface type(c_ptr) function new_gen_vertex () bind(C) import end function new_gen_vertex end interface interface type(c_ptr) function new_gen_vertex_pos (prt_obj) bind(C) import type(c_ptr), value :: prt_obj end function new_gen_vertex_pos end interface @ %def new_gen_vertex new_gen_vertex_pos <>= public :: hepmc_vertex_init <>= subroutine hepmc_vertex_init (v, x) type(hepmc_vertex_t), intent(out) :: v type(vector4_t), intent(in), optional :: x type(hepmc_four_vector_t) :: pos if (present (x)) then call hepmc_four_vector_init (pos, x) v%obj = new_gen_vertex_pos (pos%obj) call hepmc_four_vector_final (pos) else v%obj = new_gen_vertex () end if end subroutine hepmc_vertex_init @ %def hepmc_vertex_init @ Return true if the vertex pointer is non-null: <>= interface function gen_vertex_is_valid (v_obj) result (flag) bind(C) import logical(c_bool) :: flag type(c_ptr), value :: v_obj end function gen_vertex_is_valid end interface @ %def gen_vertex_is_valid <>= public :: hepmc_vertex_is_valid <>= function hepmc_vertex_is_valid (v) result (flag) logical :: flag type(hepmc_vertex_t), intent(in) :: v flag = gen_vertex_is_valid (v%obj) end function hepmc_vertex_is_valid @ %def hepmc_vertex_is_valid @ Add a particle to a vertex, incoming or outgoing. <>= interface subroutine gen_vertex_add_particle_in (v_obj, prt_obj) bind(C) import type(c_ptr), value :: v_obj, prt_obj end subroutine gen_vertex_add_particle_in end interface interface subroutine gen_vertex_add_particle_out (v_obj, prt_obj) bind(C) import type(c_ptr), value :: v_obj, prt_obj end subroutine gen_vertex_add_particle_out end interface <>= public :: hepmc_vertex_add_particle_in public :: hepmc_vertex_add_particle_out @ %def gen_vertex_add_particle_in gen_vertex_add_particle_out <>= subroutine hepmc_vertex_add_particle_in (v, prt) type(hepmc_vertex_t), intent(inout) :: v type(hepmc_particle_t), intent(in) :: prt call gen_vertex_add_particle_in (v%obj, prt%obj) end subroutine hepmc_vertex_add_particle_in subroutine hepmc_vertex_add_particle_out (v, prt) type(hepmc_vertex_t), intent(inout) :: v type(hepmc_particle_t), intent(in) :: prt call gen_vertex_add_particle_out (v%obj, prt%obj) end subroutine hepmc_vertex_add_particle_out @ %def hepmc_vertex_add_particle_in hepmc_vertex_add_particle_out @ Return the number of incoming/outgoing particles. <>= interface function gen_vertex_particles_in_size (v_obj) result (size) bind(C) import integer(c_int) :: size type(c_ptr), value :: v_obj end function gen_vertex_particles_in_size end interface interface function gen_vertex_particles_out_size (v_obj) result (size) bind(C) import integer(c_int) :: size type(c_ptr), value :: v_obj end function gen_vertex_particles_out_size end interface interface function gen_particle_get_n_parents (p_obj) result (size) bind(C) import integer(c_int) :: size type(c_ptr), value :: p_obj end function gen_particle_get_n_parents end interface interface function gen_particle_get_n_children (p_obj) result (size) bind(C) import integer(c_int) :: size type(c_ptr), value :: p_obj end function gen_particle_get_n_children end interface @ %def gen_vertex_particles_in_size gen_vertex_particles_out_size @ %def gen_particle_get_n_parents get_particle_get_n_children <>= public :: hepmc_vertex_get_n_in public :: hepmc_vertex_get_n_out public :: hepmc_particle_get_parents public :: hepmc_particle_get_children <>= function hepmc_vertex_get_n_in (v) result (n_in) integer :: n_in type(hepmc_vertex_t), intent(in) :: v n_in = gen_vertex_particles_in_size (v%obj) end function hepmc_vertex_get_n_in function hepmc_vertex_get_n_out (v) result (n_out) integer :: n_out type(hepmc_vertex_t), intent(in) :: v n_out = gen_vertex_particles_out_size (v%obj) end function hepmc_vertex_get_n_out function hepmc_particle_get_parents (p) result (n_p) integer :: n_p type(hepmc_particle_t), intent(in) :: p n_p = gen_particle_get_n_parents (p%obj) end function hepmc_particle_get_parents function hepmc_particle_get_children (p) result (n_ch) integer :: n_ch type(hepmc_particle_t), intent(in) :: p n_ch = gen_particle_get_n_children (p%obj) end function hepmc_particle_get_children @ %def hepmc_vertex_n_in hepmc_vertex_n_out @ %def hepmc_particle_get_parents hepmc_particle_get_children @ Return the number of parents/children. <>= public :: hepmc_particle_get_n_parents public :: hepmc_particle_get_n_children <>= function hepmc_particle_get_n_parents (prt) result (n_parents) integer :: n_parents type(hepmc_particle_t), intent(in) :: prt type(hepmc_vertex_t) :: v if (HEPMC2_AVAILABLE) then v = hepmc_particle_get_production_vertex (prt) if (hepmc_vertex_is_valid (v)) then n_parents = hepmc_vertex_get_n_in (v) else n_parents = 0 end if else if (HEPMC3_AVAILABLE) then n_parents = hepmc_particle_get_parents (prt) end if end function hepmc_particle_get_n_parents function hepmc_particle_get_n_children (prt) result (n_children) integer :: n_children type(hepmc_particle_t), intent(in) :: prt type(hepmc_vertex_t) :: v if (HEPMC2_AVAILABLE) then v = hepmc_particle_get_decay_vertex (prt) if (hepmc_vertex_is_valid (v)) then n_children = hepmc_vertex_get_n_out (v) else n_children = 0 end if else if (HEPMC3_AVAILABLE) then n_children = hepmc_particle_get_children (prt) end if end function hepmc_particle_get_n_children @ %def hepmc_particle_get_n_parents @ %def hepmc_particle_get_n_children \subsection{Vertex-particle-in iterator} This iterator iterates over all incoming particles in an vertex. We store a pointer to the vertex in addition to the iterator. This allows for simple end checking. The iterator is actually a constant iterator; it can only read. <>= public :: hepmc_vertex_particle_in_iterator_t <>= type :: hepmc_vertex_particle_in_iterator_t private type(c_ptr) :: obj type(c_ptr) :: v_obj end type hepmc_vertex_particle_in_iterator_t @ %def hepmc_vertex_particle_in_iterator_t @ Constructor. The iterator is initialized at the first particle in the vertex. <>= interface type(c_ptr) function & new_vertex_particles_in_const_iterator (v_obj) bind(C) import type(c_ptr), value :: v_obj end function new_vertex_particles_in_const_iterator end interface @ %def new_vertex_particles_in_const_iterator <>= public :: hepmc_vertex_particle_in_iterator_init <>= subroutine hepmc_vertex_particle_in_iterator_init (it, v) type(hepmc_vertex_particle_in_iterator_t), intent(out) :: it type(hepmc_vertex_t), intent(in) :: v it%obj = new_vertex_particles_in_const_iterator (v%obj) it%v_obj = v%obj end subroutine hepmc_vertex_particle_in_iterator_init @ %def hepmc_vertex_particle_in_iterator_init @ Destructor. Necessary because the iterator is allocated on the heap. <>= interface subroutine vertex_particles_in_const_iterator_delete (it_obj) bind(C) import type(c_ptr), value :: it_obj end subroutine vertex_particles_in_const_iterator_delete end interface @ %def vertex_particles_in_const_iterator_delete <>= public :: hepmc_vertex_particle_in_iterator_final <>= subroutine hepmc_vertex_particle_in_iterator_final (it) type(hepmc_vertex_particle_in_iterator_t), intent(inout) :: it call vertex_particles_in_const_iterator_delete (it%obj) end subroutine hepmc_vertex_particle_in_iterator_final @ %def hepmc_vertex_particle_in_iterator_final @ Increment <>= interface subroutine vertex_particles_in_const_iterator_advance (it_obj) bind(C) import type(c_ptr), value :: it_obj end subroutine vertex_particles_in_const_iterator_advance end interface @ %def vertex_particles_in_const_iterator_advance <>= public :: hepmc_vertex_particle_in_iterator_advance <>= subroutine hepmc_vertex_particle_in_iterator_advance (it) type(hepmc_vertex_particle_in_iterator_t), intent(inout) :: it call vertex_particles_in_const_iterator_advance (it%obj) end subroutine hepmc_vertex_particle_in_iterator_advance @ %def hepmc_vertex_particle_in_iterator_advance @ Reset to the beginning <>= interface subroutine vertex_particles_in_const_iterator_reset & (it_obj, v_obj) bind(C) import type(c_ptr), value :: it_obj, v_obj end subroutine vertex_particles_in_const_iterator_reset end interface @ %def vertex_particles_in_const_iterator_reset <>= public :: hepmc_vertex_particle_in_iterator_reset <>= subroutine hepmc_vertex_particle_in_iterator_reset (it) type(hepmc_vertex_particle_in_iterator_t), intent(inout) :: it call vertex_particles_in_const_iterator_reset (it%obj, it%v_obj) end subroutine hepmc_vertex_particle_in_iterator_reset @ %def hepmc_vertex_particle_in_iterator_reset @ Test: return true as long as we are not past the end. <>= interface function vertex_particles_in_const_iterator_is_valid & (it_obj, v_obj) result (flag) bind(C) import logical(c_bool) :: flag type(c_ptr), value :: it_obj, v_obj end function vertex_particles_in_const_iterator_is_valid end interface @ %def vertex_particles_in_const_iterator_is_valid <>= public :: hepmc_vertex_particle_in_iterator_is_valid <>= function hepmc_vertex_particle_in_iterator_is_valid (it) result (flag) logical :: flag type(hepmc_vertex_particle_in_iterator_t), intent(in) :: it flag = vertex_particles_in_const_iterator_is_valid (it%obj, it%v_obj) end function hepmc_vertex_particle_in_iterator_is_valid @ %def hepmc_vertex_particle_in_iterator_is_valid @ Return the particle pointed to by the iterator. (The particle object should not be finalized, since it contains merely a pointer to the particle which is owned by the vertex.) <>= interface type(c_ptr) function & vertex_particles_in_const_iterator_get (it_obj) bind(C) import type(c_ptr), value :: it_obj end function vertex_particles_in_const_iterator_get end interface @ %def vertex_particles_in_const_iterator_get <>= public :: hepmc_vertex_particle_in_iterator_get <>= function hepmc_vertex_particle_in_iterator_get (it) result (prt) type(hepmc_particle_t) :: prt type(hepmc_vertex_particle_in_iterator_t), intent(in) :: it prt%obj = vertex_particles_in_const_iterator_get (it%obj) end function hepmc_vertex_particle_in_iterator_get @ %def hepmc_vertex_particle_in_iterator_get @ <>= interface type(c_ptr) function vertex_get_nth_particle_in (vtx_obj, n) bind(C) import type(c_ptr), value :: vtx_obj integer(c_int), value :: n end function vertex_get_nth_particle_in end interface interface type(c_ptr) function vertex_get_nth_particle_out (vtx_obj, n) bind(C) import type(c_ptr), value :: vtx_obj integer(c_int), value :: n end function vertex_get_nth_particle_out end interface @ %def vertex_get_nth_particle_in <>= public :: hepmc_vertex_get_nth_particle_in public :: hepmc_vertex_get_nth_particle_out <>= function hepmc_vertex_get_nth_particle_in (vtx, n) result (prt) type(hepmc_particle_t) :: prt type(hepmc_vertex_t), intent(in) :: vtx integer, intent(in) :: n integer(c_int) :: nth nth = n prt%obj = vertex_get_nth_particle_in (vtx%obj, nth) end function hepmc_vertex_get_nth_particle_in function hepmc_vertex_get_nth_particle_out (vtx, n) result (prt) type(hepmc_particle_t) :: prt type(hepmc_vertex_t), intent(in) :: vtx integer, intent(in) :: n integer(c_int) :: nth nth = n prt%obj = vertex_get_nth_particle_out (vtx%obj, nth) end function hepmc_vertex_get_nth_particle_out @ %def hepmc_vertex_get_nth_particle_in @ %def hepmc_vertex_get_nth_particle_out @ \subsection{Vertex-particle-out iterator} This iterator iterates over all incoming particles in an vertex. We store a pointer to the vertex in addition to the iterator. This allows for simple end checking. The iterator is actually a constant iterator; it can only read. <>= public :: hepmc_vertex_particle_out_iterator_t <>= type :: hepmc_vertex_particle_out_iterator_t private type(c_ptr) :: obj type(c_ptr) :: v_obj end type hepmc_vertex_particle_out_iterator_t @ %def hepmc_vertex_particle_out_iterator_t @ Constructor. The iterator is initialized at the first particle in the vertex. <>= interface type(c_ptr) function & new_vertex_particles_out_const_iterator (v_obj) bind(C) import type(c_ptr), value :: v_obj end function new_vertex_particles_out_const_iterator end interface @ %def new_vertex_particles_out_const_iterator <>= public :: hepmc_vertex_particle_out_iterator_init <>= subroutine hepmc_vertex_particle_out_iterator_init (it, v) type(hepmc_vertex_particle_out_iterator_t), intent(out) :: it type(hepmc_vertex_t), intent(in) :: v it%obj = new_vertex_particles_out_const_iterator (v%obj) it%v_obj = v%obj end subroutine hepmc_vertex_particle_out_iterator_init @ %def hepmc_vertex_particle_out_iterator_init @ Destructor. Necessary because the iterator is allocated on the heap. <>= interface subroutine vertex_particles_out_const_iterator_delete (it_obj) bind(C) import type(c_ptr), value :: it_obj end subroutine vertex_particles_out_const_iterator_delete end interface @ %def vertex_particles_out_const_iterator_delete <>= public :: hepmc_vertex_particle_out_iterator_final <>= subroutine hepmc_vertex_particle_out_iterator_final (it) type(hepmc_vertex_particle_out_iterator_t), intent(inout) :: it call vertex_particles_out_const_iterator_delete (it%obj) end subroutine hepmc_vertex_particle_out_iterator_final @ %def hepmc_vertex_particle_out_iterator_final @ Increment <>= interface subroutine vertex_particles_out_const_iterator_advance (it_obj) bind(C) import type(c_ptr), value :: it_obj end subroutine vertex_particles_out_const_iterator_advance end interface @ %def vertex_particles_out_const_iterator_advance <>= public :: hepmc_vertex_particle_out_iterator_advance <>= subroutine hepmc_vertex_particle_out_iterator_advance (it) type(hepmc_vertex_particle_out_iterator_t), intent(inout) :: it call vertex_particles_out_const_iterator_advance (it%obj) end subroutine hepmc_vertex_particle_out_iterator_advance @ %def hepmc_vertex_particle_out_iterator_advance @ Reset to the beginning <>= interface subroutine vertex_particles_out_const_iterator_reset & (it_obj, v_obj) bind(C) import type(c_ptr), value :: it_obj, v_obj end subroutine vertex_particles_out_const_iterator_reset end interface @ %def vertex_particles_out_const_iterator_reset <>= public :: hepmc_vertex_particle_out_iterator_reset <>= subroutine hepmc_vertex_particle_out_iterator_reset (it) type(hepmc_vertex_particle_out_iterator_t), intent(inout) :: it call vertex_particles_out_const_iterator_reset (it%obj, it%v_obj) end subroutine hepmc_vertex_particle_out_iterator_reset @ %def hepmc_vertex_particle_out_iterator_reset @ Test: return true as long as we are not past the end. <>= interface function vertex_particles_out_const_iterator_is_valid & (it_obj, v_obj) result (flag) bind(C) import logical(c_bool) :: flag type(c_ptr), value :: it_obj, v_obj end function vertex_particles_out_const_iterator_is_valid end interface @ %def vertex_particles_out_const_iterator_is_valid <>= public :: hepmc_vertex_particle_out_iterator_is_valid <>= function hepmc_vertex_particle_out_iterator_is_valid (it) result (flag) logical :: flag type(hepmc_vertex_particle_out_iterator_t), intent(in) :: it flag = vertex_particles_out_const_iterator_is_valid (it%obj, it%v_obj) end function hepmc_vertex_particle_out_iterator_is_valid @ %def hepmc_vertex_particle_out_iterator_is_valid @ Return the particle pointed to by the iterator. (The particle object should not be finalized, since it contains merely a pointer to the particle which is owned by the vertex.) <>= interface type(c_ptr) function & vertex_particles_out_const_iterator_get (it_obj) bind(C) import type(c_ptr), value :: it_obj end function vertex_particles_out_const_iterator_get end interface @ %def vertex_particles_out_const_iterator_get <>= public :: hepmc_vertex_particle_out_iterator_get <>= function hepmc_vertex_particle_out_iterator_get (it) result (prt) type(hepmc_particle_t) :: prt type(hepmc_vertex_particle_out_iterator_t), intent(in) :: it prt%obj = vertex_particles_out_const_iterator_get (it%obj) end function hepmc_vertex_particle_out_iterator_get @ %def hepmc_vertex_particle_out_iterator_get @ \subsection{GenEvent} The main object of HepMC is a GenEvent. The object is filled by GenVertex objects, which in turn contain GenParticle objects. + +This is an extension of the abstract [[event_handle_t]], so we can use the +according communicator features. <>= public :: hepmc_event_t <>= - type :: hepmc_event_t + type, extends (event_handle_t) :: hepmc_event_t private - type(c_ptr) :: obj + type(c_ptr) :: obj = c_null_ptr end type hepmc_event_t @ %def hepmc_event_t @ Constructor. Arguments are process ID (integer) and event ID (integer). The Fortran version has initializer form. <>= interface type(c_ptr) function new_gen_event (proc_id, event_id) bind(C) import integer(c_int), value :: proc_id, event_id end function new_gen_event end interface @ %def new_gen_event <>= public :: hepmc_event_init <>= subroutine hepmc_event_init (evt, proc_id, event_id) type(hepmc_event_t), intent(out) :: evt integer, intent(in), optional :: proc_id, event_id integer(c_int) :: pid, eid pid = 0; if (present (proc_id)) pid = proc_id eid = 0; if (present (event_id)) eid = event_id evt%obj = new_gen_event (pid, eid) end subroutine hepmc_event_init @ %def hepmc_event_init @ Destructor. <>= interface subroutine gen_event_delete (evt_obj) bind(C) import type(c_ptr), value :: evt_obj end subroutine gen_event_delete end interface @ %def gen_event_delete +@ Finalize: use the HepMC destructor. Also nullify the pointer explicitly, to +be on the safe side. <>= public :: hepmc_event_final <>= subroutine hepmc_event_final (evt) type(hepmc_event_t), intent(inout) :: evt - call gen_event_delete (evt%obj) + if (c_associated (evt%obj)) then + call gen_event_delete (evt%obj) + evt%obj = c_null_ptr + end if end subroutine hepmc_event_final @ %def hepmc_event_final +@ Nullify: do not call the destructor, just nullify the C pointer. There +should be another pointer associated with the object. +<>= + public :: hepmc_event_nullify +<>= + subroutine hepmc_event_nullify (evt) + type(hepmc_event_t), intent(inout) :: evt + evt%obj = c_null_ptr + end subroutine hepmc_event_nullify + +@ %def hepmc_event_nullify +@ Return the actual object as a C pointer. For use in the native C++ +interface only. +<>= + public :: hepmc_event_get_c_ptr +<>= + function hepmc_event_get_c_ptr (evt) result (p) + type(hepmc_event_t), intent(in) :: evt + type(c_ptr) :: p + p = evt%obj + end function hepmc_event_get_c_ptr + +@ %def hepmc_event_get_c_ptr @ Screen output. Printing to file is possible in principle (using a C++ output channel), by allowing an argument. Printing to an open Fortran unit is obviously not possible. <>= interface subroutine gen_event_print (evt_obj) bind(C) import type(c_ptr), value :: evt_obj end subroutine gen_event_print end interface @ %def gen_event_print <>= public :: hepmc_event_print <>= subroutine hepmc_event_print (evt) type(hepmc_event_t), intent(in) :: evt call gen_event_print (evt%obj) end subroutine hepmc_event_print @ %def hepmc_event_print @ Get the event number. <>= interface integer(c_int) function gen_event_event_number (evt_obj) bind(C) use iso_c_binding !NODEP! type(c_ptr), value :: evt_obj end function gen_event_event_number end interface @ %def gen_event_event_number <>= public :: hepmc_event_get_event_index <>= function hepmc_event_get_event_index (evt) result (i_proc) integer :: i_proc type(hepmc_event_t), intent(in) :: evt i_proc = gen_event_event_number (evt%obj) end function hepmc_event_get_event_index @ %def hepmc_event_get_event_index <>= interface integer(c_int) function gen_event_get_n_particles & (evt_obj) bind(C) import type(c_ptr), value :: evt_obj end function gen_event_get_n_particles end interface interface integer(c_int) function gen_event_get_n_beams & (evt_obj) bind(C) import type(c_ptr), value :: evt_obj end function gen_event_get_n_beams end interface @ %def gen_event_get_n_particles gen_event_get_n_beams <>= public :: hepmc_event_get_n_particles public :: hepmc_event_get_n_beams <>= function hepmc_event_get_n_particles (evt) result (n_tot) integer :: n_tot type(hepmc_event_t), intent(in) :: evt n_tot = gen_event_get_n_particles (evt%obj) end function hepmc_event_get_n_particles function hepmc_event_get_n_beams (evt) result (n_tot) integer :: n_tot type(hepmc_event_t), intent(in) :: evt n_tot = gen_event_get_n_beams (evt%obj) end function hepmc_event_get_n_beams @ %def hepmc_event_get_n_particles @ %def hepmc_event_get_n_beams @ Set the numeric signal process ID <>= interface subroutine gen_event_set_signal_process_id (evt_obj, proc_id) bind(C) import type(c_ptr), value :: evt_obj integer(c_int), value :: proc_id end subroutine gen_event_set_signal_process_id end interface @ %def gen_event_set_signal_process_id <>= public :: hepmc_event_set_process_id <>= subroutine hepmc_event_set_process_id (evt, proc) type(hepmc_event_t), intent(in) :: evt integer, intent(in) :: proc integer(c_int) :: i_proc i_proc = proc call gen_event_set_signal_process_id (evt%obj, i_proc) end subroutine hepmc_event_set_process_id @ %def hepmc_event_set_process_id @ Get the numeric signal process ID <>= interface integer(c_int) function gen_event_signal_process_id (evt_obj) bind(C) import type(c_ptr), value :: evt_obj end function gen_event_signal_process_id end interface @ %def gen_event_signal_process_id <>= public :: hepmc_event_get_process_id <>= function hepmc_event_get_process_id (evt) result (i_proc) integer :: i_proc type(hepmc_event_t), intent(in) :: evt i_proc = gen_event_signal_process_id (evt%obj) end function hepmc_event_get_process_id @ %def hepmc_event_get_process_id @ Set the event energy scale <>= interface subroutine gen_event_set_event_scale (evt_obj, scale) bind(C) import type(c_ptr), value :: evt_obj real(c_double), value :: scale end subroutine gen_event_set_event_scale end interface @ %def gen_event_set_event_scale <>= public :: hepmc_event_set_scale <>= subroutine hepmc_event_set_scale (evt, scale) type(hepmc_event_t), intent(in) :: evt real(default), intent(in) :: scale real(c_double) :: cscale cscale = scale call gen_event_set_event_scale (evt%obj, cscale) end subroutine hepmc_event_set_scale @ %def hepmc_event_set_scale @ Get the event energy scale <>= interface real(c_double) function gen_event_event_scale (evt_obj) bind(C) import type(c_ptr), value :: evt_obj end function gen_event_event_scale end interface @ %def gen_event_event_scale <>= public :: hepmc_event_get_scale <>= function hepmc_event_get_scale (evt) result (scale) real(default) :: scale type(hepmc_event_t), intent(in) :: evt scale = gen_event_event_scale (evt%obj) end function hepmc_event_get_scale @ %def hepmc_event_set_scale @ Set the value of $\alpha_{\rm QCD}$. <>= interface subroutine gen_event_set_alpha_qcd (evt_obj, a) bind(C) import type(c_ptr), value :: evt_obj real(c_double), value :: a end subroutine gen_event_set_alpha_qcd end interface @ %def gen_event_set_alpha_qcd <>= public :: hepmc_event_set_alpha_qcd <>= subroutine hepmc_event_set_alpha_qcd (evt, alpha) type(hepmc_event_t), intent(in) :: evt real(default), intent(in) :: alpha real(c_double) :: a a = alpha call gen_event_set_alpha_qcd (evt%obj, a) end subroutine hepmc_event_set_alpha_qcd @ %def hepmc_event_set_alpha_qcd @ Get the value of $\alpha_{\rm QCD}$. <>= interface real(c_double) function gen_event_alpha_qcd (evt_obj) bind(C) import type(c_ptr), value :: evt_obj end function gen_event_alpha_qcd end interface @ %def gen_event_get_alpha_qcd <>= public :: hepmc_event_get_alpha_qcd <>= function hepmc_event_get_alpha_qcd (evt) result (alpha) real(default) :: alpha type(hepmc_event_t), intent(in) :: evt alpha = gen_event_alpha_qcd (evt%obj) end function hepmc_event_get_alpha_qcd @ %def hepmc_event_get_alpha_qcd @ Set the value of $\alpha_{\rm QED}$. <>= interface subroutine gen_event_set_alpha_qed (evt_obj, a) bind(C) import type(c_ptr), value :: evt_obj real(c_double), value :: a end subroutine gen_event_set_alpha_qed end interface @ %def gen_event_set_alpha_qed <>= public :: hepmc_event_set_alpha_qed <>= subroutine hepmc_event_set_alpha_qed (evt, alpha) type(hepmc_event_t), intent(in) :: evt real(default), intent(in) :: alpha real(c_double) :: a a = alpha call gen_event_set_alpha_qed (evt%obj, a) end subroutine hepmc_event_set_alpha_qed @ %def hepmc_event_set_alpha_qed @ Get the value of $\alpha_{\rm QED}$. <>= interface real(c_double) function gen_event_alpha_qed (evt_obj) bind(C) import type(c_ptr), value :: evt_obj end function gen_event_alpha_qed end interface @ %def gen_event_get_alpha_qed <>= public :: hepmc_event_get_alpha_qed <>= function hepmc_event_get_alpha_qed (evt) result (alpha) real(default) :: alpha type(hepmc_event_t), intent(in) :: evt alpha = gen_event_alpha_qed (evt%obj) end function hepmc_event_get_alpha_qed @ %def hepmc_event_get_alpha_qed @ Clear a weight value to the end of the weight container. <>= interface subroutine gen_event_clear_weights (evt_obj) bind(C) use iso_c_binding !NODEP! type(c_ptr), value :: evt_obj end subroutine gen_event_clear_weights end interface @ %def gen_event_set_alpha_qed @ The HepMC weights are measured in pb. <>= integer, parameter, public :: HEPMC3_MODE_HEPMC2 = 1 integer, parameter, public :: HEPMC3_MODE_HEPMC3 = 2 integer, parameter, public :: HEPMC3_MODE_ROOT = 3 integer, parameter, public :: HEPMC3_MODE_ROOTTREE = 4 integer, parameter, public :: HEPMC3_MODE_HEPEVT = 5 @ %def HEPMC3_MODE_HEPMC2 HEPMC3_MODE_HEPMC3 @ %def HEPMC3_MODE_ROOT HEPMC3_MODE_ROOTTREE @ %def HEPMC3_MODE_HEPEVT @ <>= public :: hepmc_event_clear_weights <>= subroutine hepmc_event_clear_weights (evt) type(hepmc_event_t), intent(in) :: evt call gen_event_clear_weights (evt%obj) end subroutine hepmc_event_clear_weights @ %def hepmc_event_clear_weights @ Add a weight value to the end of the weight container. <>= interface subroutine gen_event_add_weight (evt_obj, w) bind(C) use iso_c_binding !NODEP! type(c_ptr), value :: evt_obj real(c_double), value :: w end subroutine gen_event_add_weight end interface @ %def gen_event_add_weight @ <>= public :: hepmc_event_add_weight <>= subroutine hepmc_event_add_weight (evt, weight, rescale) type(hepmc_event_t), intent(in) :: evt real(default), intent(in) :: weight logical, intent(in) :: rescale real(c_double) :: w if (rescale) then w = weight * pb_per_fb else w = weight end if call gen_event_add_weight (evt%obj, w) end subroutine hepmc_event_add_weight @ %def hepmc_event_add_weight @ Get the size of the weight container (the number of valid elements). <>= interface integer(c_int) function gen_event_weights_size (evt_obj) bind(C) use iso_c_binding !NODEP! type(c_ptr), value :: evt_obj end function gen_event_weights_size end interface @ %def gen_event_get_weight <>= public :: hepmc_event_get_weights_size <>= function hepmc_event_get_weights_size (evt) result (n) integer :: n type(hepmc_event_t), intent(in) :: evt n = gen_event_weights_size (evt%obj) end function hepmc_event_get_weights_size @ %def hepmc_event_get_weights_size @ Get the value of the weight with index [[i]]. (Count from 1, while C counts from zero.) <>= interface real(c_double) function gen_event_weight (evt_obj, i) bind(C) use iso_c_binding !NODEP! type(c_ptr), value :: evt_obj integer(c_int), value :: i end function gen_event_weight end interface @ %def gen_event_get_weight <>= public :: hepmc_event_get_weight <>= function hepmc_event_get_weight (evt, index, rescale) result (weight) real(default) :: weight type(hepmc_event_t), intent(in) :: evt integer, intent(in) :: index logical, intent(in) :: rescale integer(c_int) :: i i = index - 1 if (rescale) then weight = gen_event_weight (evt%obj, i) / pb_per_fb else weight = gen_event_weight (evt%obj, i) end if end function hepmc_event_get_weight @ %def hepmc_event_get_weight @ Add a vertex to the event container. <>= interface subroutine gen_event_add_vertex (evt_obj, v_obj) bind(C) import type(c_ptr), value :: evt_obj type(c_ptr), value :: v_obj end subroutine gen_event_add_vertex end interface @ %def gen_event_add_vertex <>= public :: hepmc_event_add_vertex <>= subroutine hepmc_event_add_vertex (evt, v) type(hepmc_event_t), intent(inout) :: evt type(hepmc_vertex_t), intent(in) :: v call gen_event_add_vertex (evt%obj, v%obj) end subroutine hepmc_event_add_vertex @ %def hepmc_event_add_vertex @ Mark a particular vertex as the signal process (hard interaction). <>= interface subroutine gen_event_set_signal_process_vertex (evt_obj, v_obj) bind(C) import type(c_ptr), value :: evt_obj type(c_ptr), value :: v_obj end subroutine gen_event_set_signal_process_vertex end interface @ %def gen_event_set_signal_process_vertex <>= public :: hepmc_event_set_signal_process_vertex <>= subroutine hepmc_event_set_signal_process_vertex (evt, v) type(hepmc_event_t), intent(inout) :: evt type(hepmc_vertex_t), intent(in) :: v call gen_event_set_signal_process_vertex (evt%obj, v%obj) end subroutine hepmc_event_set_signal_process_vertex @ %def hepmc_event_set_signal_process_vertex @ Return the the signal process (hard interaction). <>= interface function gen_event_get_signal_process_vertex (evt_obj) & result (v_obj) bind(C) import type(c_ptr), value :: evt_obj type(c_ptr) :: v_obj end function gen_event_get_signal_process_vertex end interface @ %def gen_event_get_signal_process_vertex <>= public :: hepmc_event_get_signal_process_vertex <>= function hepmc_event_get_signal_process_vertex (evt) result (v) type(hepmc_event_t), intent(in) :: evt type(hepmc_vertex_t) :: v v%obj = gen_event_get_signal_process_vertex (evt%obj) end function hepmc_event_get_signal_process_vertex @ %def hepmc_event_get_signal_process_vertex @ Set the beam particles explicitly. <>= public :: hepmc_event_set_beam_particles <>= subroutine hepmc_event_set_beam_particles (evt, prt1, prt2) type(hepmc_event_t), intent(inout) :: evt type(hepmc_particle_t), intent(in) :: prt1, prt2 logical(c_bool) :: flag flag = gen_event_set_beam_particles (evt%obj, prt1%obj, prt2%obj) end subroutine hepmc_event_set_beam_particles @ %def hepmc_event_set_beam_particles @ The C function returns a boolean which we do not use. <>= interface logical(c_bool) function gen_event_set_beam_particles & (evt_obj, prt1_obj, prt2_obj) bind(C) import type(c_ptr), value :: evt_obj, prt1_obj, prt2_obj end function gen_event_set_beam_particles end interface @ %def gen_event_set_beam_particles @ Set the cross section and error explicitly. Note that HepMC uses pb, while WHIZARD uses fb. <>= public :: hepmc_event_set_cross_section <>= subroutine hepmc_event_set_cross_section (evt, xsec, xsec_err) type(hepmc_event_t), intent(inout) :: evt real(default), intent(in) :: xsec, xsec_err call gen_event_set_cross_section & (evt%obj, & real (xsec * 1e-3_default, c_double), & real (xsec_err * 1e-3_default, c_double)) end subroutine hepmc_event_set_cross_section @ %def hepmc_event_set_cross_section @ The C function returns a boolean which we do not use. <>= interface subroutine gen_event_set_cross_section (evt_obj, xs, xs_err) bind(C) import type(c_ptr), value :: evt_obj real(c_double), value :: xs, xs_err end subroutine gen_event_set_cross_section end interface @ %def gen_event_set_cross_section @ \subsection{Event-particle iterator} This iterator iterates over all particles in an event. We store a pointer to the event in addition to the iterator. This allows for simple end checking. The iterator is actually a constant iterator; it can only read. <>= public :: hepmc_event_particle_iterator_t <>= type :: hepmc_event_particle_iterator_t private type(c_ptr) :: obj type(c_ptr) :: evt_obj end type hepmc_event_particle_iterator_t @ %def hepmc_event_particle_iterator_t @ Constructor. The iterator is initialized at the first particle in the event. <>= interface type(c_ptr) function new_event_particle_const_iterator (evt_obj) bind(C) import type(c_ptr), value :: evt_obj end function new_event_particle_const_iterator end interface @ %def new_event_particle_const_iterator <>= public :: hepmc_event_particle_iterator_init <>= subroutine hepmc_event_particle_iterator_init (it, evt) type(hepmc_event_particle_iterator_t), intent(out) :: it type(hepmc_event_t), intent(in) :: evt it%obj = new_event_particle_const_iterator (evt%obj) it%evt_obj = evt%obj end subroutine hepmc_event_particle_iterator_init @ %def hepmc_event_particle_iterator_init @ Destructor. Necessary because the iterator is allocated on the heap. <>= interface subroutine event_particle_const_iterator_delete (it_obj) bind(C) import type(c_ptr), value :: it_obj end subroutine event_particle_const_iterator_delete end interface @ %def event_particle_const_iterator_delete <>= public :: hepmc_event_particle_iterator_final <>= subroutine hepmc_event_particle_iterator_final (it) type(hepmc_event_particle_iterator_t), intent(inout) :: it call event_particle_const_iterator_delete (it%obj) end subroutine hepmc_event_particle_iterator_final @ %def hepmc_event_particle_iterator_final @ Increment <>= interface subroutine event_particle_const_iterator_advance (it_obj) bind(C) import type(c_ptr), value :: it_obj end subroutine event_particle_const_iterator_advance end interface @ %def event_particle_const_iterator_advance <>= public :: hepmc_event_particle_iterator_advance <>= subroutine hepmc_event_particle_iterator_advance (it) type(hepmc_event_particle_iterator_t), intent(inout) :: it call event_particle_const_iterator_advance (it%obj) end subroutine hepmc_event_particle_iterator_advance @ %def hepmc_event_particle_iterator_advance @ Reset to the beginning <>= interface subroutine event_particle_const_iterator_reset (it_obj, evt_obj) bind(C) import type(c_ptr), value :: it_obj, evt_obj end subroutine event_particle_const_iterator_reset end interface @ %def event_particle_const_iterator_reset <>= public :: hepmc_event_particle_iterator_reset <>= subroutine hepmc_event_particle_iterator_reset (it) type(hepmc_event_particle_iterator_t), intent(inout) :: it call event_particle_const_iterator_reset (it%obj, it%evt_obj) end subroutine hepmc_event_particle_iterator_reset @ %def hepmc_event_particle_iterator_reset @ Test: return true as long as we are not past the end. <>= interface function event_particle_const_iterator_is_valid & (it_obj, evt_obj) result (flag) bind(C) import logical(c_bool) :: flag type(c_ptr), value :: it_obj, evt_obj end function event_particle_const_iterator_is_valid end interface @ %def event_particle_const_iterator_is_valid <>= public :: hepmc_event_particle_iterator_is_valid <>= function hepmc_event_particle_iterator_is_valid (it) result (flag) logical :: flag type(hepmc_event_particle_iterator_t), intent(in) :: it flag = event_particle_const_iterator_is_valid (it%obj, it%evt_obj) end function hepmc_event_particle_iterator_is_valid @ %def hepmc_event_particle_iterator_is_valid @ Return the particle pointed to by the iterator. (The particle object should not be finalized, since it contains merely a pointer to the particle which is owned by the vertex.) <>= interface type(c_ptr) function event_particle_const_iterator_get (it_obj) bind(C) import type(c_ptr), value :: it_obj end function event_particle_const_iterator_get end interface @ %def event_particle_const_iterator_get <>= public :: hepmc_event_particle_iterator_get <>= function hepmc_event_particle_iterator_get (it) result (prt) type(hepmc_particle_t) :: prt type(hepmc_event_particle_iterator_t), intent(in) :: it prt%obj = event_particle_const_iterator_get (it%obj) end function hepmc_event_particle_iterator_get @ %def hepmc_event_particle_iterator_get <>= interface type(c_ptr) function gen_event_get_nth_particle (evt_obj, n) bind(C) import type(c_ptr), value :: evt_obj integer(c_int), value :: n end function gen_event_get_nth_particle end interface interface integer(c_int) function gen_event_get_nth_beam (evt_obj, n) bind(C) import type(c_ptr), value :: evt_obj integer(c_int), value :: n end function gen_event_get_nth_beam end interface @ %def gen_event_get_nth_particle @ %def gen_event_get_nth_beam <>= public :: hepmc_event_get_nth_particle public :: hepmc_event_get_nth_beam <>= function hepmc_event_get_nth_particle (evt, n) result (prt) type(hepmc_particle_t) :: prt type(hepmc_event_t), intent(in) :: evt integer, intent(in) :: n integer :: n_tot integer(c_int) :: nth nth = n n_tot = gen_event_get_n_particles (evt%obj) if (n > n_tot .or. n < 1) then prt%obj = c_null_ptr call msg_error ("HepMC interface called for wrong particle ID.") else prt%obj = gen_event_get_nth_particle (evt%obj, nth) end if end function hepmc_event_get_nth_particle function hepmc_event_get_nth_beam (evt, n) result (beam_barcode) integer :: beam_barcode type(hepmc_event_t), intent(in) :: evt integer, intent(in) :: n integer(c_int) :: bc bc = gen_event_get_nth_beam (evt%obj, n) beam_barcode = bc end function hepmc_event_get_nth_beam @ %def hepmc_event_get_nth_particle @ %def hepmc_event_get_nth_beam @ \subsection{I/O streams} There is a specific I/O stream type for handling the output of GenEvent objects (i.e., Monte Carlo event samples) to file. Opening the file is done by the constructor, closing by the destructor. <>= public :: hepmc_iostream_t <>= type :: hepmc_iostream_t private type(c_ptr) :: obj end type hepmc_iostream_t @ %def hepmc_iostream_t @ Constructor for an output stream associated to a file. <>= interface type(c_ptr) function new_io_gen_event_out (hepmc3_mode, filename) bind(C) import integer(c_int), intent(in) :: hepmc3_mode character(c_char), dimension(*), intent(in) :: filename end function new_io_gen_event_out end interface @ %def new_io_gen_event_out <>= public :: hepmc_iostream_open_out <>= subroutine hepmc_iostream_open_out (iostream, filename, hepmc3_mode) type(hepmc_iostream_t), intent(out) :: iostream type(string_t), intent(in) :: filename integer, intent(in) :: hepmc3_mode integer(c_int) :: mode mode = hepmc3_mode iostream%obj = & new_io_gen_event_out (mode, char (filename) // c_null_char) end subroutine hepmc_iostream_open_out @ %def hepmc_iostream_open_out @ Constructor for an input stream associated to a file. <>= interface type(c_ptr) function new_io_gen_event_in (hepmc3_mode, filename) bind(C) import integer(c_int), intent(in) :: hepmc3_mode character(c_char), dimension(*), intent(in) :: filename end function new_io_gen_event_in end interface @ %def new_io_gen_event_in <>= public :: hepmc_iostream_open_in <>= subroutine hepmc_iostream_open_in (iostream, filename, hepmc3_mode) type(hepmc_iostream_t), intent(out) :: iostream type(string_t), intent(in) :: filename integer, intent(in) :: hepmc3_mode integer(c_int) :: mode mode = hepmc3_mode iostream%obj = & new_io_gen_event_in (mode, char (filename) // c_null_char) end subroutine hepmc_iostream_open_in @ %def hepmc_iostream_open_in @ Destructor: <>= interface subroutine io_gen_event_delete (io_obj) bind(C) import type(c_ptr), value :: io_obj end subroutine io_gen_event_delete end interface @ %def io_gen_event_delete <>= public :: hepmc_iostream_close <>= subroutine hepmc_iostream_close (iostream) type(hepmc_iostream_t), intent(inout) :: iostream call io_gen_event_delete (iostream%obj) end subroutine hepmc_iostream_close @ %def hepmc_iostream_close @ Write a single event to the I/O stream. <>= interface subroutine io_gen_event_write_event (io_obj, evt_obj) bind(C) import type(c_ptr), value :: io_obj, evt_obj end subroutine io_gen_event_write_event end interface interface subroutine io_gen_event_write_event_hepmc2 (io_obj, evt_obj) bind(C) import type(c_ptr), value :: io_obj, evt_obj end subroutine io_gen_event_write_event_hepmc2 end interface @ %def io_gen_event_write_event io_gen_event_write_event_hepmc2 <>= public :: hepmc_iostream_write_event <>= subroutine hepmc_iostream_write_event (iostream, evt, hepmc3_mode) type(hepmc_iostream_t), intent(inout) :: iostream type(hepmc_event_t), intent(in) :: evt integer, intent(in), optional :: hepmc3_mode integer :: mode mode = HEPMC3_MODE_HEPMC3 if (present (hepmc3_mode)) mode = hepmc3_mode call io_gen_event_write_event (iostream%obj, evt%obj) end subroutine hepmc_iostream_write_event @ %def hepmc_iostream_write_event @ Read a single event from the I/O stream. Return true if successful. <>= interface logical(c_bool) function io_gen_event_read_event (io_obj, evt_obj) bind(C) import type(c_ptr), value :: io_obj, evt_obj end function io_gen_event_read_event end interface @ %def io_gen_event_read_event <>= public :: hepmc_iostream_read_event <>= subroutine hepmc_iostream_read_event (iostream, evt, ok) type(hepmc_iostream_t), intent(inout) :: iostream type(hepmc_event_t), intent(inout) :: evt logical, intent(out) :: ok ok = io_gen_event_read_event (iostream%obj, evt%obj) end subroutine hepmc_iostream_read_event @ %def hepmc_iostream_read_event @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[hepmc_interface_ut.f90]]>>= <> module hepmc_interface_ut use unit_tests use system_dependencies, only: HEPMC2_AVAILABLE use system_dependencies, only: HEPMC3_AVAILABLE use hepmc_interface_uti <> <> contains <> end module hepmc_interface_ut @ %def hepmc_interface_ut @ <<[[hepmc_interface_uti.f90]]>>= <> module hepmc_interface_uti <> <> use io_units use lorentz use flavors use colors use polarizations use hepmc_interface <> <> contains <> end module hepmc_interface_uti @ %def hepmc_interface_ut @ API: driver for the unit tests below. <>= public :: hepmc_interface_test <>= subroutine hepmc_interface_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine hepmc_interface_test @ %def hepmc_test @ This test example is an abridged version from the build-from-scratch example in the HepMC distribution. We create two vertices for $p\to q$ PDF splitting, then a vertex for a $qq\to W^-g$ hard-interaction process, and finally a vertex for $W^-\to qq$ decay. The setup is for LHC kinematics. Extending the original example, we set color flow for the incoming quarks and polarization for the outgoing photon. For the latter, we have to define a particle-data object for the photon, so a flavor object can be correctly initialized. <>= if (HEPMC2_AVAILABLE) then call test (hepmc_interface_1, "hepmc2_interface_1", & "check HepMC2 interface", & u, results) else if (HEPMC3_AVAILABLE) then call test (hepmc_interface_1, "hepmc3_interface_1", & "check HepMC3 interface", & u, results) end if <>= public :: hepmc_interface_1 <>= subroutine hepmc_interface_1 (u) use physics_defs, only: VECTOR use model_data, only: field_data_t integer, intent(in) :: u integer :: u_file, iostat type(hepmc_event_t) :: evt type(hepmc_vertex_t) :: v1, v2, v3, v4 type(hepmc_particle_t) :: prt1, prt2, prt3, prt4, prt5, prt6, prt7, prt8 type(hepmc_iostream_t) :: iostream type(flavor_t) :: flv type(color_t) :: col type(polarization_t) :: pol type(field_data_t), target :: photon_data character(80) :: buffer write (u, "(A)") "* Test output: HepMC interface" write (u, "(A)") "* Purpose: test HepMC interface" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") ! Initialize a photon flavor object and some polarization call photon_data%init (var_str ("PHOTON"), 22) call photon_data%set (spin_type=VECTOR) call photon_data%freeze () call flv%init (photon_data) call pol%init_angles & (flv, 0.6_default, 1._default, 0.5_default) ! Event initialization call hepmc_event_init (evt, 20, 1) write (u, "(A)") "* p -> q splitting" write (u, "(A)") ! $p\to q$ splittings call hepmc_vertex_init (v1) call hepmc_event_add_vertex (evt, v1) call hepmc_vertex_init (v2) call hepmc_event_add_vertex (evt, v2) call particle_init (prt1, & 0._default, 0._default, 7000._default, 7000._default, & 2212, 3) call hepmc_vertex_add_particle_in (v1, prt1) call particle_init (prt2, & 0._default, 0._default,-7000._default, 7000._default, & 2212, 3) call hepmc_vertex_add_particle_in (v2, prt2) call particle_init (prt3, & .750_default, -1.569_default, 32.191_default, 32.238_default, & 1, 3) call color_init_from_array (col, [501]) call hepmc_particle_set_color (prt3, col) call hepmc_vertex_add_particle_out (v1, prt3) call particle_init (prt4, & -3.047_default, -19._default, -54.629_default, 57.920_default, & -2, 3) call color_init_from_array (col, [-501]) call hepmc_particle_set_color (prt4, col) call hepmc_vertex_add_particle_out (v2, prt4) write (u, "(A)") "* Hard interaction" write (u, "(A)") ! Hard interaction call hepmc_vertex_init (v3) call hepmc_event_add_vertex (evt, v3) call hepmc_vertex_add_particle_in (v3, prt3) call hepmc_vertex_add_particle_in (v3, prt4) call particle_init (prt6, & -3.813_default, 0.113_default, -1.833_default, 4.233_default, & 22, 1) call hepmc_particle_set_polarization (prt6, pol) call hepmc_vertex_add_particle_out (v3, prt6) call particle_init (prt5, & 1.517_default, -20.68_default, -20.605_default, 85.925_default, & -24, 3) call hepmc_vertex_add_particle_out (v3, prt5) call hepmc_event_set_signal_process_vertex (evt, v3) ! $W^-$ decay call vertex_init_pos (v4, & 0.12_default, -0.3_default, 0.05_default, 0.004_default) call hepmc_event_add_vertex (evt, v4) call hepmc_vertex_add_particle_in (v4, prt5) call particle_init (prt7, & -2.445_default, 28.816_default, 6.082_default, 29.552_default, & 1, 1) call hepmc_vertex_add_particle_out (v4, prt7) call particle_init (prt8, & 3.962_default, -49.498_default, -26.687_default, 56.373_default, & -2, 1) call hepmc_vertex_add_particle_out (v4, prt8) ! Event output call hepmc_event_print (evt) write (u, "(A)") "Writing to file 'hepmc_test.hepmc'" write (u, "(A)") call hepmc_iostream_open_out (iostream , var_str ("hepmc_test.hepmc"), 2) call hepmc_iostream_write_event (iostream, evt) call hepmc_iostream_close (iostream) write (u, "(A)") "Writing completed" write (u, "(A)") write (u, "(A)") "* File contents:" write (u, "(A)") u_file = free_unit () open (u_file, file = "hepmc_test.hepmc", & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (buffer(1:14) == "HepMC::Version") buffer = "[...]" if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Cleanup" write (u, "(A)") ! Wrapup ! call pol%final () call hepmc_event_final (evt) write (u, "(A)") write (u, "(A)") "* Test output end: hepmc_interface_1" contains subroutine vertex_init_pos (v, x, y, z, t) type(hepmc_vertex_t), intent(out) :: v real(default), intent(in) :: x, y, z, t type(vector4_t) :: xx xx = vector4_moving (t, vector3_moving ([x, y, z])) call hepmc_vertex_init (v, xx) end subroutine vertex_init_pos subroutine particle_init (prt, px, py, pz, E, pdg, status) type(hepmc_particle_t), intent(out) :: prt real(default), intent(in) :: px, py, pz, E integer, intent(in) :: pdg, status type(vector4_t) :: p p = vector4_moving (E, vector3_moving ([px, py, pz])) call hepmc_particle_init (prt, p, pdg, status) end subroutine particle_init end subroutine hepmc_interface_1 @ %def hepmc_interface_1 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{LCIO events} This section provides the interface to the LCIO C++ library for handling Monte-Carlo events. Each C++ class of LCIO that we use is mirrored by a Fortran type, which contains as its only component the C pointer to the C++ object. Each C++ method of LCIO that we use has a C wrapper function. This function takes a pointer to the host object as its first argument. Further arguments are either C pointers, or in the case of simple types (integer, real), interoperable C/Fortran objects. The C wrapper functions have explicit interfaces in the Fortran module. They are called by Fortran wrapper procedures. These are treated as methods of the corresponding Fortran type. <<[[lcio_interface.f90]]>>= <> module lcio_interface use, intrinsic :: iso_c_binding !NODEP! <> <> use constants, only: PI use physics_defs, only: ns_per_mm use diagnostics use lorentz use flavors use colors use helicities use polarizations + use event_handles, only: event_handle_t <> <> <> <> contains <> end module lcio_interface @ %def lcio_interface @ \subsection{Interface check} This function can be called in order to verify that we are using the actual LCIO library, and not the dummy version. <>= interface logical(c_bool) function lcio_available () bind(C) import end function lcio_available end interface <>= public :: lcio_is_available <>= function lcio_is_available () result (flag) logical :: flag flag = lcio_available () end function lcio_is_available @ %def lcio_is_available @ \subsection{LCIO Run Header} This is a type for the run header of the LCIO file. <>= public :: lcio_run_header_t <>= type :: lcio_run_header_t private type(c_ptr) :: obj end type lcio_run_header_t @ %def lcio_run_header_t The Fortran version has initializer form. <>= interface type(c_ptr) function new_lcio_run_header (proc_id) bind(C) import integer(c_int), value :: proc_id end function new_lcio_run_header end interface @ %def new_lcio_run_header <>= interface subroutine run_header_set_simstring & (runhdr_obj, simstring) bind(C) import type(c_ptr), value :: runhdr_obj character(c_char), dimension(*), intent(in) :: simstring end subroutine run_header_set_simstring end interface @ %def run_header_set_simstring <>= public :: lcio_run_header_init <>= subroutine lcio_run_header_init (runhdr, proc_id, run_id) type(lcio_run_header_t), intent(out) :: runhdr integer, intent(in), optional :: proc_id, run_id integer(c_int) :: rid rid = 0; if (present (run_id)) rid = run_id runhdr%obj = new_lcio_run_header (rid) call run_header_set_simstring (runhdr%obj, & "WHIZARD version:" // "<>") end subroutine lcio_run_header_init @ %def lcio_run_header_init @ <>= interface subroutine write_run_header (lcwrt_obj, runhdr_obj) bind(C) import type(c_ptr), value :: lcwrt_obj type(c_ptr), value :: runhdr_obj end subroutine write_run_header end interface @ %def write_run_header <>= public :: lcio_run_header_write <>= subroutine lcio_run_header_write (wrt, hdr) type(lcio_writer_t), intent(inout) :: wrt type(lcio_run_header_t), intent(inout) :: hdr call write_run_header (wrt%obj, hdr%obj) end subroutine lcio_run_header_write @ %def lcio_run_header_write @ \subsection{LCIO Event and LC Collection} The main object of LCIO is a LCEventImpl. The object is filled by MCParticle objects, which are set as LCCollection. <>= public :: lccollection_t <>= type :: lccollection_t private - type(c_ptr) :: obj + type(c_ptr) :: obj = c_null_ptr end type lccollection_t @ %def lccollection_t @ Initializer. <>= interface type(c_ptr) function new_lccollection () bind(C) import end function new_lccollection end interface @ %def new_lccollection <>= public :: lcio_event_t <>= - type :: lcio_event_t + type, extends (event_handle_t) :: lcio_event_t private - type(c_ptr) :: obj + type(c_ptr) :: obj = c_null_ptr type(lccollection_t) :: lccoll end type lcio_event_t @ %def lcio_event_t @ Constructor. Arguments are process ID (integer) and event ID (integer). The Fortran version has initializer form. <>= interface type(c_ptr) function new_lcio_event (proc_id, event_id, run_id) bind(C) import integer(c_int), value :: proc_id, event_id, run_id end function new_lcio_event end interface @ %def new_lcio_event @ <>= public :: lcio_event_init <>= subroutine lcio_event_init (evt, proc_id, event_id, run_id) type(lcio_event_t), intent(out) :: evt integer, intent(in), optional :: proc_id, event_id, run_id integer(c_int) :: pid, eid, rid pid = 0; if (present (proc_id)) pid = proc_id eid = 0; if (present (event_id)) eid = event_id rid = 0; if (present (run_id)) rid = run_id evt%obj = new_lcio_event (pid, eid, rid) evt%lccoll%obj = new_lccollection () end subroutine lcio_event_init @ %def lcio_event_init @ Destructor. <>= interface subroutine lcio_event_delete (evt_obj) bind(C) import type(c_ptr), value :: evt_obj end subroutine lcio_event_delete end interface @ %def lcio_event_delete @ Show event on screen. <>= interface subroutine dump_lcio_event (evt_obj) bind(C) import type(c_ptr), value :: evt_obj end subroutine dump_lcio_event end interface @ %def dump_lcio_event <>= public :: show_lcio_event <>= subroutine show_lcio_event (evt) type(lcio_event_t), intent(in) :: evt if (c_associated (evt%obj)) then call dump_lcio_event (evt%obj) else call msg_error ("LCIO event is not allocated.") end if end subroutine show_lcio_event @ %def show_lcio_event @ Put a single event to file. <>= interface subroutine lcio_event_to_file (evt_obj, filename) bind(C) import type(c_ptr), value :: evt_obj character(c_char), dimension(*), intent(in) :: filename end subroutine lcio_event_to_file end interface @ %def lcio_event_to_file <>= public :: write_lcio_event <>= subroutine write_lcio_event (evt, filename) type(lcio_event_t), intent(in) :: evt type(string_t), intent(in) :: filename call lcio_event_to_file (evt%obj, char (filename) // c_null_char) end subroutine write_lcio_event @ %def write_lcio_event -@ +@ Finalize: use the LCIO destructor. Also nullify the pointer explicitly, to +be on the safe side. <>= public :: lcio_event_final <>= subroutine lcio_event_final (evt) type(lcio_event_t), intent(inout) :: evt - call lcio_event_delete (evt%obj) + if (c_associated (evt%obj)) then + call lcio_event_delete (evt%obj) + evt%obj = c_null_ptr + evt%lccoll%obj = c_null_ptr + end if end subroutine lcio_event_final @ %def lcio_event_final +@ Nullify: do not call the destructor, just nullify the C pointer. There +should be another pointer associated with the object. +<>= + public :: lcio_event_nullify +<>= + subroutine lcio_event_nullify (evt) + type(lcio_event_t), intent(inout) :: evt + evt%obj = c_null_ptr + evt%lccoll%obj = c_null_ptr + end subroutine lcio_event_nullify + +@ %def lcio_event_nullify +@ Return the actual object as a C pointer. For use in the native C++ +interface only. +<>= + public :: lcio_event_get_c_ptr +<>= + function lcio_event_get_c_ptr (evt) result (p) + type(lcio_event_t), intent(in) :: evt + type(c_ptr) :: p + p = evt%obj + end function lcio_event_get_c_ptr + +@ %def lcio_event_get_c_ptr @ <>= interface subroutine lcio_set_weight (evt_obj, weight) bind(C) import type(c_ptr), value :: evt_obj real(c_double), value :: weight end subroutine lcio_set_weight end interface interface subroutine lcio_set_alpha_qcd (evt_obj, alphas) bind(C) import type(c_ptr), value :: evt_obj real(c_double), value :: alphas end subroutine lcio_set_alpha_qcd end interface interface subroutine lcio_set_scale (evt_obj, scale) bind(C) import type(c_ptr), value :: evt_obj real(c_double), value :: scale end subroutine lcio_set_scale end interface interface subroutine lcio_set_sqrts (evt_obj, sqrts) bind(C) import type(c_ptr), value :: evt_obj real(c_double), value :: sqrts end subroutine lcio_set_sqrts end interface interface subroutine lcio_set_xsec (evt_obj, xsec, xsec_err) bind(C) import type(c_ptr), value :: evt_obj real(c_double), value :: xsec, xsec_err end subroutine lcio_set_xsec end interface interface subroutine lcio_set_beam (evt_obj, pdg, beam) bind(C) import type(c_ptr), value :: evt_obj integer(c_int), value :: pdg, beam end subroutine lcio_set_beam end interface interface subroutine lcio_set_pol (evt_obj, pol1, pol2) bind(C) import type(c_ptr), value :: evt_obj real(c_double), value :: pol1, pol2 end subroutine lcio_set_pol end interface interface subroutine lcio_set_beam_file (evt_obj, file) bind(C) import type(c_ptr), value :: evt_obj character(len=1, kind=c_char), dimension(*), intent(in) :: file end subroutine lcio_set_beam_file end interface interface subroutine lcio_set_process_name (evt_obj, name) bind(C) import type(c_ptr), value :: evt_obj character(len=1, kind=c_char), dimension(*), intent(in) :: name end subroutine lcio_set_process_name end interface interface subroutine lcio_set_sqme (evt_obj, sqme) bind(C) import type(c_ptr), value :: evt_obj real(c_double), value :: sqme end subroutine lcio_set_sqme end interface interface subroutine lcio_set_alt_sqme (evt_obj, sqme, index) bind(C) import type(c_ptr), value :: evt_obj real(c_double), value :: sqme integer(c_int), value :: index end subroutine lcio_set_alt_sqme end interface interface subroutine lcio_set_alt_weight (evt_obj, weight, index) bind(C) import type(c_ptr), value :: evt_obj real(c_double), value :: weight integer(c_int), value :: index end subroutine lcio_set_alt_weight end interface @ %def lcio_set_weight lcio_set_alpha_qcd lcio_set_scale lcio_set_sqrts @ %def lcio_set_xsec lcio_set_beam lcio_set_pol @ %def lcio_set_beam_file lcio_set_process_name @ %def lcio_set_sqme lcio_set_alt_sqme lcio_set_alt_weight @ <>= public :: lcio_event_set_weight <>= subroutine lcio_event_set_weight (evt, weight) type(lcio_event_t), intent(inout) :: evt real(default), intent(in) :: weight call lcio_set_weight (evt%obj, real (weight, c_double)) end subroutine lcio_event_set_weight @ %def lcio_event_set_weight @ <>= public :: lcio_event_set_alpha_qcd <>= subroutine lcio_event_set_alpha_qcd (evt, alphas) type(lcio_event_t), intent(inout) :: evt real(default), intent(in) :: alphas call lcio_set_alpha_qcd (evt%obj, real (alphas, c_double)) end subroutine lcio_event_set_alpha_qcd @ %def lcio_event_set_alpha_qcd @ <>= public :: lcio_event_set_scale <>= subroutine lcio_event_set_scale (evt, scale) type(lcio_event_t), intent(inout) :: evt real(default), intent(in) :: scale call lcio_set_scale (evt%obj, real (scale, c_double)) end subroutine lcio_event_set_scale @ %def lcio_event_set_scale @ <>= public :: lcio_event_set_sqrts <>= subroutine lcio_event_set_sqrts (evt, sqrts) type(lcio_event_t), intent(inout) :: evt real(default), intent(in) :: sqrts call lcio_set_sqrts (evt%obj, real (sqrts, c_double)) end subroutine lcio_event_set_sqrts @ %def lcio_event_set_sqrts @ <>= public :: lcio_event_set_xsec <>= subroutine lcio_event_set_xsec (evt, xsec, xsec_err) type(lcio_event_t), intent(inout) :: evt real(default), intent(in) :: xsec, xsec_err call lcio_set_xsec (evt%obj, & real (xsec, c_double), real (xsec_err, c_double)) end subroutine lcio_event_set_xsec @ %def lcio_event_set_xsec @ <>= public :: lcio_event_set_beam <>= subroutine lcio_event_set_beam (evt, pdg, beam) type(lcio_event_t), intent(inout) :: evt integer, intent(in) :: pdg, beam call lcio_set_beam (evt%obj, & int (pdg, c_int), int (beam, c_int)) end subroutine lcio_event_set_beam @ %def lcio_event_set_beam @ <>= public :: lcio_event_set_polarization <>= subroutine lcio_event_set_polarization (evt, pol) type(lcio_event_t), intent(inout) :: evt real(default), intent(in), dimension(2) :: pol call lcio_set_pol (evt%obj, & real (pol(1), c_double), real (pol(2), c_double)) end subroutine lcio_event_set_polarization @ %def lcio_event_set_polarization @ <>= public :: lcio_event_set_beam_file <>= subroutine lcio_event_set_beam_file (evt, file) type(lcio_event_t), intent(inout) :: evt type(string_t), intent(in) :: file call lcio_set_beam_file (evt%obj, & char (file) // c_null_char) end subroutine lcio_event_set_beam_file @ %def lcio_event_set_beam_file @ <>= public :: lcio_event_set_process_name <>= subroutine lcio_event_set_process_name (evt, name) type(lcio_event_t), intent(inout) :: evt type(string_t), intent(in) :: name call lcio_set_process_name (evt%obj, & char (name) // c_null_char) end subroutine lcio_event_set_process_name @ %def lcio_event_set_process_name @ <>= public :: lcio_event_set_alt_sqme <>= subroutine lcio_event_set_alt_sqme (evt, sqme, index) type(lcio_event_t), intent(inout) :: evt real(default), intent(in) :: sqme integer, intent(in) :: index call lcio_set_alt_sqme (evt%obj, real (sqme, c_double), & int (index, c_int)) end subroutine lcio_event_set_alt_sqme @ %def lcio_event_set_alt_sqme @ <>= public :: lcio_event_set_sqme <>= subroutine lcio_event_set_sqme (evt, sqme) type(lcio_event_t), intent(inout) :: evt real(default), intent(in) :: sqme call lcio_set_sqme (evt%obj, real (sqme, c_double)) end subroutine lcio_event_set_sqme @ %def lcio_event_set_sqme @ <>= public :: lcio_event_set_alt_weight <>= subroutine lcio_event_set_alt_weight (evt, weight, index) type(lcio_event_t), intent(inout) :: evt real(default), intent(in) :: weight integer, intent(in) :: index call lcio_set_alt_weight (evt%obj, real (weight, c_double), & int (index, c_int)) end subroutine lcio_event_set_alt_weight @ %def lcio_event_set_alt_weight @ <>= interface subroutine lcio_event_add_collection & (evt_obj, lccoll_obj) bind(C) import type(c_ptr), value :: evt_obj, lccoll_obj end subroutine lcio_event_add_collection end interface @ %def lcio_event_add_collection <>= public :: lcio_event_add_coll <>= subroutine lcio_event_add_coll (evt) type(lcio_event_t), intent(inout) :: evt call lcio_event_add_collection (evt%obj, & evt%lccoll%obj) end subroutine lcio_event_add_coll @ %def lcio_event_add_coll @ \subsection{LCIO Particle} Particle objects have the obvious meaning. <>= public :: lcio_particle_t <>= type :: lcio_particle_t private type(c_ptr) :: obj end type lcio_particle_t @ %def lcio_particle_t @ Constructor. <>= interface type(c_ptr) function new_lcio_particle & (px, py, pz, pdg_id, mass, charge, status) bind(C) import integer(c_int), value :: pdg_id, status real(c_double), value :: px, py, pz, mass, charge end function new_lcio_particle end interface @ %def new_lcio_particle @ <>= interface subroutine add_particle_to_collection & (prt_obj, lccoll_obj) bind(C) import type(c_ptr), value :: prt_obj, lccoll_obj end subroutine add_particle_to_collection end interface @ %def add_particle_to_collection <>= public :: lcio_particle_add_to_evt_coll <>= subroutine lcio_particle_add_to_evt_coll & (lprt, evt) type(lcio_particle_t), intent(in) :: lprt type(lcio_event_t), intent(inout) :: evt call add_particle_to_collection (lprt%obj, evt%lccoll%obj) end subroutine lcio_particle_add_to_evt_coll @ %def lcio_particle_to_collection @ <>= public :: lcio_particle_init <>= subroutine lcio_particle_init (prt, p, pdg, charge, status) type(lcio_particle_t), intent(out) :: prt type(vector4_t), intent(in) :: p real(default), intent(in) :: charge real(default) :: mass real(default) :: px, py, pz integer, intent(in) :: pdg, status px = vector4_get_component (p, 1) py = vector4_get_component (p, 2) pz = vector4_get_component (p, 3) mass = p**1 prt%obj = new_lcio_particle (real (px, c_double), real (py, c_double), & real (pz, c_double), int (pdg, c_int), & real (mass, c_double), real (charge, c_double), int (status, c_int)) end subroutine lcio_particle_init @ %def lcio_particle_init @ Set the particle color flow. <>= interface subroutine lcio_set_color_flow (prt_obj, col1, col2) bind(C) import type(c_ptr), value :: prt_obj integer(c_int), value :: col1, col2 end subroutine lcio_set_color_flow end interface @ %def lcio_set_color_flow @ Set the particle color. Either from a [[color_t]] object or directly from a pair of integers. <>= interface lcio_particle_set_color module procedure lcio_particle_set_color_col module procedure lcio_particle_set_color_int end interface lcio_particle_set_color <>= public :: lcio_particle_set_color <>= subroutine lcio_particle_set_color_col (prt, col) type(lcio_particle_t), intent(inout) :: prt type(color_t), intent(in) :: col integer(c_int), dimension(2) :: c c(1) = col%get_col () c(2) = col%get_acl () if (c(1) /= 0 .or. c(2) /= 0) then call lcio_set_color_flow (prt%obj, c(1), c(2)) end if end subroutine lcio_particle_set_color_col subroutine lcio_particle_set_color_int (prt, col) type(lcio_particle_t), intent(inout) :: prt integer, dimension(2), intent(in) :: col integer(c_int), dimension(2) :: c c = col if (c(1) /= 0 .or. c(2) /= 0) then call lcio_set_color_flow (prt%obj, c(1), c(2)) end if end subroutine lcio_particle_set_color_int @ %def lcio_particle_set_color @ Return the particle color as a two-dimensional array (color, anticolor). <>= interface integer(c_int) function lcio_particle_flow (prt_obj, col_index) bind(C) use iso_c_binding !NODEP! type(c_ptr), value :: prt_obj integer(c_int), value :: col_index end function lcio_particle_flow end interface @ %def lcio_particle_flow <>= public :: lcio_particle_get_flow <>= function lcio_particle_get_flow (prt) result (col) integer, dimension(2) :: col type(lcio_particle_t), intent(in) :: prt col(1) = lcio_particle_flow (prt%obj, 0_c_int) col(2) = - lcio_particle_flow (prt%obj, 1_c_int) end function lcio_particle_get_flow @ %def lcio_particle_get_flow @ Return the four-momentum of a LCIO particle. <>= interface real(c_double) function lcio_three_momentum (prt_obj, p_index) bind(C) use iso_c_binding !NODEP! type(c_ptr), value :: prt_obj integer(c_int), value :: p_index end function lcio_three_momentum end interface @ %def lcio_three_momentum <>= interface real(c_double) function lcio_energy (prt_obj) bind(C) import type(c_ptr), intent(in), value :: prt_obj end function lcio_energy end interface @ %def lcio_energy <>= public :: lcio_particle_get_momentum <>= function lcio_particle_get_momentum (prt) result (p) type(vector4_t) :: p type(lcio_particle_t), intent(in) :: prt real(default) :: E, px, py, pz E = lcio_energy (prt%obj) px = lcio_three_momentum (prt%obj, 0_c_int) py = lcio_three_momentum (prt%obj, 1_c_int) pz = lcio_three_momentum (prt%obj, 2_c_int) p = vector4_moving ( E, vector3_moving ([ px, py, pz ])) end function lcio_particle_get_momentum @ %def lcio_particle_get_momentum @ Return the invariant mass squared of the particle object. LCIO stores the signed invariant mass (no squaring). <>= interface function lcio_mass (prt_obj) result (mass) bind(C) import real(c_double) :: mass type(c_ptr), value :: prt_obj end function lcio_mass end interface @ %def lcio_mass <>= public :: lcio_particle_get_mass_squared <>= function lcio_particle_get_mass_squared (prt) result (m2) real(default) :: m2 type(lcio_particle_t), intent(in) :: prt real(default) :: m m = lcio_mass (prt%obj) m2 = sign (m**2, m) end function lcio_particle_get_mass_squared @ %def lcio_particle_get_mass_squared @ Return vertex and production time of a LCIO particle. <>= interface real(c_double) function lcio_vtx_x (prt) bind(C) import type(c_ptr), value :: prt end function lcio_vtx_x end interface interface real(c_double) function lcio_vtx_y (prt) bind(C) import type(c_ptr), value :: prt end function lcio_vtx_y end interface interface real(c_double) function lcio_vtx_z (prt) bind(C) import type(c_ptr), value :: prt end function lcio_vtx_z end interface interface real(c_float) function lcio_prt_time (prt) bind(C) import type(c_ptr), value :: prt end function lcio_prt_time end interface @ @ (Decay) times in LCIO are in nanoseconds, so they need to get converted to mm for the internal format. <>= public :: lcio_particle_get_vertex public :: lcio_particle_get_time <>= function lcio_particle_get_vertex (prt) result (vtx) type(vector3_t) :: vtx type(lcio_particle_t), intent(in) :: prt real(default) :: vx, vy, vz vx = lcio_vtx_x (prt%obj) vy = lcio_vtx_y (prt%obj) vz = lcio_vtx_z (prt%obj) vtx = vector3_moving ([vx, vy, vz]) end function lcio_particle_get_vertex function lcio_particle_get_time (prt) result (time) real(default) :: time type(lcio_particle_t), intent(in) :: prt time = lcio_prt_time (prt%obj) time = time / ns_per_mm end function lcio_particle_get_time @ %def lcio_particle_get_vertex lcio_particle_get_time @ \subsection{Polarization} For polarization there is a three-component float entry foreseen in the LCIO format. Completely generic density matrices can in principle be attached to events as float vectors added to [[LCCollection]] of the [[LCEvent]]. This is not yet implemented currently. Here, we restrict ourselves to the same implementation as in HepMC format: we use two entries as the polarization angles, while the first entry gives the degree of polarization (something not specified in the HepMC format). \emph{For massive vector bosons, we arbitrarily choose the convention that the longitudinal (zero) helicity state is mapped to the theta angle $\pi/2$. This works under the condition that helicity is projected onto one of the basis states.} <>= interface subroutine lcio_particle_set_spin (prt_obj, s1, s2, s3) bind(C) import type(c_ptr), value :: prt_obj real(c_double), value :: s1, s2, s3 end subroutine lcio_particle_set_spin end interface @ %def lcio_particle_set_spin @ <>= public :: lcio_polarization_init <>= interface lcio_polarization_init module procedure lcio_polarization_init_pol module procedure lcio_polarization_init_hel module procedure lcio_polarization_init_int end interface <>= subroutine lcio_polarization_init_pol (prt, pol) type(lcio_particle_t), intent(inout) :: prt type(polarization_t), intent(in) :: pol real(default) :: r, theta, phi if (pol%is_polarized ()) then call pol%to_angles (r, theta, phi) call lcio_particle_set_spin (prt%obj, & real(r, c_double), real (theta, c_double), real (phi, c_double)) end if end subroutine lcio_polarization_init_pol subroutine lcio_polarization_init_hel (prt, hel) type(lcio_particle_t), intent(inout) :: prt type(helicity_t), intent(in) :: hel integer, dimension(2) :: h if (hel%is_defined ()) then h = hel%to_pair () select case (h(1)) case (1:) call lcio_particle_set_spin (prt%obj, 1._c_double, & 0._c_double, 0._c_double) case (:-1) call lcio_particle_set_spin (prt%obj, 1._c_double, & real (pi, c_double), 0._c_double) case (0) call lcio_particle_set_spin (prt%obj, 1._c_double, & real (pi/2, c_double), 0._c_double) end select end if end subroutine lcio_polarization_init_hel subroutine lcio_polarization_init_int (prt, hel) type(lcio_particle_t), intent(inout) :: prt integer, intent(in) :: hel call lcio_particle_set_spin (prt%obj, 0._c_double, & 0._c_double, real (hel, c_double)) end subroutine lcio_polarization_init_int @ %def lcio_polarization_init @ Recover polarization from LCIO particle (with the abovementioned deficiencies). <>= interface function lcio_polarization_degree (prt_obj) result (degree) bind(C) import real(c_double) :: degree type(c_ptr), value :: prt_obj end function lcio_polarization_degree end interface interface function lcio_polarization_theta (prt_obj) result (theta) bind(C) import real(c_double) :: theta type(c_ptr), value :: prt_obj end function lcio_polarization_theta end interface interface function lcio_polarization_phi (prt_obj) result (phi) bind(C) import real(c_double) :: phi type(c_ptr), value :: prt_obj end function lcio_polarization_phi end interface @ %def lcio_polarization_degree lcio_polarization_theta lcio_polarization_phi <>= public :: lcio_particle_to_pol <>= subroutine lcio_particle_to_pol (prt, flv, pol) type(lcio_particle_t), intent(in) :: prt type(flavor_t), intent(in) :: flv type(polarization_t), intent(out) :: pol real(default) :: degree, theta, phi degree = lcio_polarization_degree (prt%obj) theta = lcio_polarization_theta (prt%obj) phi = lcio_polarization_phi (prt%obj) call pol%init_angles (flv, degree, theta, phi) end subroutine lcio_particle_to_pol @ %def lcio_polarization_to_pol @ Recover helicity. Here, $\phi$ and [[degree]] is ignored and only the sign of $\cos\theta$ is relevant, mapped to positive/negative helicity. <>= public :: lcio_particle_to_hel <>= subroutine lcio_particle_to_hel (prt, flv, hel) type(lcio_particle_t), intent(in) :: prt type(flavor_t), intent(in) :: flv type(helicity_t), intent(out) :: hel real(default) :: theta integer :: hmax theta = lcio_polarization_theta (prt%obj) hmax = flv%get_spin_type () / 2 call hel%init (sign (hmax, nint (cos (theta)))) end subroutine lcio_particle_to_hel @ %def lcio_particle_to_hel @ Set the vertex of a particle. <>= interface subroutine lcio_particle_set_vertex (prt_obj, vx, vy, vz) bind(C) import type(c_ptr), value :: prt_obj real(c_double), value :: vx, vy, vz end subroutine lcio_particle_set_vertex end interface interface subroutine lcio_particle_set_time (prt_obj, t) bind(C) import type(c_ptr), value :: prt_obj real(c_float), value :: t end subroutine lcio_particle_set_time end interface @ %def lcio_particle_set_vertex lcio_particle_set_time @ <>= public :: lcio_particle_set_vtx <>= subroutine lcio_particle_set_vtx (prt, vtx) type(lcio_particle_t), intent(inout) :: prt type(vector3_t), intent(in) :: vtx call lcio_particle_set_vertex (prt%obj, real(vtx%p(1), c_double), & real(vtx%p(2), c_double), real(vtx%p(3), c_double)) end subroutine lcio_particle_set_vtx @ %def lcio_particle_set_vtx @ Times in LCIO are in nanoseconds, not in mm, so need to be converted. <>= public :: lcio_particle_set_t <>= subroutine lcio_particle_set_t (prt, t) type(lcio_particle_t), intent(inout) :: prt real(default), intent(in) :: t real(default) :: ns_from_t_mm ns_from_t_mm = ns_per_mm * t call lcio_particle_set_time (prt%obj, real(ns_from_t_mm, c_float)) end subroutine lcio_particle_set_t @ %def lcio_particle_set_t @ <>= interface subroutine lcio_particle_add_parent (prt_obj1, prt_obj2) bind(C) import type(c_ptr), value :: prt_obj1, prt_obj2 end subroutine lcio_particle_add_parent end interface @ %def lcio_particle_add_parent <>= public :: lcio_particle_set_parent <>= subroutine lcio_particle_set_parent (daughter, parent) type(lcio_particle_t), intent(inout) :: daughter, parent call lcio_particle_add_parent (daughter%obj, parent%obj) end subroutine lcio_particle_set_parent @ %def lcio_particle_set_parent @ <>= interface integer(c_int) function lcio_particle_get_generator_status & (prt_obj) bind(C) import type(c_ptr), value :: prt_obj end function lcio_particle_get_generator_status end interface @ %def lcio_particle_get_generator_status <>= public :: lcio_particle_get_status <>= function lcio_particle_get_status (lptr) result (status) integer :: status type(lcio_particle_t), intent(in) :: lptr status = lcio_particle_get_generator_status (lptr%obj) end function lcio_particle_get_status @ %def lcio_particle_get_status @ Getting the PDG code. <>= interface integer(c_int) function lcio_particle_get_pdg_code (prt_obj) bind(C) import type(c_ptr), value :: prt_obj end function lcio_particle_get_pdg_code end interface @ %def lcio_particle_get_pdg_code @ <>= public :: lcio_particle_get_pdg <>= function lcio_particle_get_pdg (lptr) result (pdg) integer :: pdg type(lcio_particle_t), intent(in) :: lptr pdg = lcio_particle_get_pdg_code (lptr%obj) end function lcio_particle_get_pdg @ %def lcio_particle_get_pdg @ Obtaining the number of parents and daughters of an LCIO particle. <>= interface integer(c_int) function lcio_n_parents (prt_obj) bind(C) import type(c_ptr), value :: prt_obj end function lcio_n_parents end interface @ %def lcio_n_parents @ <>= interface integer(c_int) function lcio_n_daughters (prt_obj) bind(C) import type(c_ptr), value :: prt_obj end function lcio_n_daughters end interface @ %def lcio_n_daughters @ <>= public :: lcio_particle_get_n_parents <>= function lcio_particle_get_n_parents (lptr) result (n_parents) integer :: n_parents type(lcio_particle_t), intent(in) :: lptr n_parents = lcio_n_parents (lptr%obj) end function lcio_particle_get_n_parents @ %def lcio_particle_get_n_parents @ <>= public :: lcio_particle_get_n_children <>= function lcio_particle_get_n_children (lptr) result (n_children) integer :: n_children type(lcio_particle_t), intent(in) :: lptr n_children = lcio_n_daughters (lptr%obj) end function lcio_particle_get_n_children @ %def lcio_particle_get_n_children @ This provides access from the LCIO event [[lcio_event_t]] to the array entries of the parent and daughter arrays of the LCIO particles. <>= interface integer(c_int) function lcio_event_parent_k & (evt_obj, num_part, k_parent) bind (C) use iso_c_binding !NODEP! type(c_ptr), value :: evt_obj integer(c_int), value :: num_part, k_parent end function lcio_event_parent_k end interface @ %def lcio_event_parent_k <>= interface integer(c_int) function lcio_event_daughter_k & (evt_obj, num_part, k_daughter) bind (C) use iso_c_binding !NODEP! type(c_ptr), value :: evt_obj integer(c_int), value :: num_part, k_daughter end function lcio_event_daughter_k end interface @ %def lcio_event_daughter_k @ <>= public :: lcio_get_n_parents <>= function lcio_get_n_parents (evt, num_part, k_parent) result (index_parent) type(lcio_event_t), intent(in) :: evt integer, intent(in) :: num_part, k_parent integer :: index_parent index_parent = lcio_event_parent_k (evt%obj, int (num_part, c_int), & int (k_parent, c_int)) end function lcio_get_n_parents @ %def lcio_get_n_parents @ <>= public :: lcio_get_n_children <>= function lcio_get_n_children (evt, num_part, k_daughter) result (index_daughter) type(lcio_event_t), intent(in) :: evt integer, intent(in) :: num_part, k_daughter integer :: index_daughter index_daughter = lcio_event_daughter_k (evt%obj, int (num_part, c_int), & int (k_daughter, c_int)) end function lcio_get_n_children @ %def lcio_get_n_children @ \subsection{LCIO Writer type} There is a specific LCIO Writer type for handling the output of LCEventImpl objects (i.e., Monte Carlo event samples) to file. Opening the file is done by the constructor, closing by the destructor. <>= public :: lcio_writer_t <>= type :: lcio_writer_t private type(c_ptr) :: obj end type lcio_writer_t @ %def lcio_writer_t @ Constructor for an output associated to a file. <>= interface type(c_ptr) function open_lcio_writer_new (filename, complevel) bind(C) import character(c_char), dimension(*), intent(in) :: filename integer(c_int), intent(in) :: complevel end function open_lcio_writer_new end interface @ %def open_lcio_writer_now <>= public :: lcio_writer_open_out <>= subroutine lcio_writer_open_out (lcio_writer, filename) type(lcio_writer_t), intent(out) :: lcio_writer type(string_t), intent(in) :: filename lcio_writer%obj = open_lcio_writer_new (char (filename) // & c_null_char, 9_c_int) end subroutine lcio_writer_open_out @ %def lcio_writer_open_out @ Destructor: <>= interface subroutine lcio_writer_delete (io_obj) bind(C) import type(c_ptr), value :: io_obj end subroutine lcio_writer_delete end interface @ %def lcio_writer_delete <>= public :: lcio_writer_close <>= subroutine lcio_writer_close (lciowriter) type(lcio_writer_t), intent(inout) :: lciowriter call lcio_writer_delete (lciowriter%obj) end subroutine lcio_writer_close @ %def lcio_writer_close @ Write a single event to the LCIO writer. <>= interface subroutine lcio_write_event (io_obj, evt_obj) bind(C) import type(c_ptr), value :: io_obj, evt_obj end subroutine lcio_write_event end interface @ %def lcio_write_event <>= public :: lcio_event_write <>= subroutine lcio_event_write (wrt, evt) type(lcio_writer_t), intent(inout) :: wrt type(lcio_event_t), intent(in) :: evt call lcio_write_event (wrt%obj, evt%obj) end subroutine lcio_event_write @ %def lcio_event_write @ \subsection{LCIO Reader type} There is a specific LCIO Reader type for handling the input of LCEventImpl objects (i.e., Monte Carlo event samples) from file. Opening the file is done by the constructor, closing by the destructor. <>= public :: lcio_reader_t <>= type :: lcio_reader_t private type(c_ptr) :: obj end type lcio_reader_t @ %def lcio_reader_t @ Constructor for an output associated to a file. <>= interface type(c_ptr) function open_lcio_reader (filename) bind(C) import character(c_char), dimension(*), intent(in) :: filename end function open_lcio_reader end interface @ %def open_lcio_reader <>= public :: lcio_open_file <>= subroutine lcio_open_file (lcio_reader, filename) type(lcio_reader_t), intent(out) :: lcio_reader type(string_t), intent(in) :: filename lcio_reader%obj = open_lcio_reader (char (filename) // c_null_char) end subroutine lcio_open_file @ %def lcio_open_file @ Destructor: <>= interface subroutine lcio_reader_delete (io_obj) bind(C) import type(c_ptr), value :: io_obj end subroutine lcio_reader_delete end interface @ %def lcio_reader_delete <>= public :: lcio_reader_close <>= subroutine lcio_reader_close (lcioreader) type(lcio_reader_t), intent(inout) :: lcioreader call lcio_reader_delete (lcioreader%obj) end subroutine lcio_reader_close @ %def lcio_reader_close @ @ Read a single event from the event file. Return true if successful. <>= interface type(c_ptr) function read_lcio_event (io_obj) bind(C) import type(c_ptr), value :: io_obj end function read_lcio_event end interface @ %def read_lcio_event <>= public :: lcio_read_event <>= subroutine lcio_read_event (lcrdr, evt, ok) type(lcio_reader_t), intent(inout) :: lcrdr type(lcio_event_t), intent(out) :: evt logical, intent(out) :: ok evt%obj = read_lcio_event (lcrdr%obj) ok = c_associated (evt%obj) end subroutine lcio_read_event @ %def lcio_read_event @ Get the event index. <>= interface integer(c_int) function lcio_event_get_event_number (evt_obj) bind(C) import type(c_ptr), value :: evt_obj end function lcio_event_get_event_number end interface @ %def lcio_event_get_event_number <>= public :: lcio_event_get_event_index <>= function lcio_event_get_event_index (evt) result (i_evt) integer :: i_evt type(lcio_event_t), intent(in) :: evt i_evt = lcio_event_get_event_number (evt%obj) end function lcio_event_get_event_index @ %def lcio_event_get_event_index @ Extract the process ID. This is stored (at the moment abusively) in the RUN ID as well as in an additional event parameter. <>= interface integer(c_int) function lcio_event_signal_process_id (evt_obj) bind(C) import type(c_ptr), value :: evt_obj end function lcio_event_signal_process_id end interface @ %def lcio_event_signal_process_id <>= public :: lcio_event_get_process_id <>= function lcio_event_get_process_id (evt) result (i_proc) integer :: i_proc type(lcio_event_t), intent(in) :: evt i_proc = lcio_event_signal_process_id (evt%obj) end function lcio_event_get_process_id @ %def lcio_event_get_process_id @ Number of particles in an LCIO event. <>= interface integer(c_int) function lcio_event_get_n_particles (evt_obj) bind(C) import type(c_ptr), value :: evt_obj end function lcio_event_get_n_particles end interface @ %def lcio_event_get_n_particles <>= @ <>= public :: lcio_event_get_n_tot <>= function lcio_event_get_n_tot (evt) result (n_tot) integer :: n_tot type(lcio_event_t), intent(in) :: evt n_tot = lcio_event_get_n_particles (evt%obj) end function lcio_event_get_n_tot @ %def lcio_event_get_n_tot @ Extracting $\alpha_s$ and the scale. <>= interface function lcio_event_get_alpha_qcd (evt_obj) result (as) bind(C) import real(c_double) :: as type(c_ptr), value :: evt_obj end function lcio_event_get_alpha_qcd end interface interface function lcio_event_get_scale (evt_obj) result (scale) bind(C) import real(c_double) :: scale type(c_ptr), value :: evt_obj end function lcio_event_get_scale end interface @ %def lcio_event_get_alpha_qcd lcio_event_get_scale @ <>= public :: lcio_event_get_alphas <>= function lcio_event_get_alphas (evt) result (as) type(lcio_event_t), intent(in) :: evt real(default) :: as as = lcio_event_get_alpha_qcd (evt%obj) end function lcio_event_get_alphas @ %def lcio_event_get_alphas @ <>= public :: lcio_event_get_scaleval <>= function lcio_event_get_scaleval (evt) result (scale) type(lcio_event_t), intent(in) :: evt real(default) :: scale scale = lcio_event_get_scale (evt%obj) end function lcio_event_get_scaleval @ %def lcio_event_get_scaleval @ Extracting particles by index from an LCIO event. <>= interface type(c_ptr) function lcio_event_particle_k (evt_obj, k) bind(C) import type(c_ptr), value :: evt_obj integer(c_int), value :: k end function lcio_event_particle_k end interface @ %def lcio_event_particle_k @ <>= public :: lcio_event_get_particle <>= function lcio_event_get_particle (evt, n) result (prt) type(lcio_event_t), intent(in) :: evt integer, intent(in) :: n type(lcio_particle_t) :: prt prt%obj = lcio_event_particle_k (evt%obj, int (n, c_int)) end function lcio_event_get_particle @ %def lcio_event_get_particle @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[lcio_interface_ut.f90]]>>= <> module lcio_interface_ut use unit_tests use lcio_interface_uti <> <> contains <> end module lcio_interface_ut @ %def lcio_interface_ut @ <<[[lcio_interface_uti.f90]]>>= <> module lcio_interface_uti <> <> use io_units use lorentz use flavors use colors use polarizations use lcio_interface <> <> contains <> end module lcio_interface_uti @ %def lcio_interface_ut @ API: driver for the unit tests below. <>= public :: lcio_interface_test <>= subroutine lcio_interface_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine lcio_interface_test @ %def lcio_interface_test @ <>= call test (lcio_interface_1, "lcio_interface_1", & "check LCIO interface", & u, results) <>= public :: lcio_interface_1 <>= subroutine lcio_interface_1 (u) use physics_defs, only: VECTOR use model_data, only: field_data_t integer, intent(in) :: u integer :: u_file, iostat type(lcio_event_t) :: evt type(lcio_particle_t) :: prt1, prt2, prt3, prt4, prt5, prt6, prt7, prt8 type(flavor_t) :: flv type(color_t) :: col type(polarization_t) :: pol type(field_data_t), target :: photon_data character(220) :: buffer write (u, "(A)") "* Test output: LCIO interface" write (u, "(A)") "* Purpose: test LCIO interface" write (u, "(A)") write (u, "(A)") "* Initialization" write (u, "(A)") ! Initialize a photon flavor object and some polarization call photon_data%init (var_str ("PHOTON"), 22) call photon_data%set (spin_type=VECTOR) call photon_data%freeze () call flv%init (photon_data) call pol%init_angles & (flv, 0.6_default, 1._default, 0.5_default) ! Event initialization call lcio_event_init (evt, 20, 1, 42) write (u, "(A)") "* p -> q splitting" write (u, "(A)") ! $p\to q$ splittings call particle_init (prt1, & 0._default, 0._default, 7000._default, 7000._default, & 2212, 1._default, 3) call particle_init (prt2, & 0._default, 0._default,-7000._default, 7000._default, & 2212, 1._default, 3) call particle_init (prt3, & .750_default, -1.569_default, 32.191_default, 32.238_default, & 1, -1._default/3._default, 3) call color_init_from_array (col, [501]) call lcio_particle_set_color (prt3, col) call lcio_particle_set_parent (prt3, prt1) call lcio_particle_set_parent (prt3, prt2) call particle_init (prt4, & -3.047_default, -19._default, -54.629_default, 57.920_default, & -2, -2._default/3._default, 3) call color_init_from_array (col, [-501]) call lcio_particle_set_color (prt4, col) call lcio_particle_set_parent (prt4, prt1) call lcio_particle_set_parent (prt4, prt2) write (u, "(A)") "* Hard interaction" write (u, "(A)") ! Hard interaction call particle_init (prt6, & -3.813_default, 0.113_default, -1.833_default, 4.233_default, & 22, 0._default, 1) call lcio_polarization_init (prt6, pol) call particle_init (prt5, & 1.517_default, -20.68_default, -20.605_default, 85.925_default, & -24, -1._default, 3) call lcio_particle_set_parent (prt5, prt3) call lcio_particle_set_parent (prt5, prt4) call lcio_particle_set_parent (prt6, prt3) call lcio_particle_set_parent (prt6, prt4) ! $W^-$ decay call particle_init (prt7, & -2.445_default, 28.816_default, 6.082_default, 29.552_default, & 1, -1._default/3._default, 1) call particle_init (prt8, & 3.962_default, -49.498_default, -26.687_default, 56.373_default, & -2, -2._default/3._default, 1) call lcio_particle_set_t (prt7, 0.12_default) call lcio_particle_set_t (prt8, 0.12_default) call lcio_particle_set_vtx & (prt7, vector3_moving ([-0.3_default, 0.05_default, 0.004_default])) call lcio_particle_set_vtx & (prt8, vector3_moving ([-0.3_default, 0.05_default, 0.004_default])) call lcio_particle_set_parent (prt7, prt5) call lcio_particle_set_parent (prt8, prt5) call lcio_particle_add_to_evt_coll (prt1, evt) call lcio_particle_add_to_evt_coll (prt2, evt) call lcio_particle_add_to_evt_coll (prt3, evt) call lcio_particle_add_to_evt_coll (prt4, evt) call lcio_particle_add_to_evt_coll (prt5, evt) call lcio_particle_add_to_evt_coll (prt6, evt) call lcio_particle_add_to_evt_coll (prt7, evt) call lcio_particle_add_to_evt_coll (prt8, evt) call lcio_event_add_coll (evt) ! Event output write (u, "(A)") "Writing in ASCII form to file 'lcio_test.slcio'" write (u, "(A)") call write_lcio_event (evt, var_str ("lcio_test.slcio")) write (u, "(A)") "Writing completed" write (u, "(A)") write (u, "(A)") "* File contents:" write (u, "(A)") u_file = free_unit () open (u_file, file = "lcio_test.slcio", & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (trim (buffer) == "") cycle if (buffer(1:12) == " - timestamp") buffer = "[...]" if (buffer(1:6) == " date:") buffer = "[...]" if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Cleanup" write (u, "(A)") ! Wrapup ! call pol%final () call lcio_event_final (evt) write (u, "(A)") write (u, "(A)") "* Test output end: lcio_interface_1" contains subroutine particle_init & (prt, px, py, pz, E, pdg, charge, status) type(lcio_particle_t), intent(out) :: prt real(default), intent(in) :: px, py, pz, E, charge integer, intent(in) :: pdg, status type(vector4_t) :: p p = vector4_moving (E, vector3_moving ([px, py, pz])) call lcio_particle_init (prt, p, pdg, charge, status) end subroutine particle_init end subroutine lcio_interface_1 @ %def lcio_interface_1 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{HEP Common and Events} This is a separate module that manages data exchange between the common blocks and [[event_t]] objects. We separate this from the previous module in order to avoid a circular module dependency. It also contains the functions necessary for communication between [[hepmc_event_t]] and [[event_t]] or [[lcio_event_t]] and [[event_t]] as well as [[particle_set_t]] and [[particle_t]] objects. <<[[hep_events.f90]]>>= <> module hep_events <> <> use system_dependencies, only: HEPMC2_AVAILABLE use system_dependencies, only: HEPMC3_AVAILABLE use diagnostics use lorentz use numeric_utils use flavors use colors use helicities use polarizations use model_data use subevents, only: PRT_BEAM, PRT_INCOMING, PRT_OUTGOING use subevents, only: PRT_UNDEFINED use subevents, only: PRT_VIRTUAL, PRT_RESONANT, PRT_BEAM_REMNANT use particles use hep_common use hepmc_interface use lcio_interface use event_base <> <> contains <> end module hep_events @ %def hep_events @ \subsection{Data Transfer: events} Fill the HEPEUP block, given a \whizard\ event object. <>= public :: hepeup_from_event <>= subroutine hepeup_from_event & (event, keep_beams, keep_remnants, process_index) class(generic_event_t), intent(in), target :: event logical, intent(in), optional :: keep_beams logical, intent(in), optional :: keep_remnants integer, intent(in), optional :: process_index type(particle_set_t), pointer :: particle_set real(default) :: scale, alpha_qcd if (event%has_valid_particle_set ()) then particle_set => event%get_particle_set_ptr () call hepeup_from_particle_set (particle_set, keep_beams, keep_remnants) if (present (process_index)) then call hepeup_set_event_parameters (proc_id = process_index) end if scale = event%get_fac_scale () if (.not. vanishes (scale)) then call hepeup_set_event_parameters (scale = scale) end if alpha_qcd = event%get_alpha_s () if (.not. vanishes (alpha_qcd)) then call hepeup_set_event_parameters (alpha_qcd = alpha_qcd) end if if (event%weight_prc_is_known ()) then call hepeup_set_event_parameters (weight = event%get_weight_prc ()) end if else call msg_bug ("HEPEUP: event incomplete") end if end subroutine hepeup_from_event @ %def hepeup_from_event @ Reverse. Note: The current implementation sets the particle set of the hard process and is therefore not useful if the event on file is dressed. This should be reconsidered. Note: setting of scale or alpha is not yet supported by the [[event_t]] object. Ticket \#628. <>= public :: hepeup_to_event <>= subroutine hepeup_to_event & (event, fallback_model, process_index, recover_beams, & use_alpha_s, use_scale) class(generic_event_t), intent(inout), target :: event class(model_data_t), intent(in), target :: fallback_model integer, intent(out), optional :: process_index logical, intent(in), optional :: recover_beams logical, intent(in), optional :: use_alpha_s logical, intent(in), optional :: use_scale class(model_data_t), pointer :: model real(default) :: weight, scale, alpha_qcd type(particle_set_t) :: particle_set model => event%get_model_ptr () call hepeup_to_particle_set & (particle_set, recover_beams, model, fallback_model) call event%set_hard_particle_set (particle_set) call particle_set%final () if (present (process_index)) then call hepeup_get_event_parameters (proc_id = process_index) end if call hepeup_get_event_parameters (weight = weight, & scale = scale, alpha_qcd = alpha_qcd) call event%set_weight_ref (weight) if (present (use_alpha_s)) then if (use_alpha_s .and. alpha_qcd > 0) & call event%set_alpha_qcd_forced (alpha_qcd) end if if (present (use_scale)) then if (use_scale .and. scale > 0) & call event%set_scale_forced (scale) end if end subroutine hepeup_to_event @ %def hepeup_to_event @ Fill the HEPEVT (event) common block. The [[i_evt]] argument overrides the index stored in the [[event]] object. <>= public :: hepevt_from_event <>= subroutine hepevt_from_event & (event, process_index, i_evt, keep_beams, keep_remnants, & ensure_order, fill_hepev4) class(generic_event_t), intent(in), target :: event integer, intent(in), optional :: i_evt, process_index logical, intent(in), optional :: keep_beams logical, intent(in), optional :: keep_remnants logical, intent(in), optional :: ensure_order logical, intent(in), optional :: fill_hepev4 type(particle_set_t), pointer :: particle_set real(default) :: alpha_qcd, scale if (event%has_valid_particle_set ()) then particle_set => event%get_particle_set_ptr () call hepevt_from_particle_set (particle_set, keep_beams, & keep_remnants, ensure_order, fill_hepev4) if (present (process_index)) then call hepevt_set_event_parameters (proc_id = process_index) end if if (event%weight_prc_is_known ()) then call hepevt_set_event_parameters (weight = event%get_weight_prc ()) end if if (event%sqme_prc_is_known ()) then call hepevt_set_event_parameters & (function_value = event%get_sqme_prc ()) end if scale = event%get_fac_scale () if (.not. vanishes (scale)) then call hepevt_set_event_parameters (scale = scale) end if alpha_qcd = event%get_alpha_s () if (.not. vanishes (alpha_qcd)) then call hepevt_set_event_parameters (alpha_qcd = alpha_qcd) end if if (present (i_evt)) then call hepevt_set_event_parameters (i_evt = i_evt) else if (event%has_index ()) then call hepevt_set_event_parameters (i_evt = event%get_index ()) else call hepevt_set_event_parameters (i_evt = 0) end if else call msg_bug ("HEPEVT: event incomplete") end if end subroutine hepevt_from_event @ %def hepevt_from_event @ \subsubsection{HepMC format} The master output function fills a HepMC GenEvent object that is already initialized, but has no vertices in it. We first set up the vertex lists and enter the vertices into the HepMC event. Then, we assign first all incoming particles and then all outgoing particles to their associated vertices. Particles which have neither parent nor children entries (this should not happen) are dropped. Finally, we insert the beam particles. If there are none, use the incoming particles instead. @ Transform a particle into a [[hepmc_particle]] object, including color and polarization. The HepMC status is equivalent to the HEPEVT status, in particular: 0 = null entry, 1 = physical particle, 2 = decayed/fragmented SM hadron, tau or muon, 3 = other unphysical particle entry, 4 = incoming particles, 11 = intermediate resonance such as squarks. The use of 11 for intermediate resonances is as done by HERWIG, see http://herwig.hepforge.org/trac/wiki/FaQs. <>= subroutine particle_to_hepmc (prt, hprt) type(particle_t), intent(in) :: prt type(hepmc_particle_t), intent(out) :: hprt integer :: hepmc_status select case (prt%get_status ()) case (PRT_UNDEFINED) hepmc_status = 0 case (PRT_OUTGOING) hepmc_status = 1 case (PRT_BEAM) hepmc_status = 4 case (PRT_RESONANT) if (abs(prt%get_pdg()) == 13 .or. & abs(prt%get_pdg()) == 15) then hepmc_status = 2 else hepmc_status = 11 end if case default hepmc_status = 3 end select call hepmc_particle_init (hprt, & prt%get_momentum (), prt%get_pdg (), & hepmc_status) if (HEPMC2_AVAILABLE) then call hepmc_particle_set_color (hprt, prt%get_color ()) select case (prt%get_polarization_status ()) case (PRT_DEFINITE_HELICITY) call hepmc_particle_set_polarization (hprt, & prt%get_helicity ()) case (PRT_GENERIC_POLARIZATION) call hepmc_particle_set_polarization (hprt, & prt%get_polarization ()) end select end if end subroutine particle_to_hepmc @ %def particle_to_hepmc @ For HepMC3, a HepMC particle needs first to be attached to a vertex and an event before non-intrinsic particle properties (color flow and helicity) could be set. <>= public :: hepmc_event_from_particle_set <>= subroutine hepmc_event_from_particle_set & (evt, particle_set, cross_section, error) type(hepmc_event_t), intent(inout) :: evt type(particle_set_t), intent(in) :: particle_set real(default), intent(in), optional :: cross_section, error type(hepmc_vertex_t), dimension(:), allocatable :: v type(hepmc_particle_t), dimension(:), allocatable :: hprt type(hepmc_particle_t), dimension(2) :: hbeam type(vector4_t), dimension(:), allocatable :: vtx logical, dimension(:), allocatable :: is_beam integer, dimension(:), allocatable :: v_from, v_to integer :: n_vertices, n_tot, i n_tot = particle_set%get_n_tot () allocate (v_from (n_tot), v_to (n_tot)) call particle_set%assign_vertices (v_from, v_to, n_vertices) allocate (hprt (n_tot)) allocate (vtx (n_vertices)) vtx = vector4_null do i = 1, n_tot if (v_to(i) /= 0 .or. v_from(i) /= 0) then call particle_to_hepmc (particle_set%prt(i), hprt(i)) if (v_to(i) /= 0) then vtx(v_to(i)) = particle_set%prt(i)%get_vertex () end if end if end do if (present (cross_section) .and. present(error)) & call hepmc_event_set_cross_section (evt, cross_section, error) allocate (v (n_vertices)) do i = 1, n_vertices call hepmc_vertex_init (v(i), vtx(i)) call hepmc_event_add_vertex (evt, v(i)) end do allocate (is_beam (n_tot)) is_beam = particle_set%prt(1:n_tot)%get_status () == PRT_BEAM if (.not. any (is_beam)) then is_beam = particle_set%prt(1:n_tot)%get_status () == PRT_INCOMING end if if (count (is_beam) == 2) then hbeam = pack (hprt, is_beam) call hepmc_event_set_beam_particles (evt, hbeam(1), hbeam(2)) end if do i = 1, n_tot if (v_to(i) /= 0) then call hepmc_vertex_add_particle_in (v(v_to(i)), hprt(i)) end if end do do i = 1, n_tot if (v_from(i) /= 0) then call hepmc_vertex_add_particle_out (v(v_from(i)), hprt(i)) end if end do FIND_SIGNAL_PROCESS: do i = 1, n_tot if (particle_set%prt(i)%get_status () == PRT_INCOMING) then call hepmc_event_set_signal_process_vertex (evt, v(v_to(i))) exit FIND_SIGNAL_PROCESS end if end do FIND_SIGNAL_PROCESS if (HEPMC3_AVAILABLE) then do i = 1, n_tot call hepmc_particle_set_color (hprt(i), & particle_set%prt(i)%get_color ()) select case (particle_set%prt(i)%get_polarization_status ()) case (PRT_DEFINITE_HELICITY) call hepmc_particle_set_polarization (hprt(i), & particle_set%prt(i)%get_helicity ()) case (PRT_GENERIC_POLARIZATION) call hepmc_particle_set_polarization (hprt(i), & particle_set%prt(i)%get_polarization ()) end select end do end if end subroutine hepmc_event_from_particle_set @ %def hepmc_event_from_particle_set @ Initialize a particle from a HepMC particle object. The model is necessary for making a fully qualified flavor component. We have the additional flag [[polarized]] which tells whether the polarization information should be interpreted or ignored, and the lookup array of barcodes. Note that the lookup array is searched linearly, a possible bottleneck for large particle arrays. If necessary, the barcode array could be replaced by a hash table. <>= subroutine particle_from_hepmc_particle & (prt, hprt, model, fallback_model, polarization, barcode) type(particle_t), intent(out) :: prt type(hepmc_particle_t), intent(in) :: hprt type(model_data_t), intent(in), target :: model type(model_data_t), intent(in), target :: fallback_model type(hepmc_vertex_t) :: vtx integer, intent(in) :: polarization integer, dimension(:), intent(in) :: barcode type(hepmc_polarization_t) :: hpol type(flavor_t) :: flv type(color_t) :: col type(helicity_t) :: hel type(polarization_t) :: pol type(vector4_t) :: vertex integer :: n_parents, n_children integer, dimension(:), allocatable :: & parent_barcode, child_barcode, parent, child integer :: i select case (hepmc_particle_get_status (hprt)) case (1); call prt%set_status (PRT_OUTGOING) case (2); call prt%set_status (PRT_RESONANT) case (3); call prt%set_status (PRT_VIRTUAL) end select if (hepmc_particle_is_beam (hprt)) call prt%set_status (PRT_BEAM) call flv%init (hepmc_particle_get_pdg (hprt), model, fallback_model) call col%init (hepmc_particle_get_color (hprt)) call prt%set_flavor (flv) call prt%set_color (col) call prt%set_polarization (polarization) select case (polarization) case (PRT_DEFINITE_HELICITY) hpol = hepmc_particle_get_polarization (hprt) call hepmc_polarization_to_hel (hpol, prt%get_flv (), hel) call prt%set_helicity (hel) call hepmc_polarization_final (hpol) case (PRT_GENERIC_POLARIZATION) hpol = hepmc_particle_get_polarization (hprt) call hepmc_polarization_to_pol (hpol, prt%get_flv (), pol) call prt%set_pol (pol) call hepmc_polarization_final (hpol) end select call prt%set_momentum (hepmc_particle_get_momentum (hprt), & hepmc_particle_get_mass_squared (hprt)) n_parents = hepmc_particle_get_n_parents (hprt) n_children = hepmc_particle_get_n_children (hprt) if (HEPMC2_AVAILABLE) then allocate (parent_barcode (n_parents), parent (n_parents)) allocate (child_barcode (n_children), child (n_children)) parent_barcode = hepmc_particle_get_parent_barcodes (hprt) child_barcode = hepmc_particle_get_child_barcodes (hprt) do i = 1, size (barcode) where (parent_barcode == barcode(i)) parent = i where (child_barcode == barcode(i)) child = i end do call prt%set_parents (parent) call prt%set_children (child) else if (HEPMC3_AVAILABLE) then allocate (parent_barcode (n_parents), parent (n_parents)) allocate (child_barcode (n_children), child (n_children)) parent_barcode = hepmc_particle_get_parent_barcodes (hprt) child_barcode = hepmc_particle_get_child_barcodes (hprt) do i = 1, size (barcode) where (parent_barcode == barcode(i)) parent = i where (child_barcode == barcode(i)) child = i end do call prt%set_parents (parent) call prt%set_children (child) end if if (prt%get_status () == PRT_VIRTUAL .and. n_parents == 0) & call prt%set_status (PRT_INCOMING) if (HEPMC2_AVAILABLE) then vtx = hepmc_particle_get_decay_vertex (hprt) if (hepmc_vertex_is_valid (vtx)) then vertex = hepmc_vertex_to_vertex (vtx) if (vertex /= vector4_null) call prt%set_vertex (vertex) end if end if end subroutine particle_from_hepmc_particle @ %def particle_from_hepmc_particle @ If a particle set is initialized from a HepMC event record, we have to specify the treatment of polarization (unpolarized or density matrix) which is common to all particles. Correlated polarization information is not available. There is some complication in reconstructing incoming particles and beam remnants. First of all, they all will be tagged as virtual. We then define an incoming particle as <>= public :: hepmc_event_to_particle_set <>= subroutine hepmc_event_to_particle_set & (particle_set, evt, model, fallback_model, polarization) type(particle_set_t), intent(inout), target :: particle_set type(hepmc_event_t), intent(in) :: evt class(model_data_t), intent(in), target :: model, fallback_model integer, intent(in) :: polarization type(hepmc_event_particle_iterator_t) :: it type(hepmc_vertex_t) :: v type(hepmc_vertex_particle_in_iterator_t) :: v_it type(hepmc_particle_t) :: prt integer, dimension(:), allocatable :: barcode, n_parents integer :: n_tot, n_beam, i, bc n_tot = hepmc_event_get_n_particles(evt) allocate (barcode (n_tot)) if (HEPMC2_AVAILABLE) then call hepmc_event_particle_iterator_init (it, evt) do i = 1, n_tot barcode(i) = hepmc_particle_get_barcode & (hepmc_event_particle_iterator_get (it)) call hepmc_event_particle_iterator_advance (it) end do allocate (particle_set%prt (n_tot)) call hepmc_event_particle_iterator_reset (it) do i = 1, n_tot prt = hepmc_event_particle_iterator_get (it) call particle_from_hepmc_particle (particle_set%prt(i), & prt, model, fallback_model, polarization, barcode) call hepmc_event_particle_iterator_advance (it) end do call hepmc_event_particle_iterator_final (it) v = hepmc_event_get_signal_process_vertex (evt) if (hepmc_vertex_is_valid (v)) then call hepmc_vertex_particle_in_iterator_init (v_it, v) do while (hepmc_vertex_particle_in_iterator_is_valid (v_it)) prt = hepmc_vertex_particle_in_iterator_get (v_it) bc = hepmc_particle_get_barcode & (hepmc_vertex_particle_in_iterator_get (v_it)) do i = 1, size(barcode) if (bc == barcode(i)) & call particle_set%prt(i)%set_status (PRT_INCOMING) end do call hepmc_vertex_particle_in_iterator_advance (v_it) end do call hepmc_vertex_particle_in_iterator_final (v_it) end if else if (HEPMC3_AVAILABLE) then allocate (particle_set%prt (n_tot)) do i = 1, n_tot barcode(i) = hepmc_particle_get_barcode & (hepmc_event_get_nth_particle (evt, i)) end do do i = 1, n_tot prt = hepmc_event_get_nth_particle (evt, i) call particle_from_hepmc_particle (particle_set%prt(i), & prt, model, fallback_model, polarization, barcode) end do end if do i = 1, n_tot if (particle_set%prt(i)%get_status () == PRT_VIRTUAL & .and. particle_set%prt(i)%get_n_children () == 0) & call particle_set%prt(i)%set_status (PRT_OUTGOING) end do if (HEPMC3_AVAILABLE) then n_beam = hepmc_event_get_n_beams (evt) do i = 1, n_beam bc = hepmc_event_get_nth_beam (evt, i) if (.not. particle_set%prt(bc)%get_status () == PRT_INCOMING) & call particle_set%prt(bc)%set_status (PRT_BEAM) end do do i = 1, n_tot if (particle_set%prt(i)%get_status () == PRT_VIRTUAL) then n_parents = particle_set%prt(i)%get_parents () if (all & (particle_set%prt(n_parents)%get_status () == PRT_BEAM)) then call particle_set%prt(i)%set_status (PRT_INCOMING) end if end if end do end if particle_set%n_tot = n_tot particle_set%n_beam = & count (particle_set%prt%get_status () == PRT_BEAM) particle_set%n_in = & count (particle_set%prt%get_status () == PRT_INCOMING) particle_set%n_out = & count (particle_set%prt%get_status () == PRT_OUTGOING) particle_set%n_vir = & particle_set%n_tot - particle_set%n_in - particle_set%n_out end subroutine hepmc_event_to_particle_set @ %def hepmc_event_to_particle_set @ Fill a WHIZARD event from a HepMC event record. In HepMC the weights are in a weight container. If the size of this container is larger than one, it is ambiguous to assign the event a specific weight. For now we only allow to read in unweighted events. <>= public :: hepmc_to_event <>= subroutine hepmc_to_event & (event, hepmc_event, fallback_model, process_index, & recover_beams, use_alpha_s, use_scale) class(generic_event_t), intent(inout), target :: event type(hepmc_event_t), intent(inout) :: hepmc_event class(model_data_t), intent(in), target :: fallback_model integer, intent(out), optional :: process_index logical, intent(in), optional :: recover_beams logical, intent(in), optional :: use_alpha_s logical, intent(in), optional :: use_scale class(model_data_t), pointer :: model real(default) :: scale, alpha_qcd type(particle_set_t) :: particle_set model => event%get_model_ptr () call event%set_index (hepmc_event_get_event_index (hepmc_event)) call hepmc_event_to_particle_set (particle_set, & hepmc_event, model, fallback_model, PRT_DEFINITE_HELICITY) call event%set_hard_particle_set (particle_set) call particle_set%final () call event%set_weight_ref (1._default) alpha_qcd = hepmc_event_get_alpha_qcd (hepmc_event) scale = hepmc_event_get_scale (hepmc_event) if (present (use_alpha_s)) then if (use_alpha_s .and. alpha_qcd > 0) & call event%set_alpha_qcd_forced (alpha_qcd) end if if (present (use_scale)) then if (use_scale .and. scale > 0) & call event%set_scale_forced (scale) end if end subroutine hepmc_to_event @ %def hepmc_to_event @ \subsubsection{LCIO event format} The master output function fills a LCIO event object that is already initialized, but has no particles in it. In contrast to HepMC in LCIO there are no vertices (except for tracker and other detector specifications). So we assign first all incoming particles and then all outgoing particles to LCIO particle types. Particles which have neither parent nor children entries (this should not happen) are dropped. Finally, we insert the beam particles. If there are none, use the incoming particles instead. Transform a particle into a [[lcio_particle]] object, including color and polarization. The LCIO status is equivalent to the HepMC status, in particular: 0 = null entry, 1 = physical particle, 2 = decayed/fragmented SM hadron, tau or muon, 3 = other unphysical particle entry, 4 = incoming particles, 11 = intermediate resonance such as squarks. The use of 11 for intermediate resonances is as done by HERWIG, see http://herwig.hepforge.org/trac/wiki/FaQs. A beam-remnant particle (e.g., ISR photon) that has no children is tagged as outgoing, otherwise unphysical. <>= public :: particle_to_lcio <>= subroutine particle_to_lcio (prt, lprt) type(particle_t), intent(in) :: prt type(lcio_particle_t), intent(out) :: lprt integer :: lcio_status type(vector4_t) :: vtx select case (prt%get_status ()) case (PRT_UNDEFINED) lcio_status = 0 case (PRT_OUTGOING) lcio_status = 1 case (PRT_BEAM_REMNANT) if (prt%get_n_children () == 0) then lcio_status = 1 else lcio_status = 3 end if case (PRT_BEAM) lcio_status = 4 case (PRT_RESONANT) lcio_status = 2 case default lcio_status = 3 end select call lcio_particle_init (lprt, & prt%get_momentum (), & prt%get_pdg (), & prt%flv%get_charge (), & lcio_status) call lcio_particle_set_color (lprt, prt%get_color ()) vtx = prt%get_vertex () call lcio_particle_set_vtx (lprt, space_part (vtx)) call lcio_particle_set_t (lprt, vtx%p(0)) select case (prt%get_polarization_status ()) case (PRT_DEFINITE_HELICITY) call lcio_polarization_init (lprt, prt%get_helicity ()) case (PRT_GENERIC_POLARIZATION) call lcio_polarization_init (lprt, prt%get_polarization ()) end select end subroutine particle_to_lcio @ %def particle_to_lcio @ @ Initialize a particle from a LCIO particle object. The model is necessary for making a fully qualified flavor component. <>= public :: particle_from_lcio_particle <>= subroutine particle_from_lcio_particle & (prt, lprt, model, daughters, parents, polarization) type(particle_t), intent(out) :: prt type(lcio_particle_t), intent(in) :: lprt type(model_data_t), intent(in), target :: model integer, dimension(:), intent(in) :: daughters, parents type(vector4_t) :: vtx4 type(flavor_t) :: flv type(color_t) :: col type(helicity_t) :: hel type(polarization_t) :: pol integer, intent(in) :: polarization select case (lcio_particle_get_status (lprt)) case (1); call prt%set_status (PRT_OUTGOING) case (2); call prt%set_status (PRT_RESONANT) case (3) select case (size (parents)) case (0) call prt%set_status (PRT_INCOMING) case default call prt%set_status (PRT_VIRTUAL) end select case (4); call prt%set_status (PRT_BEAM) end select call flv%init (lcio_particle_get_pdg (lprt), model) call col%init (lcio_particle_get_flow (lprt)) if (flv%is_beam_remnant ()) call prt%set_status (PRT_BEAM_REMNANT) call prt%set_flavor (flv) call prt%set_color (col) call prt%set_polarization (polarization) select case (polarization) case (PRT_DEFINITE_HELICITY) call lcio_particle_to_hel (lprt, prt%get_flv (), hel) call prt%set_helicity (hel) case (PRT_GENERIC_POLARIZATION) call lcio_particle_to_pol (lprt, prt%get_flv (), pol) call prt%set_pol (pol) end select call prt%set_momentum (lcio_particle_get_momentum (lprt), & lcio_particle_get_mass_squared (lprt)) call prt%set_parents (parents) call prt%set_children (daughters) vtx4 = vector4_moving (lcio_particle_get_time (lprt), & lcio_particle_get_vertex (lprt)) if (vtx4 /= vector4_null) call prt%set_vertex (vtx4) end subroutine particle_from_lcio_particle @ %def particle_from_lcio_particle @ <>= public :: lcio_event_from_particle_set <>= subroutine lcio_event_from_particle_set (evt, particle_set) type(lcio_event_t), intent(inout) :: evt type(particle_set_t), intent(in) :: particle_set type(lcio_particle_t), dimension(:), allocatable :: lprt type(particle_set_t), target :: pset_filtered integer, dimension(:), allocatable :: parent integer :: n_tot, i, j, n_beam, n_parents, type, beam_count call particle_set%filter_particles ( pset_filtered, real_parents = .true. , & keep_beams = .true. , keep_virtuals = .false.) n_tot = pset_filtered%n_tot n_beam = count (pset_filtered%prt%get_status () == PRT_BEAM) if (n_beam == 0) then type = PRT_INCOMING else type = PRT_BEAM end if beam_count = 0 allocate (lprt (n_tot)) do i = 1, n_tot call particle_to_lcio (pset_filtered%prt(i), lprt(i)) n_parents = pset_filtered%prt(i)%get_n_parents () if (n_parents /= 0) then allocate (parent (n_parents)) parent = pset_filtered%prt(i)%get_parents () do j = 1, n_parents call lcio_particle_set_parent (lprt(i), lprt(parent(j))) end do deallocate (parent) end if if (pset_filtered%prt(i)%get_status () == type) then beam_count = beam_count + 1 call lcio_event_set_beam & (evt, pset_filtered%prt(i)%get_pdg (), beam_count) end if call lcio_particle_add_to_evt_coll (lprt(i), evt) end do call lcio_event_add_coll (evt) end subroutine lcio_event_from_particle_set @ %def lcio_event_from_particle_set @ If a particle set is initialized from a LCIO event record, we have to specify the treatment of polarization (unpolarized or density matrix) which is common to all particles. Correlated polarization information is not available. <>= public :: lcio_event_to_particle_set <>= subroutine lcio_event_to_particle_set & (particle_set, evt, model, fallback_model, polarization) type(particle_set_t), intent(inout), target :: particle_set type(lcio_event_t), intent(in) :: evt class(model_data_t), intent(in), target :: model, fallback_model integer, intent(in) :: polarization type(lcio_particle_t) :: prt integer, dimension(:), allocatable :: parents, daughters integer :: n_tot, i, j, n_parents, n_children n_tot = lcio_event_get_n_tot (evt) allocate (particle_set%prt (n_tot)) do i = 1, n_tot prt = lcio_event_get_particle (evt, i-1) n_parents = lcio_particle_get_n_parents (prt) n_children = lcio_particle_get_n_children (prt) allocate (daughters (n_children)) allocate (parents (n_parents)) if (n_children > 0) then do j = 1, n_children daughters(j) = lcio_get_n_children (evt,i,j) end do end if if (n_parents > 0) then do j = 1, n_parents parents(j) = lcio_get_n_parents (evt,i,j) end do end if call particle_from_lcio_particle (particle_set%prt(i), prt, model, & daughters, parents, polarization) deallocate (daughters, parents) end do do i = 1, n_tot if (particle_set%prt(i)%get_status () == PRT_VIRTUAL) then CHECK_BEAM: do j = 1, particle_set%prt(i)%get_n_parents () if (particle_set%prt(j)%get_status () == PRT_BEAM) & call particle_set%prt(i)%set_status (PRT_INCOMING) exit CHECK_BEAM end do CHECK_BEAM end if end do particle_set%n_tot = n_tot particle_set%n_beam = & count (particle_set%prt%get_status () == PRT_BEAM) particle_set%n_in = & count (particle_set%prt%get_status () == PRT_INCOMING) particle_set%n_out = & count (particle_set%prt%get_status () == PRT_OUTGOING) particle_set%n_vir = & particle_set%n_tot - particle_set%n_in - particle_set%n_out end subroutine lcio_event_to_particle_set @ %def lcio_event_to_particle_set @ <>= public :: lcio_to_event <>= subroutine lcio_to_event & (event, lcio_event, fallback_model, process_index, recover_beams, & use_alpha_s, use_scale) class(generic_event_t), intent(inout), target :: event type(lcio_event_t), intent(inout) :: lcio_event class(model_data_t), intent(in), target :: fallback_model integer, intent(out), optional :: process_index logical, intent(in), optional :: recover_beams logical, intent(in), optional :: use_alpha_s logical, intent(in), optional :: use_scale class(model_data_t), pointer :: model real(default) :: scale, alpha_qcd type(particle_set_t) :: particle_set model => event%get_model_ptr () call lcio_event_to_particle_set (particle_set, & lcio_event, model, fallback_model, PRT_DEFINITE_HELICITY) call event%set_hard_particle_set (particle_set) call particle_set%final () call event%set_weight_ref (1._default) alpha_qcd = lcio_event_get_alphas (lcio_event) scale = lcio_event_get_scaleval (lcio_event) if (present (use_alpha_s)) then if (use_alpha_s .and. alpha_qcd > 0) & call event%set_alpha_qcd_forced (alpha_qcd) end if if (present (use_scale)) then if (use_scale .and. scale > 0) & call event%set_scale_forced (scale) end if end subroutine lcio_to_event @ %def lcio_to_event @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[hep_events_ut.f90]]>>= <> module hep_events_ut use unit_tests use hepmc_interface, only: HEPMC_IS_AVAILABLE use system_dependencies, only: HEPMC2_AVAILABLE use hep_events_uti <> <> contains <> end module hep_events_ut @ %def hep_events_ut @ <<[[hep_events_uti.f90]]>>= <> module hep_events_uti <> <> use lorentz use flavors use colors use helicities use quantum_numbers use state_matrices, only: FM_SELECT_HELICITY, FM_FACTOR_HELICITY use interactions use evaluators use model_data use particles use subevents use hepmc_interface use hep_events <> <> contains <> end module hep_events_uti @ %def hep_events_ut @ API: driver for the unit tests below. <>= public :: hep_events_test <>= subroutine hep_events_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine hep_events_test @ %def particles_test @ If [[HepMC]] is available, check the routines via [[HepMC]]. Set up a chain of production and decay and factorize the result into particles. The process is $d\bar d \to Z \to q\bar q$. <>= if (hepmc_is_available ()) then call test (hep_events_1, "hep_events_1", & "check HepMC event routines", & u, results) end if <>= public :: hep_events_1 <>= subroutine hep_events_1 (u) use os_interface integer, intent(in) :: u type(model_data_t), target :: model type(flavor_t), dimension(3) :: flv type(color_t), dimension(3) :: col type(helicity_t), dimension(3) :: hel type(quantum_numbers_t), dimension(3) :: qn type(vector4_t), dimension(3) :: p type(interaction_t), target :: int1, int2 type(quantum_numbers_mask_t) :: qn_mask_conn type(evaluator_t), target :: eval type(interaction_t), pointer :: int type(particle_set_t) :: particle_set1, particle_set2 type(hepmc_event_t) :: hepmc_event type(hepmc_iostream_t) :: iostream real(default) :: cross_section, error, weight logical :: ok write (u, "(A)") "* Test output: HEP events" write (u, "(A)") "* Purpose: test HepMC event routines" write (u, "(A)") write (u, "(A)") "* Reading model file" call model%init_sm_test () write (u, "(A)") write (u, "(A)") "* Initializing production process" call int1%basic_init (2, 0, 1, set_relations=.true.) call flv%init ([1, -1, 23], model) call col%init_col_acl ([0, 0, 0], [0, 0, 0]) call hel(3)%init ( 1, 1) call qn%init (flv, col, hel) call int1%add_state (qn, value=(0.25_default, 0._default)) call hel(3)%init ( 1,-1) call qn%init (flv, col, hel) call int1%add_state (qn, value=(0._default, 0.25_default)) call hel(3)%init (-1, 1) call qn%init (flv, col, hel) call int1%add_state (qn, value=(0._default,-0.25_default)) call hel(3)%init (-1,-1) call qn%init (flv, col, hel) call int1%add_state (qn, value=(0.25_default, 0._default)) call hel(3)%init ( 0, 0) call qn%init (flv, col, hel) call int1%add_state (qn, value=(0.5_default, 0._default)) call int1%freeze () p(1) = vector4_moving (45._default, 45._default, 3) p(2) = vector4_moving (45._default,-45._default, 3) p(3) = p(1) + p(2) call int1%set_momenta (p) write (u, "(A)") write (u, "(A)") "* Setup decay process" call int2%basic_init (1, 0, 2, set_relations=.true.) call flv%init ([23, 1, -1], model) call col%init_col_acl ([0, 501, 0], [0, 0, 501]) call hel%init ([1, 1, 1], [1, 1, 1]) call qn%init (flv, col, hel) call int2%add_state (qn, value=(1._default, 0._default)) call hel%init ([1, 1, 1], [-1,-1,-1]) call qn%init (flv, col, hel) call int2%add_state (qn, value=(0._default, 0.1_default)) call hel%init ([-1,-1,-1], [1, 1, 1]) call qn%init (flv, col, hel) call int2%add_state (qn, value=(0._default,-0.1_default)) call hel%init ([-1,-1,-1], [-1,-1,-1]) call qn%init (flv, col, hel) call int2%add_state (qn, value=(1._default, 0._default)) call hel%init ([0, 1,-1], [0, 1,-1]) call qn%init (flv, col, hel) call int2%add_state (qn, value=(4._default, 0._default)) call hel%init ([0,-1, 1], [0, 1,-1]) call qn%init (flv, col, hel) call int2%add_state (qn, value=(2._default, 0._default)) call hel%init ([0, 1,-1], [0,-1, 1]) call qn%init (flv, col, hel) call int2%add_state (qn, value=(2._default, 0._default)) call hel%init ([0,-1, 1], [0,-1, 1]) call qn%init (flv, col, hel) call int2%add_state (qn, value=(4._default, 0._default)) call flv%init ([23, 2, -2], model) call hel%init ([0, 1,-1], [0, 1,-1]) call qn%init (flv, col, hel) call int2%add_state (qn, value=(0.5_default, 0._default)) call hel%init ([0,-1, 1], [0,-1, 1]) call qn%init (flv, col, hel) call int2%add_state (qn, value=(0.5_default, 0._default)) call int2%freeze () p(2) = vector4_moving (45._default, 45._default, 2) p(3) = vector4_moving (45._default,-45._default, 2) call int2%set_momenta (p) call int2%set_source_link (1, int1, 3) call int1%basic_write (u) call int2%basic_write (u) write (u, "(A)") write (u, "(A)") "* Concatenate production and decay" call eval%init_product (int1, int2, qn_mask_conn, & connections_are_resonant=.true.) call eval%receive_momenta () call eval%evaluate () call eval%write (u) write (u, "(A)") write (u, "(A)") "* Factorize as subevent (complete, polarized)" write (u, "(A)") int => eval%interaction_t call particle_set1%init & (ok, int, int, FM_FACTOR_HELICITY, & [0.2_default, 0.2_default], .false., .true.) call particle_set1%write (u) write (u, "(A)") write (u, "(A)") "* Factorize as subevent (in/out only, selected helicity)" write (u, "(A)") int => eval%interaction_t call particle_set2%init & (ok, int, int, FM_SELECT_HELICITY, & [0.9_default, 0.9_default], .false., .false.) call particle_set2%write (u) call particle_set2%final () write (u, "(A)") write (u, "(A)") "* Factorize as subevent (complete, selected helicity)" write (u, "(A)") int => eval%interaction_t call particle_set2%init & (ok, int, int, FM_SELECT_HELICITY, & [0.7_default, 0.7_default], .false., .true.) call particle_set2%write (u) write (u, "(A)") write (u, "(A)") "* Transfer particle_set to HepMC, print, and output to" write (u, "(A)") " hep_events.hepmc.dat" write (u, "(A)") cross_section = 42.0_default error = 17.0_default weight = 1.0_default call hepmc_event_init (hepmc_event, 11, 127) call hepmc_event_from_particle_set (hepmc_event, particle_set2, & cross_section, error) call hepmc_event_add_weight (hepmc_event, weight, .true.) call hepmc_event_print (hepmc_event) call hepmc_iostream_open_out & (iostream , var_str ("hep_events.hepmc.dat"), 2) call hepmc_iostream_write_event (iostream, hepmc_event) call hepmc_iostream_close (iostream) write (u, "(A)") write (u, "(A)") "* Recover from HepMC file" write (u, "(A)") call particle_set2%final () call hepmc_event_final (hepmc_event) call hepmc_event_init (hepmc_event) call hepmc_iostream_open_in & (iostream , var_str ("hep_events.hepmc.dat"), HEPMC3_MODE_HEPMC3) call hepmc_iostream_read_event (iostream, hepmc_event, ok=ok) call hepmc_iostream_close (iostream) call hepmc_event_to_particle_set (particle_set2, & hepmc_event, model, model, PRT_DEFINITE_HELICITY) call particle_set2%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call particle_set1%final () call particle_set2%final () call eval%final () call int1%final () call int2%final () call hepmc_event_final (hepmc_event) call model%final () write (u, "(A)") write (u, "(A)") "* Test output end: hep_events_1" end subroutine hep_events_1 @ @ %def hep_events_1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{LHEF Input/Output} The LHEF event record is standardized. It is an ASCII format. We try our best at using it for both input and output. <<[[eio_lhef.f90]]>>= <> module eio_lhef <> <> use io_units use string_utils use numeric_utils use diagnostics use os_interface use xml use event_base + use event_handles, only: event_handle_t use eio_data use eio_base use hep_common use hep_events <> <> <> contains <> end module eio_lhef @ %def eio_lhef @ \subsection{Type} With sufficient confidence that it will always be three characters, we can store the version string with a default value. <>= public :: eio_lhef_t <>= type, extends (eio_t) :: eio_lhef_t logical :: writing = .false. logical :: reading = .false. integer :: unit = 0 type(event_sample_data_t) :: data type(cstream_t) :: cstream character(3) :: version = "1.0" logical :: keep_beams = .false. logical :: keep_remnants = .true. logical :: keep_virtuals = .false. logical :: recover_beams = .true. logical :: unweighted = .true. logical :: write_sqme_ref = .false. logical :: write_sqme_prc = .false. logical :: write_sqme_alt = .false. logical :: use_alphas_from_file = .false. logical :: use_scale_from_file = .false. integer :: n_alt = 0 integer, dimension(:), allocatable :: proc_num_id integer :: i_weight_sqme = 0 type(xml_tag_t) :: tag_lhef, tag_head, tag_init, tag_event type(xml_tag_t), allocatable :: tag_gen_n, tag_gen_v type(xml_tag_t), allocatable :: tag_generator, tag_xsecinfo type(xml_tag_t), allocatable :: tag_sqme_ref, tag_sqme_prc type(xml_tag_t), dimension(:), allocatable :: tag_sqme_alt, tag_wgts_alt type(xml_tag_t), allocatable :: tag_weight, tag_weightinfo, tag_weights contains <> end type eio_lhef_t @ %def eio_lhef_t @ \subsection{Specific Methods} Set parameters that are specifically used with LHEF. <>= procedure :: set_parameters => eio_lhef_set_parameters <>= subroutine eio_lhef_set_parameters (eio, & keep_beams, keep_remnants, recover_beams, & use_alphas_from_file, use_scale_from_file, & version, extension, write_sqme_ref, write_sqme_prc, write_sqme_alt) class(eio_lhef_t), intent(inout) :: eio logical, intent(in), optional :: keep_beams logical, intent(in), optional :: keep_remnants logical, intent(in), optional :: recover_beams logical, intent(in), optional :: use_alphas_from_file logical, intent(in), optional :: use_scale_from_file character(*), intent(in), optional :: version type(string_t), intent(in), optional :: extension logical, intent(in), optional :: write_sqme_ref logical, intent(in), optional :: write_sqme_prc logical, intent(in), optional :: write_sqme_alt if (present (keep_beams)) eio%keep_beams = keep_beams if (present (keep_remnants)) eio%keep_remnants = keep_remnants if (present (recover_beams)) eio%recover_beams = recover_beams if (present (use_alphas_from_file)) & eio%use_alphas_from_file = use_alphas_from_file if (present (use_scale_from_file)) & eio%use_scale_from_file = use_scale_from_file if (present (version)) then select case (version) case ("1.0", "2.0", "3.0") eio%version = version case default call msg_error ("LHEF version " // version & // " is not supported. Inserting 2.0") eio%version = "2.0" end select end if if (present (extension)) then eio%extension = extension else eio%extension = "lhe" end if if (present (write_sqme_ref)) eio%write_sqme_ref = write_sqme_ref if (present (write_sqme_prc)) eio%write_sqme_prc = write_sqme_prc if (present (write_sqme_alt)) eio%write_sqme_alt = write_sqme_alt end subroutine eio_lhef_set_parameters @ %def eio_lhef_set_parameters @ \subsection{Common Methods} Output. This is not the actual event format, but a readable account of the current object status. <>= procedure :: write => eio_lhef_write <>= subroutine eio_lhef_write (object, unit) class(eio_lhef_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit) write (u, "(1x,A)") "LHEF event stream:" if (object%writing) then write (u, "(3x,A,A)") "Writing to file = ", char (object%filename) else if (object%reading) then write (u, "(3x,A,A)") "Reading from file = ", char (object%filename) else write (u, "(3x,A)") "[closed]" end if write (u, "(3x,A,L1)") "Keep beams = ", object%keep_beams write (u, "(3x,A,L1)") "Keep remnants = ", object%keep_remnants write (u, "(3x,A,L1)") "Recover beams = ", object%recover_beams write (u, "(3x,A,L1)") "Alpha_s from file = ", & object%use_alphas_from_file write (u, "(3x,A,L1)") "Scale from file = ", & object%use_scale_from_file write (u, "(3x,A,A)") "Version = ", object%version write (u, "(3x,A,A,A)") "File extension = '", & char (object%extension), "'" if (allocated (object%proc_num_id)) then write (u, "(3x,A)") "Numerical process IDs:" do i = 1, size (object%proc_num_id) write (u, "(5x,I0,': ',I0)") i, object%proc_num_id(i) end do end if end subroutine eio_lhef_write @ %def eio_lhef_write @ Finalizer: close any open file. <>= procedure :: final => eio_lhef_final <>= subroutine eio_lhef_final (object) class(eio_lhef_t), intent(inout) :: object if (allocated (object%proc_num_id)) deallocate (object%proc_num_id) if (object%writing) then write (msg_buffer, "(A,A,A)") "Events: closing LHEF file '", & char (object%filename), "'" call msg_message () call object%write_footer () close (object%unit) object%writing = .false. else if (object%reading) then write (msg_buffer, "(A,A,A)") "Events: closing LHEF file '", & char (object%filename), "'" call msg_message () call object%cstream%final () close (object%unit) object%reading = .false. end if end subroutine eio_lhef_final @ %def eio_lhef_final @ Common initialization for input and output. <>= procedure :: common_init => eio_lhef_common_init <>= subroutine eio_lhef_common_init (eio, sample, data, extension) class(eio_lhef_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(in), optional :: data if (.not. present (data)) & call msg_bug ("LHEF initialization: missing data") eio%data = data if (data%n_beam /= 2) & call msg_fatal ("LHEF: defined for scattering processes only") eio%unweighted = data%unweighted if (eio%unweighted) then select case (data%norm_mode) case (NORM_UNIT) case default; call msg_fatal & ("LHEF: normalization for unweighted events must be '1'") end select else select case (data%norm_mode) case (NORM_SIGMA) case default; call msg_fatal & ("LHEF: normalization for weighted events must be 'sigma'") end select end if eio%n_alt = data%n_alt eio%sample = sample if (present (extension)) then eio%extension = extension end if call eio%set_filename () eio%unit = free_unit () call eio%init_tags (data) allocate (eio%proc_num_id (data%n_proc), source = data%proc_num_id) end subroutine eio_lhef_common_init @ %def eio_lhef_common_init @ Initialize the tag objects. Some tags depend on the LHEF version. In particular, the tags that in LHEF 2.0 identify individual weights by name in each event block, in LHEF 3.0 are replaced by info tags in the init block and a single \texttt{weights} tag in the event block. The name attributes of those tags are specific for \whizard. <>= procedure :: init_tags => eio_lhef_init_tags <>= subroutine eio_lhef_init_tags (eio, data) class(eio_lhef_t), intent(inout) :: eio type(event_sample_data_t), intent(in) :: data real(default), parameter :: pb_per_fb = 1.e-3_default integer :: i call eio%tag_lhef%init ( & var_str ("LesHouchesEvents"), & [xml_attribute (var_str ("version"), var_str (eio%version))], & .true.) call eio%tag_head%init ( & var_str ("header"), & .true.) call eio%tag_init%init ( & var_str ("init"), & .true.) call eio%tag_event%init (var_str ("event"), & .true.) select case (eio%version) case ("1.0") allocate (eio%tag_gen_n) call eio%tag_gen_n%init ( & var_str ("generator_name"), & .true.) allocate (eio%tag_gen_v) call eio%tag_gen_v%init ( & var_str ("generator_version"), & .true.) end select select case (eio%version) case ("2.0", "3.0") allocate (eio%tag_generator) call eio%tag_generator%init ( & var_str ("generator"), & [xml_attribute (var_str ("version"), var_str ("<>"))], & .true.) allocate (eio%tag_xsecinfo) call eio%tag_xsecinfo%init ( & var_str ("xsecinfo"), & [xml_attribute (var_str ("neve"), str (data%n_evt)), & xml_attribute (var_str ("totxsec"), & str (data%total_cross_section * pb_per_fb))]) end select select case (eio%version) case ("2.0") allocate (eio%tag_weight) call eio%tag_weight%init (var_str ("weight"), & [xml_attribute (var_str ("name"))]) if (eio%write_sqme_ref) then allocate (eio%tag_sqme_ref) call eio%tag_sqme_ref%init (var_str ("weight"), & [xml_attribute (var_str ("name"), var_str ("sqme_ref"))], & .true.) end if if (eio%write_sqme_prc) then allocate (eio%tag_sqme_prc) call eio%tag_sqme_prc%init (var_str ("weight"), & [xml_attribute (var_str ("name"), var_str ("sqme_prc"))], & .true.) end if if (eio%n_alt > 0) then if (eio%write_sqme_alt) then allocate (eio%tag_sqme_alt (1)) call eio%tag_sqme_alt(1)%init (var_str ("weight"), & [xml_attribute (var_str ("name"), var_str ("sqme_alt"))], & .true.) end if allocate (eio%tag_wgts_alt (1)) call eio%tag_wgts_alt(1)%init (var_str ("weight"), & [xml_attribute (var_str ("name"), var_str ("wgts_alt"))], & .true.) end if case ("3.0") if (eio%write_sqme_ref) then allocate (eio%tag_sqme_ref) call eio%tag_sqme_ref%init (var_str ("weightinfo"), & [xml_attribute (var_str ("name"), var_str ("sqme_ref"))]) end if if (eio%write_sqme_prc) then allocate (eio%tag_sqme_prc) call eio%tag_sqme_prc%init (var_str ("weightinfo"), & [xml_attribute (var_str ("name"), var_str ("sqme_prc"))]) end if if (eio%n_alt > 0) then if (eio%write_sqme_alt) then allocate (eio%tag_sqme_alt (eio%n_alt)) do i = 1, eio%n_alt call eio%tag_sqme_alt(i)%init (var_str ("weightinfo"), & [xml_attribute (var_str ("name"), & var_str ("sqme_alt") // str (i))]) end do end if allocate (eio%tag_wgts_alt (eio%n_alt)) do i = 1, eio%n_alt call eio%tag_wgts_alt(i)%init (var_str ("weightinfo"), & [xml_attribute (var_str ("name"), & var_str ("wgts_alt") // str (i))]) end do end if allocate (eio%tag_weightinfo) call eio%tag_weightinfo%init (var_str ("weightinfo"), & [xml_attribute (var_str ("name"))]) allocate (eio%tag_weights) call eio%tag_weights%init (var_str ("weights"), .true.) end select end subroutine eio_lhef_init_tags @ %def eio_lhef_init_tags @ Initialize event writing. <>= procedure :: init_out => eio_lhef_init_out <>= subroutine eio_lhef_init_out (eio, sample, data, success, extension) class(eio_lhef_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(in), optional :: data logical, intent(out), optional :: success integer :: u, i call eio%set_splitting (data) call eio%common_init (sample, data, extension) write (msg_buffer, "(A,A,A)") "Events: writing to LHEF file '", & char (eio%filename), "'" call msg_message () eio%writing = .true. u = eio%unit open (u, file = char (eio%filename), & action = "write", status = "replace") call eio%write_header () call heprup_init & (data%pdg_beam, & data%energy_beam, & n_processes = data%n_proc, & unweighted = data%unweighted, & negative_weights = data%negative_weights) do i = 1, data%n_proc call heprup_set_process_parameters (i = i, & process_id = data%proc_num_id(i), & cross_section = data%cross_section(i), & error = data%error(i)) end do call eio%tag_init%write (u); write (u, *) call heprup_write_lhef (u) select case (eio%version) case ("2.0"); call eio%write_init_20 (data) case ("3.0"); call eio%write_init_30 (data) end select call eio%tag_init%close (u); write (u, *) if (present (success)) success = .true. end subroutine eio_lhef_init_out @ %def eio_lhef_init_out @ Initialize event reading. First read the LHEF tag and version, then read the header and skip over its contents, then read the init block. (We require the opening and closing tags of the init block to be placed on separate lines without extra stuff.) For input, we do not (yet?) support split event files. <>= procedure :: init_in => eio_lhef_init_in <>= subroutine eio_lhef_init_in (eio, sample, data, success, extension) class(eio_lhef_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(inout), optional :: data logical, intent(out), optional :: success logical :: exist, ok, closing type(event_sample_data_t) :: data_file type(string_t) :: string integer :: u eio%split = .false. call eio%common_init (sample, data, extension) write (msg_buffer, "(A,A,A)") "Events: reading from LHEF file '", & char (eio%filename), "'" call msg_message () inquire (file = char (eio%filename), exist = exist) if (.not. exist) call msg_fatal ("Events: LHEF file not found.") eio%reading = .true. u = eio%unit open (u, file = char (eio%filename), & action = "read", status = "old") call eio%cstream%init (u) call eio%read_header () call eio%tag_init%read (eio%cstream, ok) if (.not. ok) call err_init select case (eio%version) case ("1.0"); call eio%read_init_10 (data_file) call eio%tag_init%read_content (eio%cstream, string, closing) if (string /= "" .or. .not. closing) call err_init case ("2.0"); call eio%read_init_20 (data_file) case ("3.0"); call eio%read_init_30 (data_file) end select call eio%merge_data (data, data_file) if (present (success)) success = .true. contains subroutine err_init call msg_fatal ("LHEF: syntax error in init tag") end subroutine err_init end subroutine eio_lhef_init_in @ %def eio_lhef_init_in @ Merge event sample data: we can check the data in the file against our assumptions and set or reset parameters. <>= procedure :: merge_data => eio_merge_data <>= subroutine eio_merge_data (eio, data, data_file) class(eio_lhef_t), intent(inout) :: eio type(event_sample_data_t), intent(inout) :: data type(event_sample_data_t), intent(in) :: data_file real, parameter :: tolerance = 1000 * epsilon (1._default) if (data%unweighted .neqv. data_file%unweighted) call err_weights if (data%negative_weights .neqv. data_file%negative_weights) & call err_weights if (data%norm_mode /= data_file%norm_mode) call err_norm if (data%n_beam /= data_file%n_beam) call err_beams if (any (data%pdg_beam /= data_file%pdg_beam)) call err_beams if (any (abs ((data%energy_beam - data_file%energy_beam)) & > (data%energy_beam + data_file%energy_beam) * tolerance)) & call err_beams if (data%n_proc /= data_file%n_proc) call err_proc if (any (data%proc_num_id /= data_file%proc_num_id)) call err_proc where (data%cross_section == 0) data%cross_section = data_file%cross_section data%error = data_file%error end where data%total_cross_section = sum (data%cross_section) if (data_file%n_evt > 0) then if (data%n_evt > 0 .and. data_file%n_evt /= data%n_evt) call err_n_evt data%n_evt = data_file%n_evt end if contains subroutine err_weights call msg_fatal ("LHEF: mismatch in event weight properties") end subroutine err_weights subroutine err_norm call msg_fatal ("LHEF: mismatch in event normalization") end subroutine err_norm subroutine err_beams call msg_fatal ("LHEF: mismatch in beam properties") end subroutine err_beams subroutine err_proc call msg_fatal ("LHEF: mismatch in process definitions") end subroutine err_proc subroutine err_n_evt call msg_error ("LHEF: mismatch in specified number of events (ignored)") end subroutine err_n_evt end subroutine eio_merge_data @ %def eio_merge_data @ Switch from input to output: reopen the file for reading. <>= procedure :: switch_inout => eio_lhef_switch_inout <>= subroutine eio_lhef_switch_inout (eio, success) class(eio_lhef_t), intent(inout) :: eio logical, intent(out), optional :: success call msg_bug ("LHEF: in-out switch not supported") if (present (success)) success = .false. end subroutine eio_lhef_switch_inout @ %def eio_lhef_switch_inout @ Split event file: increment the counter, close the current file, open a new one. If the file needs a header, repeat it for the new file. (We assume that the common block contents are still intact.) <>= procedure :: split_out => eio_lhef_split_out <>= subroutine eio_lhef_split_out (eio) class(eio_lhef_t), intent(inout) :: eio integer :: u if (eio%split) then eio%split_index = eio%split_index + 1 call eio%set_filename () write (msg_buffer, "(A,A,A)") "Events: writing to LHEF file '", & char (eio%filename), "'" call msg_message () call eio%write_footer () u = eio%unit close (u) open (u, file = char (eio%filename), & action = "write", status = "replace") call eio%write_header () call eio%tag_init%write (u); write (u, *) call heprup_write_lhef (u) select case (eio%version) case ("2.0"); call eio%write_init_20 (eio%data) case ("3.0"); call eio%write_init_30 (eio%data) end select call eio%tag_init%close (u); write (u, *) end if end subroutine eio_lhef_split_out @ %def eio_lhef_split_out @ Output an event. Write first the event indices, then weight and squared matrix element, then the particle set. <>= procedure :: output => eio_lhef_output <>= - subroutine eio_lhef_output (eio, event, i_prc, reading, passed, pacify) + subroutine eio_lhef_output & + (eio, event, i_prc, reading, passed, pacify, event_handle) class(eio_lhef_t), intent(inout) :: eio class(generic_event_t), intent(in), target :: event integer, intent(in) :: i_prc logical, intent(in), optional :: reading, passed, pacify + class(event_handle_t), intent(inout), optional :: event_handle integer :: u u = given_output_unit (eio%unit); if (u < 0) return if (present (passed)) then if (.not. passed) return end if if (eio%writing) then call hepeup_from_event (event, & process_index = eio%proc_num_id (i_prc), & keep_beams = eio%keep_beams, & keep_remnants = eio%keep_remnants) write (u, '(A)') "" call hepeup_write_lhef (eio%unit) select case (eio%version) case ("2.0"); call eio%write_event_20 (event) case ("3.0"); call eio%write_event_30 (event) end select write (u, '(A)') "" else call eio%write () call msg_fatal ("LHEF file is not open for writing") end if end subroutine eio_lhef_output @ %def eio_lhef_output @ Input an event. Upon input of [[i_prc]], we can just read in the whole HEPEUP common block. These data are known to come first. The [[i_prc]] value can be deduced from the IDPRUP value by a table lookup. Reading the common block bypasses the [[cstream]] which accesses the input unit. This is consistent with the LHEF specification. After the common-block data have been swallowed, we can resume reading from stream. We don't catch actual I/O errors. However, we return a negative value in [[iostat]] if we reached the terminating [[]] tag. <>= procedure :: input_i_prc => eio_lhef_input_i_prc <>= subroutine eio_lhef_input_i_prc (eio, i_prc, iostat) class(eio_lhef_t), intent(inout) :: eio integer, intent(out) :: i_prc integer, intent(out) :: iostat integer :: i, proc_num_id type(string_t) :: s logical :: ok iostat = 0 call eio%tag_lhef%read_content (eio%cstream, s, ok) if (ok) then if (s == "") then iostat = -1 else call err_close end if return else call eio%cstream%revert_record (s) end if call eio%tag_event%read (eio%cstream, ok) if (.not. ok) then call err_evt1 return end if call hepeup_read_lhef (eio%unit) call hepeup_get_event_parameters (proc_id = proc_num_id) i_prc = 0 FIND_I_PRC: do i = 1, size (eio%proc_num_id) if (eio%proc_num_id(i) == proc_num_id) then i_prc = i exit FIND_I_PRC end if end do FIND_I_PRC if (i_prc == 0) call err_index contains subroutine err_close call msg_error ("LHEF: reading events: syntax error in closing tag") iostat = 1 end subroutine subroutine err_evt1 call msg_error ("LHEF: reading events: invalid event tag, & &aborting read") iostat = 2 end subroutine err_evt1 subroutine err_index call msg_error ("LHEF: reading events: undefined process ID " & // char (str (proc_num_id)) // ", aborting read") iostat = 3 end subroutine err_index end subroutine eio_lhef_input_i_prc @ %def eio_lhef_input_i_prc @ Since we have already read the event information from file, this input routine can transfer the common-block contents to the event record. Also, we read any further information in the event record. Since LHEF doesn't give this information, we must assume that the MCI group, term, and channel can all be safely set to 1. This works if there is only one MCI group and term. The channel doesn't matter for the matrix element. The event index is incremented, as if the event was generated. The LHEF format does not support event indices. <>= procedure :: input_event => eio_lhef_input_event <>= - subroutine eio_lhef_input_event (eio, event, iostat) + subroutine eio_lhef_input_event (eio, event, iostat, event_handle) class(eio_lhef_t), intent(inout) :: eio class(generic_event_t), intent(inout), target :: event integer, intent(out) :: iostat + class(event_handle_t), intent(inout), optional :: event_handle type(string_t) :: s logical :: closing iostat = 0 call event%reset_contents () call event%select (1, 1, 1) call hepeup_to_event (event, eio%fallback_model, & recover_beams = eio%recover_beams, & use_alpha_s = eio%use_alphas_from_file, & use_scale = eio%use_scale_from_file) select case (eio%version) case ("1.0") call eio%tag_event%read_content (eio%cstream, s, closing = closing) if (s /= "" .or. .not. closing) call err_evt2 case ("2.0"); call eio%read_event_20 (event) case ("3.0"); call eio%read_event_30 (event) end select call event%increment_index () contains subroutine err_evt2 call msg_error ("LHEF: reading events: syntax error in event record, & &aborting read") iostat = 2 end subroutine err_evt2 end subroutine eio_lhef_input_event @ %def eio_lhef_input_event @ <>= procedure :: skip => eio_lhef_skip <>= subroutine eio_lhef_skip (eio, iostat) class(eio_lhef_t), intent(inout) :: eio integer, intent(out) :: iostat if (eio%reading) then read (eio%unit, iostat = iostat) else call eio%write () call msg_fatal ("Raw event file is not open for reading") end if end subroutine eio_lhef_skip @ %def eio_lhef_skip @ \subsection{Les Houches Event File: header/footer} These two routines write the header and footer for the Les Houches Event File format (LHEF). The current version writes no information except for the generator name and version (v.1.0 only). <>= procedure :: write_header => eio_lhef_write_header procedure :: write_footer => eio_lhef_write_footer <>= subroutine eio_lhef_write_header (eio) class(eio_lhef_t), intent(in) :: eio integer :: u u = given_output_unit (eio%unit); if (u < 0) return call eio%tag_lhef%write (u); write (u, *) call eio%tag_head%write (u); write (u, *) select case (eio%version) case ("1.0") write (u, "(2x)", advance = "no") call eio%tag_gen_n%write (var_str ("WHIZARD"), u) write (u, *) write (u, "(2x)", advance = "no") call eio%tag_gen_v%write (var_str ("<>"), u) write (u, *) end select call eio%tag_head%close (u); write (u, *) end subroutine eio_lhef_write_header subroutine eio_lhef_write_footer (eio) class(eio_lhef_t), intent(in) :: eio integer :: u u = given_output_unit (eio%unit); if (u < 0) return call eio%tag_lhef%close (u) end subroutine eio_lhef_write_footer @ %def eio_lhef_write_header eio_lhef_write_footer @ Reading the header just means finding the tags and ignoring any contents. When done, we should stand just after the header tag. <>= procedure :: read_header => eio_lhef_read_header <>= subroutine eio_lhef_read_header (eio) class(eio_lhef_t), intent(inout) :: eio logical :: success, closing type(string_t) :: content call eio%tag_lhef%read (eio%cstream, success) if (.not. success .or. .not. eio%tag_lhef%has_content) call err_lhef if (eio%tag_lhef%get_attribute (1) /= eio%version) call err_version call eio%tag_head%read (eio%cstream, success) if (.not. success) call err_header if (eio%tag_head%has_content) then SKIP_HEADER_CONTENT: do call eio%tag_head%read_content (eio%cstream, content, closing) if (closing) exit SKIP_HEADER_CONTENT end do SKIP_HEADER_CONTENT end if contains subroutine err_lhef call msg_fatal ("LHEF: LesHouchesEvents tag absent or corrupted") end subroutine err_lhef subroutine err_header call msg_fatal ("LHEF: header tag absent or corrupted") end subroutine err_header subroutine err_version call msg_error ("LHEF: version mismatch: expected " & // eio%version // ", found " & // char (eio%tag_lhef%get_attribute (1))) end subroutine err_version end subroutine eio_lhef_read_header @ %def eio_lhef_read_header @ \subsection{Version-Specific Code: 1.0} In version 1.0, the init tag contains just HEPRUP data. While a [[cstream]] is connected to the input unit, we bypass it temporarily for the purpose of reading the HEPRUP contents. This is consistent with the LHEF standard. This routine does not read the closing tag of the init block. <>= procedure :: read_init_10 => eio_lhef_read_init_10 <>= subroutine eio_lhef_read_init_10 (eio, data) class(eio_lhef_t), intent(in) :: eio type(event_sample_data_t), intent(out) :: data integer :: n_proc, i call heprup_read_lhef (eio%unit) call heprup_get_run_parameters (n_processes = n_proc) call data%init (n_proc) data%n_beam = 2 call heprup_get_run_parameters ( & unweighted = data%unweighted, & negative_weights = data%negative_weights, & beam_pdg = data%pdg_beam, & beam_energy = data%energy_beam) if (data%unweighted) then data%norm_mode = NORM_UNIT else data%norm_mode = NORM_SIGMA end if do i = 1, n_proc call heprup_get_process_parameters (i, & process_id = data%proc_num_id(i), & cross_section = data%cross_section(i), & error = data%error(i)) end do end subroutine eio_lhef_read_init_10 @ %def eio_lhef_read_init_10 @ \subsection{Version-Specific Code: 2.0} This is the init information for the 2.0 format, after the HEPRUP data. We have the following tags: \begin{itemize} \item \texttt{generator} Generator name and version. \item \texttt{xsecinfo} Cross section and weights data. We have the total cross section and number of events (assuming that the event file is intact), but information on minimum and maximum weights is not available before the file is complete. We just write the mandatory tags. (Note that the default values of the other tags describe a uniform unit weight, but we can determine most values only after the sample is complete.) \item \texttt{cutsinfo} This optional tag is too specific to represent the possibilities of WHIZARD, so we skip it. \item \texttt{procinfo} This optional tag is useful for giving details of NLO calculations. Skipped. \item \texttt{mergetype} Optional, also not applicable. \end{itemize} <>= procedure :: write_init_20 => eio_lhef_write_init_20 <>= subroutine eio_lhef_write_init_20 (eio, data) class(eio_lhef_t), intent(in) :: eio type(event_sample_data_t), intent(in) :: data integer :: u u = eio%unit call eio%tag_generator%write (u) write (u, "(A)", advance="no") "WHIZARD" call eio%tag_generator%close (u); write (u, *) call eio%tag_xsecinfo%write (u); write (u, *) end subroutine eio_lhef_write_init_20 @ %def eio_lhef_write_init_20 @ When reading the init block, we first call the 1.0 routine that fills HEPRUP. Then we consider the possible tags. Only the \texttt{generator} and \texttt{xsecinfo} tags are of interest. We skip everything else except for the closing tag. <>= procedure :: read_init_20 => eio_lhef_read_init_20 <>= subroutine eio_lhef_read_init_20 (eio, data) class(eio_lhef_t), intent(inout) :: eio type(event_sample_data_t), intent(out) :: data real(default), parameter :: pb_per_fb = 1.e-3_default type(string_t) :: content logical :: found, closing call eio_lhef_read_init_10 (eio, data) SCAN_INIT_TAGS: do call eio%tag_generator%read (eio%cstream, found) if (found) then if (.not. eio%tag_generator%has_content) call err_generator call eio%tag_generator%read_content (eio%cstream, content, closing) call msg_message ("LHEF: Event file has been generated by " & // char (content) // " " & // char (eio%tag_generator%get_attribute (1))) cycle SCAN_INIT_TAGS end if call eio%tag_xsecinfo%read (eio%cstream, found) if (found) then if (eio%tag_xsecinfo%has_content) call err_xsecinfo cycle SCAN_INIT_TAGS end if call eio%tag_init%read_content (eio%cstream, content, closing) if (closing) then if (content /= "") call err_init exit SCAN_INIT_TAGS end if end do SCAN_INIT_TAGS data%n_evt = & read_ival (eio%tag_xsecinfo%get_attribute (1)) data%total_cross_section = & read_rval (eio%tag_xsecinfo%get_attribute (2)) / pb_per_fb contains subroutine err_generator call msg_fatal ("LHEF: invalid generator tag") end subroutine err_generator subroutine err_xsecinfo call msg_fatal ("LHEF: invalid xsecinfo tag") end subroutine err_xsecinfo subroutine err_init call msg_fatal ("LHEF: syntax error after init tag") end subroutine err_init end subroutine eio_lhef_read_init_20 @ %def eio_lhef_read_init_20 @ This is additional event-specific information for the 2.0 format, after the HEPEUP data. We can specify weights, starting from the master weight and adding alternative weights. The alternative weights are collected in a common tag. <>= procedure :: write_event_20 => eio_lhef_write_event_20 <>= subroutine eio_lhef_write_event_20 (eio, event) class(eio_lhef_t), intent(in) :: eio class(generic_event_t), intent(in) :: event type(string_t) :: s integer :: i, u u = eio%unit if (eio%write_sqme_ref) then s = str (event%get_sqme_ref ()) call eio%tag_sqme_ref%write (s, u); write (u, *) end if if (eio%write_sqme_prc) then s = str (event%get_sqme_prc ()) call eio%tag_sqme_prc%write (s, u); write (u, *) end if if (eio%n_alt > 0) then if (eio%write_sqme_alt) then s = str (event%get_sqme_alt(1)) do i = 2, eio%n_alt s = s // " " // str (event%get_sqme_alt(i)); write (u, *) end do call eio%tag_sqme_alt(1)%write (s, u) end if s = str (event%get_weight_alt(1)) do i = 2, eio%n_alt s = s // " " // str (event%get_weight_alt(i)); write (u, *) end do call eio%tag_wgts_alt(1)%write (s, u) end if end subroutine eio_lhef_write_event_20 @ %def eio_lhef_write_event_20 @ Read extra event data. If there is a weight entry labeled [[sqme_prc]], we take this as the squared matrix-element value (the new \emph{reference} value [[sqme_ref]]). Other tags, including tags written by the above writer, are skipped. <>= procedure :: read_event_20 => eio_lhef_read_event_20 <>= subroutine eio_lhef_read_event_20 (eio, event) class(eio_lhef_t), intent(inout) :: eio class(generic_event_t), intent(inout) :: event type(string_t) :: content logical :: found, closing SCAN_EVENT_TAGS: do call eio%tag_weight%read (eio%cstream, found) if (found) then if (.not. eio%tag_weight%has_content) call err_weight call eio%tag_weight%read_content (eio%cstream, content, closing) if (.not. closing) call err_weight if (eio%tag_weight%get_attribute (1) == "sqme_prc") then call event%set_sqme_ref (read_rval (content)) end if cycle SCAN_EVENT_TAGS end if call eio%tag_event%read_content (eio%cstream, content, closing) if (closing) then if (content /= "") call err_event exit SCAN_EVENT_TAGS end if end do SCAN_EVENT_TAGS contains subroutine err_weight call msg_fatal ("LHEF: invalid weight tag in event record") end subroutine err_weight subroutine err_event call msg_fatal ("LHEF: syntax error after event tag") end subroutine err_event end subroutine eio_lhef_read_event_20 @ %def eio_lhef_read_event_20 @ \subsection{Version-Specific Code: 3.0} This is the init information for the 3.0 format, after the HEPRUP data. We have the following tags: \begin{itemize} \item \texttt{generator} Generator name and version. \item \texttt{xsecinfo} Cross section and weights data. We have the total cross section and number of events (assuming that the event file is intact), but information on minimum and maximum weights is not available before the file is complete. We just write the mandatory tags. (Note that the default values of the other tags describe a uniform unit weight, but we can determine most values only after the sample is complete.) \item \texttt{cutsinfo} This optional tag is too specific to represent the possibilities of WHIZARD, so we skip it. \item \texttt{procinfo} This optional tag is useful for giving details of NLO calculations. Skipped. \item \texttt{weightinfo} Determine the meaning of optional weights, whose values are given in the event record. \end{itemize} <>= procedure :: write_init_30 => eio_lhef_write_init_30 <>= subroutine eio_lhef_write_init_30 (eio, data) class(eio_lhef_t), intent(in) :: eio type(event_sample_data_t), intent(in) :: data integer :: u, i u = given_output_unit (eio%unit) call eio%tag_generator%write (u) write (u, "(A)", advance="no") "WHIZARD" call eiO%tag_generator%close (u); write (u, *) call eio%tag_xsecinfo%write (u); write (u, *) if (eio%write_sqme_ref) then call eio%tag_sqme_ref%write (u); write (u, *) end if if (eio%write_sqme_prc) then call eio%tag_sqme_prc%write (u); write (u, *) end if if (eio%write_sqme_alt) then do i = 1, eio%n_alt call eio%tag_sqme_alt(i)%write (u); write (u, *) end do end if do i = 1, eio%n_alt call eio%tag_wgts_alt(i)%write (u); write (u, *) end do end subroutine eio_lhef_write_init_30 @ %def eio_lhef_write_init_30 @ When reading the init block, we first call the 1.0 routine that fills HEPRUP. Then we consider the possible tags. Only the \texttt{generator} and \texttt{xsecinfo} tags are of interest. We skip everything else except for the closing tag. <>= procedure :: read_init_30 => eio_lhef_read_init_30 <>= subroutine eio_lhef_read_init_30 (eio, data) class(eio_lhef_t), intent(inout) :: eio type(event_sample_data_t), intent(out) :: data real(default), parameter :: pb_per_fb = 1.e-3_default type(string_t) :: content logical :: found, closing integer :: n_weightinfo call eio_lhef_read_init_10 (eio, data) n_weightinfo = 0 eio%i_weight_sqme = 0 SCAN_INIT_TAGS: do call eio%tag_generator%read (eio%cstream, found) if (found) then if (.not. eio%tag_generator%has_content) call err_generator call eio%tag_generator%read_content (eio%cstream, content, closing) call msg_message ("LHEF: Event file has been generated by " & // char (content) // " " & // char (eio%tag_generator%get_attribute (1))) cycle SCAN_INIT_TAGS end if call eio%tag_xsecinfo%read (eio%cstream, found) if (found) then if (eio%tag_xsecinfo%has_content) call err_xsecinfo cycle SCAN_INIT_TAGS end if call eio%tag_weightinfo%read (eio%cstream, found) if (found) then if (eio%tag_weightinfo%has_content) call err_xsecinfo n_weightinfo = n_weightinfo + 1 if (eio%tag_weightinfo%get_attribute (1) == "sqme_prc") then eio%i_weight_sqme = n_weightinfo end if cycle SCAN_INIT_TAGS end if call eio%tag_init%read_content (eio%cstream, content, closing) if (closing) then if (content /= "") call err_init exit SCAN_INIT_TAGS end if end do SCAN_INIT_TAGS data%n_evt = & read_ival (eio%tag_xsecinfo%get_attribute (1)) data%total_cross_section = & read_rval (eio%tag_xsecinfo%get_attribute (2)) / pb_per_fb contains subroutine err_generator call msg_fatal ("LHEF: invalid generator tag") end subroutine err_generator subroutine err_xsecinfo call msg_fatal ("LHEF: invalid xsecinfo tag") end subroutine err_xsecinfo subroutine err_init call msg_fatal ("LHEF: syntax error after init tag") end subroutine err_init end subroutine eio_lhef_read_init_30 @ %def eio_lhef_read_init_30 @ This is additional event-specific information for the 3.0 format, after the HEPEUP data. We can specify weights, starting from the master weight and adding alternative weights. The weight tags are already allocated, so we just have to transfer the weight values to strings, assemble them and write them to file. All weights are collected in a single tag. Note: If efficiency turns out to be an issue, we may revert to traditional character buffer writing. However, we need to know the maximum length. <>= procedure :: write_event_30 => eio_lhef_write_event_30 <>= subroutine eio_lhef_write_event_30 (eio, event) class(eio_lhef_t), intent(in) :: eio class(generic_event_t), intent(in) :: event type(string_t) :: s integer :: u, i u = eio%unit s = "" if (eio%write_sqme_ref) then s = s // str (event%get_sqme_ref ()) // " " end if if (eio%write_sqme_prc) then s = s // str (event%get_sqme_prc ()) // " " end if if (eio%n_alt > 0) then if (eio%write_sqme_alt) then s = s // str (event%get_sqme_alt(1)) // " " do i = 2, eio%n_alt s = s // str (event%get_sqme_alt(i)) // " " end do end if s = s // str (event%get_weight_alt(1)) // " " do i = 2, eio%n_alt s = s // str (event%get_weight_alt(i)) // " " end do end if if (len_trim (s) > 0) then call eio%tag_weights%write (trim (s), u); write (u, *) end if end subroutine eio_lhef_write_event_30 @ %def eio_lhef_write_event_30 @ Read extra event data. If there is a [[weights]] tag and if there was a [[weightinfo]] entry labeled [[sqme_prc]], we extract the corresponding entry from the weights string and store this as the event's squared matrix-element value. Other tags, including tags written by the above writer, are skipped. <>= procedure :: read_event_30 => eio_lhef_read_event_30 <>= subroutine eio_lhef_read_event_30 (eio, event) class(eio_lhef_t), intent(inout) :: eio class(generic_event_t), intent(inout) :: event type(string_t) :: content, string logical :: found, closing integer :: i SCAN_EVENT_TAGS: do call eio%tag_weights%read (eio%cstream, found) if (found) then if (.not. eio%tag_weights%has_content) call err_weights call eio%tag_weights%read_content (eio%cstream, content, closing) if (.not. closing) call err_weights if (eio%i_weight_sqme > 0) then SCAN_WEIGHTS: do i = 1, eio%i_weight_sqme call split (content, string, " ") content = adjustl (content) if (i == eio%i_weight_sqme) then call event%set_sqme_ref (read_rval (string)) exit SCAN_WEIGHTS end if end do SCAN_WEIGHTS end if cycle SCAN_EVENT_TAGS end if call eio%tag_event%read_content (eio%cstream, content, closing) if (closing) then if (content /= "") call err_event exit SCAN_EVENT_TAGS end if end do SCAN_EVENT_TAGS contains subroutine err_weights call msg_fatal ("LHEF: invalid weights tag in event record") end subroutine err_weights subroutine err_event call msg_fatal ("LHEF: syntax error after event tag") end subroutine err_event end subroutine eio_lhef_read_event_30 @ %def eio_lhef_read_event_30 @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[eio_lhef_ut.f90]]>>= <> module eio_lhef_ut use unit_tests use eio_lhef_uti <> <> contains <> end module eio_lhef_ut @ %def eio_lhef_ut @ <<[[eio_lhef_uti.f90]]>>= <> module eio_lhef_uti <> <> use io_units use model_data use event_base use eio_data use eio_base use eio_lhef use eio_base_ut, only: eio_prepare_test, eio_cleanup_test use eio_base_ut, only: eio_prepare_fallback_model, eio_cleanup_fallback_model <> <> contains <> end module eio_lhef_uti @ %def eio_lhef_ut @ API: driver for the unit tests below. <>= public :: eio_lhef_test <>= subroutine eio_lhef_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine eio_lhef_test @ %def eio_lhef_test @ \subsubsection{Version 1.0 Output} We test the implementation of all I/O methods. We start with output according to version 1.0. <>= call test (eio_lhef_1, "eio_lhef_1", & "write version 1.0", & u, results) <>= public :: eio_lhef_1 <>= subroutine eio_lhef_1 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(80) :: buffer write (u, "(A)") "* Test output: eio_lhef_1" write (u, "(A)") "* Purpose: generate an event and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) call data%init (1) data%n_evt = 1 data%n_beam = 2 data%unweighted = .true. data%norm_mode = NORM_UNIT data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_lhef_1" allocate (eio_lhef_t :: eio) select type (eio) type is (eio_lhef_t) call eio%set_parameters () end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents:" write (u, "(A)") u_file = free_unit () open (u_file, file = char (sample // "." // eio%extension), & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (buffer(1:21) == " ") buffer = "[...]" if (iostat /= 0) exit write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Reset data" write (u, "(A)") deallocate (eio) allocate (eio_lhef_t :: eio) select type (eio) type is (eio_lhef_t) call eio%set_parameters () end select select type (eio) type is (eio_lhef_t) call eio%set_parameters (keep_beams = .true.) end select call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_lhef_1" end subroutine eio_lhef_1 @ %def eio_lhef_1 @ \subsubsection{Version 2.0 Output} Version 2.0 has added a lot of options to the LHEF format. We implement some of them. <>= call test (eio_lhef_2, "eio_lhef_2", & "write version 2.0", & u, results) <>= public :: eio_lhef_2 <>= subroutine eio_lhef_2 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(80) :: buffer write (u, "(A)") "* Test output: eio_lhef_2" write (u, "(A)") "* Purpose: generate an event and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) call data%init (1) data%unweighted = .false. data%norm_mode = NORM_SIGMA data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_lhef_2" allocate (eio_lhef_t :: eio) select type (eio) type is (eio_lhef_t) call eio%set_parameters (version = "2.0", write_sqme_prc = .true.) end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents:" write (u, "(A)") u_file = free_unit () open (u_file, file = char (sample // "." // eio%extension), & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (buffer(1:10) == ">= call test (eio_lhef_3, "eio_lhef_3", & "write version 3.0", & u, results) <>= public :: eio_lhef_3 <>= subroutine eio_lhef_3 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(80) :: buffer write (u, "(A)") "* Test output: eio_lhef_3" write (u, "(A)") "* Purpose: generate an event and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted = .false.) call data%init (1) data%unweighted = .false. data%norm_mode = NORM_SIGMA data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_lhef_3" allocate (eio_lhef_t :: eio) select type (eio) type is (eio_lhef_t) call eio%set_parameters (version = "3.0", write_sqme_prc = .true.) end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents:" write (u, "(A)") u_file = free_unit () open (u_file, file = char (sample // ".lhe"), & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (buffer(1:10) == ">= call test (eio_lhef_4, "eio_lhef_4", & "read version 1.0", & u, results) <>= public :: eio_lhef_4 <>= subroutine eio_lhef_4 (u) integer, intent(in) :: u class(model_data_t), pointer :: fallback_model class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat, i_prc write (u, "(A)") "* Test output: eio_lhef_4" write (u, "(A)") "* Purpose: read a LHEF 1.0 file" write (u, "(A)") write (u, "(A)") "* Write a LHEF data file" write (u, "(A)") u_file = free_unit () sample = "eio_lhef_4" open (u_file, file = char (sample // ".lhe"), & status = "replace", action = "readwrite") write (u_file, "(A)") '' write (u_file, "(A)") '
' write (u_file, "(A)") ' content' write (u_file, "(A)") ' Text' write (u_file, "(A)") ' ' write (u_file, "(A)") '
' write (u_file, "(A)") '' write (u_file, "(A)") ' 25 25 5.0000000000E+02 5.0000000000E+02 & & -1 -1 -1 -1 3 1' write (u_file, "(A)") ' 1.0000000000E-01 1.0000000000E-03 & & 1.0000000000E+00 42' write (u_file, "(A)") '' write (u_file, "(A)") '' write (u_file, "(A)") ' 4 42 3.0574068604E+08 1.0000000000E+03 & & -1.0000000000E+00 -1.0000000000E+00' write (u_file, "(A)") ' 25 -1 0 0 0 0 0.0000000000E+00 0.0000000000E+00 & & 4.8412291828E+02 5.0000000000E+02 1.2500000000E+02 & & 0.0000000000E+00 9.0000000000E+00' write (u_file, "(A)") ' 25 -1 0 0 0 0 0.0000000000E+00 0.0000000000E+00 & &-4.8412291828E+02 5.0000000000E+02 1.2500000000E+02 & & 0.0000000000E+00 9.0000000000E+00' write (u_file, "(A)") ' 25 1 1 2 0 0 -1.4960220911E+02 -4.6042825611E+02 & & 0.0000000000E+00 5.0000000000E+02 1.2500000000E+02 & & 0.0000000000E+00 9.0000000000E+00' write (u_file, "(A)") ' 25 1 1 2 0 0 1.4960220911E+02 4.6042825611E+02 & & 0.0000000000E+00 5.0000000000E+02 1.2500000000E+02 & & 0.0000000000E+00 9.0000000000E+00' write (u_file, "(A)") '' write (u_file, "(A)") '
' close (u_file) write (u, "(A)") "* Initialize test process" write (u, "(A)") allocate (fallback_model) call eio_prepare_fallback_model (fallback_model) call eio_prepare_test (event, unweighted = .false.) allocate (eio_lhef_t :: eio) select type (eio) type is (eio_lhef_t) call eio%set_parameters (recover_beams = .false.) end select call eio%set_fallback_model (fallback_model) call data%init (1) data%n_beam = 2 data%unweighted = .true. data%norm_mode = NORM_UNIT data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] call data%write (u) write (u, *) write (u, "(A)") "* Initialize and read header" write (u, "(A)") call eio%init_in (sample, data) call eio%write (u) write (u, *) select type (eio) type is (eio_lhef_t) call eio%tag_lhef%write (u); write (u, *) end select write (u, *) call data%write (u) write (u, "(A)") write (u, "(A)") "* Read event" write (u, "(A)") call eio%input_i_prc (i_prc, iostat) select type (eio) type is (eio_lhef_t) write (u, "(A,I0,A,I0)") "Found process #", i_prc, & " with ID = ", eio%proc_num_id(i_prc) end select call eio%input_event (event, iostat) call event%write (u) write (u, "(A)") write (u, "(A)") "* Read closing" write (u, "(A)") call eio%input_i_prc (i_prc, iostat) write (u, "(A,I0)") "iostat = ", iostat write (u, "(A)") write (u, "(A)") "* Cleanup" call eio%final () call eio_cleanup_test (event) call eio_cleanup_fallback_model (fallback_model) deallocate (fallback_model) write (u, "(A)") write (u, "(A)") "* Test output end: eio_lhef_4" end subroutine eio_lhef_4 @ %def eio_lhef_4 @ \subsubsection{Version 2.0 Input} Check input of a version-2.0 conforming LHEF file. <>= call test (eio_lhef_5, "eio_lhef_5", & "read version 2.0", & u, results) <>= public :: eio_lhef_5 <>= subroutine eio_lhef_5 (u) integer, intent(in) :: u class(model_data_t), pointer :: fallback_model class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat, i_prc write (u, "(A)") "* Test output: eio_lhef_5" write (u, "(A)") "* Purpose: read a LHEF 2.0 file" write (u, "(A)") write (u, "(A)") "* Write a LHEF data file" write (u, "(A)") u_file = free_unit () sample = "eio_lhef_5" open (u_file, file = char (sample // ".lhe"), & status = "replace", action = "readwrite") write (u_file, "(A)") '' write (u_file, "(A)") '
' write (u_file, "(A)") '
' write (u_file, "(A)") '' write (u_file, "(A)") ' 25 25 5.0000000000E+02 5.0000000000E+02 & &-1 -1 -1 -1 4 1' write (u_file, "(A)") ' 1.0000000000E-01 1.0000000000E-03 & & 0.0000000000E+00 42' write (u_file, "(A)") 'WHIZARD& &' write (u_file, "(A)") '' write (u_file, "(A)") '' write (u_file, "(A)") '' write (u_file, "(A)") ' 4 42 3.0574068604E+08 1.0000000000E+03 & &-1.0000000000E+00 -1.0000000000E+00' write (u_file, "(A)") ' 25 -1 0 0 0 0 0.0000000000E+00 & & 0.0000000000E+00 4.8412291828E+02 5.0000000000E+02 & & 1.2500000000E+02 0.0000000000E+00 9.0000000000E+00' write (u_file, "(A)") ' 25 -1 0 0 0 0 0.0000000000E+00 & & 0.0000000000E+00 -4.8412291828E+02 5.0000000000E+02 & & 1.2500000000E+02 0.0000000000E+00 9.0000000000E+00' write (u_file, "(A)") ' 25 1 1 2 0 0 -1.4960220911E+02 & &-4.6042825611E+02 0.0000000000E+00 5.0000000000E+02 & & 1.2500000000E+02 0.0000000000E+00 9.0000000000E+00' write (u_file, "(A)") ' 25 1 1 2 0 0 1.4960220911E+02 & & 4.6042825611E+02 0.0000000000E+00 5.0000000000E+02 & & 1.2500000000E+02 0.0000000000E+00 9.0000000000E+00' write (u_file, "(A)") '1.0000000000E+00' write (u_file, "(A)") '' write (u_file, "(A)") '
' close (u_file) write (u, "(A)") "* Initialize test process" write (u, "(A)") allocate (fallback_model) call eio_prepare_fallback_model (fallback_model) call eio_prepare_test (event, unweighted = .false.) allocate (eio_lhef_t :: eio) select type (eio) type is (eio_lhef_t) call eio%set_parameters (version = "2.0", recover_beams = .false.) end select call eio%set_fallback_model (fallback_model) call data%init (1) data%unweighted = .false. data%norm_mode = NORM_SIGMA data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] call data%write (u) write (u, *) write (u, "(A)") "* Initialize and read header" write (u, "(A)") call eio%init_in (sample, data) call eio%write (u) write (u, *) select type (eio) type is (eio_lhef_t) call eio%tag_lhef%write (u); write (u, *) end select write (u, *) call data%write (u) write (u, "(A)") write (u, "(A)") "* Read event" write (u, "(A)") call eio%input_i_prc (i_prc, iostat) select type (eio) type is (eio_lhef_t) write (u, "(A,I0,A,I0)") "Found process #", i_prc, & " with ID = ", eio%proc_num_id(i_prc) end select call eio%input_event (event, iostat) call event%write (u) write (u, "(A)") write (u, "(A)") "* Read closing" write (u, "(A)") call eio%input_i_prc (i_prc, iostat) write (u, "(A,I0)") "iostat = ", iostat write (u, "(A)") write (u, "(A)") "* Cleanup" call eio%final () call eio_cleanup_test (event) call eio_cleanup_fallback_model (fallback_model) deallocate (fallback_model) write (u, "(A)") write (u, "(A)") "* Test output end: eio_lhef_5" end subroutine eio_lhef_5 @ %def eio_lhef_5 @ \subsubsection{Version 3.0 Input} Check input of a version-3.0 conforming LHEF file. <>= call test (eio_lhef_6, "eio_lhef_6", & "read version 3.0", & u, results) <>= public :: eio_lhef_6 <>= subroutine eio_lhef_6 (u) integer, intent(in) :: u class(model_data_t), pointer :: fallback_model class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat, i_prc write (u, "(A)") "* Test output: eio_lhef_6" write (u, "(A)") "* Purpose: read a LHEF 3.0 file" write (u, "(A)") write (u, "(A)") "* Write a LHEF data file" write (u, "(A)") u_file = free_unit () sample = "eio_lhef_6" open (u_file, file = char (sample // ".lhe"), & status = "replace", action = "readwrite") write (u_file, "(A)") '' write (u_file, "(A)") '
' write (u_file, "(A)") '
' write (u_file, "(A)") '' write (u_file, "(A)") ' 25 25 5.0000000000E+02 5.0000000000E+02 & &-1 -1 -1 -1 4 1' write (u_file, "(A)") ' 1.0000000000E-01 1.0000000000E-03 & & 0.0000000000E+00 42' write (u_file, "(A)") 'WHIZARD& &' write (u_file, "(A)") '' write (u_file, "(A)") '' write (u_file, "(A)") '' write (u_file, "(A)") '' write (u_file, "(A)") ' 4 42 3.0574068604E+08 1.0000000000E+03 & &-1.0000000000E+00 -1.0000000000E+00' write (u_file, "(A)") ' 25 -1 0 0 0 0 0.0000000000E+00 & & 0.0000000000E+00 4.8412291828E+02 5.0000000000E+02 & & 1.2500000000E+02 0.0000000000E+00 9.0000000000E+00' write (u_file, "(A)") ' 25 -1 0 0 0 0 0.0000000000E+00 & & 0.0000000000E+00 -4.8412291828E+02 5.0000000000E+02 & & 1.2500000000E+02 0.0000000000E+00 9.0000000000E+00' write (u_file, "(A)") ' 25 1 1 2 0 0 -1.4960220911E+02 & &-4.6042825611E+02 0.0000000000E+00 5.0000000000E+02 & & 1.2500000000E+02 0.0000000000E+00 9.0000000000E+00' write (u_file, "(A)") ' 25 1 1 2 0 0 1.4960220911E+02 & & 4.6042825611E+02 0.0000000000E+00 5.0000000000E+02 & & 1.2500000000E+02 0.0000000000E+00 9.0000000000E+00' write (u_file, "(A)") '1.0000000000E+00' write (u_file, "(A)") '' write (u_file, "(A)") '
' close (u_file) write (u, "(A)") "* Initialize test process" write (u, "(A)") allocate (fallback_model) call eio_prepare_fallback_model (fallback_model) call eio_prepare_test (event, unweighted = .false.) allocate (eio_lhef_t :: eio) select type (eio) type is (eio_lhef_t) call eio%set_parameters (version = "3.0", recover_beams = .false.) end select call eio%set_fallback_model (fallback_model) call data%init (1) data%unweighted = .false. data%norm_mode = NORM_SIGMA data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] call data%write (u) write (u, *) write (u, "(A)") "* Initialize and read header" write (u, "(A)") call eio%init_in (sample, data) call eio%write (u) write (u, *) select type (eio) type is (eio_lhef_t) call eio%tag_lhef%write (u); write (u, *) end select write (u, *) call data%write (u) write (u, "(A)") write (u, "(A)") "* Read event" write (u, "(A)") call eio%input_i_prc (i_prc, iostat) select type (eio) type is (eio_lhef_t) write (u, "(A,I0,A,I0)") "Found process #", i_prc, & " with ID = ", eio%proc_num_id(i_prc) end select call eio%input_event (event, iostat) call event%write (u) write (u, "(A)") write (u, "(A)") "* Read closing" write (u, "(A)") call eio%input_i_prc (i_prc, iostat) write (u, "(A,I0)") "iostat = ", iostat write (u, "(A)") write (u, "(A)") "* Cleanup" call eio%final () call eio_cleanup_test (event) call eio_cleanup_fallback_model (fallback_model) deallocate (fallback_model) write (u, "(A)") write (u, "(A)") "* Test output end: eio_lhef_6" end subroutine eio_lhef_6 @ %def eio_lhef_6 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{STDHEP File Formats} Here, we implement the two existing STDHEP file formats, one based on the HEPRUP/HEPEUP common blocks, the other based on the HEPEVT common block. The second one is actually the standard STDHEP format. <<[[eio_stdhep.f90]]>>= <> module eio_stdhep use kinds, only: i32, i64 <> use io_units use string_utils use diagnostics use event_base + use event_handles, only: event_handle_t use hep_common use hep_events use eio_data use eio_base <> <> <> <> contains <> end module eio_stdhep @ %def eio_stdhep @ \subsection{Type} <>= public :: eio_stdhep_t <>= type, abstract, extends (eio_t) :: eio_stdhep_t logical :: writing = .false. logical :: reading = .false. integer :: unit = 0 logical :: keep_beams = .false. logical :: keep_remnants = .true. logical :: ensure_order = .false. logical :: recover_beams = .false. logical :: use_alphas_from_file = .false. logical :: use_scale_from_file = .false. integer, dimension(:), allocatable :: proc_num_id integer(i64) :: n_events_expected = 0 contains <> end type eio_stdhep_t @ %def eio_stdhep_t @ <>= public :: eio_stdhep_hepevt_t <>= type, extends (eio_stdhep_t) :: eio_stdhep_hepevt_t end type eio_stdhep_hepevt_t @ %def eio_stdhep_hepevt_t @ <>= public :: eio_stdhep_hepeup_t <>= type, extends (eio_stdhep_t) :: eio_stdhep_hepeup_t end type eio_stdhep_hepeup_t @ %def eio_stdhep_hepeup_t @ <>= public :: eio_stdhep_hepev4_t <>= type, extends (eio_stdhep_t) :: eio_stdhep_hepev4_t end type eio_stdhep_hepev4_t @ %def eio_stdhep_hepev4_t @ \subsection{Specific Methods} Set parameters that are specifically used with STDHEP file formats. <>= procedure :: set_parameters => eio_stdhep_set_parameters <>= subroutine eio_stdhep_set_parameters (eio, & keep_beams, keep_remnants, ensure_order, recover_beams, & use_alphas_from_file, use_scale_from_file, extension) class(eio_stdhep_t), intent(inout) :: eio logical, intent(in), optional :: keep_beams logical, intent(in), optional :: keep_remnants logical, intent(in), optional :: ensure_order logical, intent(in), optional :: recover_beams logical, intent(in), optional :: use_alphas_from_file logical, intent(in), optional :: use_scale_from_file type(string_t), intent(in), optional :: extension if (present (keep_beams)) eio%keep_beams = keep_beams if (present (keep_remnants)) eio%keep_remnants = keep_remnants if (present (ensure_order)) eio%ensure_order = ensure_order if (present (recover_beams)) eio%recover_beams = recover_beams if (present (use_alphas_from_file)) & eio%use_alphas_from_file = use_alphas_from_file if (present (use_scale_from_file)) & eio%use_scale_from_file = use_scale_from_file if (present (extension)) then eio%extension = extension else select type (eio) type is (eio_stdhep_hepevt_t) eio%extension = "hep" type is (eio_stdhep_hepev4_t) eio%extension = "ev4.hep" type is (eio_stdhep_hepeup_t) eio%extension = "up.hep" end select end if end subroutine eio_stdhep_set_parameters @ %def eio_ascii_stdhep_parameters @ \subsection{Common Methods} Output. This is not the actual event format, but a readable account of the current object status. <>= procedure :: write => eio_stdhep_write <>= subroutine eio_stdhep_write (object, unit) class(eio_stdhep_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit) write (u, "(1x,A)") "STDHEP event stream:" if (object%writing) then write (u, "(3x,A,A)") "Writing to file = ", char (object%filename) else if (object%reading) then write (u, "(3x,A,A)") "Reading from file = ", char (object%filename) else write (u, "(3x,A)") "[closed]" end if write (u, "(3x,A,L1)") "Keep beams = ", object%keep_beams write (u, "(3x,A,L1)") "Keep remnants = ", object%keep_remnants write (u, "(3x,A,L1)") "Recover beams = ", object%recover_beams write (u, "(3x,A,L1)") "Alpha_s from file = ", & object%use_alphas_from_file write (u, "(3x,A,L1)") "Scale from file = ", & object%use_scale_from_file if (allocated (object%proc_num_id)) then write (u, "(3x,A)") "Numerical process IDs:" do i = 1, size (object%proc_num_id) write (u, "(5x,I0,': ',I0)") i, object%proc_num_id(i) end do end if end subroutine eio_stdhep_write @ %def eio_stdhep_write @ Finalizer: close any open file. <>= procedure :: final => eio_stdhep_final <>= subroutine eio_stdhep_final (object) class(eio_stdhep_t), intent(inout) :: object if (allocated (object%proc_num_id)) deallocate (object%proc_num_id) if (object%writing) then write (msg_buffer, "(A,A,A)") "Events: closing STDHEP file '", & char (object%filename), "'" call msg_message () call stdhep_write (200) call stdhep_end () object%writing = .false. else if (object%reading) then write (msg_buffer, "(A,A,A)") "Events: closing STDHEP file '", & char (object%filename), "'" call msg_message () object%reading = .false. end if end subroutine eio_stdhep_final @ %def eio_stdhep_final @ Common initialization for input and output. <>= procedure :: common_init => eio_stdhep_common_init <>= subroutine eio_stdhep_common_init (eio, sample, data, extension) class(eio_stdhep_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(in), optional :: data if (.not. present (data)) & call msg_bug ("STDHEP initialization: missing data") if (data%n_beam /= 2) & call msg_fatal ("STDHEP: defined for scattering processes only") if (present (extension)) then eio%extension = extension end if eio%sample = sample call eio%set_filename () eio%unit = free_unit () allocate (eio%proc_num_id (data%n_proc), source = data%proc_num_id) end subroutine eio_stdhep_common_init @ %def eio_stdhep_common_init @ Split event file: increment the counter, close the current file, open a new one. If the file needs a header, repeat it for the new file. (We assume that the common block contents are still intact.) <>= procedure :: split_out => eio_stdhep_split_out <>= subroutine eio_stdhep_split_out (eio) class(eio_stdhep_t), intent(inout) :: eio if (eio%split) then eio%split_index = eio%split_index + 1 call eio%set_filename () write (msg_buffer, "(A,A,A)") "Events: writing to STDHEP file '", & char (eio%filename), "'" call msg_message () call stdhep_write (200) call stdhep_end () select type (eio) type is (eio_stdhep_hepeup_t) call stdhep_init_out (char (eio%filename), & "WHIZARD <>", eio%n_events_expected) call stdhep_write (100) call stdhep_write (STDHEP_HEPRUP) type is (eio_stdhep_hepevt_t) call stdhep_init_out (char (eio%filename), & "WHIZARD <>", eio%n_events_expected) call stdhep_write (100) type is (eio_stdhep_hepev4_t) call stdhep_init_out (char (eio%filename), & "WHIZARD <>", eio%n_events_expected) call stdhep_write (100) end select end if end subroutine eio_stdhep_split_out @ %def eio_stdhep_split_out @ Initialize event writing. <>= procedure :: init_out => eio_stdhep_init_out <>= subroutine eio_stdhep_init_out (eio, sample, data, success, extension) class(eio_stdhep_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(in), optional :: data logical, intent(out), optional :: success integer :: i if (.not. present (data)) & call msg_bug ("STDHEP initialization: missing data") call eio%set_splitting (data) call eio%common_init (sample, data, extension) eio%n_events_expected = data%n_evt write (msg_buffer, "(A,A,A)") "Events: writing to STDHEP file '", & char (eio%filename), "'" call msg_message () eio%writing = .true. select type (eio) type is (eio_stdhep_hepeup_t) call heprup_init & (data%pdg_beam, & data%energy_beam, & n_processes = data%n_proc, & unweighted = data%unweighted, & negative_weights = data%negative_weights) do i = 1, data%n_proc call heprup_set_process_parameters (i = i, & process_id = data%proc_num_id(i), & cross_section = data%cross_section(i), & error = data%error(i)) end do call stdhep_init_out (char (eio%filename), & "WHIZARD <>", eio%n_events_expected) call stdhep_write (100) call stdhep_write (STDHEP_HEPRUP) type is (eio_stdhep_hepevt_t) call stdhep_init_out (char (eio%filename), & "WHIZARD <>", eio%n_events_expected) call stdhep_write (100) type is (eio_stdhep_hepev4_t) call stdhep_init_out (char (eio%filename), & "WHIZARD <>", eio%n_events_expected) call stdhep_write (100) end select if (present (success)) success = .true. end subroutine eio_stdhep_init_out @ %def eio_stdhep_init_out @ Initialize event reading. <>= procedure :: init_in => eio_stdhep_init_in <>= subroutine eio_stdhep_init_in (eio, sample, data, success, extension) class(eio_stdhep_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(inout), optional :: data logical, intent(out), optional :: success integer :: ilbl, lok logical :: exist call eio%common_init (sample, data, extension) write (msg_buffer, "(A,A,A)") "Events: reading from STDHEP file '", & char (eio%filename), "'" call msg_message () inquire (file = char (eio%filename), exist = exist) if (.not. exist) call msg_fatal ("Events: STDHEP file not found.") eio%reading = .true. call stdhep_init_in (char (eio%filename), eio%n_events_expected) call stdhep_read (ilbl, lok) if (lok /= 0) then call stdhep_end () write (msg_buffer, "(A)") "Events: STDHEP file appears to" // & " be empty." call msg_message () end if if (ilbl == 100) then write (msg_buffer, "(A)") "Events: reading in STDHEP events" call msg_message () end if if (present (success)) success = .false. end subroutine eio_stdhep_init_in @ %def eio_stdhep_init_in @ Switch from input to output: reopen the file for reading. <>= procedure :: switch_inout => eio_stdhep_switch_inout <>= subroutine eio_stdhep_switch_inout (eio, success) class(eio_stdhep_t), intent(inout) :: eio logical, intent(out), optional :: success call msg_bug ("STDHEP: in-out switch not supported") if (present (success)) success = .false. end subroutine eio_stdhep_switch_inout @ %def eio_stdhep_switch_inout @ Output an event. Write first the event indices, then weight and squared matrix element, then the particle set. <>= procedure :: output => eio_stdhep_output <>= - subroutine eio_stdhep_output (eio, event, i_prc, reading, passed, pacify) + subroutine eio_stdhep_output & + (eio, event, i_prc, reading, passed, pacify, event_handle) class(eio_stdhep_t), intent(inout) :: eio class(generic_event_t), intent(in), target :: event integer, intent(in) :: i_prc logical, intent(in), optional :: reading, passed, pacify + class(event_handle_t), intent(inout), optional :: event_handle if (present (passed)) then if (.not. passed) return end if if (eio%writing) then select type (eio) type is (eio_stdhep_hepeup_t) call hepeup_from_event (event, & process_index = eio%proc_num_id (i_prc), & keep_beams = eio%keep_beams, & keep_remnants = eio%keep_remnants) call stdhep_write (STDHEP_HEPEUP) type is (eio_stdhep_hepevt_t) call hepevt_from_event (event, & keep_beams = eio%keep_beams, & keep_remnants = eio%keep_remnants, & ensure_order = eio%ensure_order) call stdhep_write (STDHEP_HEPEVT) type is (eio_stdhep_hepev4_t) call hepevt_from_event (event, & process_index = eio%proc_num_id (i_prc), & keep_beams = eio%keep_beams, & keep_remnants = eio%keep_remnants, & ensure_order = eio%ensure_order, & fill_hepev4 = .true.) call stdhep_write (STDHEP_HEPEV4) end select else call eio%write () call msg_fatal ("STDHEP file is not open for writing") end if end subroutine eio_stdhep_output @ %def eio_stdhep_output @ Input an event. We do not allow to read in STDHEP files written via the HEPEVT common block as there is no control on the process ID. This implies that the event index cannot be read; it is simply incremented to count the current event sample. <>= procedure :: input_i_prc => eio_stdhep_input_i_prc procedure :: input_event => eio_stdhep_input_event <>= subroutine eio_stdhep_input_i_prc (eio, i_prc, iostat) class(eio_stdhep_t), intent(inout) :: eio integer, intent(out) :: i_prc integer, intent(out) :: iostat integer :: i, ilbl, proc_num_id iostat = 0 select type (eio) type is (eio_stdhep_hepevt_t) if (size (eio%proc_num_id) > 1) then call msg_fatal ("Events: only single processes allowed " // & "with the STDHEP HEPEVT format.") else proc_num_id = eio%proc_num_id (1) call stdhep_read (ilbl, lok) end if type is (eio_stdhep_hepev4_t) call stdhep_read (ilbl, lok) proc_num_id = idruplh type is (eio_stdhep_hepeup_t) call stdhep_read (ilbl, lok) if (lok /= 0) call msg_error ("Events: STDHEP appears to be " // & "empty or corrupted.") if (ilbl == 12) then call stdhep_read (ilbl, lok) end if if (ilbl == 11) then proc_num_id = IDPRUP end if end select FIND_I_PRC: do i = 1, size (eio%proc_num_id) if (eio%proc_num_id(i) == proc_num_id) then i_prc = i exit FIND_I_PRC end if end do FIND_I_PRC if (i_prc == 0) call err_index contains subroutine err_index call msg_error ("STDHEP: reading events: undefined process ID " & // char (str (proc_num_id)) // ", aborting read") iostat = 1 end subroutine err_index end subroutine eio_stdhep_input_i_prc - subroutine eio_stdhep_input_event (eio, event, iostat) + subroutine eio_stdhep_input_event (eio, event, iostat, event_handle) class(eio_stdhep_t), intent(inout) :: eio class(generic_event_t), intent(inout), target :: event integer, intent(out) :: iostat + class(event_handle_t), intent(inout), optional :: event_handle iostat = 0 call event%reset_contents () call event%select (1, 1, 1) call hepeup_to_event (event, eio%fallback_model, & recover_beams = eio%recover_beams, & use_alpha_s = eio%use_alphas_from_file, & use_scale = eio%use_scale_from_file) call event%increment_index () end subroutine eio_stdhep_input_event @ %def eio_stdhep_input_i_prc @ %def eio_stdhep_input_event <>= procedure :: skip => eio_stdhep_skip <>= subroutine eio_stdhep_skip (eio, iostat) class(eio_stdhep_t), intent(inout) :: eio integer, intent(out) :: iostat if (eio%reading) then read (eio%unit, iostat = iostat) else call eio%write () call msg_fatal ("Raw event file is not open for reading") end if end subroutine eio_stdhep_skip @ %def eio_stdhep_skip @ STDHEP speficic routines. <>= public :: stdhep_init_out public :: stdhep_init_in public :: stdhep_write public :: stdhep_end <>= subroutine stdhep_init_out (file, title, nevt) character(len=*), intent(in) :: file, title integer(i64), intent(in) :: nevt integer(i32) :: nevt32 nevt32 = min (nevt, int (huge (1_i32), i64)) call stdxwinit (file, title, nevt32, istr, lok) end subroutine stdhep_init_out subroutine stdhep_init_in (file, nevt) character(len=*), intent(in) :: file integer(i64), intent(out) :: nevt integer(i32) :: nevt32 call stdxrinit (file, nevt32, istr, lok) if (lok /= 0) call msg_fatal ("STDHEP: error in reading file '" // & file // "'.") nevt = int (nevt32, i64) end subroutine stdhep_init_in subroutine stdhep_write (ilbl) integer, intent(in) :: ilbl call stdxwrt (ilbl, istr, lok) end subroutine stdhep_write subroutine stdhep_read (ilbl, lok) integer, intent(out) :: ilbl, lok call stdxrd (ilbl, istr, lok) if (lok /= 0) return end subroutine stdhep_read subroutine stdhep_end call stdxend (istr) end subroutine stdhep_end @ %def stdhep_init stdhep_read stdhep_write stdhep_end @ \subsection{Variables} <>= integer, save :: istr, lok integer, parameter :: & STDHEP_HEPEVT = 1, STDHEP_HEPEV4 = 4, & STDHEP_HEPEUP = 11, STDHEP_HEPRUP = 12 @ @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[eio_stdhep_ut.f90]]>>= <> module eio_stdhep_ut use unit_tests use eio_stdhep_uti <> <> contains <> end module eio_stdhep_ut @ %def eio_stdhep_ut @ <<[[eio_stdhep_uti.f90]]>>= <> module eio_stdhep_uti <> <> use io_units use model_data use event_base use eio_data use eio_base use xdr_wo_stdhep use eio_stdhep use eio_base_ut, only: eio_prepare_test, eio_cleanup_test use eio_base_ut, only: eio_prepare_fallback_model, eio_cleanup_fallback_model <> <> contains <> end module eio_stdhep_uti @ %def eio_stdhep_ut @ API: driver for the unit tests below. <>= public :: eio_stdhep_test <>= subroutine eio_stdhep_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine eio_stdhep_test @ %def eio_stdhep_test @ \subsubsection{Test I/O methods} We test the implementation of the STDHEP HEPEVT I/O method: <>= call test (eio_stdhep_1, "eio_stdhep_1", & "read and write event contents, format [stdhep]", & u, results) <>= public :: eio_stdhep_1 <>= subroutine eio_stdhep_1 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(215) :: buffer write (u, "(A)") "* Test output: eio_stdhep_1" write (u, "(A)") "* Purpose: generate an event in STDHEP HEPEVT format" write (u, "(A)") "* and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event) call data%init (1) data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_stdhep_1" allocate (eio_stdhep_hepevt_t :: eio) select type (eio) type is (eio_stdhep_hepevt_t) call eio%set_parameters () end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%set_index (61) ! not supported by reader, actually call event%evaluate_expressions () call event%pacify_particle_set () call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* Write STDHEP file contents to ASCII file" write (u, "(A)") call write_stdhep_event & (sample // ".hep", var_str ("eio_stdhep_1.hep.out"), 1) write (u, "(A)") write (u, "(A)") "* Read in ASCII contents of STDHEP file" write (u, "(A)") u_file = free_unit () open (u_file, file = "eio_stdhep_1.hep.out", & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (iostat /= 0) exit if (trim (buffer) == "") cycle if (buffer(1:18) == " total blocks: ") & buffer = " total blocks: [...]" if (buffer(1:25) == " title: WHIZARD") & buffer = " title: WHIZARD [version]" if (buffer(1:17) == " date:") & buffer = " date: [...]" if (buffer(1:17) == " closing date:") & buffer = " closing date: [...]" write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Reset data" write (u, "(A)") deallocate (eio) allocate (eio_stdhep_hepevt_t :: eio) select type (eio) type is (eio_stdhep_hepevt_t) call eio%set_parameters (keep_beams = .true.) end select call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_stdhep_1" end subroutine eio_stdhep_1 @ %def eio_stdhep_1 @ We test the implementation of the STDHEP HEPEUP I/O method: <>= call test (eio_stdhep_2, "eio_stdhep_2", & "read and write event contents, format [stdhep]", & u, results) <>= public :: eio_stdhep_2 <>= subroutine eio_stdhep_2 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(model_data_t), pointer :: fallback_model class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(215) :: buffer write (u, "(A)") "* Test output: eio_stdhep_2" write (u, "(A)") "* Purpose: generate an event in STDHEP HEPEUP format" write (u, "(A)") "* and write weight to file" write (u, "(A)") write (u, "(A)") "* Initialize test process" allocate (fallback_model) call eio_prepare_fallback_model (fallback_model) call eio_prepare_test (event, unweighted = .false.) call data%init (1) data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_stdhep_2" allocate (eio_stdhep_hepeup_t :: eio) select type (eio) type is (eio_stdhep_hepeup_t) call eio%set_parameters () end select call eio%set_fallback_model (fallback_model) call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%set_index (62) ! not supported by reader, actually call event%evaluate_expressions () call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* Write STDHEP file contents to ASCII file" write (u, "(A)") call write_stdhep_event & (sample // ".up.hep", var_str ("eio_stdhep_2.hep.out"), 2) write (u, "(A)") write (u, "(A)") "* Read in ASCII contents of STDHEP file" write (u, "(A)") u_file = free_unit () open (u_file, file = "eio_stdhep_2.hep.out", & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (iostat /= 0) exit if (trim (buffer) == "") cycle if (buffer(1:18) == " total blocks: ") & buffer = " total blocks: [...]" if (buffer(1:25) == " title: WHIZARD") & buffer = " title: WHIZARD [version]" if (buffer(1:17) == " date:") & buffer = " date: [...]" if (buffer(1:17) == " closing date:") & buffer = " closing date: [...]" write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Reset data" write (u, "(A)") deallocate (eio) allocate (eio_stdhep_hepeup_t :: eio) select type (eio) type is (eio_stdhep_hepeup_t) call eio%set_parameters (keep_beams = .true.) end select call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) call eio_cleanup_fallback_model (fallback_model) deallocate (fallback_model) write (u, "(A)") write (u, "(A)") "* Test output end: eio_stdhep_2" end subroutine eio_stdhep_2 @ %def eio_stdhep_2 @ Check input from a StdHep file, HEPEVT block. <>= call test (eio_stdhep_3, "eio_stdhep_3", & "read StdHep file, HEPEVT block", & u, results) <>= public :: eio_stdhep_3 <>= subroutine eio_stdhep_3 (u) integer, intent(in) :: u class(model_data_t), pointer :: fallback_model class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: iostat, i_prc write (u, "(A)") "* Test output: eio_stdhep_3" write (u, "(A)") "* Purpose: read a StdHep file, HEPEVT block" write (u, "(A)") write (u, "(A)") "* Write a StdHep data file, HEPEVT block" write (u, "(A)") allocate (fallback_model) call eio_prepare_fallback_model (fallback_model) call eio_prepare_test (event) call data%init (1) data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_stdhep_3" allocate (eio_stdhep_hepevt_t :: eio) select type (eio) type is (eio_stdhep_hepevt_t) call eio%set_parameters () end select call eio%set_fallback_model (fallback_model) call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%set_index (63) ! not supported by reader, actually call event%evaluate_expressions () call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () call eio_cleanup_test (event) call eio_cleanup_fallback_model (fallback_model) deallocate (eio) deallocate (fallback_model) write (u, "(A)") "* Initialize test process" write (u, "(A)") allocate (fallback_model) call eio_prepare_fallback_model (fallback_model) call eio_prepare_test (event, unweighted = .false.) allocate (eio_stdhep_hepevt_t :: eio) select type (eio) type is (eio_stdhep_hepevt_t) call eio%set_parameters (recover_beams = .false.) end select call eio%set_fallback_model (fallback_model) call data%init (1) data%n_beam = 2 data%unweighted = .true. data%norm_mode = NORM_UNIT data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] call data%write (u) write (u, *) write (u, "(A)") "* Initialize" write (u, "(A)") call eio%init_in (sample, data) call eio%write (u) write (u, "(A)") write (u, "(A)") "* Read event" write (u, "(A)") call eio%input_i_prc (i_prc, iostat) select type (eio) type is (eio_stdhep_hepevt_t) write (u, "(A,I0,A,I0)") "Found process #", i_prc, & " with ID = ", eio%proc_num_id(i_prc) end select call eio%input_event (event, iostat) call event%write (u) write (u, "(A)") write (u, "(A)") "* Read closing" write (u, "(A)") call eio%input_i_prc (i_prc, iostat) write (u, "(A,I0)") "iostat = ", iostat write (u, "(A)") write (u, "(A)") "* Cleanup" call eio%final () call eio_cleanup_test (event) call eio_cleanup_fallback_model (fallback_model) deallocate (fallback_model) write (u, "(A)") write (u, "(A)") "* Test output end: eio_stdhep_3" end subroutine eio_stdhep_3 @ %def eio_stdhep_3 @ Check input from a StdHep file, HEPEVT block. <>= call test (eio_stdhep_4, "eio_stdhep_4", & "read StdHep file, HEPRUP/HEPEUP block", & u, results) <>= public :: eio_stdhep_4 <>= subroutine eio_stdhep_4 (u) integer, intent(in) :: u class(model_data_t), pointer :: fallback_model class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: iostat, i_prc write (u, "(A)") "* Test output: eio_stdhep_3" write (u, "(A)") "* Purpose: read a StdHep file, HEPRUP/HEPEUP block" write (u, "(A)") write (u, "(A)") "* Write a StdHep data file, HEPRUP/HEPEUP block" write (u, "(A)") allocate (fallback_model) call eio_prepare_fallback_model (fallback_model) call eio_prepare_test (event) call data%init (1) data%n_evt = 1 data%n_beam = 2 data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event, HEPEUP/HEPRUP" write (u, "(A)") sample = "eio_stdhep_4" allocate (eio_stdhep_hepeup_t :: eio) select type (eio) type is (eio_stdhep_hepeup_t) call eio%set_parameters () end select call eio%set_fallback_model (fallback_model) call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%set_index (64) ! not supported by reader, actually call event%evaluate_expressions () call event%pacify_particle_set () call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () call eio_cleanup_test (event) call eio_cleanup_fallback_model (fallback_model) deallocate (eio) deallocate (fallback_model) write (u, "(A)") "* Initialize test process" write (u, "(A)") allocate (fallback_model) call eio_prepare_fallback_model (fallback_model) call eio_prepare_test (event, unweighted = .false.) allocate (eio_stdhep_hepeup_t :: eio) select type (eio) type is (eio_stdhep_hepeup_t) call eio%set_parameters (recover_beams = .false.) end select call eio%set_fallback_model (fallback_model) call data%init (1) data%n_beam = 2 data%unweighted = .true. data%norm_mode = NORM_UNIT data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] call data%write (u) write (u, *) write (u, "(A)") "* Initialize" write (u, "(A)") call eio%init_in (sample, data) call eio%write (u) write (u, "(A)") write (u, "(A)") "* Read event" write (u, "(A)") call eio%input_i_prc (i_prc, iostat) select type (eio) type is (eio_stdhep_hepeup_t) write (u, "(A,I0,A,I0)") "Found process #", i_prc, & " with ID = ", eio%proc_num_id(i_prc) end select call eio%input_event (event, iostat) call event%write (u) write (u, "(A)") write (u, "(A)") "* Read closing" write (u, "(A)") call eio%input_i_prc (i_prc, iostat) write (u, "(A,I0)") "iostat = ", iostat write (u, "(A)") write (u, "(A)") "* Cleanup" call eio%final () call eio_cleanup_test (event) call eio_cleanup_fallback_model (fallback_model) deallocate (fallback_model) write (u, "(A)") write (u, "(A)") "* Test output end: eio_stdhep_4" end subroutine eio_stdhep_4 @ %def eio_stdhep_4 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{HepMC Output} The HepMC event record is standardized. It is an ASCII format. We try our best at using it for both input and output. <<[[eio_hepmc.f90]]>>= <> module eio_hepmc <> <> use io_units use string_utils use diagnostics use particles use model_data use event_base + use event_handles, only: event_handle_t use hep_events use eio_data use eio_base use hepmc_interface <> <> <> contains <> end module eio_hepmc @ %def eio_hepmc @ \subsection{Type} A type [[hepmc_event]] is introduced as container to store HepMC event data, particularly for splitting the reading into read out of the process index and the proper event data. Note: the [[keep_beams]] flag is not supported. Beams will always be written. Tools like \texttt{Rivet} can use the cross section information of a HepMC file for scaling plots. As there is no header in HepMC and this is written for every event, we make it optional with [[output_cross_section]]. <>= public :: eio_hepmc_t <>= type, extends (eio_t) :: eio_hepmc_t logical :: writing = .false. logical :: reading = .false. type(event_sample_data_t) :: data ! logical :: keep_beams = .false. logical :: recover_beams = .false. logical :: use_alphas_from_file = .false. logical :: use_scale_from_file = .false. logical :: output_cross_section = .false. integer :: hepmc3_mode = HEPMC3_MODE_HEPMC3 type(hepmc_iostream_t) :: iostream type(hepmc_event_t) :: hepmc_event integer, dimension(:), allocatable :: proc_num_id contains <> end type eio_hepmc_t @ %def eio_hepmc_t @ \subsection{Specific Methods} Set parameters that are specifically used with HepMC. <>= procedure :: set_parameters => eio_hepmc_set_parameters <>= subroutine eio_hepmc_set_parameters & (eio, & recover_beams, use_alphas_from_file, use_scale_from_file, & extension, output_cross_section, hepmc3_mode) class(eio_hepmc_t), intent(inout) :: eio logical, intent(in), optional :: recover_beams logical, intent(in), optional :: use_alphas_from_file logical, intent(in), optional :: use_scale_from_file logical, intent(in), optional :: output_cross_section type(string_t), intent(in), optional :: extension integer, intent(in), optional :: hepmc3_mode if (present (recover_beams)) & eio%recover_beams = recover_beams if (present (use_alphas_from_file)) & eio%use_alphas_from_file = use_alphas_from_file if (present (use_scale_from_file)) & eio%use_scale_from_file = use_scale_from_file if (present (extension)) then eio%extension = extension else eio%extension = "hepmc" end if if (present (output_cross_section)) & eio%output_cross_section = output_cross_section if (present (hepmc3_mode)) & eio%hepmc3_mode = hepmc3_mode end subroutine eio_hepmc_set_parameters @ %def eio_hepmc_set_parameters @ \subsection{Common Methods} Output. This is not the actual event format, but a readable account of the current object status. <>= procedure :: write => eio_hepmc_write <>= subroutine eio_hepmc_write (object, unit) class(eio_hepmc_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit) write (u, "(1x,A)") "HepMC event stream:" if (object%writing) then write (u, "(3x,A,A)") "Writing to file = ", char (object%filename) else if (object%reading) then write (u, "(3x,A,A)") "Reading from file = ", char (object%filename) else write (u, "(3x,A)") "[closed]" end if write (u, "(3x,A,L1)") "Recover beams = ", object%recover_beams write (u, "(3x,A,L1)") "Alpha_s from file = ", & object%use_alphas_from_file write (u, "(3x,A,L1)") "Scale from file = ", & object%use_scale_from_file write (u, "(3x,A,A,A)") "File extension = '", & char (object%extension), "'" write (u, "(3x,A,I0)") "HepMC3 mode = ", object%hepmc3_mode if (allocated (object%proc_num_id)) then write (u, "(3x,A)") "Numerical process IDs:" do i = 1, size (object%proc_num_id) write (u, "(5x,I0,': ',I0)") i, object%proc_num_id(i) end do end if end subroutine eio_hepmc_write @ %def eio_hepmc_write @ Finalizer: close any open file. <>= procedure :: final => eio_hepmc_final <>= subroutine eio_hepmc_final (object) class(eio_hepmc_t), intent(inout) :: object if (allocated (object%proc_num_id)) deallocate (object%proc_num_id) if (object%writing) then write (msg_buffer, "(A,A,A)") "Events: closing HepMC file '", & char (object%filename), "'" call msg_message () call hepmc_iostream_close (object%iostream) object%writing = .false. else if (object%reading) then write (msg_buffer, "(A,A,A)") "Events: closing HepMC file '", & char (object%filename), "'" call msg_message () call hepmc_iostream_close (object%iostream) object%reading = .false. end if end subroutine eio_hepmc_final @ %def eio_hepmc_final @ Split event file: increment the counter, close the current file, open a new one. If the file needs a header, repeat it for the new file. <>= procedure :: split_out => eio_hepmc_split_out <>= subroutine eio_hepmc_split_out (eio) class(eio_hepmc_t), intent(inout) :: eio if (eio%split) then eio%split_index = eio%split_index + 1 call eio%set_filename () write (msg_buffer, "(A,A,A)") "Events: writing to HepMC file '", & char (eio%filename), "'" call msg_message () call hepmc_iostream_close (eio%iostream) call hepmc_iostream_open_out (eio%iostream, & eio%filename, eio%hepmc3_mode) end if end subroutine eio_hepmc_split_out @ %def eio_hepmc_split_out @ Common initialization for input and output. <>= procedure :: common_init => eio_hepmc_common_init <>= subroutine eio_hepmc_common_init (eio, sample, data, extension) class(eio_hepmc_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(in), optional :: data if (.not. present (data)) & call msg_bug ("HepMC initialization: missing data") eio%data = data if (data%n_beam /= 2) & call msg_fatal ("HepMC: defined for scattering processes only") ! We could relax this condition now with weighted hepmc events if (data%unweighted) then select case (data%norm_mode) case (NORM_UNIT) case default; call msg_fatal & ("HepMC: normalization for unweighted events must be '1'") end select end if eio%sample = sample if (present (extension)) then eio%extension = extension end if call eio%set_filename () allocate (eio%proc_num_id (data%n_proc), source = data%proc_num_id) end subroutine eio_hepmc_common_init @ %def eio_hepmc_common_init @ Initialize event writing. <>= procedure :: init_out => eio_hepmc_init_out <>= subroutine eio_hepmc_init_out (eio, sample, data, success, extension) class(eio_hepmc_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(in), optional :: data logical, intent(out), optional :: success call eio%set_splitting (data) call eio%common_init (sample, data, extension) write (msg_buffer, "(A,A,A)") "Events: writing to HepMC file '", & char (eio%filename), "'" call msg_message () eio%writing = .true. call hepmc_iostream_open_out (eio%iostream, & eio%filename, eio%hepmc3_mode) if (present (success)) success = .true. end subroutine eio_hepmc_init_out @ %def eio_hepmc_init_out @ Initialize event reading. For input, we do not (yet) support split event files. <>= procedure :: init_in => eio_hepmc_init_in <>= subroutine eio_hepmc_init_in (eio, sample, data, success, extension) class(eio_hepmc_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(inout), optional :: data logical, intent(out), optional :: success logical :: exist eio%split = .false. call eio%common_init (sample, data, extension) write (msg_buffer, "(A,A,A)") "Events: reading from HepMC file '", & char (eio%filename), "'" call msg_message () inquire (file = char (eio%filename), exist = exist) if (.not. exist) call msg_fatal ("Events: HepMC file not found.") eio%reading = .true. call hepmc_iostream_open_in (eio%iostream, & eio%filename, eio%hepmc3_mode) if (present (success)) success = .true. end subroutine eio_hepmc_init_in @ %def eio_hepmc_init_in @ Switch from input to output: reopen the file for reading. <>= procedure :: switch_inout => eio_hepmc_switch_inout <>= subroutine eio_hepmc_switch_inout (eio, success) class(eio_hepmc_t), intent(inout) :: eio logical, intent(out), optional :: success call msg_bug ("HepMC: in-out switch not supported") if (present (success)) success = .false. end subroutine eio_hepmc_switch_inout @ %def eio_hepmc_switch_inout @ Output an event to the allocated HepMC output stream. For the moment, we set [[alpha_qed]] always to -1. There should be methods for the handling of $\alpha$ in [[me_methods]] in the same way as for $\alpha_s$. + +If an [[event_handle]] is in the argument list, and it is of the correct HepMC +type, do not destroy the event but transfer it there (i.e., the enclosed C +pointer). <>= procedure :: output => eio_hepmc_output <>= - subroutine eio_hepmc_output (eio, event, i_prc, reading, passed, pacify) + subroutine eio_hepmc_output & + (eio, event, i_prc, reading, passed, pacify, event_handle) class(eio_hepmc_t), intent(inout) :: eio class(generic_event_t), intent(in), target :: event integer, intent(in) :: i_prc logical, intent(in), optional :: reading, passed, pacify + class(event_handle_t), intent(inout), optional :: event_handle type(particle_set_t), pointer :: pset_ptr if (present (passed)) then if (.not. passed) return end if if (eio%writing) then pset_ptr => event%get_particle_set_ptr () call hepmc_event_init (eio%hepmc_event, & proc_id = eio%proc_num_id(i_prc), & event_id = event%get_index ()) if (eio%output_cross_section) then call hepmc_event_from_particle_set (eio%hepmc_event, pset_ptr, & eio%data%cross_section(i_prc), eio%data%error(i_prc)) else call hepmc_event_from_particle_set (eio%hepmc_event, pset_ptr) end if call hepmc_event_set_scale (eio%hepmc_event, event%get_fac_scale ()) call hepmc_event_set_alpha_qcd (eio%hepmc_event, event%get_alpha_s ()) call hepmc_event_set_alpha_qed (eio%hepmc_event, -1._default) if (.not. eio%data%unweighted) then select case (eio%data%norm_mode) case (NORM_UNIT,NORM_N_EVT) call hepmc_event_add_weight & (eio%hepmc_event, event%weight_prc, .false.) case default call hepmc_event_add_weight & (eio%hepmc_event, event%weight_prc, .true.) end select end if call hepmc_iostream_write_event (eio%iostream, & eio%hepmc_event, eio%hepmc3_mode) + call maybe_transfer_event_to_handle (eio%hepmc_event, event_handle) call hepmc_event_final (eio%hepmc_event) else call eio%write () call msg_fatal ("HepMC file is not open for writing") end if end subroutine eio_hepmc_output @ %def eio_hepmc_output @ Input an event. <>= procedure :: input_i_prc => eio_hepmc_input_i_prc procedure :: input_event => eio_hepmc_input_event <>= subroutine eio_hepmc_input_i_prc (eio, i_prc, iostat) class(eio_hepmc_t), intent(inout) :: eio integer, intent(out) :: i_prc integer, intent(out) :: iostat logical :: ok integer :: i, proc_num_id iostat = 0 call hepmc_event_init (eio%hepmc_event) call hepmc_iostream_read_event (eio%iostream, & eio%hepmc_event, ok=ok) proc_num_id = hepmc_event_get_process_id (eio%hepmc_event) if (.not. ok) then iostat = -1 return end if i_prc = 0 FIND_I_PRC: do i = 1, size (eio%proc_num_id) if (eio%proc_num_id(i) == proc_num_id) then i_prc = i exit FIND_I_PRC end if end do FIND_I_PRC if (i_prc == 0) call err_index contains subroutine err_index call msg_error ("HepMC: reading events: undefined process ID " & // char (str (proc_num_id)) // ", aborting read") iostat = 1 end subroutine err_index end subroutine eio_hepmc_input_i_prc - subroutine eio_hepmc_input_event (eio, event, iostat) + subroutine eio_hepmc_input_event (eio, event, iostat, event_handle) class(eio_hepmc_t), intent(inout) :: eio class(generic_event_t), intent(inout), target :: event integer, intent(out) :: iostat + class(event_handle_t), intent(inout), optional :: event_handle iostat = 0 call event%reset_contents () call event%select (1, 1, 1) call hepmc_to_event (event, eio%hepmc_event, & eio%fallback_model, & recover_beams = eio%recover_beams, & use_alpha_s = eio%use_alphas_from_file, & use_scale = eio%use_scale_from_file) + call maybe_transfer_event_to_handle (eio%hepmc_event, event_handle) call hepmc_event_final (eio%hepmc_event) end subroutine eio_hepmc_input_event @ %def eio_hepmc_input_i_prc @ %def eio_hepmc_input_event @ +If an [[event_handle]] is in the argument list, and it is of the correct HepMC +type, do not destroy the event but transfer it to the handle (i.e., the +enclosed C pointer). Nullify the original pointer, so the event does not get +destroyed. +<>= + subroutine maybe_transfer_event_to_handle (hepmc_event, event_handle) + type(hepmc_event_t), intent(inout) :: hepmc_event + class(event_handle_t), intent(inout), optional :: event_handle + if (present (event_handle)) then + select type (event_handle) + type is (hepmc_event_t) + call hepmc_event_final (event_handle) ! just in case + event_handle = hepmc_event + call hepmc_event_nullify (hepmc_event) ! avoid destructor call + end select + end if + end subroutine maybe_transfer_event_to_handle + +@ %def transfer_event_to_handle +@ <>= procedure :: skip => eio_hepmc_skip <>= subroutine eio_hepmc_skip (eio, iostat) class(eio_hepmc_t), intent(inout) :: eio integer, intent(out) :: iostat iostat = 0 end subroutine eio_hepmc_skip @ %def eio_hepmc_skip @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[eio_hepmc_ut.f90]]>>= <> module eio_hepmc_ut use unit_tests use system_dependencies, only: HEPMC2_AVAILABLE use system_dependencies, only: HEPMC3_AVAILABLE use eio_hepmc_uti <> <> contains <> end module eio_hepmc_ut @ %def eio_hepmc_ut @ <<[[eio_hepmc_uti.f90]]>>= <> module eio_hepmc_uti <> <> use system_dependencies, only: HEPMC2_AVAILABLE use system_dependencies, only: HEPMC3_AVAILABLE use io_units use diagnostics use model_data use event_base use eio_data use eio_base use eio_hepmc use eio_base_ut, only: eio_prepare_test, eio_cleanup_test use eio_base_ut, only: eio_prepare_fallback_model, eio_cleanup_fallback_model <> <> contains <> end module eio_hepmc_uti @ %def eio_hepmc_ut @ API: driver for the unit tests below. <>= public :: eio_hepmc_test <>= subroutine eio_hepmc_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine eio_hepmc_test @ %def eio_hepmc_test @ \subsubsection{Test I/O methods} We test the implementation of all I/O methods. <>= if (HEPMC2_AVAILABLE) then call test (eio_hepmc_1, "eio_hepmc2_1", & "write event contents", & u, results) else if (HEPMC3_AVAILABLE) then call test (eio_hepmc_1, "eio_hepmc3_1", & "write event contents", & u, results) end if <>= public :: eio_hepmc_1 <>= subroutine eio_hepmc_1 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(116) :: buffer write (u, "(A)") "* Test output: eio_hepmc_1" write (u, "(A)") "* Purpose: write a HepMC file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted=.false.) call data%init (1) data%n_beam = 2 data%unweighted = .true. data%norm_mode = NORM_UNIT data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_hepmc_1" allocate (eio_hepmc_t :: eio) select type (eio) type is (eio_hepmc_t) call eio%set_parameters () end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%set_index (55) call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents (blanking out last two digits):" write (u, "(A)") u_file = free_unit () open (u_file, file = char (sample // ".hepmc"), & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (iostat /= 0) exit if (trim (buffer) == "") cycle if (buffer(1:14) == "HepMC::Version") cycle if (HEPMC2_AVAILABLE) then if (buffer(1:10) == "P 10001 25") & call buffer_blanker (buffer, 32, 55, 78) if (buffer(1:10) == "P 10002 25") & call buffer_blanker (buffer, 33, 56, 79) if (buffer(1:10) == "P 10003 25") & call buffer_blanker (buffer, 29, 53, 78, 101) if (buffer(1:10) == "P 10004 25") & call buffer_blanker (buffer, 28, 51, 76, 99) else if (HEPMC3_AVAILABLE) then if (buffer(1:8) == "P 1 0 25") & call buffer_blanker (buffer, 26, 49, 72) if (buffer(1:8) == "P 2 0 25") & call buffer_blanker (buffer, 26, 49, 73) if (buffer(1:9) == "P 3 -1 25") & call buffer_blanker (buffer, 28, 52, 75) if (buffer(1:9) == "P 4 -1 25") & call buffer_blanker (buffer, 27, 50, 73) end if write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Reset data" write (u, "(A)") deallocate (eio) allocate (eio_hepmc_t :: eio) select type (eio) type is (eio_hepmc_t) call eio%set_parameters () end select call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_hepmc_1" contains subroutine buffer_blanker (buf, pos1, pos2, pos3, pos4) character(len=*), intent(inout) :: buf integer, intent(in) :: pos1, pos2, pos3 integer, intent(in), optional :: pos4 type(string_t) :: line line = var_str (trim (buf)) line = replace (line, pos1, "XX") line = replace (line, pos2, "XX") line = replace (line, pos3, "XX") if (present (pos4)) then line = replace (line, pos4, "XX") end if line = replace (line, "4999999999999", "5000000000000") buf = char (line) end subroutine buffer_blanker end subroutine eio_hepmc_1 @ %def eio_hepmc_1 @ Test also the reading of HepMC events. <>= if (HEPMC2_AVAILABLE) then call test (eio_hepmc_2, "eio_hepmc2_2", & "read event contents", & u, results) else if (HEPMC3_AVAILABLE) then call test (eio_hepmc_2, "eio_hepmc3_2", & "read event contents", & u, results) end if <>= public :: eio_hepmc_2 <>= subroutine eio_hepmc_2 (u) integer, intent(in) :: u class(model_data_t), pointer :: fallback_model class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat, i_prc write (u, "(A)") "* Test output: eio_hepmc_2" write (u, "(A)") "* Purpose: read a HepMC event" write (u, "(A)") write (u, "(A)") "* Write a HepMC data file" write (u, "(A)") u_file = free_unit () sample = "eio_hepmc_2" open (u_file, file = char (sample // ".hepmc"), & status = "replace", action = "readwrite") if (HEPMC2_AVAILABLE) then write (u_file, "(A)") "HepMC::Version 2.06.09" write (u_file, "(A)") "HepMC::IO_GenEvent-START_EVENT_LISTING" write (u_file, "(A)") "E 66 -1 -1.0000000000000000e+00 & &-1.0000000000000000e+00 & &-1.0000000000000000e+00 42 0 1 10001 10002 0 0" write (u_file, "(A)") "U GEV MM" write (u_file, "(A)") "V -1 0 0 0 0 0 2 2 0" write (u_file, "(A)") "P 10001 25 0 0 4.8412291827592713e+02 & &5.0000000000000000e+02 & &1.2499999999999989e+02 3 0 0 -1 0" write (u_file, "(A)") "P 10002 25 0 0 -4.8412291827592713e+02 & &5.0000000000000000e+02 & &1.2499999999999989e+02 3 0 0 -1 0" write (u_file, "(A)") "P 10003 25 -1.4960220911365536e+02 & &-4.6042825611414656e+02 & &0 5.0000000000000000e+02 1.2500000000000000e+02 1 0 0 0 0" write (u_file, "(A)") "P 10004 25 1.4960220911365536e+02 & &4.6042825611414656e+02 & &0 5.0000000000000000e+02 1.2500000000000000e+02 1 0 0 0 0" write (u_file, "(A)") "HepMC::IO_GenEvent-END_EVENT_LISTING" else if (HEPMC3_AVAILABLE) then write (u_file, "(A)") "HepMC::Version 3.01.01" write (u_file, "(A)") "HepMC::Asciiv3-START_EVENT_LISTING" write (u_file, "(A)") "E 55 1 4" write (u_file, "(A)") "U GEV MM" write (u_file, "(A)") "A 0 alphaQCD -1" write (u_file, "(A)") "A 0 event_scale 1000" write (u_file, "(A)") "A 0 signal_process_id 42" write (u_file, "(A)") "P 1 0 25 0.0000000000000000e+00 & &0.0000000000000000e+00 4.8412291827592713e+02 & &5.0000000000000000e+02 1.2499999999999989e+02 3" write (u_file, "(A)") "P 2 0 25 0.0000000000000000e+00 & &0.0000000000000000e+00 -4.8412291827592713e+02 & &5.0000000000000000e+02 1.2499999999999989e+02 3" write (u_file, "(A)") "V -1 0 [1,2]" write (u_file, "(A)") "P 3 -1 25 -1.4960220911365536e+02 & &-4.6042825611414656e+02 0.0000000000000000e+00 & &5.0000000000000000e+02 1.2500000000000000e+02 1" write (u_file, "(A)") "P 4 -1 25 1.4960220911365536e+02 & &4.6042825611414656e+02 0.0000000000000000e+00 & &5.0000000000000000e+02 1.2500000000000000e+02 1" write (u_file, "(A)") "HepMC::Asciiv3-END_EVENT_LISTING" else call msg_fatal & ("Trying to execute eio_hepmc unit tests without a linked HepMC") end if close (u_file) write (u, "(A)") "* Initialize test process" write (u, "(A)") allocate (fallback_model) call eio_prepare_fallback_model (fallback_model) call eio_prepare_test (event, unweighted=.false.) allocate (eio_hepmc_t :: eio) select type (eio) type is (eio_hepmc_t) call eio%set_parameters (recover_beams = .false.) end select call eio%set_fallback_model (fallback_model) call data%init (1) data%n_beam = 2 data%unweighted = .true. data%norm_mode = NORM_UNIT data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] call data%write (u) write (u, "(A)") write (u, "(A)") "* Initialize" write (u, "(A)") call eio%init_in (sample, data) call eio%write (u) write (u, "(A)") write (u, "(A)") "* Read event" write (u, "(A)") call eio%input_i_prc (i_prc, iostat) select type (eio) type is (eio_hepmc_t) write (u, "(A,I0,A,I0)") "Found process #", i_prc, & " with ID = ", eio%proc_num_id(i_prc) end select call eio%input_event (event, iostat) call event%write (u) write (u, "(A)") write (u, "(A)") "* Read closing" write (u, "(A)") call eio%input_i_prc (i_prc, iostat) write (u, "(A,I0)") "iostat = ", iostat write (u, "(A)") write (u, "(A)") "* Cleanup" call eio%final () call eio_cleanup_test (event) call eio_cleanup_fallback_model (fallback_model) deallocate (fallback_model) write (u, "(A)") write (u, "(A)") "* Test output end: eio_hepmc_2" end subroutine eio_hepmc_2 @ %def eio_hepmc_2 @ Test also the correct normalization of weighted HepMC events. <>= if (HEPMC2_AVAILABLE) then call test (eio_hepmc_3, "eio_hepmc2_3", & "write event contents", & u, results) else if (HEPMC3_AVAILABLE) then call test (eio_hepmc_3, "eio_hepmc3_3", & "event contents weighted, '1' normalization", & u, results) end if <>= public :: eio_hepmc_3 <>= subroutine eio_hepmc_3 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: u_file, iostat character(126) :: buffer write (u, "(A)") "* Test output: eio_hepmc_3" write (u, "(A)") "* Purpose: test correct HepMC normalization" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event, unweighted=.false., & sample_norm = var_str ("1")) call data%init (1) data%n_beam = 2 data%unweighted = .false. data%norm_mode = NORM_UNIT data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 20 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_hepmc_3" allocate (eio_hepmc_t :: eio) select type (eio) type is (eio_hepmc_t) call eio%set_parameters () end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%set_index (55) call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* File contents (blanking out last two digits):" write (u, "(A)") u_file = free_unit () open (u_file, file = char (sample // ".hepmc"), & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (iostat /= 0) exit if (trim (buffer) == "") cycle if (buffer(1:14) == "HepMC::Version") cycle if (HEPMC2_AVAILABLE) then if (buffer(1:4) == "E 55") then buffer = replace (buffer, 113, "XXXXXXXXX") end if if (buffer(1:10) == "P 10001 25") & call buffer_blanker (buffer, 32, 55, 78) if (buffer(1:10) == "P 10002 25") & call buffer_blanker (buffer, 33, 56, 79) if (buffer(1:10) == "P 10003 25") & call buffer_blanker (buffer, 29, 53, 78, 101) if (buffer(1:10) == "P 10004 25") & call buffer_blanker (buffer, 28, 51, 76, 99) else if (HEPMC3_AVAILABLE) then if (buffer(1:4) == "W 3.") then buffer = replace (buffer, 11, "XXXXXXXXXXXXXXXX") end if if (buffer(1:8) == "P 1 0 25") & call buffer_blanker (buffer, 26, 49, 72, 118) if (buffer(1:8) == "P 2 0 25") & call buffer_blanker (buffer, 26, 49, 73, 119) if (buffer(1:9) == "P 3 -1 25") & call buffer_blanker (buffer, 28, 52, 75, 121) if (buffer(1:9) == "P 4 -1 25") & call buffer_blanker (buffer, 27, 50, 73, 119) end if write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Reset data" write (u, "(A)") deallocate (eio) allocate (eio_hepmc_t :: eio) select type (eio) type is (eio_hepmc_t) call eio%set_parameters () end select call eio%write (u) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_hepmc_3" contains subroutine buffer_blanker (buf, pos1, pos2, pos3, pos4) character(len=*), intent(inout) :: buf integer, intent(in) :: pos1, pos2, pos3 integer, intent(in), optional :: pos4 type(string_t) :: line line = var_str (trim (buf)) line = replace (line, pos1, "XX") line = replace (line, pos2, "XX") line = replace (line, pos3, "XX") if (present (pos4)) then line = replace (line, pos4, "XX") end if line = replace (line, "4999999999999", "5000000000000") buf = char (line) end subroutine buffer_blanker end subroutine eio_hepmc_3 @ %def eio_hepmc_3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{LCIO Output} The LCIO event record is standardized for the use with Linear $e^+e^-$ colliders. It is a binary event format. We try our best at using it for both input and output. <<[[eio_lcio.f90]]>>= <> module eio_lcio <> <> use io_units use string_utils use diagnostics use particles use event_base + use event_handles, only: event_handle_t use hep_events use eio_data use eio_base use lcio_interface <> <> <> contains <> end module eio_lcio @ %def eio_lcio @ \subsection{Type} A type [[lcio_event]] is introduced as container to store LCIO event data, particularly for splitting the reading into read out of the process index and the proper event data. Note: the [[keep_beams]] flag is not supported. <>= public :: eio_lcio_t <>= type, extends (eio_t) :: eio_lcio_t logical :: writing = .false. logical :: reading = .false. type(event_sample_data_t) :: data logical :: recover_beams = .false. logical :: use_alphas_from_file = .false. logical :: use_scale_from_file = .false. logical :: proc_as_run_id = .true. integer :: n_alt = 0 integer :: lcio_run_id = 0 type(lcio_writer_t) :: lcio_writer type(lcio_reader_t) :: lcio_reader type(lcio_run_header_t) :: lcio_run_hdr type(lcio_event_t) :: lcio_event integer, dimension(:), allocatable :: proc_num_id contains <> end type eio_lcio_t @ %def eio_lcio_t @ \subsection{Specific Methods} Set parameters that are specifically used with LCIO. <>= procedure :: set_parameters => eio_lcio_set_parameters <>= subroutine eio_lcio_set_parameters & (eio, recover_beams, use_alphas_from_file, use_scale_from_file, & extension, proc_as_run_id, lcio_run_id) class(eio_lcio_t), intent(inout) :: eio logical, intent(in), optional :: recover_beams logical, intent(in), optional :: use_alphas_from_file logical, intent(in), optional :: use_scale_from_file logical, intent(in), optional :: proc_as_run_id integer, intent(in), optional :: lcio_run_id type(string_t), intent(in), optional :: extension if (present (recover_beams)) eio%recover_beams = recover_beams if (present (use_alphas_from_file)) & eio%use_alphas_from_file = use_alphas_from_file if (present (use_scale_from_file)) & eio%use_scale_from_file = use_scale_from_file if (present (proc_as_run_id)) & eio%proc_as_run_id = proc_as_run_id if (present (lcio_run_id)) & eio%lcio_run_id = lcio_run_id if (present (extension)) then eio%extension = extension else eio%extension = "slcio" end if end subroutine eio_lcio_set_parameters @ %def eio_lcio_set_parameters @ \subsection{Common Methods} Output. This is not the actual event format, but a readable account of the current object status. <>= procedure :: write => eio_lcio_write <>= subroutine eio_lcio_write (object, unit) class(eio_lcio_t), intent(in) :: object integer, intent(in), optional :: unit integer :: u, i u = given_output_unit (unit) write (u, "(1x,A)") "LCIO event stream:" if (object%writing) then write (u, "(3x,A,A)") "Writing to file = ", char (object%filename) else if (object%reading) then write (u, "(3x,A,A)") "Reading from file = ", char (object%filename) else write (u, "(3x,A)") "[closed]" end if write (u, "(3x,A,L1)") "Recover beams = ", object%recover_beams write (u, "(3x,A,L1)") "Alpha_s from file = ", & object%use_alphas_from_file write (u, "(3x,A,L1)") "Scale from file = ", & object%use_scale_from_file write (u, "(3x,A,L1)") "Process as run ID = ", & object%proc_as_run_id write (u, "(3x,A,I0)") "LCIO run ID = ", & object%lcio_run_id write (u, "(3x,A,A,A)") "File extension = '", & char (object%extension), "'" if (allocated (object%proc_num_id)) then write (u, "(3x,A)") "Numerical process IDs:" do i = 1, size (object%proc_num_id) write (u, "(5x,I0,': ',I0)") i, object%proc_num_id(i) end do end if end subroutine eio_lcio_write @ %def eio_lcio_write @ Finalizer: close any open file. <>= procedure :: final => eio_lcio_final <>= subroutine eio_lcio_final (object) class(eio_lcio_t), intent(inout) :: object if (allocated (object%proc_num_id)) deallocate (object%proc_num_id) if (object%writing) then write (msg_buffer, "(A,A,A)") "Events: closing LCIO file '", & char (object%filename), "'" call msg_message () call lcio_writer_close (object%lcio_writer) object%writing = .false. else if (object%reading) then write (msg_buffer, "(A,A,A)") "Events: closing LCIO file '", & char (object%filename), "'" call msg_message () call lcio_reader_close (object%lcio_reader) object%reading = .false. end if end subroutine eio_lcio_final @ %def eio_lcio_final @ Split event file: increment the counter, close the current file, open a new one. If the file needs a header, repeat it for the new file. <>= procedure :: split_out => eio_lcio_split_out <>= subroutine eio_lcio_split_out (eio) class(eio_lcio_t), intent(inout) :: eio if (eio%split) then eio%split_index = eio%split_index + 1 call eio%set_filename () write (msg_buffer, "(A,A,A)") "Events: writing to LCIO file '", & char (eio%filename), "'" call msg_message () call lcio_writer_close (eio%lcio_writer) call lcio_writer_open_out (eio%lcio_writer, eio%filename) end if end subroutine eio_lcio_split_out @ %def eio_lcio_split_out @ Common initialization for input and output. <>= procedure :: common_init => eio_lcio_common_init <>= subroutine eio_lcio_common_init (eio, sample, data, extension) class(eio_lcio_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(in), optional :: data if (.not. present (data)) & call msg_bug ("LCIO initialization: missing data") eio%data = data if (data%n_beam /= 2) & call msg_fatal ("LCIO: defined for scattering processes only") if (data%unweighted) then select case (data%norm_mode) case (NORM_UNIT) case default; call msg_fatal & ("LCIO: normalization for unweighted events must be '1'") end select else call msg_fatal ("LCIO: events must be unweighted") end if eio%n_alt = data%n_alt eio%sample = sample if (present (extension)) then eio%extension = extension end if call eio%set_filename () allocate (eio%proc_num_id (data%n_proc), source = data%proc_num_id) end subroutine eio_lcio_common_init @ %def eio_lcio_common_init @ Initialize event writing. <>= procedure :: init_out => eio_lcio_init_out <>= subroutine eio_lcio_init_out (eio, sample, data, success, extension) class(eio_lcio_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(in), optional :: data logical, intent(out), optional :: success call eio%set_splitting (data) call eio%common_init (sample, data, extension) write (msg_buffer, "(A,A,A)") "Events: writing to LCIO file '", & char (eio%filename), "'" call msg_message () eio%writing = .true. call lcio_writer_open_out (eio%lcio_writer, eio%filename) call lcio_run_header_init (eio%lcio_run_hdr) call lcio_run_header_write (eio%lcio_writer, eio%lcio_run_hdr) if (present (success)) success = .true. end subroutine eio_lcio_init_out @ %def eio_lcio_init_out @ Initialize event reading. For input, we do not (yet) support split event files. <>= procedure :: init_in => eio_lcio_init_in <>= subroutine eio_lcio_init_in (eio, sample, data, success, extension) class(eio_lcio_t), intent(inout) :: eio type(string_t), intent(in) :: sample type(string_t), intent(in), optional :: extension type(event_sample_data_t), intent(inout), optional :: data logical, intent(out), optional :: success logical :: exist eio%split = .false. call eio%common_init (sample, data, extension) write (msg_buffer, "(A,A,A)") "Events: reading from LCIO file '", & char (eio%filename), "'" call msg_message () inquire (file = char (eio%filename), exist = exist) if (.not. exist) call msg_fatal ("Events: LCIO file not found.") eio%reading = .true. call lcio_open_file (eio%lcio_reader, eio%filename) if (present (success)) success = .true. end subroutine eio_lcio_init_in @ %def eio_lcio_init_in @ Switch from input to output: reopen the file for reading. <>= procedure :: switch_inout => eio_lcio_switch_inout <>= subroutine eio_lcio_switch_inout (eio, success) class(eio_lcio_t), intent(inout) :: eio logical, intent(out), optional :: success call msg_bug ("LCIO: in-out switch not supported") if (present (success)) success = .false. end subroutine eio_lcio_switch_inout @ %def eio_lcio_switch_inout @ Output an event to the allocated LCIO writer. <>= procedure :: output => eio_lcio_output <>= - subroutine eio_lcio_output (eio, event, i_prc, reading, passed, pacify) + subroutine eio_lcio_output & + (eio, event, i_prc, reading, passed, pacify, event_handle) class(eio_lcio_t), intent(inout) :: eio class(generic_event_t), intent(in), target :: event integer, intent(in) :: i_prc logical, intent(in), optional :: reading, passed, pacify + class(event_handle_t), intent(inout), optional :: event_handle type(particle_set_t), pointer :: pset_ptr real(default) :: sqme_prc, weight integer :: i if (present (passed)) then if (.not. passed) return end if if (eio%writing) then pset_ptr => event%get_particle_set_ptr () if (eio%proc_as_run_id) then call lcio_event_init (eio%lcio_event, & proc_id = eio%proc_num_id (i_prc), & event_id = event%get_index (), & run_id = eio%proc_num_id (i_prc)) else call lcio_event_init (eio%lcio_event, & proc_id = eio%proc_num_id (i_prc), & event_id = event%get_index (), & run_id = eio%lcio_run_id) end if call lcio_event_from_particle_set (eio%lcio_event, pset_ptr) call lcio_event_set_weight (eio%lcio_event, event%weight_prc) call lcio_event_set_sqrts (eio%lcio_event, event%get_sqrts ()) call lcio_event_set_sqme (eio%lcio_event, event%get_sqme_prc ()) call lcio_event_set_scale (eio%lcio_event, event%get_fac_scale ()) call lcio_event_set_alpha_qcd (eio%lcio_event, event%get_alpha_s ()) call lcio_event_set_xsec (eio%lcio_event, eio%data%cross_section(i_prc), & eio%data%error(i_prc)) call lcio_event_set_polarization (eio%lcio_event, & event%get_polarization ()) call lcio_event_set_beam_file (eio%lcio_event, & event%get_beam_file ()) call lcio_event_set_process_name (eio%lcio_event, & event%get_process_name ()) do i = 1, eio%n_alt sqme_prc = event%get_sqme_alt(i) weight = event%get_weight_alt(i) call lcio_event_set_alt_sqme (eio%lcio_event, sqme_prc, i) call lcio_event_set_alt_weight (eio%lcio_event, weight, i) end do call lcio_event_write (eio%lcio_writer, eio%lcio_event) + call maybe_transfer_event_to_handle (eio%lcio_event, event_handle) call lcio_event_final (eio%lcio_event) else call eio%write () call msg_fatal ("LCIO file is not open for writing") end if end subroutine eio_lcio_output @ %def eio_lcio_output @ Input an event. <>= procedure :: input_i_prc => eio_lcio_input_i_prc procedure :: input_event => eio_lcio_input_event <>= subroutine eio_lcio_input_i_prc (eio, i_prc, iostat) class(eio_lcio_t), intent(inout) :: eio integer, intent(out) :: i_prc integer, intent(out) :: iostat logical :: ok integer :: i, proc_num_id iostat = 0 call lcio_read_event (eio%lcio_reader, eio%lcio_event, ok) if (.not. ok) then iostat = -1 return end if proc_num_id = lcio_event_get_process_id (eio%lcio_event) i_prc = 0 FIND_I_PRC: do i = 1, size (eio%proc_num_id) if (eio%proc_num_id(i) == proc_num_id) then i_prc = i exit FIND_I_PRC end if end do FIND_I_PRC if (i_prc == 0) call err_index contains subroutine err_index call msg_error ("LCIO: reading events: undefined process ID " & // char (str (proc_num_id)) // ", aborting read") iostat = 1 end subroutine err_index end subroutine eio_lcio_input_i_prc - subroutine eio_lcio_input_event (eio, event, iostat) + subroutine eio_lcio_input_event (eio, event, iostat, event_handle) class(eio_lcio_t), intent(inout) :: eio class(generic_event_t), intent(inout), target :: event integer, intent(out) :: iostat + class(event_handle_t), intent(inout), optional :: event_handle iostat = 0 call event%reset_contents () call event%select (1, 1, 1) call event%set_index (lcio_event_get_event_index (eio%lcio_event)) call lcio_to_event (event, eio%lcio_event, eio%fallback_model, & recover_beams = eio%recover_beams, & use_alpha_s = eio%use_alphas_from_file, & use_scale = eio%use_scale_from_file) + call maybe_transfer_event_to_handle (eio%lcio_event, event_handle) call lcio_event_final (eio%lcio_event) end subroutine eio_lcio_input_event @ %def eio_lcio_input_i_prc @ %def eio_lcio_input_event @ +If an [[event_handle]] is in the argument list, and it is of the correct HepMC +type, do not destroy the event but transfer it to the handle (i.e., the +enclosed C pointer). Nullify the original pointer, so the event does not get +destroyed. +<>= + subroutine maybe_transfer_event_to_handle (lcio_event, event_handle) + type(lcio_event_t), intent(inout) :: lcio_event + class(event_handle_t), intent(inout), optional :: event_handle + if (present (event_handle)) then + select type (event_handle) + type is (lcio_event_t) + call lcio_event_final (event_handle) ! just in case + event_handle = lcio_event +call show_lcio_event (event_handle) + call lcio_event_nullify (lcio_event) ! avoid destructor call + end select + end if + end subroutine maybe_transfer_event_to_handle + +@ %def transfer_event_to_handle +@ <>= procedure :: skip => eio_lcio_skip <>= subroutine eio_lcio_skip (eio, iostat) class(eio_lcio_t), intent(inout) :: eio integer, intent(out) :: iostat iostat = 0 end subroutine eio_lcio_skip @ %def eio_lcio_skip @ \subsection{Unit tests} Test module, followed by the corresponding implementation module. <<[[eio_lcio_ut.f90]]>>= <> module eio_lcio_ut use unit_tests use eio_lcio_uti <> <> contains <> end module eio_lcio_ut @ %def eio_lcio_ut @ <<[[eio_lcio_uti.f90]]>>= <> module eio_lcio_uti <> <> use io_units use model_data use particles use event_base use eio_data use eio_base use hep_events use lcio_interface use eio_lcio use eio_base_ut, only: eio_prepare_test, eio_cleanup_test use eio_base_ut, only: eio_prepare_fallback_model, eio_cleanup_fallback_model <> <> contains <> end module eio_lcio_uti @ %def eio_lcio_ut @ API: driver for the unit tests below. <>= public :: eio_lcio_test <>= subroutine eio_lcio_test (u, results) integer, intent(in) :: u type(test_results_t), intent(inout) :: results <> end subroutine eio_lcio_test @ %def eio_lcio_test @ \subsubsection{Test I/O methods} We test the implementation of all I/O methods. <>= call test (eio_lcio_1, "eio_lcio_1", & "write event contents", & u, results) <>= public :: eio_lcio_1 <>= subroutine eio_lcio_1 (u) integer, intent(in) :: u class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(particle_set_t), pointer :: pset_ptr type(string_t) :: sample integer :: u_file, iostat character(215) :: buffer write (u, "(A)") "* Test output: eio_lcio_1" write (u, "(A)") "* Purpose: write a LCIO file" write (u, "(A)") write (u, "(A)") "* Initialize test process" call eio_prepare_test (event) call data%init (1) data%n_beam = 2 data%unweighted = .true. data%norm_mode = NORM_UNIT data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_lcio_1" allocate (eio_lcio_t :: eio) select type (eio) type is (eio_lcio_t) call eio%set_parameters () end select call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%set_index (77) call event%pacify_particle_set () call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () write (u, "(A)") write (u, "(A)") "* Reset data" write (u, "(A)") deallocate (eio) allocate (eio_lcio_t :: eio) select type (eio) type is (eio_lcio_t) call eio%set_parameters () end select call eio%write (u) write (u, "(A)") write (u, "(A)") "* Write LCIO file contents to ASCII file" write (u, "(A)") select type (eio) type is (eio_lcio_t) call lcio_event_init (eio%lcio_event, & proc_id = 42, & event_id = event%get_index ()) pset_ptr => event%get_particle_set_ptr () call lcio_event_from_particle_set & (eio%lcio_event, pset_ptr) call write_lcio_event (eio%lcio_event, var_str ("test_file.slcio")) call lcio_event_final (eio%lcio_event) end select write (u, "(A)") write (u, "(A)") "* Read in ASCII contents of LCIO file" write (u, "(A)") u_file = free_unit () open (u_file, file = "test_file.slcio", & action = "read", status = "old") do read (u_file, "(A)", iostat = iostat) buffer if (iostat /= 0) exit if (trim (buffer) == "") cycle if (buffer(1:12) == " - timestamp") cycle if (buffer(1:6) == " date:") cycle write (u, "(A)") trim (buffer) end do close (u_file) write (u, "(A)") write (u, "(A)") "* Cleanup" call eio_cleanup_test (event) write (u, "(A)") write (u, "(A)") "* Test output end: eio_lcio_1" end subroutine eio_lcio_1 @ %def eio_lcio_1 @ Test also the reading of LCIO events. <>= call test (eio_lcio_2, "eio_lcio_2", & "read event contents", & u, results) <>= public :: eio_lcio_2 <>= subroutine eio_lcio_2 (u) integer, intent(in) :: u class(model_data_t), pointer :: fallback_model class(generic_event_t), pointer :: event type(event_sample_data_t) :: data class(eio_t), allocatable :: eio type(string_t) :: sample integer :: iostat, i_prc write (u, "(A)") "* Test output: eio_lcio_2" write (u, "(A)") "* Purpose: read a LCIO event" write (u, "(A)") write (u, "(A)") "* Initialize test process" allocate (fallback_model) call eio_prepare_fallback_model (fallback_model) call eio_prepare_test (event) call data%init (1) data%n_beam = 2 data%unweighted = .true. data%norm_mode = NORM_UNIT data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] data%cross_section(1) = 100 data%error(1) = 1 data%total_cross_section = sum (data%cross_section) write (u, "(A)") write (u, "(A)") "* Generate and write an event" write (u, "(A)") sample = "eio_lcio_2" allocate (eio_lcio_t :: eio) select type (eio) type is (eio_lcio_t) call eio%set_parameters (recover_beams = .false.) end select call eio%set_fallback_model (fallback_model) call eio%init_out (sample, data) call event%generate (1, [0._default, 0._default]) call event%set_index (88) call event%evaluate_expressions () call event%pacify_particle_set () call eio%output (event, i_prc = 1) call eio%write (u) call eio%final () deallocate (eio) call event%reset_contents () call event%reset_index () write (u, "(A)") write (u, "(A)") "* Initialize" write (u, "(A)") allocate (eio_lcio_t :: eio) select type (eio) type is (eio_lcio_t) call eio%set_parameters (recover_beams = .false.) end select call eio%set_fallback_model (fallback_model) call data%init (1) data%n_beam = 2 data%unweighted = .true. data%norm_mode = NORM_UNIT data%pdg_beam = 25 data%energy_beam = 500 data%proc_num_id = [42] call data%write (u) write (u, *) write (u, "(A)") "* Initialize" write (u, "(A)") call eio%init_in (sample, data) call eio%write (u) write (u, "(A)") write (u, "(A)") "* Read event" write (u, "(A)") call eio%input_i_prc (i_prc, iostat) select type (eio) type is (eio_lcio_t) write (u, "(A,I0,A,I0)") "Found process #", i_prc, & " with ID = ", eio%proc_num_id(i_prc) end select call eio%input_event (event, iostat) call event%write (u) write (u, "(A)") write (u, "(A)") "* Read closing" write (u, "(A)") call eio%input_i_prc (i_prc, iostat) write (u, "(A,I0)") "iostat = ", iostat write (u, "(A)") write (u, "(A)") "* Cleanup" call eio%final () call eio_cleanup_test (event) call eio_cleanup_fallback_model (fallback_model) deallocate (fallback_model) write (u, "(A)") write (u, "(A)") "* Test output end: eio_lcio_2" end subroutine eio_lcio_2 @ %def eio_lcio_2 Index: trunk/src/events/Makefile.am =================================================================== --- trunk/src/events/Makefile.am (revision 8428) +++ trunk/src/events/Makefile.am (revision 8429) @@ -1,230 +1,232 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement quantum field theory concepts ## such as model representation and quantum numbers. ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libevents.la check_LTLIBRARIES = libevents_ut.la libevents_la_SOURCES = \ event_base.f90 \ + event_handles.f90 \ eio_data.f90 \ eio_base.f90 \ eio_direct.f90 \ eio_checkpoints.f90 \ eio_callback.f90 \ eio_weights.f90 \ eio_dump.f90 \ hep_common.f90 \ hepmc_interface.f90 \ lcio_interface.f90 \ hep_events.f90 \ eio_ascii.f90 \ eio_lhef.f90 \ eio_stdhep.f90 \ eio_hepmc.f90 \ eio_lcio.f90 libevents_ut_la_SOURCES = \ eio_data_uti.f90 eio_data_ut.f90 \ eio_base_uti.f90 eio_base_ut.f90 \ eio_direct_uti.f90 eio_direct_ut.f90 \ eio_checkpoints_uti.f90 eio_checkpoints_ut.f90 \ eio_weights_uti.f90 eio_weights_ut.f90 \ eio_dump_uti.f90 eio_dump_ut.f90 \ hepmc_interface_uti.f90 hepmc_interface_ut.f90 \ lcio_interface_uti.f90 lcio_interface_ut.f90 \ hep_events_uti.f90 hep_events_ut.f90 \ eio_ascii_uti.f90 eio_ascii_ut.f90 \ eio_lhef_uti.f90 eio_lhef_ut.f90 \ eio_stdhep_uti.f90 eio_stdhep_ut.f90 \ eio_hepmc_uti.f90 eio_hepmc_ut.f90 \ eio_lcio_uti.f90 eio_lcio_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = events.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libevents_la_SOURCES:.f90=.$(FCMOD)} + libevents_Modules = \ ${libevents_la_SOURCES:.f90=} \ ${libevents_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libevents_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../parsing/Modules \ ../physics/Modules \ ../qft/Modules \ ../types/Modules \ ../particles/Modules \ ../xdr/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libevents_la_SOURCES) $(libevents_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libevents_la_SOURCES) $(libevents_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend libevents_la_LIBADD = \ ../../mcfio/libwo_mcfio.la \ ../../stdhep/libwo_stdhep.la # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../parsing -I../physics -I../qft -I../expr_base -I../types -I../fastjet -I../particles -I../xdr ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -#execmoddir = $(pkglibdir)/mod/events -#nodist_execmod_HEADERS = \# - ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw events.stamp: $(PRELUDE) $(srcdir)/events.nw $(POSTLUDE) @rm -f events.tmp @touch events.tmp for src in $(libevents_la_SOURCES) $(libevents_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f events.tmp events.stamp $(libevents_la_SOURCES) $(libevents_ut_la_SOURCES): events.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f events.stamp; \ $(MAKE) $(AM_MAKEFLAGS) events.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f events.stamp events.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/recola/Makefile.am =================================================================== --- trunk/src/recola/Makefile.am (revision 8428) +++ trunk/src/recola/Makefile.am (revision 8429) @@ -1,212 +1,219 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory interface the Recola amplitude calculator ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libwo_recola.la check_LTLIBRARIES = libwo_recola_ut.la if RECOLA_AVAILABLE libwo_recola_la_SOURCES = \ recola_wrapper.f90 prc_recola.f90 SOURCE_DUMMY_FILES = recola_wrapper_dummy.f90 else libwo_recola_la_SOURCES = \ recola_wrapper_dummy.f90 prc_recola.f90 SOURCE_DUMMY_FILES = recola_wrapper.f90 endif libwo_recola_ut_la_SOURCES = \ prc_recola_uti.f90 prc_recola_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = recola.nw +# Modules and installation # Dump module names into file Modules -#libwo_recola_Modules = ${libwo_recola_la_SOURCES:.f90=} ${libwo_recola_ut_la_SOURCES:.f90=} +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + recola_wrapper.$(FCMOD) prc_recola.$(FCMOD) + libwo_recola_Modules = prc_recola recola_wrapper \ prc_recola_uti prc_recola_ut if RECOLA_AVAILABLE - prc_recola.lo: recola_wrapper.lo + prc_recola.lo prc_recola.$(FCMOD): recola_wrapper.lo + recola_wrapper.$(FCMOD): recola_wrapper.lo else - prc_recola.lo: recola_wrapper_dummy.lo + prc_recola.lo prc_recola.$(FCMOD): recola_wrapper_dummy.lo + recola_wrapper.$(FCMOD): recola_wrapper_dummy.lo endif Modules: Makefile @for module in $(libwo_recola_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../physics/Modules \ ../qft/Modules \ ../types/Modules \ ../particles/Modules \ ../matrix_elements/Modules \ ../me_methods/Modules \ ../variables/Modules \ ../beams/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $^; do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done ; \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libwo_recola_la_SOURCES) ${libwo_recola_ut_la_SOURCES} @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend +### Disabled, explicit rule above # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): - @: +#.lo.$(FCMOD):# +# @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../parsing -I../physics -I../qft -I../expr_base -I../types -I../particles -I../matrix_elements -I../me_methods -I../variables -I../beams -I../lhapdf -I../pdf_builtin -I../fastjet ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif if RECOLA_AVAILABLE AM_FCFLAGS += $(RECOLA_INCLUDES) endif ######################################################################## ## Non-standard targets and dependencies ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw recola.stamp: $(PRELUDE) $(srcdir)/recola.nw $(POSTLUDE) @rm -f recola.tmp @touch recola.tmp for src in $(libwo_recola_la_SOURCES) $(libwo_recola_ut_la_SOURCES) $(SOURCE_DUMMY_FILES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f recola.tmp recola.stamp $(libwo_recola_la_SOURCES) $(libwo_recola_ut_la_SOURCES) $(SOURCE_DUMMY_FILES): recola.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f recola.stamp; \ $(MAKE) $(AM_MAKEFLAGS) recola.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f recola.stamp recola.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/vegas/Makefile.am =================================================================== --- trunk/src/vegas/Makefile.am (revision 8428) +++ trunk/src/vegas/Makefile.am (revision 8429) @@ -1,228 +1,233 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement the VEGAS algorithm and the ## multi-channel implementation with VEGAS as backbone integrator ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libvegas.la check_LTLIBRARIES = libvegas_ut.la COMMON_F90 = MPI_F90 = \ vegas.f90_mpi \ vamp2.f90_mpi SERIAL_F90 = \ vegas.f90_serial \ vamp2.f90_serial EXTRA_DIST = \ $(COMMON_F90) \ $(SERIAL_F90) \ $(MPI_F90) nodist_libvegas_la_SOURCES = \ $(COMMON_F90) \ vegas.f90 \ vamp2.f90 DISTCLEANFILES = vegas.f90 vamp2.f90 if FC_USE_MPI vegas.f90: vegas.f90_mpi -cp -f $< $@ vamp2.f90: vamp2.f90_mpi -cp -f $< $@ else vegas.f90: vegas.f90_serial -cp -f $< $@ vamp2.f90: vamp2.f90_serial -cp -f $< $@ endif libvegas_ut_la_SOURCES = \ vegas_uti.f90 vegas_ut.f90 \ vamp2_uti.f90 vamp2_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = vegas.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${nodist_libvegas_la_SOURCES:.f90=.$(FCMOD)} + libvegas_Modules = $(nodist_libvegas_la_SOURCES:.f90=) $(libvegas_ut_la_SOURCES:.f90=) Modules: Makefile @for module in $(libvegas_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../rng/Modules \ ../phase_space/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(nodist_libvegas_la_SOURCES) $(libvegas_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done ; \ done DISTCLEANFILES += Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(nodist_libvegas_la_SOURCES) $(libvegas_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend ## Dependencies across directories and packages, if not automatically generated -rng_tao.lo: ../../vamp/src/tao_random_numbers.$(FC_MODULE_EXT) +rng_tao.lo: ../../vamp/src/tao_random_numbers.$(FCMOD) # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../rng -I../physics -I../fastjet -I../qft -I../matrix_elements -I../types -I../particles -I../beams -I../phase_space -I../expr_base -I../variables -I../../vamp/src -I../mci ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE FILTER = -filter "sed 's/defn MPI:/defn/'" PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw vegas.stamp: $(PRELUDE) $(srcdir)/vegas.nw $(POSTLUDE) @rm -f vegas.tmp @touch vegas.tmp for src in $(COMMON_F90) $(libvegas_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done for src in $(SERIAL_F90:.f90_serial=.f90); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src'_serial'; \ done for src in $(MPI_F90:.f90_mpi=.f90); do \ $(NOTANGLE) -R[[$$src]] $(FILTER) $^ | $(CPIF) $$src'_mpi'; \ done @mv -f vegas.tmp vegas.stamp $(COMMON_F90) $(SERIAL_F90) $(MPI_F90) $(libvegas_ut_la_SOURCES): vegas.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f vegas.stamp; \ $(MAKE) $(AM_MAKEFLAGS) vegas.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.f90_serial *.f90_mpi *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.f90_serial *.f90_mpi *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f vegas.stamp vegas.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/muli/Makefile.am =================================================================== --- trunk/src/muli/Makefile.am (revision 8428) +++ trunk/src/muli/Makefile.am (revision 8429) @@ -1,185 +1,190 @@ ## Makefile.am -- Makefile for WHIZARD - Multiple Interactions ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory end up in an auxiliary libtool library. noinst_LTLIBRARIES = libmuli.la libmuli_la_SOURCES = \ muli.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = muli.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libmuli_la_SOURCES:.f90=.$(FCMOD)} + libmuli_Modules = ${libmuli_la_SOURCES:.f90=} Modules: Makefile @for module in $(libmuli_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../system/Modules \ ../utilities/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libmuli_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed ## Dependencies across directories and packages, if not automatically generated $(libmuli_la_OBJECTS): \ - ../pdf_builtin/pdf_builtin.$(FC_MODULE_EXT) + ../pdf_builtin/pdf_builtin.$(FCMOD) # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libmuli_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../system -I../../vamp/src/ -I../pdf_builtin -I../utilities AM_FFLAGS = ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FFLAGS += $(FCFLAGS_PROFILING) AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FFLAGS += $(FCFLAGS_OPENMP) AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FFLAGS += $(FCFLAGS_MPI) AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw muli.stamp: $(PRELUDE) $(srcdir)/muli.nw $(POSTLUDE) @rm -f muli.tmp @touch muli.tmp for src in $(MULI_SRC); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f muli.tmp muli.stamp MULI_SRC = $(libmuli_la_SOURCES) $(MULI_SRC): muli.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f muli.stamp; \ $(MAKE) $(AM_MAKEFLAGS) muli.stamp; \ fi endif ######################################################################## ## Remove backup files ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.f endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.f || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f muli.stamp muli.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/blha/Makefile.am =================================================================== --- trunk/src/blha/Makefile.am (revision 8428) +++ trunk/src/blha/Makefile.am (revision 8429) @@ -1,230 +1,237 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory interface the BLHA amplitude calculator ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libblha.la check_LTLIBRARIES = libblha_ut.la COMMON_F90 = \ blha_olp_interfaces.f90 MPI_F90 = \ blha_config.f90_mpi SERIAL_F90 = \ blha_config.f90_serial EXTRA_DIST = \ $(COMMON_F90) \ $(SERIAL_F90) \ $(MPI_F90) nodist_libblha_la_SOURCES = \ blha_config.f90 \ $(COMMON_F90) DISTCLEANFILES = blha_config.f90 if FC_USE_MPI blha_config.f90: blha_config.f90_mpi -cp -f $< $@ else blha_config.f90: blha_config.f90_serial -cp -f $< $@ endif libblha_ut_la_SOURCES = \ blha_uti.f90 blha_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = blha.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libblha_la_SOURCES:.f90=.$(FCMOD)} \ + blha_olp_interfaces.$(FCMOD) \ + blha_config.$(FCMOD) + libblha_Modules = $(nodist_libblha_la_SOURCES:.f90=) $(libblha_ut_la_SOURCES:.f90=) Modules: Makefile @for module in $(libblha_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../combinatorics/Modules \ ../parsing/Modules \ ../physics/Modules \ ../qft/Modules \ ../expr_base/Modules \ ../types/Modules \ ../variables/Modules \ ../model_features/Modules \ ../matrix_elements/Modules \ ../particles/Modules \ ../threshold/Modules \ ../beams/Modules \ ../me_methods/Modules include_modules_bare = ${module_lists:/Modules=} include_modules = ${include_modules_bare:../%=-I../%} $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(nodist_libblha_la_SOURCES) $(libblha_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES += Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(nodist_libblha_la_SOURCES) $(libblha_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = $(include_modules) -I../fastjet -I../pdf_builtin -I../lhapdf ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE FILTER = -filter "sed 's/defn MPI:/defn/'" PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw blha.stamp: $(PRELUDE) $(srcdir)/blha.nw $(POSTLUDE) @rm -f blha.tmp @touch blha.tmp for src in $(COMMON_F90) $(libblha_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done for src in $(SERIAL_F90:.f90_serial=.f90); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src'_serial'; \ done for src in $(MPI_F90:.f90_mpi=.f90); do \ $(NOTANGLE) -R[[$$src]] $(FILTER) $^ | $(CPIF) $$src'_mpi'; \ done @mv -f blha.tmp blha.stamp $(COMMON_F90) $(SERIAL_F90) $(MPI_F90) $(libblha_ut_la_SOURCES): blha.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f blha.stamp; \ $(MAKE) $(AM_MAKEFLAGS) blha.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.f90_serial *.f90_mpi *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.f90_serial *.f90_mpi *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f blha.stamp blha.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/gosam/Makefile.am =================================================================== --- trunk/src/gosam/Makefile.am (revision 8428) +++ trunk/src/gosam/Makefile.am (revision 8429) @@ -1,189 +1,194 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory interface the GOSAM amplitude calculator ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libgosam.la libgosam_la_SOURCES = \ prc_gosam.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = gosam.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libgosam_la_SOURCES:.f90=.$(FCMOD)} + libgosam_Modules = ${libgosam_la_SOURCES:.f90=} Modules: Makefile @for module in $(libgosam_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../physics/Modules \ ../qft/Modules \ ../types/Modules \ ../particles/Modules \ ../matrix_elements/Modules \ ../me_methods/Modules \ ../variables/Modules \ ../fks/Modules \ ../blha/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libgosam_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libgosam_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../parsing -I../physics -I../qft -I../expr_base -I../types -I../particles -I../matrix_elements -I../beams -I../me_methods -I../variables -I../fks -I../blha -I../fastjet -I../pdf_builtin -I../lhapdf ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw gosam.stamp: $(PRELUDE) $(srcdir)/gosam.nw $(POSTLUDE) @rm -f gosam.tmp @touch gosam.tmp for src in $(libgosam_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f gosam.tmp gosam.stamp $(libgosam_la_SOURCES): gosam.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f gosam.stamp; \ $(MAKE) $(AM_MAKEFLAGS) gosam.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f gosam.stamp gosam.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/mci/Makefile.am =================================================================== --- trunk/src/mci/Makefile.am (revision 8428) +++ trunk/src/mci/Makefile.am (revision 8429) @@ -1,241 +1,242 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement quantum field theory concepts ## such as model representation and quantum numbers. ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libmci.la check_LTLIBRARIES = libmci_ut.la COMMON_F90 = \ mci_base.f90 \ iterations.f90 \ integration_results.f90 \ mci_none.f90 \ mci_midpoint.f90 \ mci_vamp.f90 \ dispatch_mci.f90 MPI_F90 = \ mci_vamp2.f90_mpi SERIAL_F90 = \ mci_vamp2.f90_serial EXTRA_DIST = \ $(COMMON_F90) \ $(SERIAL_F90) \ $(MPI_F90) nodist_libmci_la_SOURCES = \ $(COMMON_F90) \ mci_vamp2.f90 DISTCLEANFILES = mci_vamp2.f90 if FC_USE_MPI mci_vamp2.f90: mci_vamp2.f90_mpi -cp -f $< $@ else mci_vamp2.f90: mci_vamp2.f90_serial -cp -f $< $@ endif libmci_ut_la_SOURCES = \ mci_base_uti.f90 mci_base_ut.f90 \ iterations_uti.f90 iterations_ut.f90 \ mci_none_uti.f90 mci_none_ut.f90 \ integration_results_uti.f90 integration_results_ut.f90 \ mci_midpoint_uti.f90 mci_midpoint_ut.f90 \ mci_vamp_uti.f90 mci_vamp_ut.f90 \ mci_vamp2_uti.f90 mci_vamp2_ut.f90 \ dispatch_mci_uti.f90 dispatch_mci_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = mci.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${nodist_libmci_la_SOURCES:.f90=.$(FCMOD)} + libmci_Modules = $(nodist_libmci_la_SOURCES:.f90=) $(libmci_ut_la_SOURCES:.f90=) Modules: Makefile @for module in $(libmci_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../combinatorics/Modules \ ../rng/Modules \ ../phase_space/Modules \ ../variables/Modules \ ../vegas/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(nodist_libmci_la_SOURCES) $(libmci_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES += Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(nodist_libmci_la_SOURCES) $(libmci_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend ## Dependencies across directories and packages, if not automatically generated -mci_vamp.lo: ../../vamp/src/vamp.$(FC_MODULE_EXT) +mci_vamp.lo: ../../vamp/src/vamp.$(FCMOD) # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../rng -I../physics -I../fastjet -I../qft -I../matrix_elements -I../types -I../particles -I../beams -I../phase_space -I../expr_base -I../variables -I../../vamp/src -I../vegas ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -#execmoddir = $(pkglibdir)/mod/mci -#nodist_execmod_HEADERS = \# - ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE FILTER = -filter "sed 's/defn MPI:/defn/'" PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw mci.stamp: $(PRELUDE) $(srcdir)/mci.nw $(POSTLUDE) @rm -f mci.tmp @touch mci.tmp for src in $(COMMON_F90) $(libmci_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done for src in $(SERIAL_F90:.f90_serial=.f90); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src'_serial'; \ done for src in $(MPI_F90:.f90_mpi=.f90); do \ $(NOTANGLE) -R[[$$src]] $(FILTER) $^ | $(CPIF) $$src'_mpi'; \ done @mv -f mci.tmp mci.stamp $(COMMON_F90) $(SERIAL_F90) $(MPI_F90) $(libmci_ut_la_SOURCES): mci.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f mci.stamp; \ $(MAKE) $(AM_MAKEFLAGS) mci.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.f90_serial *.f90_mpi *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.f90_serial *.f90_mpi *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f mci.stamp mci.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/expr_base/Makefile.am =================================================================== --- trunk/src/expr_base/Makefile.am (revision 8428) +++ trunk/src/expr_base/Makefile.am (revision 8429) @@ -1,183 +1,184 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement objects and methods ## as they appear in the Sindarin language ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libexpr_base.la libexpr_base_la_SOURCES = \ var_base.f90 \ expr_base.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = expr_base.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libexpr_base_la_SOURCES:.f90=.$(FCMOD)} + libexpr_base_Modules = ${libexpr_base_la_SOURCES:.f90=} Modules: Makefile @for module in $(libexpr_base_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libexpr_base_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libexpr_base_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -#execmoddir = $(pkglibdir)/mod/expr_base -#nodist_execmod_HEADERS = \# - ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw expr_base.stamp: $(PRELUDE) $(srcdir)/expr_base.nw $(POSTLUDE) @rm -f expr_base.tmp @touch expr_base.tmp for src in $(libexpr_base_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f expr_base.tmp expr_base.stamp $(libexpr_base_la_SOURCES): expr_base.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f expr_base.stamp; \ $(MAKE) $(AM_MAKEFLAGS) expr_base.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f expr_base.stamp expr_base.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/variables/Makefile.am =================================================================== --- trunk/src/variables/Makefile.am (revision 8428) +++ trunk/src/variables/Makefile.am (revision 8429) @@ -1,193 +1,195 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement objects and methods ## as they appear in the Sindarin language ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libvariables.la libvariables_la_SOURCES = \ variables.f90 \ observables.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = variables.nw +# Modules and installation +# Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libvariables_la_SOURCES:.f90=.$(FCMOD)} + # Dump module names into file Modules libvariables_Modules = ${libvariables_la_SOURCES:.f90=} Modules: Makefile @for module in $(libvariables_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../expr_base/Modules \ ../physics/Modules \ ../types/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libvariables_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libvariables_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../physics -I../expr_base -I../fastjet -I../types ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -#execmoddir = $(pkglibdir)/mod/variables -#nodist_execmod_HEADERS = \# - ## Dependencies across directories and packages, if not automatically generated $(libvariables_la_OBJECTS): \ - ../fastjet/fastjet.$(FC_MODULE_EXT) + ../fastjet/fastjet.$(FCMOD) ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw variables.stamp: $(PRELUDE) $(srcdir)/variables.nw $(POSTLUDE) @rm -f variables.tmp @touch variables.tmp for src in $(libvariables_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f variables.tmp variables.stamp $(libvariables_la_SOURCES): variables.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f variables.stamp; \ $(MAKE) $(AM_MAKEFLAGS) variables.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f variables.stamp variables.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/phase_space/Makefile.am =================================================================== --- trunk/src/phase_space/Makefile.am (revision 8428) +++ trunk/src/phase_space/Makefile.am (revision 8429) @@ -1,227 +1,229 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement quantum field theory concepts ## such as model representation and quantum numbers. ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libphase_space.la check_LTLIBRARIES = libphase_space_ut.la libphase_space_la_SOURCES = \ phs_base.f90 \ phs_none.f90 \ phs_single.f90 \ phs_rambo.f90 \ resonances.f90 \ mappings.f90 phs_trees.f90 phs_forests.f90 \ cascades.f90 \ phs_wood.f90 \ phs_fks.f90 \ dispatch_phase_space.f90 \ cascades2_lexer.f90 \ cascades2.f90 libphase_space_ut_la_SOURCES = \ phs_base_uti.f90 phs_base_ut.f90 \ phs_none_uti.f90 phs_none_ut.f90 \ phs_single_uti.f90 phs_single_ut.f90 \ phs_rambo_uti.f90 phs_rambo_ut.f90 \ resonances_uti.f90 resonances_ut.f90 \ phs_trees_uti.f90 phs_trees_ut.f90 \ phs_forests_uti.f90 phs_forests_ut.f90 \ cascades_uti.f90 cascades_ut.f90 \ phs_wood_uti.f90 phs_wood_ut.f90 \ phs_fks_uti.f90 phs_fks_ut.f90 \ dispatch_phs_uti.f90 dispatch_phs_ut.f90 \ cascades2_lexer_uti.f90 cascades2_lexer_ut.f90 \ cascades2_uti.f90 cascades2_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = phase_space.nw +# Modules and installation +# Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libphase_space_la_SOURCES:.f90=.$(FCMOD)} + # Dump module names into file Modules libphase_space_Modules = \ ${libphase_space_la_SOURCES:.f90=} \ ${libphase_space_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libphase_space_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../combinatorics/Modules \ ../parsing/Modules \ ../physics/Modules \ ../qft/Modules \ ../types/Modules \ ../matrix_elements/Modules \ ../beams/Modules \ ../model_features/Modules \ ../variables/Modules \ ../expr_base/Modules \ ../threshold/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libphase_space_la_SOURCES) $(libphase_space_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libphase_space_la_SOURCES) $(libphase_space_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../parsing -I../physics -I../fastjet -I../qed_pdf -I../qft -I../matrix_elements -I../types -I../particles -I../beams -I../rng -I../../circe1/src -I../../circe2/src -I../pdf_builtin -I../lhapdf -I../model_features -I../variables -I../expr_base -I../threshold ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -#execmoddir = $(pkglibdir)/mod/phase_space -#nodist_execmod_HEADERS = \# - ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw phase_space.stamp: $(PRELUDE) $(srcdir)/phase_space.nw $(POSTLUDE) @rm -f phase_space.tmp @touch phase_space.tmp for src in \ $(libphase_space_la_SOURCES) \ $(libphase_space_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f phase_space.tmp phase_space.stamp $(libphase_space_la_SOURCES) $(libphase_space_ut_la_SOURCES): phase_space.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f phase_space.stamp; \ $(MAKE) $(AM_MAKEFLAGS) phase_space.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f phase_space.stamp phase_space.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/testing/testing.nw =================================================================== --- trunk/src/testing/testing.nw (revision 8428) +++ trunk/src/testing/testing.nw (revision 8429) @@ -1,277 +1,342 @@ % -*- ess-noweb-default-code-mode: f90-mode; noweb-default-code-mode: f90-mode; -*- % WHIZARD code as NOWEB source \chapter{Testing} \includemodulegraph{testing} This part contains tools for automatic testing. \begin{description} \item[unit\_tests] A handler that executes test procedures and compares and collects results. \end{description} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Unit tests} We provide functionality for automated unit tests. Each test is required to produce output which is compared against a reference file. If the two are identical, we signal success. Otherwise, we signal failure and write the output to a file. <<[[unit_tests.f90]]>>= <> module unit_tests <> use io_units <> <> <> <> <> contains <> end module unit_tests @ %def unit_tests @ \subsection{Parameters} Building blocks of file names. The directory names and suffixes are hard-coded here, and they must reflect actual Makefile targets where applicable. <>= character(*), parameter :: ref_prefix = "ref-output/" character(*), parameter :: ref = ".ref" character(*), parameter :: err_prefix = "err-output/" character(*), parameter :: err = ".out" @ %def prefix ref err @ \subsection{Type for storing test results} We store the results of the individual unit tests in a linked list. Here is the entry: <>= public :: test_results_t <>= type :: test_result_t logical :: success = .false. type(string_t) :: name type(string_t) :: description type(test_result_t), pointer :: next => null () end type test_result_t type :: test_results_t private type(test_result_t), pointer :: first => null () type(test_result_t), pointer :: last => null () integer :: n_success = 0 integer :: n_failure = 0 contains <> end type test_results_t @ %def test_result_t test_results_t @ Add a test result. <>= - procedure, private :: add => test_results_add + procedure :: add => test_results_add <>= subroutine test_results_add (list, name, description, success) class(test_results_t), intent(inout) :: list character(len=*), intent(in) :: name character(len=*), intent(in) :: description logical, intent(in) :: success type(test_result_t), pointer :: result allocate (result) result%success = success result%name = name result%description = description if (associated (list%first)) then list%last%next => result else list%first => result end if list%last => result if (success) then list%n_success = list%n_success + 1 else list%n_failure = list%n_failure + 1 end if end subroutine test_results_add @ %def test_results_add @ Display the current state. <>= procedure, private :: write => test_results_write <>= subroutine test_results_write (list, u) class(test_results_t), intent(in) :: list integer, intent(in) :: u type(test_result_t), pointer :: result write (u, "(A)") "*** Test Summary ***" if (list%n_success > 0) then write (u, "(2x,A)") "Success:" result => list%first do while (associated (result)) if (result%success) write (u, "(4x,A,': ',A)") & char (result%name), char (result%description) result => result%next end do end if if (list%n_failure > 0) then write (u, "(2x,A)") "Failure:" result => list%first do while (associated (result)) if (.not. result%success) write (u, "(4x,A,': ',A)") & char (result%name), char (result%description) result => result%next end do end if write (u, "(A,I0)") "Total = ", list%n_success + list%n_failure write (u, "(A,I0)") "Success = ", list%n_success write (u, "(A,I0)") "Failure = ", list%n_failure write (u, "(A)") "*** End of test Summary ***" end subroutine test_results_write @ %def test_results_write @ Return true if all tests were successful (or no test). <>= procedure, private :: report => test_results_report <>= subroutine test_results_report (list, success) class(test_results_t), intent(in) :: list logical, intent(out) :: success success = list%n_failure == 0 end subroutine test_results_report @ %def test_results_report +@ Return the number of successful/failed/total tests.. +<>= + procedure :: get_n_pass => test_results_get_n_pass + procedure :: get_n_fail => test_results_get_n_fail + procedure :: get_n_total => test_results_get_n_total +<>= + function test_results_get_n_pass (list) result (n) + class(test_results_t), intent(in) :: list + integer :: n + n = list%n_success + end function test_results_get_n_pass + + function test_results_get_n_fail (list) result (n) + class(test_results_t), intent(in) :: list + integer :: n + n = list%n_failure + end function test_results_get_n_fail + + function test_results_get_n_total (list) result (n) + class(test_results_t), intent(in) :: list + integer :: n + n = list%n_success + list%n_failure + end function test_results_get_n_total + +@ %def test_results_get_n_pass +@ %def test_results_get_n_fail +@ %def test_results_get_n_total @ Delete the list. <>= procedure, private :: final => test_results_final <>= subroutine test_results_final (list) class(test_results_t), intent(inout) :: list type(test_result_t), pointer :: result do while (associated (list%first)) result => list%first list%first => result%next deallocate (result) end do list%last => null () list%n_success = 0 list%n_failure = 0 end subroutine test_results_final @ %def test_results_final @ \subsection{Wrapup} This will write results, report status, and finalize. This is the only method which we need to access from outside. <>= procedure :: wrapup => test_results_wrapup <>= subroutine test_results_wrapup (list, u, success) class(test_results_t), intent(inout) :: list integer, intent(in) :: u logical, intent(out), optional :: success call list%write (u) if (present (success)) call list%report (success) call list%final () end subroutine test_results_wrapup @ %def test_results_wrapup @ \subsection{Tool for Unit Tests} This procedure takes a test routine as an argument. It runs the test, output directed to a temporary file. Then, it compares the file against a reference file. The test routine must take the output unit as argument. We export this abstract interface, so the test drivers can reference it for declaring the actual test routines. <>= public :: unit_test <>= abstract interface subroutine unit_test (u) integer, intent(in) :: u end subroutine unit_test end interface @ %def unit_test @ The test routine can print to screen and, optionally, to a logging unit. +This driver runs the test given as an argument, directing its output to a +scratch file which is then checked against a ref file. Only if it differs, it +is copied to an err file. NB: We call [[fatal_force_crash]] to produce a deliberate crash with backtrace on any fatal error, if the runtime system does allow it. This is not normal behavior, but should be useful if something goes wrong. <>= public :: test <>= subroutine test (test_proc, name, description, u_log, results) procedure(unit_test) :: test_proc character(*), intent(in) :: name character(*), intent(in) :: description integer, intent(in) :: u_log type(test_results_t), intent(inout) :: results - integer :: u_test, u_ref, u_err - logical :: exist - character(256) :: buffer1, buffer2 - integer :: iostat1, iostat2 + integer :: u_test logical :: success - write (*, "(A)", advance="no") "Running test: " // name - write (u_log, "(A)") "Test: " // name + + call start_test (u_log, name) + u_test = free_unit () - open (u_test, status="scratch", action="readwrite") + open (unit = u_test, status="scratch", action="readwrite") call fatal_force_crash () call test_proc (u_test) rewind (u_test) + + call compare_test_results (u_test, u_log, name, success) + call results%add (name, description, success) + close (u_test) + + end subroutine test + +@ %def test +@ Startup message. We expose this, as well as the comparison routine, for +re-use in external test programs. +<>= + public :: start_test +<>= + subroutine start_test (u_log, name) + integer, intent(in) :: u_log + character(*), intent(in) :: name + + write (*, "(A)", advance="no") "Running test: " // name + write (u_log, "(A)") "Test: " // name + + end subroutine start_test + +@ %def start_test +@ Do the actual comparison, given an open I/O unit [[u_test]]. In case of +failure, copy the test results to an error file. +<>= + public :: compare_test_results +<>= + subroutine compare_test_results (u_test, u_log, name, success) + integer, intent(in) :: u_test + integer, intent(in) :: u_log + character(*), intent(in) :: name + logical, intent(out) :: success + + integer :: u_ref, u_err + logical :: exist + character(256) :: buffer1, buffer2 + integer :: iostat1, iostat2 + inquire (file=ref_prefix//name//ref, exist=exist) if (exist) then - u_ref = free_unit () - open (u_ref, file=ref_prefix//name//ref, status="old", action="read") + open (newunit = u_ref, file=ref_prefix//name//ref, & + status="old", action="read") COMPARE_FILES: do read (u_test, "(A)", iostat=iostat1) buffer1 read (u_ref, "(A)", iostat=iostat2) buffer2 if (iostat1 /= iostat2) then success = .false. exit COMPARE_FILES else if (iostat1 < 0) then success = .true. exit COMPARE_FILES else if (buffer1 /= buffer2) then success = .false. exit COMPARE_FILES end if end do COMPARE_FILES close (u_ref) else write (*, "(A)", advance="no") " ... no reference output available" write (u_log, "(A)") " No reference output available." success = .false. end if if (success) then write (*, "(A)") " ... success." write (u_log, "(A)") " Success." else write (*, "(A)") " ... failure. See: " // err_prefix//name//err write (u_log, "(A)") " Failure." rewind (u_test) - u_err = free_unit () - open (u_err, file=err_prefix//name//err, & + open (newunit = u_err, file=err_prefix//name//err, & action="write", status="replace") WRITE_OUTPUT: do read (u_test, "(A)", end=1) buffer1 write (u_err, "(A)") trim (buffer1) end do WRITE_OUTPUT 1 close (u_err) end if - close (u_test) - call results%add (name, description, success) - end subroutine test -@ %def test + end subroutine compare_test_results + +@ %def compare_test_results Index: trunk/src/testing/Makefile.am =================================================================== --- trunk/src/testing/Makefile.am (revision 8428) +++ trunk/src/testing/Makefile.am (revision 8429) @@ -1,178 +1,184 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory handle unit tests in Fortran. ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libtesting.la libtesting_la_SOURCES = \ unit_tests.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = testing.nw +# Modules and installation +# Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libtesting_la_SOURCES:.f90=.$(FCMOD)} + # Dump module names into file Modules libtesting_Modules = ${libtesting_la_SOURCES:.f90=} Modules: Makefile @for module in $(libtesting_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libtesting_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libtesting_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../system ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw testing.stamp: $(PRELUDE) $(srcdir)/testing.nw $(POSTLUDE) @rm -f testing.tmp @touch testing.tmp for src in $(libtesting_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f testing.tmp testing.stamp $(libtesting_la_SOURCES): testing.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f testing.stamp; \ $(MAKE) $(AM_MAKEFLAGS) testing.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f testing.stamp testing.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/process_integration/Makefile.am =================================================================== --- trunk/src/process_integration/Makefile.am (revision 8428) +++ trunk/src/process_integration/Makefile.am (revision 8429) @@ -1,230 +1,235 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory form the core of process integration ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libprocess_integration.la check_LTLIBRARIES = libprocess_integration_ut.la libprocess_integration_la_SOURCES = \ subevt_expr.f90 \ parton_states.f90 \ pcm_base.f90 \ pcm.f90 \ process_counter.f90 \ process_config.f90 \ process.f90 \ instances.f90 \ process_mci.f90 \ kinematics.f90 \ process_stacks.f90 libprocess_integration_ut_la_SOURCES = \ processes_uti.f90 processes_ut.f90 \ process_stacks_uti.f90 process_stacks_ut.f90 \ parton_states_uti.f90 parton_states_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = process_integration.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libprocess_integration_la_SOURCES:.f90=.$(FCMOD)} + libprocess_integration_Modules = \ ${libprocess_integration_la_SOURCES:.f90=} \ ${libprocess_integration_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libprocess_integration_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../combinatorics/Modules \ ../rng/Modules \ ../physics/Modules \ ../qft/Modules \ ../expr_base/Modules \ ../types/Modules \ ../matrix_elements/Modules \ ../particles/Modules \ ../beams/Modules \ ../me_methods/Modules \ ../model_features/Modules \ ../phase_space/Modules \ ../mci/Modules \ ../blha/Modules \ ../gosam/Modules \ ../openloops/Modules \ ../recola/Modules \ ../fks/Modules \ ../variables/Modules \ ../parsing/Modules \ ../shower/Modules \ ../threshold/Modules include_modules_bare = ${module_lists:/Modules=} include_modules = ${include_modules_bare:../%=-I../%} $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libprocess_integration_la_SOURCES) \ $(libprocess_integration_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libprocess_integration_la_SOURCES) \ $(libprocess_integration_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = $(include_modules) -I../../vamp/src -I../../circe1/src -I../../circe2/src -I../pdf_builtin -I../lhapdf -I../qed_pdf -I../fastjet ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif if RECOLA_AVAILABLE AM_FCFLAGS += $(RECOLA_INCLUDES) endif ######################################################################## ## Non-standard targets and dependencies ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw process_integration.stamp: $(PRELUDE) $(srcdir)/process_integration.nw $(POSTLUDE) @rm -f process_integration.tmp @touch process_integration.tmp for src in \ $(libprocess_integration_la_SOURCES) \ $(libprocess_integration_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f process_integration.tmp process_integration.stamp $(libprocess_integration_la_SOURCES) $(libprocess_integration_ut_la_SOURCES): process_integration.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f process_integration.stamp; \ $(MAKE) $(AM_MAKEFLAGS) process_integration.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f process_integration.stamp process_integration.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/models/threeshl_bundle/Makefile.am =================================================================== --- trunk/src/models/threeshl_bundle/Makefile.am (revision 8428) +++ trunk/src/models/threeshl_bundle/Makefile.am (revision 8429) @@ -1,87 +1,87 @@ ## Makefile.am -- Makefile for model-parameter modules in WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## Build the threeshl bundle required for the 3SHL models. noinst_LTLIBRARIES = libthreeshl_bundle.la ## We need both in the distribution EXTRA_DIST = threeshl_bundle.f90 threeshl_bundle_lt.f90 libthreeshl_bundle_la_SOURCES = threeshl_bundle.f90 ## Unfortunately, the NAG and intel compilers require these to be happy. -execmoddir = $(pkglibdir)/mod/models +execmoddir = $(fmoddir)/whizard nodist_execmod_HEADERS = \ - tdefs.$(FC_MODULE_EXT) \ - threeshl.$(FC_MODULE_EXT) \ - tscript.$(FC_MODULE_EXT) \ - tglue.$(FC_MODULE_EXT) + tdefs.$(FCMOD) \ + threeshl.$(FCMOD) \ + tscript.$(FCMOD) \ + tglue.$(FCMOD) # Fortran90 module files are generated at the same time as object files $(nodist_execmod_HEADERS): threeshl_bundle.lo @: ######################################################################## ## Dependencies on global WHIZARD modules basicsdir = $(top_builddir)/src/basics -KINDS_MOD = kinds.$(FC_MODULE_EXT) -CONSTANTS_MOD = constants.$(FC_MODULE_EXT) +KINDS_MOD = kinds.$(FCMOD) +CONSTANTS_MOD = constants.$(FCMOD) AM_FCFLAGS = -I$(basicsdir) $(libthreeshl_bundle_la_OBJECTS): \ $(basicsdir)/$(KINDS_MOD) \ $(basicsdir)/$(CONSTANTS_MOD) ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ######################################################################## ## Non-standard cleanup tasks clean-local: - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-local: -rm -f *~ Index: trunk/src/models/Makefile.am =================================================================== --- trunk/src/models/Makefile.am (revision 8428) +++ trunk/src/models/Makefile.am (revision 8429) @@ -1,390 +1,390 @@ ## Makefile.am -- Makefile for model-parameter modules in WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## Build model-specific extra sources. SUBDIRS = \ threeshl_bundle ## Build WHIZARD/O'Mega model interface library ## These modules transfer WHIZARD's parameters to the matrix-element code ## as generated by O'Mega noinst_LTLIBRARIES = libmodels.la libmodels_la_SOURCES = \ parameters.THDM.f90 \ parameters.THDM_CKM.f90 \ parameters.AltH.f90 \ parameters.GravTest.f90 \ parameters.HSExt.f90 \ parameters.Littlest.f90 \ parameters.Littlest_Eta.f90 \ parameters.Littlest_Tpar.f90 \ parameters.MSSM.f90 \ parameters.MSSM_CKM.f90 \ parameters.MSSM_Grav.f90 \ parameters.MSSM_Hgg.f90 \ parameters.NMSSM.f90 \ parameters.NMSSM_CKM.f90 \ parameters.NMSSM_Hgg.f90 \ parameters.NoH_rx.f90 \ parameters.QED.f90 \ parameters.QCD.f90 \ parameters.PSSSM.f90 \ parameters.Simplest.f90 \ parameters.Simplest_univ.f90 \ parameters.SM.f90 \ parameters.SM_ac.f90 \ parameters.SM_ac_CKM.f90 \ parameters.SM_dim6.f90 \ parameters.SM_CKM.f90 \ parameters.SM_top.f90 \ parameters.SM_top_anom.f90 \ parameters.SM_tt_threshold.f90 \ parameters.SM_Higgs.f90 \ parameters.SM_Higgs_CKM.f90 \ parameters.SM_rx.f90 \ parameters.SM_ul.f90 \ parameters.Template.f90 \ parameters.UED.f90 \ parameters.SSC.f90 \ parameters.SSC_2.f90 \ parameters.SSC_AltT.f90 \ parameters.Xdim.f90 \ parameters.WZW.f90 \ parameters.Zprime.f90 \ parameters.Threeshl.f90 \ parameters.Threeshl_nohf.f90 \ parameters.Test.f90 ## Install the modules used by generated matrix element code -execmoddir = $(pkglibdir)/mod/models +execmoddir = $(fmoddir)/models nodist_execmod_HEADERS = \ - parameters_thdm.$(FC_MODULE_EXT) \ - parameters_thdm_ckm.$(FC_MODULE_EXT) \ - parameters_alth.$(FC_MODULE_EXT) \ - parameters_gravtest.$(FC_MODULE_EXT) \ - parameters_hsext.$(FC_MODULE_EXT) \ - parameters_littlest.$(FC_MODULE_EXT) \ - parameters_littlest_eta.$(FC_MODULE_EXT) \ - parameters_littlest_tpar.$(FC_MODULE_EXT) \ - parameters_mssm.$(FC_MODULE_EXT) \ - parameters_mssm_ckm.$(FC_MODULE_EXT) \ - parameters_mssm_hgg.$(FC_MODULE_EXT) \ - parameters_mssm_grav.$(FC_MODULE_EXT) \ - parameters_nmssm.$(FC_MODULE_EXT) \ - parameters_nmssm_ckm.$(FC_MODULE_EXT) \ - parameters_nmssm_hgg.$(FC_MODULE_EXT) \ - parameters_noh_rx.$(FC_MODULE_EXT) \ - parameters_qed.$(FC_MODULE_EXT) \ - parameters_qcd.$(FC_MODULE_EXT) \ - parameters_psssm.$(FC_MODULE_EXT) \ - parameters_simplest.$(FC_MODULE_EXT) \ - parameters_simplest_univ.$(FC_MODULE_EXT) \ - parameters_sm.$(FC_MODULE_EXT) \ - parameters_sm_ac.$(FC_MODULE_EXT) \ - parameters_sm_ac_ckm.$(FC_MODULE_EXT) \ - parameters_sm_dim6.$(FC_MODULE_EXT) \ - parameters_sm_ckm.$(FC_MODULE_EXT) \ - parameters_sm_top.$(FC_MODULE_EXT) \ - parameters_sm_top_anom.$(FC_MODULE_EXT) \ - parameters_sm_tt_threshold.$(FC_MODULE_EXT) \ - parameters_sm_higgs.$(FC_MODULE_EXT) \ - parameters_sm_higgs_ckm.$(FC_MODULE_EXT) \ - parameters_sm_rx.$(FC_MODULE_EXT) \ - parameters_sm_ul.$(FC_MODULE_EXT) \ - parameters_template.$(FC_MODULE_EXT) \ - parameters_ued.$(FC_MODULE_EXT) \ - parameters_ssc.$(FC_MODULE_EXT) \ - parameters_ssc_2.$(FC_MODULE_EXT) \ - parameters_ssc_altt.$(FC_MODULE_EXT) \ - parameters_xdim.$(FC_MODULE_EXT) \ - parameters_wzw.$(FC_MODULE_EXT) \ - parameters_zprime.$(FC_MODULE_EXT) \ - parameters_threeshl.$(FC_MODULE_EXT) \ - parameters_threeshl_nohf.$(FC_MODULE_EXT) \ - parameters_test.$(FC_MODULE_EXT) + parameters_thdm.$(FCMOD) \ + parameters_thdm_ckm.$(FCMOD) \ + parameters_alth.$(FCMOD) \ + parameters_gravtest.$(FCMOD) \ + parameters_hsext.$(FCMOD) \ + parameters_littlest.$(FCMOD) \ + parameters_littlest_eta.$(FCMOD) \ + parameters_littlest_tpar.$(FCMOD) \ + parameters_mssm.$(FCMOD) \ + parameters_mssm_ckm.$(FCMOD) \ + parameters_mssm_hgg.$(FCMOD) \ + parameters_mssm_grav.$(FCMOD) \ + parameters_nmssm.$(FCMOD) \ + parameters_nmssm_ckm.$(FCMOD) \ + parameters_nmssm_hgg.$(FCMOD) \ + parameters_noh_rx.$(FCMOD) \ + parameters_qed.$(FCMOD) \ + parameters_qcd.$(FCMOD) \ + parameters_psssm.$(FCMOD) \ + parameters_simplest.$(FCMOD) \ + parameters_simplest_univ.$(FCMOD) \ + parameters_sm.$(FCMOD) \ + parameters_sm_ac.$(FCMOD) \ + parameters_sm_ac_ckm.$(FCMOD) \ + parameters_sm_dim6.$(FCMOD) \ + parameters_sm_ckm.$(FCMOD) \ + parameters_sm_top.$(FCMOD) \ + parameters_sm_top_anom.$(FCMOD) \ + parameters_sm_tt_threshold.$(FCMOD) \ + parameters_sm_higgs.$(FCMOD) \ + parameters_sm_higgs_ckm.$(FCMOD) \ + parameters_sm_rx.$(FCMOD) \ + parameters_sm_ul.$(FCMOD) \ + parameters_template.$(FCMOD) \ + parameters_ued.$(FCMOD) \ + parameters_ssc.$(FCMOD) \ + parameters_ssc_2.$(FCMOD) \ + parameters_ssc_altt.$(FCMOD) \ + parameters_xdim.$(FCMOD) \ + parameters_wzw.$(FCMOD) \ + parameters_zprime.$(FCMOD) \ + parameters_threeshl.$(FCMOD) \ + parameters_threeshl_nohf.$(FCMOD) \ + parameters_test.$(FCMOD) ## Build WHIZARD auxiliary dynamic libraries for model access ## These modules handle initialization operations that are not accounted ## for by definitions in the model files (external parameters). modellibdir = $(pkglibdir)/models modellib_LTLIBRARIES = \ external.SM_tt_threshold.la \ external.Threeshl.la \ external.Threeshl_nohf.la \ external.Test.la external_SM_tt_threshold_la_SOURCES = external.SM_tt_threshold.f90 external_SM_tt_threshold_la_LDFLAGS = -module external_Threeshl_la_SOURCES = external.Threeshl.f90 external_Threeshl_la_LDFLAGS = -module external_Threeshl_nohf_la_SOURCES = external.Threeshl_nohf.f90 external_Threeshl_nohf_la_LDFLAGS = -module external_Test_la_SOURCES = external.Test.f90 external_Test_la_LDFLAGS = -module ## Collect the SM ttbar threshold code. external_SM_tt_threshold_la_LIBADD = ../threshold/libthreshold.la libmodels_la_LIBADD = ../threshold/libthreshold.la ## Collect the 3SHL code. external_Threeshl_la_LIBADD = threeshl_bundle/libthreeshl_bundle.la libmodels_la_LIBADD += threeshl_bundle/libthreeshl_bundle.la external_Threeshl_nohf_la_LIBADD = threeshl_bundle/libthreeshl_bundle.la ## Switch off optimization if requested ## Optimization is useless here, it just consumes compile time. if !OPTIMIZATION_FOR_PARFILES NO_OPT=-O0 endif .f90.o: $(AM_V_FC)$(FCCOMPILE) $(NO_OPT) -c -o $@ $< .f90.obj: $(AM_V_FC)$(FCCOMPILE) $(NO_OPT) -c -o $@ `$(CYGPATH_W) '$<'` .f90.lo: $(AM_V_FC)$(LTFCCOMPILE) $(NO_OPT) -c -o $@ $< ## The mismatch of filenames and module names requires a lot of repetition: -parameters_thdm.$(FC_MODULE_EXT): parameters.THDM.lo +parameters_thdm.$(FCMOD): parameters.THDM.lo @: -parameters_thdm_ckm.$(FC_MODULE_EXT): parameters.THDM_CKM.lo +parameters_thdm_ckm.$(FCMOD): parameters.THDM_CKM.lo @: -parameters_alth.$(FC_MODULE_EXT): parameters.AltH.lo +parameters_alth.$(FCMOD): parameters.AltH.lo @: -parameters_gravtest.$(FC_MODULE_EXT): parameters.GravTest.lo +parameters_gravtest.$(FCMOD): parameters.GravTest.lo @: -parameters_hsext.$(FC_MODULE_EXT): parameters.HSExt.lo +parameters_hsext.$(FCMOD): parameters.HSExt.lo @: -parameters_littlest.$(FC_MODULE_EXT): parameters.Littlest.lo +parameters_littlest.$(FCMOD): parameters.Littlest.lo @: -parameters_littlest_eta.$(FC_MODULE_EXT): parameters.Littlest_Eta.lo +parameters_littlest_eta.$(FCMOD): parameters.Littlest_Eta.lo @: -parameters_littlest_tpar.$(FC_MODULE_EXT): parameters.Littlest_Tpar.lo +parameters_littlest_tpar.$(FCMOD): parameters.Littlest_Tpar.lo @: -parameters_mssm.$(FC_MODULE_EXT): parameters.MSSM.lo +parameters_mssm.$(FCMOD): parameters.MSSM.lo @: -parameters_mssm_4.$(FC_MODULE_EXT): parameters.MSSM_4.lo +parameters_mssm_4.$(FCMOD): parameters.MSSM_4.lo @: -parameters_mssm_ckm.$(FC_MODULE_EXT): parameters.MSSM_CKM.lo +parameters_mssm_ckm.$(FCMOD): parameters.MSSM_CKM.lo @: -parameters_mssm_grav.$(FC_MODULE_EXT): parameters.MSSM_Grav.lo +parameters_mssm_grav.$(FCMOD): parameters.MSSM_Grav.lo @: -parameters_mssm_hgg.$(FC_MODULE_EXT): parameters.MSSM_Hgg.lo +parameters_mssm_hgg.$(FCMOD): parameters.MSSM_Hgg.lo @: -parameters_nmssm.$(FC_MODULE_EXT): parameters.NMSSM.lo +parameters_nmssm.$(FCMOD): parameters.NMSSM.lo @: -parameters_nmssm_ckm.$(FC_MODULE_EXT): parameters.NMSSM_CKM.lo +parameters_nmssm_ckm.$(FCMOD): parameters.NMSSM_CKM.lo @: -parameters_nmssm_hgg.$(FC_MODULE_EXT): parameters.NMSSM_Hgg.lo +parameters_nmssm_hgg.$(FCMOD): parameters.NMSSM_Hgg.lo @: -parameters_noh_rx.$(FC_MODULE_EXT): parameters.NoH_rx.lo +parameters_noh_rx.$(FCMOD): parameters.NoH_rx.lo @: -parameters_psssm.$(FC_MODULE_EXT): parameters.PSSSM.lo +parameters_psssm.$(FCMOD): parameters.PSSSM.lo @: -parameters_qcd.$(FC_MODULE_EXT): parameters.QCD.lo +parameters_qcd.$(FCMOD): parameters.QCD.lo @: -parameters_qed.$(FC_MODULE_EXT): parameters.QED.lo +parameters_qed.$(FCMOD): parameters.QED.lo @: -parameters_sm.$(FC_MODULE_EXT): parameters.SM.lo +parameters_sm.$(FCMOD): parameters.SM.lo @: -parameters_sm_ckm.$(FC_MODULE_EXT): parameters.SM_CKM.lo +parameters_sm_ckm.$(FCMOD): parameters.SM_CKM.lo @: -parameters_sm_dim6.$(FC_MODULE_EXT): parameters.SM_dim6.lo +parameters_sm_dim6.$(FCMOD): parameters.SM_dim6.lo @: -parameters_sm_ac.$(FC_MODULE_EXT): parameters.SM_ac.lo +parameters_sm_ac.$(FCMOD): parameters.SM_ac.lo @: -parameters_sm_ac_ckm.$(FC_MODULE_EXT): parameters.SM_ac_CKM.lo +parameters_sm_ac_ckm.$(FCMOD): parameters.SM_ac_CKM.lo @: -parameters_sm_top.$(FC_MODULE_EXT): parameters.SM_top.lo +parameters_sm_top.$(FCMOD): parameters.SM_top.lo @: -parameters_sm_top_anom.$(FC_MODULE_EXT): parameters.SM_top_anom.lo +parameters_sm_top_anom.$(FCMOD): parameters.SM_top_anom.lo @: -parameters_sm_tt_threshold.$(FC_MODULE_EXT): parameters.SM_tt_threshold.lo +parameters_sm_tt_threshold.$(FCMOD): parameters.SM_tt_threshold.lo @: -parameters_sm_higgs.$(FC_MODULE_EXT): parameters.SM_Higgs.lo +parameters_sm_higgs.$(FCMOD): parameters.SM_Higgs.lo @: -parameters_sm_higgs_ckm.$(FC_MODULE_EXT): parameters.SM_Higgs_CKM.lo +parameters_sm_higgs_ckm.$(FCMOD): parameters.SM_Higgs_CKM.lo @: -parameters_sm_rx.$(FC_MODULE_EXT): parameters.SM_rx.lo +parameters_sm_rx.$(FCMOD): parameters.SM_rx.lo @: -parameters_sm_ul.$(FC_MODULE_EXT): parameters.SM_ul.lo +parameters_sm_ul.$(FCMOD): parameters.SM_ul.lo @: -parameters_simplest.$(FC_MODULE_EXT): parameters.Simplest.lo +parameters_simplest.$(FCMOD): parameters.Simplest.lo @: -parameters_simplest_univ.$(FC_MODULE_EXT): parameters.Simplest_univ.lo +parameters_simplest_univ.$(FCMOD): parameters.Simplest_univ.lo @: -parameters_template.$(FC_MODULE_EXT): parameters.Template.lo +parameters_template.$(FCMOD): parameters.Template.lo @: -parameters_test.$(FC_MODULE_EXT): parameters.Test.lo +parameters_test.$(FCMOD): parameters.Test.lo @: -parameters_threeshl.$(FC_MODULE_EXT): parameters.Threeshl.lo +parameters_threeshl.$(FCMOD): parameters.Threeshl.lo @: -parameters_threeshl_nohf.$(FC_MODULE_EXT): parameters.Threeshl_nohf.lo +parameters_threeshl_nohf.$(FCMOD): parameters.Threeshl_nohf.lo @: -parameters_ued.$(FC_MODULE_EXT): parameters.UED.lo +parameters_ued.$(FCMOD): parameters.UED.lo @: -parameters_ssc.$(FC_MODULE_EXT): parameters.SSC.lo +parameters_ssc.$(FCMOD): parameters.SSC.lo @: -parameters_ssc_2.$(FC_MODULE_EXT): parameters.SSC_2.lo +parameters_ssc_2.$(FCMOD): parameters.SSC_2.lo @: -parameters_ssc_altt.$(FC_MODULE_EXT): parameters.SSC_AltT.lo +parameters_ssc_altt.$(FCMOD): parameters.SSC_AltT.lo @: -parameters_xdim.$(FC_MODULE_EXT): parameters.Xdim.lo +parameters_xdim.$(FCMOD): parameters.Xdim.lo @: -parameters_wzw.$(FC_MODULE_EXT): parameters.WZW.lo +parameters_wzw.$(FCMOD): parameters.WZW.lo @: -parameters_zprime.$(FC_MODULE_EXT): parameters.Zprime.lo +parameters_zprime.$(FCMOD): parameters.Zprime.lo @: ######################################################################## ## Dependency on O'Mega modules basicsdir = $(top_builddir)/src/basics utilitiesdir = $(top_builddir)/src/utilities systemdir = $(top_builddir)/src/system physicsdir = $(top_builddir)/src/physics combinatoricsdir = $(top_builddir)/src/combinatorics omegadir = $(top_builddir)/omega/src -KINDS_MOD = kinds.$(FC_MODULE_EXT) -CONSTANTS_MOD = constants.$(FC_MODULE_EXT) -PHYSICS_DEFS_MOD = physics_defs.$(FC_MODULE_EXT) -FORMAT_DEFS_MOD = format_defs.$(FC_MODULE_EXT) -DIAGNOSTICS_MOD = diagnostics.$(FC_MODULE_EXT) -SMPHYSICS_MOD = sm_physics.$(FC_MODULE_EXT) -SOLVER_MOD = solver.$(FC_MODULE_EXT) -OMEGAVECTORS_MOD = omega_vectors.$(FC_MODULE_EXT) -TTV_FORMFACTORS_MOD = ttv_formfactors.$(FC_MODULE_EXT) +KINDS_MOD = kinds.$(FCMOD) +CONSTANTS_MOD = constants.$(FCMOD) +PHYSICS_DEFS_MOD = physics_defs.$(FCMOD) +FORMAT_DEFS_MOD = format_defs.$(FCMOD) +DIAGNOSTICS_MOD = diagnostics.$(FCMOD) +SMPHYSICS_MOD = sm_physics.$(FCMOD) +SOLVER_MOD = solver.$(FCMOD) +OMEGAVECTORS_MOD = omega_vectors.$(FCMOD) +TTV_FORMFACTORS_MOD = ttv_formfactors.$(FCMOD) ### To be changed when moved in an external physics library $(libmodels_la_OBJECTS) $(external_SM_tt_threshold_la_OBJECTS) $(external_Threeshl_la_OBJECTS): \ $(basicsdir)/$(KINDS_MOD) \ $(basicsdir)/$(CONSTANTS_MOD) \ $(utilitiesdir)/$(FORMAT_DEFS_MOD) \ $(systemdir)/$(DIAGNOSTICS_MOD) \ $(physicsdir)/$(PHYSICS_DEFS_MOD) \ $(physicsdir)/$(SMPHYSICS_MOD) \ $(combinatoricsdir)/$(SOLVER_MOD) \ $(omegadir)/$(OMEGAVECTORS_MOD) \ ../threshold/$(TTV_FORMFACTORS_MOD) \ - threeshl_bundle/threeshl.$(FC_MODULE_EXT) \ - threeshl_bundle/tglue.$(FC_MODULE_EXT) + threeshl_bundle/threeshl.$(FCMOD) \ + threeshl_bundle/tglue.$(FCMOD) AM_FCFLAGS = -I$(basicsdir) -I$(utilitiesdir) -I$(systemdir) -I$(physicsdir) -I$(combinatoricsdir) -I$(omegadir) -I../threshold -Ithreeshl_bundle ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Threeshl and Threeshl_nohf are identical parameters.Threeshl_nohf.f90: parameters.Threeshl.f90 sed -e 's/\(module parameters_threeshl\)/\1_nohf/' < $< > $@ external.Threeshl_nohf.f90: external.Threeshl.f90 cp $< $@ ######################################################################## ## Non-standard cleanup tasks CLEANFILES = \ parameters.Threeshl_nohf.f90 \ external.Threeshl_nohf.f90 clean-local: - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-local: -rm -f *~ Index: trunk/src/fks/Makefile.am =================================================================== --- trunk/src/fks/Makefile.am (revision 8428) +++ trunk/src/fks/Makefile.am (revision 8429) @@ -1,204 +1,209 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement the FKS subtraction scheme. ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libfks.la check_LTLIBRARIES = libfks_ut.la libfks_la_SOURCES = \ fks_regions.f90 \ nlo_data.f90 \ virtual.f90 \ real_subtraction.f90 \ dglap_remnant.f90 \ dispatch_fks.f90 libfks_ut_la_SOURCES = \ fks_regions_uti.f90 fks_regions_ut.f90 \ real_subtraction_uti.f90 real_subtraction_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = fks.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libfks_la_SOURCES:.f90=.$(FCMOD)} + libfks_Modules = ${libfks_la_SOURCES:.f90=} ${libfks_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libfks_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../parsing/Modules \ ../combinatorics/Modules \ ../physics/Modules \ ../qft/Modules \ ../model_features/Modules \ ../types/Modules \ ../particles/Modules \ ../threshold/Modules \ ../matrix_elements/Modules \ ../beams/Modules \ ../me_methods/Modules \ ../phase_space/Modules \ ../variables/Modules \ ../blha/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libfks_la_SOURCES) $(libfks_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libfks_la_SOURCES) ${libfks_ut_la_SOURCES} @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../parsing -I../rng -I../combinatorics -I../physics -I../qft -I../model_features -I../expr_base -I../types -I../particles -I../matrix_elements -I../beams -I../me_methods -I../phase_space -I../variables -I../blha -I../threshold -I../lhapdf -I../pdf_builtin -I../fastjet ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw fks.stamp: $(PRELUDE) $(srcdir)/fks.nw $(POSTLUDE) @rm -f fks.tmp @touch fks.tmp for src in $(libfks_la_SOURCES) $(libfks_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f fks.tmp fks.stamp $(libfks_la_SOURCES) $(libfks_ut_la_SOURCES): fks.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f fks.stamp; \ $(MAKE) $(AM_MAKEFLAGS) fks.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f fks.stamp fks.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/main/main.nw =================================================================== --- trunk/src/main/main.nw (revision 0) +++ trunk/src/main/main.nw (revision 8429) @@ -0,0 +1,2277 @@ +% -*- ess-noweb-default-code-mode: f90-mode; noweb-default-code-mode: f90-mode; -*- +% WHIZARD main code as NOWEB source +\includemodulegraph{main} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\chapter{Main Program} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Tools for the command line} + +We do not intent to be very smart here, but this module provides a few +small tools that simplify dealing with the command line. + +The [[unquote_value]] subroutine handles an option value that begins with a +single/double quote character. It swallows extra option strings until it +finds a value that ends with another quote character. The returned string +consists of all argument strings between quotes, concatenated by blanks (with +a leading blank). Note that more complex patterns, such as quoted or embedded +quotes, or multiple blanks, are not accounted for. +<<[[cmdline_options.f90]]>>= +<> + +module cmdline_options + +<> + use diagnostics + +<> + + public :: init_options + public :: no_option_value + public :: get_option_value + +<> + + abstract interface + subroutine msg + end subroutine msg + end interface + + procedure (msg), pointer :: print_usage => null () + +contains + + subroutine init_options (usage_msg) + procedure (msg) :: usage_msg + print_usage => usage_msg + end subroutine init_options + + subroutine no_option_value (option, value) + type(string_t), intent(in) :: option, value + if (value /= "") then + call msg_error (" Option '" // char (option) // "' should have no value") + end if + end subroutine no_option_value + + function get_option_value (i, option, value) result (string) + type(string_t) :: string + integer, intent(inout) :: i + type(string_t), intent(in) :: option + type(string_t), intent(in), optional :: value + character(CMDLINE_ARG_LEN) :: arg_value + integer :: arg_len, arg_status + logical :: has_value + if (present (value)) then + has_value = value /= "" + else + has_value = .false. + end if + if (has_value) then + call unquote_value (i, option, value, string) + else + i = i + 1 + call get_command_argument (i, arg_value, arg_len, arg_status) + select case (arg_status) + case (0) + case (-1) + call msg_error (" Option value truncated: '" // arg_value // "'") + case default + call print_usage () + call msg_fatal (" Option '" // char (option) // "' needs a value") + end select + select case (arg_value(1:1)) + case ("-") + call print_usage () + call msg_fatal (" Option '" // char (option) // "' needs a value") + end select + call unquote_value (i, option, var_str (trim (arg_value)), string) + end if + end function get_option_value + + subroutine unquote_value (i, option, value, string) + integer, intent(inout) :: i + type(string_t), intent(in) :: option + type(string_t), intent(in) :: value + type(string_t), intent(out) :: string + character(1) :: quote + character(CMDLINE_ARG_LEN) :: arg_value + integer :: arg_len, arg_status + quote = extract (value, 1, 1) + select case (quote) + case ("'", '"') + string = "" + arg_value = extract (value, 2) + arg_len = len_trim (value) + APPEND_QUOTED: do + if (extract (arg_value, arg_len, arg_len) == quote) then + string = string // " " // extract (arg_value, 1, arg_len-1) + exit APPEND_QUOTED + else + string = string // " " // trim (arg_value) + i = i + 1 + call get_command_argument (i, arg_value, arg_len, arg_status) + select case (arg_status) + case (0) + case (-1) + call msg_error (" Quoted option value truncated: '" & + // char (string) // "'") + case default + call print_usage () + call msg_fatal (" Option '" // char (option) & + // "': unterminated quoted value") + end select + end if + end do APPEND_QUOTED + case default + string = value + end select + end subroutine unquote_value + +end module cmdline_options + +@ %def init_options +@ %def no_option_value +@ %def get_option_value +@ %def cmdline_options +@ +\clearpage +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Driver program} +The main program handles command options, initializes the environment, +and runs WHIZARD in a particular mode (interactive, file, standard +input). + +This is also used in the C interface: +<>= + integer, parameter :: CMDLINE_ARG_LEN = 1000 +@ %def CMDLINE_ARG_LEN +@ +The actual main program: +<<[[main.f90]]>>= +<> + +program main + +<> + use system_dependencies + use diagnostics + use ifiles + use os_interface + use rt_data, only: show_description_of_string, show_tex_descriptions + use whizard + + use cmdline_options + use features + +<> + + implicit none + +<> + +!!! (WK 02/2016) Interface for the separate external routine below + interface + subroutine print_usage () + end subroutine print_usage + end interface + +! Main program variable declarations + character(CMDLINE_ARG_LEN) :: arg + character(2) :: option + type(string_t) :: long_option, value + integer :: i, j, arg_len, arg_status + logical :: look_for_options + logical :: interactive + logical :: banner + type(string_t) :: job_id, files, this, model, default_lib, library, libraries + type(string_t) :: logfile, query_string + type(paths_t) :: paths + type(string_t) :: pack_arg, unpack_arg + type(string_t), dimension(:), allocatable :: pack_args, unpack_args + type(string_t), dimension(:), allocatable :: tmp_strings + logical :: rebuild_library + logical :: rebuild_phs, rebuild_grids, rebuild_events + logical :: recompile_library + type(ifile_t) :: commands + type(string_t) :: command, cmdfile + integer :: cmdfile_unit + logical :: cmdfile_exists + + type(whizard_options_t), allocatable :: options + type(whizard_t), allocatable, target :: whizard_instance + + ! Exit status + logical :: quit = .false. + integer :: quit_code = 0 + + ! Initial values + look_for_options = .true. + interactive = .false. + job_id = "" + files = "" + model = "SM" + default_lib = "default_lib" + library = "" + libraries = "" + banner = .true. + logging = .true. + msg_level = RESULT + logfile = "whizard.log" + rebuild_library = .false. + rebuild_phs = .false. + rebuild_grids = .false. + rebuild_events = .false. + recompile_library = .false. + call paths_init (paths) + +<> + + ! Read and process options + call init_options (print_usage) + i = 0 + SCAN_CMDLINE: do + i = i + 1 + call get_command_argument (i, arg, arg_len, arg_status) + select case (arg_status) + case (0) + case (-1) + call msg_error (" Command argument truncated: '" // arg // "'") + case default + exit SCAN_CMDLINE + end select + if (look_for_options) then + select case (arg(1:2)) + case ("--") + value = trim (arg) + call split (value, long_option, "=") + select case (char (long_option)) + case ("--version") + call no_option_value (long_option, value) + call print_version (); stop + case ("--help") + call no_option_value (long_option, value) + call print_usage (); stop + case ("--prefix") + paths%prefix = get_option_value (i, long_option, value) + cycle scan_cmdline + case ("--exec-prefix") + paths%exec_prefix = get_option_value (i, long_option, value) + cycle SCAN_CMDLINE + case ("--bindir") + paths%bindir = get_option_value (i, long_option, value) + cycle SCAN_CMDLINE + case ("--libdir") + paths%libdir = get_option_value (i, long_option, value) + cycle SCAN_CMDLINE + case ("--includedir") + paths%includedir = get_option_value (i, long_option, value) + cycle SCAN_CMDLINE + case ("--datarootdir") + paths%datarootdir = get_option_value (i, long_option, value) + cycle SCAN_CMDLINE + case ("--libtool") + paths%libtool = get_option_value (i, long_option, value) + cycle SCAN_CMDLINE + case ("--lhapdfdir") + paths%lhapdfdir = get_option_value (i, long_option, value) + cycle SCAN_CMDLINE + case ("--check") + call print_usage () + call msg_fatal ("Option --check not supported & + &(for unit tests, run whizard_ut instead)") + case ("--show-config") + call no_option_value (long_option, value) + call print_features (); stop + case ("--execute") + command = get_option_value (i, long_option, value) + call ifile_append (commands, command) + cycle SCAN_CMDLINE + case ("--file") + cmdfile = get_option_value (i, long_option, value) + inquire (file=char(cmdfile), exist=cmdfile_exists) + if (cmdfile_exists) then + open (newunit=cmdfile_unit, file=char(cmdfile), & + action="read", status="old") + call ifile_append (commands, cmdfile_unit) + close (cmdfile_unit) + else + call msg_error & + ("Sindarin file '" // char (cmdfile) // "' not found") + end if + cycle SCAN_CMDLINE + case ("--interactive") + call no_option_value (long_option, value) + interactive = .true. + cycle SCAN_CMDLINE + case ("--job-id") + job_id = get_option_value (i, long_option, value) + cycle SCAN_CMDLINE + case ("--library") + library = get_option_value (i, long_option, value) + libraries = libraries // " " // library + cycle SCAN_CMDLINE + case ("--no-library") + call no_option_value (long_option, value) + default_lib = "" + library = "" + libraries = "" + cycle SCAN_CMDLINE + case ("--localprefix") + paths%localprefix = get_option_value (i, long_option, value) + cycle SCAN_CMDLINE + case ("--logfile") + logfile = get_option_value (i, long_option, value) + cycle SCAN_CMDLINE + case ("--no-logfile") + call no_option_value (long_option, value) + logfile = "" + cycle SCAN_CMDLINE + case ("--logging") + call no_option_value (long_option, value) + logging = .true. + cycle SCAN_CMDLINE + case ("--no-logging") + call no_option_value (long_option, value) + logging = .false. + cycle SCAN_CMDLINE + case ("--query") + call no_option_value (long_option, value) + query_string = get_option_value (i, long_option, value) + call show_description_of_string (query_string) + call exit (0) + case ("--generate-variables-tex") + call no_option_value (long_option, value) + call show_tex_descriptions () + call exit (0) + case ("--debug") + call no_option_value (long_option, value) + call set_debug_levels (get_option_value (i, long_option, value)) + cycle SCAN_CMDLINE + case ("--debug2") + call no_option_value (long_option, value) + call set_debug2_levels (get_option_value (i, long_option, value)) + cycle SCAN_CMDLINE + case ("--single-event") + call no_option_value (long_option, value) + single_event = .true. + cycle SCAN_CMDLINE + case ("--banner") + call no_option_value (long_option, value) + banner = .true. + cycle SCAN_CMDLINE + case ("--no-banner") + call no_option_value (long_option, value) + banner = .false. + cycle SCAN_CMDLINE + case ("--pack") + pack_arg = get_option_value (i, long_option, value) + if (allocated (pack_args)) then + call move_alloc (from=pack_args, to=tmp_strings) + allocate (pack_args (size (tmp_strings)+1)) + pack_args(1:size(tmp_strings)) = tmp_strings + else + allocate (pack_args (1)) + end if + pack_args(size(pack_args)) = pack_arg + cycle SCAN_CMDLINE + case ("--unpack") + unpack_arg = get_option_value (i, long_option, value) + if (allocated (unpack_args)) then + call move_alloc (from=unpack_args, to=tmp_strings) + allocate (unpack_args (size (tmp_strings)+1)) + unpack_args(1:size(tmp_strings)) = tmp_strings + else + allocate (unpack_args (1)) + end if + unpack_args(size(unpack_args)) = unpack_arg + cycle SCAN_CMDLINE + case ("--model") + model = get_option_value (i, long_option, value) + cycle SCAN_CMDLINE + case ("--no-model") + call no_option_value (long_option, value) + model = "" + cycle SCAN_CMDLINE + case ("--rebuild") + call no_option_value (long_option, value) + rebuild_library = .true. + rebuild_phs = .true. + rebuild_grids = .true. + rebuild_events = .true. + cycle SCAN_CMDLINE + case ("--no-rebuild") + call no_option_value (long_option, value) + rebuild_library = .false. + recompile_library = .false. + rebuild_phs = .false. + rebuild_grids = .false. + rebuild_events = .false. + cycle SCAN_CMDLINE + case ("--rebuild-library") + call no_option_value (long_option, value) + rebuild_library = .true. + cycle SCAN_CMDLINE + case ("--rebuild-phase-space") + call no_option_value (long_option, value) + rebuild_phs = .true. + cycle SCAN_CMDLINE + case ("--rebuild-grids") + call no_option_value (long_option, value) + rebuild_grids = .true. + cycle SCAN_CMDLINE + case ("--rebuild-events") + call no_option_value (long_option, value) + rebuild_events = .true. + cycle SCAN_CMDLINE + case ("--recompile") + call no_option_value (long_option, value) + recompile_library = .true. + rebuild_grids = .true. + cycle SCAN_CMDLINE + case ("--write-syntax-tables") + call no_option_value (long_option, value) + call init_syntax_tables () + call write_syntax_tables () + call final_syntax_tables () + stop + cycle SCAN_CMDLINE + case default + call print_usage () + call msg_fatal ("Option '" // trim (arg) // "' not recognized") + end select + end select + select case (arg(1:1)) + case ("-") + j = 1 + if (len_trim (arg) == 1) then + look_for_options = .false. + else + SCAN_SHORT_OPTIONS: do + j = j + 1 + if (j > len_trim (arg)) exit SCAN_SHORT_OPTIONS + option = "-" // arg(j:j) + select case (option) + case ("-V") + call print_version (); stop + case ("-?", "-h") + call print_usage (); stop + case ("-e") + command = get_option_value (i, var_str (option)) + call ifile_append (commands, command) + cycle SCAN_CMDLINE + case ("-f") + cmdfile = get_option_value (i, var_str (option)) + inquire (file=char(cmdfile), exist=cmdfile_exists) + if (cmdfile_exists) then + open (newunit=cmdfile_unit, file=char(cmdfile), & + action="read", status="old") + call ifile_append (commands, cmdfile_unit) + close (cmdfile_unit) + else + call msg_error ("Sindarin file '" & + // char (cmdfile) // "' not found") + end if + cycle SCAN_CMDLINE + case ("-i") + interactive = .true. + cycle SCAN_SHORT_OPTIONS + case ("-J") + if (j == len_trim (arg)) then + job_id = get_option_value (i, var_str (option)) + else + job_id = trim (arg(j+1:)) + end if + cycle SCAN_CMDLINE + case ("-l") + if (j == len_trim (arg)) then + library = get_option_value (i, var_str (option)) + else + library = trim (arg(j+1:)) + end if + libraries = libraries // " " // library + cycle SCAN_CMDLINE + case ("-L") + if (j == len_trim (arg)) then + logfile = get_option_value (i, var_str (option)) + else + logfile = trim (arg(j+1:)) + end if + cycle SCAN_CMDLINE + case ("-m") + if (j < len_trim (arg)) call msg_fatal & + ("Option '" // option // "' needs a value") + model = get_option_value (i, var_str (option)) + cycle SCAN_CMDLINE + case ("-q") + call no_option_value (long_option, value) + query_string = get_option_value (i, long_option, value) + call show_description_of_string (query_string) + call exit (0) + case ("-r") + rebuild_library = .true. + rebuild_phs = .true. + rebuild_grids = .true. + rebuild_events = .true. + cycle SCAN_SHORT_OPTIONS + case default + call print_usage () + call msg_fatal & + ("Option '" // option // "' not recognized") + end select + end do SCAN_SHORT_OPTIONS + end if + case default + files = files // " " // trim (arg) + end select + else + files = files // " " // trim (arg) + end if + end do SCAN_CMDLINE + + ! Overall initialization + if (logfile /= "") call logfile_init (logfile) + if (banner) call msg_banner () + + allocate (options) + allocate (whizard_instance) + + if (.not. quit) then + + ! Set options and initialize the whizard object + options%job_id = job_id + if (allocated (pack_args)) then + options%pack_args = pack_args + else + allocate (options%pack_args (0)) + end if + if (allocated (unpack_args)) then + options%unpack_args = unpack_args + else + allocate (options%unpack_args (0)) + end if + options%preload_model = model + options%default_lib = default_lib + options%preload_libraries = libraries + options%rebuild_library = rebuild_library + options%recompile_library = recompile_library + options%rebuild_phs = rebuild_phs + options%rebuild_grids = rebuild_grids + options%rebuild_events = rebuild_events + <> + + call whizard_instance%init (options, paths, logfile) + + call mask_term_signals () + + end if + + ! Run commands given on the command line + if (.not. quit .and. ifile_get_length (commands) > 0) then + call whizard_instance%process_ifile (commands, quit, quit_code) + end if + + if (.not. quit) then + ! Process commands from standard input + if (.not. interactive .and. files == "") then + call whizard_instance%process_stdin (quit, quit_code) + + ! ... or process commands from file + else + files = trim (adjustl (files)) + SCAN_FILES: do while (files /= "") + call split (files, this, " ") + call whizard_instance%process_file (this, quit, quit_code) + if (quit) exit SCAN_FILES + end do SCAN_FILES + + end if + end if + + ! Enter an interactive shell if requested + if (.not. quit .and. interactive) then + call whizard_instance%shell (quit_code) + end if + + ! Overall finalization + call ifile_final (commands) + + deallocate (options) + + call whizard_instance%final () + deallocate (whizard_instance) + +<> + + call terminate_now_if_signal () + call release_term_signals () + call msg_terminate (quit_code = quit_code) + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +contains + + subroutine print_version () + print "(A)", "WHIZARD " // WHIZARD_VERSION + print "(A)", "Copyright (C) 1999-2020 Wolfgang Kilian, Thorsten Ohl, Juergen Reuter" + print "(A)", " --------------------------------------- " + print "(A)", "This is free software; see the source for copying conditions. There is NO" + print "(A)", "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + print * + end subroutine print_version + +end program main + +!!! (WK 02/2016) +!!! Separate subroutine, because this becomes a procedure pointer target +!!! Internal procedures as targets are not supported by some compilers. + + subroutine print_usage () + use system_dependencies, only: WHIZARD_VERSION + print "(A)", "WHIZARD " // WHIZARD_VERSION + print "(A)", "Usage: whizard [OPTIONS] [FILE]" + print "(A)", "Run WHIZARD with the command list taken from FILE(s)" + print "(A)", "Options for resetting default directories and tools" & + // "(GNU naming conventions):" + print "(A)", " --prefix DIR" + print "(A)", " --exec-prefix DIR" + print "(A)", " --bindir DIR" + print "(A)", " --libdir DIR" + print "(A)", " --includedir DIR" + print "(A)", " --datarootdir DIR" + print "(A)", " --libtool LOCAL_LIBTOOL" + print "(A)", " --lhapdfdir DIR (PDF sets directory)" + print "(A)", "Other options:" + print "(A)", "-h, --help display this help and exit" + print "(A)", " --banner display banner at startup (default)" + print "(A)", " --debug AREA switch on debug output for AREA." + print "(A)", " AREA can be one of Whizard's src dirs or 'all'" + print "(A)", " --debug2 AREA switch on more verbose debug output for AREA." + print "(A)", " --single-event only compute one phase-space point (for debugging)" + print "(A)", "-e, --execute CMDS execute SINDARIN CMDS before reading FILE(s)" + print "(A)", "-f, --file CMDFILE execute SINDARIN from CMDFILE before reading FILE(s)" + print "(A)", "-i, --interactive run interactively after reading FILE(s)" + print "(A)", "-J, --job-id STRING set job ID to STRING (default: empty)" + print "(A)", "-l, --library LIB preload process library NAME" + print "(A)", " --localprefix DIR" + print "(A)", " search in DIR for local models (default: ~/.whizard)" + print "(A)", "-L, --logfile FILE write log to FILE (default: 'whizard.log'" + print "(A)", " --logging switch on logging at startup (default)" + print "(A)", "-m, --model NAME preload model NAME (default: 'SM')" + print "(A)", " --no-banner do not display banner at startup" + print "(A)", " --no-library do not preload process library" + print "(A)", " --no-logfile do not write a logfile" + print "(A)", " --no-logging switch off logging at startup" + print "(A)", " --no-model do not preload a model" + print "(A)", " --no-rebuild do not force rebuilding" + print "(A)", " --pack DIR tar/gzip DIR after job" + print "(A)", "-q, --query VARIABLE display documentation of VARIABLE" + print "(A)", "-r, --rebuild rebuild all (see below)" + print "(A)", " --rebuild-library" + print "(A)", " rebuild process code library" + print "(A)", " --rebuild-phase-space" + print "(A)", " rebuild phase-space configuration" + print "(A)", " --rebuild-grids rebuild integration grids" + print "(A)", " --rebuild-events rebuild event samples" + print "(A)", " --recompile recompile process code" + print "(A)", " --show-config show build-time configuration" + print "(A)", " --unpack FILE untar/gunzip FILE before job" + print "(A)", "-V, --version output version information and exit" + print "(A)", " --write-syntax-tables" + print "(A)", " write the internal syntax tables to files and exit" + print "(A)", "- further options are taken as filenames" + print * + print "(A)", "With no FILE, read standard input." + end subroutine print_usage + +@ %def main +@ +\clearpage +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Driver program for the unit tests} +This is a variant of the above main program that takes unit-test names +as command-line options and runs those tests. +<<[[main_ut.f90]]>>= +<> + +program main_ut + +<> + use unit_tests + use io_units + use system_dependencies + use diagnostics + use os_interface + + use cmdline_options + + use model_testbed !NODEP! +<> + +<> + + implicit none + +<> + +!!! (WK 02/2016) Interface for the separate external routine below + interface + subroutine print_usage () + end subroutine print_usage + end interface + + ! Main program variable declarations + character(CMDLINE_ARG_LEN) :: arg + character(2) :: option + type(string_t) :: long_option, value + integer :: i, j, arg_len, arg_status + logical :: look_for_options + logical :: banner + type(string_t) :: check, checks + type(test_results_t) :: test_results + logical :: success + + ! Exit status + integer :: quit_code = 0 + + ! Initial values + look_for_options = .true. + banner = .true. + logging = .false. + msg_level = RESULT + check = "" + checks = "" + +<> + + ! Read and process options + call init_options (print_usage) + i = 0 + SCAN_CMDLINE: do + i = i + 1 + call get_command_argument (i, arg, arg_len, arg_status) + select case (arg_status) + case (0) + case (-1) + call msg_error (" Command argument truncated: '" // arg // "'") + case default + exit SCAN_CMDLINE + end select + if (look_for_options) then + select case (arg(1:2)) + case ("--") + value = trim (arg) + call split (value, long_option, "=") + select case (char (long_option)) + case ("--version") + call no_option_value (long_option, value) + call print_version (); stop + case ("--help") + call no_option_value (long_option, value) + call print_usage (); stop + case ("--banner") + call no_option_value (long_option, value) + banner = .true. + cycle SCAN_CMDLINE + case ("--no-banner") + call no_option_value (long_option, value) + banner = .false. + cycle SCAN_CMDLINE + case ("--check") + check = get_option_value (i, long_option, value) + checks = checks // " " // check + cycle SCAN_CMDLINE + case ("--debug") + call no_option_value (long_option, value) + call set_debug_levels (get_option_value (i, long_option, value)) + cycle SCAN_CMDLINE + case ("--debug2") + call no_option_value (long_option, value) + call set_debug2_levels (get_option_value (i, long_option, value)) + cycle SCAN_CMDLINE + case default + call print_usage () + call msg_fatal ("Option '" // trim (arg) // "' not recognized") + end select + end select + select case (arg(1:1)) + case ("-") + j = 1 + if (len_trim (arg) == 1) then + look_for_options = .false. + else + SCAN_SHORT_OPTIONS: do + j = j + 1 + if (j > len_trim (arg)) exit SCAN_SHORT_OPTIONS + option = "-" // arg(j:j) + select case (option) + case ("-V") + call print_version (); stop + case ("-?", "-h") + call print_usage (); stop + case default + call print_usage () + call msg_fatal & + ("Option '" // option // "' not recognized") + end select + end do SCAN_SHORT_OPTIONS + end if + case default + call print_usage () + call msg_fatal ("Option '" // trim (arg) // "' not recognized") + end select + else + call print_usage () + call msg_fatal ("Option '" // trim (arg) // "' not recognized") + end if + end do SCAN_CMDLINE + + ! Overall initialization + if (banner) call msg_banner () + + ! Run any self-checks (and no commands) + if (checks /= "") then + checks = trim (adjustl (checks)) + RUN_CHECKS: do while (checks /= "") + call split (checks, check, " ") + call whizard_check (check, test_results) + end do RUN_CHECKS + call test_results%wrapup (6, success) + if (.not. success) quit_code = 7 + end if + + <> + + call msg_terminate (quit_code = quit_code) + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +contains + + subroutine print_version () + print "(A)", "WHIZARD " // WHIZARD_VERSION // " (unit test driver)" + print "(A)", "Copyright (C) 1999-2020 Wolfgang Kilian, Thorsten Ohl, Juergen Reuter" + print "(A)", " --------------------------------------- " + print "(A)", "This is free software; see the source for copying conditions. There is NO" + print "(A)", "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + print * + end subroutine print_version + +<> + +end program main_ut + +!!! (WK 02/2016) +!!! Separate subroutine, because this becomes a procedure pointer target +!!! Internal procedures as targets are not supported by some compilers. + + subroutine print_usage () + use system_dependencies, only: WHIZARD_VERSION + print "(A)", "WHIZARD " // WHIZARD_VERSION // " (unit test driver)" + print "(A)", "Usage: whizard_ut [OPTIONS] [FILE]" + print "(A)", "Run WHIZARD unit tests as given on the command line" + print "(A)", "Options:" + print "(A)", "-h, --help display this help and exit" + print "(A)", " --banner display banner at startup (default)" + print "(A)", " --no-banner do not display banner at startup" + print "(A)", " --debug AREA switch on debug output for AREA." + print "(A)", " AREA can be one of Whizard's src dirs or 'all'" + print "(A)", " --debug2 AREA switch on more verbose debug output for AREA." + print "(A)", "-V, --version output version information and exit" + print "(A)", " --check TEST run unit test TEST" + end subroutine print_usage +@ %def main_ut +@ +<>= +@ +<>= +@ +@ MPI init. +<>= + call MPI_init () +<>= + call MPI_finalize () +@ %def MPI_init MPI_finalize +<>= +@ +Every rebuild action is forbidden for the slave workers except +[[rebuild_grids]], which is handled correctly inside the corresponding +integration object. +<>= + if (.not. mpi_is_comm_master ()) then + options%rebuild_library = .false. + options%recompile_library = .false. + options%rebuild_phs = .false. + options%rebuild_events = .false. + end if +@ +\subsection{Self-tests} +For those self-tests, we need some auxiliary routines that provide an +enviroment. The environment depends on things that are not available at the +level of the module that we want to test. + +\subsubsection{Testbed for event I/O} +This subroutine prepares a test process with a single event. All objects are +allocated via anonymous pointers, because we want to recover the pointers and +delete the objects in a separate procedure. +<>= + subroutine prepare_eio_test (event, unweighted, n_alt, sample_norm) + use variables, only: var_list_t + use model_data + use process, only: process_t + use instances, only: process_instance_t + use processes_ut, only: prepare_test_process + use event_base + use events + + class(generic_event_t), intent(inout), pointer :: event + logical, intent(in), optional :: unweighted + integer, intent(in), optional :: n_alt + type(string_t), intent(in), optional :: sample_norm + type(model_data_t), pointer :: model + type(var_list_t) :: var_list + type(string_t) :: sample_normalization + type(process_t), pointer :: proc + type(process_instance_t), pointer :: process_instance + + allocate (model) + call model%init_test () + + allocate (proc) + allocate (process_instance) + + call prepare_test_process (proc, process_instance, model, & + run_id = var_str ("run_test")) + call process_instance%setup_event_data () + + call model%final () + deallocate (model) + + allocate (event_t :: event) + select type (event) + type is (event_t) + if (present (unweighted)) then + call var_list%append_log (& + var_str ("?unweighted"), unweighted, & + intrinsic = .true.) + else + call var_list%append_log (& + var_str ("?unweighted"), .true., & + intrinsic = .true.) + end if + if (present (sample_norm)) then + sample_normalization = sample_norm + else + sample_normalization = var_str ("auto") + end if + call var_list%append_string (& + var_str ("$sample_normalization"), & + sample_normalization, intrinsic = .true.) + call event%basic_init (var_list, n_alt) + call event%connect (process_instance, proc%get_model_ptr ()) + call var_list%final () + end select + + end subroutine prepare_eio_test + +@ %def prepare_eio_test +@ Recover those pointers, finalize the objects and deallocate. +<>= + subroutine cleanup_eio_test (event) + use model_data + use process, only: process_t + use instances, only: process_instance_t + use processes_ut, only: cleanup_test_process + use event_base + use events + + class(generic_event_t), intent(inout), pointer :: event + type(process_t), pointer :: proc + type(process_instance_t), pointer :: process_instance + + select type (event) + type is (event_t) + proc => event%get_process_ptr () + process_instance => event%get_process_instance_ptr () + call cleanup_test_process (proc, process_instance) + deallocate (process_instance) + deallocate (proc) + call event%final () + end select + deallocate (event) + + end subroutine cleanup_eio_test + +@ %def cleanup_eio_test_event +@ Assign those procedures to appropriate pointers (module variables) in the +[[eio_base]] module, so they can be called as if they were module procedures. +<>= + use eio_base_ut, only: eio_prepare_test + use eio_base_ut, only: eio_cleanup_test +<>= + eio_prepare_test => prepare_eio_test + eio_cleanup_test => cleanup_eio_test +@ +\subsubsection{Any Model} +This procedure reads any model from file and, optionally, assigns a +var-list pointer. If the model pointer is still null, we allocate the model +object first, with concrete type [[model_t]]. This is a service for modules +which do just have access to the [[model_data_t]] base type. +<>= + subroutine prepare_whizard_model (model, name, vars) + <> + use os_interface + use model_data + use var_base + use models + class(model_data_t), intent(inout), pointer :: model + type(string_t), intent(in) :: name + class(vars_t), pointer, intent(out), optional :: vars + type(os_data_t) :: os_data + call syntax_model_file_init () + call os_data%init () + if (.not. associated (model)) allocate (model_t :: model) + select type (model) + type is (model_t) + call model%read (name // ".mdl", os_data) + if (present (vars)) then + vars => model%get_var_list_ptr () + end if + end select + end subroutine prepare_whizard_model + +@ %def prepare_whizard_model +@ Cleanup after use. Includes deletion of the model-file syntax. +<>= + subroutine cleanup_whizard_model (model) + use model_data + use models + class(model_data_t), intent(inout), target :: model + call model%final () + call syntax_model_file_final () + end subroutine cleanup_whizard_model + +@ %def cleanup_whizard_model +@ Assign those procedures to appropriate pointers (module variables) in the +[[model_testbed]] module, so they can be called as if they were module +procedures. +<>= + prepare_model => prepare_whizard_model + cleanup_model => cleanup_whizard_model +@ +\subsubsection{Fallback model: hadrons} +Some event format tests require the hadronic SM implementation, which +has to be read from file. We provide the functionality here, so the +tests do not depend on model I/O. +<>= + subroutine prepare_fallback_model (model) + use model_data + class(model_data_t), intent(inout), pointer :: model + call prepare_whizard_model (model, var_str ("SM_hadrons")) + end subroutine prepare_fallback_model + +@ %def prepare_fallback_model +@ Assign those procedures to appropriate pointers (module variables) in the +[[eio_base]] module, so they can be called as if they were module procedures. +<>= + use eio_base_ut, only: eio_prepare_fallback_model + use eio_base_ut, only: eio_cleanup_fallback_model +<>= + eio_prepare_fallback_model => prepare_fallback_model + eio_cleanup_fallback_model => cleanup_model +@ +\subsubsection{Access to the test random-number generator} +This generator is not normally available for the dispatcher. We assign an +additional dispatch routine to the hook in the [[dispatch]] module +which will be checked before the default rule. +<>= + use dispatch_rng, only: dispatch_rng_factory_fallback + use dispatch_rng_ut, only: dispatch_rng_factory_test +<>= + dispatch_rng_factory_fallback => dispatch_rng_factory_test +@ +\subsubsection{Access to the test structure functions} +These are not normally available for the dispatcher. We assign an +additional dispatch routine to the hook in the [[dispatch]] module +which will be checked before the default rule. +<>= + use dispatch_beams, only: dispatch_sf_data_extra + use dispatch_ut, only: dispatch_sf_data_test +<>= + dispatch_sf_data_extra => dispatch_sf_data_test +@ +\subsubsection{Procedure for Checking} +This is for developers only, but needs a well-defined interface. +<>= + subroutine whizard_check (check, results) + type(string_t), intent(in) :: check + type(test_results_t), intent(inout) :: results + type(os_data_t) :: os_data + integer :: u + call os_data%init () + u = free_unit () + open (u, file="whizard_check." // char (check) // ".log", & + action="write", status="replace") + call msg_message (repeat ('=', 76), 0) + call msg_message ("Running self-test: " // char (check), 0) + call msg_message (repeat ('-', 76), 0) + <> + select case (char (check)) + <> + case ("all") + <> + case default + call msg_fatal ("Self-test '" // char (check) // "' not implemented.") + end select + close (u) + end subroutine whizard_check + +@ %def whizard_check +@ +\subsection{Unit test references} +\subsubsection{Formats} +<>= + use formats_ut, only: format_test +<>= + case ("formats") + call format_test (u, results) +<>= + call format_test (u, results) +@ +\subsubsection{MD5} +<>= + use md5_ut, only: md5_test +<>= + case ("md5") + call md5_test (u, results) +<>= + call md5_test (u, results) +@ +\subsubsection{OS Interface} +<>= + use os_interface_ut, only: os_interface_test +<>= + case ("os_interface") + call os_interface_test (u, results) +<>= + call os_interface_test (u, results) +@ +\subsubsection{Sorting} +<>= + use sorting_ut, only: sorting_test +<>= + case ("sorting") + call sorting_test (u, results) +<>= + call sorting_test (u, results) +@ +\subsubsection{Grids} +<>= + use grids_ut, only: grids_test +<>= + case ("grids") + call grids_test (u, results) +<>= + call grids_test (u, results) +@ +\subsubsection{Solver} +<>= + use solver_ut, only: solver_test +<>= + case ("solver") + call solver_test (u, results) +<>= + call solver_test (u, results) +@ +\subsubsection{CPU Time} +<>= + use cputime_ut, only: cputime_test +<>= + case ("cputime") + call cputime_test (u, results) +<>= + call cputime_test (u, results) +@ +\subsubsection{SM QCD} +<>= + use sm_qcd_ut, only: sm_qcd_test +<>= + case ("sm_qcd") + call sm_qcd_test (u, results) +<>= + call sm_qcd_test (u, results) +@ +\subsubsection{SM physics} +<>= + use sm_physics_ut, only: sm_physics_test +<>= + case ("sm_physics") + call sm_physics_test (u, results) +<>= + call sm_physics_test (u, results) +@ +\subsubsection{Lexers} +<>= + use lexers_ut, only: lexer_test +<>= + case ("lexers") + call lexer_test (u, results) +<>= + call lexer_test (u, results) +@ +\subsubsection{Parser} +<>= + use parser_ut, only: parse_test +<>= + case ("parser") + call parse_test (u, results) +<>= + call parse_test (u, results) +@ +\subsubsection{XML} +<>= + use xml_ut, only: xml_test +<>= + case ("xml") + call xml_test (u, results) +<>= + call xml_test (u, results) +@ +\subsubsection{Colors} +<>= + use colors_ut, only: color_test +<>= + case ("colors") + call color_test (u, results) +<>= + call color_test (u, results) +@ +\subsubsection{State matrices} +<>= + use state_matrices_ut, only: state_matrix_test +<>= + case ("state_matrices") + call state_matrix_test (u, results) +<>= + call state_matrix_test (u, results) +@ +\subsubsection{Analysis} +<>= + use analysis_ut, only: analysis_test +<>= + case ("analysis") + call analysis_test (u, results) +<>= + call analysis_test (u, results) +@ +\subsubsection{Particles} +<>= + use particles_ut, only: particles_test +<>= + case ("particles") + call particles_test (u, results) +<>= + call particles_test (u, results) +@ +\subsubsection{Models} +<>= + use models_ut, only: models_test +<>= + case ("models") + call models_test (u, results) +<>= + call models_test (u, results) +@ +\subsubsection{Auto Components} +<>= + use auto_components_ut, only: auto_components_test +<>= + case ("auto_components") + call auto_components_test (u, results) +<>= + call auto_components_test (u, results) +@ +\subsubsection{Radiation Generator} +<>= + use radiation_generator_ut, only: radiation_generator_test +<>= + case ("radiation_generator") + call radiation_generator_test (u, results) +<>= + call radiation_generator_test (u, results) +@ +\subsection{BLHA} +<>= + use blha_ut, only: blha_test +<>= + case ("blha") + call blha_test (u, results) +<>= + call blha_test (u, results) +@ +\subsubsection{Evaluators} +<>= + use evaluators_ut, only: evaluator_test +<>= + case ("evaluators") + call evaluator_test (u, results) +<>= + call evaluator_test (u, results) +@ +\subsubsection{Expressions} +<>= + use eval_trees_ut, only: expressions_test +<>= + case ("expressions") + call expressions_test (u, results) +<>= + call expressions_test (u, results) +@ +\subsubsection{Resonances} +<>= + use resonances_ut, only: resonances_test +<>= + case ("resonances") + call resonances_test (u, results) +<>= + call resonances_test (u, results) +@ +\subsubsection{PHS Trees} +<>= + use phs_trees_ut, only: phs_trees_test +<>= + case ("phs_trees") + call phs_trees_test (u, results) +<>= + call phs_trees_test (u, results) +@ +\subsubsection{PHS Forests} +<>= + use phs_forests_ut, only: phs_forests_test +<>= + case ("phs_forests") + call phs_forests_test (u, results) +<>= + call phs_forests_test (u, results) +@ +\subsubsection{Beams} +<>= + use beams_ut, only: beams_test +<>= + case ("beams") + call beams_test (u, results) +<>= + call beams_test (u, results) +@ +\subsubsection{$su(N)$ Algebra} +<>= + use su_algebra_ut, only: su_algebra_test +<>= + case ("su_algebra") + call su_algebra_test (u, results) +<>= + call su_algebra_test (u, results) +@ +\subsubsection{Bloch Vectors} +<>= + use bloch_vectors_ut, only: bloch_vectors_test +<>= + case ("bloch_vectors") + call bloch_vectors_test (u, results) +<>= + call bloch_vectors_test (u, results) +@ +\subsubsection{Polarizations} +<>= + use polarizations_ut, only: polarizations_test +<>= + case ("polarizations") + call polarizations_test (u, results) +<>= + call polarizations_test (u, results) +@ +\subsubsection{SF Aux} +<>= + use sf_aux_ut, only: sf_aux_test +<>= + case ("sf_aux") + call sf_aux_test (u, results) +<>= + call sf_aux_test (u, results) +@ +\subsubsection{SF Mappings} +<>= + use sf_mappings_ut, only: sf_mappings_test +<>= + case ("sf_mappings") + call sf_mappings_test (u, results) +<>= + call sf_mappings_test (u, results) +@ +\subsubsection{SF Base} +<>= + use sf_base_ut, only: sf_base_test +<>= + case ("sf_base") + call sf_base_test (u, results) +<>= + call sf_base_test (u, results) +@ +\subsubsection{SF PDF Builtin} +<>= + use sf_pdf_builtin_ut, only: sf_pdf_builtin_test +<>= + case ("sf_pdf_builtin") + call sf_pdf_builtin_test (u, results) +<>= + call sf_pdf_builtin_test (u, results) +@ +\subsubsection{SF LHAPDF} +<>= + use sf_lhapdf_ut, only: sf_lhapdf_test +<>= + case ("sf_lhapdf") + call sf_lhapdf_test (u, results) +<>= + call sf_lhapdf_test (u, results) +@ +\subsubsection{SF ISR} +<>= + use sf_isr_ut, only: sf_isr_test +<>= + case ("sf_isr") + call sf_isr_test (u, results) +<>= + call sf_isr_test (u, results) +@ +\subsubsection{SF EPA} +<>= + use sf_epa_ut, only: sf_epa_test +<>= + case ("sf_epa") + call sf_epa_test (u, results) +<>= + call sf_epa_test (u, results) +@ +\subsubsection{SF EWA} +<>= + use sf_ewa_ut, only: sf_ewa_test +<>= + case ("sf_ewa") + call sf_ewa_test (u, results) +<>= + call sf_ewa_test (u, results) +@ +\subsubsection{SF CIRCE1} +<>= + use sf_circe1_ut, only: sf_circe1_test +<>= + case ("sf_circe1") + call sf_circe1_test (u, results) +<>= + call sf_circe1_test (u, results) +@ +\subsubsection{SF CIRCE2} +<>= + use sf_circe2_ut, only: sf_circe2_test +<>= + case ("sf_circe2") + call sf_circe2_test (u, results) +<>= + call sf_circe2_test (u, results) +@ +\subsubsection{SF Gaussian} +<>= + use sf_gaussian_ut, only: sf_gaussian_test +<>= + case ("sf_gaussian") + call sf_gaussian_test (u, results) +<>= + call sf_gaussian_test (u, results) +@ +\subsubsection{SF Beam Events} +<>= + use sf_beam_events_ut, only: sf_beam_events_test +<>= + case ("sf_beam_events") + call sf_beam_events_test (u, results) +<>= + call sf_beam_events_test (u, results) +@ +\subsubsection{SF EScan} +<>= + use sf_escan_ut, only: sf_escan_test +<>= + case ("sf_escan") + call sf_escan_test (u, results) +<>= + call sf_escan_test (u, results) +@ +\subsubsection{PHS Base} +<>= + use phs_base_ut, only: phs_base_test +<>= + case ("phs_base") + call phs_base_test (u, results) +<>= + call phs_base_test (u, results) +@ +\subsubsection{PHS None} +<>= + use phs_none_ut, only: phs_none_test +<>= + case ("phs_none") + call phs_none_test (u, results) +<>= + call phs_none_test (u, results) +@ +\subsubsection{PHS Single} +<>= + use phs_single_ut, only: phs_single_test +<>= + case ("phs_single") + call phs_single_test (u, results) +<>= + call phs_single_test (u, results) +@ +\subsubsection{PHS Rambo} +<>= + use phs_rambo_ut, only: phs_rambo_test +<>= + case ("phs_rambo") + call phs_rambo_test (u, results) +<>= + call phs_rambo_test (u, results) +@ +\subsubsection{PHS Wood} +<>= + use phs_wood_ut, only: phs_wood_test + use phs_wood_ut, only: phs_wood_vis_test +<>= + case ("phs_wood") + call phs_wood_test (u, results) + case ("phs_wood_vis") + call phs_wood_vis_test (u, results) +<>= + call phs_wood_test (u, results) + call phs_wood_vis_test (u, results) +@ +\subsubsection{PHS FKS Generator} +<>= + use phs_fks_ut, only: phs_fks_generator_test +<>= + case ("phs_fks_generator") + call phs_fks_generator_test (u, results) +<>= + call phs_fks_generator_test (u, results) +@ +\subsubsection{FKS regions} +<>= + use fks_regions_ut, only: fks_regions_test +<>= + case ("fks_regions") + call fks_regions_test (u, results) +<>= + call fks_regions_test (u, results) +@ +\subsubsection{Real subtraction} +<>= + use real_subtraction_ut, only: real_subtraction_test +<>= + case ("real_subtraction") + call real_subtraction_test (u, results) +<>= + call real_subtraction_test (u, results) +@ +\subsubsection{RECOLA} +<>= + use prc_recola_ut, only: prc_recola_test +<>= + case ("prc_recola") + call prc_recola_test (u, results) +<>= + call prc_recola_test (u, results) +@ +\subsubsection{RNG Base} +<>= + use rng_base_ut, only: rng_base_test +<>= + case ("rng_base") + call rng_base_test (u, results) +<>= + call rng_base_test (u, results) +@ +\subsubsection{RNG Tao} +<>= + use rng_tao_ut, only: rng_tao_test +<>= + case ("rng_tao") + call rng_tao_test (u, results) +<>= + call rng_tao_test (u, results) +@ +\subsubsection{RNG Stream} +<>= + use rng_stream_ut, only: rng_stream_test +<>= + case ("rng_stream") + call rng_stream_test (u, results) +<>= + call rng_stream_test (u, results) +@ +\subsubsection{Selectors} +<>= + use selectors_ut, only: selectors_test +<>= + case ("selectors") + call selectors_test (u, results) +<>= + call selectors_test (u, results) +@ +\subsubsection{VEGAS} +<>= + use vegas_ut, only: vegas_test +<>= + case ("vegas") + call vegas_test (u, results) +<>= + call vegas_test (u, results) +@ +\subsubsection{VAMP2} +<>= + use vamp2_ut, only: vamp2_test +<>= + case ("vamp2") + call vamp2_test (u, results) +<>= + call vamp2_test (u, results) +@ +\subsubsection{MCI Base} +<>= + use mci_base_ut, only: mci_base_test +<>= + case ("mci_base") + call mci_base_test (u, results) +<>= + call mci_base_test (u, results) +@ +\subsubsection{MCI None} +<>= + use mci_none_ut, only: mci_none_test +<>= + case ("mci_none") + call mci_none_test (u, results) +<>= + call mci_none_test (u, results) +@ +\subsubsection{MCI Midpoint} +<>= + use mci_midpoint_ut, only: mci_midpoint_test +<>= + case ("mci_midpoint") + call mci_midpoint_test (u, results) +<>= + call mci_midpoint_test (u, results) +@ +\subsubsection{MCI VAMP} +<>= + use mci_vamp_ut, only: mci_vamp_test +<>= + case ("mci_vamp") + call mci_vamp_test (u, results) +<>= + call mci_vamp_test (u, results) +@ +\subsubsection{MCI VAMP2} +<>= + use mci_vamp2_ut, only: mci_vamp2_test +<>= + case ("mci_vamp2") + call mci_vamp2_test (u, results) +<>= + call mci_vamp2_test (u, results) +@ +\subsubsection{Integration Results} +<>= + use integration_results_ut, only: integration_results_test +<>= + case ("integration_results") + call integration_results_test (u, results) +<>= + call integration_results_test (u, results) +@ +\subsubsection{PRCLib Interfaces} +<>= + use prclib_interfaces_ut, only: prclib_interfaces_test +<>= + case ("prclib_interfaces") + call prclib_interfaces_test (u, results) +<>= + call prclib_interfaces_test (u, results) +@ +\subsubsection{Particle Specifiers} +<>= + use particle_specifiers_ut, only: particle_specifiers_test +<>= + case ("particle_specifiers") + call particle_specifiers_test (u, results) +<>= + call particle_specifiers_test (u, results) +@ +\subsubsection{Process Libraries} +<>= + use process_libraries_ut, only: process_libraries_test +<>= + case ("process_libraries") + call process_libraries_test (u, results) +<>= + call process_libraries_test (u, results) +@ +\subsubsection{PRCLib Stacks} +<>= + use prclib_stacks_ut, only: prclib_stacks_test +<>= + case ("prclib_stacks") + call prclib_stacks_test (u, results) +<>= + call prclib_stacks_test (u, results) +@ +\subsubsection{HepMC} +<>= + use hepmc_interface_ut, only: hepmc_interface_test +<>= + case ("hepmc") + call hepmc_interface_test (u, results) +<>= + call hepmc_interface_test (u, results) +@ +\subsubsection{LCIO} +<>= + use lcio_interface_ut, only: lcio_interface_test +<>= + case ("lcio") + call lcio_interface_test (u, results) +<>= + call lcio_interface_test (u, results) +@ +\subsubsection{Jets} +<>= + use jets_ut, only: jets_test +<>= + case ("jets") + call jets_test (u, results) +<>= + call jets_test (u, results) +@ +\subsection{LHA User Process WHIZARD} +<>= + use whizard_lha_ut, only: whizard_lha_test +<>= + case ("whizard_lha") + call whizard_lha_test (u, results) +<>= + call whizard_lha_test (u, results) +@ +\subsection{Pythia8} +<>= + use pythia8_ut, only: pythia8_test +<>= + case ("pythia8") + call pythia8_test (u, results) +<>= + call pythia8_test (u, results) +@ +\subsubsection{PDG Arrays} +<>= + use pdg_arrays_ut, only: pdg_arrays_test +<>= + case ("pdg_arrays") + call pdg_arrays_test (u, results) +<>= + call pdg_arrays_test (u, results) +@ +\subsubsection{interactions} +<>= + use interactions_ut, only: interaction_test +<>= + case ("interactions") + call interaction_test (u, results) +<>= + call interaction_test (u, results) +@ +\subsubsection{SLHA} +<>= + use slha_interface_ut, only: slha_test +<>= + case ("slha_interface") + call slha_test (u, results) +<>= + call slha_test (u, results) +@ +\subsubsection{Cascades} +<>= + use cascades_ut, only: cascades_test +<>= + case ("cascades") + call cascades_test (u, results) +<>= + call cascades_test (u, results) +@ +\subsubsection{Cascades2 lexer} +<>= + use cascades2_lexer_ut, only: cascades2_lexer_test +<>= + case ("cascades2_lexer") + call cascades2_lexer_test (u, results) +<>= + call cascades2_lexer_test (u, results) +@ +\subsubsection{Cascades2} +<>= + use cascades2_ut, only: cascades2_test +<>= + case ("cascades2") + call cascades2_test (u, results) +<>= + call cascades2_test (u, results) +@ +\subsubsection{PRC Test} +<>= + use prc_test_ut, only: prc_test_test +<>= + case ("prc_test") + call prc_test_test (u, results) +<>= + call prc_test_test (u, results) +@ +\subsubsection{PRC Template ME} +<>= + use prc_template_me_ut, only: prc_template_me_test +<>= + case ("prc_template_me") + call prc_template_me_test (u, results) +<>= + call prc_template_me_test (u, results) +@ +\subsubsection{PRC OMega} +<>= + use prc_omega_ut, only: prc_omega_test + use prc_omega_ut, only: prc_omega_diags_test +<>= + case ("prc_omega") + call prc_omega_test (u, results) + case ("prc_omega_diags") + call prc_omega_diags_test (u, results) +<>= + call prc_omega_test (u, results) + call prc_omega_diags_test (u, results) +@ +\subsubsection{Parton States} +<>= + use parton_states_ut, only: parton_states_test +<>= + case ("parton_states") + call parton_states_test (u, results) +<>= + call parton_states_test (u, results) +@ +\subsubsection{Subevt Expr} +<>= + use expr_tests_ut, only: subevt_expr_test +<>= + case ("subevt_expr") + call subevt_expr_test (u, results) +<>= + call subevt_expr_test (u, results) +@ +\subsubsection{Processes} +<>= + use processes_ut, only: processes_test +<>= + case ("processes") + call processes_test (u, results) +<>= + call processes_test (u, results) +@ +\subsubsection{Process Stacks} +<>= + use process_stacks_ut, only: process_stacks_test +<>= + case ("process_stacks") + call process_stacks_test (u, results) +<>= + call process_stacks_test (u, results) +@ +\subsubsection{Event Transforms} +<>= + use event_transforms_ut, only: event_transforms_test +<>= + case ("event_transforms") + call event_transforms_test (u, results) +<>= + call event_transforms_test (u, results) +@ +\subsubsection{Resonance Insertion Transform} +<>= + use resonance_insertion_ut, only: resonance_insertion_test +<>= + case ("resonance_insertion") + call resonance_insertion_test (u, results) +<>= + call resonance_insertion_test (u, results) +@ +\subsubsection{Recoil Kinematics} +<>= + use recoil_kinematics_ut, only: recoil_kinematics_test +<>= + case ("recoil_kinematics") + call recoil_kinematics_test (u, results) +<>= + call recoil_kinematics_test (u, results) +@ +\subsubsection{ISR Handler} +<>= + use isr_epa_handler_ut, only: isr_handler_test +<>= + case ("isr_handler") + call isr_handler_test (u, results) +<>= + call isr_handler_test (u, results) +@ +\subsubsection{EPA Handler} +<>= + use isr_epa_handler_ut, only: epa_handler_test +<>= + case ("epa_handler") + call epa_handler_test (u, results) +<>= + call epa_handler_test (u, results) +@ +\subsubsection{Decays} +<>= + use decays_ut, only: decays_test +<>= + case ("decays") + call decays_test (u, results) +<>= + call decays_test (u, results) +@ +\subsubsection{Shower} +<>= + use shower_ut, only: shower_test +<>= + case ("shower") + call shower_test (u, results) +<>= + call shower_test (u, results) +@ +\subsubsection{Events} +<>= + use events_ut, only: events_test +<>= + case ("events") + call events_test (u, results) +<>= + call events_test (u, results) +@ +\subsubsection{HEP Events} +<>= + use hep_events_ut, only: hep_events_test +<>= + case ("hep_events") + call hep_events_test (u, results) +<>= + call hep_events_test (u, results) +@ +\subsubsection{EIO Data} +<>= + use eio_data_ut, only: eio_data_test +<>= + case ("eio_data") + call eio_data_test (u, results) +<>= + call eio_data_test (u, results) +@ +\subsubsection{EIO Base} +<>= + use eio_base_ut, only: eio_base_test +<>= + case ("eio_base") + call eio_base_test (u, results) +<>= + call eio_base_test (u, results) +@ +\subsubsection{EIO Direct} +<>= + use eio_direct_ut, only: eio_direct_test +<>= + case ("eio_direct") + call eio_direct_test (u, results) +<>= + call eio_direct_test (u, results) +@ +\subsubsection{EIO Raw} +<>= + use eio_raw_ut, only: eio_raw_test +<>= + case ("eio_raw") + call eio_raw_test (u, results) +<>= + call eio_raw_test (u, results) +@ +\subsubsection{EIO Checkpoints} +<>= + use eio_checkpoints_ut, only: eio_checkpoints_test +<>= + case ("eio_checkpoints") + call eio_checkpoints_test (u, results) +<>= + call eio_checkpoints_test (u, results) +@ +\subsubsection{EIO LHEF} +<>= + use eio_lhef_ut, only: eio_lhef_test +<>= + case ("eio_lhef") + call eio_lhef_test (u, results) +<>= + call eio_lhef_test (u, results) +@ +\subsubsection{EIO HepMC} +<>= + use eio_hepmc_ut, only: eio_hepmc_test +<>= + case ("eio_hepmc") + call eio_hepmc_test (u, results) +<>= + call eio_hepmc_test (u, results) +@ +\subsubsection{EIO LCIO} +<>= + use eio_lcio_ut, only: eio_lcio_test +<>= + case ("eio_lcio") + call eio_lcio_test (u, results) +<>= + call eio_lcio_test (u, results) +@ +\subsubsection{EIO StdHEP} +<>= + use eio_stdhep_ut, only: eio_stdhep_test +<>= + case ("eio_stdhep") + call eio_stdhep_test (u, results) +<>= + call eio_stdhep_test (u, results) +@ +\subsubsection{EIO ASCII} +<>= + use eio_ascii_ut, only: eio_ascii_test +<>= + case ("eio_ascii") + call eio_ascii_test (u, results) +<>= + call eio_ascii_test (u, results) +@ +\subsubsection{EIO Weights} +<>= + use eio_weights_ut, only: eio_weights_test +<>= + case ("eio_weights") + call eio_weights_test (u, results) +<>= + call eio_weights_test (u, results) +@ +\subsubsection{EIO Dump} +<>= + use eio_dump_ut, only: eio_dump_test +<>= + case ("eio_dump") + call eio_dump_test (u, results) +<>= + call eio_dump_test (u, results) +@ +\subsubsection{Iterations} +<>= + use iterations_ut, only: iterations_test +<>= + case ("iterations") + call iterations_test (u, results) +<>= + call iterations_test (u, results) +@ +\subsubsection{Beam Structures} +<>= + use beam_structures_ut, only: beam_structures_test +<>= + case ("beam_structures") + call beam_structures_test (u, results) +<>= + call beam_structures_test (u, results) +@ +\subsubsection{RT Data} +<>= + use rt_data_ut, only: rt_data_test +<>= + case ("rt_data") + call rt_data_test (u, results) +<>= + call rt_data_test (u, results) +@ +\subsubsection{Dispatch} +<>= + use dispatch_ut, only: dispatch_test +<>= + case ("dispatch") + call dispatch_test (u, results) +<>= + call dispatch_test (u, results) +@ +\subsubsection{Dispatch RNG} +<>= + use dispatch_rng_ut, only: dispatch_rng_test +<>= + case ("dispatch_rng") + call dispatch_rng_test (u, results) +<>= + call dispatch_rng_test (u, results) +@ +\subsubsection{Dispatch MCI} +<>= + use dispatch_mci_ut, only: dispatch_mci_test +<>= + case ("dispatch_mci") + call dispatch_mci_test (u, results) +<>= + call dispatch_mci_test (u, results) +@ +\subsubsection{Dispatch PHS} +<>= + use dispatch_phs_ut, only: dispatch_phs_test +<>= + case ("dispatch_phs") + call dispatch_phs_test (u, results) +<>= + call dispatch_phs_test (u, results) +@ +\subsubsection{Dispatch transforms} +<>= + use dispatch_transforms_ut, only: dispatch_transforms_test +<>= + case ("dispatch_transforms") + call dispatch_transforms_test (u, results) +<>= + call dispatch_transforms_test (u, results) +@ +\subsubsection{Shower partons} +<>= + use shower_base_ut, only: shower_base_test +<>= + case ("shower_base") + call shower_base_test (u, results) +<>= + call shower_base_test (u, results) +@ +\subsubsection{Process Configurations} +<>= + use process_configurations_ut, only: process_configurations_test +<>= + case ("process_configurations") + call process_configurations_test (u, results) +<>= + call process_configurations_test (u, results) +@ +\subsubsection{Compilations} +<>= + use compilations_ut, only: compilations_test + use compilations_ut, only: compilations_static_test +<>= + case ("compilations") + call compilations_test (u, results) + case ("compilations_static") + call compilations_static_test (u, results) +<>= + call compilations_test (u, results) + call compilations_static_test (u, results) +@ +\subsubsection{Integrations} +<>= + use integrations_ut, only: integrations_test + use integrations_ut, only: integrations_history_test +<>= + case ("integrations") + call integrations_test (u, results) + case ("integrations_history") + call integrations_history_test (u, results) +<>= + call integrations_test (u, results) + call integrations_history_test (u, results) +@ +\subsubsection{Event Streams} +<>= + use event_streams_ut, only: event_streams_test +<>= + case ("event_streams") + call event_streams_test (u, results) +<>= + call event_streams_test (u, results) +@ +\subsubsection{Restricted Subprocesses} +<>= + use restricted_subprocesses_ut, only: restricted_subprocesses_test +<>= + case ("restricted_subprocesses") + call restricted_subprocesses_test (u, results) +<>= + call restricted_subprocesses_test (u, results) +@ +\subsubsection{Simulations} +<>= + use simulations_ut, only: simulations_test +<>= + case ("simulations") + call simulations_test (u, results) +<>= + call simulations_test (u, results) +@ +\subsubsection{Commands} +<>= + use commands_ut, only: commands_test +<>= + case ("commands") + call commands_test (u, results) +<>= + call commands_test (u, results) +@ +\subsubsection{$ttV$ formfactors} +<>= + use ttv_formfactors_ut, only: ttv_formfactors_test +<>= + case ("ttv_formfactors") + call ttv_formfactors_test (u, results) +<>= + call ttv_formfactors_test (u, results) +@ +\subsubsection{API} +<>= + use api_ut, only: api_test +<>= + case ("api") + call api_test (u, results) +<>= + call api_test (u, results) +@ +\subsubsection{API/HepMC} +<>= + use api_hepmc_ut, only: api_hepmc_test +<>= + case ("api_hepmc") + call api_hepmc_test (u, results) +<>= + call api_hepmc_test (u, results) +@ +\subsubsection{API/LCIO} +<>= + use api_lcio_ut, only: api_lcio_test +<>= + case ("api_lcio") + call api_lcio_test (u, results) +<>= + call api_lcio_test (u, results) Index: trunk/src/main/Makefile.am =================================================================== --- trunk/src/main/Makefile.am (revision 0) +++ trunk/src/main/Makefile.am (revision 8429) @@ -0,0 +1,270 @@ +## Makefile.am -- Makefile for WHIZARD +## +## Process this file with automake to produce Makefile.in +# +# Copyright (C) 1999-2020 by +# Wolfgang Kilian +# Thorsten Ohl +# Juergen Reuter +# with contributions from +# cf. main AUTHORS file +# +# WHIZARD is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# WHIZARD is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +######################################################################## + +## The main program is contained in a library on its own. +lib_LTLIBRARIES = libwhizard_main.la +check_LTLIBRARIES = libwhizard_main_ut.la + +COMMON_F90 = \ + cmdline_options.f90 +MPI_F90 = \ + main.f90_mpi +SERIAL_F90 = \ + main.f90_serial + +nodist_libwhizard_main_la_SOURCES = \ + $(COMMON_F90) \ + main.f90 + +DISTCLEANFILES = main.f90 + +if FC_USE_MPI +main.f90: main.f90_mpi + -cp -f $< $@ +else +main.f90: main.f90_serial + -cp -f $< $@ +endif + +MPI_F90 += main_ut.f90_mpi +SERIAL_F90 += main_ut.f90_serial + +nodist_libwhizard_main_ut_la_SOURCES = \ + $(COMMON_F90) \ + main_ut.f90 + +DISTCLEANFILES += main_ut.f90 + +if FC_USE_MPI +main_ut.f90: main_ut.f90_mpi + -cp -f $< $@ +else +main_ut.f90: main_ut.f90_serial + -cp -f $< $@ +endif + +EXTRA_DIST = \ + $(COMMON_F90) \ + $(SERIAL_F90) \ + $(MPI_F90) + +## Omitting this would exclude it from the distribution +dist_noinst_DATA = main.nw + +# # Dump module names into file Modules +# libwhizard_core_Modules = \ +# ${libwhizard_core_la_SOURCES:.f90=} \ +# ${nodist_libwhizard_core_la_SOURCES:.f90=} \ +# ${libwhizard_core_ut_la_SOURCES:.f90=} +# Modules: Makefile +# @for module in $(libwhizard_core_Modules); do \ +# echo $$module >> $@.new; \ +# done +# @if diff $@ $@.new -q >/dev/null; then \ +# rm $@.new; \ +# else \ +# mv $@.new $@; echo "Modules updated"; \ +# fi +# BUILT_SOURCES = Modules + +## Fortran module dependencies +# Get module lists from other directories +module_lists = \ + ../basics/Modules \ + ../utilities/Modules \ + ../testing/Modules \ + ../system/Modules \ + ../combinatorics/Modules \ + ../parsing/Modules \ + ../rng/Modules \ + ../physics/Modules \ + ../qft/Modules \ + ../expr_base/Modules \ + ../types/Modules \ + ../matrix_elements/Modules \ + ../particles/Modules \ + ../beams/Modules \ + ../me_methods/Modules \ + ../pythia8/Modules \ + ../events/Modules \ + ../phase_space/Modules \ + ../mci/Modules \ + ../vegas/Modules \ + ../blha/Modules \ + ../gosam/Modules \ + ../openloops/Modules \ + ../recola/Modules \ + ../fks/Modules \ + ../variables/Modules \ + ../model_features/Modules \ + ../muli/Modules \ + ../shower/Modules \ + ../matching/Modules \ + ../process_integration/Modules \ + ../transforms/Modules \ + ../threshold/Modules \ + ../whizard-core/Modules \ + ../api/Modules + +$(module_lists): + $(MAKE) -C `dirname $@` Modules + +Module_dependencies.sed: \ + $(nodist_libwhizard_main_la_SOURCES) \ + $(nodist_libwhizard_main_ut_la_SOURCES) +Module_dependencies.sed: $(module_lists) + @rm -f $@ + echo 's/, *only:.*//' >> $@ + echo 's/, *&//' >> $@ + echo 's/, *.*=>.*//' >> $@ + echo 's/$$/.lo/' >> $@ + for list in $(module_lists); do \ + dir="`dirname $$list`"; \ + for mod in `cat $$list`; do \ + echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ + done \ + done + +DISTCLEANFILES += Module_dependencies.sed + +# The following line just says +# include Makefile.depend +# but in a portable fashion (depending on automake's AM_MAKE_INCLUDE +@am__include@ @am__quote@Makefile.depend@am__quote@ + +Makefile.depend: Module_dependencies.sed +Makefile.depend: \ + $(nodist_libwhizard_main_la_SOURCES) \ + $(nodist_libwhizard_main_ut_la_SOURCES) + @rm -f $@ + for src in $^; do \ + module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ + grep '^ *use ' $$src \ + | grep -v '!NODEP!' \ + | sed -e 's/^ *use */'$$module'.lo: /' \ + -f Module_dependencies.sed; \ + done > $@ + +DISTCLEANFILES += Makefile.depend + +SUFFIXES = .lo .$(FCMOD) +# Fortran90 module files are generated at the same time as object files +.lo.$(FCMOD): + @: +# touch $@ + +AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../parsing -I../rng -I../physics -I../qed_pdf -I../qft -I../expr_base -I../types -I../matrix_elements -I../particles -I../beams -I../me_methods -I../events -I../phase_space -I../mci -I../vegas -I../blha -I../gosam -I../openloops -I../fks -I../variables -I../model_features -I../muli -I../pythia8 -I../shower -I../matching -I../process_integration -I../transforms -I../xdr -I../../vamp/src -I../pdf_builtin -I../../circe1/src -I../../circe2/src -I../lhapdf -I../fastjet -I../threshold -I../tauola -I../recola -I../whizard-core -I../api +######################################################################## +## Default Fortran compiler options + +## Profiling +if FC_USE_PROFILING +AM_FCFLAGS += $(FCFLAGS_PROFILING) +endif + +## OpenMP +if FC_USE_OPENMP +AM_FCFLAGS += $(FCFLAGS_OPENMP) +endif + +## MPI +if FC_USE_MPI +AM_FCFLAGS += $(FCFLAGS_MPI) +endif + +if RECOLA_AVAILABLE +AM_FCFLAGS += $(RECOLA_INCLUDES) +endif + +######################################################################## +## Non-standard targets and dependencies + +## (Re)create F90 sources from NOWEB source. +if NOWEB_AVAILABLE + +FILTER = -filter "sed 's/defn MPI:/defn/'" + +COMMON_SRC = \ + $(COMMON_F90) + +PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw +POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw + +main.stamp: $(PRELUDE) $(srcdir)/main.nw $(POSTLUDE) + @rm -f main.tmp + @touch main.tmp + for src in $(COMMON_SRC); do \ + $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ + done + for src in $(MPI_F90:.f90_mpi=.f90); do \ + $(NOTANGLE) -R[[$$src]] $(FILTER) $^ | $(CPIF) $$src'_mpi'; \ + done + for src in $(SERIAL_F90:.f90_serial=.f90); do \ + $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src'_serial'; \ + done + @mv -f main.tmp main.stamp + +$(MPI_F90) $(SERIAL_F90) $(COMMON_SRC): main.stamp +## Recover from the removal of $@ + @if test -f $@; then :; else \ + rm -f main.stamp; \ + $(MAKE) $(AM_MAKEFLAGS) main.stamp; \ + fi + +endif + +######################################################################## +## Non-standard cleanup tasks +## Remove sources that can be recreated using NOWEB +if NOWEB_AVAILABLE +maintainer-clean-noweb: + -rm -f *.f90 *.f90_mpi *.f90_serial *.c +endif +.PHONY: maintainer-clean-noweb + +## Remove those sources also if builddir and srcdir are different +if NOWEB_AVAILABLE +clean-noweb: + test "$(srcdir)" != "." && rm -f *.f90 *.f90_mpi *.f90_serial *.c || true +endif +.PHONY: clean-noweb + +## Remove F90 module files +clean-local: clean-noweb + -rm -f main.stamp main.tmp + -rm -f *.$(FCMOD) +if FC_SUBMODULES + -rm -f *.smod +endif + +## Remove backup files +maintainer-clean-backup: + -rm -f *~ +.PHONY: maintainer-clean-backup + +## Register additional clean targets +maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/tauola/Makefile.am =================================================================== --- trunk/src/tauola/Makefile.am (revision 8428) +++ trunk/src/tauola/Makefile.am (revision 8429) @@ -1,147 +1,152 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory end up in an auxiliary libtool library. noinst_LTLIBRARIES = libtauola_interface.la libtauola_interface_la_SOURCES = \ hepev4_aux.f90 \ tauola_interface.f90 +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libtauola_interface_la_SOURCES:.f90=.$(FCMOD)} + libtauola_interface_Modules = ${libtauola_interface_la_SOURCES:.f90=} Modules: Makefile @for module in $(libtauola_interface_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../system/Modules \ ../variables/Modules \ ../qft/Modules \ ../events/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libtauola_interface_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libtauola_interface_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend -SUFFIXES = .lo .$(FC_MODULE_EXT) +SUFFIXES = .lo .$(FCMOD) # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ if PYTHIA6_AVAILABLE libtauola_interface_la_LIBADD = ../../pythia6/libpythia6_wo.la ../../tauola/libtauola_wo.la else libtauola_interface_la_LIBADD = ../../pythia6/libpythia6_wo_dummy.la ../../tauola/libtauola_wo_dummy.la endif AM_FCFLAGS = ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Explicit dependencies AM_FCFLAGS += -I../basics -I../utilities -I../system -I../expr_base -I../combinatorics -I../parsing -I../physics -I../qft -I../types -I../fastjet -I../particles -I../events -I../variables MODULES= \ - tauola_interface.$(FC_MODULE_EXT) \ - hepev4_aux.$(FC_MODULE_EXT) + tauola_interface.$(FCMOD) \ + hepev4_aux.$(FCMOD) ######################################################################## ## Non-standard cleanup tasks ## Remove backup files maintainer-clean-local: -rm -f *~ ## Remove module files clean-local: -rm -f $(MODULES) if FC_SUBMODULES -rm -f *.smod endif Index: trunk/src/particles/Makefile.am =================================================================== --- trunk/src/particles/Makefile.am (revision 8428) +++ trunk/src/particles/Makefile.am (revision 8429) @@ -1,203 +1,204 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement quantum field theory concepts ## such as model representation and quantum numbers. ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libparticles.la check_LTLIBRARIES = libparticles_ut.la libparticles_la_SOURCES = \ su_algebra.f90 \ bloch_vectors.f90 \ polarizations.f90 \ particles.f90 libparticles_ut_la_SOURCES = \ su_algebra_uti.f90 su_algebra_ut.f90 \ bloch_vectors_uti.f90 bloch_vectors_ut.f90 \ polarizations_uti.f90 polarizations_ut.f90 \ particles_uti.f90 particles_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = particles.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libparticles_la_SOURCES:.f90=.$(FCMOD)} + libparticles_Modules = \ ${libparticles_la_SOURCES:.f90=} \ ${libparticles_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libparticles_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../physics/Modules \ ../qft/Modules \ ../types/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libparticles_la_SOURCES) $(libparticles_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libparticles_la_SOURCES) $(libparticles_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../physics -I../fastjet -I../qft -I../types ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -#execmoddir = $(pkglibdir)/mod/particles -#nodist_execmod_HEADERS = \# - ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw particles.stamp: $(PRELUDE) $(srcdir)/particles.nw $(POSTLUDE) @rm -f particles.tmp @touch particles.tmp for src in \ $(libparticles_la_SOURCES) \ $(libparticles_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f particles.tmp particles.stamp $(libparticles_la_SOURCES) $(libparticles_ut_la_SOURCES): particles.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f particles.stamp; \ $(MAKE) $(AM_MAKEFLAGS) particles.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f particles.stamp particles.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/prebuilt/Makefile.am =================================================================== --- trunk/src/prebuilt/Makefile.am (revision 8428) +++ trunk/src/prebuilt/Makefile.am (revision 8429) @@ -1,48 +1,48 @@ ## Makefile.am -- Makefile for WHIZARD prebuilt process libraries ## ## Process this file with automake to produce Makefile.in ## The main program makes up a library on its own. lib_LTLIBRARIES = libwhizard_prebuilt.la libwhizard_prebuilt_la_SOURCES = libmanager.f90 ## Dependencies of whizard_prebuilt $(libwhizard_prebuilt_la_OBJECTS): \ - ../basics/iso_varying_string.$(FC_MODULE_EXT) \ - ../matrix_elements/prclib_interfaces.$(FC_MODULE_EXT) + ../basics/iso_varying_string.$(FCMOD) \ + ../matrix_elements/prclib_interfaces.$(FCMOD) AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../matrix_elements ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Cleanup ## Remove F90 module files clean-local: - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-backup Index: trunk/src/matching/Makefile.am =================================================================== --- trunk/src/matching/Makefile.am (revision 8428) +++ trunk/src/matching/Makefile.am (revision 8429) @@ -1,248 +1,254 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement different matchings ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libmatching.la check_LTLIBRARIES = libmatching_ut.la COMMON_F90 = \ matching_base.f90 \ ckkw_matching.f90 \ mlm_matching.f90 MPI_F90 = \ powheg_matching.f90_mpi SERIAL_F90 = \ powheg_matching.f90_serial EXTRA_DIST = \ $(COMMON_F90) \ $(SERIAL_F90) \ $(MPI_F90) nodist_libmatching_la_SOURCES = \ $(COMMON_F90) \ powheg_matching.f90 DISTCLEANFILES = powheg_matching.f90 if FC_USE_MPI powheg_matching.f90: powheg_matching.f90_mpi -cp -f $< $@ else powheg_matching.f90: powheg_matching.f90_serial -cp -f $< $@ endif libmatching_ut_la_SOURCES = \ powheg_matching_uti.f90 powheg_matching_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = matching.nw +# Modules and installation +# Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${nodist_libmatching_la_SOURCES:.f90=.$(FCMOD)} + # Dump module names into file Modules libmatching_Modules = \ $(nodist_libmatching_la_SOURCES:.f90=) \ $(libmatching_ut_la_SOURCES:.f90=) Modules: Makefile @for module in $(libmatching_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../combinatorics/Modules \ ../parsing/Modules \ ../rng/Modules \ ../physics/Modules \ ../qft/Modules \ ../expr_base/Modules \ ../types/Modules \ ../particles/Modules \ ../beams/Modules \ ../matrix_elements/Modules \ ../me_methods/Modules \ ../events/Modules \ ../muli/Modules \ ../phase_space/Modules \ ../mci/Modules \ ../blha/Modules \ ../gosam/Modules \ ../openloops/Modules \ ../recola/Modules \ ../fks/Modules \ ../model_features/Modules \ ../variables/Modules \ ../shower/Modules \ ../threshold/Modules \ ../process_integration/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(nodist_libmatching_la_SOURCES) $(libmatching_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES += Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(nodist_libmatching_la_SOURCES) $(libmatching_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../parsing -I../rng -I../physics -I../qft -I../expr_base -I../types -I../particles -I../beams -I../matrix_elements -I../me_methods -I../events -I../muli -I../phase_space -I../mci -I../blha -I../gosam -I../openloops -I../recola -I../fks -I../model_features -I../variables -I../tauola -I../shower -I../threshold -I../process_integration -I../../circe1/src -I../../circe2/src -I../pdf_builtin -I../lhapdf -I../qed_pdf -I../fastjet -I../../vamp/src ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif if RECOLA_AVAILABLE AM_FCFLAGS += $(RECOLA_INCLUDES) endif ######################################################################## ## Non-standard targets and dependencies ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE FILTER = -filter "sed 's/defn MPI:/defn/'" PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw matching.stamp: $(PRELUDE) $(srcdir)/matching.nw $(POSTLUDE) @rm -f matching.tmp @touch matching.tmp for src in \ $(COMMON_F90) $(libmatching_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done for src in $(SERIAL_F90:.f90_serial=.f90); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src'_serial'; \ done for src in $(MPI_F90:.f90_mpi=.f90); do \ $(NOTANGLE) -R[[$$src]] $(FILTER) $^ | $(CPIF) $$src'_mpi'; \ done @mv -f matching.tmp matching.stamp $(COMMON_F90) $(SERIAL_F90) $(MPI_F90) $(libmatching_ut_la_SOURCES): matching.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f matching.stamp; \ $(MAKE) $(AM_MAKEFLAGS) matching.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.f90_serial *.f90_mpi *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.f90_serial *.f90_mpi *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f matching.stamp matching.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/combinatorics/Makefile.am =================================================================== --- trunk/src/combinatorics/Makefile.am (revision 8428) +++ trunk/src/combinatorics/Makefile.am (revision 8429) @@ -1,234 +1,233 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement standard algorithms for WHIZARD ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libcombinatorics.la check_LTLIBRARIES = libcombinatorics_ut.la COMMON_F90 = \ bytes.f90 \ hashes.f90 \ md5.f90 \ permutations.f90 \ sorting.f90 \ solver.f90 MPI_F90 = \ grids.f90_mpi SERIAL_F90 = \ grids.f90_serial EXTRA_DIST = \ $(COMMON_F90) \ $(SERIAL_F90) \ $(MPI_F90) nodist_libcombinatorics_la_SOURCES = \ $(COMMON_F90) \ grids.f90 DISTCLEANFILES = grids.f90 if FC_USE_MPI grids.f90: grids.f90_mpi -cp -f $< $@ else grids.f90: grids.f90_serial -cp -f $< $@ endif libcombinatorics_ut_la_SOURCES = \ md5_uti.f90 md5_ut.f90 \ sorting_uti.f90 sorting_ut.f90 \ grids_uti.f90 grids_ut.f90 \ solver_uti.f90 solver_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = combinatorics.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${nodist_libcombinatorics_la_SOURCES:.f90=.$(FCMOD)} + libcombinatorics_Modules = \ - $(nodist_libcombinatorics_la_SOURCES:.f90=) \ - $(libcombinatorics_ut_la_SOURCES:.f90=) + ${nodist_libcombinatorics_la_SOURCES:.f90=} \ + ${libcombinatorics_ut_la_SOURCES:.f90=} Modules: Makefile @for module in \ $(libcombinatorics_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../testing/Modules \ ../system/Modules \ ../utilities/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(nodist_libcombinatorics_la_SOURCES) \ $(libcombinatorics_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES += Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(nodist_libcombinatorics_la_SOURCES) \ $(libcombinatorics_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../testing -I../system -I../utilities ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -## and by the user code library -execmoddir = $(pkglibdir)/mod/combinatorics -nodist_execmod_HEADERS = \ - solver.$(FC_MODULE_EXT) - ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE FILTER = -filter "sed 's/defn MPI:/defn/'" PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw combinatorics.stamp: $(PRELUDE) $(srcdir)/combinatorics.nw $(POSTLUDE) @rm -f combinatorics.tmp @touch combinatorics.tmp for src in $(COMMON_F90) $(libcombinatorics_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done for src in $(SERIAL_F90:.f90_serial=.f90); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src'_serial'; \ done for src in $(MPI_F90:.f90_mpi=.f90); do \ $(NOTANGLE) -R[[$$src]] $(FILTER) $^ | $(CPIF) $$src'_mpi'; \ done @mv -f combinatorics.tmp combinatorics.stamp $(COMMON_F90) $(SERIAL_F90) $(MPI_F90) $(libcombinatorics_ut_la_SOURCES): combinatorics.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f combinatorics.stamp; \ $(MAKE) $(AM_MAKEFLAGS) combinatorics.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.f90_serial *.f90_mpi *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.f90_serial *.f90_mpi *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f combinatorics.stamp combinatorics.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/threshold/Makefile.am =================================================================== --- trunk/src/threshold/Makefile.am (revision 8428) +++ trunk/src/threshold/Makefile.am (revision 8429) @@ -1,209 +1,225 @@ ## Makefile.am -- Makefile for model-parameter modules in WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## Build the objects required for the SM ttbar threshold model. noinst_LTLIBRARIES = libthreshold.la check_LTLIBRARIES = libthreshold_ut.la ## We need all in the distribution EXTRA_DIST = interpolation.f90 nr_tools.f90 \ toppik.f toppik_axial.f ttv_formfactors.f90 libthreshold_la_SOURCES = \ interpolation.f90 \ nr_tools.f90 \ toppik.f \ toppik_axial.f \ ttv_formfactors.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = threshold.nw libthreshold_ut_la_SOURCES = \ ttv_formfactors_uti.f90 ttv_formfactors_ut.f90 +# Modules and installation +# Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + interpolation.$(FCMOD) \ + nr_tools.$(FCMOD) \ + ttv_formfactors.$(FCMOD) \ + nr.$(FCMOD) \ + nrtype.$(FCMOD) \ + nrutil.$(FCMOD) \ + hypgeo_info.$(FCMOD) \ + ode_path.$(FCMOD) + # Dump module names into file Modules libthreshold_Modules = \ ${libthreshold_la_SOURCES:.f90=} \ ${libthreshold_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libthreshold_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../testing/Modules \ ../utilities/Modules \ ../system/Modules \ ../physics/Modules \ ../combinatorics/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libthreshold_la_SOURCES) \ $(libthreshold_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libthreshold_la_SOURCES) \ $(libthreshold_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend -nrtype.$(FC_MODULE_EXT) nr.$(FC_MODULE_EXT): nr_tools.$(FC_MODULE_EXT) +nrtype.$(FCMOD) nr.$(FCMOD): nr_tools.$(FCMOD) -SUFFIXES = .lo .$(FC_MODULE_EXT) +SUFFIXES = .lo .$(FCMOD) # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: AM_FCFLAGS = -I../basics -I../testing -I../utilities -I../system -I../physics -I../combinatorics ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -execmoddir = $(pkglibdir)/mod/threshold -nodist_execmod_HEADERS = \ - interpolation.$(FC_MODULE_EXT) \ - nr_tools.$(FC_MODULE_EXT) \ - nr.$(FC_MODULE_EXT) \ - nrtype.$(FC_MODULE_EXT) \ - ttv_formfactors.$(FC_MODULE_EXT) - ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw threshold.stamp: $(PRELUDE) $(srcdir)/threshold.nw $(POSTLUDE) @rm -f threshold.tmp @touch threshold.tmp for src in \ $(libthreshold_la_SOURCES) \ $(libthreshold_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f threshold.tmp threshold.stamp $(libthreshold_la_SOURCES) $(libthreshold_ut_la_SOURCES): threshold.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f threshold.stamp; \ $(MAKE) $(AM_MAKEFLAGS) threshold.stamp; \ fi endif ######################################################################## +## Explicit dependencies + +interpolation.$(FCMOD): interpolation.lo +nr_tools.$(FCMOD): nr_tools.lo +ttv_formfactors.$(FCMOD): ttv_formfactors.lo +nr.$(FCMOD): nr_tools.lo +nrtype.$(FCMOD): nr_tools.lo +nrutil.$(FCMOD): nr_tools.lo +hypgeo_info.$(FCMOD): nr_tools.lo +ode_path.$(FCMOD): nr_tools.lo + +######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f *.f90 || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f *.stamp *.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-local: -rm -f *~ ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/pdf_builtin/Makefile.am =================================================================== --- trunk/src/pdf_builtin/Makefile.am (revision 8428) +++ trunk/src/pdf_builtin/Makefile.am (revision 8429) @@ -1,79 +1,109 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in ## ######################################################################## # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory end up in an auxiliary libtool library. noinst_LTLIBRARIES = libpdf_builtin.la libpdf_builtin_la_SOURCES = \ cteq6pdf.f90 pdf_builtin.f90 mrst2004qed.f90 mstwpdf.f90 \ ct10pdf.f90 CJpdf.f90 ct14pdf.f90 $(libpdf_builtin_la_OBJECTS): \ - ../basics/kinds.$(FC_MODULE_EXT) \ - ../basics/iso_varying_string.$(FC_MODULE_EXT) \ - ../basics/io_units.$(FC_MODULE_EXT) \ - ../utilities/format_utils.$(FC_MODULE_EXT) \ - ../system/diagnostics.$(FC_MODULE_EXT) + ../basics/kinds.$(FCMOD) \ + ../basics/iso_varying_string.$(FCMOD) \ + ../basics/io_units.$(FCMOD) \ + ../utilities/format_utils.$(FCMOD) \ + ../system/diagnostics.$(FCMOD) + +# Modules and installation +# Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + pdf_builtin.$(FCMOD) \ + cteq6pdf.$(FCMOD) \ + cj_pdf.$(FCMOD) \ + mrst2004qed.$(FCMOD) \ + mstwpdf.$(FCMOD) \ + ct10pdf.$(FCMOD) \ + ct14pdf.$(FCMOD) + +SUFFIXES = .lo .$(FCMOD) + +# Fortran90 module files are generated at the same time as object files +.lo.$(FCMOD): + @: +# touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../system -pdf_builtin.lo: cteq6pdf.lo mrst2004qed.lo mstwpdf.lo ct10pdf.lo CJpdf.lo ct14pdf.lo - ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## +## Explicit dependencies + +pdf_builtin.lo: cteq6pdf.lo mrst2004qed.lo mstwpdf.lo ct10pdf.lo CJpdf.lo ct14pdf.lo + +pdf_builtin.$(FCMOD): pdf_builtin.lo +cteq6pdf.$(FCMOD): cteq6pdf.lo +cj_pdf.$(FCMOD): CJpdf.lo +mrst2004qed.$(FCMOD): mrst2004qed.lo +mstwpdf.$(FCMOD): mstwpdf.lo +ct10pdf.$(FCMOD): ct10pdf.lo +ct14pdf.$(FCMOD): ct14pdf.lo + +######################################################################## ## Non-standard cleanup tasks ## Remove F90 module files clean-local: - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-local: -rm -f *~ Index: trunk/src/hoppet/Makefile.am =================================================================== --- trunk/src/hoppet/Makefile.am (revision 8428) +++ trunk/src/hoppet/Makefile.am (revision 8429) @@ -1,79 +1,79 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory end up in an auxiliary libtool library. if HOPPET_AVAILABLE noinst_LTLIBRARIES = libhoppet.la libhoppet_la_SOURCES = hoppet.f90 libhoppet_la_FCFLAGS = $(AM_FCFLAGS) $(HOPPET_INCLUDES) else noinst_LTLIBRARIES = libhoppet_dummy.la libhoppet_dummy_la_SOURCES = hoppet_dummy.f90 endif AM_FCFLAGS = ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Explicit dependencies libhoppet.lo: \ - ../system/system_dependencies.$(FC_MODULE_EXT) \ - ../pdf_builtin/pdf_builtin.$(FC_MODULE_EXT) \ - ../lhapdf/lhapdf.$(FC_MODULE_EXT) + ../system/system_dependencies.$(FCMOD) \ + ../pdf_builtin/pdf_builtin.$(FCMOD) \ + ../lhapdf/lhapdf.$(FCMOD) libhoppet_dummy.lo: \ - ../lhapdf/lhapdf.$(FC_MODULE_EXT) + ../lhapdf/lhapdf.$(FCMOD) AM_FCFLAGS += -I../basics -I../system -I../pdf_builtin -I../lhapdf MODULES= \ - hoppet.$(FC_MODULE_EXT) + hoppet.$(FCMOD) ######################################################################## ## Cleanup ## Remove backup files maintainer-clean-local: -rm -f *~ Index: trunk/src/fastjet/Makefile.am =================================================================== --- trunk/src/fastjet/Makefile.am (revision 8428) +++ trunk/src/fastjet/Makefile.am (revision 8429) @@ -1,88 +1,104 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory end up in an auxiliary libtool library. if FASTJET_AVAILABLE noinst_LTLIBRARIES = libFastjetWrap.la libFastjetWrap_la_SOURCES = \ CppStringsWrap.cpp FastjetWrap.cpp \ cpp_strings.f90 fastjet.f90 libFastjetWrap_la_CPPFLAGS = $(FASTJET_CXXFLAGS) else noinst_LTLIBRARIES = libFastjetWrap_dummy.la libFastjetWrap_dummy_la_SOURCES = \ CppStringsWrap_dummy.f90 FastjetWrap_dummy.f90 \ cpp_strings.f90 fastjet.f90 endif +# Modules and installation +# Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + cpp_strings.$(FCMOD) \ + fastjet.$(FCMOD) + +SUFFIXES = .lo .$(FCMOD) + +# Fortran90 module files are generated at the same time as object files +.lo.$(FCMOD): + @: +# touch $@ + AM_FCFLAGS = ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Explicit dependencies fastjet.lo: cpp_strings.lo fastjet.lo: \ - ../basics/kinds.$(FC_MODULE_EXT) \ - ../physics/lorentz.$(FC_MODULE_EXT) + ../basics/kinds.$(FCMOD) \ + ../physics/lorentz.$(FCMOD) +cpp_strings.$(FCMOD): cpp_strings.lo +fastjet.$(FCMOD): fastjet.lo AM_FCFLAGS += -I../basics -I../utilities -I../testing -I../system -I../physics MODULES= \ - cpp_strings.$(FC_MODULE_EXT) \ - fastjet.$(FC_MODULE_EXT) + cpp_strings.$(FCMOD) \ + fastjet.$(FCMOD) ######################################################################## ## Non-standard cleanup tasks ## Remove backup files maintainer-clean-local: -rm -f *~ ## Remove module files clean-local: -rm -f $(MODULES) if FC_SUBMODULES -rm -f *.smod endif Index: trunk/src/parsing/Makefile.am =================================================================== --- trunk/src/parsing/Makefile.am (revision 8428) +++ trunk/src/parsing/Makefile.am (revision 8429) @@ -1,197 +1,198 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement text-handling and parsing utilities. ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libparsing.la check_LTLIBRARIES = libparsing_ut.la libparsing_la_SOURCES = \ ifiles.f90 \ lexers.f90 \ syntax_rules.f90 \ parser.f90 \ xml.f90 libparsing_ut_la_SOURCES = \ lexers_uti.f90 lexers_ut.f90 \ parser_uti.f90 parser_ut.f90 \ xml_uti.f90 xml_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = parsing.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libparsing_la_SOURCES:.f90=.$(FCMOD)} + libparsing_Modules = \ ${libparsing_la_SOURCES:.f90=} \ ${libparsing_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libparsing_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../combinatorics/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libparsing_la_SOURCES) $(libparsing_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libparsing_la_SOURCES) $(libparsing_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -#execmoddir = $(pkglibdir)/mod/misc -#nodist_execmod_HEADERS = - ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw parsing.stamp: $(PRELUDE) $(srcdir)/parsing.nw $(POSTLUDE) @rm -f parsing.tmp @touch parsing.tmp for src in $(libparsing_la_SOURCES) $(libparsing_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f parsing.tmp parsing.stamp $(libparsing_la_SOURCES) $(libparsing_ut_la_SOURCES): parsing.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f parsing.stamp; \ $(MAKE) $(AM_MAKEFLAGS) parsing.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f parsing.stamp parsing.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/types/Makefile.am =================================================================== --- trunk/src/types/Makefile.am (revision 8428) +++ trunk/src/types/Makefile.am (revision 8429) @@ -1,203 +1,204 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory implement objects and methods ## as they appear in the Sindarin language ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libtypes.la check_LTLIBRARIES = libtypes_ut.la libtypes_la_SOURCES = \ particle_specifiers.f90 \ analysis.f90 \ pdg_arrays.f90 \ jets.f90 \ subevents.f90 libtypes_ut_la_SOURCES = \ particle_specifiers_uti.f90 particle_specifiers_ut.f90 \ analysis_uti.f90 analysis_ut.f90 \ pdg_arrays_uti.f90 pdg_arrays_ut.f90 \ jets_uti.f90 jets_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = types.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libtypes_la_SOURCES:.f90=.$(FCMOD)} + libtypes_Modules = ${libtypes_la_SOURCES:.f90=} ${libtypes_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libtypes_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../combinatorics/Modules \ ../parsing/Modules \ ../physics/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libtypes_la_SOURCES) $(libtypes_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libtypes_la_SOURCES) $(libtypes_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../parsing -I../physics -I../qft -I../fastjet ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -#execmoddir = $(pkglibdir)/mod/types -#nodist_execmod_HEADERS = \# - ## Dependencies across directories and packages, if not automatically generated $(libtypes_la_OBJECTS): \ - ../fastjet/fastjet.$(FC_MODULE_EXT) + ../fastjet/fastjet.$(FCMOD) ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw types.stamp: $(PRELUDE) $(srcdir)/types.nw $(POSTLUDE) @rm -f types.tmp @touch types.tmp for src in $(libtypes_la_SOURCES) $(libtypes_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f types.tmp types.stamp $(libtypes_la_SOURCES) $(libtypes_ut_la_SOURCES): types.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f types.stamp; \ $(MAKE) $(AM_MAKEFLAGS) types.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f types.stamp types.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/basics/Makefile.am =================================================================== --- trunk/src/basics/Makefile.am (revision 8428) +++ trunk/src/basics/Makefile.am (revision 8429) @@ -1,107 +1,107 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in ## ######################################################################## # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory end up in an auxiliary libtool library. noinst_LTLIBRARIES = libbasics.la nodist_libbasics_la_SOURCES = \ kinds.f90 libbasics_la_SOURCES = \ iso_varying_string.f90 \ io_units.f90 \ constants.f90 +# Modules and installation # Dump module names into file Modules -libbasics_Modules = ${nodist_libbasics_la_SOURCES:.f90=} ${libbasics_la_SOURCES:.f90=} +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${nodist_libbasics_la_SOURCES:.f90=.$(FCMOD)} \ + ${libbasics_la_SOURCES:.f90=.$(FCMOD)} + +libbasics_Modules = \ + ${nodist_libbasics_la_SOURCES:.f90=} \ + ${libbasics_la_SOURCES:.f90=} Modules: Makefile @for module in $(libbasics_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules -## Install the modules used by generated matrix element code -execmoddir = $(pkglibdir)/mod/basics -nodist_execmod_HEADERS = \ - kinds.$(FC_MODULE_EXT) \ - iso_varying_string.$(FC_MODULE_EXT) \ - io_units.$(FC_MODULE_EXT) \ - constants.$(FC_MODULE_EXT) - -SUFFIXES = .lo .$(FC_MODULE_EXT) +SUFFIXES = .lo .$(FCMOD) # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ # Explicit dependencies constants.lo: kinds.lo AM_FCFLAGS = ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies .PHONY: clean-noweb clean-local: clean-noweb - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif DISTCLEANFILES = kinds.f90 ## Remove backup files maintainer-clean-local: -rm -f *~ Index: trunk/src/shower/Makefile.am =================================================================== --- trunk/src/shower/Makefile.am (revision 8428) +++ trunk/src/shower/Makefile.am (revision 8429) @@ -1,210 +1,220 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory make up the shower routines noinst_LTLIBRARIES = libshower.la check_LTLIBRARIES = libshower_ut.la libshower_la_SOURCES = \ pythia6_up.f \ ktclus.f90 \ shower_base.f90 \ shower_partons.f90 \ shower_core.f90 \ shower_pythia6.f90 \ shower_pythia8.f90 libshower_ut_la_SOURCES = \ shower_base_uti.f90 shower_base_ut.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = shower.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ktclus.$(FCMOD) \ + shower_base.$(FCMOD) \ + shower_core.$(FCMOD) \ + shower_partons.$(FCMOD) \ + shower_pythia6.$(FCMOD) \ + shower_pythia8.$(FCMOD) + libshower_Modules = ${libshower_la_SOURCES:.f90=} ${libshower_ut_la_SOURCES:.f90=} Modules: Makefile @for module in $(libshower_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../combinatorics/Modules \ ../parsing/Modules \ ../rng/Modules \ ../physics/Modules \ ../qft/Modules \ ../expr_base/Modules \ ../particles/Modules \ ../types/Modules \ ../variables/Modules \ ../model_features/Modules \ ../muli/Modules \ ../events/Modules \ ../beams/Modules \ ../tauola/Modules \ ../pythia8/Modules include_modules_bare = ${module_lists:/Modules=} include_modules = ${include_modules_bare:../%=-I../%} $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libshower_la_SOURCES) $(libshower_ut_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libshower_la_SOURCES) $(libshower_ut_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = $(include_modules) -I../../vamp/src -I../fastjet -I../lhapdf -I ../pdf_builtin -I../tauola -I../../pythia6 -I../pythia8 AM_FFLAGS = ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FFLAGS += $(FCFLAGS_PROFILING) AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FFLAGS += $(FCFLAGS_OPENMP) AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## MPI if FC_USE_MPI AM_FFLAGS += $(FCFLAGS_MPI) AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw shower.stamp: $(PRELUDE) $(srcdir)/shower.nw $(POSTLUDE) @rm -f shower.tmp @touch shower.tmp for src in $(libshower_la_SOURCES) $(libshower_ut_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f shower.tmp shower.stamp $(libshower_la_SOURCES) $(libshower_ut_la_SOURCES): shower.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f shower.stamp; \ $(MAKE) $(AM_MAKEFLAGS) shower.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.f endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.f || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f shower.stamp shower.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/api/Makefile.am =================================================================== --- trunk/src/api/Makefile.am (revision 0) +++ trunk/src/api/Makefile.am (revision 8429) @@ -0,0 +1,338 @@ +## Makefile.am -- Makefile for WHIZARD +## +## Process this file with automake to produce Makefile.in +# +# Copyright (C) 1999-2020 by +# Wolfgang Kilian +# Thorsten Ohl +# Juergen Reuter +# with contributions from +# cf. main AUTHORS file +# +# WHIZARD is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# WHIZARD is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +######################################################################## + +## The files in this directory make up the WHIZARD core + +## We create a library which is still to be combined with auxiliary libs. +noinst_LTLIBRARIES = libapi.la +check_LTLIBRARIES = libapi_ut.la +check_LTLIBRARIES += libapi_ut_c.la +check_LTLIBRARIES += libapi_ut_cc.la + +COMMON_F90 = \ + api.f90 \ + api_c.f90 + +COMMON_C = +MPI_C = +SERIAL_C = + +COMMON_CC = \ + api_cc.cc +MPI_CC = +SERIAL_CC = + +EXTRA_DIST = \ + $(COMMON_C) \ + $(SERIAL_C) \ + $(MPI_C) \ + $(COMMON_CC) \ + $(SERIAL_CC) \ + $(MPI_CC) + + +libapi_la_SOURCES = \ + $(COMMON_F90) \ + api_cc.cc + +DISTCLEANFILES = api.f90 + +libapi_ut_la_SOURCES = \ + api_uti.f90 api_ut.f90 \ + api_hepmc_uti.f90 api_hepmc_ut.f90 \ + api_lcio_uti.f90 api_lcio_ut.f90 + + +nodist_libapi_ut_c_la_SOURCES = \ + api_ut_c.c + +DISTCLEANFILES += api_ut_c.c + +MPI_C += api_ut_c.c_mpi +SERIAL_C += api_ut_c.c_serial + +if FC_USE_MPI +api_ut_c.c: api_ut_c.c_mpi + -cp -f $< $@ +else +api_ut_c.c: api_ut_c.c_serial + -cp -f $< $@ +endif + +nodist_libapi_ut_cc_la_SOURCES = \ + whizard_ut.cc \ + api_ut_cc.cc + +DISTCLEANFILES += \ + whizard_ut.cc \ + api_ut_cc.cc + +COMMON_CC += whizard_ut.cc +MPI_CC += api_ut_cc.cc_mpi +SERIAL_CC += api_ut_cc.cc_serial + +if FC_USE_MPI +api_ut_cc.cc: api_ut_cc.cc_mpi + -cp -f $< $@ +else +api_ut_cc.cc: api_ut_cc.cc_serial + -cp -f $< $@ +endif + + + +libapi_la_CPPFLAGS = +libapi_ut_cc_la_CPPFLAGS = +if HEPMC3_AVAILABLE +libapi_la_CPPFLAGS += -DWHIZARD_WITH_HEPMC3 $(HEPMC_INCLUDES) +libapi_ut_cc_la_CPPFLAGS += -DWHIZARD_WITH_HEPMC3 $(HEPMC_INCLUDES) +endif +if HEPMC2_AVAILABLE +libapi_la_CPPFLAGS += -DWHIZARD_WITH_HEPMC2 $(HEPMC_INCLUDES) +libapi_ut_cc_la_CPPFLAGS += -DWHIZARD_WITH_HEPMC2 $(HEPMC_INCLUDES) +endif +if LCIO_AVAILABLE +libapi_la_CPPFLAGS += -DWHIZARD_WITH_LCIO $(LCIO_INCLUDES) +libapi_ut_cc_la_CPPFLAGS += -DWHIZARD_WITH_LCIO $(LCIO_INCLUDES) +endif + +include_HEADERS = \ + whizard.h +dist_noinst_HEADERS = \ + whizard_ut.h + +## Omitting this would exclude it from the distribution +dist_noinst_DATA = api.nw + +# Modules and installation +# Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + api.$(FCMOD) + +# Dump module names into file Modules +libapi_Modules = \ + ${libapi_la_SOURCES:.f90=} \ + ${libapi_ut_la_SOURCES:.f90=} +Modules: Makefile + @for module in $(libapi_Modules); do \ + echo $$module >> $@.new; \ + done + @if diff $@ $@.new -q >/dev/null; then \ + rm $@.new; \ + else \ + mv $@.new $@; echo "Modules updated"; \ + fi +BUILT_SOURCES = Modules + +## Fortran module dependencies +# Get module lists from other directories +module_lists = \ + ../basics/Modules \ + ../utilities/Modules \ + ../testing/Modules \ + ../system/Modules \ + ../combinatorics/Modules \ + ../parsing/Modules \ + ../rng/Modules \ + ../physics/Modules \ + ../qft/Modules \ + ../expr_base/Modules \ + ../types/Modules \ + ../matrix_elements/Modules \ + ../particles/Modules \ + ../beams/Modules \ + ../me_methods/Modules \ + ../pythia8/Modules \ + ../events/Modules \ + ../phase_space/Modules \ + ../mci/Modules \ + ../vegas/Modules \ + ../blha/Modules \ + ../gosam/Modules \ + ../openloops/Modules \ + ../recola/Modules \ + ../fks/Modules \ + ../variables/Modules \ + ../model_features/Modules \ + ../muli/Modules \ + ../shower/Modules \ + ../matching/Modules \ + ../process_integration/Modules \ + ../transforms/Modules \ + ../threshold/Modules \ + ../whizard-core/Modules + +$(module_lists): + $(MAKE) -C `dirname $@` Modules + +Module_dependencies.sed: $(libapi_la_SOURCES) \ + $(libapi_ut_la_SOURCES) +Module_dependencies.sed: $(module_lists) + @rm -f $@ + echo 's/, *only:.*//' >> $@ + echo 's/, *&//' >> $@ + echo 's/, *.*=>.*//' >> $@ + echo 's/$$/.lo/' >> $@ + for list in $(module_lists); do \ + dir="`dirname $$list`"; \ + for mod in `cat $$list`; do \ + echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ + done \ + done + +DISTCLEANFILES += Module_dependencies.sed + +# The following line just says +# include Makefile.depend +# but in a portable fashion (depending on automake's AM_MAKE_INCLUDE +@am__include@ @am__quote@Makefile.depend@am__quote@ + +Makefile.depend: Module_dependencies.sed +Makefile.depend: \ + $(libapi_la_SOURCES) \ + $(libapi_ut_la_SOURCES) + @rm -f $@ + for src in $^; do \ + module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ + grep '^ *use ' $$src \ + | grep -v '!NODEP!' \ + | sed -e 's/^ *use */'$$module'.lo: /' \ + -f Module_dependencies.sed; \ + done > $@ + +DISTCLEANFILES += Makefile.depend + +SUFFIXES = .lo .$(FCMOD) +# Fortran90 module files are generated at the same time as object files +.lo.$(FCMOD): + @: +# touch $@ + +AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../parsing -I../rng -I../physics -I../qed_pdf -I../qft -I../expr_base -I../types -I../matrix_elements -I../particles -I../beams -I../me_methods -I../events -I../phase_space -I../mci -I../vegas -I../blha -I../gosam -I../openloops -I../fks -I../variables -I../model_features -I../muli -I../pythia8 -I../shower -I../matching -I../process_integration -I../transforms -I../xdr -I../../vamp/src -I../pdf_builtin -I../../circe1/src -I../../circe2/src -I../lhapdf -I../fastjet -I../threshold -I../tauola -I../recola -I../whizard-core +######################################################################## +## Default Fortran compiler options + +## Profiling +if FC_USE_PROFILING +AM_FCFLAGS += $(FCFLAGS_PROFILING) +endif + +## OpenMP +if FC_USE_OPENMP +AM_FCFLAGS += $(FCFLAGS_OPENMP) +endif + +## MPI +if FC_USE_MPI +AM_FCFLAGS += $(FCFLAGS_MPI) +endif + +if RECOLA_AVAILABLE +AM_FCFLAGS += $(RECOLA_INCLUDES) +endif + +######################################################################## +## Non-standard targets and dependencies + +## (Re)create F90 sources from NOWEB source. +if NOWEB_AVAILABLE + +FILTER = -filter "sed 's/defn MPI:/defn/'" + +COMMON_SRC = \ + $(COMMON_F90) \ + $(COMMON_CC) \ + $(libapi_ut_la_SOURCES) \ + $(libapi_ut_cc_la_SOURCES) \ + $(include_HEADERS) \ + $(dist_noinst_HEADERS) + +PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw +POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw + +api.stamp: $(PRELUDE) $(srcdir)/api.nw $(POSTLUDE) + @rm -f api.tmp + @touch api.tmp + for src in $(COMMON_SRC); do \ + $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ + done + for src in $(MPI_C:.c_mpi=.c); do \ + $(NOTANGLE) -R[[$$src]] $(FILTER) $^ | $(CPIF) $$src'_mpi'; \ + done + for src in $(SERIAL_C:.c_serial=.c); do \ + $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src'_serial'; \ + done + for src in $(MPI_CC:.cc_mpi=.cc); do \ + $(NOTANGLE) -R[[$$src]] $(FILTER) $^ | $(CPIF) $$src'_mpi'; \ + done + for src in $(SERIAL_CC:.cc_serial=.cc); do \ + $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src'_serial'; \ + done + @mv -f api.tmp api.stamp + +$(COMMON_SRC) $(MPI_C) $(SERIAL_C) $(MPI_CC) $(SERIAL_CC): api.stamp +## Recover from the removal of $@ + @if test -f $@; then :; else \ + rm -f api.stamp; \ + $(MAKE) $(AM_MAKEFLAGS) api.stamp; \ + fi + +endif + +######################################################################## +## Non-standard cleanup tasks +## Remove sources that can be recreated using NOWEB +if NOWEB_AVAILABLE +maintainer-clean-noweb: + -rm -f *.f90 *.f90_mpi *.f90_serial *.c *.cc *.h +endif +.PHONY: maintainer-clean-noweb + +## Remove those sources also if builddir and srcdir are different +if NOWEB_AVAILABLE +clean-noweb: + test "$(srcdir)" != "." && rm -f *.f90 *.f90_mpi *.f90_serial \ + *.c_mpi *.c_serial *.cc_mpi *.cc_serial *.c *.cc *.h || true +endif +.PHONY: clean-noweb + +## Remove F90 module files +clean-local: clean-noweb + -rm -f api.stamp api.tmp + -rm -f *.$(FCMOD) +if FC_SUBMODULES + -rm -f *.smod +endif + +## Remove backup files +maintainer-clean-backup: + -rm -f *~ +.PHONY: maintainer-clean-backup + +## Register additional clean targets +maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/api/api.nw =================================================================== --- trunk/src/api/api.nw (revision 0) +++ trunk/src/api/api.nw (revision 8429) @@ -0,0 +1,4117 @@ +% -*- ess-noweb-default-code-mode: f90-mode; noweb-default-code-mode: f90-mode; -*- +% WHIZARD main code as NOWEB source +\includemodulegraph{api} +\chapter{API for external programs} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Fortran API} + +This section declares the frontend object for communicating with the \whizard\ +package. We try to keep the API, i.e., the methods of the frontend object, +clear from any internal types and data structures. +<<[[api.f90]]>>= +<> + +module api + + use iso_fortran_env, only: int32, real64 !NODEP! +<> +<> + use diagnostics, only: logfile_init + use diagnostics, only: logging + use diagnostics, only: logfile_final + use diagnostics, only: mask_term_signals + use diagnostics, only: release_term_signals + use diagnostics, only: msg_message + use diagnostics, only: msg_error + use diagnostics, only: msg_fatal + use diagnostics, only: msg_summary + use string_utils, only: split_string + use lexers, only: stream_t + use lexers, only: lexer_t + use parser, only: parse_tree_t + use parser, only: parse_node_t + use flavors, only: flavor_t + use event_handles, only: event_handle_t + use events, only: event_t + use event_streams, only: event_stream_array_t + use simulations, only: simulation_t + use commands, only: lexer_init_cmd_list + use commands, only: syntax_cmd_list + use commands, only: command_list_t + use whizard, only: whizard_t + use whizard, only: whizard_options_t + +<> + +<> + +<> + +<> + +<> + +contains + +<> + +end module api +@ %def api +@ +\subsection{The \whizard\ API object} +This object provides the frontend for a \whizard\ instance. It is mainly a +wrapper around a master [[whizard_t]] object (and may eventually be merged +with that). We allocate the master object as a pointer, so we can guarantee +the [[target]] attribute for it -- otherwise this would be the duty of the +calling code. + +The [[whizard_api]] object is opaque, while the master object contains public +data for convenience. + +Important: the [[whizard_api]] object must not be copied, since this would be +a shallow copy of the master object. +<>= + public :: whizard_api_t +<>= + type :: whizard_api_t + private + type(whizard_t), pointer :: master => null () + character(:), allocatable :: logfile + type(whizard_options_t) :: options + type(lexer_t) :: sindarin_lexer + contains + <> + end type whizard_api_t + +@ %def whizard_api_t +@ +\subsection{Initialize and finalize} +Before the \whizard\ object is initialized, we have the opportunity to set +options. All option names and values are strings, which we convert to the +appropriate types. +<>= + procedure :: option +<>= + subroutine option (whizard, key, value) + class(whizard_api_t), intent(inout) :: whizard + character(*), intent(in) :: key + character(*), intent(in) :: value + + logical :: rebuild + + if (associated (whizard%master)) then + call msg_error ("WHIZARD: options must be set before initialization; & + &extra option '" // key // "' ignored.") + return + end if + + associate (options => whizard%options) + select case (key) + case ("model") + options%preload_model = value + case ("library") + options%preload_libraries = value + case ("logfile") + whizard%logfile = value + case ("job_id") + options%job_id = value + case ("pack") + call split_string (var_str (value), var_str (","), & + options%pack_args) + options%pack_args = trim (adjustl (options%pack_args)) + case ("unpack") + call split_string (var_str (value), var_str (","), & + options%unpack_args) + options%unpack_args = trim (adjustl (options%unpack_args)) + case ("rebuild") + read (value, "(L1)") rebuild + options%rebuild_library = rebuild + options%recompile_library = rebuild + options%rebuild_phs = rebuild + options%rebuild_grids = rebuild + options%rebuild_events = rebuild + case ("rebuild_library") + read (value, "(L1)") options%rebuild_library + case ("recompile") + read (value, "(L1)") options%recompile_library + case ("rebuild_phase_space") + read (value, "(L1)") options%rebuild_phs + case ("rebuild_grids") + read (value, "(L1)") options%rebuild_grids + case ("rebuild_events") + read (value, "(L1)") options%rebuild_events + case default + call msg_error ("WHIZARD: option '" // key // "' not recognized.") + end select + end associate + + end subroutine option + +@ %def option +@ +The initializer has to be called once. It prepares all internal structure of +the master object, and it initializes any global data. The initialization +options must be set before, using the [[whizard_option]] method. Likewise, the +finalizer cleans all internal structure and finalizes global data. + +TODO: not yet supported: [[paths]] option. + +We allow for multiple calls of [[init]] and [[final]], with the following +semantics: redundant calls do nothing except for issuing a non-fatal error. + +TODO: As long as global data exist in the program, finalizing a master object +should be avoided if others are still present. In fact, several objects may +not be allowed to co-exist. Global state should either be made local, or be +guarded against removal of a master object. +<>= + procedure :: init +<>= + subroutine init (whizard) + class(whizard_api_t), intent(inout) :: whizard + + whizard%options%default_lib = "whizard_processes" + if (.not. associated (whizard%master)) then + allocate (whizard%master) + if (allocated (whizard%logfile)) then + logging = .true. + call logfile_init (var_str (whizard%logfile)) + call whizard%master%init (whizard%options, & + logfile = var_str (whizard%logfile)) + else + call whizard%master%init (whizard%options) + end if + call lexer_init_cmd_list (whizard%sindarin_lexer) + call msg_message ("WHIZARD: master object initialized.") + else + call msg_error ("WHIZARD: extra call to initializer is ignored") + end if + + end subroutine init + +@ %def init +@ Finalizer as explicit method: +<>= + procedure :: final +<>= + subroutine final (whizard) + class(whizard_api_t), intent(inout) :: whizard + + if (associated (whizard%master)) then + call whizard%sindarin_lexer%final () + call whizard%master%final () + call msg_message ("WHIZARD: master object finalized.") + deallocate (whizard%master) + call msg_summary () + call logfile_final () + else + call msg_error ("WHIZARD: extra call to finalizer is ignored") + end if + + end subroutine final + +@ %def final +@ Finalizer as implicit destructor (modern form). Do not complain for a +redundant call. + +TODO: finalizer disabled +<>= +! final :: finalize +<>= + subroutine finalize (whizard) + type(whizard_api_t), intent(inout), target :: whizard + + if (associated (whizard%master)) call whizard%final () + + end subroutine finalize + +@ %def finalize +@ As a guard against user errors, we provide this check which is to be +called at the beginning of each method: +<>= + subroutine sanity_check (whizard) + class(whizard_api_t), intent(in) :: whizard + + if (.not. associated (whizard%master)) then + call msg_fatal ("WHIZARD: method call without initialization") + end if + + end subroutine sanity_check + +@ %def sanity_check +@ The WHIZARD banner should be shown on screen, but only once -- even if the +WHIZARD object is initialized and finalized more than once. We record this in +a module variable. +<>= + logical :: whizard_banner_shown = .false. +@ %def whizard_banner_shown +@ +\subsection{Variables} +Set and retrieve named Sindarin variables (from the global variable record). +<>= + generic :: set_var => set_var_real64 + generic :: set_var => set_var_int32 + generic :: set_var => set_var_logical + generic :: set_var => set_var_character + procedure :: set_var_real64 + procedure :: set_var_int32 + procedure :: set_var_logical + procedure :: set_var_character +<>= + subroutine set_var_real64 (whizard, name, value) + class(whizard_api_t), intent(inout) :: whizard + character(*), intent(in) :: name + real(real64), intent(in) :: value + + call sanity_check (whizard) + call whizard%master%global%set_real & + (var_str (name), real (value, default), & + verbose=.true., is_known=.true.) + + end subroutine set_var_real64 + + subroutine set_var_int32 (whizard, name, value) + class(whizard_api_t), intent(inout) :: whizard + character(*), intent(in) :: name + integer(int32), intent(in) :: value + + call sanity_check (whizard) + call whizard%master%global%set_int & + (var_str (name), int (value), & + verbose=.true., is_known=.true.) + + end subroutine set_var_int32 + + subroutine set_var_logical (whizard, name, value) + class(whizard_api_t), intent(inout) :: whizard + character(*), intent(in) :: name + logical, intent(in) :: value + + call sanity_check (whizard) + call whizard%master%global%set_log & + (var_str (name), value, & + verbose=.true., is_known=.true.) + + end subroutine set_var_logical + + subroutine set_var_character (whizard, name, value) + class(whizard_api_t), intent(inout) :: whizard + character(*), intent(in) :: name + character(*), intent(in) :: value + + call sanity_check (whizard) + call whizard%master%global%set_string & + (var_str (name), var_str (value), & + verbose=.true., is_known=.true.) + + end subroutine set_var_character + +@ %def set_var_real64 +@ %def set_var_int32 +@ %def set_var_logical +<>= + generic :: get_var => get_var_real64 + generic :: get_var => get_var_int32 + generic :: get_var => get_var_logical + generic :: get_var => get_var_character + procedure :: get_var_real64 + procedure :: get_var_int32 + procedure :: get_var_logical + procedure :: get_var_character + procedure :: get_var_character_length +<>= + subroutine get_var_real64 (whizard, name, value, known) + class(whizard_api_t), intent(inout) :: whizard + character(*), intent(in) :: name + real(real64), intent(out) :: value + logical, intent(out), optional :: known + + call sanity_check (whizard) + value = whizard%master%global%get_rval (var_str (name)) + if (present (known)) & + known = whizard%master%global%is_known (var_str (name)) + + end subroutine get_var_real64 + + subroutine get_var_int32 (whizard, name, value, known) + class(whizard_api_t), intent(inout) :: whizard + character(*), intent(in) :: name + integer(int32), intent(out) :: value + logical, intent(out), optional :: known + + call sanity_check (whizard) + value = whizard%master%global%get_ival (var_str (name)) + if (present (known)) & + known = whizard%master%global%is_known (var_str (name)) + + end subroutine get_var_int32 + + subroutine get_var_logical (whizard, name, value, known) + class(whizard_api_t), intent(inout) :: whizard + character(*), intent(in) :: name + logical, intent(out) :: value + logical, intent(out), optional :: known + + call sanity_check (whizard) + value = whizard%master%global%get_lval (var_str (name)) + if (present (known)) & + known = whizard%master%global%is_known (var_str (name)) + + end subroutine get_var_logical + + subroutine get_var_character (whizard, name, value, known, strlen) + class(whizard_api_t), intent(inout) :: whizard + character(*), intent(in) :: name + character(:), allocatable, intent(out) :: value + logical, intent(out), optional :: known + integer, intent(in), optional :: strlen + + call sanity_check (whizard) + value = char (whizard%master%global%get_sval (var_str (name))) + if (present (known)) & + known = whizard%master%global%is_known (var_str (name)) + if (present (strlen)) then + if (len (value) > strlen) value = value(1:strlen) + end if + + end subroutine get_var_character + + function get_var_character_length (whizard, name) result (strlen) + class(whizard_api_t), intent(inout) :: whizard + character(*), intent(in) :: name + integer :: strlen + + call sanity_check (whizard) + strlen = len (whizard%master%global%get_sval (var_str (name))) + + end function get_var_character_length + +@ %def get_var_real64 +@ %def get_var_int32 +@ %def get_var_logical +@ %def get_var_character +@ %def get_var_character_length +@ +Convenience methods to retrieve process-integration results: +<>= + procedure :: get_integration_result +<>= + subroutine get_integration_result (whizard, proc_id, integral, error, known) + class(whizard_api_t), intent(in) :: whizard + character(*), intent(in) :: proc_id + real(real64), intent(out) :: integral + real(real64), intent(out) :: error + logical, intent(out), optional :: known + + character(:), allocatable :: integral_var + character(:), allocatable :: error_var + + integral_var = "integral(" // proc_id // ")" + error_var = "error(" // proc_id // ")" + + integral = whizard%master%global%get_rval (var_str (integral_var)) + error = whizard%master%global%get_rval (var_str (error_var)) + if (present (known)) & + known = whizard%master%global%is_known (var_str (integral_var)) + + end subroutine get_integration_result + +@ %def get_integration_result +@ +\subsection{Generic Sindarin commands} +Interpret and execute Sindarin code given by a string. +<>= + procedure :: command +<>= + subroutine command (whizard, code) + class(whizard_api_t), intent(inout) :: whizard + character(*), intent(in) :: code + + type(stream_t), target :: stream + type(parse_tree_t) :: parse_tree + type(parse_node_t), pointer :: pn_root + type(command_list_t), target :: cmd_list + + call sanity_check (whizard) + + call stream%init (var_str (code)) + call whizard%sindarin_lexer%assign_stream (stream) + call parse_tree%parse (syntax_cmd_list, whizard%sindarin_lexer) + pn_root => parse_tree%get_root_ptr () + if (associated (pn_root)) then + call cmd_list%compile (pn_root, whizard%master%global) + call mask_term_signals () + call cmd_list%execute (whizard%master%global) + call release_term_signals () + end if + call stream%final () + call whizard%sindarin_lexer%clear () + + end subroutine command + +@ %def command +@ +\subsection{Particle name translation} +Create a flavor string from a PDG value or array, depending on the current +global model. +<>= + generic :: flv_string => flv_string_single, flv_string_array + procedure :: flv_string_single + procedure :: flv_string_array +<>= + function flv_string_single (whizard, pdg) result (string) + class(whizard_api_t), intent(in) :: whizard + integer(int32), intent(in) :: pdg + character(:), allocatable :: string + + type(flavor_t) :: flv + + if (associated (whizard%master%global%model)) then + call flv%init (int (pdg), whizard%master%global%model) + end if + string = '"' // char (flv%get_name ()) // '"' + + end function flv_string_single + + function flv_string_array (whizard, pdg) result (string) + class(whizard_api_t), intent(in) :: whizard + integer(int32), dimension(:), intent(in) :: pdg + character(:), allocatable :: string + + integer :: i + + if (size (pdg) > 0) then + string = whizard%flv_string (pdg(1)) + do i = 2, size (pdg) + string = string // ":" // whizard%flv_string (pdg(i)) + end do + else + string = "" + end if + + end function flv_string_array + +@ %def flv_string +@ +\subsection{The event-sample API object} +This object represents an event sample. It allows the user to steer event +generation, generate events one-by-one. It also handles the configuration of +and access to event I/O. + +We store a [[simulation_t]] object and an [[es_array_t]] object. + +The [[it_begin]] and [[it_end]] counters are relevant for running with MPI +active. Storing them here allows us to have a [[close]] method without extra +arguments. +<>= + public :: simulation_api_t +<>= + type :: simulation_api_t + private + type(simulation_t), pointer :: sim => null () + type(event_stream_array_t) :: esa + integer :: it_begin = 0 + integer :: it_end = 0 + contains + <> + end type simulation_api_t + +@ %def simulation_api_t +@ +\subsubsection{Create a new sample} +This is a factory method of the \whizard\ API object. All configuration data +should be present in the global data record. We create a sample object that +allows us to generate events such as the [[simulate]] command does, but with +full control and access to each single event. + +Multiple processes can be combined in the sample by concatenating the process +ID strings. The separator is a comma, surrounded by optional blanks. + +Note: The initialization of [[sample]] establishes a link (via pointer) to the +environment present in the parent [[whizard]] object. In principle, this can +result in unwanted side effects. As long as we do not make further use of +local variables, we should be safe. + +Not supported: local options (cf.\ [[cmd_simulate]]), alternate environments. +<>= + procedure :: new_sample +<>= + subroutine new_sample (whizard, proc_id_string, sample) + class(whizard_api_t), intent(in) :: whizard + character(*), intent(in) :: proc_id_string + type(simulation_api_t), intent(out) :: sample + + integer :: i, n_events + type(string_t), dimension(:), allocatable :: proc_id + + call sanity_check (whizard) + + call split_string (var_str (proc_id_string), var_str (","), proc_id) + proc_id = trim (adjustl (proc_id)) + + allocate (sample%sim) + call sample%sim%init (proc_id, .true., .true., whizard%master%global) + if (sample%sim%is_valid ()) then + + call sample%sim%init_process_selector () + call sample%sim%setup_openmp () + call sample%sim%compute_n_events (n_events) + call sample%sim%set_n_events_requested (n_events) + call sample%sim%activate_extra_logging () + call sample%sim%prepare_event_streams (sample%esa) + + end if + + end subroutine new_sample + +@ %def new_sample +@ +\subsubsection{Finalizer} +No actual need to call this explicitly, if the Fortran finalizer facility +works. + +TODO: finalizer disabled +<>= + procedure :: final => sample_final +! final :: sample_finalize +<>= + subroutine sample_final (sample) + class(simulation_api_t), intent(inout) :: sample + + call sample%esa%final () + + if (associated (sample%sim)) then + call sample%sim%final () + deallocate (sample%sim) + end if + + end subroutine sample_final + + subroutine sample_finalize (sample) + type(simulation_api_t), intent(inout) :: sample + + call sample%final () + + end subroutine sample_finalize + +@ %def sample_final +@ +\subsubsection{Event loop} +This procedure initializes the simulation for event generation, computes the +requested number of events, and prepares the event streams. The configuration +is taken from the variable-list copy that is stored inside the simulation +object. +<>= + procedure :: open => sample_open +<>= + subroutine sample_open (sample, it_begin, it_end) + class(simulation_api_t), intent(inout) :: sample + integer, intent(out) :: it_begin + integer, intent(out) :: it_end + + if (sample%sim%is_valid ()) then + if (sample%esa%is_valid ()) then + call sample%sim%before_first_event (it_begin, it_end, sample%esa) + else + call sample%sim%before_first_event (it_begin, it_end) + end if + end if + sample%it_begin = it_begin + sample%it_end = it_end + + end subroutine sample_open + +@ %def sample_open +@ Generate (or read) a single event, using the current status of the +[[sample]] object. +<>= + procedure :: next_event => sample_next_event +<>= + subroutine sample_next_event (sample, event_handle_out, event_handle_in) + class(simulation_api_t), intent(inout) :: sample + class(event_handle_t), intent(inout), optional :: event_handle_out + class(event_handle_t), intent(inout), optional :: event_handle_in + + if (sample%sim%is_valid ()) then + call mask_term_signals () + if (sample%esa%is_valid ()) then + call sample%sim%next_event & + (sample%esa, event_handle_out, event_handle_in) + else + call sample%sim%next_event () + end if + call release_term_signals () + end if + + end subroutine sample_next_event + +@ %def sample_next_event +@ Finalize the event generation: collect statistics and close the event-stream +array. Then call the finalizer to close the event streams etc. +<>= + procedure :: close => sample_close +<>= + subroutine sample_close (sample) + class(simulation_api_t), intent(inout) :: sample + + if (sample%sim%is_valid ()) then + call sample%sim%after_last_event (sample%it_begin, sample%it_end) + end if + call sample%final () + + end subroutine sample_close + +@ %def sample_close +@ +\subsubsection{Event data} +These data are available as soon as [[next_event]] has been called, querying +the [[sample]] object. +<>= + procedure :: get_event_index => sample_get_event_index + procedure :: get_process_index => sample_get_process_index + procedure :: get_process_id => sample_get_process_id + procedure :: get_sqrts => sample_get_sqrts + procedure :: get_fac_scale => sample_get_fac_scale + procedure :: get_alpha_s => sample_get_alpha_s + procedure :: get_sqme => sample_get_sqme + procedure :: get_weight => sample_get_weight +<>= + subroutine sample_get_event_index (sample, i) + class(simulation_api_t), intent(in) :: sample + integer(int32), intent(out) :: i + + i = sample%sim%get_event_index () + + end subroutine sample_get_event_index + + subroutine sample_get_process_index (sample, i) + class(simulation_api_t), intent(in) :: sample + integer(int32), intent(out) :: i + + i = sample%sim%get_process_index () + + end subroutine sample_get_process_index + + subroutine sample_get_process_id (sample, proc_id) + class(simulation_api_t), intent(in) :: sample + character(:), allocatable, intent(out) :: proc_id + + class(event_t), pointer :: event + + event => sample%sim%get_event_ptr () + proc_id = char (event%get_process_name ()) + + end subroutine sample_get_process_id + + subroutine sample_get_sqrts (sample, sqrts) + class(simulation_api_t), intent(in) :: sample + real(real64), intent(out) :: sqrts + + class(event_t), pointer :: event + + event => sample%sim%get_event_ptr () + sqrts = event%get_sqrts () + + end subroutine sample_get_sqrts + + subroutine sample_get_fac_scale (sample, fac_scale) + class(simulation_api_t), intent(in) :: sample + real(real64), intent(out) :: fac_scale + + class(event_t), pointer :: event + + event => sample%sim%get_event_ptr () + fac_scale = event%get_fac_scale () + + end subroutine sample_get_fac_scale + + subroutine sample_get_alpha_s (sample, alpha_s) + class(simulation_api_t), intent(in) :: sample + real(real64), intent(out) :: alpha_s + + class(event_t), pointer :: event + + event => sample%sim%get_event_ptr () + alpha_s = event%get_alpha_s () + + end subroutine sample_get_alpha_s + + subroutine sample_get_sqme (sample, sqme) + class(simulation_api_t), intent(in) :: sample + real(real64), intent(out) :: sqme + + class(event_t), pointer :: event + + event => sample%sim%get_event_ptr () + sqme = event%get_sqme_prc () + + end subroutine sample_get_sqme + + subroutine sample_get_weight (sample, weight) + class(simulation_api_t), intent(in) :: sample + real(real64), intent(out) :: weight + + class(event_t), pointer :: event + + event => sample%sim%get_event_ptr () + weight = event%get_weight_prc () + + end subroutine sample_get_weight + +@ %def sample_get_event_index +@ %def sample_get_process_index +@ %def sample_get_sqrts +@ %def sample_get_fac_scale +@ %def sample_get_alpha_s +@ %def sample_get_sqme +@ %def sample_get_weight +@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\subsection{Unit tests: generic} +Test module, followed by the corresponding implementation module. +<<[[api_ut.f90]]>>= +<> + +module api_ut + use unit_tests + use api_uti + +<> + +<> + +contains + +<> + +end module api_ut +@ %def api_ut +@ +<<[[api_uti.f90]]>>= +<> + +module api_uti + + use iso_fortran_env, only: int32, real64 !NODEP! + use diagnostics, only: msg_message + + use api + +<> + +<> + +contains + +<> + +end module api_uti +@ %def api_ut +@ API: driver for the unit tests below. +<>= + public :: api_test +<>= + subroutine api_test (u, results) + integer, intent(in) :: u + type(test_results_t), intent(inout) :: results + <> + end subroutine api_test + +@ %def api_test +@ +\subsubsection{API Initialization} +Initialize and finalize \whizard\ master object. +<>= + call test (api_1, "api_1", & + "init/final", & + u, results) +<>= + public :: api_1 +<>= + subroutine api_1 (u) + integer, intent(in) :: u + type(whizard_api_t) :: whizard + + character(:), allocatable :: logfile + integer :: u_log + integer :: iostat + character(80) :: buffer + + write (u, "(A)") "* Test output: api_1" + write (u, "(A)") "* Purpose: call init/final" + write (u, "(A)") + + logfile = "api_1_log.out" + call whizard%option ("logfile", logfile) + call whizard%init () + call msg_message ("Intentional error: double init") + call whizard%init () + call whizard%final () + call msg_message ("Intentional error: double final") + call whizard%final () + + open (newunit = u_log, file = logfile, action = "read", status = "old") + do + read (u_log, "(A)", iostat=iostat) buffer + if (iostat /= 0) exit + if (buffer(1:10) == "| WHIZARD:") write (u, "(A)") trim (buffer) + if (buffer(1:10) == "*** ERROR:") write (u, "(A)") trim (buffer) + end do + close (u_log) + + write (u, "(A)") + write (u, "(A)") "* Test output end: api_1" + + end subroutine api_1 + +@ %def api_1 +@ +\subsubsection{API: data} +Set and get Sindarin-variable values. +<>= + call test (api_2, "api_2", & + "set/get Sindarin values", & + u, results) +<>= + public :: api_2 +<>= + subroutine api_2 (u) + integer, intent(in) :: u + type(whizard_api_t) :: whizard + + character(:), allocatable :: job_id + character(:), allocatable :: sample + logical :: unweighted + integer :: n_events + real(real64) :: sqrts + logical :: known + + write (u, "(A)") "* Test output: api_2" + write (u, "(A)") "* Purpose: access Sindarin variables" + write (u, "(A)") + + call whizard%option ("logfile", "api_2_log.out") + call whizard%option ("job_id", "api_2_ID") + call whizard%init () + + call whizard%get_var ("sqrts", sqrts, known) + write (u, "(A,1x,L1)") "sqrts is known =", known + write (u, "(A,1x,F5.1)") "sqrts =", sqrts + + call whizard%set_var ("sqrts", 100._real64) + call whizard%set_var ("n_events", 3_int32) + call whizard%set_var ("?unweighted", .false.) + call whizard%set_var ("$sample", "foo") + + call whizard%get_var ("sqrts", sqrts, known) + call whizard%get_var ("$job_id", job_id) + call whizard%get_var ("n_events", n_events) + call whizard%get_var ("?unweighted", unweighted) + call whizard%get_var ("$sample", sample) + + write (u, "(A,1x,L1)") "sqrts is known =", known + write (u, "(A,1x,F5.1)") "sqrts =", sqrts + write (u, "(A,1x,A)") "$job_id =", job_id + write (u, "(A,1x,I0)") "n_events =", n_events + write (u, "(A,1x,L1)") "?unweighted =", unweighted + write (u, "(A,1x,A)") "$sample =", sample + + write (u, *) + + call whizard%set_var ("?unweighted", .true.) + call whizard%get_var ("?unweighted", unweighted) + write (u, "(A,1x,L1)") "?unweighted =", unweighted + + call whizard%final () + + write (u, "(A)") + write (u, "(A)") "* Test output end: api_2" + + end subroutine api_2 + +@ %def api_2 +@ +\subsubsection{API: generic commands} +Execute Sindarin command. +<>= + call test (api_3, "api_3", & + "preload model and execute command (model)", & + u, results) +<>= + public :: api_3 +<>= + subroutine api_3 (u) + integer, intent(in) :: u + type(whizard_api_t) :: whizard + + character(:), allocatable :: model_name + + write (u, "(A)") "* Test output: api_3" + write (u, "(A)") "* Purpose: set model in advance and via Sindarin string" + write (u, "(A)") + + call whizard%option ("model", "QCD") + call whizard%option ("logfile", "api_3_log.out") + call whizard%init () + + call whizard%get_var ("$model_name", model_name) + write (u, "(A,1x,A)") "model =", model_name + + call whizard%command ("model = QED") + + call whizard%get_var ("$model_name", model_name) + write (u, "(A,1x,A)") "model =", model_name + + call whizard%final () + + write (u, "(A)") + write (u, "(A)") "* Test output end: api_3" + + end subroutine api_3 + +@ %def api_3 +@ +\subsubsection{API: generic commands} +Translate PDG (single or array) to \whizard\ flavor string. +<>= + call test (api_4, "api_4", & + "flavor string translation", & + u, results) +<>= + public :: api_4 +<>= + subroutine api_4 (u) + integer, intent(in) :: u + type(whizard_api_t) :: whizard + + character(:), allocatable :: flv_string + + write (u, "(A)") "* Test output: api_4" + write (u, "(A)") "* Purpose: translate PDG code(s) to flavor string" + write (u, "(A)") + + call whizard%option ("model", "QED") + call whizard%option ("logfile", "api_4_log.out") + call whizard%init () + + write (u, "(A,1x,A)") "electron =", whizard%flv_string (11) + write (u, "(A,1x,A)") "leptons =", whizard%flv_string ([11,13,15]) + + call whizard%final () + + write (u, "(A)") + write (u, "(A)") "* Test output end: api_4" + + end subroutine api_4 + +@ %def api_4 +@ +\subsubsection{API: integration} +Declare a process and do an integration run, and retrieve the results. +<>= + call test (api_5, "api_5", & + "integration", & + u, results) +<>= + public :: api_5 +<>= + subroutine api_5 (u) + integer, intent(in) :: u + type(whizard_api_t) :: whizard + + real(real64) :: sqrts, integral, error + logical :: known + + write (u, "(A)") "* Test output: api_5" + write (u, "(A)") "* Purpose: integrate and retrieve results" + write (u, "(A)") + + call whizard%option ("model", "QED") + call whizard%option ("library", "api_5_lib") + call whizard%option ("logfile", "api_5_log.out") + call whizard%option ("rebuild", "T") + call whizard%init () + + write (u, "(A)") "* Process setup" + write (u, "(A)") + + call whizard%command ("process api_5_p = e1, E1 => e2, E2") + call whizard%command ("sqrts = 10") + call whizard%command ("iterations = 1:100") + call whizard%set_var ("seed", 0_int32) + call whizard%get_integration_result ("api_5_p", integral, error, known) + write (u, 2) "integral is known =", known + + call whizard%command ("integrate (api_5_p)") + + write (u, "(A)") + write (u, "(A)") "* Integrate" + write (u, "(A)") + + call whizard%get_integration_result ("api_5_p", integral, error, known) + write (u, 2) "integral is known =", known + + call whizard%get_var ("sqrts", sqrts) + call whizard%get_integration_result ("api_5_p", integral, error) + write (u, 1) "sqrt(s) =", sqrts, "GeV" + write (u, 1) "cross section =", integral / 1000, "pb" + write (u, 1) "error =", error / 1000, "pb" +1 format (2x,A,1x,F5.1,1x,A) +2 format (2x,A,1x,L1) + + call whizard%final () + + write (u, "(A)") + write (u, "(A)") "* Test output end: api_5" + + end subroutine api_5 + +@ %def api_5 +@ +\subsubsection{API: event generation} +Declare a process and generate two events, one by one +<>= + call test (api_6, "api_6", & + "event generation", & + u, results) +<>= + public :: api_6 +<>= + subroutine api_6 (u) + integer, intent(in) :: u + + type(whizard_api_t) :: whizard + type(simulation_api_t) :: sample + + integer :: it_begin, it_end + integer :: i + integer(int32) :: idx + real(real64) :: sqme + real(real64) :: weight + + write (u, "(A)") "* Test output: api_6" + write (u, "(A)") "* Purpose: generate events" + write (u, "(A)") + + call whizard%option ("model", "QED") + call whizard%option ("library", "api_6_lib") + call whizard%option ("logfile", "api_6_log.out") + call whizard%option ("rebuild", "T") + call whizard%init () + + call whizard%command ("process api_6_p = e1, E1 => e2, E2") + + call whizard%set_var ("sqrts", 10._real64) + call whizard%command ("iterations = 1:100") + call whizard%set_var ("seed", 0_int32) + call whizard%command ("integrate (api_6_p)") + + call whizard%set_var ("?unweighted", .false.) + call whizard%set_var ("$sample", "api_6_evt") + call whizard%command ("sample_format = dump") + call whizard%set_var ("n_events", 2_int32) + call whizard%set_var ("event_index_offset", 4_int32) + + call whizard%new_sample ("api_6_p", sample) + call sample%open (it_begin, it_end) + do i = it_begin, it_end + call sample%next_event () + call sample%get_event_index (idx) + call sample%get_weight (weight) + call sample%get_sqme (sqme) + write (u, "(A,I0)") "Event #", idx + write (u, 3) "sqme =", sqme + write (u, 3) "weight =", weight +3 format (2x,A,1x,ES10.3) + end do + call sample%close () + + call whizard%final () + + write (u, "(A)") + write (u, "(A)") "* Test output end: api_6" + + end subroutine api_6 + +@ %def api_6 +@ +\subsubsection{API: event generation with multiple processes} +Declare two processes and generate events in a mixed sample, one by one +<>= + call test (api_7, "api_7", & + "more event generation", & + u, results) +<>= + public :: api_7 +<>= + subroutine api_7 (u) + integer, intent(in) :: u + + type(whizard_api_t) :: whizard + type(simulation_api_t) :: sample + + integer :: it_begin, it_end + integer :: i + integer(int32) :: idx + integer(int32) :: i_proc + character(:), allocatable :: proc_id + real(real64) :: sqrts + real(real64) :: scale + real(real64) :: alpha_s + real(real64) :: sqme + real(real64) :: weight + + write (u, "(A)") "* Test output: api_7" + write (u, "(A)") "* Purpose: generate events" + write (u, "(A)") + + call whizard%option ("model", "QCD") + call whizard%option ("library", "api_7_lib") + call whizard%option ("logfile", "api_7_log.out") + call whizard%option ("rebuild", "T") + call whizard%init () + + call whizard%command ("process api_7_p1 = u, U => t, T") + call whizard%command ("process api_7_p2 = d, D => t, T") + call whizard%command ("process api_7_p3 = s, S => t, T") + + call whizard%set_var ("sqrts", 1000._real64) + call whizard%command ("beams = p, p => pdf_builtin") + call whizard%set_var ("?alphas_is_fixed", .false.) + call whizard%set_var ("?alphas_from_pdf_builtin", .true.) + call whizard%command ("iterations = 1:100") + call whizard%set_var ("seed", 0_int32) + call whizard%command ("integrate (api_7_p1)") + call whizard%command ("integrate (api_7_p2)") + call whizard%command ("integrate (api_7_p3)") + + call whizard%set_var ("?unweighted", .false.) + call whizard%set_var ("$sample", "api_7_evt") + call whizard%command ("sample_format = dump") + call whizard%set_var ("n_events", 10_int32) + + call whizard%new_sample ("api_7_p1, api_7_p2 ,api_7_p3", sample) + call sample%open (it_begin, it_end) + do i = it_begin, it_end + call sample%next_event () + call sample%get_event_index (idx) + call sample%get_process_index (i_proc) + call sample%get_process_id (proc_id) + call sample%get_sqrts (sqrts) + call sample%get_fac_scale (scale) + call sample%get_alpha_s (alpha_s) + call sample%get_weight (weight) + call sample%get_sqme (sqme) + write (u, "(A,I0)") "Event #", idx + write (u, 1) "process #", i_proc + write (u, 2) "proc_id =", proc_id + write (u, 3) "sqrts =", sqrts + write (u, 3) "f_scale =", scale + write (u, 3) "alpha_s =", alpha_s + write (u, 3) "sqme =", sqme + write (u, 3) "weight =", weight +1 format (2x,A,I0) +2 format (2x,A,1x,A) +3 format (2x,A,1x,ES10.3) + end do + call sample%close () + + call whizard%final () + + write (u, "(A)") + write (u, "(A)") "* Test output end: api_7" + + end subroutine api_7 + +@ %def api_7 +@ +\subsubsection{API: extra options} +Check support for extra (not so common) options that would be given on the +command line. +<>= + call test (api_8, "api_8", & + "check pack/unpack options", & + u, results) +<>= + public :: api_8 +<>= + subroutine api_8 (u) + integer, intent(in) :: u + type(whizard_api_t) :: whizard + + character(:), allocatable :: logfile + integer :: u_log + integer :: iostat + character(80) :: buffer + + character(:), allocatable :: pack_args + character(:), allocatable :: unpack_args + + write (u, "(A)") "* Test output: api_8" + write (u, "(A)") "* Purpose: check pack/unpack options" + write (u, "(A)") + + logfile = "api_8_log.out" + call whizard%option ("logfile", logfile) + call whizard%option ("pack", "api_8_foo") + call whizard%option ("unpack", "api_8_bar.tgz, api_8_gee.tgz") + call whizard%init () + call msg_message ("WHIZARD: Intentional errors: pack/unpack files do not exist") + + call whizard%final () + + open (newunit = u_log, file = logfile, action = "read", status = "old") + do + read (u_log, "(A)", iostat=iostat) buffer + if (iostat /= 0) exit + if (buffer(1:10) == "| WHIZARD:") write (u, "(A)") trim (buffer) + if (buffer(1:10) == "*** ERROR:") write (u, "(A)") trim (buffer) + end do + close (u_log) + + write (u, "(A)") + write (u, "(A)") "* Test output end: api_8" + + end subroutine api_8 + +@ %def api_8 +@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\subsection{Unit tests: HepMC interface} +Test module, followed by the corresponding implementation module. +<<[[api_hepmc_ut.f90]]>>= +<> + +module api_hepmc_ut + use unit_tests + use system_dependencies, only: HEPMC2_AVAILABLE + use system_dependencies, only: HEPMC3_AVAILABLE + use api_hepmc_uti + +<> + +<> + +contains + +<> + +end module api_hepmc_ut +@ %def api_hepmc_ut +@ +<<[[api_hepmc_uti.f90]]>>= +<> + +module api_hepmc_uti + + use iso_fortran_env, only: int32, real64 !NODEP! + use hepmc_interface, only: hepmc_event_t + + use api + +<> + +<> + +contains + +<> + +end module api_hepmc_uti +@ %def api_hepmc_ut +@ API/HEPMC: driver for the unit tests below. +<>= + public :: api_hepmc_test +<>= + subroutine api_hepmc_test (u, results) + integer, intent(in) :: u + type(test_results_t), intent(inout) :: results + <> + end subroutine api_hepmc_test + +@ %def api_hepmc_test +@ +\subsubsection{HepMC2/HepMC3 interface test} +Declare a process and generate two events. Access the events via an HepMC3 +(or HepMC2) object. +<>= + if (HEPMC2_AVAILABLE) then + call test (api_hepmc_1, "api_hepmc2_1", & + "HepMC2 interface", & + u, results) + else if (HEPMC3_AVAILABLE) then + call test (api_hepmc_1, "api_hepmc3_1", & + "HepMC3 interface", & + u, results) + end if +<>= + public :: api_hepmc_1 +<>= + subroutine api_hepmc_1 (u) + use hepmc_interface, only: hepmc_event_get_event_index + use hepmc_interface, only: hepmc_event_get_n_particles + use hepmc_interface, only: hepmc_event_print + use hepmc_interface, only: hepmc_event_final + integer, intent(in) :: u + + type(whizard_api_t) :: whizard + type(simulation_api_t) :: sample + + integer :: it_begin, it_end + integer :: i + integer(int32) :: idx, npt + + type(hepmc_event_t) :: hepmc_event + + write (u, "(A)") "* Test output: api_hepmc_1" + write (u, "(A)") "* Purpose: generate events" + write (u, "(A)") + + call whizard%option ("model", "QED") + call whizard%option ("library", "api_hepmc_1_lib") + call whizard%option ("logfile", "api_hepmc_1_log.out") + call whizard%option ("rebuild", "T") + call whizard%init () + + call whizard%command ("process api_hepmc_1_p = e1, E1 => e2, E2") + + call whizard%set_var ("sqrts", 10._real64) + call whizard%command ("iterations = 1:100") + call whizard%set_var ("seed", 0_int32) + call whizard%command ("integrate (api_hepmc_1_p)") + + call whizard%set_var ("?unweighted", .false.) + call whizard%set_var ("$sample", "api_hepmc_1_evt") + call whizard%command ("sample_format = hepmc") + call whizard%set_var ("n_events", 2_int32) + + call whizard%new_sample ("api_hepmc_1_p", sample) + call sample%open (it_begin, it_end) + do i = it_begin, it_end + call sample%next_event (hepmc_event) + idx = hepmc_event_get_event_index (hepmc_event) + npt = hepmc_event_get_n_particles (hepmc_event) + call hepmc_event_print (hepmc_event) + write (u, "(A,I0)") "Event #", idx + write (u, "(2x,A,1x,I0)") "n_particles =", npt + call hepmc_event_final (hepmc_event) + end do + call sample%close () + + call whizard%final () + + write (u, "(A)") + write (u, "(A)") "* Test output end: api_hepmc_1" + + end subroutine api_hepmc_1 + +@ %def api_hepmc_1 +@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\subsection{Unit tests: LCIO interface} +Test module, followed by the corresponding implementation module. +<<[[api_lcio_ut.f90]]>>= +<> + +module api_lcio_ut + use unit_tests + use system_dependencies, only: LCIO_AVAILABLE + use api_lcio_uti + +<> + +<> + +contains + +<> + +end module api_lcio_ut +@ %def api_lcio_ut +@ +<<[[api_lcio_uti.f90]]>>= +<> + +module api_lcio_uti + + use iso_fortran_env, only: int32, real64 !NODEP! + use lcio_interface, only: lcio_event_t + + use api + +<> + +<> + +contains + +<> + +end module api_lcio_uti +@ %def api_lcio_ut +@ API/LCIO: driver for the unit tests below. +<>= + public :: api_lcio_test +<>= + subroutine api_lcio_test (u, results) + integer, intent(in) :: u + type(test_results_t), intent(inout) :: results + <> + end subroutine api_lcio_test + +@ %def api_lcio_test +@ +\subsubsection{LCIO interface test} +Declare a process and generate two events. Access the events via an Lcio +object. +<>= + if (LCIO_AVAILABLE) then + call test (api_lcio_1, "api_lcio_1", & + "LCIO interface", & + u, results) + end if +<>= + public :: api_lcio_1 +<>= + subroutine api_lcio_1 (u) + use lcio_interface, only: lcio_event_get_event_index + use lcio_interface, only: lcio_event_get_n_tot + use lcio_interface, only: show_lcio_event + use lcio_interface, only: lcio_event_final + integer, intent(in) :: u + + type(whizard_api_t) :: whizard + type(simulation_api_t) :: sample + + integer :: it_begin, it_end + integer :: i + integer(int32) :: idx, npt + + type(lcio_event_t) :: lcio_event + + write (u, "(A)") "* Test output: api_lcio_1" + write (u, "(A)") "* Purpose: generate events" + write (u, "(A)") + + call whizard%option ("model", "QED") + call whizard%option ("library", "api_lcio_1_lib") + call whizard%option ("logfile", "api_lcio_1_log.out") + call whizard%option ("rebuild", "T") + call whizard%init () + + call whizard%command ("process api_lcio_1_p = e1, E1 => e2, E2") + + call whizard%set_var ("sqrts", 10._real64) + call whizard%command ("iterations = 1:100") + call whizard%set_var ("seed", 0_int32) + call whizard%command ("integrate (api_lcio_1_p)") + + call whizard%set_var ("?unweighted", .true.) + call whizard%set_var ("$sample", "api_lcio_1_evt") + call whizard%command ("sample_format = lcio") + call whizard%set_var ("n_events", 2_int32) + + call whizard%new_sample ("api_lcio_1_p", sample) + call sample%open (it_begin, it_end) + do i = it_begin, it_end + call sample%next_event (lcio_event) + idx = lcio_event_get_event_index (lcio_event) + npt = lcio_event_get_n_tot (lcio_event) + call show_lcio_event (lcio_event) + write (u, "(A,I0)") "Event #", idx + write (u, "(2x,A,1x,I0)") "n_particles =", npt + call lcio_event_final (lcio_event) + end do + call sample%close () + + call whizard%final () + + write (u, "(A)") + write (u, "(A)") "* Test output end: api_lcio_1" + + end subroutine api_lcio_1 + +@ %def api_lcio_1 +@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{C API} + +The C and C++ APIs share a common header file. We use the [[__cplusplus]] +macro to adapt to the different language environments. + +The C API is implemented in Fortran subroutines with a [[bind(C)]] attribute. +Apart from the header file, there is no C glue code involved, and we can +implement unit tests in C directly. We use interoperable ISO types for +communication. Arrays and strings are transmitted as plain-C array pointers. + +The C++ API adds an object-oriented interface which makes use of the C++ +library types [[string]] and [[vector]]. + +\subsection{C/C++ Header File} +For the C side, the (single!) \whizard\ API object becomes a [[void*]] +pointer. Since the object itself is not C interoperable, we require an extra +[[new_whizard_object]] procedure that creates this object. Then, we can set +options and activate the object by the [[whizard_init]] call. +<<[[whizard.h]]>>= +/* Public API */ + +/* **************************************************************** */ +/* Plain C part, interfaces with Fortran bind(C) procedures */ +#ifdef __cplusplus +extern "C" { +#endif + + typedef void* whizard_t; + typedef void* sample_handle_t; + +<> + +#ifdef __cplusplus +} +#endif + +/* **************************************************************** */ +/* C++ part: wrapper classes for Whizard API objects */ + +#ifdef __cplusplus + +<> + +<> + +#endif +@ %def whizard.h +@ +@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\subsection{Fortran implementation of the interface} +This is the Fortran source for the implementation of the C interface, as +declared in [[whizard.h]]. +<<[[api_c.f90]]>>= +<> + +!!! ************************************************************ +!!! Below: procedures used for intrinsic tests only +<> +@ %def api_c +@ +\subsubsection{Initialization/finalization} +Create the \whizard\ object so the pointer becomes valid. +<>= +void whizard_create (void* wh); +<>= +subroutine whizard_create (whizard_handle) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_loc !NODEP! + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(inout) :: whizard_handle + type(whizard_api_t), pointer :: whizard + + allocate (whizard) + whizard_handle = c_loc (whizard) + +end subroutine whizard_create + +@ %def whizard_create +@ +Set an option before initialization. +<>= +void whizard_option (void* wh, const char* key, const char* value); +<>= +subroutine whizard_option (whizard_handle, key, value) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use string_utils, only: string_c2f + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(inout) :: whizard_handle + character(c_char), dimension(*), intent(in) :: key + character(c_char), dimension(*), intent(in) :: value + + type(whizard_api_t), pointer :: whizard + + call c_f_pointer (whizard_handle, whizard) + call whizard%option (string_c2f (key), string_c2f (value)) + +end subroutine whizard_option + +@ %def whizard_option +@ +Initialize the \whizard\ object, after options have been set. +<>= +void whizard_init (void* wh); +<>= +subroutine whizard_init (whizard_handle) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + type(whizard_api_t), pointer :: whizard + + call c_f_pointer (whizard_handle, whizard) + call whizard%init () + +end subroutine whizard_init + +@ %def whizard_init +@ +Finalize the \whizard\ object and deallocate the pointer. +<>= +void whizard_final (void* wh); + +<>= +subroutine whizard_final (whizard_handle) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + + type(whizard_api_t), pointer :: whizard + + call c_f_pointer (whizard_handle, whizard) + call whizard%final () + deallocate (whizard) + +end subroutine whizard_final + + +@ %def whizard_final +@ +\subsubsection{Variables} +Set Sindarin variables directly. +<>= +void whizard_set_double (void* wh, const char* var, const double value); +void whizard_set_int (void* wh, const char* var, const int value); +void whizard_set_bool (void* wh, const char* var, const int value); +void whizard_set_char (void* wh, const char* var, const char* value); +<>= +subroutine whizard_set_double (whizard_handle, var, value) bind (C) + use iso_fortran_env, only: real64 !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_double !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use string_utils, only: string_c2f + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + character(c_char), dimension(*), intent(in) :: var + real(c_double), intent(in), value :: value + + type(whizard_api_t), pointer :: whizard + + call c_f_pointer (whizard_handle, whizard) + call whizard%set_var (string_c2f (var), real (value, real64)) + +end subroutine whizard_set_double + +subroutine whizard_set_int (whizard_handle, var, value) bind (C) + use iso_fortran_env, only: int32 !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use string_utils, only: string_c2f + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + character(c_char), dimension(*), intent(in) :: var + integer(c_int), intent(in), value :: value + + type(whizard_api_t), pointer :: whizard + + call c_f_pointer (whizard_handle, whizard) + call whizard%set_var (string_c2f (var), int (value, int32)) + +end subroutine whizard_set_int + +subroutine whizard_set_bool (whizard_handle, var, value) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use string_utils, only: string_c2f + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + character(c_char), dimension(*), intent(in) :: var + integer(c_int), intent(in), value :: value + + type(whizard_api_t), pointer :: whizard + + call c_f_pointer (whizard_handle, whizard) + call whizard%set_var (string_c2f (var), value /= 0) + +end subroutine whizard_set_bool + +subroutine whizard_set_char (whizard_handle, var, value) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use string_utils, only: string_c2f + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + character(c_char), dimension(*), intent(in) :: var + character(c_char), dimension(*), intent(in) :: value + + type(whizard_api_t), pointer :: whizard + + call c_f_pointer (whizard_handle, whizard) + call whizard%set_var (string_c2f (var), string_c2f (value)) + +end subroutine whizard_set_char + +@ %def whizard_set_double +@ %def whizard_set_int +@ %def whizard_set_bool +@ %def whizard_set_char +@ +Retrieve the values of Sindarin variables. The [[int]] return value is +nonzero if the Sindarin value is unknown. + +For the character-string case, we have a separate function that returns the +length, so the caller can allocate the array accordingly. +<>= +int whizard_get_double (void* wh, const char* var, double* value); +int whizard_get_int (void* wh, const char* var, int* value); +int whizard_get_bool (void* wh, const char* var, int* value); +int whizard_get_char (void* wh, const char* var, char* value, const int strlen); +int whizard_get_char_len (void* wh, const char* var); + +<>= +function whizard_get_double (whizard_handle, var, value) result (stat) bind (C) + use iso_fortran_env, only: real64 !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_double !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use string_utils, only: string_c2f + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + character(c_char), dimension(*), intent(in) :: var + real(c_double), intent(inout) :: value + integer(c_int) :: stat + + type(whizard_api_t), pointer :: whizard + logical :: known + real(real64) :: v + + call c_f_pointer (whizard_handle, whizard) + call whizard%get_var (string_c2f (var), v, known) + if (known) then + value = v + stat = 0 + else + value = 0 + stat = 1 + end if + +end function whizard_get_double + +function whizard_get_int (whizard_handle, var, value) result (stat) bind (C) + use iso_fortran_env, only: int32 !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use string_utils, only: string_c2f + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + character(c_char), dimension(*), intent(in) :: var + integer(c_int), intent(inout) :: value + integer(c_int) :: stat + + type(whizard_api_t), pointer :: whizard + logical :: known + integer(int32) :: v + + call c_f_pointer (whizard_handle, whizard) + call whizard%get_var (string_c2f (var), v, known) + if (known) then + value = v + stat = 0 + else + value = 0 + stat = 1 + end if + +end function whizard_get_int + +function whizard_get_bool (whizard_handle, var, value) result (stat) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use string_utils, only: string_c2f + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + character(c_char), dimension(*), intent(in) :: var + integer(c_int), intent(inout) :: value + integer(c_int) :: stat + + type(whizard_api_t), pointer :: whizard + logical :: known + logical :: v + + call c_f_pointer (whizard_handle, whizard) + call whizard%get_var (string_c2f (var), v, known) + if (known) then + if (v) then + value = 1 + else + value = 0 + end if + stat = 0 + else + value = 0 + stat = 1 + end if + +end function whizard_get_bool + +function whizard_get_char (whizard_handle, var, value, strlen) result (stat) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use string_utils, only: string_c2f + use string_utils, only: strcpy_f2c + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + character(c_char), dimension(*), intent(in) :: var + character(c_char), dimension(*), intent(inout) :: value + integer(c_int), value :: strlen + integer(c_int) :: stat + + type(whizard_api_t), pointer :: whizard + logical :: known + character(:), allocatable :: v + + call c_f_pointer (whizard_handle, whizard) + call whizard%get_var_character (string_c2f (var), v, known, strlen-1) + if (known) then + call strcpy_f2c (v, value) + stat = 0 + else + call strcpy_f2c ("", value) + stat = 1 + end if + +end function whizard_get_char + +function whizard_get_char_len (whizard_handle, var) result (strlen) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use string_utils, only: string_c2f + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + character(c_char), dimension(*), intent(in) :: var + integer(c_int) :: strlen + + type(whizard_api_t), pointer :: whizard + + call c_f_pointer (whizard_handle, whizard) + strlen = whizard%get_var_character_length (string_c2f (var)) + 1 + +end function whizard_get_char_len + +@ %def whizard_get_double +@ %def whizard_get_int +@ %def whizard_get_bool +@ %def whizard_get_char +@ %def whizard_get_char_len +@ +\subsubsection{PDG Translation} +Translate a PDG value or an array (with length passed separately) to a +character string. Again, we have separate functions that return the string +length. The return value is nonzero if the allowed string length was too +short. +<>= +int whizard_flv_string (void* wh, const int pdg, char* fstr, const int strlen); +int whizard_flv_string_len (void* wh, const int pdg); +int whizard_flv_array_string (void* wh, const int* pdg, const int nf, char* fstr, const int strlen); +int whizard_flv_array_string_len (void* wh, const int* pdg, const int nf); + +<>= +function whizard_flv_string (whizard_handle, pdg, fstr, strlen) result (stat) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use string_utils, only: strcpy_f2c + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + integer(c_int), value :: pdg + character(c_char), dimension(*), intent(inout) :: fstr + integer(c_int), value :: strlen + integer(c_int) :: stat + + type(whizard_api_t), pointer :: whizard + character(:), allocatable :: v + + call c_f_pointer (whizard_handle, whizard) + v = whizard%flv_string (pdg) + if (len (v) < strlen) then + call strcpy_f2c (v, fstr) + stat = 0 + else + call strcpy_f2c ("", fstr) + stat = 1 + end if + +end function whizard_flv_string + +function whizard_flv_string_len (whizard_handle, pdg) result (strlen) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + integer(c_int), value :: pdg + integer(c_int) :: strlen + + type(whizard_api_t), pointer :: whizard + + call c_f_pointer (whizard_handle, whizard) + strlen = len (whizard%flv_string (pdg)) + 1 + +end function whizard_flv_string_len + +function whizard_flv_array_string (whizard_handle, pdg, nf, fstr, strlen) result (stat) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use string_utils, only: strcpy_f2c + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + integer(c_int), dimension(*), intent(in) :: pdg + integer(c_int), value :: nf + character(c_char), dimension(*), intent(inout) :: fstr + integer(c_int), value :: strlen + integer(c_int) :: stat + + type(whizard_api_t), pointer :: whizard + character(:), allocatable :: v + + call c_f_pointer (whizard_handle, whizard) + v = whizard%flv_string (pdg(1:nf)) + if (len (v) < strlen) then + call strcpy_f2c (v, fstr) + stat = 0 + else + call strcpy_f2c ("", fstr) + stat = 1 + end if + +end function whizard_flv_array_string + +function whizard_flv_array_string_len (whizard_handle, pdg, nf) result (strlen) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + integer(c_int), dimension(*), intent(in) :: pdg + integer(c_int), value :: nf + integer(c_int) :: strlen + + type(whizard_api_t), pointer :: whizard + + call c_f_pointer (whizard_handle, whizard) + strlen = len (whizard%flv_string (pdg(1:nf))) + 1 + +end function whizard_flv_array_string_len + +@ %def whizard_flv_string +@ %def whizard_flv_string_len +@ %def whizard_flv_array_string +@ %def whizard_flv_array_string_len +@ +\subsubsection{\whizard\ Commands} +Issue a \whizard\ command. +<>= +void whizard_command (void* wh, const char* cmd); +<>= +subroutine whizard_command (whizard_handle, cmd) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use string_utils, only: string_c2f + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + character(c_char), dimension(*), intent(in) :: cmd + + type(whizard_api_t), pointer :: whizard + + call c_f_pointer (whizard_handle, whizard) + call whizard%command (string_c2f (cmd)) + +end subroutine whizard_command + +@ %def whizard_command +@ +\subsubsection{Integration Results} +Return the results of an integration pass. The return value is nonzero if the +integration results are not (yet) available. +<>= +int whizard_get_integration_result (void* wh, const char* proc_id, double* integral, double* error); + +<>= +function whizard_get_integration_result (whizard_handle, proc_id, integral, error) result (stat) bind (C) + use iso_fortran_env, only: real64 !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_double !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use string_utils, only: string_c2f + use api, only: whizard_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + character(c_char), dimension(*), intent(in) :: proc_id + real(c_double), intent(inout) :: integral + real(c_double), intent(inout) :: error + integer(c_int) :: stat + + type(whizard_api_t), pointer :: whizard + logical :: known + real(real64) :: int, err + + call c_f_pointer (whizard_handle, whizard) + call whizard%get_integration_result (string_c2f (proc_id), int, err, known) + if (known) then + integral = int + error = err + stat = 0 + else + integral = 0 + error = 0 + stat = 1 + end if + +end function whizard_get_integration_result + +@ %def whizard_get_integration_result +@ +\subsubsection{Event Sample Init/Final} +Create a new sample object, returned via a C-pointer handle. +<>= +void whizard_new_sample (void* wh, const char* name, void* sample); +<>= +subroutine whizard_new_sample (whizard_handle, name, sample_handle) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use iso_c_binding, only: c_loc !NODEP! + use string_utils, only: string_c2f + use api, only: whizard_api_t + use api, only: simulation_api_t + + implicit none + + type(c_ptr), intent(in) :: whizard_handle + character(c_char), dimension(*), intent(in) :: name + type(c_ptr), intent(inout) :: sample_handle + + type(whizard_api_t), pointer :: whizard + type(simulation_api_t), pointer :: sample + + call c_f_pointer (whizard_handle, whizard) + allocate (sample) + sample_handle = c_loc (sample) + call whizard%new_sample (string_c2f (name), sample) + +end subroutine whizard_new_sample + +@ %def whizard_new_sample +@ +Operations for event generation: open, advance, and close the event loop. +<>= +void whizard_sample_open (void* sample, int* it_begin, int* it_end); +void whizard_sample_next_event (void* sample); +void whizard_sample_close (void* sample); + +<>= +subroutine whizard_sample_open (sample_handle, it_begin, it_end) bind (C) + use iso_fortran_env, only: int32 !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use api, only: simulation_api_t + + type(c_ptr), intent(inout) :: sample_handle + integer(c_int), intent(inout) :: it_begin + integer(c_int), intent(inout) :: it_end + + type(simulation_api_t), pointer :: sample + integer(int32) :: it_b, it_e + + call c_f_pointer (sample_handle, sample) + call sample%open (it_b, it_e) + it_begin = it_b + it_end = it_e + +end subroutine whizard_sample_open + +subroutine whizard_sample_next_event (sample_handle) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use api, only: simulation_api_t + + type(c_ptr), intent(inout) :: sample_handle + + type(simulation_api_t), pointer :: sample + + call c_f_pointer (sample_handle, sample) + call sample%next_event () + +end subroutine whizard_sample_next_event + +subroutine whizard_sample_close (sample_handle) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use api, only: simulation_api_t + + type(c_ptr), intent(inout) :: sample_handle + + type(simulation_api_t), pointer :: sample + + call c_f_pointer (sample_handle, sample) + call sample%close () + deallocate (sample) + +end subroutine whizard_sample_close + +@ %def whizard_sample_open +@ %def whizard_sample_next_event +@ %def whizard_sample_close +@ +Extra handler for HepMC events. This is available for C++ only. The Fortran +function returns a C pointer, which is supposed to be the pointer to a +[[GenEvent]] object. +<>= +#ifdef WHIZARD_WITH_HEPMC3 +#include "HepMC3/GenEvent.h" +extern "C" { +HepMC3::GenEvent* whizard_sample_next_event_hepmc( void* sample ); +} +#endif +#ifdef WHIZARD_WITH_HEPMC2 +#include "HepMC/GenEvent.h" +extern "C" { +HepMC::GenEvent* whizard_sample_next_event_hepmc( void* sample ); +} +#endif + +<>= +function whizard_sample_next_event_hepmc (sample_handle) result (evt) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use hepmc_interface, only: hepmc_event_t + use hepmc_interface, only: hepmc_event_get_c_ptr + use api, only: simulation_api_t + + type(c_ptr), intent(inout) :: sample_handle + type(c_ptr) :: evt + + type(simulation_api_t), pointer :: sample + type(hepmc_event_t) :: hepmc_event + + call c_f_pointer (sample_handle, sample) + call sample%next_event (hepmc_event) + evt = hepmc_event_get_c_ptr (hepmc_event) + +end function whizard_sample_next_event_hepmc + +@ %def whizard_sample_next_event_hepmc +@ +Extra handler for LCIO events. This is available for C++ only. The Fortran +function returns a C pointer, which is supposed to be the pointer to a +[[LCEvent]] object. +<>= +#ifdef WHIZARD_WITH_LCIO +#include "lcio.h" +extern "C" { +lcio::LCEvent* whizard_sample_next_event_lcio( void* sample ); +} +#endif + +<>= +function whizard_sample_next_event_lcio (sample_handle) result (evt) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use lcio_interface, only: lcio_event_t + use lcio_interface, only: lcio_event_get_c_ptr + use api, only: simulation_api_t + + type(c_ptr), intent(inout) :: sample_handle + type(c_ptr) :: evt + + type(simulation_api_t), pointer :: sample + type(lcio_event_t) :: lcio_event + + call c_f_pointer (sample_handle, sample) + call sample%next_event (lcio_event) + evt = lcio_event_get_c_ptr (lcio_event) + +end function whizard_sample_next_event_lcio + +@ %def whizard_sample_next_event_lcio +@ +\subsubsection{Event Data} +Return information for the current event, after [[next_event]] has been called. +Implemented as subroutines, so we can do the character-string case as usual. +<>= +void whizard_sample_get_event_index (void* sample, int* idx); +void whizard_sample_get_process_index (void* sample, int* i_proc); +void whizard_sample_get_process_id (void* sample, char* proc_id, const int strlen); +int whizard_sample_get_process_id_len (void* sample); +void whizard_sample_get_fac_scale (void* sample, double* f_scale); +void whizard_sample_get_alpha_s (void* sample, double* alpha_s); +void whizard_sample_get_weight (void* sample, double* weight); +void whizard_sample_get_sqme (void* sample, double* sqme); +<>= +subroutine whizard_sample_get_event_index (sample_handle, idx) bind (C) + use iso_fortran_env, only: int32 !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use api, only: simulation_api_t + + implicit none + + type(c_ptr), intent(inout) :: sample_handle + integer(c_int), intent(inout) :: idx + + type(simulation_api_t), pointer :: sample + integer(int32) :: i + + call c_f_pointer (sample_handle, sample) + call sample%get_event_index (i) + idx = i + +end subroutine whizard_sample_get_event_index + +subroutine whizard_sample_get_process_index (sample_handle, i_proc) bind (C) + use iso_fortran_env, only: int32 !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use api, only: simulation_api_t + + implicit none + + type(c_ptr), intent(inout) :: sample_handle + integer(c_int), intent(inout) :: i_proc + + type(simulation_api_t), pointer :: sample + integer(int32) :: i + + call c_f_pointer (sample_handle, sample) + call sample%get_process_index (i) + i_proc = i + +end subroutine whizard_sample_get_process_index + +subroutine whizard_sample_get_process_id (sample_handle, proc_id, strlen) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use string_utils, only: strcpy_f2c + use api, only: simulation_api_t + + implicit none + + type(c_ptr), intent(inout) :: sample_handle + character(c_char), dimension(*), intent(inout) :: proc_id + integer(c_int), value :: strlen + + type(simulation_api_t), pointer :: sample + character(:), allocatable :: p_id + + call c_f_pointer (sample_handle, sample) + call sample%get_process_id (p_id) + if (len (p_id) < strlen) then + call strcpy_f2c (p_id, proc_id) + else + call strcpy_f2c (p_id(1:strlen-1), proc_id) + end if + +end subroutine whizard_sample_get_process_id + +function whizard_sample_get_process_id_len (sample_handle) result (strlen) bind (C) + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use api, only: simulation_api_t + + implicit none + + type(c_ptr), intent(inout) :: sample_handle + integer(c_int) :: strlen + + type(simulation_api_t), pointer :: sample + character(:), allocatable :: p_id + + call c_f_pointer (sample_handle, sample) + call sample%get_process_id (p_id) + strlen = len (p_id) + +end function whizard_sample_get_process_id_len + +subroutine whizard_sample_get_fac_scale (sample_handle, f_scale) bind (C) + use iso_fortran_env, only: real64 !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_double !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use api, only: simulation_api_t + + implicit none + + type(c_ptr), intent(inout) :: sample_handle + real(c_double), intent(inout) :: f_scale + + type(simulation_api_t), pointer :: sample + real(real64) :: s + + call c_f_pointer (sample_handle, sample) + call sample%get_fac_scale (s) + f_scale = s + +end subroutine whizard_sample_get_fac_scale + +subroutine whizard_sample_get_alpha_s (sample_handle, alpha_s) bind (C) + use iso_fortran_env, only: real64 !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_double !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use api, only: simulation_api_t + + implicit none + + type(c_ptr), intent(inout) :: sample_handle + real(c_double), intent(inout) :: alpha_s + + type(simulation_api_t), pointer :: sample + real(real64) :: a + + call c_f_pointer (sample_handle, sample) + call sample%get_alpha_s (a) + alpha_s = a + +end subroutine whizard_sample_get_alpha_s + +subroutine whizard_sample_get_weight (sample_handle, weight) bind (C) + use iso_fortran_env, only: real64 !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_double !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use api, only: simulation_api_t + + implicit none + + type(c_ptr), intent(inout) :: sample_handle + real(c_double), intent(inout) :: weight + + type(simulation_api_t), pointer :: sample + real(real64) :: w + + call c_f_pointer (sample_handle, sample) + call sample%get_weight (w) + weight = w + +end subroutine whizard_sample_get_weight + +subroutine whizard_sample_get_sqme (sample_handle, sqme) bind (C) + use iso_fortran_env, only: real64 !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_double !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use api, only: simulation_api_t + + implicit none + + type(c_ptr), intent(inout) :: sample_handle + real(c_double), intent(inout) :: sqme + + type(simulation_api_t), pointer :: sample + real(real64) :: s + + call c_f_pointer (sample_handle, sample) + call sample%get_sqme (s) + sqme = s + +end subroutine whizard_sample_get_sqme + +@ %def whizard_sample_get_event_index +@ %def whizard_sample_get_process_index +@ %def whizard_sample_get_process_id +@ %def whizard_sample_get_process_id_len +@ %def whizard_sample_get_fac_scale +@ %def whizard_sample_get_alpha_s +@ %def whizard_sample_get_weight +@ %def whizard_sample_get_sqme +@ +\section{C API: Unit-Test Tools} +The C/C++ interface is guarded by a unit-test suite which parallels the set of +Fortran-API unit tests. We want to handle all tests on the same footing. We +provide a separate API (in C and in C++) that interfaces the unit-test tools +that we are using for the main program. + +The main programs for the C and C++ test suites are stand-alone. + +\subsection{C/C++ Header File for Unit Tests} +<<[[whizard_ut.h]]>>= +/* API for executing WHIZARD unit tests */ + +/* **************************************************************** */ +/* Plain C part, interfaces with Fortran bind(C) procedures */ + +#ifdef __cplusplus +extern "C" { +#endif + +<> + +#ifdef __cplusplus +} +#endif + +/* **************************************************************** */ +/* C++ part: wrapper class for Fortran test utilities */ + +#ifdef __cplusplus + +<> + +#endif +@ %def whizard_ut.h +@ +\subsection{C Driver for Unit Tests} +We define a test driver which is analogous to the Fortran test driver. There +is somewhat less sophistication because we only need this for one test suite. +<<[[api_ut_c.c]]>>= +#include +#include "whizard.h" +#include "whizard_ut.h" +<> + +<> + +int main( int argc, char* argv[] ) +{ + int u_log; + void* results; + int n_fail; + + printf( "| ============================================================================\n" ); + printf( "| Running WHIZARD self-test: api_c with C driver program\n" ); + printf( "| ----------------------------------------------------------------------------\n" ); + + whizard_ut_setup( "api_c", &u_log, &results ); + +<> + +<> + +<> + + n_fail = whizard_ut_get_n_fail( &results ); + + whizard_ut_wrapup( u_log, &results ); + + printf( "| ----------------------------------------------------------------------------\n" ); + printf( "| Finished WHIZARD self-test: api_c with C driver program\n" ); + printf( "| ============================================================================\n" ); + + return n_fail; +} +@ %def api_ut_c +@ +\subsubsection{MPI specifics} +Need the MPI header file. +<>= +<>= +#include "mpi.h" +@ +Call MPI init before any MPI calls can occur +<>= +<>= + MPI_Init( &argc, &argv ); +@ +Call MPI finalize after all tests +<>= +<>= + MPI_Finalize(); +@ +\subsubsection{Minimal test} +This test does initialization and finalization, with basic options. +<>= + api_ut_c_1( u_log, results ); +<>= + void api_ut_c_1( int u_log, void* results ) { + + void* wh; + + whizard_ut_start (u_log, "api_c_1"); + FILE *outfile; + outfile = fopen( "api_c_1.out", "w" ); + + fprintf (outfile, "* Test output: api_c_1\n"); + fprintf (outfile, "* Purpose: call init/final\n"); + fprintf (outfile, "\n"); + + fprintf (outfile, "* Creating WHIZARD object handle\n"); + whizard_create (&wh); + + fprintf (outfile, "* Setting options\n"); + whizard_option (&wh, "logfile", "api_c_1.log"); + + fprintf (outfile, "* Initializing WHIZARD\n"); + whizard_init (&wh); + + fprintf (outfile, "* Finalizing WHIZARD\n"); + whizard_final (&wh); + + fprintf (outfile, "\n"); + fprintf (outfile, "* Test output end: api_c_1\n"); + + fclose (outfile); + whizard_ut_end (u_log, "api_c_1", "basic init/final", &results); + + } +@ %def api_ut_c_1 +@ +\subsubsection{Variables} +This test sets and retrieves values of Sindarin variables. +<>= + api_ut_c_2( u_log, results ); +<>= + void api_ut_c_2( int u_log, void* results ) { + + void* wh; + + int err; + char job_id[16]; + double sqrts; + int n_events; + int unweighted; + char sample[16]; + + whizard_ut_start (u_log, "api_c_2"); + FILE *outfile; + outfile = fopen( "api_c_2.out", "w" ); + + fprintf (outfile, "* Test output: api_c_2\n"); + fprintf (outfile, "* Purpose: access Sindarin variables\n"); + fprintf (outfile, "\n"); + + whizard_create (&wh); + whizard_option (&wh, "logfile", "api_c_2_log.out"); + whizard_option (&wh, "job_id", "api_c_2_ID"); + whizard_init (&wh); + + err = whizard_get_char (&wh, "$job_id", job_id, 16); + if (!err) fprintf (outfile, "$job_id = %s\n", job_id); + + err = whizard_get_double (&wh, "sqrts", &sqrts); + if (!err) { + fprintf (outfile, "sqrts = %5.1f\n", sqrts); + } else { + fprintf (outfile, "sqrts = [unknown]\n", sqrts); + } + + fprintf (outfile, "\n"); + + whizard_set_double (&wh, "sqrts", 100.); + whizard_set_int (&wh, "n_events", 3); + whizard_set_bool (&wh, "?unweighted", 0); + whizard_set_char (&wh, "$sample", "foobar"); + + err = whizard_get_double (&wh, "sqrts", &sqrts); + if (!err) fprintf (outfile, "sqrts = %5.1f\n", sqrts); + + err = whizard_get_int (&wh, "n_events", &n_events); + if (!err) fprintf (outfile, "n_events = %1d\n", n_events); + + err = whizard_get_bool (&wh, "?unweighted", &unweighted); + if (!err) fprintf (outfile, "?unweighted = %1d\n", unweighted); + + err = whizard_get_char (&wh, "$sample", sample, 16); + if (!err) fprintf (outfile, "$sample = %s\n", sample); + + fprintf (outfile, "\n"); + + whizard_set_bool (&wh, "?unweighted", 1); + whizard_get_bool (&wh, "?unweighted", &unweighted); + fprintf (outfile, "?unweighted = %1d\n", unweighted); + whizard_get_char (&wh, "$sample", sample, 4); + fprintf (outfile, "$sample = %s\n", sample); + + whizard_final (&wh); + + fprintf (outfile, "\n"); + fprintf (outfile, "* Test output end: api_c_2\n"); + + fclose (outfile); + whizard_ut_end (u_log, "api_c_2", "set/get Sindarin values", &results); + + } +@ %def api_ut_c_2 +@ +\subsubsection{Flavor string} +Use the flavor-string convenience translation. +<>= + api_ut_c_3( u_log, results ); +<>= + void api_ut_c_3( int u_log, void* results ) { + + void* wh; + + #define NF 3 + #define CLEN 16 + + int err; + int f = 11; + int fa[NF] = {11, 13, 15}; + char electron[CLEN]; + char leptons[CLEN]; + + whizard_ut_start (u_log, "api_c_3"); + FILE *outfile; + outfile = fopen( "api_c_3.out", "w" ); + + fprintf (outfile, "* Test output: api_c_3\n"); + fprintf (outfile, "* Purpose: translate PDG code(s) to flavor string\n"); + fprintf (outfile, "\n"); + + whizard_create (&wh); + whizard_option (&wh, "logfile", "api_c_3_log.out"); + whizard_option (&wh, "model", "QED"); + whizard_init (&wh); + + err = whizard_flv_string (&wh, f, electron, CLEN); + if (!err) fprintf (outfile, "electron = %s\n", electron); + + err = whizard_flv_array_string (&wh, fa, NF, leptons, CLEN); + if (!err) fprintf (outfile, "leptons = %s\n", leptons); + + whizard_final (&wh); + + fprintf (outfile, "\n"); + fprintf (outfile, "* Test output end: api_c_3\n"); + + fclose (outfile); + whizard_ut_end (u_log, "api_c_3", "handle flavor string", &results); + + } +@ %def api_ut_c_3 +@ +\subsubsection{Integration} +Compute integral and retrieve results. +<>= + api_ut_c_4( u_log, results ); +<>= + void api_ut_c_4( int u_log, void* results ) { + + void* wh; + + int err; + double sqrts; + double integral; + double error; + + whizard_ut_start (u_log, "api_c_4"); + FILE *outfile; + outfile = fopen( "api_c_4.out", "w" ); + + fprintf (outfile, "* Test output: api_c_4\n"); + fprintf (outfile, "* Purpose: integrate and retrieve results\n"); + fprintf (outfile, "\n"); + + whizard_create (&wh); + whizard_option (&wh, "logfile", "api_c_4_log.out"); + whizard_option (&wh, "library", "api_c_4_lib"); + whizard_option (&wh, "model", "QED"); + whizard_option (&wh, "rebuild", "true"); + whizard_init (&wh); + + fprintf (outfile, "* Process setup\n"); + fprintf (outfile, "\n"); + + whizard_command (&wh, "process api_c_4_p = e1, E1 => e2, E2"); + whizard_command (&wh, "sqrts = 10"); + whizard_command (&wh, "iterations = 1:100"); + whizard_set_int (&wh, "seed", 0); + err = whizard_get_integration_result (&wh, "api_c_4_p", &integral, &error); + fprintf (outfile, " integral is unknown = %d\n", err); + + whizard_command (&wh, "integrate (api_c_4_p)"); + + fprintf (outfile, "\n"); + fprintf (outfile, "* Integrate\n"); + fprintf (outfile, "\n"); + + err = whizard_get_integration_result (&wh, "api_c_4_p", &integral, &error); + fprintf (outfile, " integral is unknown = %d\n", err); + + whizard_get_double (&wh, "sqrts", &sqrts); + fprintf (outfile, " sqrt(s) = %5.1f GeV\n", sqrts); + fprintf (outfile, " cross section = %5.1f pb\n", integral / 1000.); + fprintf (outfile, " error = %5.1f pb\n", error / 1000.); + + whizard_final (&wh); + + fprintf (outfile, "\n"); + fprintf (outfile, "* Test output end: api_c_4\n"); + + fclose (outfile); + whizard_ut_end (u_log, "api_c_4", "integrate", &results); + + } +@ %def api_ut_c_4 +@ +\subsubsection{Simulation} +Generate events and retrieve event data. +<>= + api_ut_c_5( u_log, results ); +<>= + void api_ut_c_5( int u_log, void* results ) { + + void* wh; + void* sample; + + #define CLEN 16 + + int it, it_begin, it_end; + + int i_proc; + char proc_id[CLEN]; + int idx; + double f_scale; + double alpha_s; + double weight; + double sqme; + + whizard_ut_start (u_log, "api_c_5"); + FILE *outfile; + outfile = fopen( "api_c_5.out", "w" ); + + fprintf (outfile, "* Test output: api_c_5\n"); + fprintf (outfile, "* Purpose: generate events\n"); + fprintf (outfile, "\n"); + + whizard_create (&wh); + whizard_option (&wh, "logfile", "api_c_5_log.out"); + whizard_option (&wh, "library", "api_c_5_lib"); + whizard_option (&wh, "model", "QCD"); + whizard_option (&wh, "rebuild", "true"); + whizard_init (&wh); + + whizard_command (&wh, "process api_c_5_p1 = u, U => t, T"); + whizard_command (&wh, "process api_c_5_p2 = d, D => t, T"); + whizard_command (&wh, "process api_c_5_p3 = s, S => t, T"); + whizard_command (&wh, "sqrts = 1000"); + whizard_command (&wh, "beams = p, p => pdf_builtin"); + whizard_set_bool (&wh, "?alphas_is_fixed", 0); + whizard_set_bool (&wh, "?alphas_from_pdf_builtin", 1); + whizard_command (&wh, "iterations = 1:100"); + whizard_set_int (&wh, "seed", 0); + whizard_command (&wh, "integrate (api_c_5_p1)"); + whizard_command (&wh, "integrate (api_c_5_p2)"); + whizard_command (&wh, "integrate (api_c_5_p3)"); + + whizard_set_bool (&wh, "?unweighted", 0); + whizard_set_char (&wh, "$sample", "api_c_5_evt"); + whizard_command (&wh, "sample_format = dump"); + whizard_set_int (&wh, "n_events", 10); + + whizard_new_sample (&wh, "api_c_5_p1, api_c_5_p2, api_c_5_p3", &sample); + whizard_sample_open (&sample, &it_begin, &it_end); + for (it=it_begin; it<=it_end; it++) { + whizard_sample_next_event (&sample); + whizard_sample_get_event_index (&sample, &idx); + whizard_sample_get_process_index (&sample, &i_proc); + whizard_sample_get_process_id (&sample, proc_id, CLEN); + whizard_sample_get_fac_scale (&sample, &f_scale); + whizard_sample_get_alpha_s (&sample, &alpha_s); + whizard_sample_get_weight (&sample, &weight); + whizard_sample_get_sqme (&sample, &sqme); + fprintf (outfile, "Event #%d\n", idx); + fprintf (outfile, " process #%d\n", i_proc); + fprintf (outfile, " proc_id = %s\n", proc_id); + fprintf (outfile, " f_scale = %10.3e\n", f_scale); + fprintf (outfile, " alpha_s = %10.3e\n", alpha_s); + fprintf (outfile, " sqme = %10.3e\n", sqme); + fprintf (outfile, " weight = %10.3e\n", weight); + } + whizard_sample_close (&sample); + + whizard_final (&wh); + + fprintf (outfile, "\n"); + fprintf (outfile, "* Test output end: api_c_5\n"); + + fclose (outfile); + whizard_ut_end (u_log, "api_c_5", "generate events", &results); + + } +@ %def api_ut_c_5 +@ +\subsection{Tools for Unit Tests} +We provide an infrastructure in C/C++ that accesses the Fortran unit-test +tools, such that the C/C++ unit tests seamlessly integrate into the generic +unit-test suite. + +There are C interface declarations and a Fortran-interface implementation. In +C++, we build a test-driver object on top of this that simplifies the test API. + +\subsubsection{Test suite Initialization/finalization} +Create a handle to the Fortran [[results]] object. +<>= +void whizard_ut_setup( const char* ut_name, int* u_log, void* results ); +<>= +subroutine whizard_ut_setup (ut_name, u_log, results_handle) bind (C) + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_loc !NODEP! + use string_utils, only: string_c2f + use io_units, only: free_unit + use unit_tests, only: test_results_t + + implicit none + + character(c_char), dimension(*), intent(in) :: ut_name + integer(c_int), intent(out) :: u_log + type(c_ptr), intent(inout) :: results_handle + + type(test_results_t), pointer :: results + + allocate (results) + results_handle = c_loc (results) + + u_log = free_unit () + open (unit = u_log, & + file = "whizard_check." // string_c2f (ut_name) // ".log", & + action = "write", status = "replace") + +end subroutine whizard_ut_setup + +@ %def whizard_ut_setup +@ +Finalize the test suite and display results. +<>= +void whizard_ut_wrapup( const int u_log, void* results ); +<>= +subroutine whizard_ut_wrapup (u_log, results_handle) bind (C) + use iso_fortran_env, only: output_unit !NODEP! + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use unit_tests, only: test_results_t + + implicit none + + integer(c_int), value :: u_log + type(c_ptr), intent(inout) :: results_handle + + type(test_results_t), pointer :: results + + call c_f_pointer (results_handle, results) + call results%wrapup (output_unit) + + close (u_log) + +end subroutine whizard_ut_wrapup + +@ %def whizard_ut_wrapup +@ +\subsubsection{Retrieve test-suite results} +Return the number of passed/failed/total tests so far. +<>= +int whizard_ut_get_n_pass( void* results ); +int whizard_ut_get_n_fail( void* results ); +int whizard_ut_get_n_total( void* results ); +<>= +function whizard_ut_get_n_pass (results_handle) result (n_pass) bind (C) + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use unit_tests, only: test_results_t + + implicit none + + type(c_ptr), intent(inout) :: results_handle + integer(c_int) :: n_pass + + type(test_results_t), pointer :: results + + call c_f_pointer (results_handle, results) + n_pass = results%get_n_pass () + +end function whizard_ut_get_n_pass + +function whizard_ut_get_n_fail (results_handle) result (n_fail) bind (C) + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use unit_tests, only: test_results_t + + implicit none + + type(c_ptr), intent(inout) :: results_handle + integer(c_int) :: n_fail + + type(test_results_t), pointer :: results + + call c_f_pointer (results_handle, results) + n_fail = results%get_n_fail () + +end function whizard_ut_get_n_fail + +function whizard_ut_get_n_total (results_handle) result (n_total) bind (C) + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use unit_tests, only: test_results_t + + implicit none + + type(c_ptr), intent(inout) :: results_handle + integer(c_int) :: n_total + + type(test_results_t), pointer :: results + + call c_f_pointer (results_handle, results) + n_total = results%get_n_total () + +end function whizard_ut_get_n_total + +@ %def whizard_ut_get_n_pass +@ %def whizard_ut_get_n_fail +@ %def whizard_ut_get_n_total +@ +\subsubsection{Single unit-test tools} +Start a single unit test. +<>= +void whizard_ut_start( const int u_log, const char* name ); +<>= +subroutine whizard_ut_start (u_log, name) bind (C) + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_char !NODEP! + use string_utils, only: string_c2f + use unit_tests, only: start_test + + implicit none + + integer(c_int), value :: u_log + character(c_char), dimension(*), intent(in) :: name + + call start_test (int (u_log), string_c2f (name)) + +end subroutine whizard_ut_start + +@ %def whizard_ut_start +@ +Complete a single unit test. +<>= +void whizard_ut_end( const int u_log, const char* name, const char* description, void* results ); +<>= +subroutine whizard_ut_end (u_log, name, description, results_handle) bind (C) + use iso_c_binding, only: c_int !NODEP! + use iso_c_binding, only: c_ptr !NODEP! + use iso_c_binding, only: c_char !NODEP! + use iso_c_binding, only: c_f_pointer !NODEP! + use string_utils, only: string_c2f + use unit_tests, only: compare_test_results + use unit_tests, only: test_results_t + + implicit none + + integer(c_int), value :: u_log + character(c_char), dimension(*), intent(in) :: name + character(c_char), dimension(*), intent(in) :: description + type(c_ptr), intent(inout) :: results_handle + + type(test_results_t), pointer :: results + + integer :: u_test + logical :: success + + open (newunit = u_test, file = string_c2f (name) // ".out", & + action = "read", status = "old") + call compare_test_results (u_test, int (u_log), string_c2f (name), success) + call c_f_pointer (results_handle, results) + call results%add (string_c2f (name), string_c2f (description), success) + +end subroutine whizard_ut_end + +@ %def whizard_ut_end +@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{C++ API} + +The C++ API consists of classes that wrap the \whizard\ handler objects (the +[[whizard_api_t]] and [[simulation_api_t]] objects). The methods interface +the Fortran API. + +\subsection{API implementation file} +This file contains the implementation for the class methods as declared in the +common header file. +<<[[api_cc.cc]]>>= +#include +#include +#include "whizard.h" + +#ifdef WHIZARD_WITH_HEPMC3 +#include "HepMC3/GenEvent.h" +#endif +#ifdef WHIZARD_WITH_HEPMC2 +#include "HepMC/GenEvent.h" +#endif + +using namespace std; + +<> + +<> +@ %def api_cc +@ +\subsubsection{Whizard class} +<>= +#include +#include + +using namespace std; + +class WhizardSample; // pre-declaration for use inside Whizard + +class Whizard { + + private: + void* wh; + + public: +<> + +}; + +@ %def Whizard +@ +Constructor: create the handle for the Fortran object. +<>= + Whizard(); +<>= +Whizard::Whizard() { + whizard_create( &wh ); +}; + +@ %def Whizard::Whizard +@ +Set options (before initialization). We employ the C++ [[string]] class for +all character strings. +<>= + void option( const string key, const string value ); +<>= +void Whizard::option( const string key, const string value ) { + whizard_option( &wh, &key[0], &value[0] ); +}; + +@ %def Whizard::option +@ +Initialize, after options have been set. +<>= + void init(); +<>= +void Whizard::init() { + whizard_init( &wh ); +}; + +@ %def Whizard::init +@ +Destructor: finalize WHIZARD and delete the handle. +<>= + ~Whizard(); +<>= +Whizard::~Whizard() { + whizard_final( &wh ); +}; + +@ %def Whizard::~Whizard +@ +Set a variable. +<>= + void set_double( const string var, const double value ); + void set_int( const string var, const int value ); + void set_bool( const string var, const int value ); + void set_string( const string var, const string value ); +<>= +void Whizard::set_double( const string var, const double value ) { + whizard_set_double ( &wh, &var[0], value ); +}; + +void Whizard::set_int( const string var, const int value ) { + whizard_set_int ( &wh, &var[0], value ); +}; + +void Whizard::set_bool( const string var, const int value ) { + whizard_set_bool ( &wh, &var[0], value ); +}; + +void Whizard::set_string( const string var, const string value ) { + whizard_set_char ( &wh, &var[0], &value[0] ); +}; + +@ %def Whizard::set_double +@ %def Whizard::set_int +@ %def Whizard::set_bool +@ +Retrieve a variable. +<>= + int get_double( const string var, double* value ); + int get_int( const string var, int* value ); + int get_bool( const string var, int* value ); + int get_string( const string var, string** value ); +<>= +int Whizard::get_double( const string var, double* value ) { + return whizard_get_double ( &wh, &var[0], value ); +}; + +int Whizard::get_int( const string var, int* value ) { + return whizard_get_int ( &wh, &var[0], value ); +}; + +int Whizard::get_bool( const string var, int* value ) { + return whizard_get_bool ( &wh, &var[0], value ); +}; + +int Whizard::get_string( const string var, string** value ) { + int strlen = whizard_get_char_len( &wh, &var[0] ); + char* tmp = new char ( strlen ); + int known = whizard_get_char ( &wh, &var[0], tmp, strlen ); + *value = new string (tmp); + delete tmp; + return known; +}; + +@ %def Whizard::get_double +@ %def Whizard::get_int +@ %def Whizard::get_bool +@ %def Whizard::get_string +@ +Return a flavor string as [[std::string]]. The array version uses +[[std::vector]] for input. +<>= + string* flv_string( const int f ); + string* flv_array_string( const vector fa ); +<>= +string* Whizard::flv_string( const int f ) { + int strlen = whizard_flv_string_len( &wh, f ); + char* tmp = new char ( strlen ); + whizard_flv_string ( &wh, f, tmp, strlen+1 ); + string *value = new string (tmp); + delete tmp; + return value; +}; + +string* Whizard::flv_array_string( const vector fa ) { + int strlen = whizard_flv_array_string_len( &wh, &fa[0], fa.size() ); + char* tmp = new char ( strlen ); + whizard_flv_array_string ( &wh, &fa[0], fa.size(), tmp, strlen+1 ); + string *value = new string (tmp); + delete tmp; + return value; +}; + +@ %def Whizard::flv_string +@ +Issue a \whizard\ command, specified as a [[std::string]]. +<>= + void command( const string cmd ); +<>= +void Whizard::command( const string cmd ) { + whizard_command( &wh, &cmd[0] ); +}; + +@ %def Whizard::command +@ +Retrieve the integration results (integral and error). Return~0 if those are +known, otherwise return~1. +<>= + int get_integration_result( const string proc_id, double* integral, double* error ); +<>= +int Whizard::get_integration_result( const string proc_id, double* integral, double* error ) { + return whizard_get_integration_result( &wh, &proc_id[0], integral, error ); +}; + +@ %def Whizard::get_integration_result +@ +Factory method: create a new [[WhizardSample]] object. +<>= + WhizardSample* new_sample( const string name ); +<>= +WhizardSample* Whizard::new_sample( const string name ) { + return new WhizardSample( wh, name ); +}; + +@ %def Whizard::new_sample +@ +\subsubsection{WhizardSample class} +<>= +class WhizardSample { + + private: + void* sample; + +<> + + public: +<> + +}; + +@ %def WhizardSample +@ The constructor is private but can be called +exclusively by the [[Whizard::new_sample]] factory method. It takes the +API-pointer component of the [[Whizard]] object as argument. +<>= + friend WhizardSample* Whizard::new_sample( const string ); + WhizardSample( void* wh, const string name ); +<>= +WhizardSample::WhizardSample( void* wh, const string name ) { + whizard_new_sample( &wh, &name[0], &sample ); +}; + +@ %def WhizardSample::WhizardSample +@ +Initialize the sample for event generation and return the iteration limits. +<>= + void open( int* it_begin, int* it_end ); +<>= +void WhizardSample::open( int* it_begin, int* it_end ) { + whizard_sample_open( &sample, it_begin, it_end ); +}; + +@ %def WhizardSample::open +@ +Produce a new event, accessible via the [[sample]] Fortran pointer. +<>= + void next_event(); +<>= +void WhizardSample::next_event() { + whizard_sample_next_event( &sample ); +}; + +@ %def WhizardSample::next_event +@ +Finalize event generation. +<>= + void close(); +<>= +void WhizardSample::close() { + whizard_sample_close( &sample ); +}; + +@ %def WhizardSample::close +@ Return event data. +<>= + int get_event_index(); + int get_process_index(); + string* get_process_id(); + double get_fac_scale(); + double get_alpha_s(); + double get_weight(); + double get_sqme(); +<>= +int WhizardSample::get_event_index() { + int idx; + whizard_sample_get_event_index( &sample, &idx ); + return idx; +}; + +int WhizardSample::get_process_index() { + int i_proc; + whizard_sample_get_process_index( &sample, &i_proc ); + return i_proc; +}; + +string* WhizardSample::get_process_id() { + int strlen = whizard_sample_get_process_id_len( &sample ); + char* tmp = new char ( strlen ); + whizard_sample_get_process_id ( &sample, tmp, strlen+1 ); + string *proc_id = new string (tmp); + delete tmp; + return proc_id; +}; + +double WhizardSample::get_fac_scale() { + double f_scale; + whizard_sample_get_fac_scale( &sample, &f_scale ); + return f_scale; +}; + +double WhizardSample::get_alpha_s() { + double alpha_s; + whizard_sample_get_alpha_s( &sample, &alpha_s ); + return alpha_s; +}; + +double WhizardSample::get_weight() { + double weight; + whizard_sample_get_weight( &sample, &weight ); + return weight; +}; + +double WhizardSample::get_sqme() { + double sqme; + whizard_sample_get_sqme( &sample, &sqme ); + return sqme; +}; + +@ %def WhizardSample::get_event_index +@ %def WhizardSample::get_process_index +@ %def WhizardSample::get_process_id +@ %def WhizardSample::get_fac_scale +@ %def WhizardSample::get_alpha_s +@ %def WhizardSample::get_weight +@ %def WhizardSample::get_sqme +@ +If HepMC is available: produce a new event, accessible via the [[sample]] +Fortran pointer, and return a pointer to a new [[GenEvent]] event object. +<>= +#ifdef WHIZARD_WITH_HEPMC2 + void next_event( HepMC::GenEvent** evt ); +#endif +#ifdef WHIZARD_WITH_HEPMC3 + void next_event( HepMC3::GenEvent** evt ); +#endif +<>= +#ifdef WHIZARD_WITH_HEPMC2 +void WhizardSample::next_event( HepMC::GenEvent** evt ) { + *evt = whizard_sample_next_event_hepmc( &sample ); +}; +#endif +#ifdef WHIZARD_WITH_HEPMC3 +void WhizardSample::next_event( HepMC3::GenEvent** evt ) { + *evt = whizard_sample_next_event_hepmc( &sample ); +}; +#endif + +@ %def WhizardSample::next_event +@ +If LCIO is available: produce a new event, accessible via the [[sample]] +Fortran pointer, and return a pointer to a new [[LCEvent]] event object. +<>= +#ifdef WHIZARD_WITH_LCIO + void next_event( lcio::LCEvent** evt ); +#endif +<>= +#ifdef WHIZARD_WITH_LCIO +void WhizardSample::next_event( lcio::LCEvent** evt ) { + *evt = whizard_sample_next_event_lcio( &sample ); +}; +#endif + +@ %def WhizardSample::next_event +@ +\subsection{C++ API: class header for unit-test driver} +Compared with the plain-C test driver, we can take a more advanced approach +and define a class and class methods for the test-driver object. This object +holds references to the Fortran unit-test collection object, which is thus +invoked indirectly. + +This code goes into the common [[whizard.h]] C/C++ header: +<>= +#include +#include + +using namespace std; + +class WhizardCCTest { + + private: + string name; + int u_log; + void* results; + + public: +<> + +}; +@ +\subsection{C++ API: class implementation for unit-test driver} +This is the corresponding implementation: +<<[[whizard_ut.cc]]>>= +#include +#include +#include +#include "whizard.h" +#include "whizard_ut.h" + +using namespace std; + +<> + +@ %def whizard_ut.cc +@ +Constructor: +<>= + WhizardCCTest( const char* test_collection_name ); +<>= +WhizardCCTest::WhizardCCTest( const char* test_collection_name ) { + + name = test_collection_name; + + cout << "| ============================================================================\n"; + cout << "| Running WHIZARD self-test: " << name << " with C++ driver program\n"; + cout << "| ----------------------------------------------------------------------------\n"; + + whizard_ut_setup (test_collection_name, &u_log, &results); + +} + +@ %def WhizardCCTest +@ +Return status = number of failed tests: +<>= + int get_n_fail(); +<>= +int WhizardCCTest::get_n_fail() { + + return whizard_ut_get_n_fail (&results); + +} + +@ %def WhizardCCTest::get_n_fail +@ +Destructor: include the final wrapup and messages. +<>= + ~WhizardCCTest(); +<>= +WhizardCCTest::~WhizardCCTest() { + + whizard_ut_wrapup (u_log, &results); + + cout << "| ----------------------------------------------------------------------------\n"; + cout << "| Finished WHIZARD self-test: " << name << " with C++ driver program\n"; + cout << "| ============================================================================\n"; + +} + +@ %def ~WhizardCCTest +@ +Execute a test, which takes a C file pointer as its argument: +<>= + void run_test( void (*f)(FILE*), const char* test_name, const char* test_description ); +<>= +void WhizardCCTest::run_test( void (*f)(FILE*), const char* test_name, const char* test_description ) { + + whizard_ut_start( u_log, test_name ); + + string outfile_name; + outfile_name = test_name; + outfile_name += ".out"; + + FILE *outfile; + outfile = fopen( &outfile_name[0], "w" ); + + f( outfile ); + + fclose( outfile ); + whizard_ut_end( u_log, test_name, test_description, &results ); + +} + +@ +@ +\subsection{C++ API: unit-test driver} +We define a test driver which is analogous to the Fortran test driver. There +is somewhat less sophistication because we only need this for one test suite. + +The MPI interface is identical to the C version. +<<[[api_ut_cc.cc]]>>= +#include +#include +#include "whizard.h" +#include "whizard_ut.h" +<> + +#ifdef WHIZARD_WITH_HEPMC2 +#include "HepMC/GenEvent.h" +using namespace HepMC; +#endif +#ifdef WHIZARD_WITH_HEPMC3 +#include "HepMC3/GenEvent.h" +using namespace HepMC3; +#endif + +#ifdef WHIZARD_WITH_LCIO +#include "lcio.h" +#include "IMPL/LCEventImpl.h" +using namespace lcio; +#endif + + +<> + +int main( int argc, char* argv[] ) +{ + int n_fail; + WhizardCCTest* WTest; + + WTest = new WhizardCCTest("api_cc"); + +<> + +<> + +<> + +<> + +<> + + n_fail = WTest->get_n_fail(); + delete(WTest); + + return n_fail; +} +@ %def api_c++_test +@ +\subsection{C++ API: unit tests} +\subsubsection{Minimal test} +This test does initialization and finalization, with basic options. +<>= + WTest->run_test( &api_ut_cc_1, "api_cc_1", "basic init/final" ); +<>= +void api_ut_cc_1( FILE* outfile ) { + + Whizard* whizard; + + fprintf (outfile, "* Test output: api_cc_1\n"); + fprintf (outfile, "* Purpose: call init/final\n"); + fprintf (outfile, "\n"); + + fprintf (outfile, "* Creating WHIZARD object\n"); + whizard = new Whizard(); + + fprintf (outfile, "* Setting options\n"); + whizard->option( "logfile", "api_cc_1.log" ); + + fprintf (outfile, "* Initializing WHIZARD\n"); + whizard->init (); + + fprintf (outfile, "* Finalizing WHIZARD\n"); + delete( whizard ); + + fprintf (outfile, "\n"); + fprintf (outfile, "* Test output end: api_cc_1\n"); + +} + +@ %def api_ut_cc_1 +@ +\subsubsection{Variables} +This test sets and retrieves values of Sindarin variables. +<>= + WTest->run_test( &api_ut_cc_2, "api_cc_2", "set/get Sindarin values" ); +<>= + void api_ut_cc_2( FILE* outfile ) { + + Whizard* whizard; + + int err; + string* job_id; + double sqrts; + int n_events; + int unweighted; + string* sample; + + fprintf (outfile, "* Test output: api_cc_2\n"); + fprintf (outfile, "* Purpose: access Sindarin variables\n"); + fprintf (outfile, "\n"); + + whizard = new Whizard(); + whizard->option ("logfile", "api_cc_2_log.out"); + whizard->option ("job_id", "api_cc_2_ID"); + whizard->init (); + + err = whizard->get_string ("$job_id", &job_id); + if (!err) fprintf (outfile, "$job_id = %s\n", job_id->c_str ()); + delete job_id; + + err = whizard->get_double ("sqrts", &sqrts); + if (!err) { + fprintf (outfile, "sqrts = %5.1f\n", sqrts); + } else { + fprintf (outfile, "sqrts = [unknown]\n", sqrts); + } + + fprintf (outfile, "\n"); + + whizard->set_double ("sqrts", 100.); + whizard->set_int ("n_events", 3); + whizard->set_bool ("?unweighted", 0); + whizard->set_string ("$sample", "foobar"); + + err = whizard->get_double ("sqrts", &sqrts); + if (!err) fprintf (outfile, "sqrts = %5.1f\n", sqrts); + + err = whizard->get_int ("n_events", &n_events); + if (!err) fprintf (outfile, "n_events = %1d\n", n_events); + + err = whizard->get_bool ("?unweighted", &unweighted); + if (!err) fprintf (outfile, "?unweighted = %1d\n", unweighted); + + whizard->get_string ("$sample", &sample); + fprintf (outfile, "$sample = %s\n", sample->c_str()); + delete sample; + + fprintf (outfile, "\n"); + + whizard->set_bool ("?unweighted", 1); + whizard->get_bool ("?unweighted", &unweighted); + fprintf (outfile, "?unweighted = %1d\n", unweighted); + + delete (whizard); + + fprintf (outfile, "\n"); + fprintf (outfile, "* Test output end: api_cc_2\n"); + + } +@ %def api_ut_cc_2 +@ +\subsubsection{Flavor string} +Use the flavor-string convenience translation. +<>= + WTest->run_test( &api_ut_cc_3, "api_cc_3", "andle flavor string" ); +<>= + void api_ut_cc_3( FILE* outfile ) { + + Whizard* whizard; + + int err; + int f = 11; + vector fa(3); + fa[0] = 11; + fa[1] = 13; + fa[2] = 15; + string* electron; + string* leptons; + + fprintf (outfile, "* Test output: api_cc_3\n"); + fprintf (outfile, "* Purpose: translate PDG code(s) to flavor string\n"); + fprintf (outfile, "\n"); + + whizard = new Whizard(); + whizard->option( "logfile", "api_c_3_log.out" ); + whizard->option( "model", "QED" ); + whizard->init(); + + electron = whizard->flv_string( f ); + fprintf (outfile, "electron = %s\n", electron->c_str ()); + delete electron; + + leptons = whizard->flv_array_string( fa ); + fprintf (outfile, "leptons = %s\n", leptons->c_str ()); + delete leptons; + + delete whizard; + + fprintf (outfile, "\n"); + fprintf (outfile, "* Test output end: api_cc_3\n"); + + } +@ %def api_ut_cc_3 +@ +\subsubsection{Integration} +Compute integral and retrieve results. +<>= + WTest->run_test( &api_ut_cc_4, "api_cc_4", "integrate" ); +<>= + void api_ut_cc_4( FILE* outfile ) { + + Whizard* whizard; + + int err; + double sqrts; + double integral; + double error; + + fprintf( outfile, "* Test output: api_cc_4\n" ); + fprintf( outfile, "* Purpose: integrate and retrieve results\n" ); + fprintf( outfile, "\n" ); + + whizard = new Whizard(); + whizard->option( "logfile", "api_cc_4_log.out" ); + whizard->option( "library", "api_cc_4_lib" ); + whizard->option( "model", "QED" ); + whizard->option( "rebuild", "true" ); + whizard->init(); + + fprintf( outfile, "* Process setup\n"); + fprintf( outfile, "\n"); + + whizard->command( "process api_cc_4_p = e1, E1 => e2, E2" ); + whizard->command( "sqrts = 10" ); + whizard->command( "iterations = 1:100" ); + whizard->set_int( "seed", 0 ); + err = whizard->get_integration_result( "api_cc_4_p", &integral, &error ); + fprintf( outfile, " integral is unknown = %d\n", err ); + + whizard->command( "integrate (api_cc_4_p)" ); + + fprintf( outfile, "\n" ); + fprintf( outfile, "* Integrate\n" ); + fprintf( outfile, "\n" ); + + err = whizard->get_integration_result( "api_cc_4_p", &integral, &error ); + fprintf( outfile, " integral is unknown = %d\n", err ); + + whizard->get_double( "sqrts", &sqrts ); + fprintf( outfile, " sqrt(s) = %5.1f GeV\n", sqrts ); + fprintf( outfile, " cross section = %5.1f pb\n", integral / 1000. ); + fprintf( outfile, " error = %5.1f pb\n", error / 1000. ); + + delete whizard; + + fprintf( outfile, "\n" ); + fprintf( outfile, "* Test output end: api_cc_4\n" ); + + } +@ %def api_ut_cc_4 +@ +\subsubsection{Simulation} +Generate events and retrieve event data. +<>= + WTest->run_test( &api_ut_cc_5, "api_cc_5", "generate events" ); +<>= + void api_ut_cc_5( FILE* outfile ) { + + Whizard* whizard; + WhizardSample* sample; + + int it, it_begin, it_end; + + int i_proc; + string* proc_id; + int idx; + double f_scale; + double alpha_s; + double weight; + double sqme; + + fprintf( outfile, "* Test output: api_cc_5\n" ); + fprintf( outfile, "* Purpose: generate events\n" ); + fprintf( outfile, "\n" ); + + whizard = new Whizard( ); + whizard->option( "logfile", "api_cc_5_log.out" ); + whizard->option( "library", "api_cc_5_lib" ); + whizard->option( "model", "QCD" ); + whizard->option( "rebuild", "true" ); + whizard->init(); + + whizard->command( "process api_cc_5_p1 = u, U => t, T" ); + whizard->command( "process api_cc_5_p2 = d, D => t, T" ); + whizard->command( "process api_cc_5_p3 = s, S => t, T" ); + whizard->command( "sqrts = 1000" ); + whizard->command( "beams = p, p => pdf_builtin" ); + whizard->set_bool( "?alphas_is_fixed", 0 ); + whizard->set_bool( "?alphas_from_pdf_builtin", 1 ); + whizard->command( "iterations = 1:100" ); + whizard->set_int( "seed", 0 ); + whizard->command( "integrate (api_cc_5_p1)" ); + whizard->command( "integrate (api_cc_5_p2)" ); + whizard->command( "integrate (api_cc_5_p3)" ); + + whizard->set_bool( "?unweighted", 0 ); + whizard->set_string( "$sample", "api_cc_5_evt" ); + whizard->command( "sample_format = dump" ); + whizard->set_int( "n_events", 10 ); + + sample = whizard->new_sample( "api_cc_5_p1, api_cc_5_p2, api_cc_5_p3" ); + sample->open( &it_begin, &it_end ); + for (it=it_begin; it<=it_end; it++) { + sample->next_event(); + idx = sample->get_event_index(); + i_proc = sample->get_process_index(); + proc_id = sample->get_process_id(); + f_scale = sample->get_fac_scale(); + alpha_s = sample->get_alpha_s(); + weight = sample->get_weight(); + sqme = sample->get_sqme(); + fprintf( outfile, "Event #%d\n", idx ); + fprintf( outfile, " process #%d\n", i_proc ); + fprintf( outfile, " proc_id = %s\n", proc_id->c_str()); + fprintf( outfile, " f_scale = %10.3e\n", f_scale ); + fprintf( outfile, " alpha_s = %10.3e\n", alpha_s ); + fprintf( outfile, " sqme = %10.3e\n", sqme ); + fprintf( outfile, " weight = %10.3e\n", weight ); + delete proc_id; + } + sample->close (); + + delete whizard; + + fprintf( outfile, "\n" ); + fprintf( outfile, "* Test output end: api_cc_5\n" ); + + } +@ %def api_ut_cc_5 +@ +\subsubsection{HepMC3 test} +This test checks whether we can interface the [[GenEvent]] handle. If HepMC3 +is not available, the test is skipped. We can use the macro [[WHIZARD_WITH_HEPMC3]] to +check if this is the case. +<>= +#ifdef WHIZARD_WITH_HEPMC3 + WTest->run_test( &api_ut_hepmc3_cc_1, "api_hepmc3_cc_1", "HepMC3 interface" ); +#elif WHIZARD_WITH_HEPMC2 + WTest->run_test( &api_ut_hepmc2_cc_1, "api_hepmc2_cc_1", "HepMC2 interface" ); +#else + cout << "Skipping test: api_hepmc_cc_1 (HepMC2/3 unavailable)\n"; +#endif +<>= +#if defined(WHIZARD_WITH_HEPMC3) + void api_ut_hepmc3_cc_1( FILE* outfile ) { + + Whizard* whizard; + WhizardSample* sample; + + GenEvent* evt; + int it, it_begin, it_end; + int idx; + int npt; + + fprintf( outfile, "* Test output: api_hepmc3_cc_1\n" ); + fprintf( outfile, "* Purpose: generate events\n" ); + fprintf( outfile, "\n" ); + + whizard = new Whizard(); + + whizard->option( "logfile", "api_hepmc3_cc_1.log.out" ); + whizard->option( "library", "api_hepmc3_cc_1_lib" ); + whizard->option( "model", "QED" ); + whizard->option( "rebuild", "T" ); + + whizard->init (); + + whizard->command( "process api_hepmc3_cc_1_p = e1, E1 => e2, E2" ); + + whizard->set_double( "sqrts", 10. ); + whizard->command( "iterations = 1:100" ); + whizard->set_int( "seed", 0 ); + whizard->command( "integrate (api_hepmc3_cc_1_p)" ); + + whizard->set_bool( "?unweighted", 0 ); + whizard->set_string( "$sample", "api_hepmc3_cc_1_evt" ); + whizard->command( "sample_format = hepmc" ); + whizard->set_int( "n_events", 2 ); + + sample = whizard->new_sample( "api_hepmc3_cc_1_p" ); + + sample->open( &it_begin, &it_end ); + for (it=it_begin; it<=it_end; it++) { + sample->next_event( &evt ); + idx = evt->event_number(); + npt = evt->particles().size(); + fprintf( outfile, "Event #%d\n", idx ); + fprintf( outfile, " n_particles = %d\n", npt ); + delete evt; + } + sample->close (); + + delete whizard; + + fprintf (outfile, "\n"); + fprintf (outfile, "* Test output end: api_hepmc3_cc_1\n"); + + } +#endif +#if defined(WHIZARD_WITH_HEPMC2) + void api_ut_hepmc2_cc_1( FILE* outfile ) { + + Whizard* whizard; + WhizardSample* sample; + + GenEvent* evt; + int it, it_begin, it_end; + int idx; + int npt; + + fprintf( outfile, "* Test output: api_hepmc2_cc_1\n" ); + fprintf( outfile, "* Purpose: generate events\n" ); + fprintf( outfile, "\n" ); + + whizard = new Whizard(); + + whizard->option( "logfile", "api_hepmc2_cc_1.log.out" ); + whizard->option( "library", "api_hepmc2_cc_1_lib" ); + whizard->option( "model", "QED" ); + whizard->option( "rebuild", "T" ); + + whizard->init (); + + whizard->command( "process api_hepmc2_cc_1_p = e1, E1 => e2, E2" ); + + whizard->set_double( "sqrts", 10. ); + whizard->command( "iterations = 1:100" ); + whizard->set_int( "seed", 0 ); + whizard->command( "integrate (api_hepmc2_cc_1_p)" ); + + whizard->set_bool( "?unweighted", 0 ); + whizard->set_string( "$sample", "api_hepmc2_cc_1_evt" ); + whizard->command( "sample_format = hepmc" ); + whizard->set_int( "n_events", 2 ); + + sample = whizard->new_sample( "api_hepmc2_cc_1_p" ); + + sample->open( &it_begin, &it_end ); + for (it=it_begin; it<=it_end; it++) { + npt = 0; + sample->next_event( &evt ); + idx = evt->event_number(); + for ( GenEvent::particle_iterator it = evt->particles_begin(); + it != evt->particles_end(); ++it ) + { npt++; + } + fprintf( outfile, "Event #%d\n", idx ); + fprintf( outfile, " n_particles = %d\n", npt ); + delete evt; + } + sample->close (); + + delete whizard; + + fprintf (outfile, "\n"); + fprintf (outfile, "* Test output end: api_hepmc2_cc_1\n"); + + } +#endif + +@ %def api_ut_cc_1 +@ +\subsubsection{LCIO test} +This test checks whether we can interface the [[GenEvent]] handle. If LCIO +is not available, the test is skipped. We can use the macro [[LCIO]] to +check if this is the case. +<>= +#ifdef WHIZARD_WITH_LCIO + WTest->run_test( &api_ut_lcio_cc_1, "api_lcio_cc_1", "LCIO interface" ); +#else + cout << "Skipping test: api_lcio_cc_1 (LCIO unavailable)\n"; +#endif +<>= +#ifdef WHIZARD_WITH_LCIO + void api_ut_lcio_cc_1( FILE* outfile ) { + + Whizard* whizard; + WhizardSample* sample; + + LCEvent* evt; + int it, it_begin, it_end; + int idx; + int npt; + + fprintf( outfile, "* Test output: api_lcio_cc_1\n" ); + fprintf( outfile, "* Purpose: generate events\n" ); + fprintf( outfile, "\n" ); + + whizard = new Whizard(); + + whizard->option( "logfile", "api_lcio_cc_1.log.out" ); + whizard->option( "library", "api_lcio_cc_1_lib" ); + whizard->option( "model", "QED" ); + whizard->option( "rebuild", "T" ); + + whizard->init (); + + whizard->command( "process api_lcio_cc_1_p = e1, E1 => e2, E2" ); + + whizard->set_double( "sqrts", 10. ); + whizard->command( "iterations = 1:100" ); + whizard->set_int( "seed", 0 ); + whizard->command( "integrate (api_lcio_cc_1_p)" ); + + whizard->set_bool( "?unweighted", 1 ); + whizard->set_string( "$sample", "api_lcio_cc_1_evt" ); + whizard->command( "sample_format = lcio" ); + whizard->set_int( "n_events", 2 ); + + sample = whizard->new_sample( "api_lcio_cc_1_p" ); + + sample->open( &it_begin, &it_end ); + for (it=it_begin; it<=it_end; it++) { + sample->next_event( &evt ); + idx = evt->getEventNumber(); + npt = evt->getCollection( LCIO::MCPARTICLE )->getNumberOfElements(); + fprintf( outfile, "Event #%d\n", idx ); + fprintf( outfile, " n_particles = %d\n", npt ); + delete evt; + } + sample->close (); + + delete whizard; + + fprintf (outfile, "\n"); + fprintf (outfile, "* Test output end: api_lcio_cc_1\n"); + + } +#endif + Index: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am (revision 8428) +++ trunk/src/Makefile.am (revision 8429) @@ -1,297 +1,367 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## Subdirectories to configure ## directories in one line do not depend on each other SUBDIRS = \ noweb-frame \ basics \ hepmc lcio lhapdf lhapdf5 looptools xdr \ expr_base utilities \ system \ combinatorics pdf_builtin testing \ hoppet \ muli parsing physics qed_pdf \ fastjet types qft threshold \ models particles matrix_elements variables \ events prebuilt rng \ beams tauola \ me_methods pythia8 shower \ blha model_features \ gosam openloops \ recola phase_space \ fks vegas mci \ process_integration \ matching \ transforms \ - whizard-core + whizard-core \ + api \ + main if MPOST_AVAILABLE SUBDIRS += gamelan feynmf endif ######################################################################## ## Build ## (1) the toplevel WHIZARD library, which wraps various libraries ## built in the subdirectories ## (2) the WHIZARD test library that is linked to the main executable ## as the provider of internal unit tests ## (3) the wrapper O'Mega library, which contains omegalib and ## the W/O interface modules for the various models lib_LTLIBRARIES = libwhizard.la libomega.la libwhizard_la_SOURCES = libwhizard_la_LDFLAGS = $(LIBRARY_VERSION) ## Collect the various partial libraries libwhizard_la_LIBADD = \ + api/libapi.la \ threshold/libthreshold.la \ whizard-core/libwhizard_core.la \ transforms/libtransforms.la \ ../vamp/src/libvamp.la \ ../circe1/src/libcirce1.la \ ../circe2/src/libcirce2.la \ shower/libshower.la \ tauola/libtauola_interface.la \ muli/libmuli.la \ pdf_builtin/libpdf_builtin.la \ model_features/libmodel_features.la \ variables/libvariables.la \ process_integration/libprocess_integration.la \ matching/libmatching.la \ fks/libfks.la \ gosam/libgosam.la \ openloops/liboloops.la \ recola/libwo_recola.la \ blha/libblha.la \ vegas/libvegas.la \ mci/libmci.la \ phase_space/libphase_space.la \ xdr/libWOStdHep.la \ events/libevents.la \ beams/libbeams.la \ particles/libparticles.la \ me_methods/libme_methods.la \ matrix_elements/libmatrix_elements.la \ types/libtypes.la \ qft/libqft.la \ physics/libphysics.la \ qed_pdf/libqed_pdf.la \ expr_base/libexpr_base.la \ rng/librng.la \ parsing/libparsing.la \ combinatorics/libcombinatorics.la \ system/libsystem.la \ testing/libtesting.la \ utilities/libutilities.la \ basics/libbasics.la if HEPMC_AVAILABLE libwhizard_la_LIBADD += hepmc/libHepMCWrap.la else libwhizard_la_LIBADD += hepmc/libHepMCWrap_dummy.la endif if LCIO_AVAILABLE libwhizard_la_LIBADD += lcio/libLCIOWrap.la else libwhizard_la_LIBADD += lcio/libLCIOWrap_dummy.la endif ## If (parts of) LHAPDF is not available, link in a dummy as replacements if LHAPDF5_AVAILABLE libwhizard_la_LIBADD += $(LDFLAGS_LHAPDF) if LHAPDF5_HAS_PHOTON_DUMMY libwhizard_la_LIBADD += lhapdf5/libLHAPDF5_dummy.la endif else if !LHAPDF6_AVAILABLE libwhizard_la_LIBADD += lhapdf5/libLHAPDF5_dummy.la endif endif if LHAPDF6_AVAILABLE libwhizard_la_LIBADD += $(LHAPDF_LIBS) lhapdf/libLHAPDFWrap.la else libwhizard_la_LIBADD += lhapdf/libLHAPDFWrap_dummy.la endif if HOPPET_AVAILABLE libwhizard_la_LIBADD += $(LDFLAGS_HOPPET) hoppet/libhoppet.la else libwhizard_la_LIBADD += hoppet/libhoppet_dummy.la endif if FASTJET_AVAILABLE libwhizard_la_LIBADD += $(FASTJET_LIBS) fastjet/libFastjetWrap.la else libwhizard_la_LIBADD += fastjet/libFastjetWrap_dummy.la endif if LOOPTOOLS_AVAILABLE libwhizard_la_LIBADD += $(LDFLAGS_LOOPTOOLS) looptools/liblooptools.la else libwhizard_la_LIBADD += looptools/liblooptools_dummy.la endif libwhizard_la_LIBADD += $(PYTHIA8_LIBS) pythia8/libwo_pythia8.la if IS_IFORT_DARWIN libwhizard_la_LIBADD += $(FCLIBS) endif ## ------------------------------------------------------------------- ## WHIZARD unit-test library -check_LTLIBRARIES = libwhizard_test.la +check_LTLIBRARIES = libwhizard_ut.la -libwhizard_test_la_SOURCES = +libwhizard_ut_la_SOURCES = -libwhizard_test_la_LIBADD = \ +libwhizard_ut_la_LIBADD = \ + main/libwhizard_main_ut.la \ + api/libapi_ut.la \ threshold/libthreshold_ut.la \ whizard-core/libwhizard_core_ut.la \ transforms/libtransforms_ut.la \ matching/libmatching_ut.la \ fks/libfks_ut.la \ shower/libshower_ut.la \ process_integration/libprocess_integration_ut.la \ recola/libwo_recola_ut.la \ blha/libblha_ut.la \ model_features/libmodel_features_ut.la \ vegas/libvegas_ut.la mci/libmci_ut.la \ phase_space/libphase_space_ut.la \ pythia8/libwo_pythia8_ut.la \ events/libevents_ut.la \ beams/libbeams_ut.la \ particles/libparticles_ut.la \ me_methods/libme_methods_ut.la \ matrix_elements/libmatrix_elements_ut.la \ types/libtypes_ut.la \ qft/libqft_ut.la \ physics/libphysics_ut.la \ rng/librng_ut.la \ parsing/libparsing_ut.la \ combinatorics/libcombinatorics_ut.la \ system/libsystem_ut.la ## ------------------------------------------------------------------- +## WHIZARD C API test library + +check_LTLIBRARIES += libwhizard_ut_c.la + +libwhizard_ut_c_la_SOURCES = + +libwhizard_ut_c_la_LIBADD = \ + api/libapi_ut_c.la + +## ------------------------------------------------------------------- +## WHIZARD C++ API test library + +check_LTLIBRARIES += libwhizard_ut_cc.la + +libwhizard_ut_cc_la_SOURCES = + +libwhizard_ut_cc_la_LIBADD = \ + api/libapi_ut_cc.la + +## ------------------------------------------------------------------- ## O'Mega main library libomega_la_SOURCES = libomega_la_LIBADD = \ ../omega/src/libomega_core.la \ models/libmodels.la if RECOLA_AVAILABLE libwhizard_la_LIBADD += $(LDFLAGS_RECOLA) -libwhizard_test_la_LIBADD += $(LDFLAGS_RECOLA) +libwhizard_ut_la_LIBADD += $(LDFLAGS_RECOLA) endif ######################################################################## ## Build a standalone program bin_PROGRAMS = whizard whizard_SOURCES = ## A dummy source tells libtool that the F90 compiler is used for linking ## Without dummy, libtool uses the C linker (default: ld) nodist_EXTRA_whizard_SOURCES = dummy.f90 if IS_IFORT_DARWIN whizard_LDFLAGS = $(AM_LDFLAGS) -static endif -whizard_LDADD = whizard-core/libwhizard_main.la +whizard_LDADD = main/libwhizard_main.la whizard_LDADD += ./libwhizard.la whizard_LDADD += prebuilt/libwhizard_prebuilt.la whizard_LDADD += $(CXXLIBS) whizard_LDADD += $(RPC_CFLAGS) whizard_LDADD += $(LDFLAGS_LHAPDF) whizard_LDADD += $(LDFLAGS_HEPMC) whizard_LDADD += $(LDFLAGS_LCIO) whizard_LDADD += $(LDFLAGS_HOPPET) whizard_LDADD += $(FASTJET_LIBS) whizard_LDADD += $(LDFLAGS_LOOPTOOLS) ## ------------------------------------------------------------------- -## Build a standalone program for running the unit tests +## Build a standalone program for running the Fortran unit tests check_PROGRAMS = whizard_ut whizard_ut_SOURCES = ## A dummy source tells libtool that the F90 compiler is used for linking ## Without dummy, libtool uses the C linker (default: ld) nodist_EXTRA_whizard_ut_SOURCES = dummy.f90 if IS_IFORT_DARWIN whizard_ut_LDFLAGS = $(AM_LDFLAGS) -static endif -whizard_ut_LDADD = whizard-core/libwhizard_main_ut.la -whizard_ut_LDADD += ./libwhizard_test.la +whizard_ut_LDADD = ./libwhizard_ut.la whizard_ut_LDADD += ./libwhizard.la whizard_ut_LDADD += prebuilt/libwhizard_prebuilt.la whizard_ut_LDADD += $(CXXLIBS) whizard_ut_LDADD += $(RPC_CFLAGS) whizard_ut_LDADD += $(LDFLAGS_LHAPDF) whizard_ut_LDADD += $(LDFLAGS_HEPMC) whizard_ut_LDADD += $(LDFLAGS_LCIO) whizard_ut_LDADD += $(LDFLAGS_HOPPET) whizard_ut_LDADD += $(FASTJET_LIBS) whizard_ut_LDADD += $(LDFLAGS_LOOPTOOLS) +## ------------------------------------------------------------------- +## Build a standalone program for running the C interface test + +check_PROGRAMS += whizard_ut_c + +whizard_ut_c_SOURCES = + +if IS_IFORT_DARWIN +whizard_ut_c_LDFLAGS = $(AM_LDFLAGS) -static +endif + +whizard_ut_c_LDADD = ./libwhizard_ut_c.la +whizard_ut_c_LDADD += ./libwhizard.la +whizard_ut_c_LDADD += prebuilt/libwhizard_prebuilt.la +whizard_ut_c_LDADD += $(CXXLIBS) +whizard_ut_c_LDADD += $(RPC_CFLAGS) +whizard_ut_c_LDADD += $(LDFLAGS_LHAPDF) +whizard_ut_c_LDADD += $(LDFLAGS_HEPMC) +whizard_ut_c_LDADD += $(LDFLAGS_LCIO) +whizard_ut_c_LDADD += $(LDFLAGS_HOPPET) +whizard_ut_c_LDADD += $(FASTJET_LIBS) +whizard_ut_c_LDADD += $(LDFLAGS_LOOPTOOLS) + +## ------------------------------------------------------------------- +## Build a standalone program for running the C++ interface test + +check_PROGRAMS += whizard_ut_cc + +whizard_ut_cc_SOURCES = + +if IS_IFORT_DARWIN +whizard_ut_cc_LDFLAGS = $(AM_LDFLAGS) -static +endif + +whizard_ut_cc_LDADD = ./libwhizard_ut_cc.la +whizard_ut_cc_LDADD += ./libwhizard.la +whizard_ut_cc_LDADD += prebuilt/libwhizard_prebuilt.la +whizard_ut_cc_LDADD += $(CXXLIBS) +whizard_ut_cc_LDADD += $(RPC_CFLAGS) +whizard_ut_cc_LDADD += $(LDFLAGS_LHAPDF) +whizard_ut_cc_LDADD += $(LDFLAGS_HEPMC) +whizard_ut_cc_LDADD += $(LDFLAGS_LCIO) +whizard_ut_cc_LDADD += $(LDFLAGS_HOPPET) +whizard_ut_cc_LDADD += $(FASTJET_LIBS) +whizard_ut_cc_LDADD += $(LDFLAGS_LOOPTOOLS) + ######################################################################## ## Default Fortran compiler options AM_FCFLAGS = ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ######################################################################## ## Non-standard cleanup tasks ## Remove backup files maintainer-clean-local: -rm -f *~ ## Remove Module lists only after final subdir cleanup distclean-local: for d in $(SUBDIRS); do \ rm -f $$d/Modules; \ done Index: trunk/src/utilities/Makefile.am =================================================================== --- trunk/src/utilities/Makefile.am (revision 8428) +++ trunk/src/utilities/Makefile.am (revision 8429) @@ -1,192 +1,188 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory are simple utilities used by WHIZARD ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = libutilities.la libutilities_la_SOURCES = \ file_utils.f90 \ file_registries.f90 \ string_utils.f90 \ format_utils.f90 \ format_defs.f90 \ numeric_utils.f90 ## Omitting this would exclude it from the distribution dist_noinst_DATA = utilities.nw +# Modules and installation +# Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${libutilities_la_SOURCES:.f90=.$(FCMOD)} + # Dump module names into file Modules libutilities_Modules = ${libutilities_la_SOURCES:.f90=} Modules: Makefile @for module in $(libutilities_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(libutilities_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES = Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(libutilities_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ## MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif ######################################################################## ## Non-standard targets and dependencies -## Install the modules used by generated matrix element code -## and by the user code library -execmoddir = $(pkglibdir)/mod/utilities -nodist_execmod_HEADERS = \ - file_utils.$(FC_MODULE_EXT) \ - string_utils.$(FC_MODULE_EXT) \ - format_utils.$(FC_MODULE_EXT) \ - format_defs.$(FC_MODULE_EXT) \ - numeric_utils.$(FC_MODULE_EXT) - ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw utilities.stamp: $(PRELUDE) $(srcdir)/utilities.nw $(POSTLUDE) @rm -f utilities.tmp @touch utilities.tmp for src in $(libutilities_la_SOURCES); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done @mv -f utilities.tmp utilities.stamp $(libutilities_la_SOURCES): utilities.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f utilities.stamp; \ $(MAKE) $(AM_MAKEFLAGS) utilities.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f utilities.stamp utilities.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/src/utilities/utilities.nw =================================================================== --- trunk/src/utilities/utilities.nw (revision 8428) +++ trunk/src/utilities/utilities.nw (revision 8429) @@ -1,1314 +1,1365 @@ % -*- ess-noweb-default-code-mode: f90-mode; noweb-default-code-mode: f90-mode; -*- % WHIZARD code as NOWEB source: Utilities \chapter{Utilities} \includemodulegraph{utilities} These modules are intended as part of WHIZARD, but in fact they are generic and could be useful for any purpose. The modules depend only on modules from the [[basics]] set. \begin{description} \item[file\_utils] Procedures that deal with external files, if not covered by Fortran built-ins. \item[file\_registries] Manage files that are accessed by their name. \item[string\_utils] Some string-handling utilities. Includes conversion to C string. \item[format\_utils] Utilities for pretty-printing. \item[format\_defs] Predefined format strings. \item[numeric\_utils] Utilities for comparing numerical values. \end{description} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{File Utilities} This module provides miscellaneous tools associated with named external files. Currently only: \begin{itemize} \item Delete a named file \end{itemize} <<[[file_utils.f90]]>>= <> module file_utils use io_units <> <> contains <> end module file_utils @ %def file_utils @ \subsection{Deleting a file} Fortran does not contain a command for deleting a file. Here, we provide a subroutine that deletes a file if it exists. We do not handle the subtleties, so we assume that it is writable if it exists. <>= public :: delete_file <>= subroutine delete_file (name) character(*), intent(in) :: name logical :: exist integer :: u inquire (file = name, exist = exist) if (exist) then u = free_unit () open (unit = u, file = name) close (u, status = "delete") end if end subroutine delete_file @ %def delete_file @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{File Registries} This module provides a file-registry facility. We can open and close files multiple times without inadvertedly accessing a single file by two different I/O unit numbers. Opening a file the first time enters it into the registry. Opening again just returns the associated I/O unit. The registry maintains a reference count, so closing a file does not actually complete until the last reference is released. File access will always be sequential, however. The file can't be opened at different positions simultaneously. <<[[file_registries.f90]]>>= <> module file_registries <> use io_units <> <> <> contains <> end module file_registries @ %def file_registries @ \subsection{File handle} This object holds a filename (fully qualified), the associated unit, and a reference count. The idea is that the object should be deleted when the reference count drops to zero. <>= type :: file_handle_t type(string_t) :: file integer :: unit = 0 integer :: refcount = 0 contains <> end type file_handle_t @ %def file_handle_t @ Debugging output: <>= procedure :: write => file_handle_write <>= subroutine file_handle_write (handle, u, show_unit) class(file_handle_t), intent(in) :: handle integer, intent(in) :: u logical, intent(in), optional :: show_unit logical :: show_u show_u = .false.; if (present (show_unit)) show_u = show_unit if (show_u) then write (u, "(3x,A,1x,I0,1x,'(',I0,')')") & char (handle%file), handle%unit, handle%refcount else write (u, "(3x,A,1x,'(',I0,')')") & char (handle%file), handle%refcount end if end subroutine file_handle_write @ %def file_handle_write @ Initialize with a file name, don't open the file yet: <>= procedure :: init => file_handle_init <>= subroutine file_handle_init (handle, file) class(file_handle_t), intent(out) :: handle type(string_t), intent(in) :: file handle%file = file end subroutine file_handle_init @ %def file_handle_init @ We check the [[refcount]] before actually opening the file. <>= procedure :: open => file_handle_open <>= subroutine file_handle_open (handle) class(file_handle_t), intent(inout) :: handle if (handle%refcount == 0) then handle%unit = free_unit () open (unit = handle%unit, file = char (handle%file), action = "read", & status = "old") end if handle%refcount = handle%refcount + 1 end subroutine file_handle_open @ %def file_handle_open @ Analogously, close if the refcount drops to zero. The caller may then delete the object. <>= procedure :: close => file_handle_close <>= subroutine file_handle_close (handle) class(file_handle_t), intent(inout) :: handle handle%refcount = handle%refcount - 1 if (handle%refcount == 0) then close (handle%unit) handle%unit = 0 end if end subroutine file_handle_close @ %def file_handle_close @ The I/O unit will be nonzero when the file is open. <>= procedure :: is_open => file_handle_is_open <>= function file_handle_is_open (handle) result (flag) class(file_handle_t), intent(in) :: handle logical :: flag flag = handle%unit /= 0 end function file_handle_is_open @ %def file_handle_is_open @ Return the filename, so we can identify the entry. <>= procedure :: get_file => file_handle_get_file <>= function file_handle_get_file (handle) result (file) class(file_handle_t), intent(in) :: handle type(string_t) :: file file = handle%file end function file_handle_get_file @ %def file_handle_get_file @ For debugging, return the I/O unit number. <>= procedure :: get_unit => file_handle_get_unit <>= function file_handle_get_unit (handle) result (unit) class(file_handle_t), intent(in) :: handle integer :: unit unit = handle%unit end function file_handle_get_unit @ %def file_handle_get_unit @ \subsection{File handles registry} This is implemented as a doubly-linked list. The list exists only once in the program, as a private module variable. Extend the handle type to become a list entry: <>= type, extends (file_handle_t) :: file_entry_t type(file_entry_t), pointer :: prev => null () type(file_entry_t), pointer :: next => null () end type file_entry_t @ %def file_entry_t @ The actual registry. We need only the pointer to the first entry. <>= public :: file_registry_t <>= type :: file_registry_t type(file_entry_t), pointer :: first => null () contains <> end type file_registry_t @ %def file_registry_t @ Debugging output. <>= procedure :: write => file_registry_write <>= subroutine file_registry_write (registry, unit, show_unit) class(file_registry_t), intent(in) :: registry integer, intent(in), optional :: unit logical, intent(in), optional :: show_unit type(file_entry_t), pointer :: entry integer :: u u = given_output_unit (unit) if (associated (registry%first)) then write (u, "(1x,A)") "File registry:" entry => registry%first do while (associated (entry)) call entry%write (u, show_unit) entry => entry%next end do else write (u, "(1x,A)") "File registry: [empty]" end if end subroutine file_registry_write @ %def file_registry_write @ Open a file: find the appropriate entry. Create a new entry and add to the list if necessary. The list is extended at the beginning. Return the I/O unit number for the records. <>= procedure :: open => file_registry_open <>= subroutine file_registry_open (registry, file, unit) class(file_registry_t), intent(inout) :: registry type(string_t), intent(in) :: file integer, intent(out), optional :: unit type(file_entry_t), pointer :: entry entry => registry%first FIND_ENTRY: do while (associated (entry)) if (entry%get_file () == file) exit FIND_ENTRY entry => entry%next end do FIND_ENTRY if (.not. associated (entry)) then allocate (entry) call entry%init (file) if (associated (registry%first)) then registry%first%prev => entry entry%next => registry%first end if registry%first => entry end if call entry%open () if (present (unit)) unit = entry%get_unit () end subroutine file_registry_open @ %def file_registry_open @ Close a file: find the appropriate entry. Delete the entry if there is no file connected to it anymore. <>= procedure :: close => file_registry_close <>= subroutine file_registry_close (registry, file) class(file_registry_t), intent(inout) :: registry type(string_t), intent(in) :: file type(file_entry_t), pointer :: entry entry => registry%first FIND_ENTRY: do while (associated (entry)) if (entry%get_file () == file) exit FIND_ENTRY entry => entry%next end do FIND_ENTRY if (associated (entry)) then call entry%close () if (.not. entry%is_open ()) then if (associated (entry%prev)) then entry%prev%next => entry%next else registry%first => entry%next end if if (associated (entry%next)) then entry%next%prev => entry%prev end if deallocate (entry) end if end if end subroutine file_registry_close @ %def file_registry_close @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{String Utilities} This module provides tools associated with strings (built-in and variable). Currently: \begin{itemize} \item Upper and lower case for strings \item Convert to null-terminated C string \end{itemize} <<[[string_utils.f90]]>>= <> module string_utils use, intrinsic :: iso_c_binding <> <> <> <> <> contains <> end module string_utils @ %def string_utils @ \subsection{Upper and Lower Case} These are, unfortunately, not part of Fortran. <>= public :: upper_case public :: lower_case <>= interface upper_case module procedure upper_case_char, upper_case_string end interface interface lower_case module procedure lower_case_char, lower_case_string end interface <>= function upper_case_char (string) result (new_string) character(*), intent(in) :: string character(len(string)) :: new_string integer :: pos, code integer, parameter :: offset = ichar('A')-ichar('a') do pos = 1, len (string) code = ichar (string(pos:pos)) select case (code) case (ichar('a'):ichar('z')) new_string(pos:pos) = char (code + offset) case default new_string(pos:pos) = string(pos:pos) end select end do end function upper_case_char function lower_case_char (string) result (new_string) character(*), intent(in) :: string character(len(string)) :: new_string integer :: pos, code integer, parameter :: offset = ichar('a')-ichar('A') do pos = 1, len (string) code = ichar (string(pos:pos)) select case (code) case (ichar('A'):ichar('Z')) new_string(pos:pos) = char (code + offset) case default new_string(pos:pos) = string(pos:pos) end select end do end function lower_case_char function upper_case_string (string) result (new_string) type(string_t), intent(in) :: string type(string_t) :: new_string new_string = upper_case_char (char (string)) end function upper_case_string function lower_case_string (string) result (new_string) type(string_t), intent(in) :: string type(string_t) :: new_string new_string = lower_case_char (char (string)) end function lower_case_string @ %def upper_case lower_case @ -\subsection{C-compatible Output} -Convert a FORTRAN string into a zero terminated C string. +\subsection{C-Fortran String Conversion} +Convert a FORTRAN string to a null-terminated C string. <>= public :: string_f2c <>= interface string_f2c module procedure string_f2c_char, string_f2c_var_str end interface string_f2c <>= pure function string_f2c_char (i) result (o) character(*), intent(in) :: i character(kind=c_char, len=len (i) + 1) :: o o = i // c_null_char end function string_f2c_char pure function string_f2c_var_str (i) result (o) type(string_t), intent(in) :: i character(kind=c_char, len=len (i) + 1) :: o o = char (i) // c_null_char end function string_f2c_var_str @ %def string_f2c +@ The same task done by a subroutine, analogous to the C [[strcpy]] function. +We append a null char and copy the characters to the output string, given by a +character array -- which is equal to a [[c_char]] character string by the rule +of sequence association. + +Note: Just like with the [[strcpy]] function, there is no bounds check. +<>= + public :: strcpy_f2c +<>= + subroutine strcpy_f2c (fstring, cstring) + character(*), intent(in) :: fstring + character(c_char), dimension(*), intent(inout) :: cstring + + integer :: i + + do i = 1, len (fstring) + cstring(i) = fstring(i:i) + end do + cstring(len(fstring)+1) = c_null_char + + end subroutine strcpy_f2c + +@ %def strcpy_f2c +@ Convert a null-terminated C string to a Fortran string. The C-string +argument is sequence-associated to a one-dimensional array of C characters, +where we do not know the dimension. + +To convert this to a [[string_t]] object, we need to assign it or to wrap it +by another [[var_str]] conversion. +<>= + public :: string_c2f +<>= + function string_c2f (cstring) result (fstring) + character(c_char), dimension(*), intent(in) :: cstring + character(:), allocatable :: fstring + + integer :: i, n + + n = 0 + do while (cstring(n+1) /= c_null_char) + n = n + 1 + end do + + allocate (character(n) :: fstring) + do i = 1, n + fstring(i:i) = cstring(i) + end do + + end function string_c2f + +@ %def string_c2f @ \subsection{Number Conversion} Create a string from a number. We use fixed format for the reals and variable format for integers. <>= public :: str <>= interface str module procedure str_log, str_logs, str_int, str_ints, & str_real, str_reals, str_complex, str_complexs end interface <>= function str_log (l) result (s) logical, intent(in) :: l type(string_t) :: s if (l) then s = "True" else s = "False" end if end function str_log function str_logs (x) result (s) logical, dimension(:), intent(in) :: x <> end function str_logs function str_int (i) result (s) integer, intent(in) :: i type(string_t) :: s character(32) :: buffer write (buffer, "(I0)") i s = var_str (trim (adjustl (buffer))) end function str_int function str_ints (x) result (s) integer, dimension(:), intent(in) :: x <> end function str_ints function str_real (x) result (s) real(default), intent(in) :: x type(string_t) :: s character(32) :: buffer write (buffer, "(ES17.10)") x s = var_str (trim (adjustl (buffer))) end function str_real function str_reals (x) result (s) real(default), dimension(:), intent(in) :: x <> end function str_reals function str_complex (x) result (s) complex(default), intent(in) :: x type(string_t) :: s s = str_real (real (x)) // " + i " // str_real (aimag (x)) end function str_complex function str_complexs (x) result (s) complex(default), dimension(:), intent(in) :: x <> end function str_complexs @ %def str <>= type(string_t) :: s integer :: i s = '[' do i = 1, size(x) - 1 s = s // str(x(i)) // ', ' end do s = s // str(x(size(x))) // ']' @ @ Auxiliary: Read real, integer, string value. <>= public :: read_rval public :: read_ival <>= function read_rval (s) result (rval) real(default) :: rval type(string_t), intent(in) :: s character(80) :: buffer buffer = s read (buffer, *) rval end function read_rval function read_ival (s) result (ival) integer :: ival type(string_t), intent(in) :: s character(80) :: buffer buffer = s read (buffer, *) ival end function read_ival @ %def read_rval read_ival @ \subsection{String splitting} <>= public :: string_contains_word <>= pure function string_contains_word (str, word, include_identical) result (val) logical :: val type(string_t), intent(in) :: str, word type(string_t) :: str_tmp, str_out logical, intent(in), optional :: include_identical logical :: yorn str_tmp = str val = .false. yorn = .false.; if (present (include_identical)) yorn = include_identical if (yorn) val = str == word call split (str_tmp, str_out, word) val = val .or. (str_out /= "") end function string_contains_word @ %def string_contains_word @ Create an array of strings using a separator. <>= public :: split_string <>= pure subroutine split_string (str, separator, str_array) type(string_t), dimension(:), allocatable, intent(out) :: str_array type(string_t), intent(in) :: str, separator type(string_t) :: str_tmp, str_out integer :: n_str n_str = 0; str_tmp = str do while (string_contains_word (str_tmp, separator)) n_str = n_str + 1 call split (str_tmp, str_out, separator) end do allocate (str_array (n_str)) n_str = 1; str_tmp = str do while (string_contains_word (str_tmp, separator)) call split (str_tmp, str_array (n_str), separator) n_str = n_str + 1 end do end subroutine split_string @ %def split_string @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Format Utilities} This module provides miscellaneous tools associated with formatting and pretty-printing. \begin{itemize} \item Horizontal separator lines in output \item Indenting an output line \item Formatting a number for \TeX\ output. \item Formatting a number for MetaPost output. \item Alternate numeric formats. \end{itemize} <<[[format_utils.f90]]>>= <> module format_utils <> <> use string_utils, only: lower_case use io_units, only: given_output_unit <> <> contains <> end module format_utils @ %def format_utils @ \subsection{Line Output} Write a separator line. <>= public :: write_separator <>= subroutine write_separator (u, mode) integer, intent(in) :: u integer, intent(in), optional :: mode integer :: m m = 1; if (present (mode)) m = mode select case (m) case default write (u, "(A)") repeat ("-", 72) case (1) write (u, "(A)") repeat ("-", 72) case (2) write (u, "(A)") repeat ("=", 72) end select end subroutine write_separator @ %def write_separator @ Indent the line with given number of blanks. <>= public :: write_indent <>= subroutine write_indent (unit, indent) integer, intent(in) :: unit integer, intent(in), optional :: indent if (present (indent)) then write (unit, "(1x,A)", advance="no") repeat (" ", indent) end if end subroutine write_indent @ %def write_indent @ \subsection{Array Output} Write an array of integers. <>= public :: write_integer_array <>= subroutine write_integer_array (array, unit, n_max, no_skip) integer, intent(in), dimension(:) :: array integer, intent(in), optional :: unit integer, intent(in), optional :: n_max logical, intent(in), optional :: no_skip integer :: u, i, n logical :: yorn u = given_output_unit (unit) yorn = .false.; if (present (no_skip)) yorn = no_skip if (present (n_max)) then n = n_max else n = size (array) end if do i = 1, n if (i < n .or. yorn) then write (u, "(I0, A)", advance = "no") array(i), ", " else write (u, "(I0)") array(i) end if end do end subroutine write_integer_array @ %def write_integer_array @ \subsection{\TeX-compatible Output} Quote underscore characters for use in \TeX\ output. <>= public :: quote_underscore <>= function quote_underscore (string) result (quoted) type(string_t) :: quoted type(string_t), intent(in) :: string type(string_t) :: part type(string_t) :: buffer buffer = string quoted = "" do call split (part, buffer, "_") quoted = quoted // part if (buffer == "") exit quoted = quoted // "\_" end do end function quote_underscore @ %def quote_underscore @ Format a number with $n$ significant digits for use in \TeX\ documents. <>= public :: tex_format <>= function tex_format (rval, n_digits) result (string) type(string_t) :: string real(default), intent(in) :: rval integer, intent(in) :: n_digits integer :: e, n, w, d real(default) :: absval real(default) :: mantissa character :: sign character(20) :: format character(80) :: cstr n = min (abs (n_digits), 16) if (rval == 0) then string = "0" else absval = abs (rval) e = int (log10 (absval)) if (rval < 0) then sign = "-" else sign = "" end if select case (e) case (:-3) d = max (n - 1, 0) w = max (d + 2, 2) write (format, "('(F',I0,'.',I0,',A,I0,A)')") w, d mantissa = absval * 10._default ** (1 - e) write (cstr, fmt=format) mantissa, "\times 10^{", e - 1, "}" case (-2:0) d = max (n - e, 1 - e) w = max (d + e + 2, d + 2) write (format, "('(F',I0,'.',I0,')')") w, d write (cstr, fmt=format) absval case (1:2) d = max (n - e - 1, -e, 0) w = max (d + e + 2, d + 2, e + 2) write (format, "('(F',I0,'.',I0,')')") w, d write (cstr, fmt=format) absval case default d = max (n - 1, 0) w = max (d + 2, 2) write (format, "('(F',I0,'.',I0,',A,I0,A)')") w, d mantissa = absval * 10._default ** (- e) write (cstr, fmt=format) mantissa, "\times 10^{", e, "}" end select string = sign // trim (cstr) end if end function tex_format @ %def tex_format @ \subsection{Metapost-compatible Output} Write a number for use in Metapost code: <>= public :: mp_format <>= function mp_format (rval) result (string) type(string_t) :: string real(default), intent(in) :: rval character(16) :: tmp write (tmp, "(G16.8)") rval string = lower_case (trim (adjustl (trim (tmp)))) end function mp_format @ %def mp_format @ \subsection{Conditional Formatting} Conditional format string, intended for switchable numeric precision. <>= public :: pac_fmt <>= subroutine pac_fmt (fmt, fmt_orig, fmt_pac, pacify) character(*), intent(in) :: fmt_orig, fmt_pac character(*), intent(out) :: fmt logical, intent(in), optional :: pacify logical :: pacified pacified = .false. if (present (pacify)) pacified = pacify if (pacified) then fmt = fmt_pac else fmt = fmt_orig end if end subroutine pac_fmt @ %def pac_fmt @ \subsection{Guard tiny values} This function can be applied if values smaller than $10^{-99}$ would cause an underflow in the output format. We know that Fortran fixed-format can handle this by omitting the exponent letter, but we should expect non-Fortran or Fortran list-directed input, which would fail. We reset such values to $\pm 10^{-99}$, assuming that such tiny values would not matter, except for being non-zero. <>= public :: refmt_tiny <>= elemental function refmt_tiny (val) result (trunc_val) real(default), intent(in) :: val real(default) :: trunc_val real(default), parameter :: tiny_val = 1.e-99_default if (val /= 0) then if (abs (val) < tiny_val) then trunc_val = sign (tiny_val, val) else trunc_val = val end if else trunc_val = val end if end function refmt_tiny @ %def refmt_tiny @ \subsection{Compressed output of integer arrays} <>= public :: write_compressed_integer_array <>= subroutine write_compressed_integer_array (chars, array) character(len=*), intent(out) :: chars integer, intent(in), allocatable, dimension(:) :: array logical, dimension(:), allocatable :: used character(len=16) :: tmp type(string_t) :: string integer :: i, j, start_chain, end_chain chars = '[none]' string = "" if (allocated (array)) then if (size (array) > 0) then allocate (used (size (array))) used = .false. do i = 1, size (array) if (.not. used(i)) then start_chain = array(i) end_chain = array(i) used(i) = .true. EXTEND: do do j = 1, size (array) if (array(j) == end_chain + 1) then end_chain = array(j) used(j) = .true. cycle EXTEND end if if (array(j) == start_chain - 1) then start_chain = array(j) used(j) = .true. cycle EXTEND end if end do exit end do EXTEND if (end_chain - start_chain > 0) then write (tmp, "(I0,A,I0)") start_chain, "-", end_chain else write (tmp, "(I0)") start_chain end if string = string // trim (tmp) if (any (.not. used)) then string = string // ',' end if end if end do chars = string end if end if chars = adjustr (chars) end subroutine write_compressed_integer_array @ %def write_compressed_integer_array %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Format Definitions} This module provides named integer parameters that specify certain format strings, used for numerical output. <<[[format_defs.f90]]>>= <> module format_defs <> <> end module format_defs @ %def format_defs @ We collect format strings for various numerical output formats here. <>= character(*), parameter, public :: FMT_19 = "ES19.12" character(*), parameter, public :: FMT_18 = "ES18.11" character(*), parameter, public :: FMT_17 = "ES17.10" character(*), parameter, public :: FMT_16 = "ES16.9" character(*), parameter, public :: FMT_15 = "ES15.8" character(*), parameter, public :: FMT_14 = "ES14.7" character(*), parameter, public :: FMT_13 = "ES13.6" character(*), parameter, public :: FMT_12 = "ES12.5" character(*), parameter, public :: FMT_11 = "ES11.4" character(*), parameter, public :: FMT_10 = "ES10.3" @ %def FMT_10 FMT_11 FMT_12 FMT_13 FMT_14 @ %def FMT_15 FMT_16 FMT_17 FMT_18 FMT_19 @ Fixed-point formats for better readability, where appropriate. <>= character(*), parameter, public :: FMF_12 = "F12.9" @ %def FMF_12 @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Numeric Utilities} <<[[numeric_utils.f90]]>>= <> module numeric_utils <> <> use string_utils use constants use format_defs <> <> <> <> <> contains <> end module numeric_utils @ %def numeric_utils @ <>= public :: assert <>= subroutine assert (unit, ok, description, exit_on_fail) integer, intent(in) :: unit logical, intent(in) :: ok character(*), intent(in), optional :: description logical, intent(in), optional :: exit_on_fail logical :: ef ef = .false.; if (present (exit_on_fail)) ef = exit_on_fail if (.not. ok) then if (present(description)) then write (unit, "(A)") "* FAIL: " // description else write (unit, "(A)") "* FAIL: Assertion error" end if if (ef) stop 1 end if end subroutine assert @ %def assert @ Compare numbers and output error message if not equal. <>= public:: assert_equal interface assert_equal module procedure assert_equal_integer, assert_equal_integers, & assert_equal_real, assert_equal_reals, & assert_equal_complex, assert_equal_complexs end interface @ <>= subroutine assert_equal_integer (unit, lhs, rhs, description, exit_on_fail) integer, intent(in) :: unit integer, intent(in) :: lhs, rhs character(*), intent(in), optional :: description logical, intent(in), optional :: exit_on_fail type(string_t) :: desc logical :: ok ok = lhs == rhs desc = ''; if (present (description)) desc = var_str(description) // ": " call assert (unit, ok, char(desc // str (lhs) // " /= " // str (rhs)), exit_on_fail) end subroutine assert_equal_integer @ %def assert_equal_integer @ <>= subroutine assert_equal_integers (unit, lhs, rhs, description, exit_on_fail) integer, intent(in) :: unit integer, dimension(:), intent(in) :: lhs, rhs character(*), intent(in), optional :: description logical, intent(in), optional :: exit_on_fail type(string_t) :: desc logical :: ok ok = all(lhs == rhs) desc = ''; if (present (description)) desc = var_str(description) // ": " call assert (unit, ok, char(desc // str (lhs) // " /= " // str (rhs)), exit_on_fail) end subroutine assert_equal_integers @ %def assert_equal_integers @ <>= subroutine assert_equal_real (unit, lhs, rhs, description, & abs_smallness, rel_smallness, exit_on_fail) integer, intent(in) :: unit real(default), intent(in) :: lhs, rhs character(*), intent(in), optional :: description real(default), intent(in), optional :: abs_smallness, rel_smallness logical, intent(in), optional :: exit_on_fail type(string_t) :: desc logical :: ok ok = nearly_equal (lhs, rhs, abs_smallness, rel_smallness) desc = ''; if (present (description)) desc = var_str(description) // ": " call assert (unit, ok, char(desc // str (lhs) // " /= " // str (rhs)), exit_on_fail) end subroutine assert_equal_real @ %def assert_equal_real @ <>= subroutine assert_equal_reals (unit, lhs, rhs, description, & abs_smallness, rel_smallness, exit_on_fail) integer, intent(in) :: unit real(default), dimension(:), intent(in) :: lhs, rhs character(*), intent(in), optional :: description real(default), intent(in), optional :: abs_smallness, rel_smallness logical, intent(in), optional :: exit_on_fail type(string_t) :: desc logical :: ok ok = all(nearly_equal (lhs, rhs, abs_smallness, rel_smallness)) desc = ''; if (present (description)) desc = var_str(description) // ": " call assert (unit, ok, char(desc // str (lhs) // " /= " // str (rhs)), exit_on_fail) end subroutine assert_equal_reals @ %def assert_equal_reals @ <>= subroutine assert_equal_complex (unit, lhs, rhs, description, & abs_smallness, rel_smallness, exit_on_fail) integer, intent(in) :: unit complex(default), intent(in) :: lhs, rhs character(*), intent(in), optional :: description real(default), intent(in), optional :: abs_smallness, rel_smallness logical, intent(in), optional :: exit_on_fail type(string_t) :: desc logical :: ok ok = nearly_equal (real(lhs), real(rhs), abs_smallness, rel_smallness) & .and. nearly_equal (aimag(lhs), aimag(rhs), abs_smallness, rel_smallness) desc = ''; if (present (description)) desc = var_str(description) // ": " call assert (unit, ok, char(desc // str (lhs) // " /= " // str (rhs)), exit_on_fail) end subroutine assert_equal_complex @ %def assert_equal_complex @ <>= subroutine assert_equal_complexs (unit, lhs, rhs, description, & abs_smallness, rel_smallness, exit_on_fail) integer, intent(in) :: unit complex(default), dimension(:), intent(in) :: lhs, rhs character(*), intent(in), optional :: description real(default), intent(in), optional :: abs_smallness, rel_smallness logical, intent(in), optional :: exit_on_fail type(string_t) :: desc logical :: ok ok = all (nearly_equal (real(lhs), real(rhs), abs_smallness, rel_smallness)) & .and. all (nearly_equal (aimag(lhs), aimag(rhs), abs_smallness, rel_smallness)) desc = ''; if (present (description)) desc = var_str(description) // ": " call assert (unit, ok, char(desc // str (lhs) // " /= " // str (rhs)), exit_on_fail) end subroutine assert_equal_complexs @ %def assert_equal_complexs @ Note that this poor man's check will be disabled if someone compiles with [[-ffast-math]] or similar optimizations. <>= elemental function ieee_is_nan (x) result (yorn) logical :: yorn real(default), intent(in) :: x yorn = (x /= x) end function ieee_is_nan @ %def ieee_is_nan @ This is still not perfect but should work in most cases. Usually one wants to compare to a relative epsilon [[rel_smallness]], except for numbers close to zero defined by [[abs_smallness]]. Both might need adaption to specific use cases but have reasonable defaults. <>= public :: nearly_equal <>= interface nearly_equal module procedure nearly_equal_real module procedure nearly_equal_complex end interface nearly_equal <>= elemental function nearly_equal_real (a, b, abs_smallness, rel_smallness) result (r) logical :: r real(default), intent(in) :: a, b real(default), intent(in), optional :: abs_smallness, rel_smallness real(default) :: abs_a, abs_b, diff, abs_small, rel_small abs_a = abs (a) abs_b = abs (b) diff = abs (a - b) ! shortcut, handles infinities and nans if (a == b) then r = .true. return else if (ieee_is_nan (a) .or. ieee_is_nan (b) .or. ieee_is_nan (diff)) then r = .false. return end if abs_small = tiny_13; if (present (abs_smallness)) abs_small = abs_smallness rel_small = tiny_10; if (present (rel_smallness)) rel_small = rel_smallness if (abs_a < abs_small .and. abs_b < abs_small) then r = diff < abs_small else r = diff / max (abs_a, abs_b) < rel_small end if end function nearly_equal_real @ %def nearly_equal_real <>= elemental function nearly_equal_complex (a, b, abs_smallness, rel_smallness) result (r) logical :: r complex(default), intent(in) :: a, b real(default), intent(in), optional :: abs_smallness, rel_smallness r = nearly_equal_real (real (a), real (b), abs_smallness, rel_smallness) .and. & nearly_equal_real (aimag (a), aimag(b), abs_smallness, rel_smallness) end function nearly_equal_complex @ %def neary_equal_complex @ Often we will need to check whether floats vanish: <>= public:: vanishes interface vanishes module procedure vanishes_real, vanishes_complex end interface @ <>= elemental function vanishes_real (x, abs_smallness, rel_smallness) result (r) logical :: r real(default), intent(in) :: x real(default), intent(in), optional :: abs_smallness, rel_smallness r = nearly_equal (x, zero, abs_smallness, rel_smallness) end function vanishes_real elemental function vanishes_complex (x, abs_smallness, rel_smallness) result (r) logical :: r complex(default), intent(in) :: x real(default), intent(in), optional :: abs_smallness, rel_smallness r = vanishes_real (abs (x), abs_smallness, rel_smallness) end function vanishes_complex @ %def vanishes @ <>= public :: expanded_amp2 <>= pure function expanded_amp2 (amp_tree, amp_blob) result (amp2) real(default) :: amp2 complex(default), dimension(:), intent(in) :: amp_tree, amp_blob amp2 = sum (amp_tree * conjg (amp_tree) + & amp_tree * conjg (amp_blob) + & amp_blob * conjg (amp_tree)) end function expanded_amp2 @ %def expanded_amp2 @ <>= public :: abs2 <>= elemental function abs2 (c) result (c2) real(default) :: c2 complex(default), intent(in) :: c c2 = real (c * conjg(c)) end function abs2 @ %def abs2 @ Remove element with [[index]] from array <>= public:: remove_array_element interface remove_array_element module procedure remove_array_element_logical end interface @ <>= function remove_array_element_logical (array, index) result (array_reduced) logical, intent(in), dimension(:) :: array integer, intent(in) :: index logical, dimension(:), allocatable :: array_reduced integer :: i allocate (array_reduced(0)) do i = 1, size (array) if (i /= index) then array_reduced = [array_reduced, [array(i)]] end if end do end function remove_array_element_logical @ %def remove_array_element @ Remove all duplicates from an array of signed integers and returns an unordered array of remaining elements. This method does not really fit into this module. It could be part of a larger module which deals with array manipulations. <>= public :: remove_duplicates_from_int_array <>= function remove_duplicates_from_int_array (array) result (array_unique) integer, intent(in), dimension(:) :: array integer, dimension(:), allocatable :: array_unique integer :: i allocate (array_unique(0)) do i = 1, size (array) if (any (array_unique == array(i))) cycle array_unique = [array_unique, [array(i)]] end do end function remove_duplicates_from_int_array @ %def remove_duplicates_from_int_array @ <>= public :: extend_integer_array <>= subroutine extend_integer_array (list, incr, initial_value) integer, intent(inout), dimension(:), allocatable :: list integer, intent(in) :: incr integer, intent(in), optional :: initial_value integer, dimension(:), allocatable :: list_store integer :: n, ini ini = 0; if (present (initial_value)) ini = initial_value n = size (list) allocate (list_store (n)) list_store = list deallocate (list) allocate (list (n+incr)) list(1:n) = list_store list(1+n : n+incr) = ini deallocate (list_store) end subroutine extend_integer_array @ %def extend_integer_array @ <>= public :: crop_integer_array <>= subroutine crop_integer_array (list, i_crop) integer, intent(inout), dimension(:), allocatable :: list integer, intent(in) :: i_crop integer, dimension(:), allocatable :: list_store allocate (list_store (i_crop)) list_store = list(1:i_crop) deallocate (list) allocate (list (i_crop)) list = list_store deallocate (list_store) end subroutine crop_integer_array @ %def crop_integer_array @ We also need an evaluation of $\log x$ which is stable near $x=1$. <>= public :: log_prec <>= function log_prec (x, xb) result (lx) real(default), intent(in) :: x, xb real(default) :: a1, a2, a3, lx a1 = xb a2 = a1 * xb / two a3 = a2 * xb * two / three if (abs (a3) < epsilon (a3)) then lx = - a1 - a2 - a3 else lx = log (x) end if end function log_prec @ %def log_prec @ <>= public :: split_array <>= interface split_array module procedure split_integer_array module procedure split_real_array end interface <>= subroutine split_integer_array (list1, list2) integer, intent(inout), dimension(:), allocatable :: list1, list2 integer, dimension(:), allocatable :: list_store allocate (list_store (size (list1) - size (list2))) list2 = list1(:size (list2)) list_store = list1 (size (list2) + 1:) deallocate (list1) allocate (list1 (size (list_store))) list1 = list_store deallocate (list_store) end subroutine split_integer_array subroutine split_real_array (list1, list2) real(default), intent(inout), dimension(:), allocatable :: list1, list2 real(default), dimension(:), allocatable :: list_store allocate (list_store (size (list1) - size (list2))) list2 = list1(:size (list2)) list_store = list1 (size (list2) + 1:) deallocate (list1) allocate (list1 (size (list_store))) list1 = list_store deallocate (list_store) end subroutine split_real_array @ %def split_array @ Index: trunk/src/openloops/Makefile.am =================================================================== --- trunk/src/openloops/Makefile.am (revision 8428) +++ trunk/src/openloops/Makefile.am (revision 8429) @@ -1,223 +1,229 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The files in this directory interface the OpenLoops amplitude calculator ## We create a library which is still to be combined with auxiliary libs. noinst_LTLIBRARIES = liboloops.la COMMOM_F90 = MPI_F90 = \ prc_openloops.f90_mpi SERIAL_F90 = \ prc_openloops.f90_serial EXTRA_DIST = \ $(COMMON_F90) \ $(SERIAL_F90) \ $(MPI_F90) nodist_liboloops_la_SOURCES = \ $(COMMON_F90) \ prc_openloops.f90 DISTCLEANFILES = prc_openloops.f90 if FC_USE_MPI prc_openloops.f90: prc_openloops.f90_mpi -cp -f $< $@ else prc_openloops.f90: prc_openloops.f90_serial -cp -f $< $@ endif ## Omitting this would exclude it from the distribution dist_noinst_DATA = openloops.nw +# Modules and installation # Dump module names into file Modules +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = \ + ${liboloops_la_SOURCES:.f90=.$(FCMOD)} \ + prc_openloops.$(FCMOD) + liboloops_Modules = $(nodist_liboloops_la_SOURCES:.f90=) Modules: Makefile @for module in $(liboloops_Modules); do \ echo $$module >> $@.new; \ done @if diff $@ $@.new -q >/dev/null; then \ rm $@.new; \ else \ mv $@.new $@; echo "Modules updated"; \ fi BUILT_SOURCES = Modules ## Fortran module dependencies # Get module lists from other directories module_lists = \ ../basics/Modules \ ../utilities/Modules \ ../testing/Modules \ ../system/Modules \ ../physics/Modules \ ../qft/Modules \ ../types/Modules \ ../particles/Modules \ ../matrix_elements/Modules \ ../me_methods/Modules \ ../fks/Modules \ ../variables/Modules \ ../blha/Modules $(module_lists): $(MAKE) -C `dirname $@` Modules Module_dependencies.sed: $(nodist_liboloops_la_SOURCES) Module_dependencies.sed: $(module_lists) @rm -f $@ echo 's/, *only:.*//' >> $@ echo 's/, *&//' >> $@ echo 's/, *.*=>.*//' >> $@ echo 's/$$/.lo/' >> $@ for list in $(module_lists); do \ dir="`dirname $$list`"; \ for mod in `cat $$list`; do \ echo 's!: '$$mod'.lo$$!': $$dir/$$mod'.lo!' >> $@; \ done \ done DISTCLEANFILES += Module_dependencies.sed # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: Module_dependencies.sed Makefile.depend: $(nodist_liboloops_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -f Module_dependencies.sed; \ done > $@ DISTCLEANFILES += Makefile.depend # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ AM_FCFLAGS = -I../basics -I../utilities -I../testing -I../system -I../combinatorics -I../parsing -I../physics -I../qft -I../expr_base -I../types -I../particles -I../matrix_elements -I../beams -I../me_methods -I../fks -I../variables -I../blha -I../fastjet -I../pdf_builtin -I../lhapdf ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif # MPI if FC_USE_MPI AM_FCFLAGS += $(FCFLAGS_MPI) endif if OPENLOOPS_AVAILABLE AM_FCFLAGS += -L$(OPENLOOPS_DIR)/lib -lcuttools -lopenloops -loneloop -lolcommon -lrambo -ltrred endif ######################################################################## ## Non-standard targets and dependencies ## (Re)create F90 sources from NOWEB source. if NOWEB_AVAILABLE FILTER = -filter "sed 's/defn MPI:/defn/'" PRELUDE = $(top_srcdir)/src/noweb-frame/whizard-prelude.nw POSTLUDE = $(top_srcdir)/src/noweb-frame/whizard-postlude.nw openloops.stamp: $(PRELUDE) $(srcdir)/openloops.nw $(POSTLUDE) @rm -f openloops.tmp @touch openloops.tmp for src in $(COMMON_F90); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src; \ done for src in $(SERIAL_F90:.f90_serial=.f90); do \ $(NOTANGLE) -R[[$$src]] $^ | $(CPIF) $$src'_serial'; \ done for src in $(MPI_F90:.f90_mpi=.f90); do \ $(NOTANGLE) -R[[$$src]] $(FILTER) $^ | $(CPIF) $$src'_mpi'; \ done @mv -f openloops.tmp openloops.stamp $(COMMON_F90) $(SERIAL_F90) $(MPI_F90): openloops.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f openloops.stamp; \ $(MAKE) $(AM_MAKEFLAGS) openloops.stamp; \ fi endif ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f *.f90 *.f90_mpi *.f90_serial *.c endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f *.f90 *.f90_mpi *.f90_serial *.c || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb -rm -f openloops.stamp openloops.tmp - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup Index: trunk/omega/tests/Makefile.am =================================================================== --- trunk/omega/tests/Makefile.am (revision 8428) +++ trunk/omega/tests/Makefile.am (revision 8429) @@ -1,979 +1,979 @@ # Makefile.am -- Makefile for O'Mega within and without WHIZARD ## ## Process this file with automake to produce Makefile.in ## ######################################################################## # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## SUBDIRS = UFO DIST_SUBDIRS = UFO # OMEGA_SPLIT = -target:single_function OMEGA_SPLIT = -target:split_function 10 # OMEGA_SPLIT = -target:split_module 10 # OMEGA_SPLIT = -target:split_file 10 OMEGA_QED = $(top_builddir)/omega/bin/omega_QED$(OCAML_NATIVE_EXT) OMEGA_QED_OPTS = $(OMEGA_SPLIT) -target:parameter_module parameters_QED OMEGA_QCD = $(top_builddir)/omega/bin/omega_QCD$(OCAML_NATIVE_EXT) OMEGA_QCD_OPTS = $(OMEGA_SPLIT) -target:parameter_module parameters_QCD OMEGA_SYM = $(top_builddir)/omega/bin/omega_SYM$(OCAML_NATIVE_EXT) OMEGA_SYM_OPTS = $(OMEGA_SPLIT) -target:parameter_module parameters_SYM OMEGA_SM = $(top_builddir)/omega/bin/omega_SM$(OCAML_NATIVE_EXT) OMEGA_SM_OPTS = $(OMEGA_SPLIT) -target:parameter_module parameters_SM OMEGA_SM_CKM = $(top_builddir)/omega/bin/omega_SM_CKM$(OCAML_NATIVE_EXT) OMEGA_SM_Higgs = $(top_builddir)/omega/bin/omega_SM_Higgs$(OCAML_NATIVE_EXT) OMEGA_THDM = $(top_builddir)/omega/bin/omega_THDM$(OCAML_NATIVE_EXT) OMEGA_THDM_CKM = $(top_builddir)/omega/bin/omega_THDM_CKM$(OCAML_NATIVE_EXT) OMEGA_HSExt = $(top_builddir)/omega/bin/omega_HSExt$(OCAML_NATIVE_EXT) OMEGA_Zprime = $(top_builddir)/omega/bin/omega_Zprime$(OCAML_NATIVE_EXT) OMEGA_SM_top_anom = $(top_builddir)/omega/bin/omega_SM_top_anom$(OCAML_NATIVE_EXT) OMEGA_SM_top_anom_OPTS = $(OMEGA_SPLIT) -target:parameter_module parameters_SM_top_anom OMEGA_UFO = $(top_builddir)/omega/bin/omega_UFO$(OCAML_NATIVE_EXT) OMEGA_UFO_MAJORANA = \ $(top_builddir)/omega/bin/omega_UFO_Majorana$(OCAML_NATIVE_EXT) OMEGA_UFO_OPTS = -target:parameter_module parameters_UFO OMEGA_UFO_PATH = $(top_srcdir)/omega/tests/UFO OMEGA_XXX = $(top_builddir)/omega/bin/omega_%%%$(OCAML_NATIVE_EXT) OMEGA_XXX_OPTS = -target:parameter_module parameters_%%% OMEGA_UFO_XXX_OPTS = \ "-model:UFO_dir $(top_srcdir)/omega/tests/UFO/%%%/ -model:exec" OMEGA_XXX_MAJORANA = \ $(top_builddir)/omega/bin/omega_%%%_Majorana$(OCAML_NATIVE_EXT) OMEGA_XXX_MAJORANA_LEGACY = \ $(top_builddir)/omega/bin/omega_%%%_Majorana_legacy$(OCAML_NATIVE_EXT) OMEGA_QED_VM = $(top_builddir)/omega/bin/omega_QED_VM$(OCAML_NATIVE_EXT) OMEGA_QCD_VM = $(top_builddir)/omega/bin/omega_QCD_VM$(OCAML_NATIVE_EXT) OMEGA_SM_VM = $(top_builddir)/omega/bin/omega_SM_VM$(OCAML_NATIVE_EXT) OMEGA_SM_CKM_VM = $(top_builddir)/omega/bin/omega_SM_CKM_VM$(OCAML_NATIVE_EXT) OMEGA_THDM_VM = $(top_builddir)/omega/bin/omega_THDM_VM$(OCAML_NATIVE_EXT) OMEGA_THDM_CKM_VM = $(top_builddir)/omega/bin/omega_THDM_CKM_VM$(OCAML_NATIVE_EXT) OMEGA_HSExt_VM = $(top_builddir)/omega/bin/omega_HSExt_VM$(OCAML_NATIVE_EXT) OMEGA_Zprime_VM = $(top_builddir)/omega/bin/omega_Zprime_VM$(OCAML_NATIVE_EXT) OMEGA_SM_Higgs_VM = $(top_builddir)/omega/bin/omega_SM_Higgs_VM$(OCAML_NATIVE_EXT) OMEGA_XXX_VM = $(top_builddir)/omega/bin/omega_%%%_VM$(OCAML_NATIVE_EXT) OMEGA_XXX_VM_PARAMS_OPTS = -params -target:parameter_module_external \ parameters_%%% -target:wrapper_module %% -target:bytecode_file % AM_FCFLAGS = -I$(top_builddir)/omega/src AM_LDFLAGS = ######################################################################## ## Default Fortran compiler options ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) AM_TESTS_ENVIRONMENT = \ export OMP_NUM_THREADS=1; endif ######################################################################## TESTS = XFAIL_TESTS = EXTRA_PROGRAMS = EXTRA_DIST = ######################################################################## include $(top_srcdir)/omega/src/Makefile.ocaml if OCAML_AVAILABLE OCAMLFLAGS += -I $(top_builddir)/omega/src OMEGA_CORE = $(top_builddir)/omega/src/omega_core.cmxa OMEGA_MODELS = $(top_builddir)/omega/src/omega_models.cmxa TESTS += omega_unit EXTRA_PROGRAMS += omega_unit omega_unit_SOURCES = omega_unit.ml omega_unit: $(OMEGA_CORE) omega_unit.cmx @if $(AM_V_P); then :; else echo " OCAMLOPT " $@; fi $(AM_V_at)$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) -o omega_unit \ unix.cmxa $(OMEGA_CORE) omega_unit.cmx omega_unit.cmx: omega_unit.ml omega_unit.cmx: $(OMEGA_CORE) endif ######################################################################## KINDS = $(top_builddir)/omega/src/kinds.lo TESTS += test_omega95 test_omega95_bispinors EXTRA_PROGRAMS += test_omega95 test_omega95_bispinors test_omega95_SOURCES = test_omega95.f90 omega_testtools.f90 test_omega95_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la test_omega95_bispinors_SOURCES = test_omega95_bispinors.f90 omega_testtools.f90 test_omega95_bispinors_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la test_omega95.o test_omega95_bispinors.o: omega_testtools.o if NOWEB_AVAILABLE test_omega95.f90: $(top_srcdir)/omega/src/omegalib.nw $(NOTANGLE) -R[[$@]] $< | $(CPIF) $@ test_omega95_bispinors.f90: $(top_srcdir)/omega/src/omegalib.nw $(NOTANGLE) -R[[$@]] $< | $(CPIF) $@ omega_testtools.f90: $(top_srcdir)/omega/src/omegalib.nw $(NOTANGLE) -R[[$@]] $< | $(CPIF) $@ endif NOWEB_AVAILABLE ######################################################################## if OCAML_AVAILABLE TESTS += test_qed_eemm EXTRA_PROGRAMS += test_qed_eemm test_qed_eemm_SOURCES = test_qed_eemm.f90 parameters_QED.f90 nodist_test_qed_eemm_SOURCES = amplitude_qed_eemm.f90 test_qed_eemm_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la amplitude_qed_eemm.f90: $(OMEGA_QED) Makefile $(OMEGA_QED) $(OMEGA_QED_OPTS) -target:module amplitude_qed_eemm \ -scatter "e+ e- -> m+ m-" > $@ test_qed_eemm.o: amplitude_qed_eemm.o test_qed_eemm.o: parameters_QED.o amplitude_qed_eemm.o: parameters_QED.o endif ######################################################################## EXTENDED_COLOR_TESTS = \ $(srcdir)/fc_s.ects \ $(srcdir)/fc_a.ects $(srcdir)/cf_a.ects $(srcdir)/fa_f.ects \ $(srcdir)/ca_c.ects $(srcdir)/af_f.ects $(srcdir)/ac_c.ects \ $(srcdir)/aa_a.ects \ $(srcdir)/fc_fc.ects \ $(srcdir)/aa_s.ects $(srcdir)/as_a.ects $(srcdir)/sa_a.ects TESTS += ects EXTRA_PROGRAMS += ects EXTRA_DIST += ects_driver.sh $(EXTENDED_COLOR_TESTS) # Explicitly state dependence on model files ects.f90: $(OMEGA_QCD) $(OMEGA_SYM) $(OMEGA_SM) ects.f90: ects_driver.sh $(EXTENDED_COLOR_TESTS) @if $(AM_V_P); then :; else echo " ECTS_DRIVER"; fi $(AM_V_at)$(SHELL) $(srcdir)/ects_driver.sh \ $(OMEGA_XXX) $(EXTENDED_COLOR_TESTS) > $@ ects_SOURCES = color_test_lib.f90 \ parameters_SM.f90 parameters_QED.f90 parameters_QCD.f90 parameters_SYM.f90 nodist_ects_SOURCES = ects.f90 ects_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la ######################################################################## TESTS += cascade # if there is some debugging output ... # XFAIL_TESTS += cascade CASCADE_TESTS = \ bhabha-s-channel.cascade bhabha-t-channel.cascade bhabha-full.cascade \ ww-onlycc.cascade ww-notgc.cascade \ jjj-notgc.cascade \ vbf-noh.cascade cascade: cascade_driver.sh Makefile $(SED) -e 's|%%cascade_tests%%|$(CASCADE_TESTS)|' \ -e 's|%%srcdir%%|$(srcdir)|' \ -e 's|%%SED%%|$(SED)|' \ -e 's|%%top_builddir%%|$(top_builddir)|' \ -e 's|%%OCAML_NATIVE_EXT%%|$(OCAML_NATIVE_EXT)|' $< >$@ chmod +x $@ EXTRA_DIST += cascade_driver.sh $(CASCADE_TESTS) ######################################################################## TESTS += phase_space PHASE_SPACE_TESTS = eeee.phs qqggg.phs phase_space: phase_space_driver.sh Makefile $(SED) -e 's|%%phase_space_tests%%|$(PHASE_SPACE_TESTS)|' \ -e 's|%%srcdir%%|$(srcdir)|' \ -e 's|%%SED%%|$(SED)|' \ -e 's|%%top_builddir%%|$(top_builddir)|' \ -e 's|%%OCAML_NATIVE_EXT%%|$(OCAML_NATIVE_EXT)|' $< >$@ chmod +x $@ EXTRA_DIST += phase_space_driver.sh $(PHASE_SPACE_TESTS) ######################################################################## TESTS += fermi # XFAIL_TESTS += fermi EXTRA_PROGRAMS += fermi EXTRA_DIST += fermi_driver.sh EXTRA_DIST += fermi.list FERMI_SUPPORT_F90 = \ omega_interface.f90 omega_testtools.f90 tao_random_numbers.f90 \ parameters_QED.f90 parameters_QCD.f90 parameters_SYM.f90 \ parameters_SM.f90 parameters_MSSM.f90 parameters_SM_top_anom.f90 FERMI_SUPPORT_O = $(FERMI_SUPPORT_F90:.f90=.o) fermi_lib.o: $(FERMI_SUPPORT_O) FERMI_LIB_F90 = fermi_lib.f90 $(FERMI_SUPPORT_F90) FERMI_LIB_O = $(FERMI_LIB_F90:.f90=.o) run_fermi: fermi ./fermi fermi.f90: fermi_driver.sh $(OMEGA_QED) $(OMEGA_QCD) $(OMEGA_SYM) fermi.f90: $(OMEGA_SM) $(OMEGA_SM_top_anom) fermi.f90: fermi.list @if $(AM_V_P); then :; else echo " FERMI_DRIVER"; fi $(AM_V_at)$(SHELL) $(srcdir)/fermi_driver.sh \ $(OMEGA_XXX) $(OMEGA_SPLIT) < $< > $@ fermi_SOURCES = $(FERMI_LIB_F90) nodist_fermi_SOURCES = fermi.f90 fermi_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la fermi.o: $(FERMI_LIB_O) ######################################################################## TESTS += ward EXTRA_PROGRAMS += ward EXTRA_DIST += ward_driver.sh EXTRA_DIST += ward_identities.list WARD_SUPPORT_F90 = \ omega_interface.f90 omega_testtools.f90 tao_random_numbers.f90 \ parameters_QED.f90 parameters_QCD.f90 parameters_SYM.f90 \ parameters_SM.f90 parameters_SM_top_anom.f90 WARD_SUPPORT_O = $(WARD_SUPPORT_F90:.f90=.o) ward_lib.o: $(WARD_SUPPORT_O) WARD_LIB_F90 = ward_lib.f90 $(WARD_SUPPORT_F90) WARD_LIB_O = $(WARD_LIB_F90:.f90=.o) run_ward: ward ./ward ward.f90: ward_driver.sh $(OMEGA_QED) $(OMEGA_QCD) $(OMEGA_SYM) ward.f90: $(OMEGA_SM) $(OMEGA_SM_top_anom) ward.f90: ward_identities.list @if $(AM_V_P); then :; else echo " WARD_DRIVER"; fi $(AM_V_at)$(SHELL) $(srcdir)/ward_driver.sh \ $(OMEGA_XXX) $(OMEGA_SPLIT) < $< > $@ ward_SOURCES = $(WARD_LIB_F90) nodist_ward_SOURCES = ward.f90 ward_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la ward.o: $(WARD_LIB_O) ######################################################################## EXTRA_PROGRAMS += ward_long EXTRA_DIST += ward_identities_long.list run_ward_long: ward_long ./ward_long ward_long.f90: ward_driver.sh ward_long.f90: ward_identities_long.list @if $(AM_V_P); then :; else echo " WARD_DRIVER"; fi $(AM_V_at)$(SHELL) $(srcdir)/ward_driver.sh \ $(OMEGA_XXX) $(OMEGA_SPLIT) < $< > $@ ward_long_SOURCES = $(WARD_LIB_F90) nodist_ward_long_SOURCES = ward_long.f90 ward_long_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la # ward_long.o: ward_long.f90 # $(FCCOMPILE) -c -o $@ $(FCFLAGS_f90) -O0 $< ward_long.o: $(WARD_LIB_O) ######################################################################## EXTRA_PROGRAMS += ward_fail EXTRA_DIST += ward_identities_fail.list run_ward_fail: ward_fail ./ward_fail ward_fail.f90: ward_driver.sh ward_fail.f90: ward_identities_fail.list @if $(AM_V_P); then :; else echo " WARD_DRIVER"; fi $(AM_V_at)$(SHELL) $(srcdir)/ward_driver.sh \ $(OMEGA_XXX) $(OMEGA_SPLIT) < $< > $@ ward_fail_SOURCES = $(WARD_LIB_F90) nodist_ward_fail_SOURCES = ward_fail.f90 ward_fail_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la ward_fail.o: ward_fail.f90 $(FCCOMPILE) -c -o $@ $(FCFLAGS_f90) -O0 $< ward_fail.o: $(WARD_LIB_O) ######################################################################## TESTS += compare_split_function compare_split_module EXTRA_PROGRAMS += compare_split_function compare_split_module EXTRA_DIST += compare_driver.sh EXTRA_DIST += comparisons.list COMPARE_SUPPORT_F90 = $(WARD_SUPPORT_F90) COMPARE_SUPPORT_O = $(WARD_SUPPORT_O) compare_lib.o: $(COMPARE_SUPPORT_O) COMPARE_LIB_F90 = compare_lib.f90 $(COMPARE_SUPPORT_F90) COMPARE_LIB_O = $(COMPARE_LIB_F90:.f90=.o) run_compare: compare_split_function compare_split_module ./compare_split_function ./compare_split_module compare_split_function.f90: comparisons.list @if $(AM_V_P); then :; else echo " COMPARE_DRIVER"; fi $(AM_V_at)$(SHELL) $(srcdir)/compare_driver.sh SF \ "$(OMEGA_XXX) -target:single_function" \ "$(OMEGA_XXX) -target:split_function 10" < $< > $@ compare_split_module.f90: comparisons.list @if $(AM_V_P); then :; else echo " COMPARE_DRIVER"; fi $(AM_V_at)$(SHELL) $(srcdir)/compare_driver.sh SM \ "$(OMEGA_XXX) -target:single_function" \ "$(OMEGA_XXX) -target:split_module 10" < $< > $@ compare_split_function.f90 compare_split_module.f90: \ compare_driver.sh $(OMEGA_QCD) $(OMEGA_SM) compare_split_function_SOURCES = $(COMPARE_LIB_F90) nodist_compare_split_function_SOURCES = compare_split_function.f90 compare_split_function_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la compare_split_module_SOURCES = $(COMPARE_LIB_F90) nodist_compare_split_module_SOURCES = compare_split_module.f90 compare_split_module_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la compare_split_function.o compare_split_module.o: $(COMPARE_LIB_O) ######################################################################## if OCAML_AVAILABLE TESTS += compare_majorana compare_majorana_legacy compare_majorana_UFO EXTRA_PROGRAMS += compare_majorana compare_majorana_legacy compare_majorana_UFO EXTRA_DIST += compare_driver_majorana.sh compare_driver_majorana_UFO.sh EXTRA_DIST += comparisons_majorana.list comparisons_majorana_legacy.list \ comparisons_majorana_UFO.list compare_majorana.f90: comparisons_majorana.list @if $(AM_V_P); then :; else echo " COMPARE_DRIVER"; fi $(AM_V_at)$(SHELL) $(srcdir)/compare_driver_majorana.sh Maj \ "$(OMEGA_XXX)" "$(OMEGA_XXX_MAJORANA)" < $< > $@ compare_majorana_legacy.f90: comparisons_majorana_legacy.list @if $(AM_V_P); then :; else echo " COMPARE_DRIVER"; fi $(AM_V_at)$(SHELL) $(srcdir)/compare_driver_majorana.sh MajL \ "$(OMEGA_XXX)" "$(OMEGA_XXX_MAJORANA_LEGACY)" < $< > $@ compare_majorana_UFO.f90: comparisons_majorana_UFO.list @if $(AM_V_P); then :; else echo " COMPARE_DRIVER"; fi $(AM_V_at)$(SHELL) $(srcdir)/compare_driver_majorana_UFO.sh MajU \ "$(OMEGA_UFO)" "$(OMEGA_UFO_MAJORANA)" "$(OMEGA_UFO_PATH)" < $< > $@ compare_majorana.f90 compare_majorana_legacy.f90 compare_majorana_UFO.f90: \ compare_driver_majorana.sh $(OMEGA_UFO) $(OMEGA_UFO_MAJORANA) compare_majorana_SOURCES = $(COMPARE_LIB_F90) nodist_compare_majorana_SOURCES = compare_majorana.f90 compare_majorana_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la compare_majorana_legacy_SOURCES = $(COMPARE_LIB_F90) nodist_compare_majorana_legacy_SOURCES = compare_majorana_legacy.f90 compare_majorana_legacy_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la compare_majorana_UFO_SOURCES = $(COMPARE_LIB_F90) parameters_SM_UFO.f90 nodist_compare_majorana_UFO_SOURCES = compare_majorana_UFO.f90 compare_majorana_UFO_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la compare_majorana.o compare_majorana_legacy.o compare_majorana_UFO.o: $(COMPARE_LIB_O) endif ######################################################################## if OCAML_AVAILABLE # At quadruple or extended precision, these tests take waaaaaayyyy too long! if FC_PREC else TESTS += compare_amplitude_UFO # XFAIL_TESTS += compare_amplitude_UFO EXTRA_PROGRAMS += compare_amplitude_UFO EXTRA_DIST += compare_driver_UFO.sh EXTRA_DIST += comparisons_UFO.list compare_amplitude_UFO_SOURCES = \ parameters_SM_from_UFO.f90 compare_lib.f90 \ omega_interface.f90 omega_testtools.f90 tao_random_numbers.f90 compare_amplitude_UFO.f90: comparisons_UFO.list compare_driver_UFO.sh $(OMEGA_UFO) @if $(AM_V_P); then :; else echo " COMPARE_DRIVER_UFO"; fi $(AM_V_at)$(SHELL) $(srcdir)/compare_driver_UFO.sh UFO \ "$(OMEGA_XXX) -model:constant_width" \ "$(OMEGA_UFO) -model:UFO_dir $(top_srcdir)/omega/tests/UFO/%%%/ -model:exec" \ < $< > $@ # -model:long_flavors nodist_compare_amplitude_UFO_SOURCES = \ compare_amplitude_UFO.f90 parameters_SM_UFO.f90 compare_amplitude_UFO_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la parameters_SM_from_UFO.o: parameters_SM_UFO.o compare_amplitude_UFO.o: parameters_SM_UFO.o parameters_SM_from_UFO.o compare_amplitude_UFO.o: $(COMPARE_LIB_O) endif parameters_SM_UFO.f90: $(OMEGA_UFO) $(OMEGA_UFO) \ -model:UFO_dir $(top_srcdir)/omega/tests/UFO/SM/ -model:exec \ -target:parameter_module parameters_sm_ufo -params > $@ endif ######################################################################## if OCAML_AVAILABLE # At quadruple or extended precision, these tests take waaaaaayyyy too long! if FC_PREC else TESTS += fermi_UFO # XFAIL_TESTS += fermi_UFO # We need more work on the parameters to pass the tests # at quadruple or extended precision. if FC_PREC XFAIL_TESTS += fermi_UFO endif EXTRA_PROGRAMS += fermi_UFO EXTRA_DIST += fermi_driver_UFO.sh EXTRA_DIST += fermi_UFO.list FERMI_UFO_SUPPORT_F90 = \ omega_interface.f90 omega_testtools.f90 tao_random_numbers.f90 FERMI_UFO_SUPPORT_O = $(FERMI_UFO_SUPPORT_F90:.f90=.o) fermi_UFO_lib.o: $(FERMI_SUPPORT_O) FERMI_UFO_LIB_F90 = fermi_lib.f90 $(FERMI_UFO_SUPPORT_F90) FERMI_UFO_LIB_O = $(FERMI_UFO_LIB_F90:.f90=.o) run_fermi_UFO: fermi_UFO ./fermi_UFO fermi_UFO.f90: fermi_UFO.list fermi_driver_UFO.sh $(OMEGA_UFO) @if $(AM_V_P); then :; else echo " FERMI_UFO_DRIVER"; fi $(AM_V_at)$(SHELL) $(srcdir)/fermi_driver_UFO.sh \ $(OMEGA_UFO) $(OMEGA_UFO_MAJORANA) $(OMEGA_UFO_PATH) \ $(OMEGA_SPLIT) < $< > $@ fermi_UFO_SOURCES = $(FERMI_UFO_LIB_F90) nodist_fermi_UFO_SOURCES = fermi_UFO.f90 parameters_SM_UFO.f90 fermi_UFO_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la fermi_UFO.o: $(FERMI_UFO_LIB_O) endif endif ######################################################################## if OCAML_AVAILABLE # At quadruple or extended precision, these tests take waaaaaayyyy too long! if FC_PREC else TESTS += ward_UFO # We need more work on the parameters to pass the tests # at quadruple or extended precision. if FC_PREC XFAIL_TESTS += ward_UFO endif EXTRA_PROGRAMS += ward_UFO EXTRA_DIST += ward_driver_UFO.sh EXTRA_DIST += ward_identities_UFO.list WARD_UFO_SUPPORT_F90 = \ omega_interface.f90 omega_testtools.f90 tao_random_numbers.f90 WARD_UFO_SUPPORT_O = $(WARD_UFO_SUPPORT_F90:.f90=.o) ward_UFO_lib.o: $(WARD_SUPPORT_O) WARD_UFO_LIB_F90 = ward_lib.f90 $(WARD_UFO_SUPPORT_F90) WARD_UFO_LIB_O = $(WARD_UFO_LIB_F90:.f90=.o) run_ward_UFO: ward_UFO ./ward_UFO ward_UFO.f90: ward_identities_UFO.list ward_driver_UFO.sh $(OMEGA_UFO) @if $(AM_V_P); then :; else echo " WARD_UFO_DRIVER"; fi $(AM_V_at)$(SHELL) $(srcdir)/ward_driver_UFO.sh \ $(OMEGA_UFO) -model:UFO_dir $(top_srcdir)/omega/tests/UFO/SM/ \ $(OMEGA_SPLIT) < $< > $@ ward_UFO_SOURCES = $(WARD_UFO_LIB_F90) nodist_ward_UFO_SOURCES = ward_UFO.f90 parameters_SM_UFO.f90 ward_UFO_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la ward_UFO.o: $(WARD_UFO_LIB_O) endif endif ######################################################################## TESTS += compare_amplitude_VM EXTRA_PROGRAMS += compare_amplitude_VM EXTRA_DIST += compare_driver_VM.sh compare_driver_VM_wrappers.sh EXTRA_DIST += comparisons_VM.list compare_amplitude_VM.f90: comparisons_VM.list comparisons_VM.wrappers.o @if $(AM_V_P); then :; else echo " COMPARE_DRIVER_VM"; fi $(AM_V_at)$(SHELL) $(srcdir)/compare_driver_VM.sh \ "$(OMEGA_XXX) " "$(OMEGA_XXX_VM) " "$(OMEGA_XXX_VM_PARAMS_OPTS)" < $< > $@ comparisons_VM.wrappers.f90: comparisons_VM.list @if $(AM_V_P); then :; else echo " COMPARE_DRIVER_VM_WRAPPERS"; fi $(AM_V_at)$(SHELL) $(srcdir)/compare_driver_VM_wrappers.sh \ "$(OMEGA_XXX) " "$(OMEGA_XXX_VM) " "$(OMEGA_XXX_VM_PARAMS_OPTS)" < $< > $@ # Explicitly state dependence on model files compare_amplitude_VM.f90: compare_driver_VM.sh \ $(OMEGA_QED) $(OMEGA_QED_VM) \ $(OMEGA_QCD) $(OMEGA_QCD_VM) \ $(OMEGA_SM) $(OMEGA_SM_VM) \ $(OMEGA_SM_CKM) $(OMEGA_SM_CKM_VM) \ $(OMEGA_SM_Higgs) $(OMEGA_SM_Higgs_VM) \ $(OMEGA_THDM) $(OMEGA_THDM_VM) \ $(OMEGA_THDM_CKM) $(OMEGA_THDM_CKM_VM) \ $(OMEGA_HSExt) $(OMEGA_HSExt_VM) \ $(OMEGA_Zprime) $(OMEGA_Zprime_VM) COMPARE_EXTRA_MODELS = parameters_SM_CKM.f90 parameters_SM_Higgs.f90 \ parameters_THDM.f90 parameters_THDM_CKM.f90 parameters_HSExt.f90 \ parameters_Zprime.f90 compare_amplitude_VM_SOURCES = $(COMPARE_LIB_F90) $(COMPARE_EXTRA_MODELS) nodist_compare_amplitude_VM_SOURCES = compare_amplitude_VM.f90 comparisons_VM.wrappers.f90 compare_amplitude_VM_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la compare_amplitude_VM.o: $(COMPARE_LIB_O) ######################################################################## if FC_USE_OPENMP TESTS += test_openmp EXTRA_PROGRAMS += test_openmp TESTOPENMP_SUPPORT_F90 = $(WARD_SUPPORT_F90) TESTOPENMP_SUPPORT_O = $(WARD_SUPPORT_O) test_openmp_SOURCES = test_openmp.f90 $(TESTOPENMP_SUPPORT_F90) nodist_test_openmp_SOURCES = amplitude_openmp.f90 test_openmp_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la amplitude_openmp.f90: $(OMEGA_QCD) Makefile $(OMEGA_QCD) $(OMEGA_QCD_OPTS) -target:openmp \ -target:module amplitude_openmp -scatter "gl gl -> gl gl gl" > $@ test_openmp.o: amplitude_openmp.o test_openmp.o: $(TESTOPENMP_SUPPORT_O) amplitude_openmp.o: parameters_QCD.o endif ######################################################################## EXTRA_PROGRAMS += benchmark_VM_vs_Fortran EXTRA_DIST += benchmark_VM_vs_Fortran_driver.sh BENCHMARK_LIB_F90 = benchmark_lib.f90 $(WARD_SUPPORT_F90) BENCHMARK_LIB_O = $(BENCHMARK_LIB_F90:.f90=.o) benchmark_VM_vs_Fortran.f90: benchmark_processes.list benchmark_processes.wrappers.o @if $(AM_V_P); then :; else echo " BENCHMARK_VM_DRIVER"; fi $(AM_V_at)$(SHELL) $(srcdir)/benchmark_VM_vs_Fortran_driver.sh \ "$(OMEGA_XXX) " "$(OMEGA_XXX_VM) " "$(OMEGA_XXX_VM_PARAMS_OPTS)" < $< > $@ benchmark_processes.wrappers.f90: benchmark_processes.list @if $(AM_V_P); then :; else echo " BENCHMARK_DRIVER_WRAPPERS"; fi $(AM_V_at)$(SHELL) $(srcdir)/benchmark_driver_wrappers.sh \ "$(OMEGA_XXX) " "$(OMEGA_XXX_VM) " "$(OMEGA_XXX_VM_PARAMS_OPTS)" < $< > $@ # Explicitly state dependence on model files benchmark_VM_vs_Fortran.f90: benchmark_VM_vs_Fortran_driver.sh \ $(OMEGA_QED) $(OMEGA_QED_VM) \ $(OMEGA_QCD) $(OMEGA_QCD_VM) \ $(OMEGA_SM) $(OMEGA_SM_VM) benchmark_VM_vs_Fortran_SOURCES = $(BENCHMARK_LIB_F90) nodist_benchmark_VM_vs_Fortran_SOURCES = benchmark_VM_vs_Fortran.f90 benchmark_processes.wrappers.f90 benchmark_VM_vs_Fortran_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la benchmark_VM_vs_Fortran.o: $(BENCHMARK_LIB_O) ######################################################################## if FC_USE_OPENMP EXTRA_PROGRAMS += benchmark_amp_parallel benchmark_amp_parallel.f90: benchmark_processes.list benchmark_processes.wrappers.o @if $(AM_V_P); then :; else echo " BENCHMARK_PARALLEL_DRIVER"; fi $(AM_V_at)$(SHELL) $(srcdir)/benchmark_amp_parallel_driver.sh \ "$(OMEGA_XXX) " "$(OMEGA_XXX_VM) " "$(OMEGA_XXX_VM_PARAMS_OPTS)" < $< > $@ # Explicitly state dependence on model files benchmark_amp_parallel.f90: benchmark_amp_parallel_driver.sh \ $(OMEGA_QED) $(OMEGA_QED_VM) \ $(OMEGA_QCD) $(OMEGA_QCD_VM) \ $(OMEGA_SM) $(OMEGA_SM_VM) benchmark_amp_parallel_SOURCES = $(BENCHMARK_LIB_F90) nodist_benchmark_amp_parallel_SOURCES = benchmark_amp_parallel.f90 benchmark_processes.wrappers.f90 benchmark_amp_parallel_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la benchmark_amp_parallel.o: $(BENCHMARK_LIB_O) endif ######################################################################## EXTRA_PROGRAMS += benchmark run_benchmark: benchmark ./benchmark BENCHMARK_PROCESS = -scatter "gl gl -> gl gl gl" BENCHMARK_SPLIT_SIZE = 10 benchmark_SOURCES = benchmark.f90 parameters_QCD.f90 nodist_benchmark_SOURCES = \ amplitude_benchmark_v1.f90 amplitude_benchmark_v2.f90 \ amplitude_benchmark_v3.f90 # amplitude_benchmark_v4.f90 benchmark_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la amplitude_benchmark_v1.f90: $(OMEGA_QCD) Makefile $(OMEGA_QCD) $(OMEGA_QCD_OPTS) -target:module amplitude_benchmark_v1 \ $(BENCHMARK_PROCESS) -target:single_function > $@ amplitude_benchmark_v2.f90: $(OMEGA_QCD) Makefile $(OMEGA_QCD) $(OMEGA_QCD_OPTS) -target:module amplitude_benchmark_v2 \ $(BENCHMARK_PROCESS) -target:split_function $(BENCHMARK_SPLIT_SIZE) > $@ amplitude_benchmark_v3.f90: $(OMEGA_QCD) Makefile $(OMEGA_QCD) $(OMEGA_QCD_OPTS) -target:module amplitude_benchmark_v3 \ $(BENCHMARK_PROCESS) -target:split_module $(BENCHMARK_SPLIT_SIZE) > $@ amplitude_benchmark_v4.f90: $(OMEGA_QCD) Makefile $(OMEGA_QCD) $(OMEGA_QCD_OPTS) -target:module amplitude_benchmark_v4 \ $(BENCHMARK_PROCESS) -target:split_file $(BENCHMARK_SPLIT_SIZE) > $@ benchmark.o: \ amplitude_benchmark_v1.o amplitude_benchmark_v2.o \ amplitude_benchmark_v3.o # amplitude_benchmark_v4.o benchmark.o: parameters_QCD.o amplitude_benchmark_v1.o amplitude_benchmark_v2.o \ amplitude_benchmark_v3.o amplitude_benchmark_v4.o: parameters_QCD.o ######################################################################## if OCAML_AVAILABLE TESTS += vertex_unit EXTRA_PROGRAMS += vertex_unit vertex_unit_SOURCES = vertex_unit.ml vertex_unit: $(OMEGA_CORE) vertex_unit.cmx @if $(AM_V_P); then :; else echo " OCAMLOPT " $@; fi $(AM_V_at)$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) -o vertex_unit \ unix.cmxa $(OMEGA_CORE) $(OMEGA_MODELS) vertex_unit.cmx vertex_unit.cmx: vertex_unit.ml vertex_unit.cmx: $(OMEGA_CORE) $(OMEGA_MODELS) endif ######################################################################## if OCAML_AVAILABLE TESTS += ufo_unit EXTRA_PROGRAMS += ufo_unit ufo_unit_SOURCES = ufo_unit.ml ufo_unit: $(OMEGA_CORE) ufo_unit.cmx @if $(AM_V_P); then :; else echo " OCAMLOPT " $@; fi $(AM_V_at)$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) -o ufo_unit \ unix.cmxa $(OMEGA_CORE) $(OMEGA_MODELS) ufo_unit.cmx ufo_unit.cmx: ufo_unit.ml ufo_unit.cmx: $(OMEGA_CORE) $(OMEGA_MODELS) endif ######################################################################## if OCAML_AVAILABLE TESTS += keystones_omegalib keystones_UFO TESTS += keystones_omegalib_bispinors keystones_UFO_bispinors # XFAIL_TESTS += keystones_UFO # XFAIL_TESTS += keystones_UFO_bispinors EXTRA_PROGRAMS += keystones_omegalib keystones_UFO EXTRA_PROGRAMS += keystones_omegalib_bispinors keystones_UFO_bispinors keystones_omegalib_SOURCES = omega_testtools.f90 keystones_tools.f90 nodist_keystones_omegalib_SOURCES = keystones_omegalib.f90 keystones_omegalib_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la keystones_UFO_SOURCES = omega_testtools.f90 keystones_tools.f90 nodist_keystones_UFO_SOURCES = keystones_UFO.f90 keystones_UFO_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la keystones_omegalib_bispinors_SOURCES = omega_testtools.f90 keystones_tools.f90 nodist_keystones_omegalib_bispinors_SOURCES = keystones_omegalib_bispinors.f90 keystones_omegalib_bispinors_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la keystones_UFO_bispinors_SOURCES = omega_testtools.f90 keystones_tools.f90 nodist_keystones_UFO_bispinors_SOURCES = keystones_UFO_bispinors.f90 keystones_UFO_bispinors_LDADD = $(KINDS) $(top_builddir)/omega/src/libomega_core.la EXTRA_PROGRAMS += keystones_omegalib_generate keystones_UFO_generate EXTRA_PROGRAMS += keystones_omegalib_bispinors_generate keystones_UFO_bispinors_generate keystones_omegalib_generate_SOURCES = \ keystones.ml keystones.mli keystones_omegalib_generate.ml keystones_UFO_generate_SOURCES = \ keystones.ml keystones.mli keystones_UFO_generate.ml keystones_omegalib_bispinors_generate_SOURCES = \ keystones.ml keystones.mli keystones_omegalib_bispinors_generate.ml keystones_UFO_bispinors_generate_SOURCES = \ keystones.ml keystones.mli keystones_UFO_bispinors_generate.ml keystones_omegalib.f90: keystones_omegalib_generate ./keystones_omegalib_generate -cat > $@ keystones_UFO.f90: keystones_UFO_generate ./keystones_UFO_generate -cat > $@ keystones_omegalib_bispinors.f90: keystones_omegalib_bispinors_generate ./keystones_omegalib_bispinors_generate -cat > $@ keystones_UFO_bispinors.f90: keystones_UFO_bispinors_generate ./keystones_UFO_bispinors_generate -cat > $@ keystones_omegalib_generate: $(OMEGA_CORE) keystones_omegalib_generate.cmx @if $(AM_V_P); then :; else echo " OCAMLOPT " $@; fi $(AM_V_at)$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) \ -o keystones_omegalib_generate \ unix.cmxa $(OMEGA_CORE) $(OMEGA_MODELS) \ keystones.cmx keystones_omegalib_generate.cmx keystones_UFO_generate: $(OMEGA_CORE) keystones_UFO_generate.cmx @if $(AM_V_P); then :; else echo " OCAMLOPT " $@; fi $(AM_V_at)$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) \ -o keystones_UFO_generate \ unix.cmxa $(OMEGA_CORE) $(OMEGA_MODELS) \ keystones.cmx keystones_UFO_generate.cmx keystones_omegalib_bispinors_generate: $(OMEGA_CORE) keystones_omegalib_bispinors_generate.cmx @if $(AM_V_P); then :; else echo " OCAMLOPT " $@; fi $(AM_V_at)$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) \ -o keystones_omegalib_bispinors_generate \ unix.cmxa $(OMEGA_CORE) $(OMEGA_MODELS) \ keystones.cmx keystones_omegalib_bispinors_generate.cmx keystones_UFO_bispinors_generate: $(OMEGA_CORE) keystones_UFO_bispinors_generate.cmx @if $(AM_V_P); then :; else echo " OCAMLOPT " $@; fi $(AM_V_at)$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) \ -o keystones_UFO_bispinors_generate \ unix.cmxa $(OMEGA_CORE) $(OMEGA_MODELS) \ keystones.cmx keystones_UFO_bispinors_generate.cmx keystones_omegalib_generate.cmx: \ keystones.cmi keystones.cmx keystones_omegalib_generate.ml keystones_omegalib_generate.cmx: $(OMEGA_CORE) $(OMEGA_MODELS) keystones_UFO_generate.cmx: \ keystones.cmi keystones.cmx keystones_UFO_generate.ml keystones_UFO_generate.cmx: $(OMEGA_CORE) $(OMEGA_MODELS) keystones_omegalib_bispinors_generate.cmx: \ keystones.cmi keystones.cmx keystones_omegalib_bispinors_generate.ml keystones_omegalib_bispinors_generate.cmx: $(OMEGA_CORE) $(OMEGA_MODELS) keystones_UFO_bispinors_generate.cmx: \ keystones.cmi keystones.cmx keystones_UFO_bispinors_generate.ml keystones_UFO_bispinors_generate.cmx: $(OMEGA_CORE) $(OMEGA_MODELS) keystones.cmx: keystones.ml keystones.cmi keystones.cmx: $(OMEGA_CORE) $(OMEGA_MODELS) keystones.cmi: keystones.mli endif ######################################################################## if RECOLA_AVAILABLE TESTS += compare_amplitude_recola # We need more work on the parameters to pass the tests # at quadruple or extended precision if FC_PREC XFAIL_TESTS += compare_amplitude_recola endif EXTRA_PROGRAMS += compare_amplitude_recola AM_FCFLAGS += $(RECOLA_INCLUDES) compare_amplitude_recola_SOURCES = \ parameters_SM_Higgs_recola.f90 \ omega_interface.f90 compare_lib.f90 compare_lib_recola.f90 \ omega_testtools.f90 tao_random_numbers.f90 nodist_compare_amplitude_recola_SOURCES = compare_amplitude_recola.f90 compare_amplitude_recola.f90: comparisons_recola.list compare_driver_recola.sh @if $(AM_V_P); then :; else echo " COMPARE_DRIVER_RECOLA"; fi $(AM_V_at)$(SHELL) $(srcdir)/compare_driver_recola.sh \ "$(OMEGA_XXX) -model:constant_width" < $< > $@ compare_amplitude_recola.o: \ omega_testtools.f90 compare_lib.o compare_lib_recola.o \ tao_random_numbers.o \ parameters_SM_Higgs_recola.o compare_lib_recola.o: \ omega_testtools.f90 compare_lib.o tao_random_numbers.o \ parameters_SM_Higgs_recola.o compare_amplitude_recola_LDADD = \ $(LDFLAGS_RECOLA) \ $(KINDS) $(top_builddir)/omega/src/libomega_core.la run_compare_recola: compare_amplitude_recola ./compare_amplitude_recola endif ######################################################################## installcheck-local: PATH=$(DESTDIR)$(bindir):$$PATH; export PATH; \ LD_LIBRARY_PATH=$(DESTDIR)$(libdir):$(DESTDIR)$(pkglibdir):$$LD_LIBRARY_PATH; \ export LD_LIBRARY_PATH; \ omega_QED.opt $(OMEGA_QED_OPTS) -scatter "e+ e- -> m+ m-" \ -target:module amplitude_qed_eemm > amplitude_qed_eemm.f90; \ $(FC) $(AM_FCFLAGS) $(FCFLAGS) -I$(pkgincludedir) \ -L$(DESTDIR)$(libdir) -L$(DESTDIR)$(pkglibdir) \ $(srcdir)/parameters_QED.f90 amplitude_qed_eemm.f90 \ $(srcdir)/test_qed_eemm.f90 -lomega_core; \ ./a.out ######################################################################## ### Remove DWARF debug information on MAC OS X clean-macosx: -rm -rf a.out.dSYM -rm -rf compare_amplitude_UFO.dSYM -rm -rf compare_amplitude_VM.dSYM -rm -rf compare_split_function.dSYM -rm -rf compare_split_module.dSYM -rm -rf ects.dSYM -rm -rf test_omega95.dSYM -rm -rf test_omega95_bispinors.dSYM -rm -rf test_qed_eemm.dSYM -rm -rf ward.dSYM .PHONY: clean-macosx clean-local: clean-macosx - rm -f a.out gmon.out *.$(FC_MODULE_EXT) \ + rm -f a.out gmon.out *.$(FCMOD) \ *.o *.cmi *.cmo *.cmx amplitude_*.f90 \ $(EXTRA_PROGRAMS) ects.f90 ward.f90 ward_UFO.f90 \ fermi.f90 fermi_UFO.f90 compare_*.f90 \ parameters_SM_UFO.f90 keystones_omegalib.f90 keystones_UFO.f90 \ keystones_UFO_bispinors.f90 keystones_omegalib_bispinors.f90 \ omega_testtools.f90 test_omega95*.f90 benchmark*.f90 \ *.hbc *wrappers.f90 cascade phase_space \ output.rcl recola.log rm -fr output_cll if FC_SUBMODULES -rm -f *.smod endif ######################################################################## ## The End. ######################################################################## Index: trunk/omega/src/Makefile.am =================================================================== --- trunk/omega/src/Makefile.am (revision 8428) +++ trunk/omega/src/Makefile.am (revision 8429) @@ -1,212 +1,212 @@ # Makefile.am -- Makefile for O'Mega within and without WHIZARD ## ## Process this file with automake to produce Makefile.in ## ######################################################################## # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## # Build the O'Mega Fortran library using libtool # (?use pkglib_ instead of lib_ to make the -rpath and *.lai business work ...) lib_LTLIBRARIES = libomega_core.la -moduleexecincludedir = $(pkgincludedir)/../omega -nodist_moduleexecinclude_DATA = $(OMEGALIB_MOD) +execmoddir = $(fmoddir)/omega +nodist_execmod_HEADERS = $(OMEGALIB_MOD) libomega_core_la_SOURCES = $(OMEGALIB_F90) EXTRA_DIST = \ $(OMEGA_CAML) \ omegalib.nw $(OMEGALIB_F90) OMEGA_CMXA = omega_core.cmxa omega_targets.cmxa omega_models.cmxa OMEGA_CMA = $(OMEGA_CMXA:.cmxa=.cma) if OCAML_AVAILABLE all-local: $(OMEGA_CMXA) $(OMEGA_APPLICATIONS_CMX) bytecode: $(OMEGA_CMA) $(OMEGA_APPLICATIONS_CMO) else all-local: bytecode: endif # Compiled interfaces and libraries for out-of-tree compilation of models if OCAML_AVAILABLE -camllibdir = $(pkglibdir)/../omega/caml +camllibdir = $(libdir)/omega/caml nodist_camllib_DATA = \ omega.cmi fusion.cmi targets.cmi coupling.cmi modeltools.cmi color.cmi \ options.cmi model.cmi \ omega_core.cmxa omega_core.a omega_targets.cmxa omega_targets.a \ charges.cmi endif ######################################################################## include $(top_srcdir)/omega/src/Makefile.ocaml include $(top_srcdir)/omega/src/Makefile.sources if OCAML_AVAILABLE omega_core.a: omega_core.cmxa omega_core.cmxa: $(OMEGA_CORE_CMX) @if $(AM_V_P); then :; else echo " OCAMLOPT " $@; fi $(AM_V_at)$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) -a -o $@ $^ omega_core.cma: $(OMEGA_CORE_CMO) @if $(AM_V_P); then :; else echo " OCAMLC " $@; fi $(AM_V_at)$(OCAMLC) $(OCAMLFLAGS) -a -o $@ $^ omega_targets.a: omega_targets.cmxa omega_targets.cmxa: $(OMEGA_TARGETS_CMX) @if $(AM_V_P); then :; else echo " OCAMLOPT " $@; fi $(AM_V_at)$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) -a -o $@ $^ omega_targets.cma: $(OMEGA_TARGETS_CMO) @if $(AM_V_P); then :; else echo " OCAMLC " $@; fi $(AM_V_at)$(OCAMLC) $(OCAMLFLAGS) -a -o $@ $^ omega_models.cmxa: $(OMEGA_MODELS_CMX) @if $(AM_V_P); then :; else echo " OCAMLOPT " $@; fi $(AM_V_at)$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) -a -o $@ $^ omega_models.cma: $(OMEGA_MODELS_CMO) @if $(AM_V_P); then :; else echo " OCAMLC " $@; fi $(AM_V_at)$(OCAMLC) $(OCAMLFLAGS) -a -o $@ $^ cascade_lexer.mli: cascade_lexer.ml cascade_parser.cmi $(OCAMLC) -i $< | $(GREP) 'val token' >$@ vertex_lexer.mli: vertex_lexer.ml vertex_parser.cmi $(OCAMLC) -i $< | $(EGREP) 'val (token|init_position)' >$@ UFO_lexer.mli: UFO_lexer.ml UFO_parser.cmi UFO_tools.cmi $(OCAMLC) -i $< | $(EGREP) 'val (token|init_position)' >$@ UFOx_lexer.mli: UFOx_lexer.ml UFOx_parser.cmi UFO_tools.cmi $(OCAMLC) -i $< | $(EGREP) 'val (token|init_position)' >$@ endif MYPRECIOUS = $(OMEGA_DERIVED_CAML) -SUFFIXES += .lo .$(FC_MODULE_EXT) +SUFFIXES += .lo .$(FCMOD) # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ ######################################################################## DISTCLEANFILES = kinds.f90 if NOWEB_AVAILABLE omegalib.stamp: $(srcdir)/omegalib.nw @rm -f omegalib.tmp @touch omegalib.tmp for src in $(OMEGALIB_DERIVED_F90); do \ $(NOTANGLE) -R[[$$src]] $< | $(CPIF) $$src; \ done @mv -f omegalib.tmp omegalib.stamp $(OMEGALIB_DERIVED_F90): omegalib.stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ rm -f omegalib.stamp; \ $(MAKE) $(AM_MAKEFLAGS) omegalib.stamp; \ fi DISTCLEANFILES += $(OMEGALIB_DERIVED_F90) endif NOWEB_AVAILABLE MYPRECIOUS += $(OMEGALIB_DERIVED_F90) ######################################################################## # The following line just says # include Makefile.depend_fortran # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE ######################################################################## @am__include@ @am__quote@Makefile.depend_fortran@am__quote@ Makefile.depend_fortran: kinds.f90 $(libomega_core_la_SOURCES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -e 's/, *only:.*//' \ -e 's/, *&//' \ -e 's/, *.*=>.*//' \ -e 's/ *$$/.lo/' ; \ done > $@ DISTCLEANFILES += Makefile.depend_fortran if OCAML_AVAILABLE @am__include@ @am__quote@Makefile.depend_ocaml@am__quote@ PARSERS = cascade vertex UFO UFOx Makefile.depend_ocaml: $(OMEGA_CAML_PRIMARY) @if $(AM_V_P); then :; else echo " OCAMLDEP " $@; fi @rm -f $@ $(AM_V_at)$(OCAMLDEP) -I $(srcdir) $^ $(OMEGA_DERIVED_CAML) \ | sed 's,[^ ]*/,,g' > $@ $(AM_V_at)for parser in $(PARSERS); do \ echo $${parser}.cmi: $${parser}_lexer.cmi; \ echo $${parser}_lexer.cmi: $${parser}_parser.cmi; \ echo $${parser}_parser.cmi: $${parser}_syntax.cmi; \ echo $${parser}_parser.mli: $${parser}_parser.ml; \ echo $${parser}.cmo: $${parser}.cmi; \ echo $${parser}.cmx: $${parser}.cmi $${parser}_lexer.cmx; \ echo $${parser}_lexer.cmo: $${parser}_lexer.cmi; \ echo $${parser}_lexer.cmx: $${parser}_lexer.cmi $${parser}_parser.cmx; \ echo $${parser}_parser.cmo: $${parser}_parser.cmi $${parser}_syntax.cmi; \ echo $${parser}_parser.cmx: $${parser}_parser.cmi \ $${parser}_syntax.cmi $${parser}_syntax.cmx; \ done >>$@ DISTCLEANFILES += Makefile.depend_ocaml endif OCAML_AVAILABLE ######################################################################## # Don't trigger remakes by deleting intermediate files. .PRECIOUS = $(MYPRECIOUS) clean-local: - rm -f *.cm[aiox] *.cmxa *.[ao] *.l[oa] *.$(FC_MODULE_EXT) \ + rm -f *.cm[aiox] *.cmxa *.[ao] *.l[oa] *.$(FCMOD) \ $(OMEGA_DERIVED_CAML) omegalib.stamp if FC_SUBMODULES -rm -f *.smod endif distclean-local: -test "$(srcdir)" != "." && rm -f config.mli ######################################################################## ## The End. ######################################################################## Index: trunk/tests/ext_tests_nmssm/Makefile.am =================================================================== --- trunk/tests/ext_tests_nmssm/Makefile.am (revision 8428) +++ trunk/tests/ext_tests_nmssm/Makefile.am (revision 8429) @@ -1,219 +1,219 @@ ## Makefile.am -- Makefile for executable WHIZARD test scripts ## ## Process this file with automake to produce Makefile.in ## ######################################################################## # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## Invoke extended tests by 'make check' or 'make check-extended' check-extended: check ######################################################################## WHIZARD_DRIVER = run_whizard.sh TESTS_EXTENDED = \ nmssm_ext.run XFAIL_TESTS_EXTENDED = TESTS_REQ_GAMELAN = #\ $(TESTS_REQ_OCAML) \ $(TESTS_EXTENDED) TEST_DRIVERS_RUN = \ $(TESTS_EXTENDED) TEST_DRIVERS_SH = $(TEST_DRIVERS_RUN:.run=.sh) ######################################################################## TESTS = XFAIL_TESTS = TESTS_SRC = TESTS += $(TESTS_EXTENDED) XFAIL_TESTS += $(XFAIL_TESTS_EXTENDED) nmssm_ext.run: $(EXTENDED_NMSSM_TEST_DRIVERS) echo '#! /bin/sh' >$@ for driver in $(EXTENDED_NMSSM_TEST_DRIVERS); do \ echo ./$$driver; \ done >>$@ chmod +x $@ EXTENDED_NMSSM_TEST_DRIVERS = \ nmssm_ext-aa.run nmssm_ext-bb1.run nmssm_ext-bb2.run \ nmssm_ext-bt.run nmssm_ext-dd1.run \ nmssm_ext-dd2.run nmssm_ext-ee1.run \ nmssm_ext-ee2.run nmssm_ext-en.run \ nmssm_ext-ga.run nmssm_ext-gg.run \ nmssm_ext-gw.run nmssm_ext-gz.run \ nmssm_ext-qg.run nmssm_ext-tn.run \ nmssm_ext-tt1.run nmssm_ext-tt2.run \ nmssm_ext-uu1.run nmssm_ext-uu2.run \ nmssm_ext-wa.run nmssm_ext-ww1.run nmssm_ext-ww2.run \ nmssm_ext-wz.run nmssm_ext-za.run EXTENDED_NMSSM_TEST_DRIVERS_SH = $(EXTENDED_NMSSM_TEST_DRIVERS:.run=.sh) EXTRA_DIST = $(TEST_DRIVERS_SH) \ $(EXTENDED_NMSSM_TEST_DRIVERS_SH) \ $(TESTS_SRC) ######################################################################## VPATH = $(srcdir) SUFFIXES = .sh .run .sh.run: @rm -f $@ @if test -f $(top_builddir)/share/tests/ext_tests_nmssm/$*.sin; then \ $(SED) 's|@script@|$(top_builddir)/share/tests/ext_tests_nmssm/$*|g' $< > $@; \ elif test -f $(top_srcdir)/share/tests/ext_tests_nmssm/$*.sin; then \ $(SED) 's|@script@|$(top_srcdir)/share/tests/ext_tests_nmssm/$*|g' $< > $@; \ fi @chmod +x $@ if MPOST_AVAILABLE $(TESTS_REQ_GAMELAN): gamelan.sty $(UNIT_TESTS_REQ_GAMELAN): gamelan.sty gamelan.sty: $(top_builddir)/src/gamelan/gamelan.sty cp $< $@ $(top_builddir)/src/gamelan/gamelan.sty: $(MAKE) -C $(top_builddir)/src/gamelan gamelan.sty endif BUILT_SOURCES = \ TESTFLAG \ HEPMC2_FLAG \ HEPMC3_FLAG \ LCIO_FLAG \ FASTJET_FLAG \ LHAPDF5_FLAG \ LHAPDF6_FLAG \ GAMELAN_FLAG \ EVENT_ANALYSIS_FLAG \ OCAML_FLAG \ PYTHIA6_FLAG \ STATIC_FLAG # If this file is found in the working directory, WHIZARD # will use the paths for the uninstalled version (source/build tree), # otherwise it uses the installed version TESTFLAG: touch $@ FASTJET_FLAG: if FASTJET_AVAILABLE touch $@ endif HEPMC2_FLAG: if HEPMC2_AVAILABLE touch $@ endif HEPMC3_FLAG: if HEPMC3_AVAILABLE touch $@ endif LCIO_FLAG: if LCIO_AVAILABLE touch $@ endif LHAPDF5_FLAG: if LHAPDF5_AVAILABLE touch $@ endif LHAPDF6_FLAG: if LHAPDF6_AVAILABLE touch $@ endif GAMELAN_FLAG: if MPOST_AVAILABLE touch $@ endif OCAML_FLAG: if OCAML_AVAILABLE touch $@ endif PYTHIA6_FLAG: if PYTHIA6_AVAILABLE touch $@ endif EVENT_ANALYSIS_FLAG: if EVENT_ANALYSIS_AVAILABLE touch $@ endif STATIC_FLAG: if STATIC_AVAILABLE touch $@ endif ## installcheck runs the test scripts with the TESTFLAG removed. installcheck-local: notestflag check-am notestflag: rm -f TESTFLAG .PHONY: notestflag ## Remove generated files clean-local: rm -f gamelan.sty rm -f TESTFLAG GAMELAN_FLAG rm -f OCAML_FLAG FASTJET_FLAG HEPMC2_FLAG HEPMC3_FLAG LCIO_FLAG rm -f EVENT_ANALYSIS_FLAG PYTHIA6_FLAG LHAPDF5_FLAG rm -f LHAPDF6_FLAG STATIC_FLAG static_1.exe rm -f *.run *.log slha_test.out rm -f core* stdhep_rd - rm -f *.f90 *.c *.$(FC_MODULE_EXT) *.o *.la + rm -f *.f90 *.c *.$(FCMOD) *.o *.la rm -f *.makefile rm -f *.sin *.hbc rm -f *.phs *.vg *.vgb *.evt *.evx *.lhe *.hepmc *.dat *.debug rm -f *.tmp *.hepevt *.hepevt.verb *.lha *.lha.verb *.slcio rm -f prc_omega_diags_1_p_i1_diags.out prc_omega_diags_1_p_i1_diags.toc rm -f *.hep *.up.hep *.[1-9] *.[1-9][0-9] *.[1-9][0-9][0-9] rm -f *.tex *.mp *.mpx *.t[1-9] *.t[1-9][0-9] *.t[1-9][0-9][0-9] rm -f *.ltp *.aux *.dvi *.ps *.pdf so_test.* rm -f *.tbl sps1ap_decays.slha bar structure_6[a-b].out rm -f slhaspectrum.in suspect2.out suspect2_lha.out rm -f susyhit.in susyhit_slha.out suspect2_lha.in if FC_SUBMODULES rm -f *.smod endif ## Remove backup files maintainer-clean-local: maintainer-clean-fc -rm -f *~ .PHONY: maintainer-clean-local Index: trunk/tests/ext_tests_mssm/Makefile.am =================================================================== --- trunk/tests/ext_tests_mssm/Makefile.am (revision 8428) +++ trunk/tests/ext_tests_mssm/Makefile.am (revision 8429) @@ -1,217 +1,217 @@ ## Makefile.am -- Makefile for executable WHIZARD test scripts ## ## Process this file with automake to produce Makefile.in ## ######################################################################## # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## Invoke extended tests by 'make check' or 'make check-extended' check-extended: check ######################################################################## WHIZARD_DRIVER = run_whizard.sh TESTS_EXTENDED = \ mssm_ext.run XFAIL_TESTS_EXTENDED = TESTS_REQ_GAMELAN = #\ $(TESTS_REQ_OCAML) \ $(TESTS_EXTENDED) TEST_DRIVERS_RUN = \ $(TESTS_EXTENDED) TEST_DRIVERS_SH = $(TEST_DRIVERS_RUN:.run=.sh) ######################################################################## TESTS = XFAIL_TESTS = TESTS_SRC = TESTS += $(TESTS_EXTENDED) XFAIL_TESTS += $(XFAIL_TESTS_EXTENDED) mssm_ext.run: $(EXTENDED_MSSM_TEST_DRIVERS) echo '#! /bin/sh' >$@ for driver in $(EXTENDED_MSSM_TEST_DRIVERS); do \ echo ./$$driver; \ done >>$@ chmod +x $@ EXTENDED_MSSM_TEST_DRIVERS = \ mssm_ext-ee.run mssm_ext-ee2.run \ mssm_ext-en.run mssm_ext-tn.run \ mssm_ext-uu.run mssm_ext-uu2.run mssm_ext-uuckm.run \ mssm_ext-dd.run mssm_ext-dd2.run mssm_ext-ddckm.run \ mssm_ext-bb.run mssm_ext-bt.run mssm_ext-tt.run \ mssm_ext-ug.run mssm_ext-dg.run \ mssm_ext-aa.run mssm_ext-wa.run mssm_ext-za.run \ mssm_ext-ww.run mssm_ext-wz.run mssm_ext-zz.run \ mssm_ext-gg.run mssm_ext-ga.run mssm_ext-gw.run mssm_ext-gz.run EXTENDED_MSSM_TEST_DRIVERS_SH = $(EXTENDED_MSSM_TEST_DRIVERS:.run=.sh) EXTRA_DIST = $(TEST_DRIVERS_SH) \ $(EXTENDED_MSSM_TEST_DRIVERS_SH) \ $(TESTS_SRC) ######################################################################## VPATH = $(srcdir) SUFFIXES = .sh .run .sh.run: @rm -f $@ @if test -f $(top_builddir)/share/tests/ext_tests_mssm/$*.sin; then \ $(SED) 's|@script@|$(top_builddir)/share/tests/ext_tests_mssm/$*|g' $< > $@; \ elif test -f $(top_srcdir)/share/tests/ext_tests_mssm/$*.sin; then \ $(SED) 's|@script@|$(top_srcdir)/share/tests/ext_tests_mssm/$*|g' $< > $@; \ fi @chmod +x $@ if MPOST_AVAILABLE $(TESTS_REQ_GAMELAN): gamelan.sty $(UNIT_TESTS_REQ_GAMELAN): gamelan.sty gamelan.sty: $(top_builddir)/src/gamelan/gamelan.sty cp $< $@ $(top_builddir)/src/gamelan/gamelan.sty: $(MAKE) -C $(top_builddir)/src/gamelan gamelan.sty endif BUILT_SOURCES = \ TESTFLAG \ HEPMC2_FLAG \ HEPMC3_FLAG \ LCIO_FLAG \ FASTJET_FLAG \ LHAPDF5_FLAG \ LHAPDF6_FLAG \ GAMELAN_FLAG \ EVENT_ANALYSIS_FLAG \ OCAML_FLAG \ PYTHIA6_FLAG \ STATIC_FLAG # If this file is found in the working directory, WHIZARD # will use the paths for the uninstalled version (source/build tree), # otherwise it uses the installed version TESTFLAG: touch $@ FASTJET_FLAG: if FASTJET_AVAILABLE touch $@ endif HEPMC2_FLAG: if HEPMC2_AVAILABLE touch $@ endif HEPMC3_FLAG: if HEPMC3_AVAILABLE touch $@ endif LCIO_FLAG: if LCIO_AVAILABLE touch $@ endif LHAPDF5_FLAG: if LHAPDF5_AVAILABLE touch $@ endif LHAPDF6_FLAG: if LHAPDF6_AVAILABLE touch $@ endif GAMELAN_FLAG: if MPOST_AVAILABLE touch $@ endif OCAML_FLAG: if OCAML_AVAILABLE touch $@ endif PYTHIA6_FLAG: if PYTHIA6_AVAILABLE touch $@ endif EVENT_ANALYSIS_FLAG: if EVENT_ANALYSIS_AVAILABLE touch $@ endif STATIC_FLAG: if STATIC_AVAILABLE touch $@ endif ## installcheck runs the test scripts with the TESTFLAG removed. installcheck-local: notestflag check-am notestflag: rm -f TESTFLAG .PHONY: notestflag ## Remove generated files clean-local: rm -f gamelan.sty rm -f TESTFLAG GAMELAN_FLAG rm -f OCAML_FLAG FASTJET_FLAG HEPMC2_FLAG HEPMC3_FLAG LCIO_FLAG rm -f EVENT_ANALYSIS_FLAG PYTHIA6_FLAG LHAPDF5_FLAG rm -f LHAPDF6_FLAG STATIC_FLAG static_1.exe rm -f *.run *.log slha_test.out rm -f core* stdhep_rd - rm -f *.f90 *.c *.$(FC_MODULE_EXT) *.o *.la + rm -f *.f90 *.c *.$(FCMOD) *.o *.la rm -f *.makefile rm -f *.sin *.hbc rm -f *.phs *.vg *.vgb *.evt *.evx *.lhe *.hepmc *.dat *.debug rm -f *.tmp *.hepevt *.hepevt.verb *.lha *.lha.verb *.slcio rm -f prc_omega_diags_1_p_i1_diags.out prc_omega_diags_1_p_i1_diags.toc rm -f *.hep *.up.hep *.[1-9] *.[1-9][0-9] *.[1-9][0-9][0-9] rm -f *.tex *.mp *.mpx *.t[1-9] *.t[1-9][0-9] *.t[1-9][0-9][0-9] rm -f *.ltp *.aux *.dvi *.ps *.pdf so_test.* rm -f *.tbl sps1ap_decays.slha bar structure_6[a-b].out rm -f slhaspectrum.in suspect2.out suspect2_lha.out rm -f susyhit.in susyhit_slha.out suspect2_lha.in if FC_SUBMODULES rm -f *.smod endif ## Remove backup files maintainer-clean-local: maintainer-clean-fc -rm -f *~ .PHONY: maintainer-clean-local Index: trunk/tests/unit_tests/api_hepmc3.sh =================================================================== --- trunk/tests/unit_tests/api_hepmc3.sh (revision 0) +++ trunk/tests/unit_tests/api_hepmc3.sh (revision 8429) @@ -0,0 +1,10 @@ +#!/bin/sh +### Check WHIZARD command setup +echo "Running script $0" +if test -f HEPMC3_FLAG; then + exec ./run_whizard_ut.sh --check api_hepmc +else + echo "|=============================================================================|" + echo "No HepMC3 available, test skipped" + exit 77 +fi Index: trunk/tests/unit_tests/run_whizard_ut_cc.sh.in =================================================================== --- trunk/tests/unit_tests/run_whizard_ut_cc.sh.in (revision 0) +++ trunk/tests/unit_tests/run_whizard_ut_cc.sh.in (revision 8429) @@ -0,0 +1,18 @@ +#!/bin/sh +### Check the WHIZARD C++ interface by executing a unit test +### Usage: run_whizard_ut_cc.sh [OPTIONS] + +# Make sure the path to the installed version is completely known +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ + +# Run either the local version or the installed version of WHIZARD +export OMP_NUM_THREADS +OMP_NUM_THREADS=1 +if test -f TESTFLAG; then + @DYLD_FLAGS@ + ../../src/whizard_ut_cc $* +else + $bindir/whizard_ut_cc $* +fi Index: trunk/tests/unit_tests/api_c.sh =================================================================== --- trunk/tests/unit_tests/api_c.sh (revision 0) +++ trunk/tests/unit_tests/api_c.sh (revision 8429) @@ -0,0 +1,10 @@ +#!/bin/sh +### Check WHIZARD command setup +echo "Running script $0" +if test -f OCAML_FLAG; then + exec ./run_whizard_ut_c.sh +else + echo "|=============================================================================|" + echo "No O'Mega matrix elements available, test skipped" + exit 77 +fi Index: trunk/tests/unit_tests/run_whizard_ut_c.sh.in =================================================================== --- trunk/tests/unit_tests/run_whizard_ut_c.sh.in (revision 0) +++ trunk/tests/unit_tests/run_whizard_ut_c.sh.in (revision 8429) @@ -0,0 +1,18 @@ +#!/bin/sh +### Check the WHIZARD C interface by executing a unit test +### Usage: run_whizard_ut_c.sh [OPTIONS] + +# Make sure the path to the installed version is completely known +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ + +# Run either the local version or the installed version of WHIZARD +export OMP_NUM_THREADS +OMP_NUM_THREADS=1 +if test -f TESTFLAG; then + @DYLD_FLAGS@ + ../../src/whizard_ut_c $* +else + $bindir/whizard_ut_c $* +fi Index: trunk/tests/unit_tests/Makefile.am =================================================================== --- trunk/tests/unit_tests/Makefile.am (revision 8428) +++ trunk/tests/unit_tests/Makefile.am (revision 8429) @@ -1,431 +1,459 @@ ## Makefile.am -- Makefile for executable WHIZARD test scripts ## ## Process this file with automake to produce Makefile.in ## ######################################################################## # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## WHIZARD_UT_DRIVER = run_whizard_ut.sh +WHIZARD_C_TEST_DRIVER = run_whizard_c_test.sh +WHIZARD_CC_TEST_DRIVER = run_whizard_cc_test.sh UNIT_TESTS = \ analysis.run \ pdg_arrays.run \ expressions.run \ beams.run \ su_algebra.run \ bloch_vectors.run \ polarizations.run \ md5.run \ cputime.run \ lexers.run \ parser.run \ color.run \ os_interface.run \ evaluators.run \ formats.run \ sorting.run \ grids.run \ solver.run \ state_matrices.run \ interactions.run \ xml.run \ sm_qcd.run \ sm_physics.run \ models.run \ auto_components.run \ radiation_generator.run \ blha.run \ particles.run \ beam_structures.run \ sf_aux.run \ sf_mappings.run \ sf_base.run \ sf_pdf_builtin.run \ sf_isr.run \ sf_epa.run \ sf_ewa.run \ sf_circe1.run \ sf_circe2.run \ sf_gaussian.run \ sf_beam_events.run \ sf_escan.run \ phs_base.run \ phs_none.run \ phs_single.run \ phs_rambo.run \ resonances.run \ phs_trees.run \ phs_forests.run \ phs_wood.run \ phs_fks_generator.run \ fks_regions.run \ real_subtraction.run \ rng_base.run \ rng_tao.run \ rng_stream.run \ selectors.run \ vegas.run \ vamp2.run \ mci_base.run \ mci_none.run \ mci_midpoint.run \ mci_vamp.run \ mci_vamp2.run \ integration_results.run \ prclib_interfaces.run \ particle_specifiers.run \ process_libraries.run \ prclib_stacks.run \ slha_interface.run \ prc_test.run \ prc_template_me.run \ parton_states.run \ subevt_expr.run \ processes.run \ process_stacks.run \ cascades.run \ cascades2_lexer.run \ cascades2.run \ event_transforms.run \ resonance_insertion.run \ recoil_kinematics.run \ isr_handler.run \ epa_handler.run \ decays.run \ shower.run \ shower_base.run \ events.run \ hep_events.run \ whizard_lha.run \ pythia8.run \ eio_data.run \ eio_base.run \ eio_direct.run \ eio_raw.run \ eio_checkpoints.run \ eio_lhef.run \ eio_stdhep.run \ eio_ascii.run \ eio_weights.run \ eio_dump.run \ iterations.run \ rt_data.run \ dispatch.run \ dispatch_rng.run \ dispatch_mci.run \ dispatch_phs.run \ dispatch_transforms.run \ process_configurations.run \ event_streams.run \ integrations.run \ ttv_formfactors.run XFAIL_UNIT_TESTS = UNIT_TESTS_REQ_GAMELAN = \ commands.run UNIT_TESTS_REQ_EV_ANA = \ phs_wood_vis.run \ prc_omega_diags.run \ integrations_history.run UNIT_TESTS_REQ_FASTJET = \ jets.run UNIT_TESTS_REQ_HEPMC2 = \ hepmc2.run \ - eio_hepmc2.run + eio_hepmc2.run \ + api_hepmc2.run UNIT_TESTS_REQ_HEPMC3 = \ hepmc3.run \ - eio_hepmc3.run + eio_hepmc3.run \ + api_hepmc3.run UNIT_TESTS_REQ_LCIO = \ lcio.run \ - eio_lcio.run + eio_lcio.run \ + api_lcio.run UNIT_TESTS_REQ_OCAML = \ prc_omega.run \ compilations.run \ compilations_static.run \ restricted_subprocesses.run \ - simulations.run + simulations.run \ + api.run \ + api_c.run \ + api_cc.run UNIT_TESTS_REQ_RECOLA = \ prc_recola.run UNIT_TESTS_REQ_LHAPDF5 = \ sf_lhapdf5.run UNIT_TESTS_REQ_LHAPDF6 = \ sf_lhapdf6.run TEST_DRIVERS_RUN = \ $(UNIT_TESTS) \ $(UNIT_TESTS_REQ_GAMELAN) \ $(UNIT_TESTS_REQ_HEPMC2) \ $(UNIT_TESTS_REQ_HEPMC3) \ $(UNIT_TESTS_REQ_LCIO) \ $(UNIT_TESTS_REQ_FASTJET) \ $(UNIT_TESTS_REQ_LHAPDF5) \ $(UNIT_TESTS_REQ_LHAPDF6) \ $(UNIT_TESTS_REQ_OCAML) \ $(UNIT_TESTS_REQ_RECOLA) TEST_DRIVERS_SH = $(TEST_DRIVERS_RUN:.run=.sh) ######################################################################## TESTS = XFAIL_TESTS = TESTS_SRC = UNIT_TESTS += $(UNIT_TESTS_REQ_GAMELAN) UNIT_TESTS += $(UNIT_TESTS_REQ_FASTJET) UNIT_TESTS += $(UNIT_TESTS_REQ_HEPMC2) UNIT_TESTS += $(UNIT_TESTS_REQ_HEPMC3) UNIT_TESTS += $(UNIT_TESTS_REQ_LCIO) UNIT_TESTS += $(UNIT_TESTS_REQ_LHAPDF5) UNIT_TESTS += $(UNIT_TESTS_REQ_LHAPDF6) UNIT_TESTS += $(UNIT_TESTS_REQ_OCAML) UNIT_TESTS += $(UNIT_TESTS_REQ_EV_ANA) UNIT_TESTS += $(UNIT_TESTS_REQ_RECOLA) TESTS += $(UNIT_TESTS) XFAIL_TESTS += $(XFAIL_UNIT_TESTS) EXTRA_DIST = $(TEST_DRIVERS_SH) $(TESTS_SRC) ######################################################################## # Force building the whizard_ut executable in the main src directory. # This depends on the unit-test libraries which will be built recursively. WHIZARD_UT = ../../src/whizard_ut $(TEST_DRIVERS_RUN): $(WHIZARD_UT) $(WHIZARD_UT): $(MAKE) -C ../../src check ######################################################################## +# Force building the whizard_c_test executable in the main src directory. +# This depends on the unit-test libraries which will be built recursively. + +WHIZARD_C_TEST = ../../src/whizard_c_test + +$(TEST_DRIVERS_RUN): $(WHIZARD_C_TEST) + +$(WHIZARD_C_TEST): $(WHIZARD_UT) + +######################################################################## +# Force building the whizard_c_test executable in the main src directory. +# This depends on the unit-test libraries which will be built recursively. + +WHIZARD_CC_TEST = ../../src/whizard_cc_test + +$(TEST_DRIVERS_RUN): $(WHIZARD_CC_TEST) + +$(WHIZARD_CC_TEST): $(WHIZARD_C_TEST) + +######################################################################## VPATH = $(srcdir) SUFFIXES = .sh .run .sh.run: @rm -f $@ @cp $< $@ @chmod +x $@ sf_beam_events.run: test_beam_events.dat test_beam_events.dat: $(top_builddir)/share/beam-sim/test_beam_events.dat cp $< $@ cascades2_lexer.run: cascades2_lexer_1.fds cascades2_lexer_1.fds: $(top_srcdir)/share/tests/cascades2_lexer_1.fds cp $< $@ cascades2.run: cascades2_1.fds cascades2_2.fds cascades2_1.fds: $(top_srcdir)/share/tests/cascades2_1.fds cp $< $@ cascades2_2.fds: $(top_srcdir)/share/tests/cascades2_2.fds cp $< $@ commands.run: sps1ap_decays.slha sps1ap_decays.slha: $(top_builddir)/share/susy/sps1ap_decays.slha cp $< $@ WT_OCAML_NATIVE_EXT=opt if MPOST_AVAILABLE $(UNIT_TESTS_REQ_GAMELAN): gamelan.sty gamelan.sty: $(top_builddir)/src/gamelan/gamelan.sty cp $< $@ $(top_builddir)/src/gamelan/gamelan.sty: $(MAKE) -C $(top_builddir)/src/gamelan gamelan.sty endif if OCAML_AVAILABLE UFO_TAG_FILE = __init__.py UFO_MODELPATH = ../models/UFO models.run: $(UFO_MODELPATH)/SM/$(UFO_TAG_FILE) $(UFO_MODELPATH)/SM/$(UFO_TAG_FILE): $(top_srcdir)/omega/tests/UFO/SM/$(UFO_TAG_FILE) $(MAKE) -C $(UFO_MODELPATH)/SM all endif BUILT_SOURCES = \ TESTFLAG \ HEPMC2_FLAG \ HEPMC3_FLAG \ LCIO_FLAG \ FASTJET_FLAG \ LHAPDF5_FLAG \ LHAPDF6_FLAG \ GAMELAN_FLAG \ EVENT_ANALYSIS_FLAG \ OCAML_FLAG \ RECOLA_FLAG \ PYTHIA6_FLAG \ PYTHIA8_FLAG \ STATIC_FLAG \ ref-output \ err-output # If this file is found in the working directory, WHIZARD # will use the paths for the uninstalled version (source/build tree), # otherwise it uses the installed version TESTFLAG: touch $@ FASTJET_FLAG: if FASTJET_AVAILABLE touch $@ endif HEPMC2_FLAG: if HEPMC2_AVAILABLE touch $@ endif HEPMC3_FLAG: if HEPMC3_AVAILABLE touch $@ endif LCIO_FLAG: if LCIO_AVAILABLE touch $@ endif LHAPDF5_FLAG: if LHAPDF5_AVAILABLE touch $@ endif LHAPDF6_FLAG: if LHAPDF6_AVAILABLE touch $@ endif GAMELAN_FLAG: if MPOST_AVAILABLE touch $@ endif OCAML_FLAG: if OCAML_AVAILABLE touch $@ endif RECOLA_FLAG: if RECOLA_AVAILABLE touch $@ endif PYTHIA6_FLAG: if PYTHIA6_AVAILABLE touch $@ endif PYTHIA8_FLAG: if PYTHIA8_AVAILABLE touch $@ endif EVENT_ANALYSIS_FLAG: if EVENT_ANALYSIS_AVAILABLE touch $@ endif STATIC_FLAG: if STATIC_AVAILABLE touch $@ endif # The reference output files are in the source directory. Copy them here. ref-output: $(top_srcdir)/share/tests/unit_tests/ref-output mkdir -p ref-output for f in $ # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## WHIZARD_DRIVER = run_whizard.sh TESTS_EXTENDED = \ nlo_decay_tbw.run \ nlo_fks_delta_o_eejj.run \ nlo_fks_delta_i_ppee.run \ nlo_jets.run \ nlo_methods_gosam.run \ nlo_qq_powheg.run \ nlo_threshold_factorized.run \ nlo_threshold.run \ nlo_tt_powheg_sudakov.run \ nlo_tt_powheg.run \ nlo_tt.run \ nlo_uu_powheg.run \ nlo_uu.run XFAIL_TESTS_EXTENDED = TESTS_REQ_GAMELAN = \ nlo_tt_powheg.run \ nlo_uu_powheg.run TEST_DRIVERS_RUN = \ $(TESTS_EXTENDED) TEST_DRIVERS_SH = $(TEST_DRIVERS_RUN:.run=.sh) ######################################################################## TESTS = $(TESTS_EXTENDED) XFAIL_TESTS = $(XFAIL_TESTS_EXTENDED) EXTRA_DIST = $(TEST_DRIVERS_SH) ######################################################################## VPATH = $(srcdir) SUFFIXES = .sh .run .sh.run: @rm -f $@ @if test -f $(top_builddir)/share/tests/ext_tests_nlo_add/$*.sin; then \ $(SED) 's|@script@|$(top_builddir)/share/tests/ext_tests_nlo_add/$*|g' $< > $@; \ elif test -f $(top_srcdir)/share/tests/ext_tests_nlo_add/$*.sin; then \ $(SED) 's|@script@|$(top_srcdir)/share/tests/ext_tests_nlo_add/$*|g' $< > $@; \ fi $(SED) 's|@python_bin@|$(PYTHON_BIN)|g' $@ >> "$@.tmp" && mv "$@.tmp" $@ $(SED) 's|@share_dir@|$(top_srcdir)/share/tests|g' $@ >> "$@.tmp" && mv "$@.tmp" $@ @chmod +x $@ if MPOST_AVAILABLE $(TESTS_REQ_GAMELAN): gamelan.sty $(UNIT_TESTS_REQ_GAMELAN): gamelan.sty gamelan.sty: $(top_builddir)/src/gamelan/gamelan.sty cp $< $@ $(top_builddir)/src/gamelan/gamelan.sty: $(MAKE) -C $(top_builddir)/src/gamelan gamelan.sty endif BUILT_SOURCES = \ TESTFLAG \ HEPMC2_FLAG \ HEPMC3_FLAG \ LCIO_FLAG \ FASTJET_FLAG \ LHAPDF5_FLAG \ LHAPDF6_FLAG \ GAMELAN_FLAG \ EVENT_ANALYSIS_FLAG \ OCAML_FLAG \ PYTHON_FLAG \ PYTHIA6_FLAG \ OPENLOOPS_FLAG \ GOSAM_FLAG \ STATIC_FLAG # If this file is found in the working directory, WHIZARD # will use the paths for the uninstalled version (source/build tree), # otherwise it uses the installed version TESTFLAG: touch $@ FASTJET_FLAG: if FASTJET_AVAILABLE touch $@ endif HEPMC2_FLAG: if HEPMC2_AVAILABLE touch $@ endif HEPMC3_FLAG: if HEPMC3_AVAILABLE touch $@ endif LCIO_FLAG: if LCIO_AVAILABLE touch $@ endif LHAPDF5_FLAG: if LHAPDF5_AVAILABLE touch $@ endif LHAPDF6_FLAG: if LHAPDF6_AVAILABLE touch $@ endif GAMELAN_FLAG: if MPOST_AVAILABLE touch $@ endif OCAML_FLAG: if OCAML_AVAILABLE touch $@ endif PYTHON_FLAG: if PYTHON_AVAILABLE touch $@ endif PYTHIA6_FLAG: if PYTHIA6_AVAILABLE touch $@ endif OPENLOOPS_FLAG: if OPENLOOPS_AVAILABLE touch $@ endif GOSAM_FLAG: if GOSAM_AVAILABLE touch $@ endif EVENT_ANALYSIS_FLAG: if EVENT_ANALYSIS_AVAILABLE touch $@ endif STATIC_FLAG: if STATIC_AVAILABLE touch $@ endif ## installcheck runs the test scripts with the TESTFLAG removed. installcheck-local: notestflag check-am notestflag: rm -f TESTFLAG .PHONY: notestflag ## Remove generated files clean-local: rm -f gamelan.sty rm -f TESTFLAG rm -f *_FLAG rm -f static_1.exe rm -f *.run *.log slha_test.out rm -f core* stdhep_rd - rm -f *.f90 *.c *.$(FC_MODULE_EXT) *.o *.la *.f90.in + rm -f *.f90 *.c *.$(FCMOD) *.o *.la *.f90.in rm -f *.makefile rm -rf ref-output rm -f *.sin *.hbc rm -f *.phs *.vg *.vgb *.evt *.evx *.lhe *.hepmc *.dat *.debug rm -f *.tmp *.hepevt *.hepevt.verb *.lha *.lha.verb *.slcio rm -f prc_omega_diags_1_p_i1_diags.out prc_omega_diags_1_p_i1_diags.toc rm -f *.hep *.up.hep *.[1-9] *.[1-9][0-9] *.[1-9][0-9][0-9] rm -f *.tex *.mp *.mpx *.t[1-9] *.t[1-9][0-9] *.t[1-9][0-9][0-9] rm -f *.ltp *.aux *.dvi *.ps *.pdf so_test.* rm -f *.tbl sps1ap_decays.slha bar structure_6[a-b].out rm -f slhaspectrum.in suspect2.out suspect2_lha.out rm -f susyhit.in susyhit_slha.out suspect2_lha.in rm -f *.olc *.olp *.olp_parameters rm -rf stability_log rm -rf *olp_modules rm -rf Generated_Loops rm -rf include lib golem.in rm -f SM_tt_threshold.grid rm -f *fks_regions.out rm -f *_powheg_*.pg if FC_SUBMODULES rm -f *.smod endif ## Remove backup files maintainer-clean-local: maintainer-clean-fc -rm -f *~ .PHONY: maintainer-clean-local Index: trunk/tests/functional_tests/Makefile.am =================================================================== --- trunk/tests/functional_tests/Makefile.am (revision 8428) +++ trunk/tests/functional_tests/Makefile.am (revision 8429) @@ -1,831 +1,831 @@ ## Makefile.am -- Makefile for executable WHIZARD test scripts ## ## Process this file with automake to produce Makefile.in ## ######################################################################## # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## WHIZARD_DRIVER = run_whizard.sh TESTS_DEFAULT = \ empty.run \ fatal.run \ cmdline_1.run \ structure_1.run \ structure_2.run \ structure_3.run \ structure_4.run \ structure_5.run \ structure_6.run \ structure_7.run \ structure_8.run \ vars.run \ extpar.run \ testproc_1.run \ testproc_2.run \ testproc_3.run \ testproc_4.run \ testproc_5.run \ testproc_6.run \ testproc_7.run \ testproc_8.run \ testproc_9.run \ testproc_10.run \ testproc_11.run \ testproc_12.run \ template_me_1.run \ template_me_2.run \ model_scheme_1.run \ rebuild_1.run \ rebuild_4.run \ susyhit.run \ helicity.run \ libraries_4.run \ job_id_1.run \ pack_1.run XFAIL_TESTS_DEFAULT = TESTS_REQ_FASTJET = \ analyze_4.run \ bjet_cluster.run \ nlo_7.run \ nlo_8.run \ openloops_12.run \ openloops_13.run TESTS_REQ_OCAML = \ libraries_1.run \ libraries_2.run \ libraries_3.run \ rebuild_2.run \ rebuild_3.run \ rebuild_5.run \ defaultcuts.run \ cuts.run \ model_change_1.run \ model_change_2.run \ model_change_3.run \ model_test.run \ job_id_2.run \ job_id_3.run \ job_id_4.run \ qedtest_1.run \ qedtest_2.run \ qedtest_3.run \ qedtest_4.run \ qedtest_5.run \ qedtest_6.run \ qedtest_7.run \ qedtest_8.run \ qedtest_9.run \ qedtest_10.run \ rambo_vamp_1.run \ rambo_vamp_2.run \ beam_setup_1.run \ beam_setup_2.run \ beam_setup_3.run \ beam_setup_4.run \ beam_setup_5.run \ qcdtest_1.run \ qcdtest_2.run \ qcdtest_3.run \ qcdtest_4.run \ qcdtest_5.run \ qcdtest_6.run \ observables_1.run \ observables_2.run \ event_weights_1.run \ event_weights_2.run \ event_eff_1.run \ event_eff_2.run \ event_dump_1.run \ event_dump_2.run \ event_failed_1.run \ reweight_1.run \ reweight_2.run \ reweight_3.run \ reweight_4.run \ reweight_5.run \ reweight_6.run \ reweight_7.run \ reweight_8.run \ reweight_9.run \ reweight_10.run \ analyze_1.run \ analyze_2.run \ analyze_5.run \ analyze_6.run \ colors.run \ colors_2.run \ colors_hgg.run \ alphas.run \ jets_xsec.run \ lhef_1.run \ lhef_2.run \ lhef_3.run \ lhef_4.run \ lhef_5.run \ lhef_6.run \ lhef_7.run \ lhef_8.run \ lhef_9.run \ lhef_10.run \ lhef_11.run \ stdhep_1.run \ stdhep_2.run \ stdhep_3.run \ stdhep_4.run \ stdhep_5.run \ stdhep_6.run \ select_1.run \ select_2.run \ fatal_beam_decay.run \ smtest_1.run \ smtest_2.run \ smtest_3.run \ smtest_4.run \ smtest_5.run \ smtest_6.run \ smtest_7.run \ smtest_8.run \ smtest_9.run \ smtest_10.run \ smtest_11.run \ smtest_12.run \ smtest_13.run \ smtest_14.run \ smtest_15.run \ smtest_16.run \ photon_isolation_1.run \ photon_isolation_2.run \ resonances_1.run \ resonances_2.run \ resonances_3.run \ resonances_4.run \ resonances_5.run \ resonances_6.run \ resonances_7.run \ resonances_8.run \ resonances_9.run \ resonances_10.run \ resonances_11.run \ resonances_12.run \ resonances_13.run \ mssmtest_1.run \ mssmtest_2.run \ mssmtest_3.run \ sm_cms_1.run \ ufo_1.run \ ufo_2.run \ ufo_3.run \ ufo_4.run \ ufo_5.run \ ufo_6.run \ nlo_1.run \ nlo_2.run \ nlo_3.run \ nlo_4.run \ nlo_5.run \ nlo_6.run \ nlo_9.run \ nlo_decay_1.run \ real_partition_1.run \ fks_res_1.run \ fks_res_2.run \ fks_res_3.run \ openloops_1.run \ openloops_2.run \ openloops_3.run \ openloops_4.run \ openloops_5.run \ openloops_6.run \ openloops_7.run \ openloops_8.run \ openloops_9.run \ openloops_10.run \ openloops_11.run \ recola_1.run \ recola_2.run \ recola_3.run \ recola_4.run \ recola_5.run \ recola_6.run \ recola_7.run \ recola_8.run \ recola_9.run \ powheg_1.run \ spincor_1.run \ show_1.run \ show_2.run \ show_3.run \ show_4.run \ show_5.run \ method_ovm_1.run \ multi_comp_1.run \ multi_comp_2.run \ multi_comp_3.run \ multi_comp_4.run \ flvsum_1.run \ br_redef_1.run \ decay_err_1.run \ decay_err_2.run \ decay_err_3.run \ polarized_1.run \ pdf_builtin.run \ ep_1.run \ ep_2.run \ ep_3.run \ circe1_1.run \ circe1_2.run \ circe1_3.run \ circe1_4.run \ circe1_5.run \ circe1_6.run \ circe1_7.run \ circe1_8.run \ circe1_9.run \ circe1_10.run \ circe1_photons_1.run \ circe1_photons_2.run \ circe1_photons_3.run \ circe1_photons_4.run \ circe1_photons_5.run \ circe1_errors_1.run \ circe2_1.run \ circe2_2.run \ circe2_3.run \ ewa_1.run \ ewa_2.run \ ewa_3.run \ ewa_4.run \ isr_1.run \ isr_2.run \ isr_3.run \ isr_4.run \ isr_5.run \ isr_6.run \ epa_1.run \ epa_2.run \ epa_3.run \ epa_4.run \ isr_epa_1.run \ ilc.run \ gaussian_1.run \ gaussian_2.run \ beam_events_1.run \ beam_events_2.run \ beam_events_3.run \ beam_events_4.run \ energy_scan_1.run \ restrictions.run \ process_log.run \ shower_err_1.run \ parton_shower_1.run \ parton_shower_2.run \ hadronize_1.run \ mlm_matching_fsr.run \ user_prc_threshold_1.run \ cascades2_phs_1.run \ cascades2_phs_2.run \ user_prc_threshold_2.run \ vamp2_1.run \ vamp2_2.run \ vamp2_3.run XFAIL_TESTS_REQ_OCAML = \ colors_hgg.run \ hadronize_1.run TESTS_REQ_HEPMC = \ hepmc_1.run \ hepmc_2.run \ hepmc_3.run \ hepmc_4.run \ hepmc_5.run \ hepmc_6.run \ hepmc_7.run \ hepmc_8.run \ hepmc_9.run \ hepmc_10.run XFAIL_TESTS_REQ_HEPMC = TESTS_REQ_LCIO = \ lcio_1.run \ lcio_2.run \ lcio_3.run \ lcio_4.run \ lcio_5.run \ lcio_6.run \ lcio_7.run \ lcio_8.run \ lcio_9.run \ lcio_10.run \ lcio_11.run XFAIL_TESTS_REQ_LCIO = TESTS_REQ_LHAPDF5 = \ lhapdf5.run TESTS_REQ_LHAPDF6 = \ lhapdf6.run XFAIL_TESTS_REQ_LHAPDF5 = XFAIL_TESTS_REQ_LHAPDF6 = TESTS_STATIC = \ static_1.run \ static_2.run XFAIL_TESTS_STATIC = TESTS_REQ_PYTHIA6 = \ pythia6_1.run \ pythia6_2.run \ pythia6_3.run \ pythia6_4.run \ tauola_1.run \ tauola_2.run \ tauola_3.run \ isr_5.run \ mlm_pythia6_isr.run \ mlm_matching_isr.run XFAIL_TESTS_REQ_PYTHIA6 = TESTS_REQ_PYTHIA8 = # pythia8_1.run \ # pythia8_2.run XFAIL_TESTS_REQ_PYTHIA8 = TESTS_REQ_EV_ANA = \ analyze_3.run XFAIL_TESTS_REQ_EV_ANA = TESTS_REQ_GAMELAN = \ analyze_3.run TEST_DRIVERS_RUN = \ $(TESTS_DEFAULT) \ $(TESTS_REQ_OCAML) \ $(TESTS_REQ_LHAPDF5) \ $(TESTS_REQ_LHAPDF6) \ $(TESTS_REQ_HEPMC) \ $(TESTS_REQ_LCIO) \ $(TESTS_REQ_FASTJET) \ $(TESTS_REQ_PYTHIA6) \ $(TESTS_REQ_EV_ANA) \ $(TESTS_STATIC) TEST_DRIVERS_SH = $(TEST_DRIVERS_RUN:.run=.sh) ######################################################################## TESTS = XFAIL_TESTS = TESTS_SRC = TESTS += $(TESTS_DEFAULT) XFAIL_TESTS += $(XFAIL_TESTS_DEFAULT) TESTS += $(TESTS_REQ_OCAML) XFAIL_TESTS += $(XFAIL_TESTS_REQ_OCAML) TESTS += $(TESTS_REQ_HEPMC) XFAIL_TESTS += $(XFAIL_TESTS_REQ_HEPMC) TESTS += $(TESTS_REQ_LCIO) XFAIL_TESTS += $(XFAIL_TESTS_REQ_LCIO) TESTS += $(TESTS_REQ_FASTJET) XFAIL_TESTS += $(XFAIL_TESTS_REQ_FASTJET) TESTS += $(TESTS_REQ_LHAPDF5) XFAIL_TESTS += $(XFAIL_TESTS_REQ_LHAPDF5) TESTS += $(TESTS_REQ_LHAPDF6) XFAIL_TESTS += $(XFAIL_TESTS_REQ_LHAPDF6) TESTS += $(TESTS_REQ_PYTHIA6) XFAIL_TESTS += $(XFAIL_TESTS_REQ_PYTHIA6) TESTS += $(TESTS_REQ_PYTHIA8) XFAIL_TESTS += $(XFAIL_TESTS_REQ_PYTHIA8) TESTS += $(TESTS_REQ_EV_ANA) XFAIL_TESTS += $(XFAIL_TESTS_REQ_EV_ANA) TESTS += $(TESTS_STATIC) XFAIL_TESTS += $(XFAIL_TESTS_STATIC) EXTRA_DIST = $(TEST_DRIVERS_SH) \ $(TESTS_SRC) ######################################################################## VPATH = $(srcdir) SUFFIXES = .sh .run .sh.run: @rm -f $@ @if test -f $(top_builddir)/share/tests/functional_tests/$*.sin; then \ $(SED) 's|@script@|$(top_builddir)/share/tests/functional_tests/$*|g' $< > $@; \ elif test -f $(top_srcdir)/share/tests/functional_tests/$*.sin; then \ $(SED) 's|@script@|$(top_srcdir)/share/tests/functional_tests/$*|g' $< > $@; \ else \ echo "$*.sin not found!" 1>&2; \ exit 2; \ fi @chmod +x $@ cmdline_1.run: cmdline_1_a.sin cmdline_1_b.sin cmdline_1_a.sin: $(top_builddir)/share/tests/functional_tests/cmdline_1_a.sin cp $< $@ cmdline_1_b.sin: $(top_builddir)/share/tests/functional_tests/cmdline_1_b.sin cp $< $@ structure_2.run: structure_2_inc.sin structure_2_inc.sin: $(top_builddir)/share/tests/functional_tests/structure_2_inc.sin cp $< $@ testproc_3.run: testproc_3.phs testproc_3.phs: $(top_builddir)/share/tests/functional_tests/testproc_3.phs cp $< $@ static_1.run: static_1.exe.sin static_1.exe.sin: $(top_builddir)/share/tests/functional_tests/static_1.exe.sin cp $< $@ static_2.run: static_2.exe.sin static_2.exe.sin: $(top_builddir)/share/tests/functional_tests/static_2.exe.sin cp $< $@ susyhit.run: susyhit.in -model_test.run: tdefs.$(FC_MODULE_EXT) tglue.$(FC_MODULE_EXT) \ - threeshl.$(FC_MODULE_EXT) tscript.$(FC_MODULE_EXT) -tdefs.mod: $(top_builddir)/src/models/threeshl_bundle/tdefs.$(FC_MODULE_EXT) +model_test.run: tdefs.$(FCMOD) tglue.$(FCMOD) \ + threeshl.$(FCMOD) tscript.$(FCMOD) +tdefs.mod: $(top_builddir)/src/models/threeshl_bundle/tdefs.$(FCMOD) cp $< $@ -tglue.mod: $(top_builddir)/src/models/threeshl_bundle/tglue.$(FC_MODULE_EXT) +tglue.mod: $(top_builddir)/src/models/threeshl_bundle/tglue.$(FCMOD) cp $< $@ -tscript.mod: $(top_builddir)/src/models/threeshl_bundle/tscript.$(FC_MODULE_EXT) +tscript.mod: $(top_builddir)/src/models/threeshl_bundle/tscript.$(FCMOD) cp $< $@ -threeshl.mod: $(top_builddir)/src/models/threeshl_bundle/threeshl.$(FC_MODULE_EXT) +threeshl.mod: $(top_builddir)/src/models/threeshl_bundle/threeshl.$(FCMOD) cp $< $@ WT_OCAML_NATIVE_EXT=opt if OCAML_AVAILABLE OMEGA_QED = $(top_builddir)/omega/bin/omega_QED.$(WT_OCAML_NATIVE_EXT) OMEGA_QCD = $(top_builddir)/omega/bin/omega_QCD.$(WT_OCAML_NATIVE_EXT) OMEGA_MSSM = $(top_builddir)/omega/bin/omega_MSSM.$(WT_OCAML_NATIVE_EXT) omega_MSSM.$(WT_OMEGA_CACHE_SUFFIX): $(OMEGA_MSSM) $(OMEGA_MSSM) -initialize . UFO_TAG_FILE = __init__.py UFO_MODELPATH = ../models/UFO ufo_1.run: ufo_1_SM/$(UFO_TAG_FILE) ufo_2.run: ufo_2_SM/$(UFO_TAG_FILE) ufo_3.run: ufo_3_models/ufo_3_SM/$(UFO_TAG_FILE) ufo_4.run: ufo_4_models/ufo_4_SM/$(UFO_TAG_FILE) ufo_5.run: ufo_5_SM/$(UFO_TAG_FILE) ufo_6.run: ufo_6_MSSM/$(UFO_TAG_FILE) ufo_1_SM/$(UFO_TAG_FILE): $(UFO_MODELPATH)/SM/$(UFO_TAG_FILE) mkdir -p ufo_1_SM cp $(UFO_MODELPATH)/SM/*.py ufo_1_SM ufo_2_SM/$(UFO_TAG_FILE): $(UFO_MODELPATH)/SM/$(UFO_TAG_FILE) mkdir -p ufo_2_SM cp $(UFO_MODELPATH)/SM/*.py ufo_2_SM ufo_3_models/ufo_3_SM/$(UFO_TAG_FILE): $(UFO_MODELPATH)/SM/$(UFO_TAG_FILE) mkdir -p ufo_3_models/ufo_3_SM cp $(UFO_MODELPATH)/SM/*.py ufo_3_models/ufo_3_SM ufo_4_models/ufo_4_SM/$(UFO_TAG_FILE): $(UFO_MODELPATH)/SM/$(UFO_TAG_FILE) mkdir -p ufo_4_models/ufo_4_SM cp $(UFO_MODELPATH)/SM/*.py ufo_4_models/ufo_4_SM ufo_5_SM/$(UFO_TAG_FILE): $(UFO_MODELPATH)/SM/$(UFO_TAG_FILE) mkdir -p ufo_5_SM cp $(UFO_MODELPATH)/SM/*.py ufo_5_SM ufo_6_MSSM/$(UFO_TAG_FILE): $(UFO_MODELPATH)/MSSM/$(UFO_TAG_FILE) mkdir -p ufo_6_MSSM cp $(UFO_MODELPATH)/MSSM/*.py ufo_6_MSSM ufo_5.run: ufo_5_test.slha ufo_5_test.slha: $(top_builddir)/share/tests/functional_tests/ufo_5_test.slha cp $< $@ $(UFO_MODELPATH)/SM/$(UFO_TAG_FILE): $(top_srcdir)/omega/tests/UFO/SM/$(UFO_TAG_FILE) $(MAKE) -C $(UFO_MODELPATH)/SM all $(UFO_MODELPATH)/MSSM/$(UFO_TAG_FILE): $(top_srcdir)/omega/tests/UFO/MSSM/$(UFO_TAG_FILE) $(MAKE) -C $(UFO_MODELPATH)/MSSM all endif OCAML_AVAILABLE if MPOST_AVAILABLE $(TESTS_REQ_GAMELAN): gamelan.sty gamelan.sty: $(top_builddir)/src/gamelan/gamelan.sty cp $< $@ $(top_builddir)/src/gamelan/gamelan.sty: $(MAKE) -C $(top_builddir)/src/gamelan gamelan.sty endif noinst_PROGRAMS = if OCAML_AVAILABLE noinst_PROGRAMS += resonances_1_count resonances_1_count_SOURCES = resonances_1_count.f90 resonances_1.run: resonances_1_count noinst_PROGRAMS += resonances_2_count resonances_2_count_SOURCES = resonances_2_count.f90 resonances_2.run: resonances_2_count noinst_PROGRAMS += resonances_3_count resonances_3_count_SOURCES = resonances_3_count.f90 resonances_3.run: resonances_3_count noinst_PROGRAMS += resonances_4_count resonances_4_count_SOURCES = resonances_4_count.f90 resonances_4.run: resonances_4_count noinst_PROGRAMS += resonances_9_count resonances_9_count_SOURCES = resonances_9_count.f90 resonances_9.run: resonances_9_count noinst_PROGRAMS += resonances_10_count resonances_10_count_SOURCES = resonances_10_count.f90 resonances_10.run: resonances_10_count noinst_PROGRAMS += resonances_11_count resonances_11_count_SOURCES = resonances_11_count.f90 resonances_11.run: resonances_11_count noinst_PROGRAMS += epa_2_count epa_2_count_SOURCES = epa_2_count.f90 epa_2.run: epa_2_count noinst_PROGRAMS += isr_epa_1_count isr_epa_1_count_SOURCES = isr_epa_1_count.f90 isr_epa_1.run: isr_epa_1_count noinst_PROGRAMS += isr_6_digest isr_6_digest_SOURCES = isr_6_digest.f90 isr_6.run: isr_6_digest noinst_PROGRAMS += analyze_6_check analyze_6_check_SOURCES = analyze_6_check.f90 analyze_6.run: analyze_6_check endif if HEPMC_AVAILABLE TESTS_SRC += $(hepmc_6_rd_SOURCES) noinst_PROGRAMS += hepmc_6_rd if HEPMC_IS_VERSION3 hepmc_6_rd_SOURCES = hepmc3_6_rd.cpp else hepmc_6_rd_SOURCES = hepmc2_6_rd.cpp endif hepmc_6_rd_CXXFLAGS = $(HEPMC_INCLUDES) $(AM_CXXFLAGS) hepmc_6_rd_LDADD = $(LDFLAGS_HEPMC) hepmc_6.run: hepmc_6_rd endif if LCIO_AVAILABLE TESTS_SRC += $(lcio_rd_SOURCES) noinst_PROGRAMS += lcio_rd lcio_rd_SOURCES = lcio_rd.cpp lcio_rd_CXXFLAGS = $(LCIO_INCLUDES) $(AM_CXXFLAGS) lcio_rd_LDADD = $(LDFLAGS_LCIO) lcio_1.run: lcio_rd lcio_2.run: lcio_rd lcio_3.run: lcio_rd lcio_4.run: lcio_rd lcio_5.run: lcio_rd lcio_10.run: lcio_rd lcio_11.run: lcio_rd endif stdhep_4.run: stdhep_rd stdhep_5.run: stdhep_rd stdhep_6.run: stdhep_rd polarized_1.run: stdhep_rd tauola_1.run: stdhep_rd tauola_2.run: stdhep_rd tauola_3.run: stdhep_rd stdhep_rd: $(top_builddir)/src/xdr/stdhep_rd cp $< $@ susyhit.in: $(top_builddir)/share/tests/functional_tests/susyhit.in cp $< $@ BUILT_SOURCES = \ TESTFLAG \ HEPMC2_FLAG \ HEPMC3_FLAG \ LCIO_FLAG \ FASTJET_FLAG \ LHAPDF5_FLAG \ LHAPDF6_FLAG \ GAMELAN_FLAG \ MPI_FLAG \ EVENT_ANALYSIS_FLAG \ OCAML_FLAG \ PYTHIA6_FLAG \ PYTHIA8_FLAG \ OPENLOOPS_FLAG \ RECOLA_FLAG \ GZIP_FLAG \ STATIC_FLAG \ ref-output # If this file is found in the working directory, WHIZARD # will use the paths for the uninstalled version (source/build tree), # otherwise it uses the installed version TESTFLAG: touch $@ FASTJET_FLAG: if FASTJET_AVAILABLE touch $@ endif HEPMC2_FLAG: if HEPMC2_AVAILABLE touch $@ endif HEPMC3_FLAG: if HEPMC3_AVAILABLE touch $@ endif LCIO_FLAG: if LCIO_AVAILABLE touch $@ endif LHAPDF5_FLAG: if LHAPDF5_AVAILABLE touch $@ endif LHAPDF6_FLAG: if LHAPDF6_AVAILABLE touch $@ endif GAMELAN_FLAG: if MPOST_AVAILABLE touch $@ endif MPI_FLAG: if FC_USE_MPI touch $@ endif OCAML_FLAG: if OCAML_AVAILABLE touch $@ endif PYTHIA6_FLAG: if PYTHIA6_AVAILABLE touch $@ endif PYTHIA8_FLAG: if PYTHIA8_AVAILABLE touch $@ endif OPENLOOPS_FLAG: if OPENLOOPS_AVAILABLE touch $@ endif RECOLA_FLAG: if RECOLA_AVAILABLE touch $@ endif EVENT_ANALYSIS_FLAG: if EVENT_ANALYSIS_AVAILABLE touch $@ endif GZIP_FLAG: if GZIP_AVAILABLE touch $@ endif STATIC_FLAG: if STATIC_AVAILABLE touch $@ endif # The reference output files are in the source directory. Copy them here. if FC_QUAD ref-output: $(top_srcdir)/share/tests/functional_tests/ref-output mkdir -p ref-output for f in $ # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## Invoke extended tests by 'make check' or 'make check-extended' check-extended: check ######################################################################## WHIZARD_DRIVER = run_whizard.sh TESTS_EXTENDED = \ ilc_top_pair_360.run \ ilc_top_pair_500.run \ ilc_vbf_higgs_360.run \ ilc_vbf_higgs_500.run \ ilc_vbf_no_higgs_360.run \ ilc_vbf_no_higgs_500.run \ ilc_higgs_strahlung_360.run \ ilc_higgs_strahlung_500.run \ ilc_higgs_strahlung_background_360.run \ ilc_higgs_strahlung_background_500.run \ ilc_higgs_coupling_360.run \ ilc_higgs_coupling_500.run \ ilc_higgs_coupling_background_360.run \ ilc_higgs_coupling_background_500.run XFAIL_TESTS_EXTENDED = TESTS_REQ_GAMELAN = #\ $(TESTS_REQ_OCAML) \ $(TESTS_EXTENDED) TEST_DRIVERS_RUN = \ $(TESTS_EXTENDED) TEST_DRIVERS_SH = $(TEST_DRIVERS_RUN:.run=.sh) ######################################################################## TESTS = XFAIL_TESTS = TESTS_SRC = if FC_PREC else TESTS += $(TESTS_EXTENDED) XFAIL_TESTS += $(XFAIL_TESTS_EXTENDED) endif EXTRA_DIST = $(TEST_DRIVERS_SH) \ $(TESTS_SRC) ######################################################################## VPATH = $(srcdir) SUFFIXES = .sh .run .sh.run: @rm -f $@ @if test -f $(top_builddir)/share/tests/ext_tests_ilc/$*.sin; then \ $(SED) 's|@script@|$(top_builddir)/share/tests/ext_tests_ilc/$*|g' $< > $@; \ elif test -f $(top_srcdir)/share/tests/ext_tests_ilc/$*.sin; then \ $(SED) 's|@script@|$(top_srcdir)/share/tests/ext_tests_ilc/$*|g' $< > $@; \ fi @chmod +x $@ if MPOST_AVAILABLE $(TESTS_REQ_GAMELAN): gamelan.sty $(UNIT_TESTS_REQ_GAMELAN): gamelan.sty gamelan.sty: $(top_builddir)/src/gamelan/gamelan.sty cp $< $@ $(top_builddir)/src/gamelan/gamelan.sty: $(MAKE) -C $(top_builddir)/src/gamelan gamelan.sty endif BUILT_SOURCES = \ TESTFLAG \ HEPMC2_FLAG \ HEPMC3_FLAG \ LCIO_FLAG \ FASTJET_FLAG \ LHAPDF5_FLAG \ LHAPDF6_FLAG \ GAMELAN_FLAG \ EVENT_ANALYSIS_FLAG \ OCAML_FLAG \ PYTHIA6_FLAG \ STATIC_FLAG ilc_top_pair_360.run: ilc_settings.sin ilc_top_pair_500.run: ilc_settings.sin ilc_vbf_higgs_360.run: ilc_settings.sin ilc_vbf_higgs_500.run: ilc_settings.sin ilc_higgs_strahlung_360.run: ilc_settings.sin ilc_higgs_strahlung_500.run: ilc_settings.sin ilc_higgs_strahlung_background_360.run: ilc_settings.sin ilc_higgs_strahlung_background_500.run: ilc_settings.sin ilc_higgs_coupling_360.run: ilc_settings.sin ilc_higgs_coupling_500.run: ilc_settings.sin ilc_higgs_coupling_background_360.run: ilc_settings.sin ilc_higgs_coupling_background_500.run: ilc_settings.sin ilc_settings.sin: $(top_builddir)/share/tests/ext_tests_ilc/ilc_settings.sin cp $< $@ # If this file is found in the working directory, WHIZARD # will use the paths for the uninstalled version (source/build tree), # otherwise it uses the installed version TESTFLAG: touch $@ FASTJET_FLAG: if FASTJET_AVAILABLE touch $@ endif HEPMC2_FLAG: if HEPMC2_AVAILABLE touch $@ endif HEPMC3_FLAG: if HEPMC3_AVAILABLE touch $@ endif LCIO_FLAG: if LCIO_AVAILABLE touch $@ endif LHAPDF5_FLAG: if LHAPDF5_AVAILABLE touch $@ endif LHAPDF6_FLAG: if LHAPDF6_AVAILABLE touch $@ endif GAMELAN_FLAG: if MPOST_AVAILABLE touch $@ endif OCAML_FLAG: if OCAML_AVAILABLE touch $@ endif PYTHIA6_FLAG: if PYTHIA6_AVAILABLE touch $@ endif EVENT_ANALYSIS_FLAG: if EVENT_ANALYSIS_AVAILABLE touch $@ endif STATIC_FLAG: if STATIC_AVAILABLE touch $@ endif ## installcheck runs the test scripts with the TESTFLAG removed. installcheck-local: notestflag check-am notestflag: rm -f TESTFLAG .PHONY: notestflag ## Remove generated files clean-local: rm -f gamelan.sty rm -f TESTFLAG GAMELAN_FLAG rm -f OCAML_FLAG FASTJET_FLAG HEPMC2_FLAG HEPMC3_FLAG LCIO_FLAG rm -f EVENT_ANALYSIS_FLAG PYTHIA6_FLAG LHAPDF5_FLAG rm -f LHAPDF6_FLAG STATIC_FLAG static_1.exe rm -f *.run *.log slha_test.out rm -f core* stdhep_rd - rm -f *.f90 *.c *.$(FC_MODULE_EXT) *.o *.la + rm -f *.f90 *.c *.$(FCMOD) *.o *.la rm -f *.makefile rm -f *.sin *.hbc rm -f *.phs *.vg *.vgb *.evt *.evx *.lhe *.hepmc *.dat *.debug *.vg2 *.vgx2 *.fds rm -f *.tmp *.hepevt *.hepevt.verb *.lha *.lha.verb *.slcio rm -f prc_omega_diags_1_p_i1_diags.out prc_omega_diags_1_p_i1_diags.toc rm -f *.hep *.up.hep *.[1-9] *.[1-9][0-9] *.[1-9][0-9][0-9] rm -f *.tex *.mp *.mpx *.t[1-9] *.t[1-9][0-9] *.t[1-9][0-9][0-9] rm -f *.ltp *.aux *.dvi *.ps *.pdf so_test.* rm -f *.tbl sps1ap_decays.slha bar structure_6[a-b].out if FC_SUBMODULES rm -f *.smod endif ## Remove backup files maintainer-clean-local: maintainer-clean-fc -rm -f *~ .PHONY: maintainer-clean-local Index: trunk/tests/ext_tests_shower/Makefile.am =================================================================== --- trunk/tests/ext_tests_shower/Makefile.am (revision 8428) +++ trunk/tests/ext_tests_shower/Makefile.am (revision 8429) @@ -1,219 +1,219 @@ ## Makefile.am -- Makefile for executable WHIZARD test scripts ## ## Process this file with automake to produce Makefile.in ## ######################################################################## # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## WHIZARD_DRIVER = run_whizard.sh TESTS_EXTENDED = \ shower_1_norad.run \ shower_2_aall.run \ shower_3_bb.run \ shower_3_jj.run \ shower_3_qqqq.run \ shower_3_tt.run \ shower_3_z_nu.run \ shower_3_z_tau.run \ shower_4_ee.run \ shower_5.run \ shower_6.run XFAIL_TESTS_EXTENDED = TESTS_REQ_GAMELAN = \ shower_2_aall.run TESTS_REQ_SLHA = \ shower_6.run TEST_DRIVERS_RUN = \ $(TESTS_EXTENDED) TEST_DRIVERS_SH = $(TEST_DRIVERS_RUN:.run=.sh) ######################################################################## TESTS = $(TESTS_EXTENDED) XFAIL_TESTS = $(XFAIL_TESTS_EXTENDED) EXTRA_DIST = $(TEST_DRIVERS_SH) ######################################################################## VPATH = $(srcdir) SUFFIXES = .sh .run .sh.run: @rm -f $@ @if test -f $(top_builddir)/share/tests/ext_tests_shower/$*.sin; then \ $(SED) 's|@script@|$(top_builddir)/share/tests/ext_tests_shower/$*|g' $< > $@; \ elif test -f $(top_srcdir)/share/tests/ext_tests_shower/$*.sin; then \ $(SED) 's|@script@|$(top_srcdir)/share/tests/ext_tests_shower/$*|g' $< > $@; \ fi - $(SED) 's|@python_bin@|$(PYTHON_BIN)|g' $@ >> "$@.tmp" && mv "$@.tmp" $@ + $(SED) 's|@python_bin@|$(PYTHON)|g' $@ >> "$@.tmp" && mv "$@.tmp" $@ $(SED) 's|@share_dir@|$(top_srcdir)/share/tests|g' $@ >> "$@.tmp" && mv "$@.tmp" $@ @chmod +x $@ $(TESTS_REQ_SLHA): nmssm.slha nmssm.slha: $(top_srcdir)/share/tests/ext_tests_nmssm/nmssm.slha cp $< $@ if MPOST_AVAILABLE $(TESTS_REQ_GAMELAN): gamelan.sty gamelan.sty: $(top_builddir)/src/gamelan/gamelan.sty cp $< $@ $(top_builddir)/src/gamelan/gamelan.sty: $(MAKE) -C $(top_builddir)/src/gamelan gamelan.sty endif BUILT_SOURCES = \ TESTFLAG \ HEPMC2_FLAG \ HEPMC3_FLAG \ LCIO_FLAG \ FASTJET_FLAG \ LHAPDF5_FLAG \ LHAPDF6_FLAG \ GAMELAN_FLAG \ EVENT_ANALYSIS_FLAG \ OCAML_FLAG \ PYTHON_FLAG \ PYTHIA6_FLAG \ STATIC_FLAG \ ref-output # If this file is found in the working directory, WHIZARD # will use the paths for the uninstalled version (source/build tree), # otherwise it uses the installed version TESTFLAG: touch $@ FASTJET_FLAG: if FASTJET_AVAILABLE touch $@ endif HEPMC2_FLAG: if HEPMC2_AVAILABLE touch $@ endif HEPMC3_FLAG: if HEPMC3_AVAILABLE touch $@ endif LCIO_FLAG: if LCIO_AVAILABLE touch $@ endif LHAPDF5_FLAG: if LHAPDF5_AVAILABLE touch $@ endif LHAPDF6_FLAG: if LHAPDF6_AVAILABLE touch $@ endif GAMELAN_FLAG: if MPOST_AVAILABLE touch $@ endif OCAML_FLAG: if OCAML_AVAILABLE touch $@ endif PYTHON_FLAG: if PYTHON_AVAILABLE touch $@ endif PYTHIA6_FLAG: if PYTHIA6_AVAILABLE touch $@ endif EVENT_ANALYSIS_FLAG: if EVENT_ANALYSIS_AVAILABLE touch $@ endif STATIC_FLAG: if STATIC_AVAILABLE touch $@ endif # The reference output files are in the source directory. Copy them here. ref-output: $(top_srcdir)/share/tests/ext_tests_shower/ref-output mkdir -p ref-output for f in $ # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## WHIZARD_DRIVER = run_whizard.sh TESTS_EXTENDED = \ nlo_ee4b.run \ nlo_ee4j.run \ nlo_ee4t.run \ nlo_ee4tj.run \ nlo_ee5j.run \ nlo_eebb.run \ nlo_eebbj.run \ nlo_eebbjj.run \ nlo_eejj.run \ nlo_eejjj.run \ nlo_eett.run \ nlo_eetta.run \ nlo_eettaa.run \ nlo_eettah.run \ nlo_eettaj.run \ nlo_eettajj.run \ nlo_eettaz.run \ nlo_eettbb.run \ nlo_eetth.run \ nlo_eetthh.run \ nlo_eetthj.run \ nlo_eetthjj.run \ nlo_eetthz.run \ nlo_eettj.run \ nlo_eettjj.run \ nlo_eettjjj.run \ nlo_eettwjj.run \ nlo_eettww.run \ nlo_eettz.run \ nlo_eettzj.run \ nlo_eettzjj.run \ nlo_eettzz.run \ nlo_ppz.run \ nlo_ppw.run \ nlo_ppzz.run \ nlo_ppzw.run \ nlo_pptttt.run XFAIL_TESTS_EXTENDED = TESTS_REQ_GAMELAN = TEST_DRIVERS_RUN = \ $(TESTS_EXTENDED) TEST_DRIVERS_SH = $(TEST_DRIVERS_RUN:.run=.sh) ######################################################################## TESTS = $(TESTS_EXTENDED) XFAIL_TESTS = $(XFAIL_TESTS_EXTENDED) EXTRA_DIST = $(TEST_DRIVERS_SH) ######################################################################## VPATH = $(srcdir) SUFFIXES = .sh .run .sh.run: @rm -f $@ @if test -f $(top_builddir)/share/tests/ext_tests_nlo/$*.sin; then \ $(SED) 's|@script@|$(top_builddir)/share/tests/ext_tests_nlo/$*|g' $< > $@; \ elif test -f $(top_srcdir)/share/tests/ext_tests_nlo/$*.sin; then \ $(SED) 's|@script@|$(top_srcdir)/share/tests/ext_tests_nlo/$*|g' $< > $@; \ fi @chmod +x $@ nlo_eejj.run: nlo_settings.sin nlo_eejjj.run: nlo_settings.sin nlo_ee4j.run: nlo_settings.sin nlo_ee5j.run: nlo_settings.sin nlo_eebb.run: nlo_settings.sin nlo_eebbj.run: nlo_settings.sin nlo_eebbjj.run: nlo_settings.sin nlo_ee4b.run: nlo_settings.sin nlo_eett.run: nlo_settings.sin nlo_eettj.run: nlo_settings.sin nlo_eettjj.run: nlo_settings.sin nlo_eettjjj.run: nlo_settings.sin nlo_eettbb.run: nlo_settings.sin nlo_eetta.run: nlo_settings.sin nlo_eettaa.run: nlo_settings.sin nlo_eettaj.run: nlo_settings.sin nlo_eettajj.run: nlo_settings.sin nlo_eettah.run: nlo_settings.sin nlo_eettaz.run: nlo_settings.sin nlo_eettz.run: nlo_settings.sin nlo_eettzj.run: nlo_settings.sin nlo_eettzjj.run: nlo_settings.sin nlo_eettzz.run: nlo_settings.sin nlo_eettwjj.run: nlo_settings.sin nlo_eettww.run: nlo_settings.sin nlo_eetth.run: nlo_settings.sin nlo_eetthj.run: nlo_settings.sin nlo_eetthjj.run: nlo_settings.sin nlo_eetthh.run: nlo_settings.sin nlo_eetthz.run: nlo_settings.sin nlo_ee4t.run: nlo_settings.sin nlo_ee4tj.run: nlo_settings.sin nlo_ppz.run: nlo_settings.sin nlo_ppw.run: nlo_settings.sin nlo_ppzz.run: nlo_settings.sin nlo_ppzw.run: nlo_settings.sin nlo_pptttt.run: nlo_settings.sin nlo_settings.sin: $(top_builddir)/share/tests/ext_tests_nlo/nlo_settings.sin cp $< $@ if MPOST_AVAILABLE $(TESTS_REQ_GAMELAN): gamelan.sty $(UNIT_TESTS_REQ_GAMELAN): gamelan.sty gamelan.sty: $(top_builddir)/src/gamelan/gamelan.sty cp $< $@ $(top_builddir)/src/gamelan/gamelan.sty: $(MAKE) -C $(top_builddir)/src/gamelan gamelan.sty endif BUILT_SOURCES = \ TESTFLAG \ HEPMC2_FLAG \ HEPMC3_FLAG \ LCIO_FLAG \ FASTJET_FLAG \ LHAPDF5_FLAG \ LHAPDF6_FLAG \ GAMELAN_FLAG \ EVENT_ANALYSIS_FLAG \ OCAML_FLAG \ PYTHON_FLAG \ PYTHIA6_FLAG \ OPENLOOPS_FLAG \ GOSAM_FLAG \ STATIC_FLAG \ ref-output # If this file is found in the working directory, WHIZARD # will use the paths for the uninstalled version (source/build tree), # otherwise it uses the installed version TESTFLAG: touch $@ FASTJET_FLAG: if FASTJET_AVAILABLE touch $@ endif HEPMC2_FLAG: if HEPMC2_AVAILABLE touch $@ endif HEPMC3_FLAG: if HEPMC3_AVAILABLE touch $@ endif LCIO_FLAG: if LCIO_AVAILABLE touch $@ endif LHAPDF5_FLAG: if LHAPDF5_AVAILABLE touch $@ endif LHAPDF6_FLAG: if LHAPDF6_AVAILABLE touch $@ endif GAMELAN_FLAG: if MPOST_AVAILABLE touch $@ endif OCAML_FLAG: if OCAML_AVAILABLE touch $@ endif PYTHON_FLAG: if PYTHON_AVAILABLE touch $@ endif PYTHIA6_FLAG: if PYTHIA6_AVAILABLE touch $@ endif OPENLOOPS_FLAG: if OPENLOOPS_AVAILABLE touch $@ endif GOSAM_FLAG: if GOSAM_AVAILABLE touch $@ endif EVENT_ANALYSIS_FLAG: if EVENT_ANALYSIS_AVAILABLE touch $@ endif STATIC_FLAG: if STATIC_AVAILABLE touch $@ endif # The reference output files are in the source directory. Copy them here. ref-output: $(top_srcdir)/share/tests/ext_tests_nlo/ref-output mkdir -p ref-output for f in $ - -void c_whizard_process_string(void *w_instance, const char *cmds); -void c_whizard_finalize(void *w_instance); - -void c_whizard_model(void *w_instance, const char *model); -void c_whizard_process(void *w_instance, const char *process, const char *in, const char *out); -void c_whizard_compile(void *w_instance); -void c_whizard_beams(void *w_instance, const char *specs); -void c_whizard_integrate(void *w_instance, const char *process); -void c_whizard_matrix_element_test(void *w_instance, const char *process); -void c_whizard_simulate(void *w_instance, const char *process); -void c_whizard_sqrts(void *w_instance, const int *val, const char *unit); -void *w_instance; - -static PyObject * - -pywhizard_process_string(PyObject *self, PyObject *args) -{ - const char *cmds; - if (!PyArg_ParseTuple(args, "s", &cmds)) - return NULL; - c_whizard_process_string(&w_instance, cmds); - return Py_BuildValue("i", 0); -} - -pywhizard_finalize(PyObject *self, PyObject *args) -{ - c_whizard_finalize(&w_instance); - return Py_BuildValue("i", 0); -} - -pywhizard_model(PyObject *self, PyObject *args) -{ - const char *model; - if (!PyArg_ParseTuple(args, "s", &model)) - return NULL; - c_whizard_model(&w_instance, model); - return Py_BuildValue("i", 0); -} - -pywhizard_process(PyObject *self, PyObject *args) -{ - const char *process; - const char *in; - const char *out; - if (!PyArg_ParseTuple(args, "sss", &process, &in, &out)) - return NULL; - c_whizard_process(&w_instance, process, in, out); - return Py_BuildValue("i", 0); -} - -pywhizard_compile(PyObject *self, PyObject *args) -{ - c_whizard_compile(&w_instance); - return Py_BuildValue("i", 0); -} - -pywhizard_beams(PyObject *self, PyObject *args) -{ - const char *specs; - if (!PyArg_ParseTuple(args, "s", &specs)) - return NULL; - c_whizard_beams(&w_instance, specs); - return Py_BuildValue("i", 0); -} - -pywhizard_integrate(PyObject *self, PyObject *args) -{ - const char *process; - if (!PyArg_ParseTuple(args, "s", &process)) - return NULL; - c_whizard_integrate(&w_instance, process); - return Py_BuildValue("i", 0); -} - -pywhizard_matrix_element_test(PyObject *self, PyObject *args) -{ - const char *process; - if (!PyArg_ParseTuple(args, "s", &process)) - return NULL; - c_whizard_matrix_element_test(&w_instance, process); - return Py_BuildValue("i", 0); -} - -pywhizard_simulate(PyObject *self, PyObject *args) -{ - const char *process; - if (!PyArg_ParseTuple(args, "s", &process)) - return NULL; - c_whizard_simulate(&w_instance, process); - return Py_BuildValue("i", 0); -} - -pywhizard_sqrts(PyObject *self, PyObject *args) -{ - const char *unit; - const int *val; - if (!PyArg_ParseTuple(args, "is", &val, &unit)) - return NULL; - c_whizard_sqrts(&w_instance, &val, unit); - return Py_BuildValue("i", 0); -} - -static PyMethodDef WhizardMethods[] = { - {"process_string", pywhizard_process_string, METH_VARARGS, "Executes a given Sindarin command."}, - {"finalize", pywhizard_finalize, METH_VARARGS, "Finalize the PyWhizard session."}, - {"model", pywhizard_model, METH_VARARGS, "Changes to given model."}, - {"process", pywhizard_process, METH_VARARGS, "Defines a new process."}, - {"compile", pywhizard_compile, METH_VARARGS, "Compiles the current process to a shared library."}, - {"beams", pywhizard_beams, METH_VARARGS, "Sets up the beams parameters."}, - {"integrate", pywhizard_integrate, METH_VARARGS, "Integrates a process."}, - {"matrix_element_test", pywhizard_matrix_element_test, METH_VARARGS, "Tests the matrix elements of a process."}, - {"simulate", pywhizard_simulate, METH_VARARGS, "Simulates a process."}, - {"sqrts", pywhizard_sqrts, METH_VARARGS, "Sets the com energy for the collisions."}, - {NULL, NULL, NULL, NULL} -}; - -PyMODINIT_FUNC -initpywhizard(void) -{ - (void) Py_InitModule("pywhizard", WhizardMethods); - c_whizard_init(&w_instance); -} - -int main(int argc, char *argv[]) -{ - Py_SetProgramName(argv[0]); - Py_Initialize; - initpywhizard(); -} Index: trunk/share/interfaces/c_test.c =================================================================== --- trunk/share/interfaces/c_test.c (revision 8428) +++ trunk/share/interfaces/c_test.c (revision 8429) @@ -1,15 +0,0 @@ -#include "c_test.h" - -int main() -{ void *w_instance; - int sqrt = 360; - c_whizard_init (&w_instance); - c_whizard_model (&w_instance, "MSSM"); - c_whizard_process (&w_instance, "EEScatC", "e1, E1", "e1, E1"); - c_whizard_sqrts (&w_instance, &sqrt, "GeV"); - c_whizard_process_string (&w_instance, "n_events = 1"); - c_whizard_process_string (&w_instance, "sample_format = lhef"); - c_whizard_simulate (&w_instance, "EEScatC"); - c_whizard_finalize (&w_instance); - return 0; -} Index: trunk/share/interfaces/cpp_test.cc =================================================================== --- trunk/share/interfaces/cpp_test.cc (revision 8428) +++ trunk/share/interfaces/cpp_test.cc (revision 8429) @@ -1,25 +0,0 @@ -#include -#include "cpp_whizard.h" -// #include "HepMC/GenEvent.h" - -int main() -{ - // HepMC::GenEvent* cur_evt = new HepMC::GenEvent(); - - Whizard* whizard = new Whizard (); - - char str_model[] = "MSSM"; - whizard->model (str_model); - char str_proc[] = "EEScatCPP"; - char str_in[] = "e1, e1"; - char str_out[] = "e1, e1"; - whizard->process (str_proc, str_in, str_out); - char str_sqrts[] = "sqrts = 360 GeV"; - whizard->process_string (str_sqrts); - - // cur_evt = whizard.hepmc_test (str_proc,1,1); - // cur_evt->print(); - - // delete cur_evt; - return 0; -} Index: trunk/share/interfaces/py_whiz_setup.py.in =================================================================== --- trunk/share/interfaces/py_whiz_setup.py.in (revision 8428) +++ trunk/share/interfaces/py_whiz_setup.py.in (revision 8429) @@ -1,12 +0,0 @@ -from distutils.core import setup, Extension - -pywhizard = Extension('pywhizard', - extra_objects = ['@BUILDDIR@/src/.libs/libwhizard.@SHRLIB_EXT@', '@BUILDDIR@/src/prebuilt/.libs/libwhizard_prebuilt.@SHRLIB_EXT@'], - libraries = ['whizard', 'whizard_prebuilt'], - library_dirs = ['@BUILDDIR@/src/.libs','@BUILDDIR@/src/prebuilt/.libs'], - sources = ['py_whizard.c']) - -setup (name = 'pywhizard', - version = '0.02', - description = 'This is the PyWhizard package.', - ext_modules = [pywhizard]) Index: trunk/share/interfaces/test.py =================================================================== --- trunk/share/interfaces/test.py (revision 8428) +++ trunk/share/interfaces/test.py (revision 8429) @@ -1,11 +0,0 @@ -import pywhizard - -pywhizard.model("MSSM") -pywhizard.process("EEScatPy", "e1, E1", "e1, E1") -pywhizard.sqrts(360, "GeV") -pywhizard.process_string("n_events = 1") -pywhizard.process_string("sample_format = lhef") -pywhizard.integrate("EEScatPy") -pywhizard.sqrts(520, "GeV") -pywhizard.integrate("EEScatPy") -pywhizard.finalize() Index: trunk/share/interfaces/c_test.h =================================================================== --- trunk/share/interfaces/c_test.h (revision 8428) +++ trunk/share/interfaces/c_test.h (revision 8429) @@ -1,8 +0,0 @@ -void c_whizard_init(void *w_instance); -void c_whizard_model(void *w_instance, char *id); -void c_whizard_process(void *w_instance, char *id, char *in, char *out); -void c_whizard_process_string(void *w_instance, char *str); -void c_whizard_sqrts(void *w_instance, int *sqrts, char *str); -void c_whizard_simulate(void *w_instance, char *str); -void c_whizard_finalize(void *w_instance); - Index: trunk/share/interfaces/Makefile.am =================================================================== --- trunk/share/interfaces/Makefile.am (revision 8428) +++ trunk/share/interfaces/Makefile.am (revision 8429) @@ -1,85 +0,0 @@ -## Makefile.am -- Makefile for WHIZARD API -## -## Process this file with automake to produce Makefile.in -## -######################################################################## -# -# Copyright (C) 1999-2020 by -# Wolfgang Kilian -# Thorsten Ohl -# Juergen Reuter -# with contributions from -# cf. main AUTHORS file -# -# WHIZARD is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# WHIZARD is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -######################################################################## - -noinst_PROGRAMS = c_example cpp_example - -c_example_SOURCES = c_test.c c_test.h -c_example_LDADD = $(top_builddir)/src/libwhizard.la -c_example_LDADD += $(top_builddir)/src/prebuilt/libwhizard_prebuilt.la -c_example_LDADD += $(CXXLIBS) -c_example_LDADD += $(RPC_CFLAGS) -c_example_LDADD += $(LDFLAGS_LHAPDF) -c_example_LDADD += $(LDFLAGS_STDHEP) -c_example_LDADD += $(LDFLAGS_HEPMC) -c_example_LDADD += $(LDFLAGS_LCIO) -c_example_LDADD += $(LDFLAGS_HOPPET) -c_example_LDADD += $(LDFLAGS_LOOPTOOLS) -c_example_LDADD += $(FCLIBS) - -cpp_example_SOURCES = cpp_whizard.cc cpp_test.cc cpp_whizard.h -cpp_example_LDADD = $(top_builddir)/src/libwhizard.la -cpp_example_LDADD += $(top_builddir)/src/prebuilt/libwhizard_prebuilt.la -cpp_example_LDADD += $(CXXLIBS) -cpp_example_LDADD += $(RPC_CFLAGS) -cpp_example_LDADD += $(LDFLAGS_LHAPDF) -cpp_example_LDADD += $(LDFLAGS_STDHEP) -cpp_example_LDADD += $(LDFLAGS_HEPMC) -cpp_example_LDADD += $(LDFLAGS_LCIO) -cpp_example_LDADD += $(LDFLAGS_HOPPET) -cpp_example_LDADD += $(LDFLAGS_LOOPTOOLS) -cpp_example_LDADD += $(FCLIBS) - -SUFFIXES: .c .cc .py - -python: py_whizard_copy - $(PYTHON_BIN) py_whiz_setup.py build_ext --inplace - -PYTHON_FROM_SRC = py_whizard.c test.py - -py_whizard_copy: $(top_srcdir)/share/interfaces/py_whizard.c - -if test "$(srcdir)" != "."; then \ - for file in $(PYTHON_FROM_SRC); do \ - test -f "$$file" || cp $(srcdir)/$$file .; \ - done; \ - fi - -## Remove files -clean-local: - -rm -f eescat* - -rm -f EEScat* - -rm -f processes.* - -rm -f *.log c_example - -rm -f default_lib* - -rm -f opr_* - -rm -rf build - -rm -f py_whizard.c - -## Remove backup files -maintainer-clean-local: - -rm -f *~ Index: trunk/share/interfaces/cpp_whizard.cc =================================================================== --- trunk/share/interfaces/cpp_whizard.cc (revision 8428) +++ trunk/share/interfaces/cpp_whizard.cc (revision 8429) @@ -1,33 +0,0 @@ -#include -#include "cpp_whizard.h" -// #include "HepMC/GenEvent.h" - - -extern "C" { - void c_whizard_init(void *w_instance); - void c_whizard_model(void *w_instance, char *id); - void c_whizard_process(void *w_instance, char *id, char *in, char *out); - void c_whizard_process_string(void *w_instance, char *str); - // HepMC::GenEvent** c_whizard_hepmc_test(void *w_instance, char *id, int proc_id, int event_id); - void c_whizard_finalize(void *w_instance); -} - -Whizard::Whizard() { - std::cout << "initializing\n"; - c_whizard_init( &w_instance ); -} -Whizard::~Whizard() { - c_whizard_finalize( &w_instance ); -} -void Whizard::model( char *id ) { - c_whizard_model( &w_instance, id ); -} -void Whizard::process( char *id, char *in, char *out ) { - c_whizard_process( &w_instance, id, in, out ); -} -void Whizard::process_string( char *str ) { - c_whizard_process_string( &w_instance, str ); -} - -// HepMC::GenEvent* c_whizard::hepmc_test(void *whizard_instance, char *id, int proc_id, int event_id){ -// return *c_whizard_hepmc_test(whizard_instance, id, proc_id, event_id);} Index: trunk/share/Makefile.am =================================================================== --- trunk/share/Makefile.am (revision 8428) +++ trunk/share/Makefile.am (revision 8429) @@ -1,181 +1,183 @@ ## Makefile.am -- Makefile for WHIZARD data files ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## Subdirectories to configure SUBDIRS = \ doc \ susy \ models \ cuts \ beam-sim \ tests \ examples \ muli \ - interfaces \ SM_tt_threshold_data \ gui ## Data files needed for running WHIZARD ## to be installed with the 'models' prefix kept modelsdir = $(pkgdatadir)/models dist_models_DATA = \ models/THDM.mdl \ models/THDM_CKM.mdl \ models/AltH.mdl \ models/GravTest.mdl \ models/HSExt.mdl \ models/Littlest_Eta.mdl \ models/Littlest_Tpar.mdl \ models/Littlest.mdl \ models/MSSM.mdl \ models/MSSM_CKM.mdl \ models/MSSM_Grav.mdl \ models/MSSM_Hgg.mdl \ models/NMSSM.mdl \ models/NMSSM_CKM.mdl \ models/NMSSM_Hgg.mdl \ models/NoH_rx.mdl \ models/PSSSM.mdl \ models/QCD.mdl \ models/QED.mdl \ models/Simplest.mdl \ models/Simplest_univ.mdl \ models/SM_ac_CKM.mdl \ models/SM_ac.mdl \ models/SM_dim6.mdl \ models/SM_CKM.mdl \ models/SM_rx.mdl \ models/SM_ul.mdl \ models/SM_top.mdl \ models/SM_top_anom.mdl \ models/SM_tt_threshold.mdl \ models/SM.mdl \ models/SM_Higgs.mdl \ models/SM_Higgs_CKM.mdl \ models/SM_hadrons.mdl \ models/SSC.mdl \ models/SSC_2.mdl \ models/SSC_AltT.mdl \ models/Template.mdl \ models/UED.mdl \ models/WZW.mdl \ models/Xdim.mdl \ models/Zprime.mdl \ models/Threeshl.mdl \ models/Threeshl_nohf.mdl \ models/Test.mdl \ models/Test_schemes.mdl ## SLHA parameter input files ## to be installed with the 'susy' prefix kept susydir = $(pkgdatadir)/susy dist_susy_DATA = \ susy/sps1a.slha \ susy/sps1ap_decays.slha \ susy/nmssm.slha ## Files containing predefined cut sets ## to be installed with the 'cuts' prefix kept cutsdir = $(pkgdatadir)/cuts dist_cuts_DATA = \ cuts/default_cuts.sin ## Files containing predefined beam simulation files ## to be installed with the 'beam-sim' prefix kept beamsimdir = $(pkgdatadir)/beam-sim dist_beamsim_DATA = \ beam-sim/uniform_spread_2.5%.dat ## Files containing complete examples examplesdir = $(pkgdatadir)/examples dist_examples_DATA = \ examples/Z-lineshape.sin \ examples/W-endpoint.sin \ examples/casc_dec.sin \ examples/Zprime.sin \ examples/LEP_higgs.sin \ examples/LEP_cc10.sin \ examples/eeww_polarized.sin \ examples/circe1.sin \ examples/HERA_DIS.sin \ examples/NLO_eettbar_GoSam.sin \ examples/NLO_eettbar_OpenLoops.sin \ examples/NLO_NLL_matched.sin \ examples/LHC_VBS_likesign.sin \ + examples/manual_api_example.c \ + examples/manual_api_example.cc \ + examples/manual_api_example.f90 \ examples/DrellYanMatchingP.sin \ examples/DrellYanMatchingW.sin \ examples/DrellYanNoMatchingP.sin \ examples/DrellYanNoMatchingW.sin \ examples/EEMatching2P.sin \ examples/EEMatching2W.sin \ examples/EEMatching3P.sin \ examples/EEMatching3W.sin \ examples/EEMatching4P.sin \ examples/EEMatching4W.sin \ examples/EEMatching5P.sin \ examples/EEMatching5W.sin \ examples/EENoMatchingP.sin \ examples/EENoMatchingW.sin ## The data files for the included PDF sets pdfdir = $(pkgdatadir)/pdf_builtin dist_pdf_DATA = \ pdf_builtin/cteq6l.tbl \ pdf_builtin/cteq6l1.tbl \ pdf_builtin/cteq6m.tbl \ pdf_builtin/cteq6d.tbl \ pdf_builtin/qed6-10gridp.dat \ pdf_builtin/qed6-10gridn.dat \ pdf_builtin/mstw2008lo.00.dat \ pdf_builtin/mstw2008nlo.00.dat \ pdf_builtin/mstw2008nnlo.00.dat \ pdf_builtin/ct10.00.pds \ pdf_builtin/CJ12_max_00.tbl \ pdf_builtin/CJ12_mid_00.tbl \ pdf_builtin/CJ12_min_00.tbl \ pdf_builtin/CJ15LO_00.tbl \ pdf_builtin/CJ15NLO_00.tbl \ pdf_builtin/mmht2014lo.00.dat \ pdf_builtin/mmht2014nlo.00.dat \ pdf_builtin/mmht2014nnlo.00.dat \ pdf_builtin/CT14llo.pds \ pdf_builtin/CT14lo.pds \ pdf_builtin/CT14n.00.pds \ pdf_builtin/CT14nn.00.pds ## Files containing precompiled cross sections for muli ## to be installed with the 'muli' prefix kept mulidir = $(pkgdatadir)/muli dist_muli_DATA = \ muli/dsigma_cteq6ll.LHpdf.xml \ muli/pdf_norm_cteq6ll.LHpdf.xml thresholddir = $(pkgdatadir)/SM_tt_threshold_data dist_threshold_DATA = \ SM_tt_threshold_data/download_data.sh \ SM_tt_threshold_data/threshold_virtual.f90 \ SM_tt_threshold_data/threshold.f90 Index: trunk/share/examples/manual_api_example.f90 =================================================================== --- trunk/share/examples/manual_api_example.f90 (revision 0) +++ trunk/share/examples/manual_api_example.f90 (revision 8429) @@ -0,0 +1,92 @@ +! Example Fortran code for calling WHIZARD via the Fortran API +! For detailed explanations, cf. the WHIZARD manual +! +! ######################################################################## +! # +! # Copyright (C) 1999-2020 by +! # Wolfgang Kilian +! # Thorsten Ohl +! # Juergen Reuter +! # with contributions from +! # cf. main AUTHORS file +! # +! # WHIZARD is free software; you can redistribute it and/or modify it +! # under the terms of the GNU General Public License as published by +! # the Free Software Foundation; either version 2, or (at your option) +! # any later version. +! # +! # WHIZARD is distributed in the hope that it will be useful, but +! # WITHOUT ANY WARRANTY; without even the implied warranty of +! # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +! # GNU General Public License for more details. +! # +! # You should have received a copy of the GNU General Public License +! # along with this program; if not, write to the Free Software +! # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +! # +! ######################################################################## + +program main + + ! WHIZARD API as a module + use api + + ! Standard numeric types + use iso_fortran_env, only: real64, int32 + + implicit none + + ! WHIZARD and event-sample objects + type(whizard_api_t) :: whizard + type(simulation_api_t) :: sample + + ! Local variables + real(real64) :: integral, error + real(real64) :: sqme, weight + integer(int32) :: idx + integer(int32) :: i, it_begin, it_end + + ! Initialize WHIZARD, setting some global option + call whizard%option ("model", "QED") + call whizard%init () + + ! Define a process, set some variables + call whizard%command ("process mupair = e1, E1 => e2, E2") + call whizard%set_var ("sqrts", 100._real64) + call whizard%set_var ("seed", 0) + + ! Integrate and retrieve result + call whizard%command ("integrate (mupair)") + call whizard%get_integration_result ("mupair", integral, error) + + ! Print result + print 1, "cross section =", integral / 1000, "pb" + print 1, "error =", error / 1000, "pb" +1 format (2x,A,1x,F5.1,1x,A) +2 format (2x,A,1x,L1) + + ! Settings for event generation + call whizard%set_var ("$sample", "mupair_events") + call whizard%set_var ("n_events", 2) + + ! Create an event-sample object and generate events + call whizard%new_sample ("mupair", sample) + call sample%open (it_begin, it_end) + do i = it_begin, it_end + call sample%next_event () + call sample%get_event_index (idx) + call sample%get_weight (weight) + call sample%get_sqme (sqme) + print "(A,I0)", "Event #", idx + print 3, "sqme =", sqme + print 3, "weight =", weight +3 format (2x,A,1x,ES10.3) + end do + + ! Finalize the event-sample object + call sample%close () + + ! Finalize the WHIZARD object + call whizard%final () + +end program main Index: trunk/share/examples/manual_api_example.cc =================================================================== --- trunk/share/examples/manual_api_example.cc (revision 0) +++ trunk/share/examples/manual_api_example.cc (revision 8429) @@ -0,0 +1,86 @@ +// Example C++ code for calling WHIZARD via the C++ API +// For detailed explanations, cf. the WHIZARD manual +// +// ######################################################################## +// # +// # Copyright (C) 1999-2020 by +// # Wolfgang Kilian +// # Thorsten Ohl +// # Juergen Reuter +// # with contributions from +// # cf. main AUTHORS file +// # +// # WHIZARD is free software; you can redistribute it and/or modify it +// # under the terms of the GNU General Public License as published by +// # the Free Software Foundation; either version 2, or (at your option) +// # any later version. +// # +// # WHIZARD is distributed in the hope that it will be useful, but +// # WITHOUT ANY WARRANTY; without even the implied warranty of +// # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// # GNU General Public License for more details. +// # +// # You should have received a copy of the GNU General Public License +// # along with this program; if not, write to the Free Software +// # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// # +// ######################################################################## + +#include +#include +#include "whizard.h" + +int main( int argc, char* argv[] ) +{ + // WHIZARD and event-sample objects + Whizard* whizard; + WhizardSample* sample; + + // Local variables + double integral, error; + double sqme, weight; + int idx; + int it, it_begin, it_end; + + // Initialize WHIZARD, setting some global option + whizard = new Whizard(); + whizard->option( "model", "QED" ); + whizard->init(); + + // Define a process, set some variables + whizard->command( "process mupair = e1, E1 => e2, E2" ); + whizard->set_double( "sqrts", 10. ); + whizard->set_int( "seed", 0 ); + + // Generate matrix-element code, integrate and retrieve result + whizard->command( "integrate (mupair)" ); + + // Print result + whizard->get_integration_result( "mupair", &integral, &error ); + printf( " cross section = %5.1f pb\n", integral / 1000. ); + printf( " error = %5.1f pb\n", error / 1000. ); + + // Settings for event generation + whizard->set_string( "$sample", "mupair_events" ); + whizard->set_int( "n_events", 2 ); + + // Create an event-sample object and generate events + sample = whizard->new_sample( "mupair" ); + sample->open( &it_begin, &it_end ); + for (it=it_begin; it<=it_end; it++) { + sample->next_event(); + idx = sample->get_event_index(); + weight = sample->get_weight(); + sqme = sample->get_sqme(); + printf( "Event #%d\n", idx ); + printf( " sqme = %10.3e\n", sqme ); + printf( " weight = %10.3e\n", weight ); + } + + // Finalize the event-sample object + sample->close(); + delete sample; + + // Finalize the WHIZARD object + delete whizard; +} Index: trunk/share/examples/manual_api_example.c =================================================================== --- trunk/share/examples/manual_api_example.c (revision 0) +++ trunk/share/examples/manual_api_example.c (revision 8429) @@ -0,0 +1,85 @@ +/* Example C code for calling WHIZARD via the C API */ +/* For detailed explanations, cf. the WHIZARD manual */ +/* +######################################################################## +# +# Copyright (C) 1999-2020 by +# Wolfgang Kilian +# Thorsten Ohl +# Juergen Reuter +# with contributions from +# cf. main AUTHORS file +# +# WHIZARD is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# WHIZARD is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +######################################################################## +*/ + +#include +#include "whizard.h" + +int main( int argc, char* argv[] ) +{ + /* WHIZARD and event-sample objects */ + void* wh; + void* sample; + + /* Local variables */ + double integral, error; + double sqme, weight; + int idx; + int it, it_begin, it_end; + + /* Initialize WHIZARD, setting some global option */ + whizard_create( &wh ); + whizard_option( &wh, "model", "QED" ); + whizard_init( &wh ); + + /* Define a process, set some variables */ + whizard_command( &wh, "process mupair = e1, E1 => e2, E2" ); + whizard_set_double( &wh, "sqrts", 10. ); + whizard_set_int( &wh, "seed", 0 ); + + /* Generate matrix-element code, integrate and retrieve result */ + whizard_command( &wh, "integrate (mupair)" ); + + /* Print result */ + whizard_get_integration_result( &wh, "mupair", &integral, &error); + printf( " cross section = %5.1f pb\n", integral / 1000. ); + printf( " error = %5.1f pb\n", error / 1000. ); + + /* Settings for event generation */ + whizard_set_char( &wh, "$sample", "mupair_events" ); + whizard_set_int( &wh, "n_events", 2 ); + + /* Create an event-sample object and generate events */ + whizard_new_sample( &wh, "mupair", &sample ); + whizard_sample_open( &sample, &it_begin, &it_end ); + for (it=it_begin; it<=it_end; it++) { + whizard_sample_next_event( &sample ); + whizard_sample_get_event_index( &sample, &idx ); + whizard_sample_get_weight( &sample, &weight ); + whizard_sample_get_sqme( &sample, &sqme ); + printf( "Event #%d\n", idx ); + printf( " sqme = %10.3e\n", sqme ); + printf( " weight = %10.3e\n", weight ); + } + + /* Finalize the event-sample object */ + whizard_sample_close( &sample ); + + /* Finalize the WHIZARD object */ + whizard_final( &wh ); +} Index: trunk/share/tests/Makefile.am =================================================================== --- trunk/share/tests/Makefile.am (revision 8428) +++ trunk/share/tests/Makefile.am (revision 8429) @@ -1,1519 +1,1541 @@ ## Makefile.am -- Makefile for WHIZARD tests ## ## Process this file with automake to produce Makefile.in ## ######################################################################## # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## EXTRA_DIST = \ $(TESTSUITE_MACROS) $(TESTSUITES_M4) $(TESTSUITES_SIN) \ $(TESTSUITE_TOOLS) \ $(REF_OUTPUT_FILES) \ cascades2_1.fds \ cascades2_2.fds \ cascades2_lexer_1.fds \ ext_tests_nmssm/nmssm.slha \ functional_tests/structure_2_inc.sin functional_tests/testproc_3.phs \ functional_tests/susyhit.in \ functional_tests/ufo_5_test.slha TESTSUITE_MACROS = testsuite.m4 TESTSUITE_TOOLS = \ check-debug-output-hadro.py \ check-debug-output.py \ check-hepmc-weights.py \ compare-histograms.py \ compare-integrals-multi.py \ compare-integrals.py \ compare-methods.py REF_OUTPUT_FILES = \ extra_integration_results.dat \ $(REF_OUTPUT_FILES_BASE) $(REF_OUTPUT_FILES_DOUBLE) \ $(REF_OUTPUT_FILES_PREC) $(REF_OUTPUT_FILES_EXT) \ $(REF_OUTPUT_FILES_QUAD) REF_OUTPUT_FILES_BASE = \ unit_tests/ref-output/analysis_1.ref \ + unit_tests/ref-output/api_1.ref \ + unit_tests/ref-output/api_2.ref \ + unit_tests/ref-output/api_3.ref \ + unit_tests/ref-output/api_4.ref \ + unit_tests/ref-output/api_5.ref \ + unit_tests/ref-output/api_6.ref \ + unit_tests/ref-output/api_7.ref \ + unit_tests/ref-output/api_8.ref \ + unit_tests/ref-output/api_c_1.ref \ + unit_tests/ref-output/api_c_2.ref \ + unit_tests/ref-output/api_c_3.ref \ + unit_tests/ref-output/api_c_4.ref \ + unit_tests/ref-output/api_c_5.ref \ + unit_tests/ref-output/api_cc_1.ref \ + unit_tests/ref-output/api_cc_2.ref \ + unit_tests/ref-output/api_cc_3.ref \ + unit_tests/ref-output/api_cc_4.ref \ + unit_tests/ref-output/api_cc_5.ref \ + unit_tests/ref-output/api_hepmc3_1.ref \ + unit_tests/ref-output/api_hepmc3_cc_1.ref \ + unit_tests/ref-output/api_lcio_1.ref \ + unit_tests/ref-output/api_lcio_cc_1.ref \ unit_tests/ref-output/auto_components_1.ref \ unit_tests/ref-output/auto_components_2.ref \ unit_tests/ref-output/auto_components_3.ref \ unit_tests/ref-output/beam_1.ref \ unit_tests/ref-output/beam_2.ref \ unit_tests/ref-output/beam_3.ref \ unit_tests/ref-output/beam_structures_1.ref \ unit_tests/ref-output/beam_structures_2.ref \ unit_tests/ref-output/beam_structures_3.ref \ unit_tests/ref-output/beam_structures_4.ref \ unit_tests/ref-output/beam_structures_5.ref \ unit_tests/ref-output/beam_structures_6.ref \ unit_tests/ref-output/blha_1.ref \ unit_tests/ref-output/blha_2.ref \ unit_tests/ref-output/blha_3.ref \ unit_tests/ref-output/bloch_vectors_1.ref \ unit_tests/ref-output/bloch_vectors_2.ref \ unit_tests/ref-output/bloch_vectors_3.ref \ unit_tests/ref-output/bloch_vectors_4.ref \ unit_tests/ref-output/bloch_vectors_5.ref \ unit_tests/ref-output/bloch_vectors_6.ref \ unit_tests/ref-output/bloch_vectors_7.ref \ unit_tests/ref-output/cascades2_1.ref \ unit_tests/ref-output/cascades2_2.ref \ unit_tests/ref-output/cascades2_lexer_1.ref \ unit_tests/ref-output/cascades_1.ref \ unit_tests/ref-output/cascades_2.ref \ unit_tests/ref-output/color_1.ref \ unit_tests/ref-output/color_2.ref \ unit_tests/ref-output/commands_1.ref \ unit_tests/ref-output/commands_2.ref \ unit_tests/ref-output/commands_3.ref \ unit_tests/ref-output/commands_4.ref \ unit_tests/ref-output/commands_5.ref \ unit_tests/ref-output/commands_6.ref \ unit_tests/ref-output/commands_7.ref \ unit_tests/ref-output/commands_8.ref \ unit_tests/ref-output/commands_9.ref \ unit_tests/ref-output/commands_10.ref \ unit_tests/ref-output/commands_11.ref \ unit_tests/ref-output/commands_12.ref \ unit_tests/ref-output/commands_13.ref \ unit_tests/ref-output/commands_14.ref \ unit_tests/ref-output/commands_15.ref \ unit_tests/ref-output/commands_16.ref \ unit_tests/ref-output/commands_17.ref \ unit_tests/ref-output/commands_18.ref \ unit_tests/ref-output/commands_19.ref \ unit_tests/ref-output/commands_20.ref \ unit_tests/ref-output/commands_21.ref \ unit_tests/ref-output/commands_22.ref \ unit_tests/ref-output/commands_23.ref \ unit_tests/ref-output/commands_24.ref \ unit_tests/ref-output/commands_25.ref \ unit_tests/ref-output/commands_26.ref \ unit_tests/ref-output/commands_27.ref \ unit_tests/ref-output/commands_28.ref \ unit_tests/ref-output/commands_29.ref \ unit_tests/ref-output/commands_30.ref \ unit_tests/ref-output/commands_31.ref \ unit_tests/ref-output/commands_32.ref \ unit_tests/ref-output/commands_33.ref \ unit_tests/ref-output/commands_34.ref \ unit_tests/ref-output/compilations_1.ref \ unit_tests/ref-output/compilations_2.ref \ unit_tests/ref-output/compilations_3.ref \ unit_tests/ref-output/compilations_static_1.ref \ unit_tests/ref-output/compilations_static_2.ref \ unit_tests/ref-output/cputime_1.ref \ unit_tests/ref-output/cputime_2.ref \ unit_tests/ref-output/decays_1.ref \ unit_tests/ref-output/decays_2.ref \ unit_tests/ref-output/decays_3.ref \ unit_tests/ref-output/decays_4.ref \ unit_tests/ref-output/decays_5.ref \ unit_tests/ref-output/decays_6.ref \ unit_tests/ref-output/dispatch_1.ref \ unit_tests/ref-output/dispatch_2.ref \ unit_tests/ref-output/dispatch_7.ref \ unit_tests/ref-output/dispatch_8.ref \ unit_tests/ref-output/dispatch_10.ref \ unit_tests/ref-output/dispatch_11.ref \ unit_tests/ref-output/dispatch_mci_1.ref \ unit_tests/ref-output/dispatch_phs_1.ref \ unit_tests/ref-output/dispatch_phs_2.ref \ unit_tests/ref-output/dispatch_rng_1.ref \ unit_tests/ref-output/dispatch_transforms_1.ref \ unit_tests/ref-output/dispatch_transforms_2.ref \ unit_tests/ref-output/eio_ascii_1.ref \ unit_tests/ref-output/eio_ascii_2.ref \ unit_tests/ref-output/eio_ascii_3.ref \ unit_tests/ref-output/eio_ascii_4.ref \ unit_tests/ref-output/eio_ascii_5.ref \ unit_tests/ref-output/eio_ascii_6.ref \ unit_tests/ref-output/eio_ascii_7.ref \ unit_tests/ref-output/eio_ascii_8.ref \ unit_tests/ref-output/eio_ascii_9.ref \ unit_tests/ref-output/eio_ascii_10.ref \ unit_tests/ref-output/eio_ascii_11.ref \ unit_tests/ref-output/eio_base_1.ref \ unit_tests/ref-output/eio_checkpoints_1.ref \ unit_tests/ref-output/eio_data_1.ref \ unit_tests/ref-output/eio_data_2.ref \ unit_tests/ref-output/eio_direct_1.ref \ unit_tests/ref-output/eio_dump_1.ref \ unit_tests/ref-output/eio_hepmc2_1.ref \ unit_tests/ref-output/eio_hepmc2_2.ref \ unit_tests/ref-output/eio_hepmc2_3.ref \ unit_tests/ref-output/eio_hepmc3_1.ref \ unit_tests/ref-output/eio_hepmc3_2.ref \ unit_tests/ref-output/eio_hepmc3_3.ref \ unit_tests/ref-output/eio_lcio_1.ref \ unit_tests/ref-output/eio_lcio_2.ref \ unit_tests/ref-output/eio_lhef_1.ref \ unit_tests/ref-output/eio_lhef_2.ref \ unit_tests/ref-output/eio_lhef_3.ref \ unit_tests/ref-output/eio_lhef_4.ref \ unit_tests/ref-output/eio_lhef_5.ref \ unit_tests/ref-output/eio_lhef_6.ref \ unit_tests/ref-output/eio_raw_1.ref \ unit_tests/ref-output/eio_raw_2.ref \ unit_tests/ref-output/eio_stdhep_1.ref \ unit_tests/ref-output/eio_stdhep_2.ref \ unit_tests/ref-output/eio_stdhep_3.ref \ unit_tests/ref-output/eio_stdhep_4.ref \ unit_tests/ref-output/eio_weights_1.ref \ unit_tests/ref-output/eio_weights_2.ref \ unit_tests/ref-output/eio_weights_3.ref \ unit_tests/ref-output/epa_handler_1.ref \ unit_tests/ref-output/epa_handler_2.ref \ unit_tests/ref-output/epa_handler_3.ref \ unit_tests/ref-output/evaluator_1.ref \ unit_tests/ref-output/evaluator_2.ref \ unit_tests/ref-output/evaluator_3.ref \ unit_tests/ref-output/evaluator_4.ref \ unit_tests/ref-output/event_streams_1.ref \ unit_tests/ref-output/event_streams_2.ref \ unit_tests/ref-output/event_streams_3.ref \ unit_tests/ref-output/event_streams_4.ref \ unit_tests/ref-output/event_transforms_1.ref \ unit_tests/ref-output/events_1.ref \ unit_tests/ref-output/events_2.ref \ unit_tests/ref-output/events_3.ref \ unit_tests/ref-output/events_4.ref \ unit_tests/ref-output/events_5.ref \ unit_tests/ref-output/events_6.ref \ unit_tests/ref-output/events_7.ref \ unit_tests/ref-output/expressions_1.ref \ unit_tests/ref-output/expressions_2.ref \ unit_tests/ref-output/expressions_3.ref \ unit_tests/ref-output/expressions_4.ref \ unit_tests/ref-output/fks_regions_1.ref \ unit_tests/ref-output/fks_regions_2.ref \ unit_tests/ref-output/fks_regions_3.ref \ unit_tests/ref-output/fks_regions_4.ref \ unit_tests/ref-output/fks_regions_5.ref \ unit_tests/ref-output/fks_regions_6.ref \ unit_tests/ref-output/fks_regions_7.ref \ unit_tests/ref-output/fks_regions_8.ref \ unit_tests/ref-output/format_1.ref \ unit_tests/ref-output/grids_1.ref \ unit_tests/ref-output/grids_2.ref \ unit_tests/ref-output/grids_3.ref \ unit_tests/ref-output/grids_4.ref \ unit_tests/ref-output/grids_5.ref \ unit_tests/ref-output/hep_events_1.ref \ unit_tests/ref-output/hepmc2_interface_1.ref \ unit_tests/ref-output/hepmc3_interface_1.ref \ unit_tests/ref-output/integration_results_1.ref \ unit_tests/ref-output/integration_results_2.ref \ unit_tests/ref-output/integration_results_3.ref \ unit_tests/ref-output/integration_results_4.ref \ unit_tests/ref-output/integration_results_5.ref \ unit_tests/ref-output/integrations_1.ref \ unit_tests/ref-output/integrations_2.ref \ unit_tests/ref-output/integrations_3.ref \ unit_tests/ref-output/integrations_4.ref \ unit_tests/ref-output/integrations_5.ref \ unit_tests/ref-output/integrations_6.ref \ unit_tests/ref-output/integrations_7.ref \ unit_tests/ref-output/integrations_8.ref \ unit_tests/ref-output/integrations_9.ref \ unit_tests/ref-output/integrations_history_1.ref \ unit_tests/ref-output/interaction_1.ref \ unit_tests/ref-output/isr_handler_1.ref \ unit_tests/ref-output/isr_handler_2.ref \ unit_tests/ref-output/isr_handler_3.ref \ unit_tests/ref-output/iterations_1.ref \ unit_tests/ref-output/iterations_2.ref \ unit_tests/ref-output/jets_1.ref \ unit_tests/ref-output/lcio_interface_1.ref \ unit_tests/ref-output/lexer_1.ref \ unit_tests/ref-output/mci_base_1.ref \ unit_tests/ref-output/mci_base_2.ref \ unit_tests/ref-output/mci_base_3.ref \ unit_tests/ref-output/mci_base_4.ref \ unit_tests/ref-output/mci_base_5.ref \ unit_tests/ref-output/mci_base_6.ref \ unit_tests/ref-output/mci_base_7.ref \ unit_tests/ref-output/mci_base_8.ref \ unit_tests/ref-output/mci_midpoint_1.ref \ unit_tests/ref-output/mci_midpoint_2.ref \ unit_tests/ref-output/mci_midpoint_3.ref \ unit_tests/ref-output/mci_midpoint_4.ref \ unit_tests/ref-output/mci_midpoint_5.ref \ unit_tests/ref-output/mci_midpoint_6.ref \ unit_tests/ref-output/mci_midpoint_7.ref \ unit_tests/ref-output/mci_none_1.ref \ unit_tests/ref-output/mci_vamp2_1.ref \ unit_tests/ref-output/mci_vamp2_2.ref \ unit_tests/ref-output/mci_vamp2_3.ref \ unit_tests/ref-output/mci_vamp_1.ref \ unit_tests/ref-output/mci_vamp_2.ref \ unit_tests/ref-output/mci_vamp_3.ref \ unit_tests/ref-output/mci_vamp_4.ref \ unit_tests/ref-output/mci_vamp_5.ref \ unit_tests/ref-output/mci_vamp_6.ref \ unit_tests/ref-output/mci_vamp_7.ref \ unit_tests/ref-output/mci_vamp_8.ref \ unit_tests/ref-output/mci_vamp_9.ref \ unit_tests/ref-output/mci_vamp_10.ref \ unit_tests/ref-output/mci_vamp_11.ref \ unit_tests/ref-output/mci_vamp_12.ref \ unit_tests/ref-output/mci_vamp_13.ref \ unit_tests/ref-output/mci_vamp_14.ref \ unit_tests/ref-output/mci_vamp_15.ref \ unit_tests/ref-output/mci_vamp_16.ref \ unit_tests/ref-output/md5_1.ref \ unit_tests/ref-output/models_1.ref \ unit_tests/ref-output/models_2.ref \ unit_tests/ref-output/models_3.ref \ unit_tests/ref-output/models_4.ref \ unit_tests/ref-output/models_5.ref \ unit_tests/ref-output/models_6.ref \ unit_tests/ref-output/models_7.ref \ unit_tests/ref-output/models_8.ref \ unit_tests/ref-output/models_9.ref \ unit_tests/ref-output/models_10.ref \ unit_tests/ref-output/os_interface_1.ref \ unit_tests/ref-output/parse_1.ref \ unit_tests/ref-output/particle_specifiers_1.ref \ unit_tests/ref-output/particle_specifiers_2.ref \ unit_tests/ref-output/particles_1.ref \ unit_tests/ref-output/particles_2.ref \ unit_tests/ref-output/particles_3.ref \ unit_tests/ref-output/particles_4.ref \ unit_tests/ref-output/particles_5.ref \ unit_tests/ref-output/particles_6.ref \ unit_tests/ref-output/particles_7.ref \ unit_tests/ref-output/particles_8.ref \ unit_tests/ref-output/particles_9.ref \ unit_tests/ref-output/parton_states_1.ref \ unit_tests/ref-output/pdg_arrays_1.ref \ unit_tests/ref-output/pdg_arrays_2.ref \ unit_tests/ref-output/pdg_arrays_3.ref \ unit_tests/ref-output/pdg_arrays_4.ref \ unit_tests/ref-output/pdg_arrays_5.ref \ unit_tests/ref-output/phs_base_1.ref \ unit_tests/ref-output/phs_base_2.ref \ unit_tests/ref-output/phs_base_3.ref \ unit_tests/ref-output/phs_base_4.ref \ unit_tests/ref-output/phs_base_5.ref \ unit_tests/ref-output/phs_fks_generator_1.ref \ unit_tests/ref-output/phs_fks_generator_2.ref \ unit_tests/ref-output/phs_fks_generator_3.ref \ unit_tests/ref-output/phs_fks_generator_4.ref \ unit_tests/ref-output/phs_fks_generator_5.ref \ unit_tests/ref-output/phs_fks_generator_6.ref \ unit_tests/ref-output/phs_fks_generator_7.ref \ unit_tests/ref-output/phs_forest_1.ref \ unit_tests/ref-output/phs_forest_2.ref \ unit_tests/ref-output/phs_none_1.ref \ unit_tests/ref-output/phs_rambo_1.ref \ unit_tests/ref-output/phs_rambo_2.ref \ unit_tests/ref-output/phs_rambo_3.ref \ unit_tests/ref-output/phs_rambo_4.ref \ unit_tests/ref-output/phs_single_1.ref \ unit_tests/ref-output/phs_single_2.ref \ unit_tests/ref-output/phs_single_3.ref \ unit_tests/ref-output/phs_single_4.ref \ unit_tests/ref-output/phs_tree_1.ref \ unit_tests/ref-output/phs_tree_2.ref \ unit_tests/ref-output/phs_wood_1.ref \ unit_tests/ref-output/phs_wood_2.ref \ unit_tests/ref-output/phs_wood_3.ref \ unit_tests/ref-output/phs_wood_4.ref \ unit_tests/ref-output/phs_wood_5.ref \ unit_tests/ref-output/phs_wood_6.ref \ unit_tests/ref-output/phs_wood_vis_1.ref \ unit_tests/ref-output/polarization_1.ref \ unit_tests/ref-output/polarization_2.ref \ unit_tests/ref-output/prc_omega_1.ref \ unit_tests/ref-output/prc_omega_2.ref \ unit_tests/ref-output/prc_omega_3.ref \ unit_tests/ref-output/prc_omega_4.ref \ unit_tests/ref-output/prc_omega_5.ref \ unit_tests/ref-output/prc_omega_6.ref \ unit_tests/ref-output/prc_omega_diags_1.ref \ unit_tests/ref-output/prc_recola_1.ref \ unit_tests/ref-output/prc_recola_2.ref \ unit_tests/ref-output/prc_template_me_1.ref \ unit_tests/ref-output/prc_template_me_2.ref \ unit_tests/ref-output/prc_test_1.ref \ unit_tests/ref-output/prc_test_2.ref \ unit_tests/ref-output/prc_test_3.ref \ unit_tests/ref-output/prc_test_4.ref \ unit_tests/ref-output/prclib_interfaces_1.ref \ unit_tests/ref-output/prclib_interfaces_2.ref \ unit_tests/ref-output/prclib_interfaces_3.ref \ unit_tests/ref-output/prclib_interfaces_4.ref \ unit_tests/ref-output/prclib_interfaces_5.ref \ unit_tests/ref-output/prclib_interfaces_6.ref \ unit_tests/ref-output/prclib_interfaces_7.ref \ unit_tests/ref-output/prclib_stacks_1.ref \ unit_tests/ref-output/prclib_stacks_2.ref \ unit_tests/ref-output/process_configurations_1.ref \ unit_tests/ref-output/process_configurations_2.ref \ unit_tests/ref-output/process_libraries_1.ref \ unit_tests/ref-output/process_libraries_2.ref \ unit_tests/ref-output/process_libraries_3.ref \ unit_tests/ref-output/process_libraries_4.ref \ unit_tests/ref-output/process_libraries_5.ref \ unit_tests/ref-output/process_libraries_6.ref \ unit_tests/ref-output/process_libraries_7.ref \ unit_tests/ref-output/process_libraries_8.ref \ unit_tests/ref-output/process_stacks_1.ref \ unit_tests/ref-output/process_stacks_2.ref \ unit_tests/ref-output/process_stacks_3.ref \ unit_tests/ref-output/process_stacks_4.ref \ unit_tests/ref-output/processes_1.ref \ unit_tests/ref-output/processes_2.ref \ unit_tests/ref-output/processes_3.ref \ unit_tests/ref-output/processes_4.ref \ unit_tests/ref-output/processes_5.ref \ unit_tests/ref-output/processes_6.ref \ unit_tests/ref-output/processes_7.ref \ unit_tests/ref-output/processes_8.ref \ unit_tests/ref-output/processes_9.ref \ unit_tests/ref-output/processes_10.ref \ unit_tests/ref-output/processes_11.ref \ unit_tests/ref-output/processes_12.ref \ unit_tests/ref-output/processes_13.ref \ unit_tests/ref-output/processes_14.ref \ unit_tests/ref-output/processes_15.ref \ unit_tests/ref-output/processes_16.ref \ unit_tests/ref-output/processes_17.ref \ unit_tests/ref-output/processes_18.ref \ unit_tests/ref-output/processes_19.ref \ unit_tests/ref-output/radiation_generator_1.ref \ unit_tests/ref-output/radiation_generator_2.ref \ unit_tests/ref-output/radiation_generator_3.ref \ unit_tests/ref-output/radiation_generator_4.ref \ unit_tests/ref-output/real_subtraction_1.ref \ unit_tests/ref-output/recoil_kinematics_1.ref \ unit_tests/ref-output/recoil_kinematics_2.ref \ unit_tests/ref-output/recoil_kinematics_3.ref \ unit_tests/ref-output/recoil_kinematics_4.ref \ unit_tests/ref-output/recoil_kinematics_5.ref \ unit_tests/ref-output/recoil_kinematics_6.ref \ unit_tests/ref-output/resonance_insertion_1.ref \ unit_tests/ref-output/resonance_insertion_2.ref \ unit_tests/ref-output/resonance_insertion_3.ref \ unit_tests/ref-output/resonance_insertion_4.ref \ unit_tests/ref-output/resonance_insertion_5.ref \ unit_tests/ref-output/resonance_insertion_6.ref \ unit_tests/ref-output/resonances_1.ref \ unit_tests/ref-output/resonances_2.ref \ unit_tests/ref-output/resonances_3.ref \ unit_tests/ref-output/resonances_4.ref \ unit_tests/ref-output/resonances_5.ref \ unit_tests/ref-output/resonances_6.ref \ unit_tests/ref-output/resonances_7.ref \ unit_tests/ref-output/restricted_subprocesses_1.ref \ unit_tests/ref-output/restricted_subprocesses_2.ref \ unit_tests/ref-output/restricted_subprocesses_3.ref \ unit_tests/ref-output/restricted_subprocesses_4.ref \ unit_tests/ref-output/restricted_subprocesses_5.ref \ unit_tests/ref-output/restricted_subprocesses_6.ref \ unit_tests/ref-output/rng_base_1.ref \ unit_tests/ref-output/rng_base_2.ref \ unit_tests/ref-output/rng_stream_1.ref \ unit_tests/ref-output/rng_stream_2.ref \ unit_tests/ref-output/rng_stream_3.ref \ unit_tests/ref-output/rng_tao_1.ref \ unit_tests/ref-output/rng_tao_2.ref \ unit_tests/ref-output/rt_data_1.ref \ unit_tests/ref-output/rt_data_2.ref \ unit_tests/ref-output/rt_data_3.ref \ unit_tests/ref-output/rt_data_4.ref \ unit_tests/ref-output/rt_data_5.ref \ unit_tests/ref-output/rt_data_6.ref \ unit_tests/ref-output/rt_data_7.ref \ unit_tests/ref-output/rt_data_8.ref \ unit_tests/ref-output/rt_data_9.ref \ unit_tests/ref-output/rt_data_10.ref \ unit_tests/ref-output/rt_data_11.ref \ unit_tests/ref-output/selectors_1.ref \ unit_tests/ref-output/selectors_2.ref \ unit_tests/ref-output/sf_aux_1.ref \ unit_tests/ref-output/sf_aux_2.ref \ unit_tests/ref-output/sf_aux_3.ref \ unit_tests/ref-output/sf_aux_4.ref \ unit_tests/ref-output/sf_base_1.ref \ unit_tests/ref-output/sf_base_2.ref \ unit_tests/ref-output/sf_base_3.ref \ unit_tests/ref-output/sf_base_4.ref \ unit_tests/ref-output/sf_base_5.ref \ unit_tests/ref-output/sf_base_6.ref \ unit_tests/ref-output/sf_base_7.ref \ unit_tests/ref-output/sf_base_8.ref \ unit_tests/ref-output/sf_base_9.ref \ unit_tests/ref-output/sf_base_10.ref \ unit_tests/ref-output/sf_base_11.ref \ unit_tests/ref-output/sf_base_12.ref \ unit_tests/ref-output/sf_base_13.ref \ unit_tests/ref-output/sf_base_14.ref \ unit_tests/ref-output/sf_beam_events_1.ref \ unit_tests/ref-output/sf_beam_events_2.ref \ unit_tests/ref-output/sf_beam_events_3.ref \ unit_tests/ref-output/sf_circe1_1.ref \ unit_tests/ref-output/sf_circe1_2.ref \ unit_tests/ref-output/sf_circe1_3.ref \ unit_tests/ref-output/sf_circe2_1.ref \ unit_tests/ref-output/sf_circe2_2.ref \ unit_tests/ref-output/sf_circe2_3.ref \ unit_tests/ref-output/sf_epa_1.ref \ unit_tests/ref-output/sf_epa_2.ref \ unit_tests/ref-output/sf_epa_3.ref \ unit_tests/ref-output/sf_epa_4.ref \ unit_tests/ref-output/sf_epa_5.ref \ unit_tests/ref-output/sf_escan_1.ref \ unit_tests/ref-output/sf_escan_2.ref \ unit_tests/ref-output/sf_ewa_1.ref \ unit_tests/ref-output/sf_ewa_2.ref \ unit_tests/ref-output/sf_ewa_3.ref \ unit_tests/ref-output/sf_ewa_4.ref \ unit_tests/ref-output/sf_ewa_5.ref \ unit_tests/ref-output/sf_gaussian_1.ref \ unit_tests/ref-output/sf_gaussian_2.ref \ unit_tests/ref-output/sf_isr_1.ref \ unit_tests/ref-output/sf_isr_2.ref \ unit_tests/ref-output/sf_isr_3.ref \ unit_tests/ref-output/sf_isr_4.ref \ unit_tests/ref-output/sf_isr_5.ref \ unit_tests/ref-output/sf_lhapdf5_1.ref \ unit_tests/ref-output/sf_lhapdf5_2.ref \ unit_tests/ref-output/sf_lhapdf5_3.ref \ unit_tests/ref-output/sf_lhapdf6_1.ref \ unit_tests/ref-output/sf_lhapdf6_2.ref \ unit_tests/ref-output/sf_lhapdf6_3.ref \ unit_tests/ref-output/sf_mappings_1.ref \ unit_tests/ref-output/sf_mappings_2.ref \ unit_tests/ref-output/sf_mappings_3.ref \ unit_tests/ref-output/sf_mappings_4.ref \ unit_tests/ref-output/sf_mappings_5.ref \ unit_tests/ref-output/sf_mappings_6.ref \ unit_tests/ref-output/sf_mappings_7.ref \ unit_tests/ref-output/sf_mappings_8.ref \ unit_tests/ref-output/sf_mappings_9.ref \ unit_tests/ref-output/sf_mappings_10.ref \ unit_tests/ref-output/sf_mappings_11.ref \ unit_tests/ref-output/sf_mappings_12.ref \ unit_tests/ref-output/sf_mappings_13.ref \ unit_tests/ref-output/sf_mappings_14.ref \ unit_tests/ref-output/sf_mappings_15.ref \ unit_tests/ref-output/sf_mappings_16.ref \ unit_tests/ref-output/sf_pdf_builtin_1.ref \ unit_tests/ref-output/sf_pdf_builtin_2.ref \ unit_tests/ref-output/sf_pdf_builtin_3.ref \ unit_tests/ref-output/shower_1.ref \ unit_tests/ref-output/shower_2.ref \ unit_tests/ref-output/shower_base_1.ref \ unit_tests/ref-output/simulations_1.ref \ unit_tests/ref-output/simulations_2.ref \ unit_tests/ref-output/simulations_3.ref \ unit_tests/ref-output/simulations_4.ref \ unit_tests/ref-output/simulations_5.ref \ unit_tests/ref-output/simulations_6.ref \ unit_tests/ref-output/simulations_7.ref \ unit_tests/ref-output/simulations_8.ref \ unit_tests/ref-output/simulations_9.ref \ unit_tests/ref-output/simulations_10.ref \ unit_tests/ref-output/simulations_11.ref \ unit_tests/ref-output/simulations_12.ref \ unit_tests/ref-output/simulations_13.ref \ unit_tests/ref-output/simulations_14.ref \ unit_tests/ref-output/simulations_15.ref \ unit_tests/ref-output/slha_1.ref \ unit_tests/ref-output/slha_2.ref \ unit_tests/ref-output/sm_physics_1.ref \ unit_tests/ref-output/sm_physics_2.ref \ unit_tests/ref-output/sm_qcd_1.ref \ unit_tests/ref-output/solver_1.ref \ unit_tests/ref-output/sorting_1.ref \ unit_tests/ref-output/state_matrix_1.ref \ unit_tests/ref-output/state_matrix_2.ref \ unit_tests/ref-output/state_matrix_3.ref \ unit_tests/ref-output/state_matrix_4.ref \ unit_tests/ref-output/state_matrix_5.ref \ unit_tests/ref-output/state_matrix_6.ref \ unit_tests/ref-output/state_matrix_7.ref \ unit_tests/ref-output/su_algebra_1.ref \ unit_tests/ref-output/su_algebra_2.ref \ unit_tests/ref-output/su_algebra_3.ref \ unit_tests/ref-output/su_algebra_4.ref \ unit_tests/ref-output/subevt_expr_1.ref \ unit_tests/ref-output/subevt_expr_2.ref \ unit_tests/ref-output/ttv_formfactors_1.ref \ unit_tests/ref-output/ttv_formfactors_2.ref \ unit_tests/ref-output/vamp2_1.ref \ unit_tests/ref-output/vamp2_2.ref \ unit_tests/ref-output/vamp2_3.ref \ unit_tests/ref-output/vamp2_4.ref \ unit_tests/ref-output/vamp2_5.ref \ unit_tests/ref-output/vegas_1.ref \ unit_tests/ref-output/vegas_2.ref \ unit_tests/ref-output/vegas_3.ref \ unit_tests/ref-output/vegas_4.ref \ unit_tests/ref-output/vegas_5.ref \ unit_tests/ref-output/vegas_6.ref \ unit_tests/ref-output/whizard_lha_1.ref \ unit_tests/ref-output/xml_1.ref \ unit_tests/ref-output/xml_2.ref \ unit_tests/ref-output/xml_3.ref \ unit_tests/ref-output/xml_4.ref \ functional_tests/ref-output/alphas.ref \ functional_tests/ref-output/analyze_1.ref \ functional_tests/ref-output/analyze_2.ref \ functional_tests/ref-output/analyze_3.ref \ functional_tests/ref-output/analyze_4.ref \ functional_tests/ref-output/analyze_5.ref \ functional_tests/ref-output/analyze_6.ref \ functional_tests/ref-output/beam_events_1.ref \ functional_tests/ref-output/beam_events_4.ref \ functional_tests/ref-output/beam_setup_1.ref \ functional_tests/ref-output/beam_setup_2.ref \ functional_tests/ref-output/beam_setup_3.ref \ functional_tests/ref-output/beam_setup_4.ref \ functional_tests/ref-output/bjet_cluster.ref \ functional_tests/ref-output/br_redef_1.ref \ functional_tests/ref-output/cascades2_phs_1.ref \ functional_tests/ref-output/cascades2_phs_2.ref \ functional_tests/ref-output/circe1_1.ref \ functional_tests/ref-output/circe1_2.ref \ functional_tests/ref-output/circe1_3.ref \ functional_tests/ref-output/circe1_6.ref \ functional_tests/ref-output/circe1_10.ref \ functional_tests/ref-output/circe1_errors_1.ref \ functional_tests/ref-output/circe2_1.ref \ functional_tests/ref-output/circe2_2.ref \ functional_tests/ref-output/circe2_3.ref \ functional_tests/ref-output/cmdline_1.ref \ functional_tests/ref-output/colors.ref \ functional_tests/ref-output/colors_hgg.ref \ functional_tests/ref-output/cuts.ref \ functional_tests/ref-output/decay_err_1.ref \ functional_tests/ref-output/decay_err_2.ref \ functional_tests/ref-output/decay_err_3.ref \ functional_tests/ref-output/energy_scan_1.ref \ functional_tests/ref-output/ep_3.ref \ functional_tests/ref-output/epa_1.ref \ functional_tests/ref-output/epa_2.ref \ functional_tests/ref-output/epa_3.ref \ functional_tests/ref-output/epa_4.ref \ functional_tests/ref-output/event_dump_1.ref \ functional_tests/ref-output/event_dump_2.ref \ functional_tests/ref-output/event_eff_1.ref \ functional_tests/ref-output/event_eff_2.ref \ functional_tests/ref-output/event_failed_1.ref \ functional_tests/ref-output/event_weights_1.ref \ functional_tests/ref-output/event_weights_2.ref \ functional_tests/ref-output/ewa_4.ref \ functional_tests/ref-output/extpar.ref \ functional_tests/ref-output/fatal.ref \ functional_tests/ref-output/fatal_beam_decay.ref \ functional_tests/ref-output/fks_res_2.ref \ functional_tests/ref-output/flvsum_1.ref \ functional_tests/ref-output/gaussian_1.ref \ functional_tests/ref-output/gaussian_2.ref \ functional_tests/ref-output/hadronize_1.ref \ functional_tests/ref-output/hepmc_1.ref \ functional_tests/ref-output/hepmc_2.ref \ functional_tests/ref-output/hepmc_3.ref \ functional_tests/ref-output/hepmc_4.ref \ functional_tests/ref-output/hepmc_5.ref \ functional_tests/ref-output/hepmc_6.ref \ functional_tests/ref-output/hepmc_7.ref \ functional_tests/ref-output/hepmc_9.ref \ functional_tests/ref-output/hepmc_10.ref \ functional_tests/ref-output/isr_1.ref \ functional_tests/ref-output/isr_epa_1.ref \ functional_tests/ref-output/jets_xsec.ref \ functional_tests/ref-output/job_id_1.ref \ functional_tests/ref-output/job_id_2.ref \ functional_tests/ref-output/job_id_3.ref \ functional_tests/ref-output/job_id_4.ref \ functional_tests/ref-output/lcio_1.ref \ functional_tests/ref-output/lcio_3.ref \ functional_tests/ref-output/lcio_4.ref \ functional_tests/ref-output/lcio_5.ref \ functional_tests/ref-output/lcio_6.ref \ functional_tests/ref-output/lcio_8.ref \ functional_tests/ref-output/lcio_9.ref \ functional_tests/ref-output/lcio_10.ref \ functional_tests/ref-output/lcio_11.ref \ functional_tests/ref-output/lhef_1.ref \ functional_tests/ref-output/lhef_2.ref \ functional_tests/ref-output/lhef_3.ref \ functional_tests/ref-output/lhef_4.ref \ functional_tests/ref-output/lhef_5.ref \ functional_tests/ref-output/lhef_6.ref \ functional_tests/ref-output/lhef_9.ref \ functional_tests/ref-output/lhef_10.ref \ functional_tests/ref-output/lhef_11.ref \ functional_tests/ref-output/libraries_1.ref \ functional_tests/ref-output/libraries_2.ref \ functional_tests/ref-output/libraries_4.ref \ functional_tests/ref-output/method_ovm_1.ref \ functional_tests/ref-output/mlm_matching_fsr.ref \ functional_tests/ref-output/mlm_pythia6_isr.ref \ functional_tests/ref-output/model_change_1.ref \ functional_tests/ref-output/model_change_2.ref \ functional_tests/ref-output/model_change_3.ref \ functional_tests/ref-output/model_scheme_1.ref \ functional_tests/ref-output/model_test.ref \ functional_tests/ref-output/mssmtest_1.ref \ functional_tests/ref-output/mssmtest_2.ref \ functional_tests/ref-output/mssmtest_3.ref \ functional_tests/ref-output/multi_comp_4.ref \ functional_tests/ref-output/nlo_1.ref \ functional_tests/ref-output/nlo_2.ref \ functional_tests/ref-output/nlo_6.ref \ functional_tests/ref-output/nlo_9.ref \ functional_tests/ref-output/nlo_decay_1.ref \ functional_tests/ref-output/observables_1.ref \ functional_tests/ref-output/openloops_1.ref \ functional_tests/ref-output/openloops_2.ref \ functional_tests/ref-output/openloops_4.ref \ functional_tests/ref-output/openloops_5.ref \ functional_tests/ref-output/openloops_6.ref \ functional_tests/ref-output/openloops_7.ref \ functional_tests/ref-output/openloops_8.ref \ functional_tests/ref-output/openloops_9.ref \ functional_tests/ref-output/openloops_10.ref \ functional_tests/ref-output/openloops_11.ref \ functional_tests/ref-output/openloops_12.ref \ functional_tests/ref-output/openloops_13.ref \ functional_tests/ref-output/pack_1.ref \ functional_tests/ref-output/parton_shower_1.ref \ functional_tests/ref-output/photon_isolation_1.ref \ functional_tests/ref-output/photon_isolation_2.ref \ functional_tests/ref-output/polarized_1.ref \ functional_tests/ref-output/process_log.ref \ functional_tests/ref-output/pythia6_1.ref \ functional_tests/ref-output/pythia6_2.ref \ functional_tests/ref-output/qcdtest_4.ref \ functional_tests/ref-output/qcdtest_5.ref \ functional_tests/ref-output/qcdtest_6.ref \ functional_tests/ref-output/qedtest_1.ref \ functional_tests/ref-output/qedtest_2.ref \ functional_tests/ref-output/qedtest_5.ref \ functional_tests/ref-output/qedtest_6.ref \ functional_tests/ref-output/qedtest_7.ref \ functional_tests/ref-output/qedtest_8.ref \ functional_tests/ref-output/qedtest_9.ref \ functional_tests/ref-output/qedtest_10.ref \ functional_tests/ref-output/rambo_vamp_1.ref \ functional_tests/ref-output/rambo_vamp_2.ref \ functional_tests/ref-output/real_partition_1.ref \ functional_tests/ref-output/rebuild_2.ref \ functional_tests/ref-output/rebuild_3.ref \ functional_tests/ref-output/rebuild_4.ref \ functional_tests/ref-output/recola_1.ref \ functional_tests/ref-output/recola_2.ref \ functional_tests/ref-output/recola_3.ref \ functional_tests/ref-output/recola_4.ref \ functional_tests/ref-output/recola_5.ref \ functional_tests/ref-output/recola_6.ref \ functional_tests/ref-output/recola_7.ref \ functional_tests/ref-output/recola_8.ref \ functional_tests/ref-output/recola_9.ref \ functional_tests/ref-output/resonances_5.ref \ functional_tests/ref-output/resonances_6.ref \ functional_tests/ref-output/resonances_7.ref \ functional_tests/ref-output/resonances_8.ref \ functional_tests/ref-output/resonances_9.ref \ functional_tests/ref-output/resonances_12.ref \ functional_tests/ref-output/restrictions.ref \ functional_tests/ref-output/reweight_1.ref \ functional_tests/ref-output/reweight_2.ref \ functional_tests/ref-output/reweight_3.ref \ functional_tests/ref-output/reweight_4.ref \ functional_tests/ref-output/reweight_5.ref \ functional_tests/ref-output/reweight_6.ref \ functional_tests/ref-output/reweight_7.ref \ functional_tests/ref-output/reweight_8.ref \ functional_tests/ref-output/reweight_9.ref \ functional_tests/ref-output/reweight_10.ref \ functional_tests/ref-output/select_1.ref \ functional_tests/ref-output/select_2.ref \ functional_tests/ref-output/show_1.ref \ functional_tests/ref-output/show_2.ref \ functional_tests/ref-output/show_3.ref \ functional_tests/ref-output/show_4.ref \ functional_tests/ref-output/show_5.ref \ functional_tests/ref-output/shower_err_1.ref \ functional_tests/ref-output/sm_cms_1.ref \ functional_tests/ref-output/smtest_1.ref \ functional_tests/ref-output/smtest_3.ref \ functional_tests/ref-output/smtest_4.ref \ functional_tests/ref-output/smtest_5.ref \ functional_tests/ref-output/smtest_6.ref \ functional_tests/ref-output/smtest_7.ref \ functional_tests/ref-output/smtest_9.ref \ functional_tests/ref-output/smtest_10.ref \ functional_tests/ref-output/smtest_11.ref \ functional_tests/ref-output/smtest_12.ref \ functional_tests/ref-output/smtest_13.ref \ functional_tests/ref-output/smtest_14.ref \ functional_tests/ref-output/smtest_15.ref \ functional_tests/ref-output/smtest_16.ref \ functional_tests/ref-output/spincor_1.ref \ functional_tests/ref-output/static_1.ref \ functional_tests/ref-output/static_2.ref \ functional_tests/ref-output/stdhep_1.ref \ functional_tests/ref-output/stdhep_2.ref \ functional_tests/ref-output/stdhep_3.ref \ functional_tests/ref-output/stdhep_4.ref \ functional_tests/ref-output/stdhep_5.ref \ functional_tests/ref-output/stdhep_6.ref \ functional_tests/ref-output/structure_1.ref \ functional_tests/ref-output/structure_2.ref \ functional_tests/ref-output/structure_3.ref \ functional_tests/ref-output/structure_4.ref \ functional_tests/ref-output/structure_5.ref \ functional_tests/ref-output/structure_6.ref \ functional_tests/ref-output/structure_7.ref \ functional_tests/ref-output/structure_8.ref \ functional_tests/ref-output/susyhit.ref \ functional_tests/ref-output/template_me_1.ref \ functional_tests/ref-output/template_me_2.ref \ functional_tests/ref-output/testproc_1.ref \ functional_tests/ref-output/testproc_2.ref \ functional_tests/ref-output/testproc_3.ref \ functional_tests/ref-output/testproc_4.ref \ functional_tests/ref-output/testproc_5.ref \ functional_tests/ref-output/testproc_6.ref \ functional_tests/ref-output/testproc_7.ref \ functional_tests/ref-output/testproc_8.ref \ functional_tests/ref-output/testproc_9.ref \ functional_tests/ref-output/testproc_10.ref \ functional_tests/ref-output/testproc_11.ref \ functional_tests/ref-output/testproc_12.ref \ functional_tests/ref-output/ufo_1.ref \ functional_tests/ref-output/ufo_2.ref \ functional_tests/ref-output/ufo_3.ref \ functional_tests/ref-output/ufo_4.ref \ functional_tests/ref-output/ufo_5.ref \ functional_tests/ref-output/ufo_6.ref \ functional_tests/ref-output/user_prc_threshold_1.ref \ functional_tests/ref-output/user_prc_threshold_2.ref \ functional_tests/ref-output/vamp2_1.ref \ functional_tests/ref-output/vamp2_2.ref \ functional_tests/ref-output/vamp2_3.ref \ functional_tests/ref-output/vars.ref \ ext_tests_nlo/ref-output/nlo_ee4j.ref \ ext_tests_nlo/ref-output/nlo_ee4t.ref \ ext_tests_nlo/ref-output/nlo_ee5j.ref \ ext_tests_nlo/ref-output/nlo_eejj.ref \ ext_tests_nlo/ref-output/nlo_eejjj.ref \ ext_tests_nlo/ref-output/nlo_eett.ref \ ext_tests_nlo/ref-output/nlo_eetth.ref \ ext_tests_nlo/ref-output/nlo_eetthh.ref \ ext_tests_nlo/ref-output/nlo_eetthj.ref \ ext_tests_nlo/ref-output/nlo_eetthz.ref \ ext_tests_nlo/ref-output/nlo_eettwjj.ref \ ext_tests_nlo/ref-output/nlo_eettww.ref \ ext_tests_nlo/ref-output/nlo_eettz.ref \ ext_tests_nlo/ref-output/nlo_eettzj.ref \ ext_tests_nlo/ref-output/nlo_eettzjj.ref \ ext_tests_nlo/ref-output/nlo_eettzz.ref \ ext_tests_nlo/ref-output/nlo_pptttt.ref \ ext_tests_nlo/ref-output/nlo_ppw.ref \ ext_tests_nlo/ref-output/nlo_ppz.ref \ ext_tests_nlo/ref-output/nlo_ppzw.ref \ ext_tests_nlo/ref-output/nlo_ppzz.ref # Reference files that depend on the numerical precision REF_OUTPUT_FILES_DOUBLE = \ functional_tests/ref-output-double/beam_events_2.ref \ functional_tests/ref-output-double/beam_events_3.ref \ functional_tests/ref-output-double/beam_setup_5.ref \ functional_tests/ref-output-double/circe1_4.ref \ functional_tests/ref-output-double/circe1_5.ref \ functional_tests/ref-output-double/circe1_7.ref \ functional_tests/ref-output-double/circe1_8.ref \ functional_tests/ref-output-double/circe1_9.ref \ functional_tests/ref-output-double/circe1_photons_1.ref \ functional_tests/ref-output-double/circe1_photons_2.ref \ functional_tests/ref-output-double/circe1_photons_3.ref \ functional_tests/ref-output-double/circe1_photons_4.ref \ functional_tests/ref-output-double/circe1_photons_5.ref \ functional_tests/ref-output-double/colors_2.ref \ functional_tests/ref-output-double/defaultcuts.ref \ functional_tests/ref-output-double/ep_1.ref \ functional_tests/ref-output-double/ep_2.ref \ functional_tests/ref-output-double/ewa_1.ref \ functional_tests/ref-output-double/ewa_2.ref \ functional_tests/ref-output-double/ewa_3.ref \ functional_tests/ref-output-double/fks_res_1.ref \ functional_tests/ref-output-double/fks_res_3.ref \ functional_tests/ref-output-double/helicity.ref \ functional_tests/ref-output-double/hepmc_8.ref \ functional_tests/ref-output-double/ilc.ref \ functional_tests/ref-output-double/isr_2.ref \ functional_tests/ref-output-double/isr_3.ref \ functional_tests/ref-output-double/isr_4.ref \ functional_tests/ref-output-double/isr_5.ref \ functional_tests/ref-output-double/isr_6.ref \ functional_tests/ref-output-double/lcio_2.ref \ functional_tests/ref-output-double/lcio_7.ref \ functional_tests/ref-output-double/lhapdf5.ref \ functional_tests/ref-output-double/lhapdf6.ref \ functional_tests/ref-output-double/lhef_7.ref \ functional_tests/ref-output-double/mlm_matching_isr.ref \ functional_tests/ref-output-double/multi_comp_1.ref \ functional_tests/ref-output-double/multi_comp_2.ref \ functional_tests/ref-output-double/multi_comp_3.ref \ functional_tests/ref-output-double/nlo_3.ref \ functional_tests/ref-output-double/nlo_4.ref \ functional_tests/ref-output-double/nlo_5.ref \ functional_tests/ref-output-double/nlo_7.ref \ functional_tests/ref-output-double/nlo_8.ref \ functional_tests/ref-output-double/observables_2.ref \ functional_tests/ref-output-double/openloops_3.ref \ functional_tests/ref-output-double/parton_shower_2.ref \ functional_tests/ref-output-double/pdf_builtin.ref \ functional_tests/ref-output-double/powheg_1.ref \ functional_tests/ref-output-double/pythia6_3.ref \ functional_tests/ref-output-double/pythia6_4.ref \ functional_tests/ref-output-double/qcdtest_1.ref \ functional_tests/ref-output-double/qcdtest_2.ref \ functional_tests/ref-output-double/qcdtest_3.ref \ functional_tests/ref-output-double/qedtest_3.ref \ functional_tests/ref-output-double/qedtest_4.ref \ functional_tests/ref-output-double/resonances_1.ref \ functional_tests/ref-output-double/resonances_2.ref \ functional_tests/ref-output-double/resonances_3.ref \ functional_tests/ref-output-double/resonances_4.ref \ functional_tests/ref-output-double/resonances_10.ref \ functional_tests/ref-output-double/resonances_11.ref \ functional_tests/ref-output-double/resonances_13.ref \ functional_tests/ref-output-double/smtest_2.ref \ functional_tests/ref-output-double/smtest_8.ref \ functional_tests/ref-output-double/tauola_1.ref \ functional_tests/ref-output-double/tauola_2.ref \ functional_tests/ref-output-double/tauola_3.ref REF_OUTPUT_FILES_PREC = \ functional_tests/ref-output-prec/beam_setup_5.ref \ functional_tests/ref-output-prec/circe1_9.ref \ functional_tests/ref-output-prec/circe1_photons_1.ref \ functional_tests/ref-output-prec/circe1_photons_2.ref \ functional_tests/ref-output-prec/circe1_photons_3.ref \ functional_tests/ref-output-prec/circe1_photons_4.ref \ functional_tests/ref-output-prec/circe1_photons_5.ref \ functional_tests/ref-output-prec/colors_2.ref \ functional_tests/ref-output-prec/defaultcuts.ref \ functional_tests/ref-output-prec/ep_1.ref \ functional_tests/ref-output-prec/ep_2.ref \ functional_tests/ref-output-prec/ewa_1.ref \ functional_tests/ref-output-prec/fks_res_1.ref \ functional_tests/ref-output-prec/fks_res_3.ref \ functional_tests/ref-output-prec/helicity.ref \ functional_tests/ref-output-prec/ilc.ref \ functional_tests/ref-output-prec/lhapdf5.ref \ functional_tests/ref-output-prec/lhapdf6.ref \ functional_tests/ref-output-prec/lhef_7.ref \ functional_tests/ref-output-prec/multi_comp_1.ref \ functional_tests/ref-output-prec/multi_comp_2.ref \ functional_tests/ref-output-prec/multi_comp_3.ref \ functional_tests/ref-output-prec/nlo_3.ref \ functional_tests/ref-output-prec/nlo_4.ref \ functional_tests/ref-output-prec/parton_shower_2.ref \ functional_tests/ref-output-prec/pdf_builtin.ref \ functional_tests/ref-output-prec/qcdtest_1.ref \ functional_tests/ref-output-prec/qcdtest_2.ref \ functional_tests/ref-output-prec/qcdtest_3.ref \ functional_tests/ref-output-prec/qedtest_3.ref \ functional_tests/ref-output-prec/qedtest_4.ref \ functional_tests/ref-output-prec/smtest_2.ref \ functional_tests/ref-output-prec/smtest_8.ref REF_OUTPUT_FILES_EXT = \ functional_tests/ref-output-ext/beam_events_2.ref \ functional_tests/ref-output-ext/beam_events_3.ref \ functional_tests/ref-output-ext/circe1_4.ref \ functional_tests/ref-output-ext/circe1_5.ref \ functional_tests/ref-output-ext/circe1_7.ref \ functional_tests/ref-output-ext/circe1_8.ref \ functional_tests/ref-output-ext/ewa_2.ref \ functional_tests/ref-output-ext/ewa_3.ref \ functional_tests/ref-output-ext/hepmc_8.ref \ functional_tests/ref-output-ext/isr_2.ref \ functional_tests/ref-output-ext/isr_3.ref \ functional_tests/ref-output-ext/isr_4.ref \ functional_tests/ref-output-ext/isr_5.ref \ functional_tests/ref-output-ext/isr_6.ref \ functional_tests/ref-output-ext/lcio_2.ref \ functional_tests/ref-output-ext/lcio_7.ref \ functional_tests/ref-output-ext/mlm_matching_isr.ref \ functional_tests/ref-output-ext/nlo_5.ref \ functional_tests/ref-output-ext/nlo_7.ref \ functional_tests/ref-output-ext/nlo_8.ref \ functional_tests/ref-output-ext/observables_2.ref \ functional_tests/ref-output-ext/openloops_3.ref \ functional_tests/ref-output-ext/powheg_1.ref \ functional_tests/ref-output-ext/pythia6_3.ref \ functional_tests/ref-output-ext/pythia6_4.ref \ functional_tests/ref-output-ext/resonances_1.ref \ functional_tests/ref-output-ext/resonances_2.ref \ functional_tests/ref-output-ext/resonances_3.ref \ functional_tests/ref-output-ext/resonances_4.ref \ functional_tests/ref-output-ext/resonances_10.ref \ functional_tests/ref-output-ext/resonances_11.ref \ functional_tests/ref-output-ext/resonances_13.ref \ functional_tests/ref-output-ext/tauola_1.ref \ functional_tests/ref-output-ext/tauola_2.ref \ functional_tests/ref-output-ext/tauola_3.ref REF_OUTPUT_FILES_QUAD = \ functional_tests/ref-output-quad/beam_events_2.ref \ functional_tests/ref-output-quad/beam_events_3.ref \ functional_tests/ref-output-quad/circe1_4.ref \ functional_tests/ref-output-quad/circe1_5.ref \ functional_tests/ref-output-quad/circe1_7.ref \ functional_tests/ref-output-quad/circe1_8.ref \ functional_tests/ref-output-quad/ewa_2.ref \ functional_tests/ref-output-quad/ewa_3.ref \ functional_tests/ref-output-quad/hepmc_8.ref \ functional_tests/ref-output-quad/isr_2.ref \ functional_tests/ref-output-quad/isr_3.ref \ functional_tests/ref-output-quad/isr_4.ref \ functional_tests/ref-output-quad/isr_5.ref \ functional_tests/ref-output-quad/isr_6.ref \ functional_tests/ref-output-quad/lcio_2.ref \ functional_tests/ref-output-quad/lcio_7.ref \ functional_tests/ref-output-quad/mlm_matching_isr.ref \ functional_tests/ref-output-quad/nlo_5.ref \ functional_tests/ref-output-quad/nlo_7.ref \ functional_tests/ref-output-quad/nlo_8.ref \ functional_tests/ref-output-quad/observables_2.ref \ functional_tests/ref-output-quad/openloops_3.ref \ functional_tests/ref-output-quad/powheg_1.ref \ functional_tests/ref-output-quad/pythia6_3.ref \ functional_tests/ref-output-quad/pythia6_4.ref \ functional_tests/ref-output-quad/resonances_1.ref \ functional_tests/ref-output-quad/resonances_2.ref \ functional_tests/ref-output-quad/resonances_3.ref \ functional_tests/ref-output-quad/resonances_4.ref \ functional_tests/ref-output-quad/resonances_10.ref \ functional_tests/ref-output-quad/resonances_11.ref \ functional_tests/ref-output-quad/resonances_13.ref \ functional_tests/ref-output-quad/tauola_1.ref \ functional_tests/ref-output-quad/tauola_2.ref \ functional_tests/ref-output-quad/tauola_3.ref TESTSUITES_M4 = \ $(MISC_TESTS_M4) \ $(EXT_MSSM_M4) \ $(EXT_NMSSM_M4) TESTSUITES_SIN = \ $(MISC_TESTS_SIN) \ $(EXT_ILC_SIN) \ $(EXT_MSSM_SIN) \ $(EXT_NMSSM_SIN) \ $(EXT_SHOWER_SIN) \ $(EXT_NLO_SIN) \ $(EXT_NLO_ADD_SIN) MISC_TESTS_M4 = MISC_TESTS_SIN = \ functional_tests/alphas.sin \ functional_tests/analyze_1.sin \ functional_tests/analyze_2.sin \ functional_tests/analyze_3.sin \ functional_tests/analyze_4.sin \ functional_tests/analyze_5.sin \ functional_tests/analyze_6.sin \ functional_tests/beam_events_1.sin \ functional_tests/beam_events_2.sin \ functional_tests/beam_events_3.sin \ functional_tests/beam_events_4.sin \ functional_tests/beam_setup_1.sin \ functional_tests/beam_setup_2.sin \ functional_tests/beam_setup_3.sin \ functional_tests/beam_setup_4.sin \ functional_tests/beam_setup_5.sin \ functional_tests/bjet_cluster.sin \ functional_tests/br_redef_1.sin \ functional_tests/cascades2_phs_1.sin \ functional_tests/cascades2_phs_2.sin \ functional_tests/circe1_1.sin \ functional_tests/circe1_2.sin \ functional_tests/circe1_3.sin \ functional_tests/circe1_4.sin \ functional_tests/circe1_5.sin \ functional_tests/circe1_6.sin \ functional_tests/circe1_7.sin \ functional_tests/circe1_8.sin \ functional_tests/circe1_9.sin \ functional_tests/circe1_10.sin \ functional_tests/circe1_errors_1.sin \ functional_tests/circe1_photons_1.sin \ functional_tests/circe1_photons_2.sin \ functional_tests/circe1_photons_3.sin \ functional_tests/circe1_photons_4.sin \ functional_tests/circe1_photons_5.sin \ functional_tests/circe2_1.sin \ functional_tests/circe2_2.sin \ functional_tests/circe2_3.sin \ functional_tests/cmdline_1.sin \ functional_tests/cmdline_1_a.sin \ functional_tests/cmdline_1_b.sin \ functional_tests/colors.sin \ functional_tests/colors_2.sin \ functional_tests/colors_hgg.sin \ functional_tests/cuts.sin \ functional_tests/decay_err_1.sin \ functional_tests/decay_err_2.sin \ functional_tests/decay_err_3.sin \ functional_tests/defaultcuts.sin \ functional_tests/empty.sin \ functional_tests/energy_scan_1.sin \ functional_tests/ep_1.sin \ functional_tests/ep_2.sin \ functional_tests/ep_3.sin \ functional_tests/epa_1.sin \ functional_tests/epa_2.sin \ functional_tests/epa_3.sin \ functional_tests/epa_4.sin \ functional_tests/event_dump_1.sin \ functional_tests/event_dump_2.sin \ functional_tests/event_eff_1.sin \ functional_tests/event_eff_2.sin \ functional_tests/event_failed_1.sin \ functional_tests/event_weights_1.sin \ functional_tests/event_weights_2.sin \ functional_tests/ewa_1.sin \ functional_tests/ewa_2.sin \ functional_tests/ewa_3.sin \ functional_tests/ewa_4.sin \ functional_tests/extpar.sin \ functional_tests/fatal.sin \ functional_tests/fatal_beam_decay.sin \ functional_tests/fks_res_1.sin \ functional_tests/fks_res_2.sin \ functional_tests/fks_res_3.sin \ functional_tests/flvsum_1.sin \ functional_tests/gaussian_1.sin \ functional_tests/gaussian_2.sin \ functional_tests/hadronize_1.sin \ functional_tests/helicity.sin \ functional_tests/hepmc_1.sin \ functional_tests/hepmc_2.sin \ functional_tests/hepmc_3.sin \ functional_tests/hepmc_4.sin \ functional_tests/hepmc_5.sin \ functional_tests/hepmc_6.sin \ functional_tests/hepmc_7.sin \ functional_tests/hepmc_8.sin \ functional_tests/hepmc_9.sin \ functional_tests/hepmc_10.sin \ functional_tests/ilc.sin \ functional_tests/isr_1.sin \ functional_tests/isr_2.sin \ functional_tests/isr_3.sin \ functional_tests/isr_4.sin \ functional_tests/isr_5.sin \ functional_tests/isr_6.sin \ functional_tests/isr_epa_1.sin \ functional_tests/jets_xsec.sin \ functional_tests/job_id_1.sin \ functional_tests/job_id_2.sin \ functional_tests/job_id_3.sin \ functional_tests/job_id_4.sin \ functional_tests/lcio_1.sin \ functional_tests/lcio_2.sin \ functional_tests/lcio_3.sin \ functional_tests/lcio_4.sin \ functional_tests/lcio_5.sin \ functional_tests/lcio_6.sin \ functional_tests/lcio_7.sin \ functional_tests/lcio_8.sin \ functional_tests/lcio_9.sin \ functional_tests/lcio_10.sin \ functional_tests/lcio_11.sin \ functional_tests/lhapdf5.sin \ functional_tests/lhapdf6.sin \ functional_tests/lhef_1.sin \ functional_tests/lhef_2.sin \ functional_tests/lhef_3.sin \ functional_tests/lhef_4.sin \ functional_tests/lhef_5.sin \ functional_tests/lhef_6.sin \ functional_tests/lhef_7.sin \ functional_tests/lhef_8.sin \ functional_tests/lhef_9.sin \ functional_tests/lhef_10.sin \ functional_tests/lhef_11.sin \ functional_tests/libraries_1.sin \ functional_tests/libraries_2.sin \ functional_tests/libraries_3.sin \ functional_tests/libraries_4.sin \ functional_tests/method_ovm_1.sin \ functional_tests/mlm_matching_fsr.sin \ functional_tests/mlm_matching_isr.sin \ functional_tests/mlm_pythia6_isr.sin \ functional_tests/model_change_1.sin \ functional_tests/model_change_2.sin \ functional_tests/model_change_3.sin \ functional_tests/model_scheme_1.sin \ functional_tests/model_test.sin \ functional_tests/mssmtest_1.sin \ functional_tests/mssmtest_2.sin \ functional_tests/mssmtest_3.sin \ functional_tests/multi_comp_1.sin \ functional_tests/multi_comp_2.sin \ functional_tests/multi_comp_3.sin \ functional_tests/multi_comp_4.sin \ functional_tests/nlo_1.sin \ functional_tests/nlo_2.sin \ functional_tests/nlo_3.sin \ functional_tests/nlo_4.sin \ functional_tests/nlo_5.sin \ functional_tests/nlo_6.sin \ functional_tests/nlo_7.sin \ functional_tests/nlo_8.sin \ functional_tests/nlo_9.sin \ functional_tests/nlo_decay_1.sin \ functional_tests/observables_1.sin \ functional_tests/observables_2.sin \ functional_tests/openloops_1.sin \ functional_tests/openloops_2.sin \ functional_tests/openloops_3.sin \ functional_tests/openloops_4.sin \ functional_tests/openloops_5.sin \ functional_tests/openloops_6.sin \ functional_tests/openloops_7.sin \ functional_tests/openloops_8.sin \ functional_tests/openloops_9.sin \ functional_tests/openloops_10.sin \ functional_tests/openloops_11.sin \ functional_tests/openloops_12.sin \ functional_tests/openloops_13.sin \ functional_tests/pack_1.sin \ functional_tests/parton_shower_1.sin \ functional_tests/parton_shower_2.sin \ functional_tests/pdf_builtin.sin \ functional_tests/photon_isolation_1.sin \ functional_tests/photon_isolation_2.sin \ functional_tests/polarized_1.sin \ functional_tests/powheg_1.sin \ functional_tests/process_log.sin \ functional_tests/pythia6_1.sin \ functional_tests/pythia6_2.sin \ functional_tests/pythia6_3.sin \ functional_tests/pythia6_4.sin \ functional_tests/pythia8_1.sin \ functional_tests/pythia8_2.sin \ functional_tests/qcdtest_1.sin \ functional_tests/qcdtest_2.sin \ functional_tests/qcdtest_3.sin \ functional_tests/qcdtest_4.sin \ functional_tests/qcdtest_5.sin \ functional_tests/qcdtest_6.sin \ functional_tests/qedtest_1.sin \ functional_tests/qedtest_2.sin \ functional_tests/qedtest_3.sin \ functional_tests/qedtest_4.sin \ functional_tests/qedtest_5.sin \ functional_tests/qedtest_6.sin \ functional_tests/qedtest_7.sin \ functional_tests/qedtest_8.sin \ functional_tests/qedtest_9.sin \ functional_tests/qedtest_10.sin \ functional_tests/rambo_vamp_1.sin \ functional_tests/rambo_vamp_2.sin \ functional_tests/real_partition_1.sin \ functional_tests/rebuild_1.sin \ functional_tests/rebuild_2.sin \ functional_tests/rebuild_3.sin \ functional_tests/rebuild_4.sin \ functional_tests/rebuild_5.sin \ functional_tests/recola_1.sin \ functional_tests/recola_2.sin \ functional_tests/recola_3.sin \ functional_tests/recola_4.sin \ functional_tests/recola_5.sin \ functional_tests/recola_6.sin \ functional_tests/recola_7.sin \ functional_tests/recola_8.sin \ functional_tests/recola_9.sin \ functional_tests/resonances_1.sin \ functional_tests/resonances_2.sin \ functional_tests/resonances_3.sin \ functional_tests/resonances_4.sin \ functional_tests/resonances_5.sin \ functional_tests/resonances_6.sin \ functional_tests/resonances_7.sin \ functional_tests/resonances_8.sin \ functional_tests/resonances_9.sin \ functional_tests/resonances_10.sin \ functional_tests/resonances_11.sin \ functional_tests/resonances_12.sin \ functional_tests/resonances_13.sin \ functional_tests/restrictions.sin \ functional_tests/reweight_1.sin \ functional_tests/reweight_2.sin \ functional_tests/reweight_3.sin \ functional_tests/reweight_4.sin \ functional_tests/reweight_5.sin \ functional_tests/reweight_6.sin \ functional_tests/reweight_7.sin \ functional_tests/reweight_8.sin \ functional_tests/reweight_9.sin \ functional_tests/reweight_10.sin \ functional_tests/select_1.sin \ functional_tests/select_2.sin \ functional_tests/show_1.sin \ functional_tests/show_2.sin \ functional_tests/show_3.sin \ functional_tests/show_4.sin \ functional_tests/show_5.sin \ functional_tests/shower_err_1.sin \ functional_tests/sm_cms_1.sin \ functional_tests/smtest_1.sin \ functional_tests/smtest_2.sin \ functional_tests/smtest_3.sin \ functional_tests/smtest_4.sin \ functional_tests/smtest_5.sin \ functional_tests/smtest_6.sin \ functional_tests/smtest_7.sin \ functional_tests/smtest_8.sin \ functional_tests/smtest_9.sin \ functional_tests/smtest_10.sin \ functional_tests/smtest_11.sin \ functional_tests/smtest_12.sin \ functional_tests/smtest_13.sin \ functional_tests/smtest_14.sin \ functional_tests/smtest_15.sin \ functional_tests/smtest_16.sin \ functional_tests/spincor_1.sin \ functional_tests/static_1.exe.sin \ functional_tests/static_1.sin \ functional_tests/static_2.exe.sin \ functional_tests/static_2.sin \ functional_tests/stdhep_1.sin \ functional_tests/stdhep_2.sin \ functional_tests/stdhep_3.sin \ functional_tests/stdhep_4.sin \ functional_tests/stdhep_5.sin \ functional_tests/stdhep_6.sin \ functional_tests/structure_1.sin \ functional_tests/structure_2.sin \ functional_tests/structure_3.sin \ functional_tests/structure_4.sin \ functional_tests/structure_5.sin \ functional_tests/structure_6.sin \ functional_tests/structure_7.sin \ functional_tests/structure_8.sin \ functional_tests/susyhit.sin \ functional_tests/tauola_1.sin \ functional_tests/tauola_2.sin \ functional_tests/tauola_3.sin \ functional_tests/template_me_1.sin \ functional_tests/template_me_2.sin \ functional_tests/testproc_1.sin \ functional_tests/testproc_2.sin \ functional_tests/testproc_3.sin \ functional_tests/testproc_4.sin \ functional_tests/testproc_5.sin \ functional_tests/testproc_6.sin \ functional_tests/testproc_7.sin \ functional_tests/testproc_8.sin \ functional_tests/testproc_9.sin \ functional_tests/testproc_10.sin \ functional_tests/testproc_11.sin \ functional_tests/testproc_12.sin \ functional_tests/ufo_1.sin \ functional_tests/ufo_2.sin \ functional_tests/ufo_3.sin \ functional_tests/ufo_4.sin \ functional_tests/ufo_5.sin \ functional_tests/ufo_6.sin \ functional_tests/user_prc_threshold_1.sin \ functional_tests/user_prc_threshold_2.sin \ functional_tests/vamp2_1.sin \ functional_tests/vamp2_2.sin \ functional_tests/vamp2_3.sin \ functional_tests/vars.sin EXT_MSSM_M4 = \ ext_tests_mssm/mssm_ext-aa.m4 \ ext_tests_mssm/mssm_ext-bb.m4 \ ext_tests_mssm/mssm_ext-bt.m4 \ ext_tests_mssm/mssm_ext-dd.m4 \ ext_tests_mssm/mssm_ext-dd2.m4 \ ext_tests_mssm/mssm_ext-ddckm.m4 \ ext_tests_mssm/mssm_ext-dg.m4 \ ext_tests_mssm/mssm_ext-ee.m4 \ ext_tests_mssm/mssm_ext-ee2.m4 \ ext_tests_mssm/mssm_ext-en.m4 \ ext_tests_mssm/mssm_ext-ga.m4 \ ext_tests_mssm/mssm_ext-gg.m4 \ ext_tests_mssm/mssm_ext-gw.m4 \ ext_tests_mssm/mssm_ext-gz.m4 \ ext_tests_mssm/mssm_ext-tn.m4 \ ext_tests_mssm/mssm_ext-tt.m4 \ ext_tests_mssm/mssm_ext-ug.m4 \ ext_tests_mssm/mssm_ext-uu.m4 \ ext_tests_mssm/mssm_ext-uu2.m4 \ ext_tests_mssm/mssm_ext-uuckm.m4 \ ext_tests_mssm/mssm_ext-wa.m4 \ ext_tests_mssm/mssm_ext-ww.m4 \ ext_tests_mssm/mssm_ext-wz.m4 \ ext_tests_mssm/mssm_ext-za.m4 \ ext_tests_mssm/mssm_ext-zz.m4 EXT_NMSSM_M4 = \ ext_tests_nmssm/nmssm_ext-aa.m4 \ ext_tests_nmssm/nmssm_ext-bb1.m4 \ ext_tests_nmssm/nmssm_ext-bb2.m4 \ ext_tests_nmssm/nmssm_ext-bt.m4 \ ext_tests_nmssm/nmssm_ext-dd1.m4 \ ext_tests_nmssm/nmssm_ext-dd2.m4 \ ext_tests_nmssm/nmssm_ext-ee1.m4 \ ext_tests_nmssm/nmssm_ext-ee2.m4 \ ext_tests_nmssm/nmssm_ext-en.m4 \ ext_tests_nmssm/nmssm_ext-ga.m4 \ ext_tests_nmssm/nmssm_ext-gg.m4 \ ext_tests_nmssm/nmssm_ext-gw.m4 \ ext_tests_nmssm/nmssm_ext-gz.m4 \ ext_tests_nmssm/nmssm_ext-qg.m4 \ ext_tests_nmssm/nmssm_ext-tn.m4 \ ext_tests_nmssm/nmssm_ext-tt1.m4 \ ext_tests_nmssm/nmssm_ext-tt2.m4 \ ext_tests_nmssm/nmssm_ext-uu1.m4 \ ext_tests_nmssm/nmssm_ext-uu2.m4 \ ext_tests_nmssm/nmssm_ext-wa.m4 \ ext_tests_nmssm/nmssm_ext-ww1.m4 \ ext_tests_nmssm/nmssm_ext-ww2.m4 \ ext_tests_nmssm/nmssm_ext-wz.m4 \ ext_tests_nmssm/nmssm_ext-za.m4 \ ext_tests_nmssm/nmssm_ext-zz1.m4 \ ext_tests_nmssm/nmssm_ext-zz2.m4 EXT_MSSM_SIN = $(EXT_MSSM_M4:.m4=.sin) EXT_NMSSM_SIN = $(EXT_NMSSM_M4:.m4=.sin) EXT_ILC_SIN = \ ext_tests_ilc/ilc_settings.sin \ ext_tests_ilc/ilc_top_pair_360.sin \ ext_tests_ilc/ilc_top_pair_500.sin \ ext_tests_ilc/ilc_vbf_higgs_360.sin \ ext_tests_ilc/ilc_vbf_higgs_500.sin \ ext_tests_ilc/ilc_vbf_no_higgs_360.sin \ ext_tests_ilc/ilc_vbf_no_higgs_500.sin \ ext_tests_ilc/ilc_higgs_strahlung_360.sin \ ext_tests_ilc/ilc_higgs_strahlung_500.sin \ ext_tests_ilc/ilc_higgs_strahlung_background_360.sin \ ext_tests_ilc/ilc_higgs_strahlung_background_500.sin \ ext_tests_ilc/ilc_higgs_coupling_360.sin \ ext_tests_ilc/ilc_higgs_coupling_500.sin \ ext_tests_ilc/ilc_higgs_coupling_background_360.sin \ ext_tests_ilc/ilc_higgs_coupling_background_500.sin EXT_SHOWER_SIN = \ ext_tests_shower/shower_1_norad.sin \ ext_tests_shower/shower_2_aall.sin \ ext_tests_shower/shower_3_bb.sin \ ext_tests_shower/shower_3_jj.sin \ ext_tests_shower/shower_3_qqqq.sin \ ext_tests_shower/shower_3_tt.sin \ ext_tests_shower/shower_3_z_nu.sin \ ext_tests_shower/shower_3_z_tau.sin \ ext_tests_shower/shower_4_ee.sin \ ext_tests_shower/shower_5.sin \ ext_tests_shower/shower_6.sin EXT_NLO_SIN = \ ext_tests_nlo/nlo_ee4b.sin \ ext_tests_nlo/nlo_ee4j.sin \ ext_tests_nlo/nlo_ee4t.sin \ ext_tests_nlo/nlo_ee4tj.sin \ ext_tests_nlo/nlo_ee5j.sin \ ext_tests_nlo/nlo_eebb.sin \ ext_tests_nlo/nlo_eebbj.sin \ ext_tests_nlo/nlo_eebbjj.sin \ ext_tests_nlo/nlo_eejj.sin \ ext_tests_nlo/nlo_eejjj.sin \ ext_tests_nlo/nlo_eett.sin \ ext_tests_nlo/nlo_eetta.sin \ ext_tests_nlo/nlo_eettaa.sin \ ext_tests_nlo/nlo_eettah.sin \ ext_tests_nlo/nlo_eettaj.sin \ ext_tests_nlo/nlo_eettajj.sin \ ext_tests_nlo/nlo_eettaz.sin \ ext_tests_nlo/nlo_eettbb.sin \ ext_tests_nlo/nlo_eetth.sin \ ext_tests_nlo/nlo_eetthh.sin \ ext_tests_nlo/nlo_eetthj.sin \ ext_tests_nlo/nlo_eetthjj.sin \ ext_tests_nlo/nlo_eetthz.sin \ ext_tests_nlo/nlo_eettj.sin \ ext_tests_nlo/nlo_eettjj.sin \ ext_tests_nlo/nlo_eettjjj.sin \ ext_tests_nlo/nlo_eettwjj.sin \ ext_tests_nlo/nlo_eettww.sin \ ext_tests_nlo/nlo_eettz.sin \ ext_tests_nlo/nlo_eettzj.sin \ ext_tests_nlo/nlo_eettzjj.sin \ ext_tests_nlo/nlo_eettzz.sin \ ext_tests_nlo/nlo_pptttt.sin \ ext_tests_nlo/nlo_ppw.sin \ ext_tests_nlo/nlo_ppz.sin \ ext_tests_nlo/nlo_ppzw.sin \ ext_tests_nlo/nlo_ppzz.sin \ ext_tests_nlo/nlo_settings.sin EXT_NLO_ADD_SIN = \ ext_tests_nlo_add/nlo_decay_tbw.sin \ ext_tests_nlo_add/nlo_fks_delta_i_ppee.sin \ ext_tests_nlo_add/nlo_fks_delta_o_eejj.sin \ ext_tests_nlo_add/nlo_jets.sin \ ext_tests_nlo_add/nlo_methods_gosam.sin \ ext_tests_nlo_add/nlo_qq_powheg.sin \ ext_tests_nlo_add/nlo_threshold_factorized.sin \ ext_tests_nlo_add/nlo_threshold.sin \ ext_tests_nlo_add/nlo_tt_powheg_sudakov.sin \ ext_tests_nlo_add/nlo_tt_powheg.sin \ ext_tests_nlo_add/nlo_tt.sin \ ext_tests_nlo_add/nlo_uu_powheg.sin \ ext_tests_nlo_add/nlo_uu.sin all-local: $(TESTSUITES_SIN) if M4_AVAILABLE SUFFIXES = .m4 .sin .m4.sin: case "$@" in \ */*) \ mkdir -p `sed 's,/.[^/]*$$,,g' <<< "$@"` ;; \ esac $(M4) $(srcdir)/$(TESTSUITE_MACROS) $< > $@ endif M4_AVAILABLE Index: trunk/share/tests/unit_tests/ref-output/api_7.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_7.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_7.ref (revision 8429) @@ -0,0 +1,85 @@ +* Test output: api_7 +* Purpose: generate events + +Event #1 + process #1 + proc_id = api_7_p1 + sqrts = 1.000E+03 + f_scale = 5.521E+02 + alpha_s = 9.289E-02 + sqme = 3.328E-05 + weight = 8.643E-01 +Event #2 + process #1 + proc_id = api_7_p1 + sqrts = 1.000E+03 + f_scale = 8.236E+02 + alpha_s = 8.872E-02 + sqme = 6.601E-12 + weight = 4.373E-08 +Event #3 + process #1 + proc_id = api_7_p1 + sqrts = 1.000E+03 + f_scale = 9.934E+02 + alpha_s = 8.690E-02 + sqme = 1.568E-18 + weight = 3.027E-16 +Event #4 + process #1 + proc_id = api_7_p1 + sqrts = 1.000E+03 + f_scale = 5.268E+02 + alpha_s = 9.340E-02 + sqme = 1.184E-04 + weight = 3.363E+00 +Event #5 + process #1 + proc_id = api_7_p1 + sqrts = 1.000E+03 + f_scale = 5.541E+02 + alpha_s = 9.285E-02 + sqme = 7.580E-07 + weight = 1.954E-02 +Event #6 + process #1 + proc_id = api_7_p1 + sqrts = 1.000E+03 + f_scale = 8.081E+02 + alpha_s = 8.891E-02 + sqme = 1.774E-09 + weight = 1.309E-05 +Event #7 + process #1 + proc_id = api_7_p1 + sqrts = 1.000E+03 + f_scale = 3.964E+02 + alpha_s = 9.665E-02 + sqme = 1.903E-03 + weight = 6.705E+01 +Event #8 + process #1 + proc_id = api_7_p1 + sqrts = 1.000E+03 + f_scale = 8.971E+02 + alpha_s = 8.788E-02 + sqme = 1.545E-11 + weight = 5.342E-08 +Event #9 + process #1 + proc_id = api_7_p1 + sqrts = 1.000E+03 + f_scale = 6.122E+02 + alpha_s = 9.177E-02 + sqme = 9.507E-08 + weight = 1.948E-03 +Event #10 + process #2 + proc_id = api_7_p2 + sqrts = 1.000E+03 + f_scale = 6.089E+02 + alpha_s = 9.183E-02 + sqme = 1.006E-07 + weight = 2.089E-03 + +* Test output end: api_7 Index: trunk/share/tests/unit_tests/ref-output/api_cc_3.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_cc_3.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_cc_3.ref (revision 8429) @@ -0,0 +1,7 @@ +* Test output: api_cc_3 +* Purpose: translate PDG code(s) to flavor string + +electron = "e-" +leptons = "e-":"m-":"t-" + +* Test output end: api_cc_3 Index: trunk/share/tests/unit_tests/ref-output/api_hepmc3_1.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_hepmc3_1.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_hepmc3_1.ref (revision 8429) @@ -0,0 +1,9 @@ +* Test output: api_hepmc_1 +* Purpose: generate events + +Event #1 + n_particles = 4 +Event #2 + n_particles = 4 + +* Test output end: api_hepmc_1 Index: trunk/share/tests/unit_tests/ref-output/api_lcio_1.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_lcio_1.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_lcio_1.ref (revision 8429) @@ -0,0 +1,9 @@ +* Test output: api_lcio_1 +* Purpose: generate events + +Event #1 + n_particles = 4 +Event #2 + n_particles = 4 + +* Test output end: api_lcio_1 Index: trunk/share/tests/unit_tests/ref-output/api_8.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_8.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_8.ref (revision 8429) @@ -0,0 +1,11 @@ +* Test output: api_8 +* Purpose: check pack/unpack options + +*** ERROR: File 'api_8_bar.tgz' not found +*** ERROR: File 'api_8_gee.tgz' not found +| WHIZARD: master object initialized. +| WHIZARD: Intentional errors: pack/unpack files do not exist +*** ERROR: File/dir 'api_8_foo' not found +| WHIZARD: master object finalized. + +* Test output end: api_8 Index: trunk/share/tests/unit_tests/ref-output/api_cc_4.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_cc_4.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_cc_4.ref (revision 8429) @@ -0,0 +1,15 @@ +* Test output: api_cc_4 +* Purpose: integrate and retrieve results + +* Process setup + + integral is unknown = 1 + +* Integrate + + integral is unknown = 0 + sqrt(s) = 10.0 GeV + cross section = 846.2 pb + error = 18.1 pb + +* Test output end: api_cc_4 Index: trunk/share/tests/unit_tests/ref-output/api_lcio_cc_1.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_lcio_cc_1.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_lcio_cc_1.ref (revision 8429) @@ -0,0 +1,9 @@ +* Test output: api_lcio_cc_1 +* Purpose: generate events + +Event #1 + n_particles = 4 +Event #2 + n_particles = 4 + +* Test output end: api_lcio_cc_1 Index: trunk/share/tests/unit_tests/ref-output/api_hepmc2_cc_1.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_hepmc2_cc_1.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_hepmc2_cc_1.ref (revision 8429) @@ -0,0 +1,9 @@ +* Test output: api_hepmc2_cc_1 +* Purpose: generate events + +Event #1 + n_particles = 4 +Event #2 + n_particles = 4 + +* Test output end: api_hepmc2_cc_1 Index: trunk/share/tests/unit_tests/ref-output/simulations_2.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/simulations_2.ref (revision 8428) +++ trunk/share/tests/unit_tests/ref-output/simulations_2.ref (revision 8429) @@ -1,203 +1,203 @@ * Test output: simulations_2 * Purpose: generate events for a single process * Initialize processes * Initialize event generation Event sample properties: MD5 sum (proc) = '5368809EAF375C82590A69A6239A7DD4' MD5 sum (config) = '84C44539010DE76E0EA21E34BD713917' unweighted = F negative weights = F normalization = 'sigma' number of beams = 2 PDG = 25 25 Energy = 5.000000000000E+02 5.000000000000E+02 total cross sec. = 7.746462203555E+03 num of processes = 1 Process #1 CSec = 7.746462203555E+03 Error = 0.000000000000E+00 * Generate three events ======================================================================== - Event sample: '' + Event sample: 'simulation_2p' Processes = 1 Unweighted = F Event norm = 'sigma' Neg. weights = F Res. history = F Respect sel. = T Update sqme = F Update wgt = F Update event = F Recov. beams = F Pacify = F Max. tries = 10000 Integral = 7.746462203555E+03 Error = 0.000000000000E+00 Sim. valid = T Ev.file ver. = 2 MD5 sum (proc) = '5368809EAF375C82590A69A6239A7DD4' MD5 sum (config) = '84C44539010DE76E0EA21E34BD713917' Events requested = 3 Event index = 3 Events total = 3 generated = 3 read = 0 positive weight = 3 negative weight = 0 zero weight = 0 excess weight = 0 Events dropped = 0 ------------------------------------------------------------------------ Current event: Process #1: simulation_2p MCI set #1 Weight = 7.746462203555E+03 Zero-weight events dropped = 0 ------------------------------------------------------------------------ TAO random-number generator: seed = 65536 calls = 0 ======================================================================== Process #1: Process = 'simulation_2p' Library = 'simulation_2a' Run = 'simulations1' is valid = T Integral = 7.746462203555E+03 Error = 0.000000000000E+00 Weight = 1.0000000000 MCI sets = 1 Events total = 3 generated = 3 read = 0 positive weight = 3 negative weight = 0 zero weight = 0 excess weight = 0 Events dropped = 0 MCI set #1: Components: 1: 'simulation_2p_i1' Integral = 7.746462203555E+03 Error = 0.000000000000E+00 Weight = 1.0000000000 Events total = 3 generated = 3 read = 0 positive weight = 3 negative weight = 0 zero weight = 0 excess weight = 0 Events dropped = 0 ======================================================================== * Write the event record for the last event ======================================================================== Event #3 ------------------------------------------------------------------------ Unweighted = F Normalization = 'sigma' Helicity handling = drop Keep correlations = F ------------------------------------------------------------------------ Squared matrix el. (ref) = 1.000000000000E+00 Squared matrix el. (prc) = 1.000000000000E+00 Event weight (ref) = 7.746462203555E+03 Event weight (prc) = 7.746462203555E+03 ------------------------------------------------------------------------ Selected MCI group = 1 Selected term = 1 Selected channel = 1 ------------------------------------------------------------------------ Passed selection = T Reweighting factor = 1.000000000000E+00 Analysis flag = T ======================================================================== Process instance [scattering]: 'simulation_2p' Run ID = 'simulations1' Process components: * 1: 'simulation_2p_i1': s, s => s, s [unit_test] status = event complete ------------------------------------------------------------------------ sqme = 1.000000000000E+00 weight = 7.746462203555E+03 ------------------------------------------------------------------------ Active MCI instance #1 = 0.24309 0.61407 x = 0.2430856107 0.6140713627 Integrand = 8.000511761705E+03 Weight = 9.682458365519E-01 Maximum = 8.000511761705E+03 Minimum = 8.000511761705E+03 Call statistics (current run): total = 3 failed kin. = 0 failed cuts = 0 passed cuts = 0 evaluated = 3 ======================================================================== ======================================================================== Event transform: trivial (hard process) ------------------------------------------------------------------------ Associated process: 'simulation_2p' TAO random-number generator: seed = 2 calls = 9 Number of tries = 1 ------------------------------------------------------------------------ Particle set: ------------------------------------------------------------------------ Particle 1 [i] f(25) E = 5.000000000000E+02 P = 0.000000000000E+00 0.000000000000E+00 4.841229182759E+02 T = 1.562500000000E+04 Children: 3 4 Particle 2 [i] f(25) E = 5.000000000000E+02 P = 0.000000000000E+00 0.000000000000E+00 -4.841229182759E+02 T = 1.562500000000E+04 Children: 3 4 Particle 3 [o] f(25) E = 5.000000000000E+02 P = -3.131375620363E+02 -2.728372711295E+02 2.487562878091E+02 T = 1.562500000000E+04 Parents: 1 2 Particle 4 [o] f(25) E = 5.000000000000E+02 P = 3.131375620363E+02 2.728372711295E+02 -2.487562878091E+02 T = 1.562500000000E+04 Parents: 1 2 ======================================================================== Local variables: ------------------------------------------------------------------------ sqrts* = 1.000000000000E+03 sqrts_hat* => 1.000000000000E+03 n_in* => 2 n_out* => 2 n_tot* => 4 $process_id* => "simulation_2p" process_num_id* => [unknown integer] sqme* => 1.000000000000E+00 sqme_ref* => 1.000000000000E+00 event_index* => 3 event_weight* => 7.746462203555E+03 event_weight_ref* => 7.746462203555E+03 event_excess* => 0.000000000000E+00 ------------------------------------------------------------------------ subevent: 1 prt(i:25|-5.0000000E+02; 0.0000000E+00, 0.0000000E+00,-4.8412292E+02| 1.562500000000E+04| 1) 2 prt(i:25|-5.0000000E+02; 0.0000000E+00, 0.0000000E+00, 4.8412292E+02| 1.562500000000E+04| 2) 3 prt(o:25| 5.0000000E+02;-3.1313756E+02,-2.7283727E+02, 2.4875629E+02| 1.562500000000E+04| 3) 4 prt(o:25| 5.0000000E+02; 3.1313756E+02, 2.7283727E+02,-2.4875629E+02| 1.562500000000E+04| 4) ======================================================================== * Cleanup * Test output end: simulations_2 Index: trunk/share/tests/unit_tests/ref-output/api_1.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_1.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_1.ref (revision 8429) @@ -0,0 +1,8 @@ +* Test output: api_1 +* Purpose: call init/final + +| WHIZARD: master object initialized. +*** ERROR: WHIZARD: extra call to initializer is ignored +| WHIZARD: master object finalized. + +* Test output end: api_1 Index: trunk/share/tests/unit_tests/ref-output/api_cc_5.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_cc_5.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_cc_5.ref (revision 8429) @@ -0,0 +1,75 @@ +* Test output: api_cc_5 +* Purpose: generate events + +Event #1 + process #1 + proc_id = api_cc_5_p1 + f_scale = 5.521e+02 + alpha_s = 9.289e-02 + sqme = 3.328e-05 + weight = 8.643e-01 +Event #2 + process #1 + proc_id = api_cc_5_p1 + f_scale = 8.236e+02 + alpha_s = 8.872e-02 + sqme = 6.601e-12 + weight = 4.373e-08 +Event #3 + process #1 + proc_id = api_cc_5_p1 + f_scale = 9.934e+02 + alpha_s = 8.690e-02 + sqme = 1.568e-18 + weight = 3.027e-16 +Event #4 + process #1 + proc_id = api_cc_5_p1 + f_scale = 5.268e+02 + alpha_s = 9.340e-02 + sqme = 1.184e-04 + weight = 3.363e+00 +Event #5 + process #1 + proc_id = api_cc_5_p1 + f_scale = 5.541e+02 + alpha_s = 9.285e-02 + sqme = 7.580e-07 + weight = 1.954e-02 +Event #6 + process #1 + proc_id = api_cc_5_p1 + f_scale = 8.081e+02 + alpha_s = 8.891e-02 + sqme = 1.774e-09 + weight = 1.309e-05 +Event #7 + process #1 + proc_id = api_cc_5_p1 + f_scale = 3.964e+02 + alpha_s = 9.665e-02 + sqme = 1.903e-03 + weight = 6.705e+01 +Event #8 + process #1 + proc_id = api_cc_5_p1 + f_scale = 8.971e+02 + alpha_s = 8.788e-02 + sqme = 1.545e-11 + weight = 5.342e-08 +Event #9 + process #1 + proc_id = api_cc_5_p1 + f_scale = 6.122e+02 + alpha_s = 9.177e-02 + sqme = 9.507e-08 + weight = 1.948e-03 +Event #10 + process #2 + proc_id = api_cc_5_p2 + f_scale = 6.089e+02 + alpha_s = 9.183e-02 + sqme = 1.006e-07 + weight = 2.089e-03 + +* Test output end: api_cc_5 Index: trunk/share/tests/unit_tests/ref-output/api_c_1.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_c_1.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_c_1.ref (revision 8429) @@ -0,0 +1,9 @@ +* Test output: api_c_1 +* Purpose: call init/final + +* Creating WHIZARD object handle +* Setting options +* Initializing WHIZARD +* Finalizing WHIZARD + +* Test output end: api_c_1 Index: trunk/share/tests/unit_tests/ref-output/simulations_10.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/simulations_10.ref (revision 8428) +++ trunk/share/tests/unit_tests/ref-output/simulations_10.ref (revision 8429) @@ -1,330 +1,330 @@ * Test output: simulations_10 * Purpose: reweight event * Initialize processes * Initialize alternative environment with custom weight weight = 2 ======================================================================== Cuts: [undefined] ------------------------------------------------------------------------ Scale: [undefined] ------------------------------------------------------------------------ Factorization scale: [undefined] ------------------------------------------------------------------------ Renormalization scale: [undefined] ------------------------------------------------------------------------ Weight: ------------------------------------------------------------------------ + SEQUENCE = + SEQUENCE = | + SEQUENCE = | | + SEQUENCE = | | | + INTEGER = 2 ======================================================================== Event selection: [undefined] ------------------------------------------------------------------------ Event reweighting factor: [undefined] ------------------------------------------------------------------------ Event analysis: [undefined] ======================================================================== * Initialize event generation Event sample properties: MD5 sum (proc) = '0B2DE50F19EBF15A744DDBDF7D7FE4CF' MD5 sum (config) = '64084026865679451CDA8B1F6B3B529D' unweighted = F negative weights = F normalization = 'sigma' number of beams = 2 PDG = 25 25 Energy = 5.000000000000E+02 5.000000000000E+02 total cross sec. = 7.746462203555E+03 num of processes = 1 Process #1 CSec = 7.746462203555E+03 Error = 0.000000000000E+00 num of alt wgt = 1 MD5 sum (cfg) = 'F7D30BB5E18EEC37BA418AD573A98F7E' 1 * Generate an event ======================================================================== - Event sample: '' + Event sample: 'simulation_10p' Processes = 1 Alt.wgts = 1 Unweighted = F Event norm = 'sigma' Neg. weights = F Res. history = F Respect sel. = T Update sqme = F Update wgt = F Update event = F Recov. beams = F Pacify = F Max. tries = 10000 Integral = 7.746462203555E+03 Error = 0.000000000000E+00 Sim. valid = T Ev.file ver. = 2 MD5 sum (proc) = '0B2DE50F19EBF15A744DDBDF7D7FE4CF' MD5 sum (config) = '64084026865679451CDA8B1F6B3B529D' Events requested = 1 Event index = 1 Events total = 1 generated = 1 read = 0 positive weight = 1 negative weight = 0 zero weight = 0 excess weight = 0 Events dropped = 0 ------------------------------------------------------------------------ Current event: Process #1: simulation_10p MCI set #1 Weight = 7.746462203555E+03 Zero-weight events dropped = 0 ------------------------------------------------------------------------ TAO random-number generator: seed = 131072 calls = 0 ======================================================================== Process #1: Process = 'simulation_10p' Library = 'simulation_10a' Run = 'simulations1' is valid = T Integral = 7.746462203555E+03 Error = 0.000000000000E+00 Weight = 1.0000000000 MCI sets = 1 Events total = 1 generated = 1 read = 0 positive weight = 1 negative weight = 0 zero weight = 0 excess weight = 0 Events dropped = 0 MCI set #1: Components: 1: 'simulation_10p_i1' Integral = 7.746462203555E+03 Error = 0.000000000000E+00 Weight = 1.0000000000 Events total = 1 generated = 1 read = 0 positive weight = 1 negative weight = 0 zero weight = 0 excess weight = 0 Events dropped = 0 ======================================================================== * Write the event record for the last event ======================================================================== Event #1 ------------------------------------------------------------------------ Unweighted = F Normalization = 'sigma' Helicity handling = drop Keep correlations = F ------------------------------------------------------------------------ Squared matrix el. (ref) = 1.000000000000E+00 alternate sqme = 2.000000000000E+00 1 Squared matrix el. (prc) = 1.000000000000E+00 Event weight (ref) = 7.746462203555E+03 alternate weight = 1.549292440711E+04 1 Event weight (prc) = 7.746462203555E+03 ------------------------------------------------------------------------ Selected MCI group = 1 Selected term = 1 Selected channel = 1 ------------------------------------------------------------------------ Passed selection = T Reweighting factor = 1.000000000000E+00 Analysis flag = T ======================================================================== Process instance [scattering]: 'simulation_10p' Run ID = 'simulations1' Process components: * 1: 'simulation_10p_i1': s, s => s, s [unit_test] status = event complete ------------------------------------------------------------------------ sqme = 1.000000000000E+00 weight = 7.746462203555E+03 ------------------------------------------------------------------------ Active MCI instance #1 = 0.05465 0.23189 x = 0.0546489097 0.2318944205 Integrand = 8.000511761705E+03 Weight = 9.682458365519E-01 Maximum = 8.000511761705E+03 Minimum = 8.000511761705E+03 Call statistics (current run): total = 1 failed kin. = 0 failed cuts = 0 passed cuts = 0 evaluated = 1 ======================================================================== ======================================================================== Event transform: trivial (hard process) ------------------------------------------------------------------------ Associated process: 'simulation_10p' TAO random-number generator: seed = 2 calls = 3 Number of tries = 1 ------------------------------------------------------------------------ Particle set: ------------------------------------------------------------------------ Particle 1 [i] f(25) E = 5.000000000000E+02 P = 0.000000000000E+00 0.000000000000E+00 4.841229182759E+02 T = 1.562500000000E+04 Children: 3 4 Particle 2 [i] f(25) E = 5.000000000000E+02 P = 0.000000000000E+00 0.000000000000E+00 -4.841229182759E+02 T = 1.562500000000E+04 Children: 3 4 Particle 3 [o] f(25) E = 5.000000000000E+02 P = 2.498205220122E+01 2.186536143155E+02 4.312093389696E+02 T = 1.562500000000E+04 Parents: 1 2 Particle 4 [o] f(25) E = 5.000000000000E+02 P = -2.498205220122E+01 -2.186536143155E+02 -4.312093389696E+02 T = 1.562500000000E+04 Parents: 1 2 ======================================================================== Local variables: ------------------------------------------------------------------------ sqrts* = 1.000000000000E+03 sqrts_hat* => 1.000000000000E+03 n_in* => 2 n_out* => 2 n_tot* => 4 $process_id* => "simulation_10p" process_num_id* => [unknown integer] sqme* => 1.000000000000E+00 sqme_ref* => 1.000000000000E+00 event_index* => 1 event_weight* => 7.746462203555E+03 event_weight_ref* => 7.746462203555E+03 event_excess* => 0.000000000000E+00 ------------------------------------------------------------------------ subevent: 1 prt(i:25|-5.0000000E+02; 0.0000000E+00, 0.0000000E+00,-4.8412292E+02| 1.562500000000E+04| 1) 2 prt(i:25|-5.0000000E+02; 0.0000000E+00, 0.0000000E+00, 4.8412292E+02| 1.562500000000E+04| 2) 3 prt(o:25| 5.0000000E+02; 2.4982052E+01, 2.1865361E+02, 4.3120934E+02| 1.562500000000E+04| 3) 4 prt(o:25| 5.0000000E+02;-2.4982052E+01,-2.1865361E+02,-4.3120934E+02| 1.562500000000E+04| 4) ======================================================================== * Write the event record for the alternative setup ======================================================================== Event #1 ------------------------------------------------------------------------ Unweighted = F Normalization = 'sigma' Helicity handling = drop Keep correlations = F ------------------------------------------------------------------------ Squared matrix el. (ref) = 2.000000000000E+00 Squared matrix el. (prc) = 2.000000000000E+00 Event weight (ref) = 1.549292440711E+04 Event weight (prc) = 1.549292440711E+04 ------------------------------------------------------------------------ Selected MCI group = 1 Selected term = 1 Selected channel = 1 ------------------------------------------------------------------------ Passed selection = T Reweighting factor = 1.000000000000E+00 Analysis flag = T ======================================================================== Process instance [scattering]: 'simulation_10p' Run ID = 'simulations1' Process components: * 1: 'simulation_10p_i1': s, s => s, s [unit_test] status = event complete ------------------------------------------------------------------------ sqme = 2.000000000000E+00 weight = 1.549292440711E+04 ------------------------------------------------------------------------ Active MCI instance #1 = 0.05465 0.23189 x = 0.0000000000 0.0000000000 Integrand = 0.000000000000E+00 Weight = 0.000000000000E+00 Call statistics (current run): [no calls] ======================================================================== ======================================================================== Event transform: trivial (hard process) ------------------------------------------------------------------------ Associated process: 'simulation_10p' TAO random-number generator: seed = 65538 calls = 0 Number of tries = 0 ------------------------------------------------------------------------ Particle set: ------------------------------------------------------------------------ Particle 1 [i] f(25) E = 5.000000000000E+02 P = 0.000000000000E+00 0.000000000000E+00 4.841229182759E+02 T = 1.562500000000E+04 Children: 3 4 Particle 2 [i] f(25) E = 5.000000000000E+02 P = 0.000000000000E+00 0.000000000000E+00 -4.841229182759E+02 T = 1.562500000000E+04 Children: 3 4 Particle 3 [o] f(25) E = 5.000000000000E+02 P = 2.498205220122E+01 2.186536143155E+02 4.312093389696E+02 T = 1.562500000000E+04 Parents: 1 2 Particle 4 [o] f(25) E = 5.000000000000E+02 P = -2.498205220122E+01 -2.186536143155E+02 -4.312093389696E+02 T = 1.562500000000E+04 Parents: 1 2 ======================================================================== Local variables: ------------------------------------------------------------------------ sqrts* = 1.000000000000E+03 sqrts_hat* => 1.000000000000E+03 n_in* => 2 n_out* => 2 n_tot* => 4 $process_id* => "simulation_10p" process_num_id* => [unknown integer] sqme* => 2.000000000000E+00 sqme_ref* => 2.000000000000E+00 event_index* => 1 event_weight* => 1.549292440711E+04 event_weight_ref* => 1.549292440711E+04 event_excess* => 0.000000000000E+00 ------------------------------------------------------------------------ subevent: 1 prt(i:25|-5.0000000E+02; 0.0000000E+00, 0.0000000E+00,-4.8412292E+02| 1.562500000000E+04| 1) 2 prt(i:25|-5.0000000E+02; 0.0000000E+00, 0.0000000E+00, 4.8412292E+02| 1.562500000000E+04| 2) 3 prt(o:25| 5.0000000E+02; 2.4982052E+01, 2.1865361E+02, 4.3120934E+02| 1.562500000000E+04| 3) 4 prt(o:25| 5.0000000E+02;-2.4982052E+01,-2.1865361E+02,-4.3120934E+02| 1.562500000000E+04| 4) ======================================================================== * Cleanup * Test output end: simulations_10 Index: trunk/share/tests/unit_tests/ref-output/simulations_3.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/simulations_3.ref (revision 8428) +++ trunk/share/tests/unit_tests/ref-output/simulations_3.ref (revision 8429) @@ -1,203 +1,203 @@ * Test output: simulations_3 * Purpose: generate unweighted events for a single process * Initialize processes * Initialize event generation Event sample properties: MD5 sum (proc) = '9DF2C4445E2B8C32C9412DAE96A91E87' MD5 sum (config) = 'D1B1F714D7049E259BC7F38036056FD5' unweighted = T negative weights = F normalization = '1' number of beams = 2 PDG = 25 25 Energy = 5.000000000000E+02 5.000000000000E+02 total cross sec. = 7.746462203555E+03 num of processes = 1 Process #1 CSec = 7.746462203555E+03 Error = 0.000000000000E+00 * Generate three events ======================================================================== - Event sample: '' + Event sample: 'simulation_3p' Processes = 1 Unweighted = T Event norm = '1' Neg. weights = F Res. history = F Respect sel. = T Update sqme = F Update wgt = F Update event = F Recov. beams = F Pacify = F Max. tries = 10000 Integral = 7.746462203555E+03 Error = 0.000000000000E+00 Sim. valid = T Ev.file ver. = 2 MD5 sum (proc) = '9DF2C4445E2B8C32C9412DAE96A91E87' MD5 sum (config) = 'D1B1F714D7049E259BC7F38036056FD5' Events requested = 3 Event index = 3 Events total = 3 generated = 3 read = 0 positive weight = 3 negative weight = 0 zero weight = 0 excess weight = 0 Events dropped = 0 ------------------------------------------------------------------------ Current event: Process #1: simulation_3p MCI set #1 Weight = 1.000000000000E+00 Zero-weight events dropped = 0 ------------------------------------------------------------------------ TAO random-number generator: seed = 65536 calls = 0 ======================================================================== Process #1: Process = 'simulation_3p' Library = 'simulation_3a' Run = 'simulations1' is valid = T Integral = 7.746462203555E+03 Error = 0.000000000000E+00 Weight = 1.0000000000 MCI sets = 1 Events total = 3 generated = 3 read = 0 positive weight = 3 negative weight = 0 zero weight = 0 excess weight = 0 Events dropped = 0 MCI set #1: Components: 1: 'simulation_3p_i1' Integral = 7.746462203555E+03 Error = 0.000000000000E+00 Weight = 1.0000000000 Events total = 3 generated = 3 read = 0 positive weight = 3 negative weight = 0 zero weight = 0 excess weight = 0 Events dropped = 0 ======================================================================== * Write the event record for the last event ======================================================================== Event #3 ------------------------------------------------------------------------ Unweighted = T Normalization = '1' Helicity handling = drop Keep correlations = F ------------------------------------------------------------------------ Squared matrix el. (ref) = 1.000000000000E+00 Squared matrix el. (prc) = 1.000000000000E+00 Event weight (ref) = 1.000000000000E+00 Event weight (prc) = 1.000000000000E+00 ------------------------------------------------------------------------ Selected MCI group = 1 Selected term = 1 Selected channel = 1 ------------------------------------------------------------------------ Passed selection = T Reweighting factor = 1.000000000000E+00 Analysis flag = T ======================================================================== Process instance [scattering]: 'simulation_3p' Run ID = 'simulations1' Process components: * 1: 'simulation_3p_i1': s, s => s, s [unit_test] status = event complete ------------------------------------------------------------------------ sqme = 1.000000000000E+00 weight = 1.000000000000E+00 ------------------------------------------------------------------------ Active MCI instance #1 = 0.81790 0.50538 x = 0.8178989226 0.5053756572 Integrand = 8.000511761705E+03 Weight = 9.682458365519E-01 Maximum = 8.000511761705E+03 Minimum = 8.000511761705E+03 Call statistics (current run): total = 3 failed kin. = 0 failed cuts = 0 passed cuts = 0 evaluated = 3 ======================================================================== ======================================================================== Event transform: trivial (hard process) ------------------------------------------------------------------------ Associated process: 'simulation_3p' TAO random-number generator: seed = 2 calls = 9 Number of tries = 1 ------------------------------------------------------------------------ Particle set: ------------------------------------------------------------------------ Particle 1 [i] f(25) E = 5.000000000000E+02 P = 0.000000000000E+00 0.000000000000E+00 4.841229182759E+02 T = 1.562500000000E+04 Children: 3 4 Particle 2 [i] f(25) E = 5.000000000000E+02 P = 0.000000000000E+00 0.000000000000E+00 -4.841229182759E+02 T = 1.562500000000E+04 Children: 3 4 Particle 3 [o] f(25) E = 5.000000000000E+02 P = -3.734598664708E+02 -1.261887306145E+01 -3.078043082516E+02 T = 1.562500000000E+04 Parents: 1 2 Particle 4 [o] f(25) E = 5.000000000000E+02 P = 3.734598664708E+02 1.261887306145E+01 3.078043082516E+02 T = 1.562500000000E+04 Parents: 1 2 ======================================================================== Local variables: ------------------------------------------------------------------------ sqrts* = 1.000000000000E+03 sqrts_hat* => 1.000000000000E+03 n_in* => 2 n_out* => 2 n_tot* => 4 $process_id* => "simulation_3p" process_num_id* => [unknown integer] sqme* => 1.000000000000E+00 sqme_ref* => 1.000000000000E+00 event_index* => 3 event_weight* => 1.000000000000E+00 event_weight_ref* => 1.000000000000E+00 event_excess* => 0.000000000000E+00 ------------------------------------------------------------------------ subevent: 1 prt(i:25|-5.0000000E+02; 0.0000000E+00, 0.0000000E+00,-4.8412292E+02| 1.562500000000E+04| 1) 2 prt(i:25|-5.0000000E+02; 0.0000000E+00, 0.0000000E+00, 4.8412292E+02| 1.562500000000E+04| 2) 3 prt(o:25| 5.0000000E+02;-3.7345987E+02,-1.2618873E+01,-3.0780431E+02| 1.562500000000E+04| 3) 4 prt(o:25| 5.0000000E+02; 3.7345987E+02, 1.2618873E+01, 3.0780431E+02| 1.562500000000E+04| 4) ======================================================================== * Cleanup * Test output end: simulations_3 Index: trunk/share/tests/unit_tests/ref-output/api_2.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_2.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_2.ref (revision 8429) @@ -0,0 +1,15 @@ +* Test output: api_2 +* Purpose: access Sindarin variables + +sqrts is known = F +sqrts = 0.0 +sqrts is known = T +sqrts = 100.0 +$job_id = api_2_ID +n_events = 3 +?unweighted = F +$sample = foo + +?unweighted = T + +* Test output end: api_2 Index: trunk/share/tests/unit_tests/ref-output/api_c_2.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_c_2.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_c_2.ref (revision 8429) @@ -0,0 +1,15 @@ +* Test output: api_c_2 +* Purpose: access Sindarin variables + +$job_id = api_c_2_ID +sqrts = [unknown] + +sqrts = 100.0 +n_events = 3 +?unweighted = 0 +$sample = foobar + +?unweighted = 1 +$sample = foo + +* Test output end: api_c_2 Index: trunk/share/tests/unit_tests/ref-output/api_hepmc3_cc_1.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_hepmc3_cc_1.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_hepmc3_cc_1.ref (revision 8429) @@ -0,0 +1,9 @@ +* Test output: api_hepmc3_cc_1 +* Purpose: generate events + +Event #1 + n_particles = 4 +Event #2 + n_particles = 4 + +* Test output end: api_hepmc3_cc_1 Index: trunk/share/tests/unit_tests/ref-output/simulations_11.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/simulations_11.ref (revision 8428) +++ trunk/share/tests/unit_tests/ref-output/simulations_11.ref (revision 8429) @@ -1,283 +1,283 @@ * Test output: simulations_11 * Purpose: apply decay * Initialize processes * Initialize simulation object * Generate event ======================================================================== - Event sample: '' + Event sample: 'simulation_11_p' Processes = 1 Unweighted = T Event norm = '1' Neg. weights = F Res. history = F Respect sel. = T Update sqme = F Update wgt = F Update event = F Recov. beams = F Pacify = F Max. tries = 10000 Integral = 7.746462203555E+03 Error = 0.000000000000E+00 Sim. valid = T Ev.file ver. = 2 MD5 sum (proc) = '5AC0462F239FFBF5B6A539F0345843FE' MD5 sum (config) = '5AC0462F239FFBF5B6A539F0345843FE' Events requested = 1 Event index = 1 Events total = 1 generated = 1 read = 0 positive weight = 1 negative weight = 0 zero weight = 0 excess weight = 0 Events dropped = 0 ------------------------------------------------------------------------ Current event: Process #1: simulation_11_p MCI set #1 Weight = 1.000000000000E+00 Zero-weight events dropped = 0 ------------------------------------------------------------------------ TAO random-number generator: seed = 0 calls = 0 ======================================================================== Process #1: Process = 'simulation_11_p' Library = 'simulation_11_lib' Run = '' is valid = T Integral = 7.746462203555E+03 Error = 0.000000000000E+00 Weight = 1.0000000000 MCI sets = 1 Events total = 1 generated = 1 read = 0 positive weight = 1 negative weight = 0 zero weight = 0 excess weight = 0 Events dropped = 0 MCI set #1: Components: 1: 'simulation_11_p_i1' Integral = 7.746462203555E+03 Error = 0.000000000000E+00 Weight = 1.0000000000 Events total = 1 generated = 1 read = 0 positive weight = 1 negative weight = 0 zero weight = 0 excess weight = 0 Events dropped = 0 ======================================================================== ======================================================================== Event #1 ------------------------------------------------------------------------ Unweighted = T Normalization = '1' Helicity handling = drop Keep correlations = F ------------------------------------------------------------------------ Squared matrix el. (ref) = 1.000000000000E+00 Squared matrix el. (prc) = 1.000000000000E+00 Event weight (ref) = 1.000000000000E+00 Event weight (prc) = 1.000000000000E+00 ------------------------------------------------------------------------ Selected MCI group = 1 Selected term = 1 Selected channel = 1 ------------------------------------------------------------------------ Passed selection = T Reweighting factor = 1.000000000000E+00 Analysis flag = T ======================================================================== Process instance [scattering]: 'simulation_11_p' Run ID = '' Process components: * 1: 'simulation_11_p_i1': s, s => s, s [test_me] status = event complete ------------------------------------------------------------------------ sqme = 1.000000000000E+00 weight = 1.000000000000E+00 ------------------------------------------------------------------------ Active MCI instance #1 = 0.10000 0.30000 x = 0.1000000000 0.3000000000 Integrand = 8.000511761705E+03 Weight = 9.682458365519E-01 Maximum = 8.000511761705E+03 Minimum = 8.000511761705E+03 Call statistics (current run): total = 1 failed kin. = 0 failed cuts = 0 passed cuts = 0 evaluated = 1 ======================================================================== ======================================================================== Event transform: trivial (hard process) ------------------------------------------------------------------------ Associated process: 'simulation_11_p' Random-number generator: test (state = 7) Number of tries = 1 ------------------------------------------------------------------------ Particle set: ------------------------------------------------------------------------ Particle 1 [i] f(25) E = 5.000000000000E+02 P = 0.000000000000E+00 0.000000000000E+00 4.841229182759E+02 T = 1.562500000000E+04 Children: 3 4 Particle 2 [i] f(25) E = 5.000000000000E+02 P = 0.000000000000E+00 0.000000000000E+00 -4.841229182759E+02 T = 1.562500000000E+04 Children: 3 4 Particle 3 [o] f(25) E = 5.000000000000E+02 P = -8.976132546819E+01 2.762569536685E+02 3.872983346207E+02 T = 1.562500000000E+04 Parents: 1 2 Particle 4 [o] f(25) E = 5.000000000000E+02 P = 8.976132546819E+01 -2.762569536685E+02 -3.872983346207E+02 T = 1.562500000000E+04 Parents: 1 2 ======================================================================== ======================================================================== Event transform: partonic decays ======================================================================== Associated process: 'simulation_11_p' Random-number generator: test (state = 7) Number of tries = 1 ------------------------------------------------------------------------ Particle set: ------------------------------------------------------------------------ Particle 1 [i] f(25) E = 5.000000000000E+02 P = 0.000000000000E+00 0.000000000000E+00 4.841229182759E+02 T = 1.562500000000E+04 Children: 3 4 Particle 2 [i] f(25) E = 5.000000000000E+02 P = 0.000000000000E+00 0.000000000000E+00 -4.841229182759E+02 T = 1.562500000000E+04 Children: 3 4 Particle 3 [r] f(25) E = 5.000000000000E+02 P = -8.976132546819E+01 2.762569536685E+02 3.872983346207E+02 T = 1.562500000000E+04 Parents: 1 2 Children: 5 6 Particle 4 [r] f(25) E = 5.000000000000E+02 P = 8.976132546819E+01 -2.762569536685E+02 -3.872983346207E+02 T = 1.562500000000E+04 Parents: 1 2 Children: 7 8 Particle 5 [o] f(6)c(1 ) E = 3.952368754828E+02 P = -7.269219222784E+01 2.237235633008E+02 3.136491673104E+02 T = 2.500000000000E+03 Parents: 3 Particle 6 [o] f(-6)c(-1 ) E = 1.047631245172E+02 P = -1.706913324035E+01 5.253339036768E+01 7.364916731037E+01 T = 2.500000000000E+03 Parents: 3 Particle 7 [o] f(6)c(2 ) E = 3.610896227967E+02 P = 8.864050770910E+01 -2.074331041616E+02 -2.774888887548E+02 T = 2.500000000000E+03 Parents: 4 Particle 8 [o] f(-6)c(-2 ) E = 1.389103772033E+02 P = 1.120817759096E+00 -6.882384950690E+01 -1.098094458659E+02 T = 2.500000000000E+03 Parents: 4 ------------------------------------------------------------------------ Variable list for simulation: [associated, not shown] ------------------------------------------------------------------------ Final-state decay tree: process ID = simulation_11_p * Selected MCI = 1 Selected term = 1 Final state: s s + Unstable: s total width = 5.729577951308E-04 error (abs) = 0.000000000000E+00 error (rel) = 0.000000000000E+00 Random-number generator: test (state = 3) Sel. decay = 1 Decay: process ID = simulation_11_d * branching ratio = 100.000000 % partial width = 5.729577951308E-04 error (abs) = 0.000000000000E+00 error (rel) = 0.000000000000E+00 Random-number generator: test (state = 3) Selected MCI = 1 Selected term = 1 Final state: f fbar + Stable: f + Stable: fbar + Unstable: s total width = 5.729577951308E-04 error (abs) = 0.000000000000E+00 error (rel) = 0.000000000000E+00 Random-number generator: test (state = 3) Sel. decay = 1 Decay: process ID = simulation_11_d * branching ratio = 100.000000 % partial width = 5.729577951308E-04 error (abs) = 0.000000000000E+00 error (rel) = 0.000000000000E+00 Random-number generator: test (state = 3) Selected MCI = 1 Selected term = 1 Final state: f fbar + Stable: f + Stable: fbar ======================================================================== Local variables: ------------------------------------------------------------------------ sqrts* = 1.000000000000E+03 sqrts_hat* => 1.000000000000E+03 n_in* => 2 n_out* => 4 n_tot* => 6 $process_id* => "simulation_11_p" process_num_id* => [unknown integer] sqme* => 1.000000000000E+00 sqme_ref* => 1.000000000000E+00 event_index* => 1 event_weight* => 1.000000000000E+00 event_weight_ref* => 1.000000000000E+00 event_excess* => 0.000000000000E+00 ------------------------------------------------------------------------ subevent: 1 prt(i:25|-5.0000000E+02; 0.0000000E+00, 0.0000000E+00,-4.8412292E+02| 1.562500000000E+04| 1) 2 prt(i:25|-5.0000000E+02; 0.0000000E+00, 0.0000000E+00, 4.8412292E+02| 1.562500000000E+04| 2) 3 prt(o:6| 3.9523688E+02;-7.2692192E+01, 2.2372356E+02, 3.1364917E+02| 2.500000000000E+03| 3) 4 prt(o:-6| 1.0476312E+02;-1.7069133E+01, 5.2533390E+01, 7.3649167E+01| 2.500000000000E+03| 4) 5 prt(o:6| 3.6108962E+02; 8.8640508E+01,-2.0743310E+02,-2.7748889E+02| 2.500000000000E+03| 5) 6 prt(o:-6| 1.3891038E+02; 1.1208178E+00,-6.8823850E+01,-1.0980945E+02| 2.500000000000E+03| 6) ======================================================================== * Cleanup * Test output end: simulations_11 Index: trunk/share/tests/unit_tests/ref-output/api_3.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_3.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_3.ref (revision 8429) @@ -0,0 +1,7 @@ +* Test output: api_3 +* Purpose: set model in advance and via Sindarin string + +model = QCD +model = QED + +* Test output end: api_3 Index: trunk/share/tests/unit_tests/ref-output/api_c_3.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_c_3.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_c_3.ref (revision 8429) @@ -0,0 +1,7 @@ +* Test output: api_c_3 +* Purpose: translate PDG code(s) to flavor string + +electron = "e-" +leptons = "e-":"m-":"t-" + +* Test output end: api_c_3 Index: trunk/share/tests/unit_tests/ref-output/api_4.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_4.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_4.ref (revision 8429) @@ -0,0 +1,7 @@ +* Test output: api_4 +* Purpose: translate PDG code(s) to flavor string + +electron = "e-" +leptons = "e-":"m-":"t-" + +* Test output end: api_4 Index: trunk/share/tests/unit_tests/ref-output/api_c_4.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_c_4.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_c_4.ref (revision 8429) @@ -0,0 +1,15 @@ +* Test output: api_c_4 +* Purpose: integrate and retrieve results + +* Process setup + + integral is unknown = 1 + +* Integrate + + integral is unknown = 0 + sqrt(s) = 10.0 GeV + cross section = 846.2 pb + error = 18.1 pb + +* Test output end: api_c_4 Index: trunk/share/tests/unit_tests/ref-output/api_5.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_5.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_5.ref (revision 8429) @@ -0,0 +1,15 @@ +* Test output: api_5 +* Purpose: integrate and retrieve results + +* Process setup + + integral is known = F + +* Integrate + + integral is known = T + sqrt(s) = 10.0 GeV + cross section = 846.2 pb + error = 18.1 pb + +* Test output end: api_5 Index: trunk/share/tests/unit_tests/ref-output/api_cc_1.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_cc_1.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_cc_1.ref (revision 8429) @@ -0,0 +1,9 @@ +* Test output: api_cc_1 +* Purpose: call init/final + +* Creating WHIZARD object +* Setting options +* Initializing WHIZARD +* Finalizing WHIZARD + +* Test output end: api_cc_1 Index: trunk/share/tests/unit_tests/ref-output/api_c_5.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_c_5.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_c_5.ref (revision 8429) @@ -0,0 +1,75 @@ +* Test output: api_c_5 +* Purpose: generate events + +Event #1 + process #1 + proc_id = api_c_5_p1 + f_scale = 5.521e+02 + alpha_s = 9.289e-02 + sqme = 3.328e-05 + weight = 8.643e-01 +Event #2 + process #1 + proc_id = api_c_5_p1 + f_scale = 8.236e+02 + alpha_s = 8.872e-02 + sqme = 6.601e-12 + weight = 4.373e-08 +Event #3 + process #1 + proc_id = api_c_5_p1 + f_scale = 9.934e+02 + alpha_s = 8.690e-02 + sqme = 1.568e-18 + weight = 3.027e-16 +Event #4 + process #1 + proc_id = api_c_5_p1 + f_scale = 5.268e+02 + alpha_s = 9.340e-02 + sqme = 1.184e-04 + weight = 3.363e+00 +Event #5 + process #1 + proc_id = api_c_5_p1 + f_scale = 5.541e+02 + alpha_s = 9.285e-02 + sqme = 7.580e-07 + weight = 1.954e-02 +Event #6 + process #1 + proc_id = api_c_5_p1 + f_scale = 8.081e+02 + alpha_s = 8.891e-02 + sqme = 1.774e-09 + weight = 1.309e-05 +Event #7 + process #1 + proc_id = api_c_5_p1 + f_scale = 3.964e+02 + alpha_s = 9.665e-02 + sqme = 1.903e-03 + weight = 6.705e+01 +Event #8 + process #1 + proc_id = api_c_5_p1 + f_scale = 8.971e+02 + alpha_s = 8.788e-02 + sqme = 1.545e-11 + weight = 5.342e-08 +Event #9 + process #1 + proc_id = api_c_5_p1 + f_scale = 6.122e+02 + alpha_s = 9.177e-02 + sqme = 9.507e-08 + weight = 1.948e-03 +Event #10 + process #2 + proc_id = api_c_5_p2 + f_scale = 6.089e+02 + alpha_s = 9.183e-02 + sqme = 1.006e-07 + weight = 2.089e-03 + +* Test output end: api_c_5 Index: trunk/share/tests/unit_tests/ref-output/api_hepmc2_1.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_hepmc2_1.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_hepmc2_1.ref (revision 8429) @@ -0,0 +1,9 @@ +* Test output: api_hepmc_1 +* Purpose: generate events + +Event #1 + n_particles = 4 +Event #2 + n_particles = 4 + +* Test output end: api_hepmc_1 Index: trunk/share/tests/unit_tests/ref-output/api_6.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_6.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_6.ref (revision 8429) @@ -0,0 +1,11 @@ +* Test output: api_6 +* Purpose: generate events + +Event #5 + sqme = 8.784E-03 + weight = 6.803E+05 +Event #6 + sqme = 8.863E-03 + weight = 6.865E+05 + +* Test output end: api_6 Index: trunk/share/tests/unit_tests/ref-output/api_cc_2.ref =================================================================== --- trunk/share/tests/unit_tests/ref-output/api_cc_2.ref (revision 0) +++ trunk/share/tests/unit_tests/ref-output/api_cc_2.ref (revision 8429) @@ -0,0 +1,14 @@ +* Test output: api_cc_2 +* Purpose: access Sindarin variables + +$job_id = api_cc_2_ID +sqrts = [unknown] + +sqrts = 100.0 +n_events = 3 +?unweighted = 0 +$sample = foobar + +?unweighted = 1 + +* Test output end: api_cc_2 Index: trunk/share/doc/manual.tex =================================================================== --- trunk/share/doc/manual.tex (revision 8428) +++ trunk/share/doc/manual.tex (revision 8429) @@ -1,17587 +1,18595 @@ \documentclass[12pt]{book} % \usepackage{feynmp} \usepackage{microtype} \usepackage{graphics,graphicx} \usepackage{color} \usepackage{amsmath,amssymb} \usepackage[colorlinks,bookmarks,bookmarksnumbered=true]{hyperref} \usepackage{thophys} \usepackage{fancyvrb} \usepackage{makeidx} \usepackage{units} \usepackage{ifpdf} %HEVEA\pdftrue \makeindex \usepackage{url} \usepackage[latin1]{inputenc} %HEVEA\@def@charset{UTF-8} %BEGIN LATEX \usepackage{supertabular,fancyvrb} \usepackage{hevea} %END LATEX \renewcommand{\topfraction}{0.9} \renewcommand{\bottomfraction}{0.8} \renewcommand{\textfraction}{0.1} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Macro section %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\email}[2]{\thanks{\ahref{#1@{}#2}{#1@{}#2}}} \newcommand{\hepforgepage}{\url{https://whizard.hepforge.org}} \newcommand{\whizardwiki}{\url{https://whizard.hepforge.org/trac/wiki}} \tocnumber %BEGIN LATEX \DeclareMathOperator{\diag}{diag} %END LATEX %BEGIN LATEX \makeatletter \newif\if@preliminary \@preliminaryfalse \def\preliminary{\@preliminarytrue} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Changes referring to article.cls % %%% Title page \def\preprintno#1{\def\@preprintno{#1}} \def\address#1{\def\@address{#1}} \def\email#1#2{\thanks{\tt #1@{}#2}} \def\abstract#1{\def\@abstract{#1}} \newcommand\abstractname{ABSTRACT} \newlength\preprintnoskip \setlength\preprintnoskip{\textwidth\@plus -1cm} \newlength\abstractwidth \setlength\abstractwidth{\textwidth\@plus -3cm} % \@titlepagetrue \renewcommand\maketitle{\begin{titlepage}% \let\footnotesize\small \hfill\parbox{\preprintnoskip}{% \begin{flushright}\@preprintno\end{flushright}}\hspace*{1cm} \vskip 60\p@ \begin{center}% {\Large\bf\boldmath \@title \par}\vskip 1cm% {\sc\@author \par}\vskip 3mm% {\@address \par}% \if@preliminary \vskip 2cm {\large\sf PRELIMINARY DRAFT \par \@date}% \fi \end{center}\par \@thanks \vfill \begin{center}% \parbox{\abstractwidth}{\centerline{\abstractname}% \vskip 3mm% \@abstract} \end{center} \end{titlepage}% \setcounter{footnote}{0}% \let\thanks\relax\let\maketitle\relax \gdef\@thanks{}\gdef\@author{}\gdef\@address{}% \gdef\@title{}\gdef\@abstract{}\gdef\@preprintno{} }% % %%% New settings of dimensions \topmargin -1.5cm \textheight 22cm \textwidth 17cm \oddsidemargin 0cm \evensidemargin 0cm % %%% Original Latex definition of citex, except for the removal of %%% 'space' following a ','. \citerange replaces the ',' by '--'. \def\@citex[#1]#2{\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi \def\@citea{}\@cite{\@for\@citeb:=#2\do {\@citea\def\@citea{,\penalty\@m}\@ifundefined {b@\@citeb}{{\bf ?}\@warning {Citation `\@citeb' on page \thepage \space undefined}}% \hbox{\csname b@\@citeb\endcsname}}}{#1}} \def\citerange{\@ifnextchar [{\@tempswatrue\@citexr}{\@tempswafalse\@citexr[]}} \def\@citexr[#1]#2{\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi \def\@citea{}\@cite{\@for\@citeb:=#2\do {\@citea\def\@citea{--\penalty\@m}\@ifundefined {b@\@citeb}{{\bf ?}\@warning {Citation `\@citeb' on page \thepage \space undefined}}% \hbox{\csname b@\@citeb\endcsname}}}{#1}} % %%% Captions set in italics \long\def\@makecaption#1#2{% \vskip\abovecaptionskip \sbox\@tempboxa{#1: \emph{#2}}% \ifdim \wd\@tempboxa >\hsize #1: \emph{#2}\par \else \hbox to\hsize{\hfil\box\@tempboxa\hfil}% \fi \vskip\belowcaptionskip} % %%% Other useful macros \def\fmslash{\@ifnextchar[{\fmsl@sh}{\fmsl@sh[0mu]}} \def\fmsl@sh[#1]#2{% \mathchoice {\@fmsl@sh\displaystyle{#1}{#2}}% {\@fmsl@sh\textstyle{#1}{#2}}% {\@fmsl@sh\scriptstyle{#1}{#2}}% {\@fmsl@sh\scriptscriptstyle{#1}{#2}}} \def\@fmsl@sh#1#2#3{\m@th\ooalign{$\hfil#1\mkern#2/\hfil$\crcr$#1#3$}} \makeatother % Labelling command for Feynman graphs generated by package FEYNMF %\def\fmfL(#1,#2,#3)#4{\put(#1,#2){\makebox(0,0)[#3]{#4}}} %END LATEX %%%% Environment for showing user input and program response \newenvironment{interaction}% {\begingroup\small \Verbatim}% {\endVerbatim \endgroup\noindent} %BEGIN LATEX %%%% Environment for typesetting listings verbatim \newenvironment{code}% {\begingroup\footnotesize \quote \Verbatim}% {\endVerbatim \endquote \endgroup\noindent} %%%% Boxed environment for typesetting listings verbatim \newenvironment{Code}% {\begingroup\footnotesize \quote \Verbatim[frame=single]}% {\endVerbatim \endquote \endgroup\noindent} %%% Environment for displaying syntax \newenvironment{syntax}% {\begin{quote} \begin{flushleft}\tt}% {\end{flushleft} \end{quote}} \newcommand{\var}[1]{$\langle$\textit{#1}$\rangle$} %END LATEX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Macros specific for this paper %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\ttt}[1]{\texttt{#1}} \newcommand{\whizard}{\ttt{WHIZARD}} \newcommand{\oMega}{\ttt{O'Mega}} \newcommand{\vamp}{\ttt{VAMP}} \newcommand{\vamptwo}{\ttt{VAMP2}} \newcommand{\vegas}{\ttt{VEGAS}} \newcommand{\madgraph}{\ttt{MadGraph}} \newcommand{\CalcHep}{\ttt{CalcHep}} \newcommand{\helas}{\ttt{HELAS}} \newcommand{\herwig}{\ttt{HERWIG}} \newcommand{\isajet}{\ttt{ISAJET}} \newcommand{\pythia}{\ttt{PYTHIA}} \newcommand{\pythiasix}{\ttt{PYTHIA6}} \newcommand{\pythiaeight}{\ttt{PYTHIA8}} \newcommand{\jetset}{\ttt{JETSET}} \newcommand{\comphep}{\ttt{CompHEP}} \newcommand{\circe}{\ttt{CIRCE}} \newcommand{\circeone}{\ttt{CIRCE1}} \newcommand{\circetwo}{\ttt{CIRCE2}} \newcommand{\gamelan}{\textsf{gamelan}} \newcommand{\stdhep}{\ttt{STDHEP}} \newcommand{\lcio}{\ttt{LCIO}} \newcommand{\pdflib}{\ttt{PDFLIB}} \newcommand{\lhapdf}{\ttt{LHAPDF}} \newcommand{\hepmc}{\ttt{HepMC}} \newcommand{\hepmcthree}{\ttt{HepMC3}} \newcommand{\fastjet}{\ttt{FastJet}} \newcommand{\hoppet}{\ttt{HOPPET}} \newcommand{\metapost}{\ttt{MetaPost}} \newcommand{\sarah}{\ttt{SARAH}} \newcommand{\spheno}{\ttt{SPheno}} \newcommand{\Mathematica}{\ttt{Mathematica}} \newcommand{\FeynRules}{\ttt{FeynRules}} \newcommand{\UFO}{\ttt{UFO}} \newcommand{\gosam}{\ttt{Gosam}} \newcommand{\openloops}{\ttt{OpenLoops}} \newcommand{\recola}{\ttt{Recola}} \newcommand{\collier}{\ttt{Collier}} \newcommand{\powheg}{\ttt{POWHEG}} \newcommand{\delphes}{\ttt{Delphes}} \newcommand{\geant}{\ttt{Geant}} \newcommand{\ROOT}{\ttt{ROOT}} \newcommand{\rivet}{\ttt{Rivet}} %%%%% \newcommand{\sindarin}{\ttt{SINDARIN}} \newcommand{\cpp}{\ttt{C++}} \newcommand{\fortran}{\ttt{Fortran}} \newcommand{\fortranSeventySeven}{\ttt{FORTRAN77}} \newcommand{\fortranNinetyFive}{\ttt{Fortran95}} \newcommand{\fortranOThree}{\ttt{Fortran2003}} \newcommand{\ocaml}{\ttt{OCaml}} \newcommand{\python}{\ttt{Python}} \newenvironment{commands}{\begin{quote}\tt}{\end{quote}} \newcommand{\eemm}{$e^+e^- \to \mu^+\mu^-$} %\def\~{$\sim$} \newcommand{\sgn}{\mathop{\rm sgn}\nolimits} \newcommand{\GeV}{\textrm{GeV}} \newcommand{\fb}{\textrm{fb}} \newcommand{\ab}{\textrm{ab}} \newenvironment{parameters}{% \begin{center} \begin{tabular}{lccp{65mm}} \hline Parameter & Value & Default & Description \\ \hline }{% \hline \end{tabular} \end{center} } \newenvironment{options}{% \begin{center} \begin{tabular}{llcp{80mm}} \hline Option & Long version & Value & Description \\ \hline }{% \hline \end{tabular} \end{center} } %BEGIN LATEX \renewenvironment{options}{% \begin{center} \tablehead{\hline Option & Long version & Value & Description \\ \hline } \begin{supertabular}{llcp{80mm}} }{% \hline \end{supertabular} \end{center} } %END LATEX %BEGIN LATEX \renewenvironment{parameters}{% \begin{center} \tablehead{\hline Parameter & Value & Default & Description \\ \hline } \begin{supertabular}{lccp{65mm}} }{% \hline \end{supertabular} \end{center} } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %END LATEX \newcommand{\thisversion}{3.0.0 $\alpha$} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %BEGIN LATEX \preprintno{} %%%\preprintno{arXiv:0708.4233 (also based on LC-TOOL-2001-039 (revised))} %END LATEX \title{% %HEVEA WHIZARD 3.0 \\ %BEGIN LATEX \ttt{\huge WHIZARD 3.0} \\[\baselineskip] %END LATEX A generic \\ Monte-Carlo integration and event generation package \\ for multi-particle processes\\[\baselineskip] MANUAL \footnote{% This work is supported by Helmholtz-Alliance ``Physics at the Terascale''. In former stages this work has also been supported by the Helmholtz-Gemeinschaft VH--NG--005 \\ E-mail: \ttt{whizard@desy.de} } \\[\baselineskip] } % \def\authormail{\ttt{kilian@physik.uni-siegen.de}, % \ttt{ohl@physik.uni-wuerzburg.de}, % \ttt{juergen.reuter@desy.de}, \ttt{cnspeckn@googlemail.com}} \author{% Wolfgang Kilian,% Thorsten Ohl,% J\"urgen Reuter,% with contributions from Fabian Bach, % Simon Bra\ss, Bijan Chokouf\'{e} Nejad, % Christian Fleper, % Vincent Rothe, % Sebastian Schmidt, % Marco Sekulla, % Christian Speckner, % So Young Shim, % Florian Staub, % Pascal Stienemeier, % Christian Weiss} %BEGIN LATEX \address{% Universit\"at Siegen, Emmy-Noether-Campus, Walter-Flex-Str. 3, D--57068 Siegen, Germany \\ Universit\"at W\"urzburg, Emil-Hilb-Weg 22, D--97074 W\"urzburg, Germany \\ Deutsches Elektronen-Synchrotron DESY, Notkestr. 85, D--22603 Hamburg, Germany \\ %% \authormail \vspace{1cm} \begin{center} \includegraphics[width=4cm]{Whizard-Logo} \end{center} \mbox{} \\ \vspace{2cm} \mbox{} when using \whizard\ please cite: \\ W. Kilian, T. Ohl, J. Reuter, \\ {\em WHIZARD: Simulating Multi-Particle Processes at LHC and ILC}, \\ Eur.Phys.J.{\bf C71} (2011) 1742, arXiv: 0708.4233 [hep-ph]; \\ M. Moretti, T. Ohl, J. Reuter, \\ {\em O'Mega: An Optimizing Matrix Element Generator}, \\ arXiv: hep-ph/0102195 } %END LATEX %BEGIN LATEX \abstract{% \whizard\ is a program system designed for the efficient calculation of multi-particle scattering cross sections and simulated event samples. The generated events can be written to file in various formats (including HepMC, LHEF, STDHEP, LCIO, and ASCII) or analyzed directly on the parton or hadron level using a built-in \LaTeX-compatible graphics package. \\[\baselineskip] Complete tree-level matrix elements are generated automatically for arbitrary partonic multi-particle processes by calling the built-in matrix-element generator \oMega. Beyond hard matrix elements, \whizard\ can generate (cascade) decays with complete spin correlations. Various models beyond the SM are implemented, in particular, the MSSM is supported with an interface to the SUSY Les Houches Accord input format. Matrix elements obtained by alternative methods (e.g., including loop corrections) may be interfaced as well. \\[\baselineskip] The program uses an adaptive multi-channel method for phase space integration, which allows to calculate numerically stable signal and background cross sections and generate unweighted event samples with reasonable efficiency for processes with up to eight and more final-state particles. Polarization is treated exactly for both the initial and final states. Quark or lepton flavors can be summed over automatically where needed. \\[\baselineskip] For hadron collider physics, we ship the package with the most recent PDF sets from the MSTW/MMHT and CTEQ/CT10/CJ12/CJ15/CT14 collaborations. Furthermore, an interface to the \lhapdf\ library is provided. \\[\baselineskip] For Linear Collider physics, beamstrahlung (\circeone, \circetwo), Compton and ISR spectra are included for electrons and photons, including the most recent ILC and CLIC collider designs. Alternatively, beam-crossing events can be read directly from file. \\[\baselineskip] For parton showering and matching/merging with hard matrix elements , fragmenting and hadronizing the final state, a first version of two different parton shower algorithms are included in the \whizard\ package. This also includes infrastructure for the MLM matching and merging algorithm. For hadronization and hadronic decays, \pythia\ and \herwig\ interfaces are provided which follow the Les Houches Accord. In addition, the last and final version of (\fortran) \pythia\ is included in the package. \\[\baselineskip] The \whizard\ distribution is available at %%% \begin{center} %%% \ttt{http://whizard.event-generator.org} %%% \end{center} %%% or at \begin{center} \url{https://whizard.hepforge.org} \end{center} where also the \ttt{svn} repository is located. } %END LATEX % \maketitle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Text %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\begin{fmffile} \tableofcontents \newpage \chapter{Introduction} \section{Disclaimer} \emph{This is a preliminary version of the WHIZARD manual. Many parts are still missing or incomplete, and some parts will be rewritten and improved soon. To find updated versions of the manual, visit the \whizard\ website} \begin{center} \hepforgepage \end{center} \emph{or consult the current version in the \ttt{svn} repository on \hepforgepage\ directly. Note, that the most recent version of the manual might contain information about features of the current \ttt{svn} version, which are not contained in the last official release version!} \emph{For information that is not (yet) written in the manual, please consult the examples in the \whizard\ distribution. You will find these in the subdirectory \ttt{share/examples} of the main directory where \whizard\ is installed. More information about the examples can be found on the \whizard\ Wiki page} \begin{center} \whizardwiki . \end{center} %%%%% \clearpage \section{Overview} \whizard\ is a multi-purpose event generator that covers all parts of event generation (unweighted and weighted), either through intrinsic components or interfaces to external packages. Realistic collider environments are covered through sophisticated descriptions for beam structures at hadron colliders, lepton colliders, lepton-hadron colliders, both circular and linear machines. Other options include scattering processes e.g. for dark matter annihilation or particle decays. \whizard\ contains its in-house generator for (tree-level) high-multiplicity matrix elements, \oMega\, that supports the whole Standard Model (SM) of particle physics and basically all possibile extensions of it. QCD parton shower describe high-multiplicity partonic jet events that can be matched with matrix elements. At the moment, only hadron collider parton distribution functions (PDFs) and hadronization are handled by packages not written by the main authors. This manual is organized mainly along the lines of the way how to run \whizard: this is done through a command language, \sindarin\ (Scripting INtegration, Data Analysis, Results display and INterfaces.) Though this seems a complication at first glance, the user is rewarded with a large possibility, flexibility and versatility on how to steer \whizard. After some general remarks in the follow-up sections, in Chap.~\ref{chap:installation} we describe how to get the program, the package structure, the prerequisites, possible external extensions of the program and the basics of the installation (both as superuser and locally). Also, a first technical overview how to work with \whizard\ on single computer, batch clusters and farms are given. Furthermore, some rare uncommon possible build problems are discussed, and a tour through options for debugging, testing and validation is being made. A first dive into the running of the program is made in Chap.~\ref{chap:start}. This is following by an extensive, but rather technical introduction into the steering language \sindarin\ in Chap.~\ref{chap:sindarinintro}. Here, the basic elements of the language like commands, statements, control structures, expressions and variables as well as the form of warnings and error messages are explained in detail. Chap.~\ref{chap:sindarin} contains the application of the \sindarin\ command language to the main tasks in running \whizard\ in a physics framework: the defintion of particles, subevents, cuts, and event selections. The specification of a particular physics models is \begin{figure}[t] \centering \includegraphics[width=0.9\textwidth]{whizstruct} \caption{General structure of the \whizard\ package.} \end{figure} discussed, while the next sections are devoted to the setup and compilation of code for particular processes, the specification of beams, beam structure and polarization. The next step is the integration, controlling the integration, phase space, generator cuts, scales and weights, proceeding further to event generation and decays. At the end of this chapter, \whizard's internal data analysis methods and graphical visualization options are documented. The following chapters are dedicated to the physics implemented in \whizard: methods for hard matrix interactions in Chap.~\ref{chap:hardint}. Then, in Chap.~\ref{chap:physics}, implemented methods for adaptive multi-channel integration, particularly the integrator \vamp\ are explained, together with the algorithms for the generation of the phase-space in \whizard. Finally, an overview is given over the physics models implemented in \whizard\ and its matrix element generator \oMega, together with possibilities for their extension. After that, the next chapter discusses parton showering, matching and hadronization as well as options for event normalizations and supported event formats. Also weighted event generation is explained along the lines with options for negative weights. Chap.~\ref{chap:visualization} is a stand-alone documentation of GAMELAN, the interal graphics support for the visualization of data and analysis. The next chapter, Chap.~\ref{chap:userint} details user interfaces: how to use more options of the \whizard\ command on the command line, how to use \whizard\ interactively, and how to include \whizard\ as a library into the user's own program. Then, an extensive list of examples in Chap.~\ref{chap:examples} documenting physics examples from the LEP, SLC, HERA, Tevatron, and LHC colliders to future linear and circular colliders. This chapter is a particular good reference for the beginning, as the whole chain from choosing a model, setting up processes, the beam structure, the integration, and finally simulation and (graphical) analysis are explained in detail. More technical details about efficiency, tuning and advance usage of \whizard\ are collected in Chap.~\ref{chap:tuning}. Then, Chap.~\ref{chap:extmodels} shows how to set up your own new physics model with the help of external programs like \sarah\ or \FeynRules\ program or the Universal Feynrules Output, UFO, and include it into the \whizard\ event generator. In the appendices, we e.g. give an exhaustive reference list of \sindarin\ commands and built-in variables. Please report any inconsistencies, bugs, problems or simply pose open questions to our contact \url{whizard@desy.de}. There is now also a support page on \texttt{Launchpad}, which offers support that is easily visible for the whole user community: \url{https://launchpad.net/whizard}. %%%%% \section{Historical remarks} This section gives a historical overview over the development of \whizard\ and can be easily skipped in a (first) reading of the manual. \whizard\ has been developed in a first place as a tool for the physics at the then planned linear electron-positron collider TESLA around 1999. The intention was to have a tool at hand to describe electroweak physics of multiple weak bosons and the Higgs boson as precise as possible with full matrix elements. Hence, the acronym: \ttt{WHiZard}, which stood for $\mathbf{W}$, {\bf H}iggs, $\mathbf{Z}$, {\bf a}nd {\bf r}espective {\bf d}ecays. Several components of the \whizard\ package that are also available as independent sub-packages have been published already before the first versions of the \whizard\ generator itself: the multi-channel adaptive Monte-Carlo integration package \vamp\ has been released mid 1998~\cite{VAMP}. The dedicated packages for the simulation of linear lepton collider beamstrahlung and the option for a photon collider on Compton backscattering (\ttt{CIRCE1/2}) date back even to mid 1996~\cite{CIRCE}. Also parts of the code for \whizard's internal graphical analysis (the \gamelan\ module) came into existence already around 1998. After first inofficial versions, the official version 1 of \whizard\ was release in the year 2000. The development, improvement and incorporation of new features continued for roughly a decade. Major milestones in the development were the full support of all kinds of beyond the Standard Model (BSM) models including spin 3/2 and spin 2 particles and the inclusion of the MSSM, the NMSSM, Little Higgs models and models for anomalous couplings as well as extra-dimensional models from version 1.90 on. In the beginning, several methods for matrix elements have been used, until the in-house matrix element generator \oMega\ became available from version 1.20 on. It was included as a part of the \whizard\ package from version 1.90 on. The support for full color amplitudes came with version 1.50, but in a full-fledged version from 2.0 on. Version 1.40 brought the necessary setups for all kinds of collider environments, i.e. asymmetric beams, decay processes, and intrinsic $p_T$ in structure functions. Version 2.0 was released in April 2010 as an almost complete rewriting of the original code. It brought the construction of an internal density-matrix formalism which allowed the use of factorized production and (cascade) decay processes including complete color and spin correlations. Another big new feature was the command-line language \sindarin\ for steering all parts of the program. Also, many performance improvement have taken place in the new release series, like OpenMP parallelization, speed gain in matrix element generation etc. Version 2.2 came out in May 2014 as a major refactoring of the program internals but keeping (almost everywhere) the same user interface. New features are inclusive processes, reweighting, and more interfaces for QCD environments (BLHA/HOPPET). The following tables shows some of the major steps (physics implementation and/or technical improvements) in the development of \whizard (we break the table into logical and temporal blocks of \whizard\ development): \begin{center} \begin{tabular}{|l|l|l|}\hline 0.99 & 08/1999 & Beta version \\\hline 1.00 & 12/2000 & First public version \\\hline 1.10 & 03/2001 & Libraries; \pythiasix\ interface \\ 1.11 & 04/2001 & PDF support; anomalous couplings \\ \hline 1.20 & 02/2002 & \oMega\ matrix elements; \ttt{CIRCE} support\\ 1.22 & 03/2002 & QED ISR; beam remnants, phase space improvements \\ 1.25 & 05/2003 & MSSM; weighted events; user-code plug-in \\ 1.28 & 04/2004 & Improved phase space; SLHA interface; signal catching \\\hline 1.30 & 09/2004 & Major technical overhaul \\\hline 1.40 & 12/2004 & Asymmetric beams; decays; $p_T$ in structure functions \\\hline 1.50 & 02/2006 & QCD support in \oMega\ (color flows); LHA format \\ 1.51 & 06/2006 & $Hgg$, $H\gamma\gamma$; Spin 3/2 + 2; BSM models \\\hline 1.90 & 11/2007 & \oMega\ included; LHAPDF support; $Z'$; $WW$ scattering \\ 1.92 & 03/2008 & LHE format; UED; parton shower beta version \\ 1.93 & 04/2009 & NMSSM; SLHA2 accord; improved color/flavor sums \\ 1.95 & 02/2010 & MLM matching; development stop in version 1 \\ 1.97 & 05/2011 & Manual for version 1 completed. \\\hline\hline \end{tabular} \end{center} \begin{center} \begin{tabular}{|l|l|l|}\hline 2.0.0 & 04/2010 & Major refactoring: automake setup; dynamic libraries \\ & & improved speed; cascades; OpenMP; \sindarin\ steering language \\ 2.0.3 & 07/2010 & QCD ISR+FSR shower; polarized beams \\ 2.0.5 & 05/2011 & Builtin PDFs; static builds; relocation scripts \\ 2.0.6 & 12/2011 & Anomalous top couplings; unit tests \\\hline 2.1.0 & 06/2012 & Analytic ISR+FSR parton shower; anomalous Higgs couplings \\\hline 2.2.0 & 05/2014 & Major technical refactoring: abstract object-orientation; THDM; \\ & & reweighting; LHE v2/3; BLHA; HOPPET interface; inclusive processes \\ 2.2.1 & 05/2014 & CJ12 PDFs; FastJet interface \\ 2.2.2 & 07/2014 & LHAPDF6 support; correlated LC beams; GuineaPig interface \\ 2.2.3 & 11/2014 & O'Mega virtual machine; lepton collider top pair threshold; \\ & & Higgs singlet extension \\ 2.2.4 & 02/2015 & LCIO support; progress on NLO; many technical bug fixes \\ 2.2.7 & 08/2015 & progress on POWHEG; fixed-order NLO events; \\ & & revalidation of ILC event chain \\ 2.2.8 & 11/2015 & support for quadruple precision; StdHEP included; \\ & & SM dim 6 operators supported \\\hline \end{tabular} \end{center} \begin{center} \begin{tabular}{|l|l|l|}\hline 2.3.0 & 07/2016 & NLO: resonance mappings for FKS subtraction; \\ & & more advanced cascade syntax; \\ & & GUI ($\alpha$ version); UFO support ($\alpha$ version); ILC v1.9x-v2.x final validation \\ 2.3.1 & 08/2016 & Complex mass scheme \\\hline 2.4.0 & 11/2016 & Refactoring of NLO setup \\ 2.4.1 & 03/2017 & $\alpha$ version of new VEGAS implementation \\\hline 2.5.0 & 05/2017 & Full UFO support (SM-like models) \\\hline 2.6.0 & 09/2017 & MPI parallel integration and event generation; resonance histories \\ & & for showers; RECOLA support \\ 2.6.1 & 11/2017 & EPA/ISR transverse distributions, handling of shower resonances; \\ & & more efficient (alternative) phase space generation \\ 2.6.2 & 12/2017 & $Hee$ coupling, improved resonance matching \\ 2.6.3 & 02/2018 & Partial NLO refactoring for quantum numbers, \\ & & unified RECOLA 1/2 interface. \\ 2.6.4 & 08/2018 & Gridpack functionality; Bug fixes: color flows, HSExt model, MPI setup \\\hline 2.7.0 & 01/2019 & PYTHIA8 interface, process setup refactoring, RAMBO PS option; \\ & & \quad gfortran 5.0+ necessary \\\hline 2.8.0 & 08/2019 & (Almost) complete UFO support, general Lorentz structures, n-point vertices \\ 2.8.1 & 09/2019 & HepMC3, NLO QCD pp (almost) complete, b/c jet selection, photon isolation \\ 2.8.2 & 10/2019 & Support for OCaml $\geq$ 4.06.0, UFO Spin-2 support, LCIO alternative weights \\ 2.8.3 & 07/2020 & UFO Majorana feature complete, many $e^+e^-$ related improvements \\ 2.8.4 & 07/2020 & Bug fix for UFO Majorana models \\\hline\hline \end{tabular} \end{center} \vspace{.5cm} For a detailed overview over the historical development of the code confer the \ttt{ChangeLog} file and the commit messages in our revision control system repository. %%%%% \section{About examples in this manual} Although \whizard\ has been designed as a Monte Carlo event generator for LHC physics, several elementary steps and aspects of its usage throughout the manual will be demonstrated with the famous textbook example of $e^+e^- \to \mu^+ \mu^-$. This is the same process, the textbook by Peskin/Schroeder \cite{PeskinSchroeder} uses as a prime example to teach the basics of quantum field theory. We use this example not because it is very special for \whizard\ or at the time being a relevant physics case, but simply because it is the easiest fundamental field theoretic process without the complications of structured beams (which can nevertheless be switched on like for ISR and beamstrahlung!), the need for jet definitions/algorithms and flavor sums; furthermore, it easily accomplishes a demonstration of polarized beams. After the basics of \whizard\ usage have been explained, we move on to actual physics cases from LHC (or Tevatron). \newpage \chapter{Installation} \label{chap:installation} \section{Package Structure} \whizard\ is a software package that consists of a main executable program (which is called \ttt{whizard}), libraries, auxiliary executable programs, and machine-independent data files. The whole package can be installed by the system administrator, by default, on a central location in the file system (\ttt{/usr/local} with its proper subdirectories). Alternatively, it is possible to install it in a user's home directory, without administrator privileges, or at any other location. A \whizard\ run requires a workspace, i.e., a writable directory where it can put generated code and data. There are no constraints on the location of this directory, but we recommend to use a separate directory for each \whizard\ project, or even for each \whizard\ run. Since \whizard\ generates the matrix elements for scattering and decay processes in form of \fortran\ code that is automatically compiled and dynamically linked into the running program, it requires a working \fortran\ compiler not just for the installation, but also at runtime. The previous major version \whizard1 did put more constraints on the setup. In a nutshell, not just the matrix element code was compiled at runtime, but other parts of the program as well, so the whole package was interleaved and had to be installed in user space. The workflow was controlled by \ttt{make} and PERL scripts. These constraints are gone in the present version in favor of a clean separation of installation and runtime workspace. \section{\label{sec:prerequisites}Prerequisites} \subsection{No Binary Distribution} \whizard\ is currently not distributed as a binary package, nor is it available as a debian or RPM package. This might change in the future. However, compiling from source is very simple (see below). Since the package needs a compiler also at runtime, it would not work without some development tools installed on the machine, anyway. Note, however, that we support an install script, that downloads all necessary prerequisites, and does the configuration and compilation described below automatically. This is called the ``instant WHIZARD'' and is accessible through the WHIZARD webpage from version 2.1.1 on: \url{https://whizard.hepforge.org/versions/install/install-whizard-2.X.X.sh}. Download this shell script, make it executable by \begin{interaction} chmod +x install-whizard-2.X.X.sh \end{interaction} and execute it. Note that this also involves compilation of the required \ttt{Fortran} compiler which takes 1-3 hours depending on your system. \ttt{Darwin} operating systems (a.k.a. as \ttt{Mac OS X}) have a very similar general system for all sorts of software, called \ttt{MacPorts} (\url{http://www.macports.org}). This offers to install \whizard\ as one of its software ports, and is very similar to ``instant WHIZARD'' described above. \subsection{Tarball Distribution} This is the recommended way of obtaining \whizard. You may download the current stable distribution from the \whizard\ webpage, hosted at the HepForge webpage \begin{quote} \hepforgepage \end{quote} The distribution is a single file, say \ttt{whizard-\thisversion.tgz} for version \thisversion. You need the additional prerequisites: \begin{itemize} \item GNU \ttt{tar} (or \ttt{gunzip} and \ttt{tar}) for unpacking the tarball. \item The \ttt{make} utility. Other standard Unix utilities (\ttt{sed}, \ttt{grep}, etc.) are usually installed by default. \item A modern \fortran\ compiler (see Sec.~\ref{sec:compilers} for details). \item The \ocaml\ system. \ocaml\ is a functional and object-oriented language. Version 4.02.3 or newer is required to compile all components of \whizard. The package is freely available either as a debian/RPM package on your system (it might be necessary to install it from the usual repositories), or you can obtain it directly from \begin{quote} \url{http://caml.inria.fr} \end{quote} and install it yourself. If desired, the package can be installed in user space without administrator privileges\footnote{ Unfortunately, the version of the \ocaml\ compiler from 3.12.0 broke backwards compatibility. Therefore, versions of \oMega/\whizard\ up to 2.0.2 only compile with older versions (3.11.x works). This has been fixed in versions 2.0.3 and later. See also Sec.~\ref{sec:buildproblems}. \whizard\ versions up to 2.7.1 were still backwards compatible with \ocaml\ 3.12.0}. \end{itemize} The following optional external packages are not required, but used for certain purposes. Make sure to check whether you will need any of them, before you install \whizard. \begin{itemize} \item \LaTeX\ and \metapost\ for data visualization. Both are part of the \TeX\ program family. These programs are not absolutely necessary, but \whizard\ will lack the tools for visualization without them. \item The \lhapdf\ structure-function library. See Sec.~\ref{sec:lhapdf_install}. \item The \hoppet\ structure-function matching tool. See Sec.~\ref{sec:hoppet}. \item The \hepmc\ event-format package. See Sec.~\ref{sec:hepmc}. \item The \fastjet\ jet-algorithm package. See Sec.~\ref{sec:fastjet}. \item The \lcio\ event-format package. See Sec.~\ref{sec:lcio}. \end{itemize} Until version v2.2.7 of \whizard, the event-format package \stdhep\ used to be available as an external package. As their distribution is frozen with the final version v5.06.01, and it used to be notoriously difficult to compile and link \stdhep\ into \whizard, it was decided to include \stdhep\ into \whizard. This is the case from version v2.2.8 of \whizard\ on. Linking against an external version of \stdhep\ is precluded from there on. Nevertheless, we list some explanations in Sec.~\ref{sec:stdhep}, particularly on the need to install the \ttt{libtirpc} headers for the legacy support of this event format. Once these prerequisites are met, you may unpack the package in a directory of your choice \begin{quote}\small\tt some-directory> tar xzf whizard-\thisversion.tgz \end{quote} and proceed.\footnote{Without GNU \ttt{tar}, this would read \ttt{\small gunzip -c whizard-\thisversion.tgz | tar xz -}} For using external physics models that are directly supported by \whizard\ and \oMega, the user can use tools like \sarah\ or \FeynRules. There installation and linking to \whizard\ will be explained in Chap.~\ref{chap:extmodels}. Besides this, also new models can be conveniently included via \UFO\ files, which will be explained as well in that chapter. The directory will then contain a subdirectory \ttt{whizard-\thisversion} where the complete source tree is located. To update later to a new version, repeat these steps. Each new version will unpack in a separate directory with the appropriate name. \subsection{SVN Repository Version} If you want to install the latest development version, you have to check it out from the \whizard\ SVN repository. In addition to the prerequisites listed in the previous section, you need: \begin{itemize} \item The \ttt{subversion} package (\ttt{svn}), the tool for dealing with SVN repositories. \item The \ttt{autoconf} package, part of the \ttt{autotools} development system. \ttt{automake} is needed with version \ttt{1.12.2} or newer. \item The \ttt{noweb} package, a light-weight tool for literate programming. This package is nowadays often part of Linux distributions\footnote{In Ubuntu from version 10.04 on, and in Debian since squeeze. For \ttt{Mac OS X}, \ttt{noweb} is available via the \ttt{MacPorts} system.}. You can obtain the source code from\footnote{Please, do not use any of the binary builds from this webpage. Probably all of them are quite old and broken.} \begin{quote} \url{http://www.cs.tufts.edu/~nr/noweb/} \end{quote} \end{itemize} To start, go to a directory of your choice and execute \begin{interaction} your-src-directory> svn checkout svn+ssh://vcs@phab.hepforge.org/source/whizardsvn/trunk \;\; . \end{interaction} Note that for the time being after the HepForge system modernization early September 2018, a HepForge account with a local ssl key is necessary to checkout the subversion repository. This is enforced by the phabricator framework of HepForge, and will hopefully be relaxed in the future. The SVN source tree will appear in the current directory. To update later, you just have to execute \begin{interaction} your-src-directory> svn update \end{interaction} within that directory. After checking out the sources, you first have to create \ttt{configure.ac} by executing the shell script \ttt{build\_master.sh}. In order to build the \ttt{configure} script, the \ttt{autotools} package \ttt{autoreconf} has to be run. On some \ttt{Unix} systems the \ttt{RPC} headers needed for the legacy support of the \stdhep\ event format are provided by the \ttt{TIRPC} library (cf. Sec.~\ref{sec:stdhep}). To easily check for them, \ttt{configure.ac} processed by \ttt{autoreconf} makes use of the \ttt{pkg-config} tool which needs to be installed for the developer version. So now, run\footnote{At least, version 2.65 of the \ttt{autoconf} package is required.} \begin{interaction} your-src-directory> autoreconf \end{interaction} This will generate a \ttt{configure} script. \subsection{\label{sec:compilers}Fortran Compilers} \whizard\ is written in modern \fortran. To be precise, it uses a subset of the \fortranOThree\ standard. At the time of this writing, this subset is supported by, at least, the following compilers: \begin{itemize} \item \ttt{gfortran} (GNU, Open Source). You will need version 5.1.0 or higher\footnote{Note that \whizard\ versions 2.0.0 until 2.3.1 compiled with \ttt{gfortran} 4.7.4, but the object-oriented refactoring of the \whizard\ code from 2.4.0 on until version 2.6.5 made a switch to \ttt{gfortran} 4.8.4 or higher necessary. In the same way, since version 2.7.0, \ttt{gfortran} 5.1.0 or newer is needed}. We recommend to use at least version 5.4 or higher, as especially the the early version of the \texttt{gfortran} experience some bugs. \ttt{gfortran} 6.5.0 has a severe regression and cannot be used. \item \ttt{nagfor} (NAG). You will need version 6.2 or higher. \item \ttt{ifort} (Intel). You will need version 19.0.2 or higher \end{itemize} %%%%% \subsection{LHAPDF} \label{sec:lhapdf_install} For computing scattering processes at hadron colliders such as the LHC, \whizard\ has a small set of standard structure-function parameterizations built in, cf.\ Sec.~\ref{sec:built-in-pdf}. For many applications, this will be sufficient, and you can skip this section. However, if you need structure-function parameterizations that are not in the default set (e.g. PDF error sets), you can use the \lhapdf\ structure-function library, which is an external package. It has to be linked during \whizard\ installation. For use with \whizard, version 5.3.0 or higher of the library is required\footnote{ Note that PDF sets which contain photons as partons are only supported with \whizard\ for \lhapdf\ version 5.7.1 or higher}. The \lhapdf\ package has undergone a major rewriting from \fortran\ version 5 to \ttt{C++} version 6. While still maintaining the interface for the \lhapdf\ version 5 series, from version 2.2.2 of \whizard\ on, the new release series of \lhapdf, version 6.0 and higher, is also supported. If \lhapdf\ is not yet installed on your system, you can download it from \begin{quote} \url{https://lhapdf.hepforge.org} \end{quote} for the most recent LHAPDF version 6 and newer, or \begin{quote} \url{https://lhapdf.hepforge.org/lhapdf5} \end{quote} for version 5 and older, and install it. The website contains comprehensive documentation on the configuring and installation procedure. Make sure that you have downloaded and installed not just the package, but also the data sets. Note that \lhapdf\ version 5 needs both a \fortran\ and a \ttt{C++} compiler. During \whizard\ configuration, \whizard\ looks for the script \ttt{lhapdf} (which is present in \lhapdf\ series 6) first, and then for \ttt{lhapdf-config} (which is present since \lhapdf\ version 4.1.0): if those are in an executable path (or only the latter for \lhapdf\ version 5), the environment variables for \lhapdf\ are automatically recognized by \whizard, as well as the version number. This should look like this in the \ttt{configure} output (for \lhapdf\ version 6 or newer), \begin{footnotesize} \begin{verbatim} configure: -------------------------------------------------------------- configure: --- LHAPDF --- configure: checking for lhapdf... /usr/local/bin/lhapdf checking for lhapdf-config... /usr/local/bin/lhapdf-config checking the LHAPDF version... 6.2.1 checking the major version... 6 checking the LHAPDF pdfsets path... /usr/local/share/LHAPDF checking the standard PDF sets... all standard PDF sets installed checking if LHAPDF is functional... yes checking LHAPDF... yes configure: -------------------------------------------------------------- \end{verbatim} \end{footnotesize} while for \lhapdf\ version 5 and older it looks like this: \begin{footnotesize} \begin{verbatim} configure: -------------------------------------------------------------- configure: --- LHAPDF --- configure: checking for lhapdf... no checking for lhapdf-config... /usr/local/bin/lhapdf-config checking the LHAPDF version... 5.9.1 checking the major version... 5 checking the LHAPDF pdfsets path... /usr/local/share/lhapdf/PDFsets checking the standard PDF sets... all standard PDF sets installed checking for getxminm in -lLHAPDF... yes checking for has_photon in -lLHAPDF... yes configure: -------------------------------------------------------------- \end{verbatim} \end{footnotesize} If you want to use a different \lhapdf\ (e.g. because the one installed on your system by default is an older one), the preferred way to do so is to put the \ttt{lhapdf} (and/or \ttt{lhapdf-config}) scripts in an executable path that is checked before the system paths, e.g. \ttt{/bin}. For the old series, \lhapdf\ version 5, a possible error could arise if \lhapdf\ had been compiled with a different \fortran\ compiler than \whizard, and if the run-time library of that \fortran\ compiler had not been included in the \whizard\ configure process. The output then looks like this: \begin{footnotesize} \begin{verbatim} configure: -------------------------------------------------------------- configure: --- LHAPDF --- configure: checking for lhapdf... no checking for lhapdf-config... /usr/local/bin/lhapdf-config checking the LHAPDF version... 5.9.1 checking the major version... 5 checking the LHAPDF pdfsets path... /usr/local/share/lhapdf/PDFsets checking for standard PDF sets... all standard PDF sets installed checking for getxminm in -lLHAPDF... no checking for has_photon in -lLHAPDF... no configure: -------------------------------------------------------------- \end{verbatim} \end{footnotesize} So, the \whizard\ configure found the \lhapdf\ distribution, but could not link because it could not resolve the symbols inside the library. In case of failure, for more details confer the \ttt{config.log}. If \lhapdf\ is installed in a non-default directory where \whizard\ would not find it, set the environment variable \ttt{LHAPDF\_DIR} to the correct installation path when configuring \whizard. The check for the standard PDF sets are those sets that are used in the default \whizard\ self tests in the case \lhapdf\ is enabled and correctly linked. If some of them are missing, then this test will result in a failure. They are the \ttt{CT10} set for \lhapdf\ version 6 (for version 5, \ttt{cteq61.LHpdf}, \ttt{cteq6ll.LHpdf}, \ttt{cteq5l.LHgrid}, and \ttt{GSG961.LHgrid} are demanded). If you want to use \lhapdf\ inside \whizard\ please install them such that \whizard\ could perform all its sanity checks with them. The last check is for the \ttt{has\_photon} flag, which tests whether photon PDFs are available in the found \lhapdf\ installation. %%%%% \subsection{HOPPET} \label{sec:hoppet} \hoppet\ (not Hobbit) is a tool for the QCD DGLAP evolution of PDFs for hadron colliders. It provides possibilities for matching algorithms for 4- and 5-flavor schemes, that are important for precision simulations of $b$-parton initiated processes at hadron colliders. If you are not interested in those features, you can skip this section. Note that this feature is not enabled by default (unlike e.g. \lhapdf), but has to be explicitly during the configuration (see below): \begin{interaction} your-build-directory> your-src-directory/configure --enable-hoppet \end{interaction} If you \ttt{configure} messages like the following: \begin{footnotesize} \begin{verbatim} configure: -------------------------------------------------------------- configure: --- HOPPET --- configure: checking for hoppet-config... /usr/local/bin/hoppet-config checking for hoppetAssign in -lhoppet_v1... yes checking the HOPPET version... 1.2.0 configure: -------------------------------------------------------------- \end{verbatim} \end{footnotesize} then you know that \hoppet\ has been found and was correctly linked. If that is not the case, you have to specify the location of the \hoppet\ library, e.g. by adding \begin{interaction} HOPPET=/lib \end{interaction} to the \ttt{configure} options above. For more details, please confer the \hoppet\ manual. %%%%% \subsection{HepMC} \label{sec:hepmc} With version 2.8.1, \whizard\ supports both the "classical" version 2 as well as the newly designed version 3 (release 2019). The configure step can successfully recognize the two different versions, the user do not have to specify which version is installed. \hepmc\ is a \ttt{C++} class library for handling collider scattering events. In particular, it provides a portable format for event files. If you want to use this format, you should link \whizard\ with \hepmc, otherwise you can skip this section. If it is not already installed on your system, you may obtain \hepmc\ from one of these two webpages: \begin{quote} \url{http://hepmc.web.cern.ch/hepmc/} \end{quote} or \begin{quote} \url{http://hepmc.web.cern.ch/hepmc/} \end{quote} If the \hepmc\ library is linked with the installation, \whizard\ is able to read and write files in the \hepmc\ format. Detailed information on the installation and usage can be found on the \hepmc\ homepage. We give here only some brief details relevant for the usage with \whizard: For the compilation of HepMC one needs a \ttt{C++} compiler. Then the procedure is the same as for the \whizard\ package, namely configure HepMC: \begin{interaction} configure --with-momentum=GEV --with-length=MM --prefix= \end{interaction} Note that the particle momentum and decay length flags are mandatory, and we highly recommend to set them to the values \ttt{GEV} and \ttt{MM}, respectively. After configuration, do \ttt{make}, an optional \ttt{make check} (which might sometimes fail for non-standard values of momentum and length), and finally \ttt{make install}. The latest version of \hepmc\ (2.6.10) as well as the new relase series use \texttt{cmake} for their build process. For more information, confer the \hepmc\ webpage. A \whizard\ configuration for \hepmc\ looks like this: \begin{footnotesize} \begin{verbatim} configure: -------------------------------------------------------------- configure: --- HepMC --- configure: checking for HepMC-config... no checking HepMC3 or newer... no configure: HepMC3 not found, incompatible, or HepMC-config not found configure: looking for HepMC2 instead ... checking the HepMC version... 2.06.10 checking for GenEvent class in -lHepMC... yes configure: -------------------------------------------------------------- \end{verbatim} \end{footnotesize} If \hepmc\ is installed in a non-default directory where \whizard\ would not find it, set the environment variable \ttt{HEPMC\_DIR} to the correct installation path when configuring \whizard. Furthermore, the environment variable \ttt{CXXFLAGS} allows you to set specific \ttt{C/C++} preprocessor flags, e.g. non-standard include paths for header files. A typical configuration of \hepmcthree\ will look like this: \begin{footnotesize} \begin{verbatim} configure: -------------------------------------------------------------- configure: --- ROOT --- configure: checking for root-config... /usr/local/bin/root-config checking for root... /usr/local/bin/root checking for rootcint... /usr/local/bin/rootcint checking for dlopen in -ldl... (cached) yes configure: -------------------------------------------------------------- configure: --- HepMC --- configure: checking for HepMC3-config... /usr/local/bin/HepMC3-config checking if HepMC3 is built with ROOT interface... yes checking if HepMC3 is functional... yes checking for HepMC3... yes checking the HepMC3 version... 3.02.01 configure: -------------------------------------------------------------- \end{verbatim} \end{footnotesize} As can be seen, \whizard\ will check for the \ROOT\ environment as well as whether \hepmcthree\ has been built with support for the \ROOT\ and \ttt{RootTree} writer classes. This is an easy option to use \whizard\ to write out \ROOT\ events. For more information see Sec.~\ref{sec:root}. %%%%% \subsection{PYTHIA8} \label{sec:pythia8} \emph{NOTE: This is at the moment not yet supported, but merely a stub with the only purpose to be recognized by the build system.} \pythiaeight\ is a \ttt{C++} class library for handling hadronization, showering and underlying event. If you want to use this feature (once it is fully supported in \whizard), you should link \whizard\ with \pythiaeight, otherwise you can skip this section. If it is not already installed on your system, you may obtain \pythiaeight\ from \begin{quote} \url{http://home.thep.lu.se/~torbjorn/Pythia.html} \end{quote} If the \pythiaeight\ library is linked with the installation, \whizard\ will be able to use its hadronization and showering, once this is fully supported within \whizard. To link a \pythiaeight\ installation to \whizard, you should specify the flag \begin{quote} \ttt{--enable-pythia8} \end{quote} to \ttt{configure}. If \pythiaeight\ is installed in a non-default directory where \whizard\ would not find it, specify also \begin{quote} \ttt{--with-pythia8=\emph{}} \end{quote} A successful \whizard\ configuration should produce a screen output similar to this: \begin{footnotesize} \begin{verbatim} configure: -------------------------------------------------------------- configure: --- SHOWERS PYTHIA6 PYTHIA8 MPI --- configure: [....] checking for pythia8-config... /usr/local/bin/pythia8-config checking if PYTHIA8 is functional... yes checking PYTHIA8... yes configure: WARNING: PYTHIA8 configure is for testing purposes at the moment. configure: -------------------------------------------------------------- \end{verbatim} \end{footnotesize} %%%%% \subsection{FastJet} \label{sec:fastjet} \fastjet\ is a \ttt{C++} class library for handling jet clustering. If you want to use this feature, you should link \whizard\ with \fastjet, otherwise you can skip this section. If it is not already installed on your system, you may obtain \fastjet\ from \begin{quote} \url{http://fastjet.fr} \end{quote} If the \fastjet\ library is linked with the installation, \whizard\ is able to call the jet algorithms provided by this program for the purposes of applying cuts and analysis. To link a \fastjet\ installation to \whizard, you should specify the flag \begin{quote} \ttt{--enable-fastjet} \end{quote} to \ttt{configure}. If \fastjet\ is installed in a non-default directory where \whizard\ would not find it, specify also \begin{quote} \ttt{--with-fastjet=\emph{}} \end{quote} A successful \whizard\ configuration should produce a screen output similar to this: \begin{footnotesize} \begin{verbatim} configure: -------------------------------------------------------------- configure: --- FASTJET --- configure: checking for fastjet-config... /usr/local/bin/fastjet-config checking if FastJet is functional... yes checking FastJet... yes checking the FastJet version... 3.3.0 configure: -------------------------------------------------------------- \end{verbatim} \end{footnotesize} %%%%% \subsection{STDHEP} \label{sec:stdhep} \stdhep\ is a library for handling collider scattering events~\cite{stdhep}. In particular, it provides a portable format for event files. Until version 2.2.7 of \whizard, \stdhep\ that was maintained by Fermilab, could be linked as an externally compiled library. As the \stdhep\ package is frozen in its final release v5.06.1 and no longer maintained, it has from version 2.2.8 been included \whizard. This eases many things, as it was notoriously difficult to compile and link \stdhep\ in a way compatible with \whizard. Not the full package has been included, but only the libraries for file I/O (\ttt{mcfio}, the library for the XDR conversion), while the various translation tools for \pythia, \herwig, etc. have been abandoned. Note that \stdhep\ has largely been replaced in the hadron collider community by the \hepmc\ format, and in the lepton collider community by \lcio. \whizard\ might serve as a conversion tools for all these formats, but other tools also exist, of course. Note that the \ttt{mcfio} framework makes use of the \ttt{RPC} headers. These come -- provided by \ttt{SunOS/Oracle America, Inc.} -- together with the system headers, but on some \ttt{Unix} systems (e.g. \ttt{ArchLinux}, \ttt{Fedora}) have been replaced by the \ttt{libtirpc} headers . The \ttt{configure} script searches for these headers so these have to be installed mandatorily. If the \stdhep\ library is linked with the installation, \whizard\ is able to write files in the \stdhep\ format, the corresponding configure output notifies you that \stdhep\ is always included: \begin{footnotesize} \begin{verbatim} configure: -------------------------------------------------------------- configure: --- STDHEP --- configure: checking for pkg-config... /opt/local/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for libtirpc... no configure: for StdHEP legacy code: using SunRPC headers and library configure: StdHEP v5.06.01 is included internally configure: -------------------------------------------------------------- \end{verbatim} \end{footnotesize} %%%%% \subsection{LCIO} \label{sec:lcio} \lcio\ is a \ttt{C++} class library for handling collider scattering events. In particular, it provides a portable format for event files. If you want to use this format, you should link \whizard\ with \lcio, otherwise you can skip this section. If it is not already installed on your system, you may obtain \lcio\ from: \begin{quote} \url{http://lcio.desy.de} \end{quote} If the \lcio\ library is linked with the installation, \whizard\ is able to read and write files in the \lcio\ format. Detailed information on the installation and usage can be found on the \lcio\ homepage. We give here only some brief details relevant for the usage with \whizard: For the compilation of \lcio\ one needs a \ttt{C++} compiler. \lcio\ is based on \ttt{cmake}. For the corresponding options please confer the \lcio\ manual. A \whizard\ configuration for \lcio\ looks like this: \begin{footnotesize} \begin{verbatim} configure: -------------------------------------------------------------- configure: --- LCIO --- configure: checking the LCIO version... 2.12.1 checking for LCEventImpl class in -llcio... yes configure: -------------------------------------------------------------- \end{verbatim} \end{footnotesize} If \lcio\ is installed in a non-default directory where \whizard\ would not find it, set the environment variable \ttt{LCIO} or \ttt{LCIO\_DIR} to the correct installation path when configuring \whizard. The first one is the variable exported by the \ttt{setup.sh} script while the second one is analogous to the environment variables of other external packages. \ttt{LCIO} takes precedence over \ttt{LCIO\_DIR}. Furthermore, the environment variable \ttt{CXXFLAGS} allows you to set specific \ttt{C/C++} preprocessor flags, e.g. non-standard include paths for header files. %%%%% \section{Installation} \label{sec:installation} Once you have unpacked the source (either the tarball or the SVN version), you are ready to compile it. There are several options. \subsection{Central Installation} This is the default and recommended way, but it requires adminstrator privileges. Make sure that all prerequisites are met (Sec.~\ref{sec:prerequisites}). \begin{enumerate} \item Create a fresh directory for the \whizard\ build. It is recommended to keep this separate from the source directory. \item Go to that directory and execute \begin{interaction} your-build-directory> your-src-directory/configure \end{interaction} This will analyze your system and prepare the compilation of \whizard\ in the build directory. Make sure to set the proper options to \ttt{configure}, see Sec.~\ref{sec:configure-options} below. \item Call \ttt{make} to compile and link \whizard: \begin{interaction} your-build-directory> make \end{interaction} \item If you want to make sure that everything works, run \begin{interaction} your-build-directory> make check \end{interaction} This will take some more time. \item Become superuser and say \begin{interaction} your-build-directory> make install \end{interaction} \end{enumerate} \whizard\ should now installed in the default locations, and the executable should be available in the standard path. Try to call \ttt{whizard --help} in order to check this. \subsection{Installation in User Space} You may lack administrator privileges on your system. In that case, you can still install and run \whizard. Make sure that all prerequisites are met (Sec.~\ref{sec:prerequisites}). \begin{enumerate} \item Create a fresh directory for the \whizard\ build. It is recommended to keep this separate from the source directory. \item Reserve a directory in user space for the \whizard\ installation. It should be empty, or yet non-existent. \item Go to that directory and execute \begin{interaction} your-build-directory> your-src-directory/configure --prefix=your-install-directory \end{interaction} This will analyze your system and prepare the compilation of \whizard\ in the build directory. Make sure to set the proper additional options to \ttt{configure}, see Sec.~\ref{sec:configure-options} below. \item Call \ttt{make} to compile and link \whizard: \begin{interaction} your-build-directory> make \end{interaction} \item If you want to make sure that everything works, run \begin{interaction} your-build-directory> make check \end{interaction} This will take some more time. \item Install: \begin{interaction} your-build-directory> make install \end{interaction} \end{enumerate} \whizard\ should now be installed in the installation directory of your choice. If the installation is not in your standard search paths, you have to account for this by extending the paths appropriately, see Sec.~\ref{sec:workspace}. \subsection{Configure Options} \label{sec:configure-options} The configure script accepts environment variables and flags. They can be given as arguments to the \ttt{configure} program in arbitrary order. You may run \ttt{configure --help} for a listing; only the last part of this long listing is specific for the \whizard\ system. Here is an example: \begin{interaction} configure FC=gfortran-5.4 FCFLAGS="-g -O3" --enable-fc-openmp \end{interaction} The most important options are \begin{itemize} \item \ttt{FC} (variable): The \fortran\ compiler. This is necessary if you need a compiler different from the standard compiler on the system, e.g., if the latter is too old. \item \ttt{FCFLAGS} (variable): The flags to be given to the Fortran compiler. The main use is to control the level of optimization. \item \ttt{--prefix=\var{directory-name}}: Specify a non-default directory for installation. \item \ttt{--enable-fc-openmp}: Enable parallel executing via OpenMP on a multi-processor/multi-core machine. This works only if OpenMP is supported by the compiler (e.g., \ttt{gfortran}). When running \whizard, the number of processors that are actually requested can be controlled by the user. Without this option, \whizard\ will run in serial mode on a single core. See Sec.~\ref{sec:openmp} for further details. \item \ttt{--enable-fc-mpi}: Enable parallel executing via MPI on a single machine using several cores or several machines. This works only if a MPI library is installed (e.g. \ttt{OpenMPI}) and \ttt{FC=mpifort CC=mpicc CXX=mpic++} is set. Without this option, \whizard\ will run in serial mode on a single core. The flag can be combined with \ttt{--enable-fc-openmp}. See Sec.~\ref{sec:mpi} for further details. \item \ttt{LHADPF\_DIR} (variable): The location of the optional \lhapdf\ package, if non-default. \item \ttt{LOOPTOOLS\_DIR} (variable): The location of the optional \ttt{LOOPTOOLS} package, if non-default. \item \ttt{OPENLOOPS\_DIR} (variable): The location of the optional \openloops\ package, if non-default. \item \ttt{GOSAM\_DIR} (variable): The location of the optional \gosam\ package, if non-default. \item \ttt{HOPPET\_DIR} (variable): The location of the optional \hoppet\ package, if non-default. \item \ttt{HEPMC\_DIR} (variable): The location of the optional \hepmc\ package, if non-default. \item \ttt{LCIO}/\ttt{LCIO\_DIR} (variable): The location of the optional \lcio\ package, if non-default. \end{itemize} Other flags that might help to work around possible problems are the flags for the $C$ and $C++$ compilers as well as the \ttt{Fortran77} compiler, or the linker flags and additional libraries for the linking process. \begin{itemize} \item \ttt{CC} (variable): \ttt{C} compiler command \item \ttt{F77} (variable): \ttt{Fortran77} compiler command \item \ttt{CXX} (variable): \ttt{C++} compiler command \item \ttt{CPP} (variable): \ttt{C} preprocessor \item \ttt{CXXCPP} (variable): \ttt{C++} preprocessor \item \ttt{CFLAGS} (variable): \ttt{C} compiler flags \item \ttt{FFLAGS} (variable): \ttt{Fortran77} compiler flags \item \ttt{CXXFLAGS} (variable): \ttt{C++} compiler flags \item \ttt{LIBS} (variable): libraries to be passed to the linker as \ttt{-l{\em library}} \item \ttt{LDFLAGS} (variable): non-standard linker flags \end{itemize} For other options (like e.g. \ttt{--with-precision=...} etc.) please see the \ttt{configure --help} option. %%%%% \subsection{Details on the Configure Process} The configure process checks for the build and host system type; only if this is not detected automatically, the user would have to specify this by himself. After that system-dependent files are searched for, LaTeX and Acroread for documentation and plots, the \fortran\ compiler is checked, and finally the \ocaml\ compiler. The next step is the checks for external programs like \lhapdf\ and \ttt{HepMC}. Finally, all the Makefiles are being built. The compilation is done by invoking \ttt{make} and finally \ttt{make install}. You could also do a \ttt{make check} in order to test whether the compilation has produced sane files on your system. This is highly recommended. Be aware that there be problems for the installation if the install path or a user's home directory is part of an AFS file system. Several times problems were encountered connected with conflicts with permissions inside the OS permission environment variables and the AFS permission flags which triggered errors during the \ttt{make install} procedure. Also please avoid using \ttt{make -j} options of parallel execution of \ttt{Makefile} directives as AFS filesystems might not be fast enough to cope with this. For specific problems that might have been encountered in rare circumstances for some FORTRAN compilers confer the webpage \url{https://whizard.hepforge.org/compilers.html}. Note that the \pythia\ bundle for showering and hadronization (and some other external legacy code pieces) do still contain good old \ttt{Fortran77} code. These parts should better be compiled with the very same \ttt{Fortran2003} compiler as the \whizard\ core. There is, however, one subtlety: when the \ttt{configure} flag \ttt{FC} gets a full system path as argument, \ttt{libtool} is not able to recognize this as a valid (GNU) \ttt{Fortran77} compiler. It then searches automatically for binaries like \ttt{f77}, \ttt{g77} etc. or a standard system compiler. This might result in a compilation failure of the \ttt{Fortran77} code. A viable solution is to define an executable link and use this (not the full path!) as \ttt{FC} flag. It is possible to compile \whizard\ without the \ocaml\ parts of \oMega, namely by using the \ttt{--disable-omega} option of the configure. This will result in a built of \whizard\ with the \oMega\ Fortran library, but without the binaries for the matrix element generation. All selftests (cf. \ref{sec:selftests}) requiring \oMega\ matrix elements are thereby switched off. Note that you can install such a built (e.g. on a batch system without \ocaml\ installation), but the try to build a distribution (all \ttt{make distxxx} targets) will fail. %%%%%%%%%%% \subsection{\whizard\ self tests/checks} \label{sec:selftests} \whizard\ has a number of self-consistency checks and tests which assure that most of its features are running in the intended way. The standard procedure to invoke these self tests is to perform a \ttt{make check} from the \ttt{build} directory. If \ttt{src} and \ttt{build} directories are the same, all relevant files for these self-tests reside in the \ttt{tests} subdirectory of the main \whizard\ directory. In that case, one could in principle just call the scripts individually from the command line. Note, that if \ttt{src} and \ttt{build} directory are different as recommended, then the input files will have been installed in \ttt{prefix/share/whizard/test}, while the corresponding test shell scripts remain in the \ttt{srcdir/test} directory. As the main shell script \ttt{run\_whizard.sh} has been built in the \ttt{build} directory, one now has to copy the files over by and set the correct paths by hand, if one wishes to run the test scripts individually. \ttt{make check} still correctly performs all \whizard\ self-consistency tests. The tests itself fall into two categories, unit self test that individually test the modular structure of \whizard, and tests that are run by \sindarin\ files. In future releases of \whizard, these two categories of tests will be better separated than in the 2.2.1 release. There are additional, quite extensiv numerical tests for validation and backwards compatibility checks for SM and MSSM processes. As a standard, these extended self tests are not invoked. However, they can be enabled by executing the corresponding specific \ttt{make check} operations in the subdirectories for these extensive tests. As the new \whizard\ testsuite does very thorough and scrupulous tests of the whole \whizard\ structure, it is always possible that some tests are failing due to some weird circumstances or because of numerical fluctuations. In such a case do not panic, contact the developers (\ttt{whizard@desy.de}) and provide them with the logfiles of the failing test as well as the setup of your configuration. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \clearpage \chapter{Working with \whizard} \label{chap:start} \whizard\ can run as a stand-alone program. You (the user) can steer \whizard\ either interactively or by a script file. We will first describe the latter method, since it will be the most common way to interact with the \whizard\ system. \section{Hello World} The legacy version series 1 of the program relied on a bunch of input files that the user had to provide in some obfuscated format. This approach is sufficient for straightforward applications. However, once you get experienced with a program, you start thinking about uses that the program's authors did not foresee. In case of a Monte Carlo package, typical abuses are parameter scans, complex patterns of cuts and reweighting factors, or data analysis without recourse to external packages. This requires more flexibility. Instead of transferring control over data input to some generic scripting language like PERL or PYTHON (or even C++), which come with their own peculiarities and learning curves, we decided to unify data input and scripting in a dedicated steering language that is particularly adapted to the needs of Monte-Carlo integration, simulation, and simple analysis of the results. Thus we discovered what everybody knew anyway: that W(h)izards communicate in \sindarin, Scripting INtegration, Data Analysis, Results display and INterfaces. \sindarin\ is a DSL -- a domain-specific scripting language -- that is designed for the single purpose of steering and talking to \whizard. Now since \sindarin\ is a programming language, we honor the old tradition of starting with the famous Hello World program. In \sindarin\ this reads simply \begin{quote} \begin{verbatim} printf "Hello World!" \end{verbatim} \end{quote} Open your favorite editor, type this text, and save it into a file named \verb|hello.sin|. \begin{figure} \centering \begin{scriptsize} \begin{Verbatim}[frame=single] | Writing log to 'whizard.log' |=============================================================================| | | | WW WW WW WW WW WWWWWW WW WWWWW WWWW | | WW WW WW WW WW WW WW WWWW WW WW WW WW | | WW WW WW WW WWWWWWW WW WW WW WW WWWWW WW WW | | WWWW WWWW WW WW WW WW WWWWWWWW WW WW WW WW | | WW WW WW WW WW WWWWWW WW WW WW WW WWWW | | | | | | W | | sW | | WW | | sWW | | WWW | | wWWW | | wWWWW | | WW WW | | WW WW | | wWW WW | | wWW WW | | WW WW | | WW WW | | WW WW | | WW WW | | WW WW | | WW WW | | wwwwww WW WW | | WWWWWww WW WW | | WWWWWwwwww WW WW | | wWWWwwwwwWW WW | | wWWWWWWWWWWwWWW WW | | wWWWWW wW WWWWWWW | | WWWW wW WW wWWWWWWWwww | | WWWW wWWWWWWWwwww | | WWWW WWWW WWw | | WWWWww WWWW | | WWWwwww WWWW | | wWWWWwww wWWWWW | | WwwwwwwwwWWW | | | | | | | | by: Wolfgang Kilian, Thorsten Ohl, Juergen Reuter | | with contributions from Christian Speckner | | Contact: | | | | if you use WHIZARD please cite: | | W. Kilian, T. Ohl, J. Reuter, Eur.Phys.J.C71 (2011) 1742 | | [arXiv: 0708.4233 [hep-ph]] | | M. Moretti, T. Ohl, J. Reuter, arXiv: hep-ph/0102195 | | | |=============================================================================| | WHIZARD 3.0.0_alpha |=============================================================================| | Reading model file '/usr/local/share/whizard/models/SM.mdl' | Preloaded model: SM | Process library 'default_lib': initialized | Preloaded library: default_lib | Reading commands from file 'hello.sin' Hello World! | WHIZARD run finished. |=============================================================================| \end{Verbatim} \end{scriptsize} \caption{Output of the \ttt{"Hello world!"} \sindarin\ script.\label{fig:helloworld}} \end{figure} Now we assume that you -- or your kind system administrator -- has installed \whizard\ in your executable path. Then you should open a command shell and execute (we will come to the meaning of the \verb|-r| option later.) \begin{verbatim} /home/user$ whizard -r hello.sin \end{verbatim} and if everything works well, you get the output (the complete output including the \whizard\ banner is shown in Fig.~\ref{fig:helloworld}) \begin{footnotesize} \begin{verbatim} | Writing log to 'whizard.log' \end{verbatim} \centerline{[... here a banner is displayed]} \begin{Verbatim} |=============================================================================| | WHIZARD 3.0.0_alpha |=============================================================================| | Reading model file '/usr/local/share/whizard/models/SM.mdl' | Preloaded model: SM ! Process library 'default_lib': initialized ! Preloaded library: default_lib | Reading commands from file 'hello.sin' Hello World! | WHIZARD run finished. |=============================================================================| \end{Verbatim} \end{footnotesize} If this has just worked for you, you can be confident that you have a working \whizard\ installation, and you have been able to successfully run the program. \section{A Simple Calculation} You may object that \whizard\ is not exactly designed for printing out plain text. So let us demonstrate a more useful example. Looking at the Hello World output, we first observe that the program writes a log file named (by default) \verb|whizard.log|. This file receives all screen output, except for the output of external programs that are called by \whizard. You don't have to cache \whizard's screen output yourself. After the welcome banner, \whizard\ tells you that it reads a physics \emph{model}, and that it initializes and preloads a \emph{process library}. The process library is initially empty. It is ready for receiving definitions of elementary high-energy physics processes (scattering or decay) that you provide. The processes are set in the context of a definite model of high-energy physics. By default this is the Standard Model, dubbed \verb|SM|. Here is the \sindarin\ code for defining a SM physics process, computing its cross section, and generating a simulated event sample in Les Houches event format: \begin{quote} \begin{Verbatim} process ee = e1, E1 => e2, E2 sqrts = 360 GeV n_events = 10 sample_format = lhef simulate (ee) \end{Verbatim} \end{quote} As before, you save this text in a file (named, e.g., \verb|ee.sin|) which is run by \begin{verbatim} /home/user$ whizard -r ee.sin \end{verbatim} (We will come to the meaning of the \verb|-r| option later.) This produces a lot of output which looks similar to this: \begin{footnotesize} \begin{verbatim} | Writing log to 'whizard.log' [... banner ...] |=============================================================================| | WHIZARD 3.0.0_alpha |=============================================================================| | Reading model file '/usr/local/share/whizard/models/SM.mdl' | Preloaded model: SM | Process library 'default_lib': initialized | Preloaded library: default_lib | Reading commands from file 'ee.sin' | Process library 'default_lib': recorded process 'ee' sqrts = 3.600000000000E+02 n_events = 10 \end{verbatim} \begin{verbatim} | Starting simulation for process 'ee' | Simulate: process 'ee' needs integration | Integrate: current process library needs compilation | Process library 'default_lib': compiling ... | Process library 'default_lib': writing makefile | Process library 'default_lib': removing old files rm -f default_lib.la rm -f default_lib.lo default_lib_driver.mod opr_ee_i1.mod ee_i1.lo rm -f ee_i1.f90 | Process library 'default_lib': writing driver | Process library 'default_lib': creating source code rm -f ee_i1.f90 rm -f opr_ee_i1.mod rm -f ee_i1.lo /usr/local/bin/omega_SM.opt -o ee_i1.f90 -target:whizard -target:parameter_module parameters_SM -target:module opr_ee_i1 -target:md5sum '70DB728462039A6DC1564328E2F3C3A5' -fusion:progress -scatter 'e- e+ -> mu- mu+' [1/1] e- e+ -> mu- mu+ ... allowed. [time: 0.00 secs, total: 0.00 secs, remaining: 0.00 secs] all processes done. [total time: 0.00 secs] SUMMARY: 6 fusions, 2 propagators, 2 diagrams | Process library 'default_lib': compiling sources [.....] \end{verbatim} \begin{verbatim} | Process library 'default_lib': loading | Process library 'default_lib': ... success. | Integrate: compilation done | RNG: Initializing TAO random-number generator | RNG: Setting seed for random-number generator to 9616 | Initializing integration for process ee: | ------------------------------------------------------------------------ | Process [scattering]: 'ee' | Library name = 'default_lib' | Process index = 1 | Process components: | 1: 'ee_i1': e-, e+ => mu-, mu+ [omega] | ------------------------------------------------------------------------ | Beam structure: [any particles] | Beam data (collision): | e- (mass = 5.1099700E-04 GeV) | e+ (mass = 5.1099700E-04 GeV) | sqrts = 3.600000000000E+02 GeV | Phase space: generating configuration ... | Phase space: ... success. | Phase space: writing configuration file 'ee_i1.phs' | Phase space: 2 channels, 2 dimensions | Phase space: found 2 channels, collected in 2 groves. | Phase space: Using 2 equivalences between channels. | Phase space: wood Warning: No cuts have been defined. \end{verbatim} \begin{verbatim} | Starting integration for process 'ee' | Integrate: iterations not specified, using default | Integrate: iterations = 3:1000:"gw", 3:10000:"" | Integrator: 2 chains, 2 channels, 2 dimensions | Integrator: Using VAMP channel equivalences | Integrator: 1000 initial calls, 20 bins, stratified = T | Integrator: VAMP |=============================================================================| | It Calls Integral[fb] Error[fb] Err[%] Acc Eff[%] Chi2 N[It] | |=============================================================================| 1 784 8.3282892E+02 1.68E+00 0.20 0.06* 39.99 2 784 8.3118961E+02 1.23E+00 0.15 0.04* 76.34 3 784 8.3278951E+02 1.36E+00 0.16 0.05 54.45 |-----------------------------------------------------------------------------| 3 2352 8.3211789E+02 8.01E-01 0.10 0.05 54.45 0.50 3 |-----------------------------------------------------------------------------| 4 9936 8.3331732E+02 1.22E-01 0.01 0.01* 54.51 5 9936 8.3341072E+02 1.24E-01 0.01 0.01 54.52 6 9936 8.3331151E+02 1.23E-01 0.01 0.01* 54.51 |-----------------------------------------------------------------------------| 6 29808 8.3334611E+02 7.10E-02 0.01 0.01 54.51 0.20 3 |=============================================================================| \end{verbatim} \begin{verbatim} [.....] | Simulate: integration done | Simulate: using integration grids from file 'ee_m1.vg' | RNG: Initializing TAO random-number generator | RNG: Setting seed for random-number generator to 9617 | Simulation: requested number of events = 10 | corr. to luminosity [fb-1] = 1.2000E-02 | Events: writing to LHEF file 'ee.lhe' | Events: writing to raw file 'ee.evx' | Events: generating 10 unweighted, unpolarized events ... | Events: event normalization mode '1' | ... event sample complete. | Events: closing LHEF file 'ee.lhe' | Events: closing raw file 'ee.evx' | There were no errors and 1 warning(s). | WHIZARD run finished. |=============================================================================| \end{verbatim} \end{footnotesize} %$ The final result is the desired event file, \ttt{ee.lhe}. Let us discuss the output quickly to walk you through the procedures of a \whizard\ run: after the logfile message and the banner, the reading of the physics model and the initialization of a process library, the recorded process with tag \ttt{'ee'} is recorded. Next, user-defined parameters like the center-of-mass energy and the number of demanded (unweighted) events are displayed. As a next step, \whizard\ is starting the simulation of the process with tag \ttt{'ee'}. It recognizes that there has not yet been an integration over phase space (done by an optional \ttt{integrate} command, cf. Sec.~\ref{sec:integrate}), and consequently starts the integration. It then acknowledges, that the process code for the process \ttt{'ee'} needs to be compiled first (done by an optional \ttt{compile} command, cf. Sec.~\ref{sec:compilation}). So, \whizard\ compiles the process library, writes the makefile for its steering, and as a safeguard against garbage removes possibly existing files. Then, the source code for the library and its processes are generated: for the process code, the default method -- the matrix element generator \oMega\ is called (cf. Sec.~\ref{sec:omega_me}); and the sources are being compiled. The next steps are the loading of the process library, and \whizard\ reports the completion of the integration. For the Monte-Carlo integration, a random number generator is initialized. Here, it is the default generator, TAO (for more details, cf. Sec.~\ref{sec:tao}, while the random seed is set to a value initialized by the system clock, as no seed has been provided in the \sindarin\ input file. Now, the integration for the process \ttt{'ee'} is initialized, and information about the process (its name, the name of its process library, its index inside the library, and the process components out of which it consists, cf. Sec.~\ref{sec:processcomp}) are displayed. Then, the beam structure is shown, which in that case are symmetric partonic electron and positron beams with the center-of-mass energy provided by the user (360 GeV). The next step is the generation of the phase space, for which the default phase space method \ttt{wood} (for more details cf. Sec.~\ref{sec:wood}) is selected. The integration is performed, and the result with absolute and relative error, unweighting efficiency, accuracy, $\chi^2$ quality is shown. The final step is the event generation (cf. Chap.~\ref{chap:events}). The integration grids are now being used, again the random number generator is initialized. Finally, event generation of ten unweighted events starts (\whizard\ let us know to which integrated luminosity that would correspond), and events are written both in an internal (binary) event format as well as in the demanded LHE format. This concludes the \whizard\ run. After a more comprehensive introduction into the \sindarin\ steering language in the next chapter, Chap.~\ref{chap:sindarinintro}, we will discuss all the details of the different steps of this introductory example. \clearpage \section{WHIZARD in a Computing Environment} \subsection{Working on a Single Computer} \label{sec:workspace} After installation, \whizard\ is ready for use. There is a slight complication if \whizard\ has been installed in a location that is not in your standard search paths. In that case, to successfully run \whizard, you may either \begin{itemize} \item manually add \ttt{your-install-directory/bin} to your execution PATH\\ and \ttt{your-install-directory/lib} to your library search path (LD\_LIBRARY\_PATH), or \item whenever you start a project, execute \begin{interaction} your-workspace> . your-install-directory/bin/whizard-setup.sh \end{interaction} which will enable the paths in your current environment, or \item source \ttt{whizard-setup.sh} script in your shell startup file. \end{itemize} In either case, try to call \ttt{whizard --help} in order to check whether this is done correctly. For a new \whizard\ project, you should set up a new (empty) directory. Depending on the complexity of your task, you may want to set up separate directories for each subproblem that you want to tackle, or even for each separate run. The location of the directories is arbitrary. To run, \whizard\ needs only a single input file, a \sindarin\ command script with extension \ttt{.sin} (by convention). Running \whizard\ is as simple as \begin{interaction} your-workspace> whizard your-input.sin \end{interaction} No other configuration files are needed. The total number of auxiliary and output files generated in a single run may get quite large, however, and they may clutter your workspace. This is the reason behind keeping subdirectories on a per-run basis. Basic usage of \whizard\ is explained in Chapter~\ref{chap:start}, for more details, consult the following chapters. In Sec.~\ref{sec:cmdline-options} we give an account of the command-line options that \whizard\ accepts. \subsection{Working Parallel on Several Computers} \label{sec:mpi} For integration (only VAMP2), \whizard\ supports parallel execution via MPI by communicating between parallel tasks on a single machine or distributed over several machines. During integration the calculation of channels is distributed along several workers where a master worker collects the results and adapts weights and grids. In wortwhile cases (e.g. high number of calls in one channel), the calculation of a single grid is distributed. In order to use these advancements, \whizard\ requires an installed MPI-3.1 capable library (e.g. OpenMPI) and configuration and compilation with the appropriate flags, cf.~Sec.~\ref{sec:installation}. MPI support is only active when the integration method is set to VAMP2. Additionally, to preserve the numerical properties of a single task run, it is recommended to use the RNGstream as random number generator. \begin{code} $integration_method = 'vamp2' $rng_method = 'rng_stream' \end{code} \whizard\ has then to be called by mpirun \begin{footnotesize} \begin{Verbatim}[frame=single] your-workspace> mpirun -f hostfile -np 4 --output-filename mpi.log whizard your-input.sin \end{Verbatim} \end{footnotesize} where the number of parallel tasks can be set by \ttt{-np} and a hostfile can be given by \ttt{--hostfile}. It is recommended to use \ttt{--output-filename} which lets mpirun redirect the standard (error) output to a file, for each worker separatly. \subsubsection{Notes on Parallelization with MPI} The parallelization of \whizard\ requires that all instances of the parallel run be able to write and read all files by produced \whizard\ in a network file system as the current implementation does not handle parallel I/O. Usually, high-performance clusters have support for at least one network filesystem. Furthermore, not all functions of \whizard\ are currently supported or are only supported in a limited way in parallel mode. Currently the \verb|?rebuild_| for the phase space and the matrix element library are not yet available, as well as the calculation of matrix elements with resonance history. Some features that have been missing in the very first implementation of the parallelized integration have now been made available, like the support of run IDs and the parallelization of the event generation. A final remark on the stability of the numerical results in terms of the number of workers involved. Under certain circumstances, results between different numbers of workers but using otherwise an identical \sindarin\ file can lead to slightly numerically different (but statistically compatible) results for integration or event generation This is related to the execution of the computational operations in MPI, which we use to reduce results from all workers. If the order of the numbers in the arithmetical operations changes, for example, by different setups of the workers, then the numerical results change slightly, which in turn is amplified under the influence of the adaptation. Nevertheless, the results are all statistically consistent. \subsection{Stopping and Resuming WHIZARD Jobs} On a Unix-like system, it is possible to prematurely stop running jobs by a \ttt{kill(1)} command, or by entering \ttt{Ctrl-C} on the terminal. If the system supports this, \whizard\ traps these signals. It also traps some signals that a batch operating system might issue, e.g., for exceeding a predefined execution time limit. \whizard\ tries to complete the calculation of the current event and gracefully close open files. Then, the program terminates with a message and a nonzero return code. Usually, this should not take more than a fraction of a second. If, for any reason, the program does not respond to an interrupt, it is always possible to kill it by \ttt{kill -9}. A convenient method, on a terminal, would be to suspend it first by \ttt{Ctrl-Z} and then to kill the suspended process. The program is usually able to recover after being stopped. Simply run the job again from start, with the same input, all output files generated so far left untouched. The results obtained so far will be quickly recovered or gathered from files written in the previous run, and the actual time-consuming calculation is resumed near the point where it was interrupted.\footnote{This holds for simple workflow. In case of scans and repeated integrations of the same process, there may be name clashes on the written files which prevent resuming. A future \whizard\ version will address this problem.} If the interruption happened during an integration step, it is resumed after the last complete iteration. If it was during event generation, the previous events are taken from file and event generation is continued. The same mechanism allows for efficiently redoing a calculation with similar, somewhat modified input. For instance, you might want to add a further observable to event analysis, or write the events in a different format. The time for rerunning the program is determined just by the time it takes to read the existing integration or event files, and the additional calculation is done on the recovered information. By managing various checksums on its input and output files, \whizard\ detects changes that affect further calculations, so it does a real recalculation only where it is actually needed. This applies to all steps that are potentially time-consuming: matrix-element code generation, compilation, phase-space setup, integration, and event generation. If desired, you can set command-line options or \sindarin\ parameters that explicitly discard previously generated information. \subsection{Files and Directories: default and customization} \whizard\ jobs take a small set of files as input. In many cases, this is just a single \sindarin\ script provided by the user. When running, \whizard\ can produce a set of auxiliary and output files: \begin{enumerate} \item \textbf{Job.} Files pertaining to the \whizard\ job as a whole. This is the default log file \ttt{whizard.log}. \item \textbf{Process compilation.} Files that originate from generating and compiling process code. If the default \oMega\ generator is used, these files include Fortran source code as well as compiled libraries that are dynamically linked to the running executable. The file names are derived from either the process-library name or the individual process names, as defined in the \sindarin\ input. The default library name is \ttt{default\_lib}. \item \textbf{Integration.} Files that are created by integration, i.e., when calculating the total cross section for a scattering process using the Monte-Carlo algorithm. The file names are derived from the process name. \item \textbf{Simulation.} Files that are created during simulation, i.e., generating event samples for a process or a set of processes. By default, the file names are derived from the name of the first process. Event-file formats are distinguished by appropriate file name extensions. \item \textbf{Result Analysis.} Files that are created by the internal analysis tools and written by the command \ttt{write\_analysis} (or \ttt{compile\_analysis}). The default base name is \ttt{whizard\_analysis}. \end{enumerate} A complex workflow with several processes, parameter sets, or runs, can easily lead to in file-name clashes or a messy working directory. Furthermore, running a batch job on a dedicated computing environment often requires transferring data from a user directory to the server and back. Custom directory and file names can be used to organize things and facilitate dealing with the environment, along with the available batch-system tools for coordinating file transfer. \begin{enumerate} \item \textbf{Job.} \begin{itemize} \item The \ttt{-L} option on the command line defines a custom base name for the log file. \item The \ttt{-J} option on the command line defines a job ID. For instance, this may be set to the job ID assigned by the batch system. Within the \sindarin\ script, the job ID is available as the string variable \ttt{\$job\_id} and can be used for constructing custom job-specific file and directory names, as described below. \end{itemize} \item \textbf{Process compilation.} \begin{itemize} \item The user can require the program to put all files created during the compilation step including the library to be linked, in a subdirectory of the working directory. To enable this, set the string variable \ttt{\$compile\_workspace} within the \sindarin\ script. \end{itemize} \item \textbf{Integration.} \begin{itemize} \item The value of the string variable \ttt{\$run\_id}, if set, is appended to the base name of all files created by integration, separated by dots. If the \sindarin\ script scans over parameters, varying the run ID avoids repeatedly overwriting files with identical name during the scan. \item The user can require the program to put the important files created during the integration step -- the phase-space configuration file and the \vamp\ grid files -- in a subdirectory of the working directory. To enable this, set the string variable \ttt{\$integrate\_workspace} within the \sindarin\ script. (\ttt{\$compile\_workspace} and \ttt{\$integrate\_workspace} may be set to the same value.) \end{itemize} Log files produced during the integration step are put in the working directory. \item \textbf{Simulation.} \begin{itemize} \item The value of the string variable \ttt{\$run\_id}, if set, identifies the specific integration run that is used for the event sample. It is also inserted into default event-sample file names. \item The variable \ttt{\$sample}, if set, defines an arbitrary base name for the files related to the event sample. \end{itemize} Files resulting from simulation are put in the working directory. \item \textbf{Result Analysis.} \begin{itemize} \item The variable \ttt{\$out\_file}, if set, defines an arbitrary base name for the analysis data and auxiliary files. \end{itemize} Files resulting from result analysis are put in the working directory. \end{enumerate} \subsection{Batch jobs on a different machine} It is possible to separate the tasks of process-code compilation, integration, and simulation, and execute them on different machines. To make use of this feature, the local and remote machines including all installed libraries that are relevant for \whizard, must be binary-compatible. \begin{enumerate} \item Process-code compilation may be done once on a local machine, while the time-consuming tasks of integration and event generation for specific parameter sets are delegated to a remote machine, e.g., a batch cluster. To enable this, prepare a \sindarin\ script that just produces process code (i.e., terminates with a \ttt{compile} command) for the local machine. You may define \ttt{\$compile\_workspace} such that all generated code conveniently ends up in a single subdirectory. To start the batch job, transfer the workspace subdirectory to the remote machine and start \whizard\ there. The \sindarin\ script on the remote machine must include the local script unchanged in all parts that are relevant for process definition. The program will recognize the contents of the workspace, skip compilation and instead link the process library immediately. To proceed further, the script should define the run-specific parameters and contain the appropriate commands for integration and simulation. \item Analogously, you may execute both process-code compilation and integration locally, but generate event samples on a remote machine. To this end, prepare a \sindarin\ script that produces process code and computes integrals (i.e., terminates with an \ttt{integrate} command) for the local machine. You may define \ttt{\$compile\_workspace} and \ttt{\$integrate\_workspace} (which may coincide) such that all generated code, phase-space and integration grid data conveniently end up in subdirectories. To start the batch job, transfer the workspace(s) to the remote machine and start \whizard\ there. The \sindarin\ script on the remote machine must include the local script unchanged in all parts that are relevant for process definition and integration. The program will recognize the contents of the workspace, skip compilation and integration and instead load the process library and integration results immediately. To proceed further, the script should define the sample-specific parameters and contain the appropriate commands for simulation. \end{enumerate} To simplify transferring whole directories, \whizard\ supports the \ttt{--pack} and \ttt{--unpack} options. You may specify any number of these options for a \whizard\ run. (The feature relies on the GNU version of the \ttt{tar} utility.) For instance, \begin{code} whizard script1.sin --pack my_ws \end{code} runs \whizard\ with the \sindarin\ script \ttt{script1.sin} as input, where within the script you have defined \begin{code} $compile_workspace = "my_ws" \end{code} as the target directory for process-compilation files. After completion, the program will tar and gzip the target directory as \ttt{my\_ws.tgz}. You should copy this file to the remote machine as one of the job's input files. On the remote machine, you can then run the program with \begin{code} whizard script2.sin --unpack my_ws.tgz \end{code} where \ttt{script2.sin} should include \ttt{script1.sin}, and add integration or simulation commands. The contents of \ttt{ws.tgz} will thus be unpacked and reused on the remote machine, instead of generating new process code. \subsection{Static Linkage} In its default running mode, \whizard\ compiles process-specific matrix element code on the fly and dynamically links the resulting library. On the computing server, this requires availability of the appropriate Fortran compiler, as well as the \ocaml\ compiler suite, and the dynamical linking feature. Since this may be unavailable or undesired, there is a possibility to distribute \whizard\ as a statically linked executable that contains a pre-compiled library of processes. This removes the need for the Fortran compiler, the \ocaml\ system, and extra dynamic linking. Any external libraries that are accessed (the \fortran\ runtime environment, and possibly some dynamically linked external libraries and/or the C++ runtime library, must still be available on the target system, binary-compatible. Otherwise, there is no need for transferring the complete \whizard\ installation or process-code compilation data. Generating, compiling and linking matrix element code is done in advance on a machine that can access the required tools and produces compatible libraries. This procedure is accomplished by \sindarin\ commands, explained below in Sec.~\ref{sec:static}. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newpage \section{Troubleshooting} \label{sec:troubleshooting} In this section, we list known issues or problems and give advice on what can be done in case something does not work as intended. \subsection{Possible (uncommon) build problems} \label{sec:buildproblems} \subsubsection{\ocaml\ versions and \oMega\ builds} For the matrix element generator \oMega\ of \whizard\, the functional programming language \ocaml\ is used. Unfortunately, the versions of the \ocaml\ compiler from 3.12.0 on broke backwards compatibility. Therefore, versions of \oMega/\whizard\ up to v2.0.2 only compile with older versions (3.04 to 3.11 works). This has been fixed in all \whizard\ versions from 2.0.3 on. \subsubsection{Identical Build and Source directories} There is a problem that only occurred with version 2.0.0 and has been corected for all follow-up versions. It can only appear if you compile the \whizard\ sources in the source directory. Then an error like this may occur: \begin{footnotesize} \begin{Verbatim}[frame=single] ... libtool: compile: gfortran -I../misc -I../vamp -g -O2 -c processes.f90 -fPIC -o .libs/processes.o libtool: compile: gfortran -I../misc -I../vamp -g -O2 -c processes.f90 -o processes.o >/dev/null 2>&1 make[2]: *** No rule to make target `limits.lo', needed by `decays.lo'. Stop. ... make: *** [all-recursive] Error 1 \end{Verbatim} \end{footnotesize} In this case, please unpack a fresh copy of \whizard\ and configure it in a separate directory (not necessarily a subdirectory). Then the compilation will go through: \begin{footnotesize} \begin{Verbatim}[frame=single] $ zcat whizard-2.0.0.tar.gz | tar xf - $ cd whizard-2.0.0 $ mkdir _build $ cd _build $ ../configure FC=gfortran $ make \end{Verbatim} \end{footnotesize} The developers use this setup to be able to test different compilers. Therefore building in the same directory is not as thoroughly tested. This behavior has been patched from version 2.0.1 on. But note that in general it is always adviced to keep build and source directory apart from each other. %%%%% \subsection{What happens if \whizard\ throws an error?} \label{ref:errors} \subsubsection{Particle name special characters in process declarations} Trying to use a process declaration like \begin{code} process foo = e-, e+ => mu-, mu+ \end{code} will lead to a \sindarin\ syntax error: \begin{Code} process foo = e-, e+ => mu-, mu+ ^^ | Expected syntax: SEQUENCE = process '=' "mu-", "mu+"}. \subsubsection{Missing collider energy} This happens if you forgot to set the collider energy in the integration of a scattering process: \begin{Code} ****************************************************************************** ****************************************************************************** *** FATAL ERROR: Colliding beams: sqrts is zero (please set sqrts) ****************************************************************************** ****************************************************************************** \end{Code} This will solve your problem: \begin{code} sqrts = \end{code} \subsubsection{Missing process declaration} If you try to integrate or simulate a process that has not declared before (and is also not available in a library that might be loaded), \whizard\ will complain: \begin{Code} ****************************************************************************** ****************************************************************************** *** FATAL ERROR: Process library doesn't contain process 'f00' ****************************************************************************** ****************************************************************************** \end{Code} Note that this could sometimes be a simple typo, e.g. in that case an \ttt{integrate (f00)} instead of \ttt{integrate (foo)} \subsubsection{Ambiguous initial state without beam declaration} When the user declares a process with a flavor sum in the initial state, e.g. \begin{code} process qqaa = u:d, U:D => A, A sqrts = integrate (qqaa) \end{code} then a fatal error will be issued: \begin{Code} ****************************************************************************** ****************************************************************************** *** FATAL ERROR: Setting up process 'qqaa': *** -------------------------------------------- *** Inconsistent initial state. This happens if either *** several processes with non-matching initial states *** have been added, or for a single process with an *** initial state flavor sum. In that case, please set beams *** explicitly [singling out a flavor / structure function.] ****************************************************************************** ****************************************************************************** \end{Code} What now? Either a structure function providing a tensor structure in flavors has to be provided like \begin{code} beams = p, pbar => pdf_builtin \end{code} or, if the partonic process was intended, a specific flavor has to be singled out, \begin{code} beams = u, U \end{code} which would take only the up-quarks. Note that a sum over process components with varying initial states is not possible. \subsubsection{Invalid or unsupported beam structure} An error message like \begin{Code} ****************************************************************************** ****************************************************************************** *** FATAL ERROR: Beam structure: [.......] not supported ****************************************************************************** ****************************************************************************** \end{Code} This happens if you try to use a beam structure with is either not supported by \whizard\ (meaning that there is no phase-space parameterization for Monte-Carlo integration available in order to allow an efficient sampling), or you have chosen a combination of beam structure functions that do not make sense physically. Here is an example for the latter (lepton collider ISR applied to protons, then proton PDFs): \begin{code} beams = p, p => isr => pdf_builtin \end{code} \subsubsection{Mismatch in beams} Sometimes you get a rather long error output statement followed by a fatal error: \begin{Code} Evaluator product First interaction Interaction: 6 Virtual: Particle 1 [momentum undefined] [.......] State matrix: norm = 1.000000000000E+00 [f(2212)] [f(11)] [f(92) c(1 )] [f(-6) c(-1 )] => ME(1) = ( 0.000000000000E+00, 0.000000000000E+00) [.......] ****************************************************************************** ****************************************************************************** *** FATAL ERROR: Product of density matrices is empty *** -------------------------------------------- *** This happens when two density matrices are convoluted *** but the processes they belong to (e.g., production *** and decay) do not match. This could happen if the *** beam specification does not match the hard *** process. Or it may indicate a WHIZARD bug. ****************************************************************************** ****************************************************************************** \end{Code} As \whizard\ indicates, this could have happened because the hard process setup did not match the specification of the beams as in: \begin{code} process neutral_current_DIS = e1, u => e1, u beams_momentum = 27.5 GeV, 920 GeV beams = p, e => pdf_builtin, none integrate (neutral_current_DIS) \end{code} In that case, the order of the beam particles simply was wrong, exchange proton and electron (together with the structure functions) into \ttt{beams = e, p => none, pdf\_builtin}, and \whizard\ will be happy. \subsubsection{Unstable heavy beam particles} If you try to use unstable particles as beams that can potentially decay into the final state particles, you might encounter the following error message: \begin{Code} ****************************************************************************** ****************************************************************************** *** FATAL ERROR: Phase space: Initial beam particle can decay ****************************************************************************** ****************************************************************************** \end{Code} This happens basically only for processes in testing/validation (like $t \bar t \to b \bar b$). In principle, it could also happen in a real physics setup, e.g. when simulating electron pairs at a muon collider: \begin{code} process mmee = "mu-", "mu+" => "e-", "e+" \end{code} However, \whizard\ at the moment does not allow a muon width, and so \whizard\ is not able to decay a muon in a scattering process. A possibile decay of the beam particle into (part of) the final state might lead to instabilities in the phase space setup. Hence, \whizard\ do not let you perform such an integration right away. When you nevertheless encounter such a rare occasion in your setup, there is a possibility to convert this fatal error into a simple warning by setting the flag: \begin{code} ?fatal_beam_decay = false \end{code} \subsubsection{Impossible beam polarization} If you specify a beam polarization that cannot correspond to any physically allowed spin density matrix, e.g., \begin{code} beams = e1, E1 beams_pol_density = @(-1), @(1:1:.5, -1, 1:-1) \end{code} \whizard\ will throw a fatal error like this: \begin{Code} Trace of matrix square = 1.4444444444444444 Polarization: spin density matrix spin type = 2 multiplicity = 2 massive = F chirality = 0 pol.degree = 1.0000000 pure state = F @(+1: +1: ( 3.333333333333E-01, 0.000000000000E+00)) @(-1: -1: ( 6.666666666667E-01, 0.000000000000E+00)) @(-1: +1: ( 6.666666666667E-01, 0.000000000000E+00)) ****************************************************************************** ****************************************************************************** *** FATAL ERROR: Spin density matrix: not permissible as density matrix ****************************************************************************** ****************************************************************************** \end{Code} \subsubsection{Beams with crossing angle} Specifying a crossing angle (e.g. at a linear lepton collider) without explicitly setting the beam momenta, \begin{code} sqrts = 1 TeV beams = e1, E1 beams\_theta = 0, 10 degree \end{code} triggers a fatal: \begin{Code} ****************************************************************************** ****************************************************************************** *** FATAL ERROR: Beam structure: angle theta/phi specified but momentum/a p undefined ****************************************************************************** ****************************************************************************** \end{Code} In that case the single beam momenta have to be explicitly set: \begin{code} beams = e1, E1 beams\_momentum = 500 GeV, 500 GeV beams\_theta = 0, 10 degree \end{code} \subsubsection{Phase-space generation failed} Sometimes an error might be issued that \whizard\ could not generate a valid phase-space parameterization: \begin{Code} | Phase space: ... failed. Increasing phs_off_shell ... | Phase space: ... failed. Increasing phs_off_shell ... | Phase space: ... failed. Increasing phs_off_shell ... | Phase space: ... failed. Increasing phs_off_shell ... ****************************************************************************** ****************************************************************************** *** FATAL ERROR: Phase-space: generation failed ****************************************************************************** ****************************************************************************** \end{Code} You see that \whizard\ tried to increase the number of off-shell lines that are taken into account for the phase-space setup. The second most important parameter for the phase-space setup, \ttt{phs\_t\_channel}, however, is not increased automatically. Its default value is $6$, so e.g. for the process $e^+ e^- \to 8\gamma$ you will run into the problem above. Setting \begin{code} phs_off_shell = -1 \end{code} where \ttt{} is the number of final-state particles will solve the problem. \subsubsection{Non-converging process integration} There could be several reasons for this to happen. The most prominent one is that no cuts have been specified for the process (\whizard\ttt{2} does not apply default cuts), and there are singular regions in the phase space over which the integration stumbles. If cuts have been specified, it could be that they are not sufficient. E.g. in $pp \to jj$ a distance cut between the two jets prevents singular collinear splitting in their generation, but if no $p_T$ cut have been set, there is still singular collinear splitting from the beams. \subsubsection{Why is there no event file?} If no event file has been generated, \whizard\ stumled over some error and should have told you, or, you simply forgot to set a \ttt{simulate} command for your process. In case there was a \ttt{simulate} command but the process under consideration is not possible (e.g. a typo, \ttt{e1, E1 => e2, E3} instead of \ttt{e1, E1 => e3, E3}), then you get an error like that: \begin{Code} ****************************************************************************** *** ERROR: Simulate: no process has a valid matrix element. ****************************************************************************** \end{Code} \subsubsection{Why is the event file empty?} In order to get events, you need to set either a desired number of events: \begin{code} n_events = \end{code} or you have to specify a certain integrated luminosity (the default unit being inverse femtobarn: \begin{code} luminosity = / 1 fbarn \end{code} In case you set both, \whizard\ will take the one that leads to the higher number of events. \subsubsection{Parton showering fails} For BSM models containing massive stable or long-lived particles parton showering with \pythiasix\ fails: \begin{Code} Advisory warning type 3 given after 0 PYEXEC calls: (PYRESD:) Failed to decay particle 1000022 with mass 15.000 ****************************************************************************** ****************************************************************************** *** FATAL ERROR: Simulation: failed to generate valid event after 10000 tries ****************************************************************************** ****************************************************************************** \end{Code} The solution to that problem is discussed in Sec.~\ref{sec:pythia6}. \vspace{1cm} %%%%% \subsection{Debugging, testing, and validation} \subsubsection{Catching/tracking arithmetic exceptions} Catching arithmetic exceptions is not automatically supported by \fortran\ compilers. In general, flags that cause the compiler to keep track of arithmetic exceptions are diminishing the maximally possible performance, and hence they should not be used in production runs. Hence, we refrained from making these flags a default. They can be added using the \ttt{FCFLAGS = {\em }} settings during configuration. For the \ttt{NAG} \fortran\ compiler we use the flags \ttt{-C=all -nan -gline} for debugging purposes. For the \ttt{gfortran} compilers, the flags \ttt{-ffpe-trap=invalid,zero,overflow} are the corresponding debugging flags. For tests, debugging or first sanity checks on your setup, you might want to make use of these flags in order to track possible numerical exceptions in the produced code. Some compilers started to include \ttt{IEEE} exception handling support (\ttt{Fortran 2008} status), but we do not use these implementations in the \whizard\ code (yet). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Steering WHIZARD: \sindarin\ Overview} \label{chap:sindarinintro} \section{The command language for WHIZARD} A conventional physics application program gets its data from a set of input files. Alternatively, it is called as a library, so the user has to write his own code to interface it, or it combines these two approaches. \whizard~1 was built in this way: there were some input files which were written by the user, and it could be called both stand-alone or as an external library. \whizard~2 is also a stand-alone program. It comes with its own full-fledged script language, called \sindarin. All interaction between the user and the program is done in \sindarin\ expressions, commands, and scripts. Two main reasons led us to this choice: \begin{itemize} \item In any nontrivial physics study, cuts and (parton- or hadron-level) analysis are of central importance. The task of specifying appropriate kinematics and particle selection for a given process is well defined, but it is impossible to cover all possiblities in a simple format like the cut files of \whizard~1. The usual way of dealing with this problem is to write analysis driver code (often in \ttt{C++}), using external libraries for Lorentz algebra etc. However, the overhead of writing correct \ttt{C++} or \ttt{Fortran} greatly blows up problems that could be formulated in a few lines of text. \item While many problems lead to a repetitive workflow (process definition, integration, simulation), there are more involved tasks that involve parameter scans, comparisons of different processes, conditional execution, or writing output in widely different formats. This is easily done by a steering script, which should be formulated in a complete language. \end{itemize} The \sindarin\ language is built specifically around event analysis, suitably extended to support steering, including data types, loops, conditionals, and I/O. It would have been possible to use an established general-purpose language for these tasks. For instance, \ocaml\ which is a functional language would be a suitable candidate, and the matrix-element generator \oMega\ is written in that language. Another candidate would be a popular scripting language such as PYTHON. We started to support interfaces for commonly used languages: prime examples for \ttt{C}, \ttt{C++}, and PYTHON are found in the \ttt{share/interfaces} subdirectory. However, introducing a special-purpose language has the three distinct advantages: First, it is compiled and executed by the very \ttt{Fortran} code that handles data and thus accesses it without interfaces. Second, it can be designed with a syntax especially suited to the task of event handling and Monte-Carlo steering, and third, the user is not forced to learn all those features of a generic language that are of no relevance to the application he/she is interested in. \section{\sindarin\ scripts} A \sindarin\ script tells the \whizard\ program what it has to do. Typically, the script is contained in a file which you (the user) create. The file name is arbitrary; by convention, it has the extension `\verb|.sin|'. \whizard\ takes the file name as its argument on the command line and executes the contained script: \begin{verbatim} /home/user$ whizard script.sin \end{verbatim} Alternatively, you can call \whizard\ interactively and execute statements line by line; we describe this below in Sec.\ref{sec:whish}. A \sindarin\ script is a sequence of \emph{statements}, similar to the statements in any imperative language such as \ttt{Fortran} or \ttt{C}. Examples of statements are commands like \ttt{integrate}, variable declarations like \ttt{logical ?flag} or assigments like \ttt{mH = 130 GeV}. The script is free-form, i.e., indentation, extra whitespace and newlines are syntactically insignificant. In contrast to most languages, there is no statement separator. Statements simply follow each other, just separated by whitespace. \begin{code} statement1 statement2 statement3 statement4 \end{code} Nevertheless, for clarity we recommend to write one statement per line where possible, and to use proper indentation for longer statements, nested and bracketed expressions. A command may consist of a \emph{keyword}, a list of \emph{arguments} in parantheses \ttt{(}\ldots\ttt{)}, and an \emph{option} script which itself is a sequence of statements. \begin{code} command command_with_args (arg1, arg2) command_with_option { option } command_with_options (arg) { option_statement1 option_statement2 } \end{code} As a rule, parentheses \ttt{()} enclose arguments and expressions, as you would expect. Arguments enclosed in square brackets \ttt{[]} also exist. They have a special meaning, they denote subevents (collections of momenta) in event analysis. Braces \ttt{\{\}} enclose blocks of \sindarin\ code. In particular, the option script associated with a command is a block of code that may contain local parameter settings, for instance. Braces always indicate a scoping unit, so parameters will be restored their previous values when the execution of that command is completed. The script can contain comments. Comments are initiated by either a \verb|#| or a \verb|!| character and extend to the end of the current line. \begin{code} statement # This is a comment statement ! This is also a comment \end{code} %%%%%%%%%%%%%%% \section{Errors} \label{sec:errors} Before turning to proper \sindarin\ syntax, let us consider error messages. \sindarin\ distinguishes syntax errors and runtime errors. Syntax errors are recognized when the script is read and compiled, before any part is executed. Look at this example: \begin{code} process foo = u, ubar => d, dbar md = 10 integrade (foo) \end{code} \whizard\ will fail with the error message \begin{interaction} sqrts = 1 TeV integrade (foo) ^^ | Expected syntax: SEQUENCE = '=' | Found token: KEYWORD: '(' ****************************************************************************** ****************************************************************************** *** FATAL ERROR: Syntax error (at or before the location indicated above) ****************************************************************************** ****************************************************************************** WHIZARD run aborted. \end{interaction} which tells you that you have misspelled the command \verb|integrate|, so the compiler tried to interpret it as a variable. Runtime errors are categorized by their severity. A warning is simply printed: \begin{interaction} Warning: No cuts have been defined. \end{interaction} This indicates a condition that is suspicious, but may actually be intended by the user. When an error is encountered, it is printed with more emphasis \begin{interaction} ****************************************************************************** *** ERROR: Variable 'md' set without declaration ****************************************************************************** \end{interaction} and the program tries to continue. However, this usually indicates that there is something wrong. (The $d$ quark is defined massless, so \verb|md| is not a model parameter.) \whizard\ counts errors and warnings and tells you at the end \begin{interaction} | There were 1 error(s) and no warnings. \end{interaction} just in case you missed the message. Other errors are considered fatal, and execution stops at this point. \begin{interaction} ****************************************************************************** ****************************************************************************** *** FATAL ERROR: Colliding beams: sqrts is zero (please set sqrts) ****************************************************************************** ****************************************************************************** \end{interaction} Here, \whizard\ was unable to do anything sensible. But at least (in this case) it told the user what to do to resolve the problem. %%%%%%%%%%%%%%% \section{Statements} \label{sec:statements} \sindarin\ statements are executed one by one. For an overview, we list the most common statements in the order in which they typically appear in a \sindarin\ script, and quote the basic syntax and simple examples. This should give an impression on the \whizard's capabilities and on the user interface. The list is not complete. Note that there are no mandatory commands (although an empty \sindarin\ script is not really useful). The details and options are explained in later sections. \subsection{Process Configuration} \subsubsection{model} \begin{syntax} model = \var{model-name} \end{syntax} This assignment sets or resets the current physics model. The Standard Model is already preloaded, so the \ttt{model} assignment applies to non-default models. Obviously, the model must be known to \whizard. Example: \begin{code} model = MSSM \end{code} See Sec.~\ref{sec:models}. \subsubsection{alias} \begin{syntax} alias \var{alias-name} = \var{alias-definition} \end{syntax} Particles are specified by their names. For most particles, there are various equivalent names. Names containing special characters such as a \verb|+| sign have to be quoted. The \ttt{alias} assignment defines an alias for a list of particles. This is useful for setting up processes with sums over flavors, cut expressions, and more. The alias name is then used like a simple particle name. Example: \begin{syntax} alias jet = u:d:s:U:D:S:g \end{syntax} See Sec.~\ref{sec:alias}. \subsubsection{process} \begin{syntax} process \var{tag} = \var{incoming} \verb|=>| \var{outgoing} \end{syntax} Define a process. You give the process a name \var{tag} by which it is identified later, and specify the incoming and outgoing particles, and possibly options. You can define an arbitrary number of processes as long as they are distinguished by their names. Example: \begin{code} process w_plus_jets = g, g => "W+", jet, jet \end{code} See Sec.~\ref{sec:processes}. \subsubsection{sqrts} \begin{syntax} sqrts = \var{energy-value} \end{syntax} Define the center-of-mass energy for collision processes. The default setup will assume head-on central collisions of two beams. Example: \begin{code} sqrts = 500 GeV \end{code} See Sec.~\ref{sec:beam-setup}. \subsubsection{beams} \begin{syntax} beams = \var{beam-particles} \\ beams = \var{beam-particles} => \var{structure-function-setup} \end{syntax} Declare beam particles and properties. The current value of \ttt{sqrts} is used, unless specified otherwise. Example: \begin{code} beams = u:d:s, U:D:S => lhapdf \end{code} With options, the assignment allows for defining beam structure in some detail. This includes beamstrahlung and ISR for lepton colliders, precise structure function definition for hadron colliders, asymmetric beams, beam polarization, and more. See Sec.~\ref{sec:beams}. \subsection{Parameters} \subsubsection{Parameter settings} \begin{syntax} \var{parameter} = \var{value} \\ \var{type} \var{user-parameter} \\ \var{type} \var{user-parameter} = \var{value} \end{syntax} Specify a value for a parameter. There are predefined parameters that affect the behavior of a command, model-specific parameters (masses, couplings), and user-defined parameters. The latter have to be declared with a type, which may be \ttt{int} (integer), \ttt{real}, \ttt{complex}, \ttt{logical}, \ttt{string}, or \ttt{alias}. Logical parameter names begin with a question mark, string parameter names with a dollar sign. Examples: \begin{code} mb = 4.2 GeV ?rebuild_grids = true real mass_sum = mZ + mW string $message = "This is a string" \end{code} % $ The value need not be a literal, it can be an arbitrary expression of the correct type. See Sec.~\ref{sec:variables}. \subsubsection{read\_slha} \begin{syntax} read\_slha (\var{filename}) \end{syntax} This is useful only for supersymmetric models: read a parameter file in the SUSY Les Houches Accord format. The file defines parameter values and, optionally, decay widths, so this command removes the need for writing assignments for each of them. \begin{code} read_slha ("sps1a.slha") \end{code} See Sec.~\ref{sec:slha}. \subsubsection{show} \begin{syntax} show (\var{data-objects}) \end{syntax} Print the current value of some data object. This includes not just variables, but also models, libraries, cuts, etc. This is rather a debugging aid, so don't expect the output to be concise in the latter cases. Example: \begin{code} show (mH, wH) \end{code} See Sec.~\ref{sec:I/O}. \subsubsection{printf} \begin{syntax} printf \var{format-string} (\var{data-objects}) \end{syntax} Pretty-print the data objects according to the given format string. If there are no data objects, just print the format string. This command is borrowed from the \ttt{C} programming language; it is actually an interface to the system's \ttt{printf(3)} function. The conversion specifiers are restricted to \ttt{d,i,e,f,g,s}, corresponding to the output of integer, real, and string variables. Example: \begin{code} printf "The Higgs mass is %f GeV" (mH) \end{code} See Sec.~\ref{sec:I/O}. \subsection{Integration} \subsubsection{cuts} \begin{syntax} cuts = \var{logical-cut-expression} \end{syntax} The cut expression is a logical macro expression that is evaluated for each phase space point during integration and event generation. You may construct expressions out of various observables that are computed for the (partonic) particle content of the current event. If the expression evaluates to \verb|true|, the matrix element is calculated and the event is used. If it evaluates to \verb|false|, the matrix element is set zero and the event is discarded. Note that for collisions the expression is evaluated in the lab frame, while for decays it is evaluated in the rest frame of the decaying particle. In case you want to impose cuts on a factorized process, i.e. a combination of a production process and one or more decay processes, you have to use the \ttt{selection} keyword instead. Example for the keyword \ttt{cuts}: \begin{code} cuts = all Pt > 20 GeV [jet] and all mZ - 10 GeV < M < mZ + 10 GeV [lepton, lepton] and no abs (Eta) < 2 [jet] \end{code} See Sec.~\ref{sec:cuts}. \subsubsection{integrate} \begin{syntax} integrate (\var{process-tags}) \end{syntax} Compute the total cross section for a process. The command takes into account the definition of the process, the beam setup, cuts, and parameters as defined in the script. Parameters may also be specified as options to the command. Integration is necessary for each process for which you want to know total or differential cross sections, or event samples. Apart from computing a value, it sets up and adapts phase space and integration grids that are used in event generation. If you just need an event sample, you can omit an explicit \ttt{integrate} command; the \ttt{simulate} command will call it automatically. Example: \begin{code} integrate (w_plus_jets, z_plus_jets) \end{code} See Sec.~\ref{sec:integrate}. \subsubsection{?phs\_only/n\_calls\_test} \begin{syntax} integrate (\var{process-tag}) \{ ?phs\_only = true n\_calls\_test = 1000 \} \end{syntax} These are just optional settings for the \ttt{integrate} command discussed just a second ago. The \ttt{?phs\_only = true} (note that variables starting with a question mark are logicals) option tells \whizard\ to prepare a process for integration, but instead of performing the integration, just to generate a phase space parameterization. \ttt{n\_calls\_test = } evaluates the sampling function for random integration channels and random momenta. \vamp\ integration grids are neither generated nor used, so the channel selection corresponds to the first integration pass, before any grids or channel weights are adapted. The number of sampling points is given by \verb||. The output contains information about the timing, number of sampling points that passed the kinematics selection, and the number of matrix-element values that were actually evaluated. This command is useful mainly for debugging and diagnostics. Example: \begin{code} integrate (some_large_process) { ?phs_only = true n_calls_test = 1000 } \end{code} (Note that there used to be a separate command \ttt{matrix\_element\_test} until version 2.1.1 of \whizard\ which has been discarded in order to simplify the \sindarin\ syntax.) \subsection{Events} \subsubsection{histogram} \begin{syntax} histogram \var{tag} (\var{lower-bound}, \var{upper-bound}) \\ histogram \var{tag} (\var{lower-bound}, \var{upper-bound}, \var{step}) \\ \end{syntax} Declare a histogram for event analysis. The histogram is filled by an analysis expression, which is evaluated once for each event during a subsequent simulation step. Example: \begin{code} histogram pt_distribution (0, 150 GeV, 10 GeV) \end{code} See Sec.~\ref{sec:histogram}. \subsubsection{plot} \begin{syntax} plot \var{tag} \end{syntax} Declare a plot for displaying data points. The plot may be filled by an analysis expression that is evaluated for each event; this would result in a scatter plot. More likely, you will use this feature for displaying data such as the energy dependence of a cross section. Example: \begin{code} plot total_cross_section \end{code} See Sec.~\ref{sec:plot}. \subsubsection{selection} \begin{syntax} selection = \var{selection-expression} \end{syntax} The selection expression is a logical macro expression that is evaluated once for each event. It is applied to the event record, after all decays have been executed (if any). It is therefore intended e.g. for modelling detector acceptance cuts etc. For unfactorized processes the usage of \ttt{cuts} or \ttt{selection} leads to the same results. Events for which the selection expression evaluates to false are dropped; they are neither analyzed nor written to any user-defined output file. However, the dropped events are written to \whizard's native event file. For unfactorized processes it is therefore preferable to implement all cuts using the \ttt{cuts} keyword for the integration, see \ttt{cuts} above. Example: \begin{code} selection = all Pt > 50 GeV [lepton] \end{code} The syntax is generically the same as for the \ttt{cuts expression}, see Sec.~\ref{sec:cuts}. For more information see also Sec.~\ref{sec:analysis}. \subsubsection{analysis} \begin{syntax} analysis = \var{analysis-expression} \end{syntax} The analysis expression is a logical macro expression that is evaluated once for each event that passes the integration and selection cuts in a subsequent simulation step. The expression has type logical in analogy with the cut expression; however, its main use will be in side effects caused by embedded \ttt{record} expressions. The \ttt{record} expression books a value, calculated from observables evaluated for the current event, in one of the predefined histograms or plots. Example: \begin{code} analysis = record pt_distribution (eval Pt [photon]) and record mval (eval M [lepton, lepton]) \end{code} See Sec.~\ref{sec:analysis}. \subsubsection{unstable} \begin{syntax} unstable \var{particle} (\var{decay-channels}) \end{syntax} Specify that a particle can decay, if it occurs in the final state of a subsequent simulation step. (In the integration step, all final-state particles are considered stable.) The decay channels are processes which should have been declared before by a \ttt{process} command (alternatively, there are options that \whizard\ takes care of this automatically; cf. Sec.~\ref{sec:decays}). They may be integrated explicitly, otherwise the \ttt{unstable} command will take care of the integration before particle decays are generated. Example: \begin{code} unstable Z (z_ee, z_jj) \end{code} Note that the decay is an on-shell approximation. Alternatively, \whizard\ is capable of generating the final state(s) directly, automatically including the particle as an internal resonance together with irreducible background. Depending on the physical problem and on the complexity of the matrix-element calculation, either option may be more appropriate. See Sec.~\ref{sec:decays}. \subsubsection{n\_events} \begin{syntax} n\_events = \var{integer} \end{syntax} Specify the number of events that a subsequent simulation step should produce. By default, simulated events are unweighted. (Unweighting is done by a rejection operation on weighted events, so the usual caveats on event unweighting by a numerical Monte-Carlo generator do apply.) Example: \begin{code} n_events = 20000 \end{code} See Sec.~\ref{sec:simulation}. \subsubsection{simulate} \begin{syntax} simulate (\var{process-tags}) \end{syntax} Generate an event sample. The command allows for analyzing the generated events by the \ttt{analysis} expression. Furthermore, events can be written to file in various formats. Optionally, the partonic events can be showered and hadronized, partly using included external (\pythia) or truly external programs called by \whizard. Example: \begin{code} simulate (w_plus_jets) { sample_format = lhef } \end{code} See Sec.~\ref{sec:simulation} and Chapter~\ref{chap:events}. \subsubsection{graph} \begin{syntax} graph (\var{tag}) = \var{histograms-and-plots} \end{syntax} Combine existing histograms and plots into a common graph. Also useful for pretty-printing single histograms or plots. Example: \begin{code} graph comparison { $title = "$p_T$ distribution for two different values of $m_h$" } = hist1 & hist2 \end{code} % $ See Sec.~\ref{sec:graphs}. \subsubsection{write\_analysis} \begin{syntax} write\_analysis (\var{analysis-objects}) \end{syntax} Writes out data tables for the specified analysis objects (plots, graphs, histograms). If the argument is empty or absent, write all analysis objects currently available. The tables are available for feeding external programs. Example: \begin{code} write_analysis \end{code} See Sec.~\ref{sec:analysis}. \subsubsection{compile\_analysis} \begin{syntax} compile\_analysis (\var{analysis-objects}) \end{syntax} Analogous to \ttt{write\_analysis}, but the generated data tables are processed by \LaTeX\ and \gamelan, which produces Postscript and PDF versions of the displayed data. Example: \begin{code} compile_analysis \end{code} See Sec.~\ref{sec:analysis}. \section{Control Structures} Like any complete programming language, \sindarin\ provides means for branching and looping the program flow. \subsection{Conditionals} \subsubsection{if} \begin{syntax} if \var{logical\_expression} then \var{statements} \\ elsif \var{logical\_expression} then \var{statements} \\ else \var{statements} \\ endif \end{syntax} Execute statements conditionally, depending on the value of a logical expression. There may be none or multiple \ttt{elsif} branches, and the \ttt{else} branch is also optional. Example: \begin{code} if (sqrts > 2 * mtop) then integrate (top_pair_production) else printf "Top pair production is not possible" endif \end{code} The current \sindarin\ implementation puts some restriction on the statements that can appear in a conditional. For instance, process definitions must be done unconditionally. \subsection{Loops} \subsubsection{scan} \begin{syntax} scan \var{variable} = (\var{value-list}) \{ \var{statements} \} \end{syntax} Execute the statements repeatedly, once for each value of the scan variable. The statements are executed in a local context, analogous to the option statement list for commands. The value list is a comma-separated list of expressions, where each item evaluates to the value that is assigned to \ttt{\var{variable}} for this iteration. The type of the variable is not restricted to numeric, scans can be done for various object types. For instance, here is a scan over strings: \begin{code} scan string $str = ("%.3g", "%.4g", "%.5g") { printf $str (mW) } \end{code} % $ The output: \begin{interaction} [user variable] $str = "%.3g" 80.4 [user variable] $str = "%.4g" 80.42 [user variable] $str = "%.5g" 80.419 \end{interaction} % $ For a numeric scan variable in particular, there are iterators that implement the usual functionality of \ttt{for} loops. If the scan variable is of type integer, an iterator may take one of the forms \begin{syntax} \var{start-value} \verb|=>| \var{end-value} \\ \var{start-value} \verb|=>| \var{end-value} \verb|/+| \var{add-step} \\ \var{start-value} \verb|=>| \var{end-value} \verb|/-| \var{subtract-step} \\ \var{start-value} \verb|=>| \var{end-value} \verb|/*| \var{multiplicator} \\ \var{start-value} \verb|=>| \var{end-value} \verb|//| \var{divisor} \\ \end{syntax} The iterator can be put in place of an expression in the \ttt{\var{value-list}}. Here is an example: \begin{code} scan int i = (1, (3 => 5), (10 => 20 /+ 4)) \end{code} which results in the output \begin{interaction} [user variable] i = 1 [user variable] i = 3 [user variable] i = 4 [user variable] i = 5 [user variable] i = 10 [user variable] i = 14 [user variable] i = 18 \end{interaction} [Note that the \ttt{\var{statements}} part of the scan construct may be empty or absent.] For real scan variables, there are even more possibilities for iterators: \begin{syntax} \var{start-value} \verb|=>| \var{end-value} \\ \var{start-value} \verb|=>| \var{end-value} \verb|/+| \var{add-step} \\ \var{start-value} \verb|=>| \var{end-value} \verb|/-| \var{subtract-step} \\ \var{start-value} \verb|=>| \var{end-value} \verb|/*| \var{multiplicator} \\ \var{start-value} \verb|=>| \var{end-value} \verb|//| \var{divisor} \\ \var{start-value} \verb|=>| \var{end-value} \verb|/+/| \var{n-points-linear} \\ \var{start-value} \verb|=>| \var{end-value} \verb|/*/| \var{n-points-logarithmic} \\ \end{syntax} The first variant is equivalent to \ttt{/+ 1}. The \ttt{/+} and \ttt{/-} operators are intended to add or subtract the given step once for each iteration. Since in floating-point arithmetic this would be plagued by rounding ambiguities, the actual implementation first determines the (integer) number of iterations from the provided step value, then recomputes the step so that the iterations are evenly spaced with the first and last value included. The \ttt{/*} and \ttt{//} operators are analogous. Here, the initial value is intended to be multiplied by the step value once for each iteration. After determining the integer number of iterations, the actual scan values will be evenly spaced on a logarithmic scale. Finally, the \ttt{/+/} and \ttt{/*/} operators allow to specify the number of iterations (not counting the initial value) directly. The \ttt{\var{start-value}} and \ttt{\var{end-value}} are always included, and the intermediate values will be evenly spaced on a linear (\ttt{/+/}) or logarithmic (\ttt{/*/}) scale. Example: \begin{code} scan real mh = (130 GeV, (140 GeV => 160 GeV /+ 5 GeV), 180 GeV, (200 GeV => 1 TeV /*/ 10)) { integrate (higgs_decay) } \end{code} \subsection{Including Files} \subsubsection{include} \begin{syntax} include (\var{file-name}) \end{syntax} Include a \sindarin\ script from the specified file. The contents must be complete commands; they are compiled and executed as if they were part of the current script. Example: \begin{code} include ("default_cuts.sin") \end{code} \section{Expressions} \sindarin\ expressions are classified by their types. The type of an expression is verified when the script is compiled, before it is executed. This provides some safety against simple coding errors. Within expressions, grouping is done using ordinary brackets \ttt{()}. For subevent expressions, use square brackets \ttt{[]}. \subsection{Numeric} The language supports the classical numeric types \begin{itemize} \item \ttt{int} for integer: machine-default, usually 32 bit; \item \ttt{real}, usually \emph{double precision} or 64 bit; \item \ttt{complex}, consisting of real and imaginary part equivalent to a \ttt{real} each. \end{itemize} \sindarin\ supports arithmetic expressions similar to conventional languages. In arithmetic expressions, the three numeric types can be mixed as appropriate. The computation essentially follows the rules for mixed arithmetic in \ttt{Fortran}. The arithmetic operators are \verb|+|, \verb|-|, \verb|*|, \verb|/|, \verb|^|. Standard functions such as \ttt{sin}, \ttt{sqrt}, etc. are available. See Sec.~\ref{sec:real} to Sec.~\ref{sec:complex}. Numeric values can be associated with units. Units evaluate to numerical factors, and their use is optional, but they can be useful in the physics context for which \whizard\ is designed. Note that the default energy/mass unit is \verb|GeV|, and the default unit for cross sections is \verb|fbarn|. \subsection{Logical and String} The language also has the following standard types: \begin{itemize} \item \ttt{logical} (a.k.a.\ boolean). Logical variable names have a \ttt{?} (question mark) as prefix. \item \ttt{string} (arbitrary length). String variable names have a \ttt{\$} (dollar) sign as prefix. \end{itemize} There are comparisons, logical operations, string concatenation, and a mechanism for formatting objects as strings for output. \subsection{Special} Furthermore, \sindarin\ deals with a bunch of data types tailored specifically for Monte Carlo applications: \begin{itemize} \item \ttt{alias} objects denote a set of particle species. \item \ttt{subevt} objects denote a collection of particle momenta within an event. They have their uses in cut and analysis expressions. \item \ttt{process} object are generated by a \ttt{process} statement. There are no expressions involving processes, but they are referred to by \ttt{integrate} and \ttt{simulate} commands. \item \ttt{model}: There is always a current object of type and name \ttt{model}. Several models can be used concurrently by appropriately defining processes, but this happens behind the scenes. \item \ttt{beams}: Similarly, the current implementation allows only for a single object of this type at a given time, which is assigned by a \ttt{beams =} statement and used by \ttt{integrate}. \end{itemize} In the current implementation, \sindarin\ has no container data types derived from basic types, such as lists, arrays, or hashes, and there are no user-defined data types. (The \ttt{subevt} type is a container for particles in the context of events, but there is no type for an individual particle: this is represented as a one-particle \ttt{subevt}). There are also containers for inclusive processes which are however simply handled as an expansion into several components of a master process tag. \section{Variables} \label{sec:variables} \sindarin\ supports global variables, variables local to a scoping unit (the option body of a command, the body of a \ttt{scan} loop), and variables local to an expression. Some variables are predefined by the system (\emph{intrinsic variables}). They are further separated into \emph{independent} variables that can be reset by the user, and \emph{derived} or locked variables that are automatically computed by the program, but not directly user-modifiable. On top of that, the user is free to introduce his own variables (\emph{user variables}). The names of numerical variables consist of alphanumeric characters and underscores. The first character must not be a digit. Logical variable names are furthermore prefixed by a \ttt{?} (question mark) sign, while string variable names begin with a \ttt{\$} (dollar) sign. Character case does matter. In this manual we follow the convention that variable names consist of lower-case letters, digits, and underscores only, but you may also use upper-case letters if you wish. Physics models contain their own, specific set of numeric variables (masses, couplings). They are attached to the model where they are defined, so they appear and disappear with the model that is currently loaded. In particular, if two different models contain a variable with the same name, these two variables are nevertheless distinct: setting one doesn't affect the other. This feature might be called, in computer-science jargon, a \emph{mixin}. User variables -- global or local -- are declared by their type when they are introduced, and acquire an initial value upon declaration. Examples: \begin{quote} \begin{footnotesize} \begin{verbatim} int i = 3 real my_cut_value = 10 GeV complex c = 3 - 4 * I logical ?top_decay_allowed = mH > 2 * mtop string $hello = "Hello world!" alias q = d:u:s:c \end{verbatim} \end{footnotesize} \end{quote} An existing user variable can be assigned a new value without a declaration: \begin{quote} \begin{footnotesize} \begin{verbatim} i = i + 1 \end{verbatim} \end{footnotesize} \end{quote} and it may also be redeclared if the new declaration specifies the same type, this is equivalent to assigning a new value. Variables local to an expression are introduced by the \ttt{let ... in} contruct. Example: \begin{quote} \begin{footnotesize} \begin{verbatim} real a = let int n = 2 in x^n + y^n \end{verbatim} \end{footnotesize} \end{quote} The explicit \ttt{int} declaration is necessary only if the variable \ttt{n} has not been declared before. An intrinsic variable must not be declared: \ttt{let mtop = 175.3 GeV in \ldots} \ttt{let} constructs can be concatenated if several local variables need to be assigned: \ttt{let a = 3 in let b = 4 in \textit{expression}}. Variables of type \ttt{subevt} can only be defined in \ttt{let} constructs. Exclusively in the context of particle selections (event analysis), there are \emph{observables} as special numeric objects. They are used like numeric variables, but they are never declared or assigned. They get their value assigned dynamically, computed from the particle momentum configuration. Hence, they may be understood as (intrinsic and predefined) macros. By convention, observable names begin with a capital letter. Further macros are \begin{itemize} \item \ttt{cuts} and \ttt{analysis}. They are of type logical, and can be assigned an expression by the user. They are evaluated once for each event. \item \ttt{scale}, \ttt{factorization\_scale} and \ttt{renormalization\_scale} are real numeric macros which define the energy scale(s) of an event. The latter two override the former. If no scale is defined, the partonic energy is used as the process scale. \item \ttt{weight} is a real numeric macro. If it is assigned an expression, the expression is evaluated for each valid phase-space point, and the result multiplies the matrix element. \end{itemize} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{\sindarin\ in Details} \label{chap:sindarin} \section{Data and expressions} \subsection{Real-valued objects} \label{sec:real} Real literals have their usual form, mantissa and, optionally, exponent: \begin{center} \ttt{0.}\quad \ttt{3.14}\quad \ttt{-.5}\quad \ttt{2.345e-3}\quad \ttt{.890E-023} \end{center} Internally, real values are treated as double precision. The values are read by the Fortran library, so details depend on its implementation. A special feature of \sindarin\ is that numerics (real and integer) can be immediately followed by a physical unit. The supported units are presently hard-coded, they are \begin{center} \ttt{meV}\quad \ttt{eV}\quad \ttt{keV}\quad \ttt{MeV}\quad \ttt{GeV}\quad \ttt{TeV} \\ \ttt{nbarn}\quad \ttt{pbarn}\quad \ttt{fbarn}\quad \ttt{abarn} \\ \ttt{rad}\quad \ttt{mrad}\quad \ttt{degree} \\ \ttt{\%} \end{center} If a number is followed by a unit, it is automatically normalized to the corresponding default unit: \ttt{14.TeV} is transformed into the real number \ttt{14000.} Default units are \ttt{GeV}, \ttt{fbarn}, and \ttt{rad}. The \ttt{\%} sign after a number has the effect that the number is multiplied by $0.01$. Note that no checks for consistency of units are done, so you can add \ttt{1 meV + 3 abarn} if you absolutely wish to. Omitting units is always allowed, in that case, the default unit is assumed. Units are not treated as variables. In particular, you can't write \ttt{theta / degree}, the correct form is \ttt{theta / 1 degree}. There is a single predefined real constant, namely $\pi$ which is referred to by the keyword \ttt{pi}. In addition, there is a single predefined complex constant, which is the complex unit $i$, being referred to by the keyword \ttt{I}. The arithmetic operators are \begin{center} \verb|+| \verb|-| \verb|*| \verb|/| \verb|^| \end{center} with their obvious meaning and the usual precedence rules. \sindarin\ supports a bunch of standard numerical functions, mostly equivalent to their Fortran counterparts: \begin{center} \ttt{abs}\quad \ttt{conjg}\quad \ttt{sgn}\quad \ttt{mod}\quad \ttt{modulo} \\ \ttt{sqrt}\quad \ttt{exp}\quad \ttt{log}\quad \ttt{log10} \\ \ttt{sin}\quad \ttt{cos}\quad \ttt{tan}\quad \ttt{asin}\quad \ttt{acos}\quad \ttt{atan} \\ \ttt{sinh}\quad \ttt{cosh}\quad \ttt{tanh} \end{center} (Unlike Fortran, the \ttt{sgn} function takes only one argument and returns $1.$, or $-1.$) The function argument is enclosed in brackets: \ttt{sqrt (2.)}, \ttt{tan (11.5 degree)}. There are two functions with two real arguments: \begin{center} \ttt{max}\quad \ttt{min} \end{center} Example: \verb|real lighter_mass = min (mZ, mH)| The following functions of a real convert to integer: \begin{center} \ttt{int}\quad \ttt{nint}\quad \ttt{floor}\quad \ttt{ceiling} %% \; . \end{center} and this converts to complex type: \begin{center} \ttt{complex} \end{center} Real values can be compared by the following operators, the result is a logical value: \begin{center} \verb|==|\quad \verb|<>| \\ \verb|>|\quad \verb|<|\quad \verb|>=|\quad \verb|<=| \end{center} In \sindarin, it is possible to have more than two operands in a logical expressions. The comparisons are done from left to right. Hence, \begin{center} \verb|115 GeV < mH < 180 GeV| \end{center} is valid \sindarin\ code and evaluates to \ttt{true} if the Higgs mass is in the given range. Tests for equality and inequality with machine-precision real numbers are notoriously unreliable and should be avoided altogether. To deal with this problem, \sindarin\ has the possibility to make the comparison operators ``fuzzy'' which should be read as ``equal (unequal) up to an absolute tolerance'', where the tolerance is given by the real-valued intrinsic variable \ttt{tolerance}. This variable is initially zero, but can be set to any value (for instance, \ttt{tolerance = 1.e-13} by the user. Note that for non-zero tolerance, operators like \verb|==| and \verb|<>| or \verb|<| and \verb|>| are not mutually exclusive\footnote{In older versions of \whizard, until v2.1.1, there used to be separate comparators for the comparisons up to a tolerance, namely \ttt{==\~{}} and \ttt{<>\~{}}. These have been discarded from v2.2.0 on in order to simplify the syntax.}. %%%%%%%%%%%%%%% \subsection{Integer-valued objects} \label{sec:integer} Integer literals are obvious: \begin{center} \ttt{1}\quad \ttt{-98765}\quad \ttt{0123} \end{center} Integers are always signed. Their range is the default-integer range as determined by the \fortran\ compiler. Like real values, integer values can be followed by a physical unit: \ttt{1 TeV}, \ttt{30 degree}. This actually transforms the integer into a real. Standard arithmetics is supported: \begin{center} \verb|+| \verb|-| \verb|*| \verb|/| \verb|^| \end{center} It is important to note that there is no fraction datatype, and pure integer arithmetics does not convert to real. Hence \ttt{3/4} evaluates to \ttt{0}, but \ttt{3 GeV / 4 GeV} evaluates to \ttt{0.75}. Since all arithmetics is handled by the underlying \fortran\ library, integer overflow is not detected. If in doubt, do real arithmetics. Integer functions are more restricted than real functions. We support the following: \begin{center} \ttt{abs}\quad \ttt{sgn}\quad \ttt{mod}\quad \ttt{modulo} \\ \ttt{max}\quad \ttt{min} \end{center} and the conversion functions \begin{center} \ttt{real}\quad \ttt{complex} \end{center} Comparisons of integers among themselves and with reals are possible using the same set of comparison operators as for real values. This includes the operators with a finite tolerance. %%%%%%%%%%%%%%%% \subsection{Complex-valued objects} \label{sec:complex} Complex variables and values are currently not yet used by the physics models implemented in \whizard. There complex input coupling constants are always split into their real and imaginary parts (or modulus and phase). They are exclusively available for arithmetic calculations. There is no form for complex literals. Complex values must be created via an arithmetic expression, \begin{center} \ttt{complex c = 1 + 2 * I} \end{center} where the imaginary unit \ttt{I} is predefined as a constant. The standard arithmetic operations are supported (also mixed with real and integer). Support for functions is currently still incomplete, among the supported functions there are \ttt{sqrt}, \ttt{log}, \ttt{exp}. \subsection{Logical-valued objects} There are two predefined logical constants, \ttt{true} and \ttt{false}. Logicals are \emph{not} equivalent to integers (like in C) or to strings (like in PERL), but they make up a type of their own. Only in \verb|printf| output, they are treated as strings, that is, they require the \verb|%s| conversion specifier. The names of logical variables begin with a question mark \ttt{?}. Here is the declaration of a logical user variable: \begin{quote} \begin{footnotesize} \begin{footnotesize} \begin{verbatim} logical ?higgs_decays_into_tt = mH > 2 * mtop \end{verbatim} \end{footnotesize} \end{footnotesize} \end{quote} Logical expressions use the standard boolean operations \begin{center} \ttt{or}\quad \ttt{and}\quad \ttt{not} \end{center} The results of comparisons (see above) are logicals. There is also a special logical operator with lower priority, concatenation by a semicolon: \begin{center} \ttt{\textit{lexpr1} ; \textit{lexpr2}} \end{center} This evaluates \textit{lexpr1} and throws its result away, then evaluates \textit{lexpr2} and returns that result. This feature is to used with logical expressions that have a side effect, namely the \ttt{record} function within analysis expressions. The primary use for intrinsic logicals are flags that change the behavior of commands. For instance, \ttt{?unweighted = true} and \ttt{?unweighted = false} switch the unweighting of simulated event samples on and off. \subsection{String-valued objects and string operations} \label{sec:sprintf} String literals are enclosed in double quotes: \ttt{"This is a string."} The empty string is \ttt{""}. String variables begin with the dollar sign: \verb|$|. There is only one string operation, concatenation \begin{quote} \begin{footnotesize} \begin{verbatim} string $foo = "abc" & "def" \end{verbatim} \end{footnotesize} \end{quote} However, it is possible to transform variables and values to a string using the \ttt{sprintf} function. This function is an interface to the system's \ttt{C} function \ttt{sprintf} with some restrictions and modifications. The allowed conversion specifiers are \begin{center} \verb|%d|\quad \verb|%i| (integer) \\ \verb|%e|\quad \verb|%f|\quad \verb|%g|\quad \verb|%E|\quad \verb|%F|\quad \verb|%G| (real) \\ \verb|%s| (string and logical) \end{center} The conversions can use flag parameter, field width, and precision, but length modifiers are not supported since they have no meaning for the application. (See also Sec.~\ref{sec:I/O}.) The \ttt{sprintf} function has the syntax \begin{center} \ttt{sprintf} \textit{format-string} \ttt{(}\textit{arg-list}\ttt{)} \end{center} This is an expression that evaluates to a string. The format string contains the mentioned conversion specifiers. The argument list is optional. The arguments are separated by commas. Allowed arguments are integer, real, logical, and string variables, and numeric expressions. Logical and string expressions can also be printed, but they have to be dressed as \emph{anonymous variables}. A logical anonymous variable has the form \ttt{?(}\textit{logical\_expr}\ttt{)} (example: \ttt{?(mH > 115 GeV)}). A string anonymous variable has the form \ttt{\$(}\textit{string-expr}\ttt{)}. Example: \begin{quote} \begin{footnotesize} \begin{verbatim} string $unit = "GeV" string $str = sprintf "mW = %f %s" (mW, $unit) \end{verbatim} \end{footnotesize} \end{quote} The related \ttt{printf} command with the same syntax prints the formatted string to standard output\footnote{In older versions of \whizard, until v2.1.1, there also used to be a \ttt{sprintd} function and a \ttt{printd} command for default formats without a format string. They have been discarded in order to simplify the syntax from version v2.2.0 on.}. \section{Particles and (sub)events} \subsection{Particle aliases} \label{sec:alias} A particle species is denoted by its name as a string: \verb|"W+"|. Alternatively, it can be addressed by an \ttt{alias}. For instance, the $W^+$ boson has the alias \ttt{Wp}. Aliases are used like variables in a context where a particle species is expected, and the user can specify his/her own aliases. An alias may either denote a single particle species or a class of particles species. A colon \ttt{:} concatenates particle names and aliases to yield multi-species aliases: \begin{quote} \begin{footnotesize} \begin{verbatim} alias quark = u:d:s alias wboson = "W+":"W-" \end{verbatim} \end{footnotesize} \end{quote} Such aliases are used for defining processes with summation over flavors, and for defining classes of particles for analysis. Each model files define both names and (single-particle) aliases for all particles it contains. Furthermore, it defines the class aliases \verb|colored| and \verb|charged| which are particularly useful for event analysis. \subsection{Subevents} Subevents are sets of particles, extracted from an event. The sets are unordered by default, but may be ordered by appropriate functions. Obviously, subevents are meaningful only in a context where an event is available. The possible context may be the specification of a cut, weight, scale, or analysis expression. To construct a simple subevent, we put a particle alias or an expression of type particle alias into square brackets: \begin{quote} \begin{footnotesize} \verb|["W+"]|\quad \verb|[u:d:s]|\quad \verb|[colored]| \end{footnotesize} \end{quote} These subevents evaluate to the set of all $W^+$ bosons (to be precise, their four-momenta), all $u$, $d$, or $s$ quarks, and all colored particles, respectively. A subevent can contain pseudoparticles, i.e., particle combinations. That is, the four-momenta of distinct particles are combined (added conmponent-wise), and the results become subevent elements just like ordinary particles. The (pseudo)particles in a subevent are non-overlapping. That is, for any of the particles in the original event, there is at most one (pseudo)particle in the subevent in which it is contained. Sometimes, variables (actually, named constants) of type subevent are useful. Subevent variables are declared by the \ttt{subevt} keyword, and their names carry the prefix \verb|@|. Subevent variables exist only within the scope of a \verb|cuts| (or \verb|scale|, \verb|analysis|, etc.) macro, which is evaluated in the presence of an actual event. In the macro body, they are assigned via the \ttt{let} construct: \begin{quote} \begin{footnotesize} \begin{verbatim} cuts = let subevt @jets = select if Pt > 10 GeV [colored] in all Theta > 10 degree [@jets, @jets] \end{verbatim} \end{footnotesize} \end{quote} In this expression, we first define \verb|@jets| to stand for the set of all colored partons with $p_T>10\;\mathrm{GeV}$. This abbreviation is then used in a logical expression, which evaluates to true if all relative angles between distinct jets are greater than $10$ degree. We note that the example also introduces pairs of subevents: the square bracket with two entries evaluates to the list of all possible pairs which do not overlap. The objects within square brackets can be either subevents or alias expressions. The latter are transformed into subevents before they are used. As a special case, the original event is always available as the predefined subevent \verb|@evt|. \subsection{Subevent functions} There are several functions that take a subevent (or an alias) as an argument and return a new subevent. Here we describe them: \subsubsection{collect} \begin{quote} \begin{footnotesize} \ttt{collect [\textit{particles}]} \\ \ttt{collect if \textit{condition} [\textit{particles}]} \\ \ttt{collect if \textit{condition} [\textit{particles}, \textit{ref\_particles}]} \end{footnotesize} \end{quote} First version: collect all particle momenta in the argument and combine them to a single four-momentum. The \textit{particles} argument may either be a \ttt{subevt} expression or an \ttt{alias} expression. The result is a one-entry \ttt{subevt}. In the second form, only those particles are collected which satisfy the \textit{condition}, a logical expression. Example: \ttt{collect if Pt > 10 GeV [colored]} The third version is useful if you want to put binary observables (i.e., observables constructed from two different particles) in the condition. The \textit{ref\_particles} provide the second argument for binary observables in the \textit{condition}. A particle is taken into account if the condition is true with respect to all reference particles that do not overlap with this particle. Example: \ttt{collect if Theta > 5 degree [photon, charged]}: combine all photons that are separated by 5 degrees from all charged particles. \subsubsection{cluster} \begin{quote} \begin{footnotesize} \ttt{cluster [\textit{particles}]} \\ \ttt{cluster if \textit{condition} [\textit{particles}]} \\ \end{footnotesize} \end{quote} First version: collect all particle momenta in the argument and cluster them to a set of jets. The \textit{particles} argument may either be a \ttt{subevt} expression or an \ttt{alias} expression. The result is a one-entry \ttt{subevt}. In the second form, only those particles are clustered which satisfy the \textit{condition}, a logical expression. Example: \ttt{cluster if Pt > 10 GeV [colored]} % The third version is usefule if you want to put binary observables (i.e., % observables constructed from two different particles) in the condition. The % \textit{ref\_particles} provide the second argument for binary observables in % the \textit{condition}. A particle is taken into account if the condition is % true with respect to all reference particles that do not overlap with this % particle. Example: \ttt{cluster if Theta > 5 degree [photon, charged]}: % combine all photons that are separated by 5 degrees from all charged % particles. This command is available from \whizard\ version 2.2.1 on, and only if the \fastjet\ package has been installed and linked with \whizard\ (cf. Sec.\ref{sec:fastjet}); in a future version of \whizard\ it is foreseen to have also an intrinsic clustering package inside \whizard\ which will be able to support some of the clustering algorithms below. To use it in an analysis, you have to set the variable \ttt{jet\_algorithm} to one of the predefined jet-algorithm values (integer constants): \begin{quote} \begin{footnotesize} \ttt{kt\_algorithm}\\ \ttt{cambridge\_algorithm}\\ \ttt{antikt\_algorithm}\\ \ttt{genkt\_algorithm}\\ \ttt{cambridge\_for\_passive\_algorithm}\\ \ttt{genkt\_for\_passive\_algorithm}\\ \ttt{ee\_kt\_algorithm}\\ \ttt{ee\_genkt\_algorithm}\\ \ttt{plugin\_algorithm} \end{footnotesize} \end{quote} and the variable \ttt{jet\_r} to the desired $R$ parameter value, as appropriate for the analysis and the jet algorithm. Example: \begin{quote} \begin{footnotesize} \begin{verbatim} jet_algorithm = antikt_algorithm jet_r = 0.7 cuts = all Pt > 15 GeV [cluster if Pt > 5 GeV [colored]] \end{verbatim} \end{footnotesize} \end{quote} \subsubsection{select\_b\_jet, select\_non\_b\_jet, select\_c\_jet, select\_light\_jet} This command is available from \whizard\ version 2.8.1 on, and it only generates anything non-trivial if the \fastjet\ package has been installed and linked with \whizard\ (cf. Sec.\ref{sec:fastjet}). It only returns sensible results when it is applied to subevents after the \ttt{cluster} command (cf. the paragraph before). It is similar to the \ttt{select} command, and accepts a logical expression as a possible condition. The four commands \ttt{select\_b\_jet}, \ttt{select\_non\_b\_jet}, \ttt{select\_c\_jet}, and \ttt{select\_light\_jet} select $b$ jets, non-$b$ jets (anything lighter than $b$s), $c$ jets (neither $b$ nor light) and light jets (anything besides $b$ and $c$), respectively. An example looks like this: \begin{quote} \begin{footnotesize} \begin{verbatim} alias lightjet = u:U:d:D:s:S:c:C:gl alias jet = b:B:lightjet process eebbjj = e1, E1 => b, B, lightjet, lightjet jet_algorithm = antikt_algorithm jet_r = 0.5 cuts = let subevt @clustered_jets = cluster [jet] in let subevt @bjets = select_b_jet [@clustered_jets] in ..... \end{verbatim} \end{footnotesize} \end{quote} \subsubsection{photon\_isolation} This command is available from \whizard\ version 2.8.1 on. It provides isolation of photons from hadronic (and possibly electromagnetic) activity in the event to define a (especially) NLO cross section that is completely perturbative. The isolation criterion according to Frixione, cf.~\cite{Frixione:1998jh}, removes the non-perturbative contribution from the photon fragmentation function. This command can in principle be applied to elementary hard process partons (and leptons), but generates something sensible only if the \fastjet\ package has been installed and linked with \whizard\ (cf. Sec.\ref{sec:fastjet}). There are three parameters which allow to tune the isolation, \ttt{photon\_iso\_r0}, which is the radius $R^0_\gamma$ of the isolation cone, \ttt{photon\_iso\_eps}, which is the fraction $\epsilon_\gamma$ of the photon (transverse) energy that enters the isolation criterion, and the exponent of the isolation cone, \ttt{photon\_iso\_n}, $n^\gamma$. For more information cf.~\cite{Frixione:1998jh}. The command allows also a conditional cut on the photon which is applied before the isolation takes place. The first argument are the photons in the event, the second the particles from which they should be isolated. If also the electromagnetic activity is to be isolated, photons need to be isolated from themselves and must be included in the second argument. This is mandatory if leptons appear in the second argument. Two examples look like this: \begin{quote} \begin{footnotesize} \begin{verbatim} alias jet = u:U:d:D:s:S:c:C:gl process eeaajj = e1, E1 => A, A, jet, jet jet_algorithm = antikt_algorithm jet_r = 0.5 cuts = photon_isolation if Pt > 10 GeV [A, jet] .... cuts = let subevt @jets = cluster [jet] in photon_isolation if Pt > 10 GeV [A, @jets] ..... process eeajmm = e1, E1 => A, jet, e2, E2 cuts = let subevt @jets = cluster [jet] in let subevt @iso = join [@jets, A:e2:E2] photon_isolation [A, @iso] \end{verbatim} \end{footnotesize} \end{quote} \subsubsection{combine} \begin{quote} \begin{footnotesize} \ttt{combine [\textit{particles\_1}, \textit{particles\_2}]} \\ \ttt{combine if \textit{condition}} [\textit{particles\_1}, \textit{particles\_2}] \end{footnotesize} \end{quote} Make a new subevent of composite particles. The composites are generated by combining all particles from subevent \textit{particles\_1} with all particles from subevent \textit{particles\_2} in all possible combinations. Overlapping combinations are excluded, however: if a (composite) particle in the first argument has a constituent in common with a composite particle in the second argument, the combination is dropped. In particular, this applies if the particles are identical. If a \textit{condition} is provided, the combination is done only when the logical expression, applied to the particle pair in question, returns true. For instance, here we reconstruct intermediate $W^-$ bosons: \begin{quote} \begin{footnotesize} \begin{verbatim} let @W_candidates = combine if 70 GeV < M < 80 GeV ["mu-", "numubar"] in ... \end{verbatim} \end{footnotesize} \end{quote} Note that the combination may fail, so the resulting subevent could be empty. \subsubsection{operator +} If there is no condition, the $+$ operator provides a convenient shorthand for the \verb|combine| command. In particular, it can be used if there are several particles to combine. Example: \begin{quote} \begin{footnotesize} \begin{verbatim} cuts = any 170 GeV < M < 180 GeV [b + lepton + invisible] \end{verbatim} \end{footnotesize} \end{quote} \subsubsection{select} \begin{quote} \begin{footnotesize} \ttt{select if \textit{condition} [\textit{particles}]} \\ \ttt{select if \textit{condition} [\textit{particles}, \textit{ref\_particles}]} \end{footnotesize} \end{quote} One argument: select all particles in the argument that satisfy the \textit{condition} and drop the rest. Two arguments: the \textit{ref\_particles} provide a second argument for binary observables. Select particles if the condition is satisfied for all reference particles. \subsubsection{extract} \begin{quote} \begin{footnotesize} \ttt{extract [\textit{particles}]} \\ \ttt{extract index \textit{index-value} [\textit{particles}]} \end{footnotesize} \end{quote} Return a single-particle subevent. In the first version, it contains the first particle in the subevent \textit{particles}. In the second version, the particle with index \textit{index-value} is returned, where \textit{index-value} is an integer expression. If its value is negative, the index is counted from the end of the subevent. The order of particles in an event or subevent is not always well-defined, so you may wish to sort the subevent before applying the \textit{extract} function to it. \subsubsection{sort} \begin{quote} \begin{footnotesize} \ttt{sort [\textit{particles}]} \\ \ttt{sort by \textit{observable} [\textit{particles}]} \\ \ttt{sort by \textit{observable} [\textit{particles}, \textit{ref\_particle}]} \end{footnotesize} \end{quote} Sort the subevent according to some criterion. If no criterion is supplied (first version), the subevent is sorted by increasing PDG code (first particles, then antiparticles). In the second version, the \textit{observable} is a real expression which is evaluated for each particle of the subevent in turn. The subevent is sorted by increasing value of this expression, for instance: \begin{quote} \begin{footnotesize} \begin{verbatim} let @sorted_evt = sort by Pt [@evt] in ... \end{verbatim} \end{footnotesize} \end{quote} In the third version, a reference particle is provided as second argument, so the sorting can be done for binary observables. It doesn't make much sense to have several reference particles at once, so the \ttt{sort} function uses only the first entry in the subevent \textit{ref-particle}, if it has more than one. \subsubsection{join} \begin{quote} \begin{footnotesize} \ttt{join [\textit{particles}, \textit{new\_particles}]} \\ \ttt{join if \textit{condition} [\textit{particles}, \textit{new\_particles}]} \end{footnotesize} \end{quote} This commands appends the particles in subevent \textit{new\_particles} to the subevent \textit{particles}, i.e., it joins the two particle sets. To be precise, a (pseudo)particle from \textit{new\_particles} is only appended if it does not overlap with any of the (pseudo)particles present in \textit{particles}, so the function will not produce overlapping entries. In the second version, each particle from \textit{new\_particles} is also checked with all particles in the first set whether \textit{condition} is fulfilled. If yes, and there is no overlap, it is appended, otherwise it is dropped. \subsubsection{operator \&} Subevents can also be concatenated by the operator \verb|&|. This effectively applies \ttt{join} to all operands in turn. Example: \begin{quote} \begin{footnotesize} \begin{verbatim} let @visible = select if Pt > 10 GeV and E > 5 GeV [photon] & select if Pt > 20 GeV and E > 10 GeV [colored] & select if Pt > 10 GeV [lepton] in ... \end{verbatim} \end{footnotesize} \end{quote} \subsection{Calculating observables} Observables (invariant mass \ttt{M}, energy \ttt{E}, \ldots) are used in expressions just like ordinary numeric variables. By convention, their names start with a capital letter. They are computed using a particle momentum (or two particle momenta) which are taken from a subsequent subevent argument. We can extract the value of an observable for an event and make it available for computing the \ttt{scale} value, or for histogramming etc.: \subsubsection{eval} \begin{quote} \begin{footnotesize} \ttt{eval \textit{expr} [\textit{particles}]} \\ \ttt{eval \textit{expr} [\textit{particles\_1}, \textit{particles\_2}]} \end{footnotesize} \end{quote} The function \ttt{eval} takes an expression involving observables and evaluates it for the first momentum (or momentum pair) of the subevent (or subevent pair) in square brackets that follows the expression. For example, \begin{quote} \begin{footnotesize} \begin{verbatim} eval Pt [colored] \end{verbatim} \end{footnotesize} \end{quote} evaluates to the transverse momentum of the first colored particle, \begin{quote} \begin{footnotesize} \begin{verbatim} eval M [@jets, @jets] \end{verbatim} \end{footnotesize} \end{quote} evaluates to the invariant mass of the first distinct pair of jets (assuming that \verb|@jets| has been defined in a \ttt{let} construct), and \begin{quote} \begin{footnotesize} \begin{verbatim} eval E - M [combine [e1, N1]] \end{verbatim} \end{footnotesize} \end{quote} evaluates to the difference of energy and mass of the combination of the first electron-neutrino pair in the event. The last example illustrates why observables are treated like variables, even though they are functions of particles: the \ttt{eval} construct with the particle reference in square brackets after the expression allows to compute derived observables -- observables which are functions of new observables -- without the need for hard-coding them as new functions. \subsection{Cuts and event selection} \label{sec:cuts} Instead of a numeric value, we can use observables to compute a logical value. \subsubsection{all} \begin{quote} \begin{footnotesize} \ttt{all \textit{logical\_expr} [\textit{particles}]} \\ \ttt{all \textit{logical\_expr} [\textit{particles\_1}, \textit{particles\_2}]} \end{footnotesize} \end{quote} The \ttt{all} construct expects a logical expression and one or two subevent arguments in square brackets. \begin{quote} \begin{footnotesize} \begin{verbatim} all Pt > 10 GeV [charged] all 80 GeV < M < 100 GeV [lepton, antilepton] \end{verbatim} \end{footnotesize} \end{quote} In the second example, \ttt{lepton} and \ttt{antilepton} should be aliases defined in a \ttt{let} construct. (Recall that aliases are promoted to subevents if they occur within square brackets.) This construction defines a cut. The result value is \ttt{true} if the logical expression evaluates to \ttt{true} for all particles in the subevent in square brackets. In the two-argument case it must be \ttt{true} for all non-overlapping combinations of particles in the two subevents. If one of the arguments is the empty subevent, the result is also \ttt{true}. \subsubsection{any} \begin{quote} \begin{footnotesize} \ttt{any \textit{logical\_expr} [\textit{particles}]} \\ \ttt{any \textit{logical\_expr} [\textit{particles\_1}, \textit{particles\_2}]} \end{footnotesize} \end{quote} The \ttt{any} construct is true if the logical expression is true for at least one particle or non-overlapping particle combination: \begin{quote} \begin{footnotesize} \begin{verbatim} any E > 100 GeV [photon] \end{verbatim} \end{footnotesize} \end{quote} This defines a trigger or selection condition. If a subevent argument is empty, it evaluates to \ttt{false} \subsubsection{no} \begin{quote} \begin{footnotesize} \ttt{no \textit{logical\_expr} [\textit{particles}]} \\ \ttt{no \textit{logical\_expr} [\textit{particles\_1}, \textit{particles\_2}]} \end{footnotesize} \end{quote} The \ttt{no} construct is true if the logical expression is true for no single one particle or non-overlapping particle combination: \begin{quote} \begin{footnotesize} \begin{verbatim} no 5 degree < Theta < 175 degree ["e-":"e+"] \end{verbatim} \end{footnotesize} \end{quote} This defines a veto condition. If a subevent argument is empty, it evaluates to \ttt{true}. It is equivalent to \ttt{not any\ldots}, but included for notational convenience. \subsection{More particle functions} \subsubsection{count} \begin{quote} \begin{footnotesize} \ttt{count [\textit{particles}]} \\ \ttt{count [\textit{particles\_1}, \textit{particles\_2}]} \\ \ttt{count if \textit{logical-expr} [\textit{particles}]} \\ \ttt{count if \textit{logical-expr} [\textit{particles}, \textit{ref\_particles}]} \end{footnotesize} \end{quote} This counts the number of events in a subevent, the result is of type \ttt{int}. If there is a conditional expression, it counts the number of \ttt{particle} in the subevent that pass the test. If there are two arguments, it counts the number of non-overlapping particle pairs (that pass the test, if any). \subsubsection{Predefined observables} The following real-valued observables are available in \sindarin\ for use in \ttt{eval}, \ttt{all}, \ttt{any}, \ttt{no}, and \ttt{count} constructs. The argument is always the subevent or alias enclosed in square brackets. \begin{itemize} \item \ttt{M2} \begin{itemize} \item One argument: Invariant mass squared of the (composite) particle in the argument. \item Two arguments: Invariant mass squared of the sum of the two momenta. \end{itemize} \item \ttt{M} \begin{itemize} \item Signed square root of \ttt{M2}: positive if $\ttt{M2}>0$, negative if $\ttt{M2}<0$. \end{itemize} \item \ttt{E} \begin{itemize} \item One argument: Energy of the (composite) particle in the argument. \item Two arguments: Sum of the energies of the two momenta. \end{itemize} \item \ttt{Px}, \ttt{Py}, \ttt{Pz} \begin{itemize} \item Like \ttt{E}, but returning the spatial momentum components. \end{itemize} \item \ttt{P} \begin{itemize} \item Like \ttt{E}, returning the absolute value of the spatial momentum. \end{itemize} \item \ttt{Pt}, \ttt{Pl} \begin{itemize} \item Like \ttt{E}, returning the transversal and longitudinal momentum, respectively. \end{itemize} \item \ttt{Theta} \begin{itemize} \item One argument: Absolute polar angle in the lab frame \item Two arguments: Angular distance of two particles in the lab frame. \end{itemize} \item \ttt{Theta\_star} Only with two arguments, gives the relative polar angle of the two momenta in the rest system of the momentum sum (i.e. mother particle). \item \ttt{Phi} \begin{itemize} \item One argument: Absolute azimuthal angle in the lab frame \item Two arguments: Azimuthal distance of two particles in the lab frame \end{itemize} \item \ttt{Rap}, \ttt{Eta} \begin{itemize} \item One argument: rapidity / pseudorapidity \item Two arguments: rapidity / pseudorapidity difference \end{itemize} \item \ttt{Dist} \begin{itemize} \item Two arguments: Distance on the $\eta$-$\phi$ cylinder, i.e., $\sqrt{\Delta\eta^2 + \Delta\phi^2}$ \end{itemize} \item \ttt{kT} \begin{itemize} \item Two arguments: $k_T$ jet clustering variable: $2 \min (E_{j1}^2, E_{j2}^2) / Q^2 \times (1 - \cos\theta_{j1,j2})$. At the moment, $Q^2 = 1$ GeV$^2$. \end{itemize} \end{itemize} There are also integer-valued observables: \begin{itemize} \item \ttt{PDG} \begin{itemize} \item One argument: PDG code of the particle. For a composite particle, the code is undefined (value 0). For flavor sums in the \ttt{cuts} statement, this observable always returns the same flavor, i.e. the first one from the flavor list. It is thus only sensible to use it in an \ttt{analysis} or \ttt{selection} statement when simulating events. \end{itemize} \item \ttt{Ncol} \begin{itemize} \item One argument: Number of open color lines. Only count color lines, not anticolor lines. This is defined only if the global flag \ttt{?colorize\_subevt} is true. \end{itemize} \item \ttt{Nacl} \begin{itemize} \item One argument: Number of open anticolor lines. Only count anticolor lines, not color lines. This is defined only if the global flag \ttt{?colorize\_subevt} is true. \end{itemize} \end{itemize} %%%%%%%%%%%%%%% \section{Physics Models} \label{sec:models} A physics model is a combination of particles, numerical parameters (masses, couplings, widths), and Feynman rules. Many physics analyses are done in the context of the Standard Model (SM). The SM is also the default model for \whizard. Alternatively, you can choose a subset of the SM (QED or QCD), variants of the SM (e.g., with or without nontrivial CKM matrix), or various extensions of the SM. The complete list is displayed in Table~\ref{tab:models}. The model definitions are contained in text files with filename extension \ttt{.mdl}, e.g., \ttt{SM.mdl}, which are located in the \ttt{share/models} subdirectory of the \whizard\ installation. These files are easily readable, so if you need details of a model implementation, inspect their contents. The model file contains the complete particle and parameter definitions as well as their default values. It also contains a list of vertices. This is used only for phase-space setup; the vertices used for generating amplitudes and the corresponding Feynman rules are stored in different files within the \oMega\ source tree. In a \sindarin\ script, a model is a special object of type \ttt{model}. There is always a \emph{current} model. Initially, this is the SM, so on startup \whizard\ reads the \ttt{SM.mdl} model file and assigns its content to the current model object. (You can change the default model by the \ttt{--model} option on the command line. Also the preloading of a model can be switched off with the \ttt{--no-model} option) Once the model has been loaded, you can define processes for the model, and you have all independent model parameters at your disposal. As noted before, these are intrinsic parameters which need not be declared when you assign them a value, for instance: \begin{quote} \begin{footnotesize} \begin{verbatim} mW = 80.33 GeV wH = 243.1 MeV \end{verbatim} \end{footnotesize} \end{quote} Other parameters are \emph{derived}. They can be used in expressions like any other parameter, they are also intrinsic, but they cannot be modified directly at all. For instance, the electromagnetic coupling \ttt{ee} is a derived parameter. If you change either \ttt{GF} (the Fermi constant), \ttt{mW} (the $W$ mass), or \ttt{mZ} (the $Z$ mass), this parameter will reflect the change, but setting it directly is an error. In other words, the SM is defined within \whizard\ in the $G_F$-$m_W$-$m_Z$ scheme. (While this scheme is unusual for loop calculations, it is natural for a tree-level event generator where the $Z$ and $W$ poles have to be at their experimentally determined location\footnote{In future versions of \whizard\ it is foreseen to implement other electroweak schemes.}.) The model also defines the particle names and aliases that you can use for defining processes, cuts, or analyses. If you would like to generate a SUSY process instead, for instance, you can assign a different model (cf.\ Table~\ref{tab:models}) to the current model object: \begin{quote} \begin{footnotesize} \begin{verbatim} model = MSSM \end{verbatim} \end{footnotesize} \end{quote} This assignment has the consequence that the list of SM parameters and particles is replaced by the corresponding MSSM list (which is much longer). The MSSM contains essentially all SM parameters by the same name, but in fact they are different parameters. This is revealed when you say \begin{quote} \begin{footnotesize} \begin{verbatim} model = SM mb = 5.0 GeV model = MSSM show (mb) \end{verbatim} \end{footnotesize} \end{quote} After the model is reassigned, you will see the MSSM value of $m_b$ which still has its default value, not the one you have given. However, if you revert to the SM later, \begin{quote} \begin{footnotesize} \begin{verbatim} model = SM show (mb) \end{verbatim} \end{footnotesize} \end{quote} you will see that your modification of the SM's $m_b$ value has been remembered. If you want both mass values to agree, you have to set them separately in the context of their respective model. Although this might seem cumbersome at first, it is nevertheless a sensible procedure since the parameters defined by the user might anyhow not be defined or available for all chosen models. When using two different models which need an SLHA input file, these {\em have} to be provided for both models. Within a given scope, there is only one current model. The current model can be reset permanently as above. It can also be temporarily be reset in a local scope, i.e., the option body of a command or the body of a \ttt{scan} loop. It is thus possible to use several models within the same script. For instance, you may define a SUSY signal process and a pure-SM background process. Each process depends only on the respective model's parameter set, and a change to a parameter in one of the models affects only the corresponding process. \section{Processes} \label{sec:processes} The purpose of \whizard\ is the integration and simulation of high-energy physics processes: scatterings and decays. Hence, \ttt{process} objects play the central role in \sindarin\ scripts. A \sindarin\ script may contain an arbitrary number of process definitions. The initial states need not agree, and the processes may belong to different physics models. \subsection{Process definition} \label{sec:procdef} A process object is defined in a straightforward notation. The definition syntax is straightforward: \begin{quote} \begin{footnotesize} \ttt{process \textit{process-id} = \textit{incoming-particles}} \verb|=>| \ttt{\textit{outgoing-particles}} \end{footnotesize} \end{quote} Here are typical examples: \begin{quote} \begin{footnotesize} \begin{verbatim} process w_pair_production = e1, E1 => "W+", "W-" process zdecay = Z => u, ubar \end{verbatim} \end{footnotesize} \end{quote} Throughout the program, the process will be identified by its \textit{process-id}, so this is the name of the process object. This identifier is arbitrary, chosen by the user. It follows the rules for variable names, so it consists of alphanumeric characters and underscores, where the first character is not numeric. As a special rule, it must not contain upper-case characters. The reason is that this name is used for identifying the process not just within the script, but also within the \fortran\ code that the matrix-element generator produces for this process. After the equals sign, there follow the lists of incoming and outgoing particles. The number of incoming particles is either one or two: scattering processes and decay processes. The number of outgoing particles should be two or larger (as $2\to 1$ processes are proportional to a $\delta$ function they can only be sensibly integrated when using a structure function like a hadron collider PDF or a beamstrahlung spectrum.). There is no hard upper limit; the complexity of processes that \whizard\ can handle depends only on the practical computing limitations (CPU time and memory). Roughly speaking, one can assume that processes up to $2\to 6$ particles are safe, $2\to 8$ processes are feasible given sufficient time for reaching a stable integration, while more complicated processes are largely unexplored. We emphasize that in the default setup, the matrix element of a physics process is computed exactly in leading-order perturbation theory, i.e., at tree level. There is no restriction of intermediate states, the result always contains the complete set of Feynman graphs that connect the initial with the final state. If the result would actually be expanded in Feynman graphs (which is not done by the \oMega\ matrix element generator that \whizard\ uses), the number of graphs can easily reach several thousands, depending on the complexity of the process and on the physics model. More details about the different methods for quantum field-theoretical matrix elements can be found in Chap.~\ref{chap:hardint}. In the following, we will discuss particle names, options for processes like restrictions on intermediate states, parallelization, flavor sums and process components for inclusive event samples (process containers). \subsection{Particle names} The particle names are taken from the particle definition in the current model file. Looking at the SM, for instance, the electron entry in \ttt{share/models/SM.mdl} reads \begin{quote} \begin{footnotesize} \begin{verbatim} particle E_LEPTON 11 spin 1/2 charge -1 isospin -1/2 name "e-" e1 electron e anti "e+" E1 positron tex_name "e^-" tex_anti "e^+" mass me \end{verbatim} \end{footnotesize} \end{quote} This tells that you can identify an electron either as \verb|"e-"|, \verb|e1|, \verb|electron|, or simply \verb|e|. The first version is used for output, but needs to be quoted, because otherwise \sindarin\ would interpret the minus sign as an operator. (Technically, unquoted particle identifiers are aliases, while the quoted versions -- you can say either \verb|e1| or \verb|"e1"| -- are names. On input, this makes no difference.) The alternative version \verb|e1| follows a convention, inherited from \comphep~\cite{Boos:2004kh}, that particles are indicated by lower case, antiparticles by upper case, and for leptons, the generation index is appended: \verb|e2| is the muon, \verb|e3| the tau. These alternative names need not be quoted because they contain no special characters. In Table~\ref{tab:SM-particles}, we list the recommended names as well as mass and width parameters for all SM particles. For other models, you may look up the names in the corresponding model file. \begin{table}[p] \begin{center} \begin{tabular}{|l|l|l|l|cc|} \hline & Particle & Output name & Alternative names & Mass & Width\\ \hline\hline Leptons &$e^-$ & \verb|e-| & \ttt{e1}\quad\ttt{electron} & \ttt{me} & \\ &$e^+$ & \verb|e+| & \ttt{E1}\quad\ttt{positron} & \ttt{me} & \\ \hline &$\mu^-$ & \verb|mu-| & \ttt{e2}\quad\ttt{muon} & \ttt{mmu} & \\ &$\mu^+$ & \verb|mu+| & \ttt{E2} & \ttt{mmu} & \\ \hline &$\tau^-$ & \verb|tau-| & \ttt{e3}\quad\ttt{tauon} & \ttt{mtau} & \\ &$\tau^+$ & \verb|tau+| & \ttt{E3} & \ttt{mtau} & \\ \hline\hline Neutrinos &$\nu_e$ & \verb|nue| & \ttt{n1} & & \\ &$\bar\nu_e$ & \verb|nuebar| & \ttt{N1} & & \\ \hline &$\nu_\mu$ & \verb|numu| & \ttt{n2} & & \\ &$\bar\nu_\mu$ & \verb|numubar| & \ttt{N2} & & \\ \hline &$\nu_\tau$ & \verb|nutau| & \ttt{n3} & & \\ &$\bar\nu_\tau$ & \verb|nutaubar| & \ttt{N3} & & \\ \hline\hline Quarks &$d$ & \verb|d| & \ttt{down} & & \\ &$\bar d$ & \verb|dbar| & \ttt{D} & & \\ \hline &$u$ & \verb|u| & \ttt{up} & & \\ &$\bar u$ & \verb|ubar| & \ttt{U} & & \\ \hline &$s$ & \verb|s| & \ttt{strange} & \ttt{ms} & \\ &$\bar s$ & \verb|sbar| & \ttt{S} & \ttt{ms} & \\ \hline &$c$ & \verb|c| & \ttt{charm} & \ttt{mc} & \\ &$\bar c$ & \verb|cbar| & \ttt{C} & \ttt{mc} & \\ \hline &$b$ & \verb|b| & \ttt{bottom} & \ttt{mb} & \\ &$\bar b$ & \verb|bbar| & \ttt{B} & \ttt{mb} & \\ \hline &$t$ & \verb|t| & \ttt{top} & \ttt{mtop} & \ttt{wtop} \\ &$\bar t$ & \verb|tbar| & \ttt{T} & \ttt{mtop} & \ttt{wtop} \\ \hline\hline Vector bosons &$g$ & \verb|gl| & \ttt{g}\quad\ttt{G}\quad\ttt{gluon} & & \\ \hline &$\gamma$ & \verb|A| & \ttt{gamma}\quad\ttt{photon} & & \\ \hline &$Z$ & \verb|Z| & & \ttt{mZ} & \ttt{wZ} \\ \hline &$W^+$ & \verb|W+| & \ttt{Wp} & \ttt{mW} & \ttt{wW} \\ &$W^-$ & \verb|W-| & \ttt{Wm} & \ttt{mW} & \ttt{wW} \\ \hline\hline Scalar bosons &$H$ & \verb|H| & \ttt{h}\quad \ttt{Higgs} & \ttt{mH} & \ttt{wH} \\ \hline \end{tabular} \end{center} \caption{\label{tab:SM-particles} Names that can be used for SM particles. Also shown are the intrinsic variables that can be used to set mass and width, if applicable.} \end{table} Where no mass or width parameters are listed in the table, the particle is assumed to be massless or stable, respectively. This is obvious for particles such as the photon. For neutrinos, the mass is meaningless to particle physics collider experiments, so it is zero. For quarks, the $u$ or $d$ quark mass is unobservable directly, so we also set it zero. For the heavier quarks, the mass may play a role, so it is kept. (The $s$ quark is borderline; one may argue that its mass is also unobservable directly.) On the other hand, the electron mass is relevant, e.g., in photon radiation without cuts, so it is not zero by default. It pays off to set particle masses to zero, if the approximation is justified, since fewer helicity states will contribute to the matrix element. Switching off one of the helicity states of an external fermion speeds up the calculation by a factor of two. Therefore, script files will usually contain the assignments \begin{quote} \begin{footnotesize} \begin{verbatim} me = 0 mmu = 0 ms = 0 mc = 0 \end{verbatim} \end{footnotesize} \end{quote} unless they deal with processes where this simplification is phenomenologically unacceptable. Often $m_\tau$ and $m_b$ can also be neglected, but this excludes processes where the Higgs couplings of $\tau$ or $b$ are relevant. Setting fermion masses to zero enables, furthermore, the possibility to define multi-flavor aliases \begin{quote} \begin{footnotesize} \begin{verbatim} alias q = d:u:s:c alias Q = D:U:S:C \end{verbatim} \end{footnotesize} \end{quote} and handle processes such as \begin{quote} \begin{footnotesize} \begin{verbatim} process two_jets_at_ilc = e1, E1 => q, Q process w_pairs_at_lhc = q, Q => Wp, Wm \end{verbatim} \end{footnotesize} \end{quote} where a sum over all allowed flavor combination is automatically included. For technical reasons, such flavor sums are possible only for massless particles (or more general for mass-degenerate particles). If you want to generate inclusive processes with sums over particles of different masses (e.g. summing over $W/Z$ in the final state etc.), confer below the section about process components, Sec.~\ref{sec:processcomp}. Assignments of masses, widths and other parameters are actually in effect when a process is integrated, not when it is defined. So, these assignments may come before or after the process definition, with no significant difference. However, since flavor summation requires masses to be zero, the assignments may be put before the alias definition which is used in the process. The muon, tau, and the heavier quarks are actually unstable. However, the width is set to zero because their decay is a macroscopic effect and, except for the muon, affected by hadron physics, so it is not described by \whizard. (In the current \whizard\ setup, all decays occur at the production vertex. A future version may describe hadronic physics and/or macroscopic particle propagation, and this restriction may be eventually removed.) \subsection{Options for processes} \label{sec:process options} The \ttt{process} definition may contain an optional argument: \begin{quote} \begin{footnotesize} \ttt{process \textit{process-id} = \textit{incoming-particles}} \verb|=>| \ttt{\textit{outgoing-particles}} \ttt{\{\textit{options\ldots}\}} \end{footnotesize} \end{quote} The \textit{options} are a \sindarin\ script that is executed in a context local to the \ttt{process} command. The assignments it contains apply only to the process that is defined. In the following, we describe the set of potentially useful options (which all can be also set globally): \subsubsection{Model reassignment} It is possible to locally reassign the model via a \ttt{model =} statment, permitting the definition of process using a model other than the globally selected model. The process will retain this association during integration and event generation. \subsubsection{Restrictions on matrix elements} \label{subsec:restrictions} Another useful option is the setting \begin{quote} \begin{footnotesize} \verb|$restrictions =| \ttt{\textit{string}} \end{footnotesize} \end{quote} This option allows to select particular classes of Feynman graphs for the process when using the \oMega\ matrix element generator. The \verb|$restrictions| string specifies e.g. propagators that the graph must contain. Here is an example: \begin{code} process zh_invis = e1, E1 => n1:n2:n3, N1:N2:N3, H { $restrictions = "1+2 ~ Z" } \end{code} The complete process $e^-e^+ \to \nu\bar\nu H$, summed over all neutrino generations, contains both $ZH$ pair production (Higgs-strahlung) and $W^+W^-\to H$ fusion. The restrictions string selects the Higgs-strahlung graph where the initial electrons combine to a $Z$ boson. Here, the particles in the process are consecutively numbered, starting with the initial particles. An alternative for the same selection would be \verb|$restrictions = "3+4 ~ Z"|. Restrictions can be combined using \verb|&&|, for instance \begin{code} $restrictions = "1+2 ~ Z && 3 + 4 ~ Z" \end{code} which is redundant here, however. The restriction keeps the full energy dependence in the intermediate propagator, so the Breit-Wigner shape can be observed in distributions. This breaks gauge invariance, in particular if the intermediate state is off shell, so you should use the feature only if you know the implications. For more details, cf. the Chap.~\ref{chap:hardint} and the \oMega\ manual. Other restrictions that can be combined with the restrictions above on intermediate propagators allow to exclude certain particles from intermediate propagators, or to exclude certain vertices from the matrix elements. For example, \begin{code} process eemm = e1, E1 => e2, E2 { $restrictions = "!A" } \end{code} would exclude all photon propagators from the matrix element and leaves only the $Z$ exchange here. In the same way, \verb|$restrictions = "!gl"| would exclude all gluon exchange. This exclusion of internal propagators works also for lists of particles, like \begin{code} $restrictions = "!Z:H" \end{code} excludes all $Z$ and $H$ propagators from the matrix elements. Besides excluding certain particles as internal lines, it is also possible to exclude certain vertices using the restriction command \begin{code} process eeww = e1, E1 => Wp, Wm { $restrictions = "^[W+,W-,Z]" } \end{code} This would generate the matrix element for the production of two $W$ bosons at LEP without the non-Abelian vertex $W^+W^-Z$. Again, these restrictions are able to work on lists, so \begin{code} $restrictions = "^[W+,W-,A:Z]" \end{code} would exclude all triple gauge boson vertices from the above process and leave only the $t$-channel neutrino exchange. It is also possible to exlude vertices by their coupling constants, e.g. the photon exchange in the process $e^+ e^- \to \mu^+ \mu^-$ can also be removed by the following restriction: \begin{code} $restrictions = "^qlep" \end{code} Here, \ttt{qlep} is the \fortran\ variable for the coupling constant of the electron-positron-photon vertex. \begin{table} \begin{center} \begin{tabular}{|l|l|} \hline \verb|3+4~Z| & external particles 3 and 4 must come from intermediate $Z$ \\\hline \verb| && | & logical ``and'', e.g. in \verb| 3+5~t && 4+6~tbar| \\\hline \verb| !A | & exclude all $\gamma$ propagators \\\hline \verb| !e+:nue | & exclude a list of propagators, here $\gamma$, $\nu_e$ \\\hline \verb|^qlep:gnclep| & exclude all vertices with \ttt{qlep},\ttt{gnclep} coupling constants \\\hline \verb|^[A:Z,W+,W-]| & exclude all vertices $W^+W^-Z$, $W^+W^-\gamma$ \\\hline \verb|^c1:c2:c3[H,H,H]| & exclude all triple Higgs couplings with $c_i$ constants \\\hline \end{tabular} \end{center} \caption{List of possible restrictions that can be applied to \oMega\ matrix elements.} \label{tab:restrictions} \end{table} The Tab.~\ref{tab:restrictions} gives a list of options that can be applied to the \oMega\ matrix elements. \subsubsection{Other options} There are some further options that the \oMega\ matrix-element generator can take. If desired, any string of options that is contained in this variable \begin{quote} \begin{footnotesize} \verb|$omega_flags =| \ttt{\textit{string}} \end{footnotesize} \end{quote} will be copied verbatim to the \oMega\ call, after all other options. One important application is the scheme of treating the width of unstable particles in the $t$-channel. This is modified by the \verb|model:| class of \oMega\ options. It is well known that for some processes, e.g., single $W$ production from photon-$W$ fusion, gauge invariance puts constraints on the treatment of the unstable-particle width. By default, \oMega\ puts a nonzero width in the $s$ channel only. This correctly represents the resummed Dyson series for the propagator, but it violates QED gauge invariance, although the effect is only visible if the cuts permit the photon to be almost on-shell. An alternative is \begin{quote} \begin{footnotesize} \verb|$omega_flags = "-model:fudged_width"| \end{footnotesize}, \end{quote} which puts zero width in the matrix element, so that gauge cancellations hold, and reinstates the $s$-channel width in the appropriate places by an overall factor that multiplies the whole matrix element. Note that the fudged width option only applies to charged unstable particles, such as the $W$ boson or top quark. Another possibility is \begin{quote} \begin{footnotesize} \verb|$omega_flags = "-model:constant_width"| \end{footnotesize}, \end{quote} which puts the width both in the $s$- and in the $t$-channel like diagrams. A third option is provided by the running width scheme \begin{quote} \begin{footnotesize} \verb|$omega_flags = "-model:running_width"| \end{footnotesize}, \end{quote} which applies the width only for $s$-channel like diagrams and multiplies it by a factor of $p^2 / M^2$. The additional $p^2$-dependent factor mimicks the momentum dependence of the imaginary part of a vacuum polarization for a particle decaying into massles decay products. It is noted that none of the above options preserves gauge invariance. For a gauge preserving approach (at least at tree level), \oMega\ provides the complex-mass scheme \begin{quote} \begin{footnotesize} \verb|$omega_flags = "-model:cms_width| \end{footnotesize}. \end{quote} However, in this case, one also has to modify the model in usage. For example, the parameter setting for the Standard Model can be changed by, \begin{quote} \begin{footnotesize} \verb|model = SM (Complex_Mass_Scheme)| \end{footnotesize}. \end{quote} \subsubsection{Multithreaded calculation of helicity sums via OpenMP} \label{sec:openmp} On multicore and / or multiprocessor systems, it is possible to speed up the calculation by using multiple threads to perform the helicity sum in the matrix element calculation. As the processing time used by \whizard\ is not used up solely in the matrix element, the speedup thus achieved varies greatly depending on the process under consideration; while simple processes without flavor sums do not profit significantly from this parallelization, the computation time for processes involving flavor sums with four or more particles in the final state is typically reduced by a factor between two and three when utilizing four parallel threads. The parallization is implemented using \ttt{OpenMP} and requires \whizard\ to be compiled with an \ttt{OpenMP} aware compiler and the appropiate compiler flags This is done in the configuration step, cf.\ Sec.~\ref{sec:installation}. As with all \ttt{OpenMP} programs, the default number of threads used at runtime is up to the compiler runtime support and typically set to the number of independent hardware threads (cores / processors / hyperthreads) available in the system. This default can be adjusted by setting the \ttt{OMP\_NUM\_THREADS} environment variable prior to calling WHIZARD. Alternatively, the available number of threads can be reset anytime by the \sindarin\ parameter \ttt{openmp\_num\_threads}. Note however that the total number of threads that can be sensibly used is limited by the number of nonvanishing helicity combinations. %%%%%%%%%%%%%%% \subsection{Process components} \label{sec:processcomp} It was mentioned above that processes with flavor sums (in the initial or final state or both) have to be mass-degenerate (in most cases massless) in all particles that are summed over at a certain position. This condition is necessary in order to use the same phase-space parameterization and integration for the flavor-summed process. However, in many applications the user wants to handle inclusive process definitions, e.g. by defining inclusive decays, inclusive SUSY samples at hadron colliders (gluino pairs, squark pairs, gluino-squark associated production), or maybe lepton-inclusive samples where the tau and muon mass should be kept at different values. In \whizard\, from version v2.2.0 on, there is the possibility to define such inclusive process containers. The infrastructure for this feature is realized via so-called process components: processes are allowed to contain several process components. Those components need not be provided by the same matrix element generator, e.g. internal matrix elements, \oMega\ matrix elements, external matrix element (e.g. from a one-loop program, OLP) can be mixed. The very same infrastructure can also be used for next-to-leading order (NLO) calculations, containing the born with real emission, possible subtraction terms to make the several components infrared- and collinear finite, as well as the virtual corrections. Here, we want to discuss the use for inclusive particle samples. There are several options, the simplest of which to add up different final states by just using the \ttt{+} operator in \sindarin, e.g.: \begin{quote} \begin{footnotesize} \begin{verbatim} process multi_comp = e1, E1 => (e2, E2) + (e3, E3) + (A, A) \end{verbatim} \end{footnotesize} \end{quote} The brackets are not only used for a better grouping of the expressions, they are not mandatory for \whizard\ to interpret the sum correctly. When integrating, \whizard\ tells you that this a process with three different components: \begin{footnotesize} \begin{Verbatim} | Initializing integration for process multi_comp_1_p1: | ------------------------------------------------------------------------ | Process [scattering]: 'multi_comp' | Library name = 'default_lib' | Process index = 1 | Process components: | 1: 'multi_comp_i1': e-, e+ => m-, m+ [omega] | 2: 'multi_comp_i2': e-, e+ => t-, t+ [omega] | 3: 'multi_comp_i3': e-, e+ => A, A [omega] | ------------------------------------------------------------------------ \end{Verbatim} \end{footnotesize} A different phase-space setup is used for each different component. The integration for each different component is performed separately, and displayed on screen. At the end, a sum of all components is shown. All files that depend on the components are being attached an \ttt{\_i{\em }} where \ttt{{\em }} is the number of the process component that appears in the list above: the \fortran\ code for the matrix element, the \ttt{.phs} file for the phase space parameterization, and the grid files for the \vamp\ Monte-Carlo integration (or any other integration method). However, there will be only one event file for the inclusive process, into which a mixture of events according to the size of the individual process component cross section enter. More options are to specify additive lists of particles. \whizard\ then expands the final states according to tensor product algebra: \begin{quote} \begin{footnotesize} \begin{verbatim} process multi_tensor = e1, E1 => e2 + e3 + A, E2 + E3 + A \end{verbatim} \end{footnotesize} \end{quote} This gives the same three process components as above, but \whizard\ recognized that e.g. $e^- e^+ \to \mu^- \gamma$ is a vanishing process, hence the numbering is different: \begin{footnotesize} \begin{Verbatim} | Process component 'multi_tensor_i2': matrix element vanishes | Process component 'multi_tensor_i3': matrix element vanishes | Process component 'multi_tensor_i4': matrix element vanishes | Process component 'multi_tensor_i6': matrix element vanishes | Process component 'multi_tensor_i7': matrix element vanishes | Process component 'multi_tensor_i8': matrix element vanishes | ------------------------------------------------------------------------ | Process [scattering]: 'multi_tensor' | Library name = 'default_lib' | Process index = 1 | Process components: | 1: 'multi_tensor_i1': e-, e+ => m-, m+ [omega] | 5: 'multi_tensor_i5': e-, e+ => t-, t+ [omega] | 9: 'multi_tensor_i9': e-, e+ => A, A [omega] | ------------------------------------------------------------------------ \end{Verbatim} \end{footnotesize} Identical copies of the same process that would be created by expanding the tensor product of final states are eliminated and appear only once in the final sum of process components. Naturally, inclusive process definitions are also available for decays: \begin{quote} \begin{footnotesize} \begin{Verbatim} process multi_dec = Wp => E2 + E3, n2 + n3 \end{Verbatim} \end{footnotesize} \end{quote} This yields: \begin{footnotesize} \begin{Verbatim} | Process component 'multi_dec_i2': matrix element vanishes | Process component 'multi_dec_i3': matrix element vanishes | ------------------------------------------------------------------------ | Process [decay]: 'multi_dec' | Library name = 'default_lib' | Process index = 2 | Process components: | 1: 'multi_dec_i1': W+ => mu+, numu [omega] | 4: 'multi_dec_i4': W+ => tau+, nutau [omega] | ------------------------------------------------------------------------ \end{Verbatim} \end{footnotesize} %%%%%%%%%%%%%%% \subsection{Compilation} \label{sec:compilation} Once processes have been set up, to make them available for integration they have to be compiled. More precisely, the matrix-element generator \oMega\ (and it works similarly if a different matrix element method is chosen) is called to generate matrix element code, the compiler is called to transform this \fortran\ code into object files, and the linker is called to collect this in a dynamically loadable library. Finally, this library is linked to the program. From version v2.2.0 of \whizard\ this is no longer done by system calls of the OS but steered via process library Makefiles. Hence, the user can execute and manipulate those Makefiles in order to manually intervene in the particular steps, if he/she wants to do so. All this is done automatically when an \ttt{integrate}, \ttt{unstable}, or \ttt{simulate} command is encountered for the first time. You may also force compilation explicitly by the command \begin{quote} \begin{footnotesize} \begin{verbatim} compile \end{verbatim} \end{footnotesize} \end{quote} which performs all steps as listed above, including loading the generated library. The \fortran\ part of the compilation will be done using the \fortran\ compiler specified by the string variable \verb|$fc| and the compiler flags specified as \verb|$fcflags|. The default settings are those that have been used for compiling \whizard\ itself during installation. For library compatibility, you should stick to the compiler. The flags may be set differently. They are applied in the compilation and loading steps, and they are processed by \ttt{libtool}, so \ttt{libtool}-specific flags can also be given. \whizard\ has some precautions against unnecessary repetitions. Hence, when a \ttt{compile} command is executed (explicitly, or implicitly by the first integration), the program checks first whether the library is already loaded, and whether source code already exists for the requested processes. If yes, this code is used and no calls to \oMega\ (or another matrix element method) or to the compiler are issued. Otherwise, it will detect any modification to the process configuration and regenerate the matrix element or recompile accordingly. Thus, a \sindarin\ script can be executed repeatedly without rebuilding everything from scratch, and you can safely add more processes to a script in a subsequent run without having to worry about the processes that have already been treated. This default behavior can be changed. By setting \begin{quote} \begin{footnotesize} \begin{verbatim} ?rebuild_library = true \end{verbatim} \end{footnotesize} \end{quote} code will be re-generated and re-compiled even if \whizard\ would think that this is unncessary. The same effect is achieved by calling \whizard\ with a command-line switch, \begin{quote} \begin{footnotesize} \begin{verbatim} /home/user$ whizard --rebuild_library \end{verbatim} \end{footnotesize} \end{quote} There are further \ttt{rebuild} switches which are described below. If everything is to be rebuilt, you can set a master switch \ttt{?rebuild} or the command line option \verb|--rebuild|. The latter can be abbreviated as a short command-line option: \begin{quote} \begin{footnotesize} \begin{verbatim} /home/user$ whizard -r \end{verbatim} \end{footnotesize} \end{quote} Setting this switch is always a good idea when starting a new project, just in case some old files clutter the working directory. When re-running the same script, possibly modified, the \verb|-r| switch should be omitted, so the existing files can be reused. \subsection{Process libraries} Processes are collected in \emph{libraries}. A script may use more than one library, although for most applications a single library will probably be sufficient. The default library is \ttt{default\_lib}. If you do not specify anything else, the processes you compile will be collected by a driver file \ttt{default\_lib.f90} which is compiled together with the process code and combined as a libtool archive \ttt{default\_lib.la}, which is dynamically linked to the running \whizard\ process. Once in a while, you work on several projects at once, and you didn't care about opening a new working directory for each. If the \verb|-r| option is given, a new run will erase the existing library, which may contain processes needed for the other project. You could omit \verb|-r|, so all processes will be collected in the same library (this does not hurt), but you may wish to cleanly separate the projects. In that case, you should open a separate library for each project. Again, there are two possibilities. You may start the script with the specification \begin{quote} \begin{footnotesize} \begin{verbatim} library = "my_lhc_proc" \end{verbatim} \end{footnotesize} \end{quote} to open a library \verb|my_lhc_proc| in place of the default library. Repeating the command with different arguments, you may introduce several libraries in the script. The active library is always the one specified last. It is possible to issue this command locally, so a particular process goes into its own library. Alternatively, you may call \whizard\ with the option \begin{quote} \begin{footnotesize} \begin{verbatim} /home/user$ whizard --library=my_lhc_proc \end{verbatim} \end{footnotesize} \end{quote} If several libraries are open simultaneously, the \ttt{compile} command will compile all libraries that the script has referenced so far. If this is not intended, you may give the command an argument, \begin{quote} \begin{footnotesize} \begin{verbatim} compile ("my_lhc_proc", "my_other_proc") \end{verbatim} \end{footnotesize} \end{quote} to compile only a specific subset. The command \begin{quote} \begin{footnotesize} \begin{verbatim} show (library) \end{verbatim} \end{footnotesize} \end{quote} will display the contents of the actually loaded library together with a status code which indicates the status of the library and the processes within. %%%%%%%%%%%%%%% \subsection{Stand-alone \whizard\ with precompiled processes} \label{sec:static} Once you have set up a process library, it is straightforward to make a special stand-alone \whizard\ executable which will have this library preloaded on startup. This is a matter of convenience, and it is also useful if you need a statically linked executable for reasons of profiling, batch processing, etc. For this task, there is a variant of the \ttt{compile} command: \begin{quote} \begin{footnotesize} \begin{verbatim} compile as "my_whizard" () \end{verbatim} \end{footnotesize} \end{quote} which produces an executable \verb|my_whizard|. You can omit the library argument if you simply want to include everything. (Note that this command will \emph{not} load a library into the current process, it is intended for creating a separate program that will be started independently.) As an example, the script \begin{quote} \begin{footnotesize} \begin{verbatim} process proc1 = e1, E1 => e1, E1 process proc2 = e1, E1 => e2, E2 process proc3 = e1, E1 => e3, E3 compile as "whizard-leptons" () \end{verbatim} \end{footnotesize} \end{quote} will make a new executable program \verb|whizard-leptons|. This program behaves completely identical to vanilla \whizard, except for the fact that the processes \ttt{proc1}, \ttt{proc2}, and \ttt{proc3} are available without configuring them or loading any library. % This feature is particularly useful when compiling with the \ttt{-static} % flag. As long as the architecture is compatible, the resulting binary may be % run on a different computer where no \whizard\ libraries are present. (The % program will still need to find its model files, however.) \section{Beams} \label{sec:beams} Before processes can be integrated and simulated, the program has to know about the collider properties. They can be specified by the \ttt{beams} statement. In the command script, it is irrelevant whether a \ttt{beams} statement comes before or after process specification. The \ttt{integrate} or \ttt{simulate} commands will use the \ttt{beams} statement that was issued last. \subsection{Beam setup} \label{sec:beam-setup} If the beams have no special properties, and the colliding particles are the incoming particles in the process themselves, there is no need for a \ttt{beams} statement at all. You only \emph{must} specify the center-of-momentum energy of the collider by setting the value of $\sqrt{s}$, for instance \begin{quote} \begin{footnotesize} \begin{verbatim} sqrts = 14 TeV \end{verbatim} \end{footnotesize} \end{quote} The \ttt{beams} statement comes into play if \begin{itemize} \item the beams have nontrivial structure, e.g., parton structure in hadron collision or photon radiation in lepton collision, or \item the beams have non-standard properties: polarization, asymmetry, crossing angle. \end{itemize} Note that some of the abovementioned beam properties had not yet been reimplemented in the \whizard\ttt{2} release series. From version v2.2.0 on all options of the legacy series \whizard\ttt{1} are available again. From version v2.1 to version v2.2 of \whizard\ there has also been a change in possible options to the \ttt{beams} statement: in the early versions of \whizard\ttt{2} (v2.0/v2.1), local options could be specified within the beam settings, e.g. \ttt{beams = p, p { sqrts = 14 TeV } => pdf\_builtin}. These possibility has been abandoned from version v2.2 on, and the \ttt{beams} command does not allow for {\em any} optional arguments any more. Hence, beam parameters can -- with the exception of the specification of structure functions -- be specified only globally: \begin{quote} \begin{footnotesize} \begin{verbatim} sqrts = 14 TeV beams = p, p => lhapdf \end{verbatim} \end{footnotesize} \end{quote} It does not make any difference whether the value of \ttt{sqrts} is set before or after the \ttt{beams} statement, the last value found before an \ttt{integrate} or \ttt{simulate} is the relevant one. This in particularly allows to specify the beam structure, and then after that perform a loop or scan over beam energies, beam parameters, or structure function settings. The \ttt{beams} statement also applies to particle decay processes, where there is only a single beam. Here, it is usually redundant because no structure functions are possible, and the energy is fixed to the decaying particle's mass. However, it is needed for computing polarized decay, e.g. \begin{quote} \begin{footnotesize} \begin{verbatim} beams = Z beams_pol_density = @(0) \end{verbatim} \end{footnotesize} \end{quote} where for a boson at rest, the polarization axis is defined to be the $z$ axis. Beam polarization is described in detail below in Sec.~\ref{sec:polarization}. Note also that future versions of \whizard\ might give support for single-beam events, where structure functions for single particles indeed do make sense. In the following sections we list the available options for structure functions or spectra inside \whizard\ and explain their usage. More about the physics of the implemented structure functions can be found in Chap.~\ref{chap:hardint}. %%%%%%%%%%%%%%% \subsection{Asymmetric beams and Crossing angles} \label{sec:asymmetricbeams} \whizard\ not only allows symmetric beam collisions, but basically arbitrary collider setups. In the case there are two different beam energies, the command \begin{quote} \begin{footnotesize} \ttt{beams\_momentum = {\em }, {\em }} \end{footnotesize} \end{quote} allows to specify the momentum (or as well energies for massless particles) for the beams. Note that for scattering processes both values for the beams must be present. So the following to setups for 14 TeV LHC proton-proton collisions are equivalent: \begin{quote} \begin{footnotesize} \ttt{beams = p, p => pdf\_builtin} \newline \ttt{sqrts = 14 TeV} \end{footnotesize} \end{quote} and \begin{quote} \begin{footnotesize} \ttt{beams = p, p => pdf\_builtin} \newline \ttt{beams\_momentum = 7 TeV, 7 TeV} \end{footnotesize} \end{quote} Asymmetric setups can be set by using different values for the two beam momenta, e.g. in a HERA setup: \begin{quote} \begin{footnotesize} \ttt{beams = e, p => none, pdf\_builtin} \ttt{beams\_momentum = 27.5 GeV, 920 GeV} \end{footnotesize} \end{quote} or for the BELLE experiment at the KEKB accelerator: \begin{quote} \begin{footnotesize} \ttt{beams = e1, E1} \ttt{beams\_momentum = 8 GeV, 3.5 GeV} \end{footnotesize} \end{quote} \whizard\ lets you know about the beam structure and calculates for you that the center of mass energy corresponds to 10.58 GeV: \begin{quote} \begin{footnotesize} \begin{Verbatim} | Beam structure: e-, e+ | momentum = 8.000000000000E+00, 3.500000000000E+00 | Beam data (collision): | e- (mass = 5.1099700E-04 GeV) | e+ (mass = 5.1099700E-04 GeV) | sqrts = 1.058300530253E+01 GeV | Beam structure: lab and c.m. frame differ \end{Verbatim} \end{footnotesize} \end{quote} It is also possible to specify beams for decaying particles, where \ttt{beams\_momentum} then only has a single argument, e.g.: \begin{quote} \begin{footnotesize} \ttt{process zee = Z => "e-", "e+"} \\ \ttt{beams = Z} \\ \ttt{beams\_momentum = 500 GeV} \\ \ttt{simulate (zee) \{ n\_events = 100 \} } \end{footnotesize} \end{quote} This would corresponds to a beam of $Z$ bosons with a momentum of 500 GeV. Note, however, that \whizard\ will always do the integration of the particle width in the particle's rest frame, while the moving beam is then only taken into account for the frame of reference for the simulation. Further options then simply having different beam energies describe a non-vanishing between the two incoming beams. Such concepts are quite common e.g. for linear colliders to improve the beam properties in the collimation region at the beam interaction points. Such crossing angles can be specified in the beam setup, too, using the \ttt{beams\_theta} command: \begin{quote} \begin{footnotesize} \ttt{beams = e1, E1} \\ \ttt{beams\_momentum = 500 GeV, 500 GeV} \\ \ttt{beams\_theta = 0, 10 degree} \end{footnotesize} \end{quote} It is important that when a crossing angle is being specified, and the collision system consequently never is the center-of-momentum system, the beam momenta have to explicitly set. Besides a planar crossing angle, one is even able to rotate an azimuthal distance: \begin{quote} \begin{footnotesize} \ttt{beams = e1, E1} \\ \ttt{beams\_momentum = 500 GeV, 500 GeV} \\ \ttt{beams\_theta = 0, 10 degree} \\ \ttt{beams\_phi = 0, 45 degree} \end{footnotesize} \end{quote} %%%%%%%%%%%%%%% \subsection{LHAPDF} \label{sec:lhapdf} For incoming hadron beams, the \ttt{beams} statement specifies which structure functions are used. The simplest example is the study of parton-parton scattering processes at a hadron-hadron collider such as LHC or Tevatron. The \lhapdf\ structure function set is selected by a syntax similar to the process setup, namely the example already shown above: \begin{quote} \begin{footnotesize} \begin{verbatim} beams = p, p => lhapdf \end{verbatim} \end{footnotesize} \end{quote} Note that there are slight differences in using the \lhapdf\ release series 6 and the older \fortran\ \lhapdf\ release series 5, at least concerning the naming conventions for the PDF sets~\footnote{Until \whizard\ version 2.2.1 including, only the \lhapdf\ series 5 was supported, while from version 2.2.2 on also the \lhapdf\ release series 6 has been supported.}. The above \ttt{beams} statement selects a default \lhapdf\ structure-function set for both proton beams (which is the \ttt{CT10} central set for \lhapdf\ 6, and \ttt{cteq6ll.LHpdf} central set for \lhapdf 5). The structure function will apply for all quarks, antiquarks, and the gluon as far as supported by the particular \lhapdf\ set. Choosing a different set is done by adding the filename as a local option to the \ttt{lhapdf} keyword: \begin{quote} \begin{footnotesize} \begin{verbatim} beams = p, p => lhapdf $lhapdf_file = "MSTW2008lo68cl" \end{verbatim} \end{footnotesize} \end{quote} for the actual \lhapdf\ 6 series, and \begin{quote} \begin{footnotesize} \begin{verbatim} beams = p, p => lhapdf $lhapdf_file = "MSTW2008lo68cl.LHgrid" \end{verbatim} \end{footnotesize} \end{quote} for \lhapdf 5.Similarly, a member within the set is selected by the numeric variable \verb|lhapdf_member| (for both release series of \lhapdf). In some cases, different structure functions have to be chosen for the two beams. For instance, we may look at $ep$ collisions: \begin{quote} \begin{footnotesize} \begin{verbatim} beams = "e-", p => none, lhapdf \end{verbatim} \end{footnotesize} \end{quote} Here, there is a list of two independent structure functions (each with its own option set, if applicable) which applies to the two beams. Another mixed case is $p\gamma$ collisions, where the photon is to be resolved as a hadron. The simple assignment \begin{quote} \begin{footnotesize} \begin{verbatim} beams = p, gamma => lhapdf, lhapdf_photon \end{verbatim} \end{footnotesize} \end{quote} will be understood as follows: \whizard\ selects the appropriate default structure functions (here we are using \lhapdf\ 5 as an example as the support of photon and pion PDFs in \lhapdf\ 6 has been dropped), \ttt{cteq6ll.LHpdf} for the proton and \ttt{GSG960.LHgrid} for the photon. The photon case has an additional integer-valued parameter \verb|lhapdf_photon_scheme|. (There are also pion structure functions available.) For modifying the default, you have to specify separate structure functions \begin{quote} \begin{footnotesize} \begin{verbatim} beams = p, gamma => lhapdf, lhapdf_photon $lhapdf_file = ... $lhapdf_photon_file = ... \end{verbatim} \end{footnotesize} \end{quote} Finally, the scattering of elementary photons on partons is described by \begin{quote} \begin{footnotesize} \begin{verbatim} beams = p, gamma => lhapdf, none \end{verbatim} \end{footnotesize} \end{quote} Note that for \lhapdf\ version 5.7.1 or higher and for PDF sets which support it, photons can be used as partons. There is one more option for the \lhapdf\ PDFs, namely to specify the path where the \lhapdf\ PDF sets reside: this is done with the string variable \ttt{\$lhapdf\_dir = "{\em }"}. Usually, it is not necessary to set this because \whizard\ detects this path via the \ttt{lhapdf-config} script during configuration, but in the case paths have been moved, or special files/special locations are to be used, the user can specify this location explicitly. %%%%%%%%%%%%%%% \subsection{Built-in PDFs} \label{sec:built-in-pdf} In addition to the possibility of linking against \lhapdf, \whizard\ comes with a couple of built-in PDFs which are selected via the \verb?pdf_builtin? keyword % \begin{quote} \begin{footnotesize} \begin{verbatim} beams = p, p => pdf_builtin \end{verbatim} \end{footnotesize} \end{quote} % The default PDF set is CTEQ6L, but other choices are also available by setting the string variable \verb?$pdf_builtin_set? to an appropiate value. E.g, modifying the above setup to % \begin{quote} \begin{footnotesize} \begin{verbatim} beams = p, p => pdf_builtin $pdf_builtin_set = "mrst2004qedp" \end{verbatim} \end{footnotesize} \end{quote} % would select the proton PDF from the MRST2004QED set. A list of all currently available PDFs can be found in Table~\ref{tab:pdfs}. % \begin{table} \centerline{\begin{tabular}{|l||l|p{0.2\textwidth}|l|} \hline Tag & Name & Notes & References \\\hline\hline % \ttt{cteq6l} & CTEQ6L & \mbox{}\hfill---\hfill\mbox{} & \cite{Pumplin:2002vw} \\\hline \ttt{cteq6l1} & CTEQ6L1 & \mbox{}\hfill---\hfill\mbox{} & \cite{Pumplin:2002vw} \\\hline \ttt{cteq6d} & CTEQ6D & \mbox{}\hfill---\hfill\mbox{} & \cite{Pumplin:2002vw} \\\hline \ttt{cteq6m} & CTEQ6M & \mbox{}\hfill---\hfill\mbox{} & \cite{Pumplin:2002vw} \\\hline \hline \ttt{mrst2004qedp} & MRST2004QED (proton) & includes photon & \cite{Martin:2004dh} \\\hline \hline \ttt{mrst2004qedn} & MRST2004QED (neutron) & includes photon & \cite{Martin:2004dh} \\\hline \hline \ttt{mstw2008lo} & MSTW2008LO & \mbox{}\hfill---\hfill\mbox{} & \cite{Martin:2009iq} \\\hline \ttt{mstw2008nlo} & MSTW2008NLO & \mbox{}\hfill---\hfill\mbox{} & \cite{Martin:2009iq} \\\hline \ttt{mstw2008nnlo} & MSTW2008NNLO & \mbox{}\hfill---\hfill\mbox{} & \cite{Martin:2009iq} \\\hline \hline \ttt{ct10} & CT10 & \mbox{}\hfill---\hfill\mbox{} & \cite{Lai:2010vv} \\\hline \hline \ttt{CJ12\_max} & CJ12\_max & \mbox{}\hfill---\hfill\mbox{} & \cite{Owens:2012bv} \\\hline \ttt{CJ12\_mid} & CJ12\_mid & \mbox{}\hfill---\hfill\mbox{} & \cite{Owens:2012bv} \\\hline \ttt{CJ12\_min} & CJ12\_min & \mbox{}\hfill---\hfill\mbox{} & \cite{Owens:2012bv} \\\hline \hline \ttt{CJ15LO} & CJ15LO & \mbox{}\hfill---\hfill\mbox{} & \cite{Accardi:2016qay} \\\hline \ttt{CJ15NLO} & CJ15NLO & \mbox{}\hfill---\hfill\mbox{} & \cite{Accardi:2016qay} \\\hline \hline \ttt{mmht2014lo} & MMHT2014LO & \mbox{}\hfill---\hfill\mbox{} & \cite{Harland-Lang:2014zoa} \\\hline \ttt{mmht2014nlo} & MMHT2014NLO & \mbox{}\hfill---\hfill\mbox{} & \cite{Harland-Lang:2014zoa} \\\hline \ttt{mmht2014nnlo} & MMHT2014NNLO & \mbox{}\hfill---\hfill\mbox{} & \cite{Harland-Lang:2014zoa} \\\hline \hline \ttt{CT14LL} & CT14LLO & \mbox{}\hfill---\hfill\mbox{} & \cite{Dulat:2015mca} \\\hline \ttt{CT14L} & CT14LO & \mbox{}\hfill---\hfill\mbox{} & \cite{Dulat:2015mca} \\\hline \ttt{CT14N} & CT1414NLO & \mbox{}\hfill---\hfill\mbox{} & \cite{Dulat:2015mca} \\\hline \ttt{CT14NN} & CT14NNLO & \mbox{}\hfill---\hfill\mbox{} & \cite{Dulat:2015mca} \\\hline \hline % \end{tabular}} \caption{All PDF sets available as builtin sets. The two MRST2004QED sets also contain a photon.} \label{tab:pdfs} \end{table} The two MRST2004QED sets also contain the photon as a parton, which can be used in the same way as for \lhapdf\ from v5.7.1 on. Note, however, that there is no builtin PDF that contains a photon structure function. There is a \ttt{beams} structure function specifier \ttt{pdf\_builtin\_photon}, but at the moment this throws an error. It just has been implemented for the case that in future versions of \whizard\ a photon structure function might be included. Note that in general only the data sets for the central values of the different PDFs ship with \whizard. Using the error sets is possible, i.e. it is supported in the syntax of the code, but you have to download the corresponding data sets from the web pages of the PDF fitting collaborations. %%%%%%%%%%%%%%% \subsection{HOPPET $b$ parton matching} When the \hoppet\ tool~\cite{Salam:2008qg} for hadron-collider PDF structure functions and their manipulations are correctly linked to \whizard, it can be used for advanced calculations and simulations of hadron collider physics. Its main usage inside \whizard\ is for matching schemes between 4-flavor and 5-flavor schemes in $b$-parton initiated processes at hadron colliders. Note that in versions 2.2.0 and 2.2.1 it only worked together with \lhapdf\ version 5, while with the \lhapdf\ version 6 interface from version 2.2.2 on it can be used also with the modern version of PDFs from \lhapdf. Furthermore, from version 2.2.2, the \hoppet\ $b$ parton matching also works for the builtin PDFs. It depends on the corresponding process and the energy scales involved whether it is a better description to use the $g\to b\bar b$ splitting from the DGLAP evolution inside the PDF and just take the $b$ parton content of a PDF, e.g. in BSM Higgs production for large $\tan\beta$: $pp \to H$ with a partonic subprocess $b\bar b \to H$, or directly take the gluon PDFs and use $pp \to b\bar b H$ with a partonic subprocess $gg \to b \bar b H$. Elaborate schemes for a proper matching between the two prescriptions have been developed and have been incorporated into the \hoppet\ interface. Another prime example for using these matching schemes is single top production at hadron colliders. Let us consider the following setup: \begin{quote} \begin{footnotesize} \begin{Verbatim} process proc1 = b, u => t, d process proc2 = u, b => t, d process proc3 = g, u => t, d, B { $restrictions = "2+4 ~ W+" } process proc4 = u, g => t, d, B { $restrictions = "1+4 ~ W+" } beams = p,p => pdf_builtin sqrts = 14 TeV ?hoppet_b_matching = true $sample = "single_top_matched" luminosity = 1 / 1 fbarn simulate (proc1, proc2, proc3, proc4) \end{Verbatim} \end{footnotesize}%$ \end{quote} The first two processes are single top production from $b$ PDFs, the last two processes contain an explicit $g\to b\bar b$ splitting (the restriction, cf. Sec.~\ref{sec:process options} has been placed in order to single out the single top production signal process). PDFs are then chosen from the default builtin PDF (which is \ttt{CTEQ6L}), and the \hoppet\ matching routines are switched on by the flag \ttt{?hoppet\_b\_matching}. %%%%%%%%%%%%%%% \subsection{Lepton Collider ISR structure functions} \label{sec:lepton_isr} Initial state QED radiation off leptons is an important feature at all kinds of lepton colliders: the radiative return to the $Z$ resonance by ISR radiation was in fact the largest higher-order effect for the SLC and LEP I colliders. The soft-collinear and soft photon radiation can indeed be resummed/exponentiated to all orders in perturbation theory~\cite{Gribov:1972rt}, while higher orders in hard-collinear photons have to be explicitly calculated order by order~\cite{Kuraev:1985hb,Skrzypek:1990qs}. \whizard\ has an intrinsic implementation of the lepton ISR structure function that includes all orders of soft and soft-collinear photons as well as up to the third order in hard-collinear photons. It can be switched on by the following statement: \begin{quote} \begin{footnotesize} \begin{Verbatim} beams = e1, E1 => isr \end{Verbatim} \end{footnotesize} \end{quote} As the ISR structure function is a single-beam structure function, this expression is synonymous for \begin{quote} \begin{footnotesize} \begin{Verbatim} beams = e1, E1 => isr, isr \end{Verbatim} \end{footnotesize} \end{quote} The ISR structure function can again be applied to only one of the two beams, e.g. in a HERA-like setup: \begin{quote} \begin{footnotesize} \begin{Verbatim} beams = e1, p => isr, pdf_builtin \end{Verbatim} \end{footnotesize} \end{quote} Their are several options for the lepton-collider ISR structure function that are summarized in the following: \vspace{2mm} \centerline{\begin{tabular}{|l|l|l|}\hline Parameter & Default & Meaning \\\hline\hline \ttt{isr\_alpha} & \ttt{0}/intrinsic & value of $\alpha_{QED}$ for ISR \\\hline \ttt{isr\_order} & \ttt{3} & max. order of hard-collinear photon emission \\\hline \ttt{isr\_mass} & \ttt{0}/intrinsic & mass of the radiating lepton \\\hline \ttt{isr\_q\_max} & \ttt{0}/$\sqrt{s}$ & upper cutoff for ISR \\\hline \hline \ttt{?isr\_recoil} & \ttt{false} & flag to switch on recoil/$p_T$ (\emph{deprecated})\\\hline \ttt{?isr\_keep\_energy} & \ttt{false} & recoil flag: conserve energy in splitting (\emph{deprecated}) \\\hline \end{tabular}}\mbox{} The maximal order of the hard-collinear photon emission taken into account by \whizard\ is set by the integer variable \ttt{isr\_order}; the default is the maximally available order of three. With the variable \ttt{isr\_alpha}, the value of the QED coupling constant $\alpha_{QED}$ used in the ISR structure function can be set. The default is taken from the active physics model. The mass of the radiating lepton (in most cases the electron) is set by \ttt{isr\_mass}; again the default is taken from the active physics model. Furthermore, the upper integration border for the ISR structure function which acts roughly as an upper hardness cutoff for the emitted photons, can be set through \ttt{isr\_q\_max}; if not set, the collider energy (possibly after beamstrahlung, cf. Sec.~\ref{sec:beamstrahlung}) $\sqrt{s}$ (or $\sqrt{\widehat{s}}$) is taken. Note that \whizard\ accounts for the exclusive effects of ISR radiation at the moment by a single (hard, resolved) photon in the event; a more realistic treatment of exclusive ISR photons in simulation is foreseen for a future version. While the ISR structure function is evaluated in the collinear limit, it is possible to generate transverse momentum for both the radiated photons and the recoiling partonic system. We recommend to stick to the collinear approximation for the integration step. Integration cuts should be set up such that they do not significantly depend on photon transverse momentum. In a subsequent simulation step, it is possible to transform the events with collinear ISR radiation into more realistic events with non-collinear radiation. To this end, \whizard\ provides a separate ISR photon handler which can be activated in the simulation step. The algorithm operates on the partonic event: it takes the radiated photons and the partons entering the hard process, and applies a $p_T$ distribution to those particles and their interaction products, i.e., all outgoing particles. Cuts that depend on photon $p_T$ may be applied to the modified events. For details on the ISR photon handler, cf.\ Sec.~\ref{sec:isr-photon-handler}. {\footnotesize The flag \ttt{?isr\_recoil} switches on $p_T$ recoil of the emitting lepton against photon radiation during integration; per default it is off. The flag \ttt{?isr\_keep\_energy} controls the mode of on-shell projection for the splitting process with $p_T$. Note that this feature is kept for backwards compatibility, but should not be used for new simulations. The reason is as follows: For a fraction of events, $p_T$ will become significant, and (i) energy/momentum non-conservation, applied to both beams separately, can lead to unexpected and unphysical effects, and (ii) the modified momenta enter the hard process, so the collinear approximation used in the ISR structure function computation does not hold. } %%%%%%%%%%%%%%% \subsection{Lepton Collider Beamstrahlung} \label{sec:beamstrahlung} At linear lepton colliders, the macroscopic electromagnetic interaction of the bunches leads to a distortion of the spectrum of the bunches that is important for an exact simulation of the beam spectrum. There are several methods to account for these effects. The most important tool to simulate classical beam-beam interactions in lepton-collider physics is \ttt{GuineaPig++}~\cite{Schulte:1998au,Schulte:1999tx,Schulte:2007zz}. A direct interface between this tool \ttt{GuineaPig++} and \whizard\ had existed as an inofficial add-on to the legacy branch \whizard\ttt{1}, but is no longer applicable in \whizard\ttt{2}. A \whizard-internal interface is foreseen for the very near future, most probably within this v2.2 release. Other options are to use parameterizations of the beam spectrum that have been included in the package \circeone~\cite{CIRCE} which has been interfaced to \whizard\ since version v1.20 and been included in the \whizard\ttt{2} release series. Another option is to generate a beam spectrum externally and then read it in as an ASCII data file, cf. Sec.~\ref{sec:beamevents}. More about this can be found in a dedicated section on lepton collider spectra, Sec.~\ref{sec:beamspectra}. In this section, we discuss the usage of beamstrahlung spectra by means of the \circeone\ package. The beamstrahlung spectra are true spectra, so they have to be applied to pairs of beams, and an application to only one beam is meaningless. They are switched on by this \ttt{beams} statement including structure functions: \begin{quote} \begin{footnotesize} \begin{Verbatim} beams = e1, E1 => circe1 \end{Verbatim} \end{footnotesize} \end{quote} It is important to note that the parameterization of the beamstrahlung spectra within \circeone\ contain also processes where $e\to\gamma$ conversions have been taking place, i.e. also hard processes with one (or two) initial photons can be simulated with beamstrahlung switched on. In that case, the explicit photon flags, \ttt{?circe1\_photon1} and \ttt{?circe1\_photon2}, for the two beams have to be properly set, e.g. (ordering in the final state does not play a role): \begin{quote} \begin{footnotesize} \begin{Verbatim} process proc1 = A, e1 => A, e1 sqrts = 500 GeV beams = e1, E1 => circe1 ?circe1_photon1 = true integrate (proc1) process proc2 = e1, A => A, e1 sqrts = 1000 GeV beams = e1, A => circe1 ?circe1_photon2 = true \end{Verbatim} \end{footnotesize} \end{quote} or \begin{quote} \begin{footnotesize} \begin{Verbatim} process proc1 = A, A => Wp, Wm sqrts = 200 GeV beams = e1, E1 => circe1 ?circe1_photon1 = true ?circe1_photon2 = true ?circe1_generate = false \end{Verbatim} \end{footnotesize} \end{quote} In all cases (one or both beams with photon conversion) the beam spectrum applies to both beams simultaneously. In the last example ($\gamma\gamma\to W^+W^-$) the default \circeone\ generator mode was turned off by unsetting \verb|?circe1_generate|. In the other examples this flag is set, by default. For standard use cases, \circeone\ implements a beam-event generator inside the \whizard\ generator, which provides beam-event samples with correctly distributed probability. For electrons, the beamstrahlung spectrum sharply peaks near maximum energy. This distribution is most efficiently handled by the generator mode. By contrast, in the $\gamma\gamma$ mode, the beam-event c.m.\ energy is concentrated at low values. For final states with low invariant mass, which are typically produced by beamstrahlung photons, the generator mode is appropriate. However, the $W^+W^-$ system requires substantial energy, and such events will be very rare in the beam-event sample. Switching off the \circeone\ generator mode solves this problem. This is an overview over all options and flags for the \circeone\ setup for lepton collider beamstrahlung: \vspace{2mm} \centerline{\begin{tabular}{|l|l|l|}\hline Parameter & Default & Meaning \\\hline\hline \ttt{?circe1\_photon1} & \ttt{false} & $e\to\gamma$ conversion for beam 1 \\\hline \ttt{?circe1\_photon2} & \ttt{false} & $e\to\gamma$ conversion for beam 2 \\\hline \ttt{circe1\_sqrts} & $\sqrt{s}$ & collider energy for the beam spectrum \\\hline \ttt{?circe1\_generate} & \ttt{true} & flag for the \circeone\ generator mode \\\hline \ttt{?circe1\_map} & \ttt{true} & flag to apply special phase-space mapping \\\hline \ttt{circe1\_mapping\_slope} & \ttt{2.} & value of PS mapping exponent \\\hline \ttt{circe1\_eps} & \ttt{1E-5} & parameter for mapping of spectrum peak position \\\hline \ttt{circe1\_ver} & \ttt{0} & internal version of \circeone\ package \\\hline \ttt{circe1\_rev} & \ttt{0}/most recent & internal revision of \circeone\ \\\hline \ttt{\$circe1\_acc} & \ttt{SBAND} & accelerator type \\\hline \ttt{circe1\_chat} & \ttt{0} & chattiness/verbosity of \circeone \\\hline \end{tabular}}\mbox{} The collider energy relevant for the beamstrahlung spectrum is set by \ttt{circe1\_sqrts}. As a default, this is always the value of \ttt{sqrts} set in the \sindarin\ script. However, sometimes these values do not match, e.g. the user wants to simulate $t\bar t h$ at \ttt{sqrts = 550 GeV}, but the only available beam spectrum is for 500 GeV. In that case, \ttt{circe1\_sqrts = 500 GeV} has to be set to use the closest possible available beam spectrum. As mentioned in the discussion of the examples above, in \circeone\ there are two options to use the beam spectra for beamstrahlung: intrinsic semi-analytic approximation formulae for the spectra, or a Monte-Carlo sampling of the sampling. The second possibility always give a better description of the spectra, and is the default for \whizard. It can, however, be switched off by setting the flag \ttt{?circe1\_generate} to \ttt{false}. As the beamstrahlung spectra are sharply peaked at the collider energy, but still having long tails, a mapping of the spectra for an efficient phase-space sampling is almost mandatory. This is the default in \whizard, which can be changed by the flag \ttt{?circe1\_map}. Also, the default exponent for the mapping can be changed from its default value \ttt{2.} with the variable \ttt{circe1\_mapping\_slope}. It is important to efficiently sample the peak position of the spectrum; the effective ratio of the peak to the whole sampling interval can be set by the parameter \ttt{circe1\_eps}. The integer parameter \ttt{circe1\_chat} sets the chattiness or verbosity of the \circeone\ package, i.e. how many messages and warnings from the beamstrahlung generation/sampling will be issued. The actual internal version and revision of the \circeone\ package are set by the two integer parameters \ttt{circe1\_ver} and \ttt{circe1\_rev}. The default is in any case always the newest version and revision, while older versions are still kept for backwards compatibility and regression testing. Finally, the geometry and design of the accelerator type is set with the string variable \ttt{\$circe1\_acc}: it contains the possible options for the old \ttt{"SBAND"} and \ttt{"XBAND"} setups, as well as the \ttt{"TESLA"} and JLC/NLC SLAC design \ttt{"JLCNLC"}. The setups for the most important energies of the ILC as they are summarized in the ILC TDR~\cite{Behnke:2013xla,Baer:2013cma,Adolphsen:2013jya,Adolphsen:2013kya} are available as \ttt{ILC}. Beam spectra for the CLIC~\cite{Aicheler:2012bya,Lebrun:2012hj,Linssen:2012hp} linear collider are much more demanding to correctly simulate (due to the drive beam concept; only the low-energy modes where the drive beam is off can be simulated with the same setup as the abovementioned machines). Their setup will be supported soon in one of the upcoming \whizard\ versions within the \circetwo\ package. An example of how to generate beamstrahlung spectra with the help of the package \circetwo\ (that is also a part of \whizard) is this: \begin{quote} \begin{footnotesize} \begin{Verbatim} process eemm = e1, E1 => e2, E2 sqrts = 500 GeV beams = e1, E1 => circe2 $circe2_file = "ilc500.circe" $circe2_design = "ILC" ?circe_polarized = false \end{Verbatim} \end{footnotesize}%$ \end{quote} Here, the ILC design is used for a beamstrahlung spectrum at 500 GeV nominal energy, with polarization averaged (hence, the setting of polarization to \ttt{false}). A list of all available options can be found in Sec.~\ref{sec:photoncoll}. More technical details about the simulation of beamstrahlung spectra see the documented source code of the \circeone\ package, as well as Chap.~\ref{chap:hardint}. In the next section, we discuss how to read in beam spectra from external files. %%%%%%%%%%%%%%% \subsection{Beam events} \label{sec:beamevents} As mentioned in the previous section, beamstrahlung is one of the crucial ingredients for a realistic simulation of linear lepton colliders. One option is to take a pre-generated beam spectrum for such a machine, and make it available for simulation within \whizard\ as an external ASCII data file. Such files basically contain only pairs of energy fractions of the nominal collider energy $\sqrt{s}$ ($x$ values). In \whizard\ they can be used in simulation with the following \ttt{beams} statement: \begin{quote} \begin{footnotesize} \begin{Verbatim} beams = e1, E1 => beam_events $beam_events_file = "" \end{Verbatim} \end{footnotesize}%$ \end{quote} Note that beam spectra must always be pair spectra, i.e. they are automatically applied to both beam simultaneously. Beam spectra via external files are expected to reside in the current working directory. Alternatively, \whizard\ searches for them in the install directory of \whizard\ in \ttt{share/beam-sim}. There you can find an example file, \ttt{uniform\_spread\_2.5\%.dat} for such a beam spectrum. The only possible parameter that can be set is the flag \ttt{?beam\_events\_warn\_eof} whose default is \ttt{true}. This triggers the issuing of a warning when the end of file of an external beam spectrum file is reached. In such a case, \whizard\ starts to reuse the same file again from the beginning. If the available data points in the beam events file are not big enough, this could result in an insufficient sampling of the beam spectrum. %%%%%%%%%%%%%%% \subsection{Gaussian beam-energy spread} \label{sec:gaussian} Real beams have a small energy spread. If beamstrahlung is small, the spread may be approximately described as Gaussian. As a replacement for the full simulation that underlies \ttt{CIRCE2} spectra, it is possible to impose a Gaussian distributed beam energy, separately for each beam. \begin{quote} \begin{footnotesize} \begin{Verbatim} beams = e1, E1 => gaussian gaussian_spread1 = 0.1\% gaussian_spread2 = 0.2\% \end{Verbatim} \end{footnotesize}%$ \end{quote} (Note that the \% sign means multiplication by 0.01, as it should.) The spread values are defined as the $\sigma$ value of the Gaussian distribution, i.e., $2/3$ of the events are within $\pm 1\sigma$ for each beam, respectively. %%%%%%%%%%%%%%%% \subsection{Equivalent photon approximation} \label{sec:epa} The equivalent photon approximation (EPA) uses an on-shell approximation for the $e \to e\gamma$ collinear splitting to allow the simulation of photon-induced backgrounds in lepton collider physics. The original concept is that of the Weizs\"acker-Williams approximation~\cite{vonWeizsacker:1934sx,Williams:1934ad,Budnev:1974de}. This is a single-beam structure function that can be applied to both beams, or also to one beam only. Usually, there are some simplifications being made in the derivation. The formula which is implemented here and seems to be the best for the QCD background for low-$p_T$ hadrons, corresponds to Eq.~(6.17) of Ref.~\cite{Budnev:1974de}. As this reference already found, this leads to an "overshooting" of accuracy, and especially in the high-$x$ (high-energy) region to wrong results. This formula corresponds to \begin{equation} \label{eq:budnev_617} f(x) = \frac{\alpha}{\pi} \frac{1}{x} \biggl[ \left( \bar{x} + \frac{x^2}{2} \right) \log \frac{Q^2_{\text{max}}}{Q^2_{\text{min}}} - \left( 1 - \frac{x}{2} \right)^2 \log \frac{x^2 + \tfrac{Q^2_{\text{max}}}{E^2}}{x^2 + \tfrac{Q^2_{\text{min}}}{E^2}} - \frac{m_e^2 x^2}{Q^2_{\text{min}}} \left( 1 - \frac{Q^2_{\text{min}}}{Q^2_{\text{max}}} \right) \biggr] \qquad . \end{equation} Here, $x$ is the ratio of the photon energy (called frequency $\omega$ in~\cite{Budnev:1974de} over the original electron (or positron) beam energy $E$. The energy of the electron (or positron) after the splitting is given by $\bar{x} = 1-x$. The simplified version is the one that corresponds to many publications about the EPA during SLC and LEP times, and corresponds to the $q^2$ integration of Eq.~(6.16e) in~\cite{Budnev:1974de}, where $q^2$ is the virtuality or momentum transfer of the photon in the EPA: \begin{equation} \label{eq:budnev_616e} f(x) = \frac{\alpha}{\pi} \frac{1}{x} \biggl[ \left( \bar{x} + \frac{x^2}{2} \right) \log \frac{Q^2_{\text{max}}}{Q^2_{\text{min}}} - \frac{m_e^2 x^2}{Q^2_{\text{min}}} \left( 1 - \frac{Q^2_{\text{min}}}{Q^2_{\text{max}}} \right) \biggr] \qquad . \end{equation} While Eq.~(\ref{eq:budnev_617}) is supposed to be the better choice for simulating hadronic background like low-$p_T$ hadrons and should be applied for the low-$x$ region of the EPA, Eq.~(\ref{eq:budnev_616e}) seems better suited for high-$x$ simulations like the photoproduction of BSM resonances etc. Note that the first term in Eqs.~(\ref{eq:budnev_617}) and (\ref{eq:budnev_616e}) is the standard Altarelli-Parisi QED splitting function of electron, $P_{e\to e\gamma}(x) \propto 1 + (1-x)^2$, while the last term in both equations is the default power correction. The two parameters $Q^2_{\text{max}}$ and $Q^2_{\text{min}}$ are the integration boundaries of the photon virtuality integration. Usually, they are given by the kinematic limits: \begin{equation} Q^2_{\text{min}} = \frac{m_e^2 x^2}{\bar{x}} \qquad\qquad Q^2_{\text{max}} = 4 E^2 \bar{x} = s \bar{x} \qquad . \end{equation} For low-$p_T$ hadron simulations, it is not a good idea to take the kinematic limit as an upper limit, but one should cut the simulation off at a hadronic scale like e.g. a multiple of the $\rho$ mass. The user can switch between the two different options using the setting \begin{quote} \begin{footnotesize} \begin{Verbatim} $epa_mode = "default" \end{Verbatim} \end{footnotesize} \end{quote} or \begin{quote} \begin{footnotesize} \begin{Verbatim} $epa_mode = "Budnev_617" \end{Verbatim} \end{footnotesize} \end{quote} for Eq.~(\ref{eq:budnev_617}), while Eq.~(\ref{eq:budnev_616e}) can be chosen with \begin{quote} \begin{footnotesize} \begin{Verbatim} $epa_mode = "Budnev_616e" \end{Verbatim} \end{footnotesize} \end{quote} Note that a thorough study for high-energy $e^+e^-$ colliders regarding the suitability of different EPA options is still lacking. For testing purposes also three more variants or simplifications of Eq.~(\ref{eq:budnev_616e}) are implemented: the first, steered by \ttt{\$epa\_mode = log\_power} uses simply $Q^2_{\text{max}} = s$. This is also the case for the two other method. But the switch \ttt{\$epa\_mode = log\_simple} uses just \ttt{epa\_mass} (cf. below) as $Q^2_{\text{min}}$. The final simplification is to drop the power correction, which can be chosen with \ttt{\$epa\_mode = log}. This corresponds to the simple formula: \begin{equation} f(x) = \frac{\alpha}{2\pi} \frac{1}{x} \, \log\frac{s}{m^2} \qquad . \end{equation} Examples for the application of the EPA in \whizard\ are: \begin{quote} \begin{footnotesize} \begin{Verbatim} beams = e1, E1 => epa \end{Verbatim} \end{footnotesize} \end{quote} or for a single beam: \begin{quote} \begin{footnotesize} \begin{Verbatim} beams = e1, p => epa, pdf_builtin \end{Verbatim} \end{footnotesize} \end{quote} The last process allows the reaction of (quasi-) on-shell photons with protons. In the following, we collect the parameters and flags that can be adjusted when using the EPA inside \whizard: \vspace{2mm} \centerline{\begin{tabular}{|l|l|l|}\hline Parameter & Default & Meaning \\\hline\hline \ttt{epa\_alpha} & \ttt{0}/intrinsic & value of $\alpha_{QED}$ for EPA \\\hline \ttt{epa\_x\_min} & \ttt{0.} & soft photon cutoff in $x$ (mandatory) \\\hline \ttt{epa\_q\_min} & \ttt{0.} & minimal $\gamma$ momentum transfer \\\hline \ttt{epa\_mass} & \ttt{0}/intrinsic & mass of the radiating fermion (mandatory) \\\hline \ttt{epa\_q\_max} & \ttt{0}/$\sqrt{s}$ & upper cutoff for EPA \\\hline \ttt{?epa\_recoil} & \ttt{false} & flag to switch on recoil/$p_T$ \\\hline \ttt{?epa\_keep\_energy} & \ttt{false} & recoil flag to conserve energy in splitting \\\hline \end{tabular}}\mbox{} The adjustable parameters are partially similar to the parameters in the QED initial-state radiation (ISR), cf. Sec.~\ref{sec:lepton_isr}: the parameter \ttt{epa\_alpha} sets the value of the electromagnetic coupling constant, $\alpha_{QED}$ used in the EPA structure function. If not set, this is taken from the value inside the active physics model. The same is true for the mass of the particle that radiates the photon of the hard interaction, which can be reset by the user with the variable \ttt{epa\_mass}. There are two dimensionful scale parameters, the minimal momentum transfer to the photon, \ttt{epa\_q\_min}, which must not be zero, and the upper momentum-transfer cutoff for the EPA structure function, \ttt{epa\_q\_max}. The default for the latter value is the collider energy, $\sqrt{s}$, or the energy reduced by another structure function like e.g. beamstrahlung, $\sqrt{\hat{s}}$. Furthermore, there is a soft-photon regulator for the splitting function in $x$ space, \ttt{epa\_x\_min}, which also has to be explicitly set different from zero. Hence, a minimal viable scenario that will be accepted by \whizard\ looks like this: \begin{quote} \begin{footnotesize} \begin{Verbatim} beams = e1, E1 => epa epa_q_min = 5 GeV epa_x_min = 0.01 \end{Verbatim} \end{footnotesize} \end{quote} Finally, like the ISR case in Sec.~\ref{sec:lepton_isr}, there is a flag to consider the recoil of the photon against the radiating electron by setting \ttt{?epa\_recoil} to \ttt{true} (default: \ttt{false}). Though in principle processes like $e^+ e^- \to e^+ e^- \gamma \gamma$ where the two photons have been created almost collinearly and then initiate a hard process could be described by exact matrix elements and exact kinematics. However, the numerical stability in the very far collinear kinematics is rather challenging, such that the use of the EPA is very often an acceptable trade-off between quality of the description on the one hand and numerical stability and speed on the other hand. In the case, the EPA is set after a second structure function like a hadron collider PDF, there is a flavor summation over the quark constituents inside the proton, which are then the radiating fermions for the EPA. Here, the masses of all fermions have to be identical. More about the physics of the equivalent photon approximation can be found in Chap.~\ref{chap:hardint}. %%%%%%%%%%%%%%% \subsection{Effective $W$ approximation} \label{sec:ewa} An approach similar to the equivalent photon approximation (EPA) discussed in the previous section Sec.~\ref{sec:epa}, is the usage of a collinear splitting function for the radiation of massive electroweak vector bosons $W$/$Z$, the effective $W$ approximation (EWA). It has been developed for the description of high-energy weak vector-boson fusion and scattering processes at hadron colliders, particularly the Superconducting Super-Collider (SSC). This was at a time when the simulation of $2\to 4$ processes war still very challenging and $2\to 6$ processes almost impossible, such that this approximation was the only viable solution for the simulation of processes like $pp \to jjVV$ and subsequent decays of the bosons $V \equiv W, Z$. Unlike the EPA, the EWA is much more involved as the structure functions do depend on the isospin of the radiating fermions, and are also different for transversal and longitudinal polarizations. Also, a truely collinear kinematics is never possible due to the finite $W$ and $Z$ boson masses, which start becoming more and more negligible for energies larger than the nominal LHC energy of 14 TeV. Though in principle all processes for which the EWA might be applicable are technically feasible in \whizard\ to be generated also via full matrix elements, the EWA has been implemented in \whizard\ for testing purposes, backwards compatibility and comparison with older simulations. Like the EPA, it is a single-beam structure function that can be applied to one or both beams. We only give an example for both beams here, this is for a 3 TeV CLIC collider: \begin{quote} \begin{footnotesize} \begin{Verbatim} sqrts = 3 TeV beams = e1, E1 => ewa \end{Verbatim} \end{footnotesize} \end{quote} And this is for LHC or a higher-energy follow-up collider (which also shows the concatenation of the single-beam structure functions, applied to both beams consecutively, cf. Sec.~\ref{sec:concatenation}: \begin{quote} \begin{footnotesize} \begin{Verbatim} sqrts = 14 TeV beams = p, p => pdf_builtin => ewa \end{Verbatim} \end{footnotesize} \end{quote} Again, we list all the options, parameters and flags that can be adapted for the EWA: \vspace{2mm} \centerline{\begin{tabular}{|l|l|l|}\hline Parameter & Default & Meaning \\\hline\hline \ttt{ewa\_x\_min} & \ttt{0.} & soft $W$/$Z$ cutoff in $x$ (mandatory) \\\hline \ttt{ewa\_mass} & \ttt{0}/intrinsic & mass of the radiating fermion \\\hline \ttt{ewa\_pt\_max} & \ttt{0}/$\sqrt{\hat{s}}$ & upper cutoff for EWA \\\hline \ttt{?ewa\_recoil} & \ttt{false} & recoil switch \\\hline \ttt{?ewa\_keep\_energy} & \ttt{false} & energy conservation for recoil in splitting \\\hline \end{tabular}}\mbox{} First of all, all coupling constants are taken from the active physics model as they have to be consistent with electroweak gauge invariance. Like for EPA, there is a soft $x$ cutoff for the $f \to f V$ splitting, \ttt{ewa\_x\_min}, that has to be set different from zero by the user. Again, the mass of the radiating fermion can be set explicitly by the user; and, also again, the masses for the flavor sum of quarks after a PDF as radiators of the electroweak bosons have to be identical. Also for the EWA, there is an upper cutoff for the $p_T$ of the electroweak boson, that can be set via \ttt{eta\_pt\_max}. Indeed, the transversal $W$/$Z$ structure function is logarithmically divergent in that variable. If it is not set by the user, it is estimated from $\sqrt{s}$ and the splitting kinematics. For the EWA, there is a flag to switch on a recoil for the electroweak boson against the radiating fermion, \ttt{?ewa\_recoil}. Note that this is an experimental feature that is not completely tested. In any case, the non-collinear kinematics violates 4-four momentum conservation, so there are two choices: either to conserve the energy (\ttt{?ewa\_keep\_energy = true}) or to conserve 3-momentum (\ttt{?ewa\_keep\_energy = false}). Momentum conservation for the kinematics is the default. This is due to the fact that for energy conservation, there will be a net total momentum in the event including the beam remnants (ISR/EPA/EWA radiated particles) that leeds to unexpected or unphysical features in the energy distributions of the beam remnants recoiling against the rest of the event. More details about the physics can be found in Chap.~\ref{chap:hardint}. %%%%%%%%%%%%%%% \subsection{Energy scans using structure functions} In \whizard, there is an implementation of a pair spectrum, \ttt{energy\_scan}, that allows to scan the energy dependence of a cross section without actually scanning over the collider energies. Instead, only a single integration at the upper end of the scan interval over the process with an additional pair spectrum structure function performed. The structure function is chosen in such a way, that the distribution of $x$ values of the energy scan pair spectrum translates in a plot over the energy of the final state in an energy scan from \ttt{0} to \ttt{sqrts} for the process under consideration. The simplest example is the $1/s$ fall-off with the $Z$ resonance in $e^+e^- \to \mu^+ \mu^-$, where the syntax is very easy: \begin{quote} \begin{footnotesize} \begin{Verbatim} process eemm = e1, E1 => e2, E2 sqrts = 500 GeV cuts = sqrts_hat > 50 beams = e1, E1 => energy_scan integrate (eemm) \end{Verbatim} \end{footnotesize} \end{quote} The value of \ttt{sqrts = 500 GeV} gives the upper limit for the scan, while the cut effectively let the scan start at 50 GeV. There are no adjustable parameters for this structure function. How to plot the invariant mass distribution of the final-state muon pair to show the energy scan over the cross section, will be explained in Sec.~\ref{sec:analysis}. More details can be found in Chap.~\ref{chap:hardint}. %%%%%%%%%%%%%%% \subsection{Photon collider spectra} \label{sec:photoncoll} One option that has been discussed as an alternative possibility for a high-energy linear lepton collider is to convert the electron and positron beam via Compton backscattering off intense laser beams into photon beams~\cite{Ginzburg:1981vm,Telnov:1989sd,Telnov:1995hc}. Naturally, due to the production of the photon beams and the inherent electron spectrum, the photon beams have a characteristic spectrum. The simulation of such spectra is possible within \whizard\ by means of the subpackage \circetwo, which have been mentioned already in Sec.~\ref{sec:beamstrahlung}. It allows to give a much more elaborate description of a linear lepton collider environment than \circeone\ (which, however, is not in all cases necessary, as the ILC beamspectra for electron/positrons can be perfectly well described with \circeone). Here is a typical photon collider setup where we take a photon-initiated process: \begin{quote} \begin{footnotesize} \begin{Verbatim} process aaww = A, A => Wp, Wm beams = A, A => circe2 $circe2_file = "teslagg_500_polavg.circe" $circe2_design = "TESLA/GG" ?circe2_polarized = false \end{Verbatim} \end{footnotesize}%$ \end{quote} Here, the photons are the initial states initiating the hard scattering. The structure function is \ttt{circe2} which always is a pair spectrum. The list of available options are: \vspace{2mm} \centerline{\begin{tabular}{|l|l|l|}\hline Parameter & Default & Meaning \\\hline\hline \ttt{?circe2\_polarized} & \ttt{true} & spectrum respects polarization info \\\hline \ttt{\$circe2\_file} & -- & name of beam spectrum data file \\\hline \ttt{\$circe2\_design} & \ttt{"*"} & collider design \\\hline \end{tabular}}\mbox{} The only logical flag \ttt{?circe2\_polarized} let \whizard\ know whether it should keep polarization information in the beam spectra or average over polarizations. Naturally, because of the Compton backscattering generation of the photons, photon spectra are always polarized. The collider design can be specified by the string variable \ttt{\$circe2\_design}, where the default setting \ttt{"*"} corresponds to the default of \circetwo\ (which is the TESLA 500 GeV machine as discussed in the TESLA Technical Design Report~\cite{AguilarSaavedra:2001rg,Richard:2001qm}). Note that up to now there have not been any setups for a photon collider option for the modern linear collider concepts like ILC and CLIC. The string variable \ttt{\$circe2\_file} then allows to give the name of the file containing the actual beam spectrum; all files that ship with \whizard\ are stored in the directory \ttt{circe2/share/data}. More details about the subpackage \circetwo\ and the physics it covers, can be found in its own manual and the chapter Chap.~\ref{chap:hardint}. %%%%%%%%%%%%%%% \subsection{Concatenation of several structure functions} \label{sec:concatenation} As has been shown already in Sec.~\ref{sec:epa} and Sec.~\ref{sec:ewa}, it is possible within \whizard\ to concatenate more than one structure function, irrespective of the fact, whether the structure functions are single-beam structure functions or pair spectra. One important thing is whether there is a phase-space mapping for these structure functions. Also, there are some combinations which do not make sense from the physics point of view, for example using lepton-collider ISR for protons, and then afterwards switching on PDFs. Such combinations will be vetoed by \whizard, and you will find an error message like (cf. also Sec.~\ref{sec:errors}): \begin{interaction} ****************************************************************************** ****************************************************************************** *** FATAL ERROR: Beam structure: [....] not supported ****************************************************************************** ****************************************************************************** \end{interaction} Common examples for the concatenation of structure functions are linear collider applications, where beamstrahlung (macroscopic electromagnetic beam-beam interactions) and electron QED initial-state radiation are both switched on: \begin{code} beams = e1, E1 => circe1 => isr \end{code} Another possibility is the simulation of photon-induced backgrounds at ILC or CLIC, using beamstrahlung and equivalent photon approximation (EPA): \begin{code} beams = e1, E1 => circe1 => epa \end{code} or with beam events from a data file: \begin{code} beams = e1, E1 => beam_events => isr \end{code} In hadron collider physics, parton distribution functions (PDFs) are basically always switched on, while afterwards the user could specify to use the effective $W$ approximation (EWA) to simulate high-energy vector boson scattering: \begin{code} sqrts = 100 TeV beams = p, p => pdf_builtin => ewa \end{code} Note that this last case involves a flavor sum over the five active quark (and anti-quark) species $u$, $d$, $c$, $s$, $b$ in the proton, all of which act as radiators for the electroweak vector bosons in the EWA. This would be an example with three structure functions: \begin{code} beams = e1, E1 => circe1 => isr => epa \end{code} %%%%%%%%%%%%%%% \section{Polarization} \label{sec:polarization} %%%%% \subsection{Initial state polarization} \label{sec:initialpolarization} \whizard\ supports polarizing the inital state fully or partially by assigning a nontrivial density matrix in helicity space. Initial state polarization requires a beam setup and is initialized by means of the \ttt{beams\_pol\_density} statement\footnote{Note that the syntax for the specification of beam polarization has changed from version v2.1 to v2.2 and is incompatible between the two release series. The old syntax \ttt{beam\_polarization} with its different polarization constructors has been discarded in favor of a unified syntax.}: \begin{quote} \begin{footnotesize} \begin{verbatim} beams_pol_density = @([]), @([]) \end{verbatim} \end{footnotesize} \end{quote} The command \ttt{beams\_pol\_fraction} gives the degree of polarization of the two beams: \begin{quote} \begin{footnotesize} \begin{verbatim} beams_pol_fraction = , \end{verbatim} \end{footnotesize} \end{quote} Both commands in the form written above apply to scattering processes, where the polarization of both beams must be specified. The \ttt{beams\_pol\_density} and \ttt{beams\_pol\_fraction} are possible with a single beam declaration if a decay process is considered, but only then. While the syntax for the command \ttt{beams\_pol\_fraction} is pretty obvious, the syntax for the actual specification of the beam polarization is more intricate. We start with the polarization fraction: for each beam there is a real number between zero (unpolarized) and one (complete polarization) that can be specified either as a floating point number like \ttt{0.4} or with a percentage: \ttt{40 \%}. Note that the actual arithmetics is sometimes counterintuitive: 80 \% left-handed electron polarization means that 80 \% of the electron beam are polarized, 20 \% are unpolarized, i.e. 20 \% have half left- and half right-handed polarization each. Hence, 90 \% of the electron beam is left-handed, 10 \% is right-handed. How does the specification of the polarization work? If there are no entries at all in the polarization constructor, \ttt{@()}, the beam is unpolarized, and the spin density matrix is proportional to the unit/identity matrix. Placing entries into the \ttt{@()} constructor follows the concept of sparse matrices, i.e. the entries that have been specified will be present, while the rest remains zero. Single numbers do specify entries for that particular helicity on the main diagonal of the spin density matrix, e.g. for an electron \ttt{@(-1)} means (100\%) left-handed polarization. Different entries are separated by commas: \ttt{@(1,-1)} sets the two diagonal entries at positions $(1,1)$ and $(-1,-1)$ in the density matrix both equal to one. Two remarks are in order already here. First, note that you do not have to worry about the correct normalization of the spin density matrix, \whizard\ is taking care of this automatically. Second, in the screen output for the beam data, only those entries of the spin density matrix that have been specified by the user, will be displayed. If a \ttt{beams\_pol\_fraction} statement appears, other components will be non-zero, but might not be shown. E.g. ILC-like, 80 \% polarization of the electrons, 30 \% positron polarization will be specified like this for left-handed electrons and right-handed positrons: \begin{code} beams = e1, E1 beams_pol_density = @(-1), @(+1) beams_pol_fraction = 80%, 30% \end{code} The screen output will be like this: \begin{code} | ------------------------------------------------------------------------ | Beam structure: e-, e+ | polarization (beam 1): | @(-1: -1: ( 1.000000000000E+00, 0.000000000000E+00)) | polarization (beam 2): | @(+1: +1: ( 1.000000000000E+00, 0.000000000000E+00)) | polarization degree = 0.8000000, 0.3000000 | Beam data (collision): | e- (mass = 0.0000000E+00 GeV) polarized | e+ (mass = 0.0000000E+00 GeV) polarized \end{code} But because of the fraction of unpolarized electrons and positrons, the spin density matrices for electrons and positrons are: \[ \rho(e^-) = \diag \left ( 0.10, 0.90 \right) \qquad \rho(e^+) = \diag \left ( 0.65, 0.35 \right) \quad , \] respectively. So, in general, only the entries due to the polarized fraction will be displayed on screen. We will come back to more examples below. Again, the setting of a single entry, e.g. \ttt{@($\pm m$)}, which always sets the diagonal component $(\pm m, \pm m)$ of the spin density matrix equal to one. Here $m$ can have the following values for the different spins (in parentheses are entries that exist only for massive particles): \vspace{1mm} \begin{center} \begin{tabular}{|l|l|l|}\hline Spin $j$ & Particle type & possible $m$ values \\\hline 0 & Scalar boson & 0 \\ 1/2 & Spinor & +1, -1 \\ 1 & (Massive) Vector boson & +1, (0), -1 \\ 3/2 & (Massive) Vectorspinor & +2, (+1), (-1), -2 \\ 2 & (Massive) Tensor & +2, (+1), (0), (-1), -2 \\\hline \end{tabular} \end{center} \vspace{1mm} Off-diagonal entries that are equal to one (up to the normalization) of the spin-density matrix can be specified simply by the position, namely: \ttt{@($m$:$m'$, $m''$)}. This would result in a spin density matrix with diagonal entry $1$ for the position $(m'', m'')$, and an entry of $1$ for the off-diagonal position $(m,m')$. Furthermore, entries in the density matrix different from $1$ with a numerical value \ttt{{\em }} can be specified, separated by another colon: \ttt{@($m$:$m'$:{\em })}. Here, it does not matter whether $m$ and $m'$ are different or not. For $m = m'$ also diagonal spin density matrix entries different from one can be specified. Note that because spin density matrices have to be Hermitian, only the entry $(m,m')$ has to be set, while the complex conjugate entry at the transposed position $(m',m)$ is set automatically by \whizard. We will give some general density matrices now, and after that a few more definite examples. In the general setups below, we always give the expression for the spin density matrix only for one single beam. % { \newcommand{\cssparse}[4]{% \begin{pmatrix} #1 & 0 & \cdots & \cdots & #3 \\ 0 & 0 & \ddots & & 0 \\ \vdots & \ddots & \ddots & \ddots & \vdots \\ 0 & & \ddots & 0 & 0 \\ #4 & \cdots & \cdots & 0 & #2 \end{pmatrix}% } % \begin{itemize} \item {\bf Unpolarized:} \begin{center} \begin{footnotesize} \ttt{beams\_pol\_density = @()} \end{footnotesize} \end{center} % \newline This has the same effect as not specifying any polarization at all and is the only constructor available for scalars and fermions declared as left- or right-handed (like the neutrino). Density matrix: \[ \rho = \frac{1}{|m|}\mathbb{I} \] ($|m|$: particle multiplicity which is 2 for massless, $2j + 1$ for massive particles). % \item {\bf Circular polarization:} \begin{center} \begin{footnotesize} \ttt{beams\_pol\_density = @($\pm j$) \qquad beams\_pol\_fraction = $f$} \end{footnotesize} \end{center} A fraction $f$ (parameter range $f \in \left[0\;;\;1\right]$) of the particles are in the maximum / minimum helicity eigenstate $\pm j$, the remainder is unpolarized. For spin $\frac{1}{2}$ and massless particles of spin $>0$, only the maximal / minimal entries of the density matrix are populated, and the density matrix looks like this: \[ \rho = \diag\left(\frac{1\pm f}{2}\;,\;0\;,\;\dots\;,\;0\;, \frac{1\mp f}{2}\right) \] % \item {\bf Longitudinal polarization (massive):} \begin{center} \begin{footnotesize} \ttt{beams\_pol\_density = @(0) \qquad beams\_pol\_fraction = $f$} \end{footnotesize} \end{center} We consider massive particles with maximal spin component $j$, a fraction $f$ of which having longitudinal polarization, the remainder is unpolarized. Longitudinal polarization is (obviously) only available for massive bosons of spin $>0$. Again, the parameter range for the fraction is: $f \in \left[0\;;\;1\right]$. The density matrix has the form: \[ \rho = \diag\left(\frac{1-f}{|m|}\;,\;\dots\;,\;\frac{1-f}{|m|}\;,\; \frac{1+f \left(|m| - 1\right)}{|m|}\;,\;\frac{1-f}{|m|}\;, \;\dots\;,\;\frac{1-f}{|m|}\right) \] ($|m| = 2j+1 $: particle multiplicity) % \item {\bf Transverse polarization (along an axis):} \begin{center} \begin{footnotesize} \ttt{beams\_pol\_density = @(j, -j, j:-j:exp(-I*phi)) \qquad beams\_pol\_fraction = $f$} \end{footnotesize} \end{center} This so called transverse polarization is a polarization along an arbitrary direction in the $x-y$ plane, with $\phi=0$ being the positive $x$ direction and $\phi=90^\circ$ the positive $y$ direction. Note that the value of \ttt{phi} has either to be set inside the beam polarization expression explicitly or by a statement \ttt{real phi = {\em val} degree} before. A fraction $f$ of the particles are polarized, the remainder is unpolarized. Note that, although this yields a valid density matrix for all particles with multiplicity $>1$ (in which the only the highest and lowest helicity states are populated), it is meaningful only for spin $\frac{1}{2}$ particles and massless bosons of spin $>0$. The range of the parameters are: $f \in \left[0\;;\;1\right]$ and $\phi \in \mathbb{R}$. This yields a density matrix: \[ \rho = \cssparse{1}{1} {\frac{f}{2}\,e^{-i\phi}} {\frac{f}{2}\,e^{i\phi}} \] (for antiparticles, the matrix is conjugated). % \item {\bf Polarization along arbitrary axis $\left(\theta, \phi\right)$:} \begin{center} \begin{footnotesize} \ttt{beams\_pol\_density = @(j:j:1-cos(theta), j:-j:sin(theta)*exp(-I*phi), -j:-j:1+cos(theta))} \qquad\quad\qquad \ttt{beams\_pol\_fraction = $f$} \end{footnotesize} \end{center} This example describes polarization along an arbitrary axis in polar coordinates (polar axis in positive $z$ direction, polar angle $\theta$, azimuthal angle $\phi$). A fraction $f$ of the particles are polarized, the remainder is unpolarized. Note that, although axis polarization defines a valid density matrix for all particles with multiplicity $>1$, it is meaningful only for particles with spin $\frac{1}{2}$. Valid ranges for the parameters are $f \in \left[0\;;\;1\right]$, $\theta \in \mathbb{R}$, $\phi \in \mathbb{R}$. The density matrix then has the form: \[ \rho = \frac{1}{2}\cdot \cssparse{1 - f\cos\theta}{1 + f\cos\theta} {f\sin\theta\, e^{-i\phi}}{f\sin\theta\, e^{i\phi}} \] % \item {\bf Diagonal density matrix:} \begin{center} \begin{footnotesize} \ttt{beams\_pol\_density = @(j:j:$h_j$, j-1:j-1:$h_{j-1}$, $\ldots$, -j:-j:$h_{-j}$)} \end{footnotesize} \end{center} This defines an arbitrary diagonal density matrix with entries $\rho_{j,j}\,,\,\dots\,,\,\rho_{-j,-j}$. % \item {\bf Arbitrary density matrix:} \begin{center} \begin{footnotesize} \ttt{beams\_pol\_density = @($\{m:m':x_{m,m'}\}$)}: \end{footnotesize} \end{center} Here, \ttt{$\{m:m':x_{m,m'}\}$} denotes a selection of entries at various positions somewhere in the spin density matrix. \whizard\ will check whether this is a valid spin density matrix, but it does e.g. not have to correspond to a pure state. % \end{itemize} } % The beam polarization statements can be used both globally directly with the \ttt{beams} specification, or locally inside the \ttt{integrate} or \ttt{simulate} command. Some more specific examples are in order to show how initial state polarization works: % \begin{itemize} \item \begin{quote} \begin{footnotesize} \begin{verbatim} beams = A, A beams_pol_density = @(+1), @(1, -1, 1:-1:-I) \end{verbatim} \end{footnotesize} \end{quote} This declares the initial state to be composed of two incoming photons, where the first photon is right-handed, and the second photon has transverse polarization in $y$ direction. % \item \begin{quote} \begin{footnotesize} \begin{verbatim} beams = A, A beams_pol_density = @(+1), @(1, -1, 1:-1:-1) \end{verbatim} \end{footnotesize} \end{quote} Same as before, but this time the second photon has transverse polarization in $x$ direction. % \item \begin{quote} \begin{footnotesize} \begin{verbatim} beams = "W+" beams_pol\_density = @(0) \end{verbatim} \end{footnotesize} \end{quote} This example sets up the decay of a longitudinal vector boson. % \item \begin{quote} \begin{footnotesize} \begin{verbatim} beams = E1, e1 scan int hel_ep = (-1, 1) { scan int hel_em = (-1, 1) { beams_pol_density = @(hel_ep), @(hel_em) integrate (eeww) } } integrate (eeww) \end{verbatim} \end{footnotesize} \end{quote} This example loops over the different positron and electron helicity combinations and calculates the respective integrals. The \ttt{beams\_pol\_density} statement is local to the scan loop(s) and, therefore, the last \ttt{integrate} calculates the unpolarized integral. \end{itemize} % Although beam polarization should be straightforward to use, some pitfalls exist for the unwary: \begin{itemize} \item Once \ttt{beams\_pol\_density} is set globally, it persists and is applied every time \ttt{beams} is executed (unless it is reset). In particular, this means that code like \begin{quote} \begin{footnotesize} \begin{verbatim} process wwaa = Wp, Wm => A, A process zee = Z => e1, E1 sqrts = 200 GeV beams_pol_density = @(1, -1, 1:-1:-1), @() beams = Wp, Wm integrate (wwaa) beams = Z integrate (zee) beams_pol_density = @(0) \end{verbatim} \end{footnotesize} \end{quote} will throw an error, because \whizard\ complains that the spin density matrix has the wrong dimensionality for the second (the decay) process. This kind of trap can be avoided be using \ttt{beams\_pol\_density} only locally in \ttt{integrate} or \ttt{simulate} statements. % \item On-the-fly integrations executed by \ttt{simulate} use the beam setup found at the point of execution. This implies that any polarization settings you have previously done affect the result of the integration. % \item The \ttt{unstable} command also requires integrals of the selected decay processes, and will compute them on-the-fly if they are unavailable. Here, a polarized integral is not meaningful at all. Therefore, this command ignores the current \ttt{beam} setting and issues a warning if a previous polarized integral is available; this will be discarded. \end{itemize} \subsection{Final state polarization} Final state polarization is available in \whizard\ in the sense that the polarization of real final state particles can be retained when generating simulated events. In order for the polarization of a particle to be retained, it must be declared as polarized via the \ttt{polarized} statement \begin{quote} \begin{footnotesize} \begin{verbatim} polarized particle [, particle, ...] \end{verbatim} \end{footnotesize} \end{quote} The effect of \ttt{polarized} can be reversed with the \ttt{unpolarized} statement which has the same syntax. For example, \begin{quote} \begin{footnotesize} \begin{verbatim} polarized "W+", "W-", Z \end{verbatim} \end{footnotesize} \end{quote} will cause the polarization of all final state $W$ and $Z$ bosons to be retained, while \begin{quote} \begin{footnotesize} \begin{verbatim} unpolarized "W+", "W-", Z \end{verbatim} \end{footnotesize} \end{quote} will reverse the effect and cause the polarization to be summed over again. Note that \ttt{polarized} and \ttt{unpolarized} are global statements which cannot be used locally as command arguments and if you use them e.g. in a loop, the effects will persist beyond the loop body. Also, a particle cannot be \ttt{polarized} and \ttt{unstable} at the same time (this restriction might be loosened in future versions of \whizard). After toggling the polarization flag, the generation of polarized events can be requested by using the \ttt{?polarized\_events} option of the \ttt{simulate} command, e.g. \begin{quote} \begin{footnotesize} \begin{verbatim} simulate (eeww) { ?polarized_events = true } \end{verbatim} \end{footnotesize} \end{quote} When \ttt{simulate} is run in this mode, helicity information for final state particles that have been toggled as \ttt{polarized} is written to the event file(s) (provided that polarization is supported by the selected event file format(s) ) and can also be accessed in the analysis by means of the \ttt{Hel} observable. For example, an analysis definition like \begin{quote} \begin{footnotesize} \begin{verbatim} analysis = if (all Hel == -1 ["W+"] and all Hel == -1 ["W-"] ) then record cta_nn (eval cos (Theta) ["W+"]) endif; if (all Hel == -1 ["W+"] and all Hel == 0 ["W-"] ) then record cta_nl (eval cos (Theta) ["W+"]) endif \end{verbatim} \end{footnotesize} \end{quote} can be used to histogram the angular distribution for the production of polarized $W$ pairs (obviously, the example would have to be extended to cover all possible helicity combinations). Note, however, that helicity information is not available in the integration step; therefore, it is not possible to use \ttt{Hel} as a cut observable. While final state polarization is straightforward to use, there is a caveat when used in combination with flavor products. If a particle in a flavor product is defined as \ttt{polarized}, then all particles ``originating'' from the product will act as if they had been declared as \ttt{polarized} --- their polarization will be recorded in the generated events. E.g., the example \begin{quote} \begin{footnotesize} \begin{verbatim} process test = u:d, ubar:dbar => d:u, dbar:ubar, u, ubar ! insert compilation, cuts and integration here polarized d, dbar simulate (test) {?polarized_events = true} \end{verbatim} \end{footnotesize} \end{quote} will generate events including helicity information for all final state $d$ and $\overline{d}$ quarks, but only for part of the final state $u$ and $\overline{u}$ quarks. In this case, if you had wanted to keep the helicity information also for all $u$ and $\overline{u}$, you would have had to explicitely include them into the \ttt{polarized} statement. \section{Cross sections} Integrating matrix elements over phase space is the core of \whizard's activities. For any process where we want the cross section, distributions, or event samples, the cross section has to be determined first. This is done by a doubly adaptive multi-channel Monte-Carlo integration. The integration, in turn, requires a \emph{phase-space setup}, i.e., a collection of phase-space \emph{channels}, which are mappings of the unit hypercube onto the complete space of multi-particle kinematics. This phase-space information is encoded in the file \emph{xxx}\ttt{.phs}, where \emph{xxx} is the process tag. \whizard\ generates the phase-space file on the fly and can reuse it in later integrations. For each phase-space channel, the unit hypercube is binned in each dimension. The bin boundaries are allowed to move during a sequence of iterations, each with a fixed number of sampled phase-space points, so they adapt to the actual phase-space density as far as possible. In addition to this \emph{intrinsic} adaptation, the relative channel weights are also allowed to vary. All these steps are done automatically when the \ttt{integrate} command is executed. At the end of the iterative adaptation procedure, the program has obtained an estimate for the integral of the matrix element over phase space, together with an error estimate, and a set of integration \emph{grids} which contains all information on channel weights and bin boundaries. This information is stored in a file \emph{xxx}\ttt{.vg}, where \emph{xxx} is the process tag, and is used for event generation by the \ttt{simulate} command. \subsection{Integration} \label{sec:integrate} Since everything can be handled automatically using default parameters, it often suffices to write the command \begin{quote} \begin{footnotesize} \begin{verbatim} integrate (proc1) \end{verbatim} \end{footnotesize} \end{quote} for integrating the process with name tag \ttt{proc1}, and similarly \begin{quote} \begin{footnotesize} \begin{verbatim} integrate (proc1, proc2, proc3) \end{verbatim} \end{footnotesize} \end{quote} for integrating several processes consecutively. Options to the integrate command are specified, if not globally, by a local option string \begin{quote} \begin{footnotesize} \begin{verbatim} integrate (proc1, proc2, proc3) { mH = 200 GeV } \end{verbatim} \end{footnotesize} \end{quote} (It is possible to place a \ttt{beams} statement inside the option string, if desired.) If the process is configured but not compiled, compilation will be done automatically. If it is not available at all, integration will fail. The integration method can be specified by the string variable \begin{quote} \begin{footnotesize} \ttt{\$integration\_method = "{\em }"} \end{footnotesize} \end{quote} %$ The default method is called \ttt{"vamp"} and uses the \vamp\ algorithm and code. (At the moment, there is only a single simplistic alternative, using the midpoint rule or rectangle method for integration, \ttt{"midpoint"}. This is mainly for testing purposes. In future versions of \whizard, more methods like e.g. Gauss integration will be made available). \vamp, however, is clearly the main integration method. It is done in several \emph{passes} (usually two), and each pass consists of several \emph{iterations}. An iteration consists of a definite number of \emph{calls} to the matrix-element function. For each iteration, \whizard\ computes an estimate of the integral and an estimate of the error, based on the binned sums of matrix element values and squares. It also computes an estimate of the rejection efficiency for generating unweighted events, i.e., the ratio of the average sampling function value over the maximum value of this function. After each iteration, both the integration grids (the binnings) and the relative weights of the integration channels can be adapted to minimize the variance estimate of the integral. After each pass of several iterations, \whizard\ computes an average of the iterations within the pass, the corresponding error estimate, and a $\chi^2$ value. The integral, error, efficiency and $\chi^2$ value computed for the most recent integration pass, together with the most recent integration grid, are used for any subsequent calculation that involves this process, in particular for event generation. In the default setup, during the first pass(es) both grid binnings and channel weights are adapted. In the final (usually second) pass, only binnings are further adapted. Roughly speaking, the final pass is the actual calculation, while the previous pass(es) are used for ``warming up'' the integration grids, without using the numerical results. Below, in the section about the specification of the iterations, Sec.~\ref{sec:iterations}, we will explain how it is possible to change the behavior of adapting grids and weights. Here is an example of the integration output, which illustrates these properties. The \sindarin\ script describes the process $e^+e^-\to q\bar q q\bar q$ with $q$ being any light quark, i.e., $W^+W^-$ and $ZZ$ production and hadronic decay together will any irreducible background. We cut on $p_T$ and energy of jets, and on the invariant mass of jet pairs. Here is the script: \begin{quote} \begin{footnotesize} \begin{verbatim} alias q = d:u:s:c alias Q = D:U:S:C process proc_4f = e1, E1 => q, Q, q, Q ms = 0 mc = 0 sqrts = 500 GeV cuts = all (Pt > 10 GeV and E > 10 GeV) [q:Q] and all M > 10 GeV [q:Q, q:Q] integrate (proc_4f) \end{verbatim} \end{footnotesize} \end{quote} After the run is finished, the integration output looks like \begin{quote} \begin{footnotesize} \begin{verbatim} | Process library 'default_lib': loading | Process library 'default_lib': ... success. | Integrate: compilation done | RNG: Initializing TAO random-number generator | RNG: Setting seed for random-number generator to 12511 | Initializing integration for process proc_4f: | ------------------------------------------------------------------------ | Process [scattering]: 'proc_4f' | Library name = 'default_lib' | Process index = 1 | Process components: | 1: 'proc_4f_i1': e-, e+ => d:u:s:c, dbar:ubar:sbar:cbar, | d:u:s:c, dbar:ubar:sbar:cbar [omega] | ------------------------------------------------------------------------ | Beam structure: [any particles] | Beam data (collision): | e- (mass = 5.1099700E-04 GeV) | e+ (mass = 5.1099700E-04 GeV) | sqrts = 5.000000000000E+02 GeV | Phase space: generating configuration ... | Phase space: ... success. | Phase space: writing configuration file 'proc_4f_i1.phs' | Phase space: 123 channels, 8 dimensions | Phase space: found 123 channels, collected in 15 groves. | Phase space: Using 195 equivalences between channels. | Phase space: wood | Applying user-defined cuts. | OpenMP: Using 8 threads | Starting integration for process 'proc_4f' | Integrate: iterations not specified, using default | Integrate: iterations = 10:10000:"gw", 5:20000:"" | Integrator: 15 chains, 123 channels, 8 dimensions | Integrator: Using VAMP channel equivalences | Integrator: 10000 initial calls, 20 bins, stratified = T | Integrator: VAMP |=============================================================================| | It Calls Integral[fb] Error[fb] Err[%] Acc Eff[%] Chi2 N[It] | |=============================================================================| 1 9963 2.3797857E+03 3.37E+02 14.15 14.13* 4.02 2 9887 2.8307603E+03 9.58E+01 3.39 3.37* 4.31 3 9815 3.0132091E+03 5.10E+01 1.69 1.68* 8.37 4 9754 2.9314937E+03 3.64E+01 1.24 1.23* 10.65 5 9704 2.9088284E+03 3.40E+01 1.17 1.15* 12.99 6 9639 2.9725788E+03 3.53E+01 1.19 1.17 15.34 7 9583 2.9812484E+03 3.10E+01 1.04 1.02* 17.97 8 9521 2.9295139E+03 2.88E+01 0.98 0.96* 22.27 9 9435 2.9749262E+03 2.94E+01 0.99 0.96 20.25 10 9376 2.9563369E+03 3.01E+01 1.02 0.99 21.10 |-----------------------------------------------------------------------------| 10 96677 2.9525019E+03 1.16E+01 0.39 1.22 21.10 1.15 10 |-----------------------------------------------------------------------------| 11 19945 2.9599072E+03 2.13E+01 0.72 1.02 15.03 12 19945 2.9367733E+03 1.99E+01 0.68 0.96* 12.68 13 19945 2.9487747E+03 2.03E+01 0.69 0.97 11.63 14 19945 2.9777794E+03 2.03E+01 0.68 0.96* 11.19 15 19945 2.9246612E+03 1.95E+01 0.67 0.94* 10.34 |-----------------------------------------------------------------------------| 15 99725 2.9488622E+03 9.04E+00 0.31 0.97 10.34 1.05 5 |=============================================================================| | Time estimate for generating 10000 events: 0d:00h:00m:51s | Creating integration history display proc_4f-history.ps and proc_4f-history.pdf \end{verbatim} \end{footnotesize} \end{quote} Each row shows the index of a single iteration, the number of matrix element calls for that iteration, and the integral and error estimate. Note that the number of calls displayed are the real calls to the matrix elements after all cuts and possible rejections. The error should be viewed as the $1\sigma$ uncertainty, computed on a statistical \begin{figure} \centering \includegraphics[width=.56\textwidth]{proc_4f-history} \caption{\label{fig:inthistory} Graphical output of the convergence of the adaptation during the integration of a \whizard\ process.} \end{figure} basis. The next two columns display the error in percent, and the \emph{accuracy} which is the same error normalized by $\sqrt{n_{\rm calls}}$. The accuracy value has the property that it is independent of $n_{\rm calls}$, it describes the quality of adaptation of the current grids. Good-quality grids have a number of order one, the smaller the better. The next column is the estimate for the rejection efficiency in percent. Here, the value should be as high as possible, with $100\,\%$ being the possible maximum. In the example, the grids are adapted over ten iterations, after which the accuracy and efficiency have saturated at about $1.0$ and $10\,\%$, respectively. The asterisk in the accuracy column marks those iterations where an improvement over the previous iteration is seen. The average over these iterations exhibits an accuracy of $1.22$, corresponding to $0.39\,\%$ error, and a $\chi^2$ value of $1.15$, which is just right: apparently, the phase-space for this process and set of cuts is well-behaved. The subsequent five iterations are used for obtaining the final integral, which has an accuracy below one (error $0.3\,\%$), while the efficiency settles at about $10\,\%$. In this example, the final $\chi^2$ value happens to be quite small, i.e., the individual results are closer together than the error estimates would suggest. One should nevertheless not scale down the error, but rather scale it up if the $\chi^2$ result happens to be much larger than unity: this often indicates sub-optimally adapted grids, which insufficiently map some corner of phase space. One should note that all values are subject to statistical fluctuations, since the number of calls within each iterations is finite. Typically, fluctuations in the efficiency estimate are considerably larger than fluctuations in the error/accuracy estimate. Two subsequent runs of the same script should yield statistically independent results which may differ in all quantities, within the error estimates, since the seed of the random-number generator will differ by default. It is possible to get exactly reproducible results by setting the random-number seed explicitly, e.g., \begin{quote} \begin{footnotesize} \begin{verbatim} seed = 12345 \end{verbatim} \end{footnotesize} \end{quote} at any point in the \sindarin\ script. \ttt{seed} is a predefined intrinsic variable. The value can be any 32bit integer. Two runs with different seeds can be safely taken as statistically independent. In the example above, no seed has been set, and the seed has therefore been determined internally by \whizard\ from the system clock. The concluding line with the time estimate applies to a subsequent simulation step with unweighted events, which is not actually requested in the current example. It is based on the timing and efficiency estimate of the most recent iteration. As a default, a graphical output of the integration history will be produced (if both \LaTeX\ and \metapost\ have been available during configuration). Fig.~\ref{fig:inthistory} shows how this looks like, and demonstrates how a proper convergence of the integral during the adaptation looks like. The generation of these graphical history files can be switched off using the command \ttt{?vis\_history = false}. %%%%% \subsection{Integration run IDs} A single \sindarin\ script may contain multiple calls to the \ttt{integrate} command with different parameters. By default, files generated for the same process in a subsequent integration will overwrite the previous ones. This is undesirable when the script is re-run: all results that have been overwritten have to be recreated. To avoid this, the user may identify a specific run by a string-valued ID, e.g. \begin{quote} \begin{footnotesize} \begin{verbatim} integrate (foo) { $run_id = "first" } \end{verbatim} \end{footnotesize} \end{quote} This ID will become part of the file name for all files that are created specifically for this run. Often it is useful to create a run ID from a numerical value using \ttt{sprintf}, e.g., in this scan: \begin{quote} \begin{footnotesize} \begin{verbatim} scan real mh = (100 => 200 /+ 10) { $run_id = sprintf "%e" (mh) integrate (h_production) } \end{verbatim} \end{footnotesize} \end{quote} With unique run IDs, a subsequent run of the same \sindarin\ script will be able to reuse all previous results, even if there is more than a single integration per process. \subsection{Controlling iterations} \label{sec:iterations} \whizard\ has some predefined numbers of iterations and calls for the first and second integration pass, respectively, which depend on the number of initial and final-state particles. They are guesses for values that yield good-quality grids and error values in standard situations, where no exceptionally strong peaks or loose cuts are present in the integrand. Actually, the large number of warmup iterations in the previous example indicates some safety margin in that respect. It is possible, and often advisable, to adjust the iteration and call numbers to the particular situation. One may reduce the default numbers to short-cut the integration, if either less accuracy is needed, or CPU time is to be saved. Otherwise, if convergence is bad, the number of iterations or calls might be increased. To set iterations manually, there is the \ttt{iterations} command: \begin{quote} \begin{footnotesize} \begin{verbatim} iterations = 5:50000, 3:100000 \end{verbatim} \end{footnotesize} \end{quote} This is a comma-separated list. Each pair of values corresponds to an integration pass. The value before the colon is the number of iterations for this pass, the other number is the number of calls per iteration. While the default number of passes is two (one for warmup, one for the final result), you may specify a single pass \begin{quote} \begin{footnotesize} \begin{verbatim} iterations = 5:100000 \end{verbatim} \end{footnotesize} \end{quote} where the relative channel weights will \emph{not} be adjusted (because this is the final pass). This is appropriate for well-behaved integrands where weight adaptation is not necessary. You can also define more than two passes. That might be useful when reusing a previous grid file with insufficient quality: specify the previous passes as-is, so the previous results will be read in, and then a new pass for further adaptation. In the final pass, the default behavior is to not adapt grids and weights anymore. Otherwise, different iterations would be correlated, and a final reliable error estimate would not be possible. For all but the final passes, the user can decide whether to adapt grids and weights by attaching a string specifier to the number of iterations: \ttt{"g"} does adapt grids, but not weights, \ttt{"w"} the other way round. \ttt{"gw"} or \ttt{"wg"} does adapt both. By the setting \ttt{""}, all adaptations are switched off. An example looks like this: \begin{code} iterations = 2:10000:"gw", 3:5000 \end{code} Since it is often not known beforehand how many iterations the grid adaptation will need, it is generally a good idea to give the first pass a large number of iterations. However, in many cases these turn out to be not necessary. To shortcut iterations, you can set any of \begin{quote} \begin{footnotesize} \begin{verbatim} accuracy_goal error_goal relative_error_goal \end{verbatim} \end{footnotesize} \end{quote} to a positive value. If this is done, \whizard\ will skip warmup iterations once all of the specified goals are reached by the current iteration. The final iterations (without weight adaptation) are always performed. \subsection{Phase space} Before \ttt{integrate} can start its work, it must have a phase-space configuration for the process at hand. The method for the phase-space parameterization is determined by the string variable \ttt{\$phs\_method}. At the moment there are only two options, \ttt{"single"}, for testing purposes, that is mainly used internally, and \whizard's traditional method, \ttt{"wood"}. This parameterization is particularly adapted and fine-tuned for electroweak processes and might not be the ideal for for pure jet cross sections. In future versions of \whizard, more options for phase-space parameterizations will be made available, e.g. the \ttt{RAMBO} algorithm and its massive cousin, and phase-space parameterizations that take care of the dipole-like emission structure in collinear QCD (or QED) splittings. For the standard method, the phase-space parameterization is laid out in an ASCII file \ttt{\textit{\_}i\textit{}.phs}. Here, \ttt{{\em }} is the process name chosen by the user while \ttt{{\em }} is the number of the process component of the corresponding process. This immediately shows that different components of processes are getting different phase space setups. This is necessary for inclusive processes, e.g. the sum of $pp \to Z + nj$ and $pp \to W + nj$, or in future versions of \whizard\ for NLO processes, where one component is the interference between the virtual and the Born matrix element, and another one is the subtraction terms. Normally, you do not have to deal with this file, since \whizard\ will generate one automatically if it does not find one. (\whizard\ is careful to check for consistency of process definition and parameters before using an existing file.) Experts might find it useful to generate a phase-space file and inspect and/or modify it before proceeding further. To this end, there is the parameter \verb|?phs_only|. If you set this \ttt{true}, \whizard\ skips the actual integration after the phase-space file has been generated. There is also a parameter \verb|?vis_channels| which can be set independently; if this is \ttt{true}, \whizard\ will generate a graphical visualization of the phase-space parameterizations encoded in the phase-space file. This file has to be taken with a grain of salt because phase space channels are represented by sample Feynman diagrams for the corresponding channel. This does however {\em not} mean that in the matrix element other Feynman diagrams are missing (the default matrix element method, \oMega, is not using Feynman-diagrammatic amplitudes at all). Things might go wrong with the default phase-space generation, or manual intervention might be necessary to improve later performance. There are a few parameters that control the algorithm of phase-space generation. To understand their meaning, you should realize that phase-space parameterizations are modeled after (dominant) Feynman graphs for the current process. \subsubsection{The main phase space setup {\em wood}} For the main phase-space parameterization of \whizard, which is called \ttt{"wood"}, there are many different parameters and flags that allow to tune and customize the phase-space setup for every certain process: The parameter \verb|phs_off_shell| controls the number of off-shell lines in those graphs, not counting $s$-channel resonances and logarithmically enhanced $s$- and $t$-channel lines. The default value is $2$. Setting it to zero will drop everything that is not resonant or logarithmically enhanced. Increasing it will include more subdominant graphs. (\whizard\ increases the value automatically if the default value does not work.) There is a similar parameter \verb|phs_t_channel| which controls multiperipheral graphs in the parameterizations. The default value is $6$, so graphs with up to $6$ $t/u$-channel lines are considered. In particular cases, such as $e^+e^-\to n\gamma$, all graphs are multiperipheral, and for $n>7$ \whizard\ would find no parameterizations in the default setup. Increasing the value of \verb|phs_t_channel| solves this problem. (This is presently not done automatically.) There are two numerical parameters that describe whether particles are treated like massless particles in particular situations. The value of \verb|phs_threshold_s| has the default value $50\;\GeV$. Hence, $W$ and $Z$ are considered massive, while $b$ quarks are considered massless. This categorization is used for deciding whether radiation of $b$ quarks can lead to (nearly) singular behavior, i.e., logarithmic enhancement, in the infrared and collinear regions. If yes, logarithmic mappings are applied to phase space. Analogously, \verb|phs_threshold_t| decides about potential $t$-channel singularities. Here, the default value is $100\;\GeV$, so amplitudes with $W$ and $Z$ in the $t$-channel are considered as logarithmically enhanced. For a high-energy hadron collider of 40 or 100 TeV energy, also $W$ and $Z$ in $s$-channel like situations might be necessary to be considered massless. Such logarithmic mappings need a dimensionful scale as parameter. There are three such scales, all with default value $10\;\GeV$: \verb|phs_e_scale| (energy), \verb|phs_m_scale| (invariant mass), and \verb|phs_q_scale| (momentum transfer). If cuts and/or masses are such that energies, invariant masses of particle pairs, and momentum transfer values below $10\;\GeV$ are excluded or suppressed, the values can be kept. In special cases they should be changed: for instance, if you want to describe $\gamma^*\to\mu^+\mu^-$ splitting well down to the muon mass, no cuts, you may set \verb|phs_m_scale = mmu|. The convergence of the Monte-Carlo integration result will be considerably faster. There are more flags. These and more details about the phase space parameterization will be described in Sec.~\ref{sec:wood}. \subsection{Cuts} \whizard~2 does not apply default cuts to the integrand. Therefore, processes with massless particles in the initial, intermediate, or final states may not have a finite cross section. This fact will manifest itself in an integration that does not converge, or is unstable, or does not yield a reasonable error or reweighting efficiency even for very large numbers of iterations or calls per iterations. When doing any calculation, you should verify first that the result that you are going to compute is finite on physical grounds. If not, you have to apply cuts that make it finite. A set of cuts is defined by the \ttt{cuts} statement. Here is an example \begin{quote} \begin{footnotesize} \begin{verbatim} cuts = all Pt > 20 GeV [colored] \end{verbatim} \end{footnotesize} \end{quote} This implies that events are kept only (for integration and simulation) if the transverse momenta of all colored particles are above $20\;\GeV$. Technically, \ttt{cuts} is a special object, which is unique within a given scope, and is defined by the logical expression on the right-hand side of the assignment. It may be defined in global scope, so it is applied to all subsequent processes. It may be redefined by another \ttt{cuts} statement. This overrides the first cuts setting: the \ttt{cuts} statement is not cumulative. Multiple cuts should be specified by the logical operators of \sindarin, for instance \begin{quote} \begin{footnotesize} \begin{verbatim} cuts = all Pt > 20 GeV [colored] and all E > 5 GeV [photon] \end{verbatim} \end{footnotesize} \end{quote} Cuts may also be defined local to an \ttt{integrate} command, i.e., in the options in braces. They will apply only to the processes being integrated, overriding any global cuts. The right-hand side expression in the \ttt{cuts} statement is evaluated at the point where it is used by an \ttt{integrate} command (which could be an implicit one called by \ttt{simulate}). Hence, if the logical expression contains parameters, such as \begin{quote} \begin{footnotesize} \begin{verbatim} mH = 120 GeV cuts = all M > mH [b, bbar] mH = 150 GeV integrate (myproc) \end{verbatim} \end{footnotesize} \end{quote} the Higgs mass value that is inserted is the value in place when \ttt{integrate} is evaluated, $150\;\GeV$ in this example. This same value will also be used when the process is called by a subsequent \ttt{simulate}; it is \ttt{integrate} which compiles the cut expression and stores it among the process data. This behavior allows for scanning over parameters without redefining the cuts every time. The cut expression can make use of all variables and constructs that are defined at the point where it is evaluated. In particular, it can make use of the particle content and kinematics of the hard process, as in the example above. In addition to the predefined variables and those defined by the user, there are the following variables which depend on the hard process: \begin{quote} \begin{tabular}{ll} integer: & \ttt{n\_in}, \ttt{n\_out}, \ttt{n\_tot} \\ real: & \ttt{sqrts}, \ttt{sqrts\_hat} \end{tabular} \end{quote} Example: \begin{quote} \begin{footnotesize} \begin{verbatim} cuts = sqrts_hat > 150 GeV \end{verbatim} \end{footnotesize} \end{quote} The constants \ttt{n\_in} etc.\ are sometimes useful if a generic set of cuts is defined, which applies to various processes simultaneously. The user is encouraged to define his/her own set of cuts, if possible in a process-independent manner, even if it is not required. The \ttt{include} command allows for storing a set of cuts in a separate \sindarin\ script which may be read in anywhere. As an example, the system directories contain a file \verb|default_cuts.sin| which may be invoked by \begin{quote} \begin{footnotesize} \begin{verbatim} include ("default_cuts.sin") \end{verbatim} \end{footnotesize} \end{quote} \subsection{QCD scale and coupling} \whizard\ treats all physical parameters of a model, the coefficients in the Lagrangian, as constants. As a leading-order program, \whizard\ does not make use of running parameters as they are described by renormalization theory. For electroweak interactions where the perturbative expansion is sufficiently well behaved, this is a consistent approach. As far as QCD is concerned, this approach does not yield numerically reliable results, even on the validity scale of the tree approximation. In \whizard\ttt{2}, it is therefore possible to replace the fixed value of $\alpha_s$ (which is accessible as the intrinsic model variable \verb|alphas|), by a function of an energy scale $\mu$. This is controlled by the parameter \verb|?alphas_is_fixed|, which is \ttt{true} by default. Setting it to \ttt{false} enables running~$\alpha_s$. The user has then to decide how $\alpha_s$ is calculated. One option is to set \verb|?alphas_from_lhapdf| (default \ttt{false}). This is recommended if the \lhapdf\ library is used for including structure functions, but it may also be set if \lhapdf\ is not invoked. \whizard\ will then use the $\alpha_s$ formula and value that matches the active \lhapdf\ structure function set and member. In the very same way, the $\alpha_s$ running from the PDFs implemented intrinsically in \whizard\ can be taken by setting \verb|?alphas_from_pdf_builtin| to \ttt{true}. This is the same running then the one from \lhapdf, if the intrinsic PDF coincides with a PDF chosen from \lhapdf. If this is not appropriate, there are again two possibilities. If \verb|?alphas_from_mz| is \ttt{true}, the user input value \verb|alphas| is interpreted as the running value $\alpha_s(m_Z)$, and for the particular event, the coupling is evolved to the appropriate scale $\mu$. The formula is controlled by the further parameters \verb|alphas_order| (default $0$, meaning leading-log; maximum $2$) and \verb|alphas_nf| (default $5$). Otherwise there is the option to set \verb|?alphas_from_lambda_qcd = true| in order to evaluate $\alpha_s$ from the scale $\Lambda_{\rm QCD}$, represented by the intrinsic variable \verb|lambda_qcd|. The reference value for the QCD scale is $\Lambda\_{\rm QCD} = 200$ MeV. \verb|alphas_order| and \verb|alphas_nf| apply analogously. Note that for using one of the running options for $\alpha_s$, always \ttt{?alphas\_is\_fixed = false} has to be invoked. In any case, if $\alpha_s$ is not fixed, each event has to be assigned an energy scale. By default, this is $\sqrt{\hat s}$, the partonic invariant mass of the event. This can be replaced by a user-defined scale, the special object \ttt{scale}. This is assigned and used just like the \ttt{cuts} object. The right-hand side is a real-valued expression. Here is an example: \begin{quote} \begin{footnotesize} \begin{verbatim} scale = eval Pt [sort by -Pt [colored]] \end{verbatim} \end{footnotesize} \end{quote} This selects the $p_T$ value of the first entry in the list of colored particles sorted by decreasing $p_T$, i.e., the $p_T$ of the hardest jet. The \ttt{scale} definition is used not just for running $\alpha_s$ (if enabled), but it is also the factorization scale for the \lhapdf\ structure functions. These two values can be set differently by specifying \ttt{factorization\_scale} for the scale at which the PDFs are evaluated. Analogously, there is a variable \ttt{renormalization\_scale} that sets the scale value for the running $\alpha_s$. Whenever any of these two values is set, it supersedes the \ttt{scale} value. Just like the \ttt{cuts} expression, the expressions for \ttt{scale}, \ttt{factorization\_scale} and also \ttt{renormalization\_scale} are evaluated at the point where it is read by an explicit or implicit \ttt{integrate} command. \subsection{Reweighting factor} It is possible to reweight the integrand by a user-defined function of the event kinematics. This is done by specifying a \ttt{weight} expression. Syntax and usage is exactly analogous to the \ttt{scale} expression. Example: \begin{quote} \begin{footnotesize} \begin{verbatim} weight = eval (1 + cos (Theta) ^ 2) [lepton] \end{verbatim} \end{footnotesize} \end{quote} We should note that the phase-space setup is not aware of this reweighting, so in complicated cases you should not expect adaptation to achieve as accurate results as for plain cross sections. Needless to say, the default \ttt{weight} is unity. \section{Events} After the cross section integral of a scattering process is known (or the partial-width integral of a decay process), \whizard\ can generate event samples. There are two limiting cases or modes of event generation: \begin{enumerate} \item For a physics simulation, one needs \emph{unweighted} events, so the probability of a process and a kinematical configuration in the event sample is given by its squared matrix element. \item Monte-Carlo integration yields \emph{weighted} events, where the probability (without any grid adaptation) is uniformly distributed over phase space, while the weight of the event is given by its squared matrix element. \end{enumerate} The choice of parameterizations and the iterative adaptation of the integration grids gradually shift the generation mode from option 2 to option 1, which obviously is preferred since it simulates the actual outcome of an experiment. Unfortunately, this adaptation is perfect only in trivial cases, such that the Monte-Carlo integration yields non-uniform probability still with weighted events. Unweighted events are obtained by rejection, i.e., accepting an event with a probability equal to its own weight divided by the maximal possible weight. Furthermore, the maximal weight is never precisely known, so this probability can only be estimated. The default generation mode of \whizard\ is unweighted. This is controlled by the parameter \verb|?unweighted| with default value \ttt{true}. Unweighted events are easy to interpret and can be directly compared with experiment, if properly interfaced with detector simulation and analysis. However, when applying rejection to generate unweighted events, the generator discards information, and for a single event it needs, on the average, $1/\epsilon$ calls, where the efficiency $\epsilon$ is the ratio of the average weight over the maximal weight. If \verb|?unweighted| is \ttt{false}, all events are kept and assigned their respective weights in histograms or event files. \subsection{Simulation} \label{sec:simulation} The \ttt{simulate} command generates an event sample. The number of events can be set either by specifying the integer variable \verb|n_events|, or by the real variable \verb|luminosity|. (This holds for unweighted events. If weighted events are requested, the luminosity value is ignored.) The luminosity is measured in femtobarns, but other units can be used, too. Since the cross sections for the processes are known at that point, the number of events is determined as the luminosity multiplied by the cross section. As usual, both parameters can be set either as global or as local parameters: \begin{quote} \begin{footnotesize} \begin{verbatim} n_events = 10000 simulate (proc1) simulate (proc2, proc3) { luminosity = 100 / 1 pbarn } \end{verbatim} \end{footnotesize} \end{quote} In the second example, both \verb|n_events| and \verb|luminosity| are set. In that case, \whizard\ chooses whatever produces the larger number of events. If more than one process is specified in the argument of \ttt{simulate}, events are distributed among the processes with fractions proportional to their cross section values. The processes are mixed randomly, as it would be the case for real data. The raw event sample is written to a file which is named after the first process in the argument of \ttt{simulate}. If the process name is \ttt{proc1}, the file will be named \ttt{proc1.evx}. You can choose another basename by the string variable \verb|$sample|. For instance, \begin{quote} \begin{footnotesize} \begin{verbatim} simulate (proc1) { n_events = 4000 $sample = "my_events" } \end{verbatim} \end{footnotesize} \end{quote} will produce an event file \verb|my_events.evx| which contains $4000$ events. This event file is in a machine-dependent binary format, so it is not of immediate use. Its principal purpose is to serve as a cache: if you re-run the same script, before starting simulation, it will look for an existing event file that matches the input. If nothing has changed, it will find the file previously generated and read in the events, instead of generating them. Thus you can modify the analysis or any further steps without repeating the time-consuming task of generating a large event sample. If you change the number of events to generate, the program will make use of the existing event sample and generate further events only when it is used up. If necessary, you can suppress the writing/reading of the raw event file by the parameters \verb|?write_raw| and \verb|?read_raw|. If you try to reuse an event file that has been written by a previous version of \whizard, you may run into an incompatibility, which will be detected as an error. If this happens, you may enforce a compatibility mode (also for writing) by setting \ttt{\$event\_file\_version} to the appropriate version string, e.g., \verb|"2.0"|. Be aware that this may break some more recent features in the event analysis. Generating an event sample can serve several purposes. First of all, it can be analyzed directly, by \whizard's built-in capabilities, to produce tables, histograms, or calculate inclusive observables. The basic analysis features of \whizard\ are described below in Sec.~\ref{sec:analysis}. It can be written to an external file in a standard format that a human or an external program can understand. In Chap.~\ref{chap:events}, you will find a more thorough discussion of event generation with \whizard, which also covers in detail the available event-file formats. Finally, \whizard\ can rescan an existing event sample. The event sample may either be the result of a previous \ttt{simulate} run or, under certain conditions, an external event sample produced by another generator or reconstructed from data. \begin{quote} \begin{footnotesize} \begin{verbatim} rescan "my_events" (proc1) { $pdf_builtin_set = "MSTW2008LO" } \end{verbatim} \end{footnotesize} \end{quote} The rescanning may apply different parameters and recalculate the matrix element, it may apply a different event selection, it may reweight the events by a different PDF set (as above). The modified event sample can again be analyzed or written to file. For more details, cf.\ Sec.~\ref{sec:rescan}. %%%%%%%%%%%%%%% \subsection{Decays} \label{sec:decays} Normally, the events generated by the \ttt{simulate} command will be identical in structure to the events that the \ttt{integrate} command generates. This implies that for a process such as $pp\to W^+W^-$, the final-state particles are on-shell and stable, so they appear explicitly in the generated event files. If events are desired where the decay products of the $W$ bosons appear, one has to generate another process, e.g., $pp\to u\bar d\bar ud$. In this case, the intermediate vector bosons, if reconstructed, are off-shell as dictated by physics, and the process contains all intermediate states that are possible. In this example, the matrix element contains also $ZZ$, photon, and non-resonant intermediate states. (This can be restricted via the \verb|$restrictions| option, cf.\ \ref{sec:process options}. Another approach is to factorize the process in production (of $W$ bosons) and decays ($W\to q\bar q$). This is actually the traditional approach, since it is much less computing-intensive. The factorization neglects all off-shell effects and irreducible background diagrams that do not have the decaying particles as an intermediate resonance. While \whizard\ is able to deal with multi-particle processes without factorization, the needed computing resources rapidly increase with the number of external particles. Particularly, it is the phase space integration that becomes the true bottleneck for a high multiplicity of final state particles. In order to use the factorized approach, one has to specify particles as \ttt{unstable}. (Also, the \ttt{?allow\_decays} switch must be \ttt{true}; this is however its default value.) We give an example for a $pp \to Wj$ final state: \begin{code} process wj = u, gl => d, Wp process wen = Wp => E1, n1 integrate (wen) sqrts = 7 TeV beams = p, p => pdf_builtin unstable Wp (wen) simulate (wj) { n_events = 1 } \end{code} This defines a $2 \to 2$ hard scattering process of $W + j$ production at the 7 TeV LHC 2011 run. The $W^+$ is marked as unstable, with its decay process being $W^+ \to e^+ \nu_e$. In the \ttt{simulate} command both processes, the production process \ttt{wj} and the decay process \ttt{wen} will be integrated, while the $W$ decays become effective only in the final event sample. This event sample will contain final states with multiplicity $3$, namely $e^+ \nu_e d$. Note that here only one decay process is given, hence the branching ratio for the decay will be taken to be $100 \%$ by \whizard. A natural restriction of the factorized approach is the implied narrow-width approximation. Theoretically, this restriction is necessary since whenever the width plays an important role, the usage of the factorized approach will not be fully justified. In particular, all involved matrix elements must be evaluated on-shell, or otherwise gauge-invariance issues could spoil the calculation. (There are plans for a future \whizard\ version to also include Breit-Wigner or Gaussian distributions when using the factorized approach.) Decays can be concatenated, e.g. for top pair production and decay, $e^+ e^- \to t \bar t$ with decay $t \to W^+ b$, and subsequent leptonic decay of the $W$ as in $W^+ \to \mu^+ \nu_\mu$: \begin{code} process eett = e1, E1 => t, tbar process t_dec = t => Wp, b process W_dec = Wp => E2, n2 unstable t (t_dec) unstable Wp (W_dec) sqrts = 500 simulate (eett) { n_events = 1 } \end{code} Note that in this case the final state in the event file will consist of $\bar t b \mu^+ \nu_\mu$ because the anti-top is not decayed. If more than one decay process is being specified like in \begin{code} process eeww = e1, E1 => Wp, Wm process w_dec1 = Wp => E2, n2 process w_dec2 = Wp => E3, n3 unstable Wp (w_dec1, w_dec2) sqrts = 500 simulate (eeww) { n_events = 100 } \end{code} then \whizard\ takes the integrals of the specified decay processes and distributes the decays statistically according to the calculated branching ratio. Note that this might not be the true branching ratios if decay processes are missing, or loop corrections to partial widths give large(r) deviations. In the calculation of the code above, \whizard\ will issue an output like \begin{code} | Unstable particle W+: computed branching ratios: | w_dec1: 5.0018253E-01 mu+, numu | w_dec2: 4.9981747E-01 tau+, nutau | Total width = 4.5496085E-01 GeV (computed) | = 2.0490000E+00 GeV (preset) | Decay options: helicity treated exactly \end{code} So in this case, \whizard\ uses 50 \% muonic and 50 \% tauonic decays of the positively charged $W$, while the $W^-$ appears directly in the event file. \whizard\ shows the difference between the preset $W$ width from the physics model file and the value computed from the two decay channels. Note that a particle in a \sindarin\ input script can be also explictly marked as being stable, using the \begin{code} stable \end{code} constructor for the particle \ttt{}. \subsubsection{Resetting branching fractions} \label{sec:br-reset} As described above, decay processes that appear in a simulation must first be integrated by the program, either explicitly via the \verb|integrate| command, or implicitly by \verb|unstable|. In either case, \whizard\ will use the computed partial widths in order to determine branching fractions. In the spirit of a purely leading-order calculation, this is consistent. However, it may be desired to rather use different branching-fraction values for the decays of a particle, for instance, NLO-corrected values. In fact, after \whizard\ has integrated any process, the integration result becomes available as an ordinary \sindarin\ variable. For instance, if a decay process has the ID \verb|h_bb|, the integral of this process -- the partial width, in this case -- becomes the variable \verb|integral(h_bb)|. This variable may be reset just like any other variable: \begin{code} integral(h_bb) = 2.40e-3 GeV \end{code} The new value will be used for all subsequent Higgs branching-ratio calculations and decays, if an unstable Higgs appears in a process for simulation. \subsubsection{Spin correlations in decays} \label{sec:spin-correlations} By default, \whizard\ applies full spin and color correlations to the factorized processes, so it keeps both color and spin coherence between productions and decays. Correlations between decay products of distinct unstable particles in the same event are also fully retained. The program sums over all intermediate quantum numbers. Although this approach obviously yields the optimal description with the limits of production-decay factorization, there is support for a simplified handling of particle decays. Essentially, there are four options, taking a decay \ttt{W\_ud}: $W^-\to \bar u d$ as an example: \begin{enumerate} \item Full spin correlations: \verb|unstable Wp (W_ud)| \item Isotropic decay: \verb|unstable Wp (W_ud) { ?isotropic_decay = true }| \item Diagonal decay matrix: \verb|unstable Wp (W_ud) { ?diagonal_decay = true }| \item Project onto specific helicity: \verb|unstable Wp (W_ud) { decay_helicity = -1 }| \end{enumerate} Here, the isotropic option completely eliminates spin correlations. The diagonal-decays option eliminates just the off-diagonal entries of the $W$ spin-density matrix. This is equivalent to a measurement of spin before the decay. As a result, spin correlations are still present in the classical sense, while quantum coherence is lost. The definite-helicity option is similar and additional selects only the specified helicity component for the decaying particle, so its decay distribution assumes the shape for an accordingly polarized particle. All options apply in the rest frame of the decaying particle, with the particle's momentum as the quantization axis. \subsubsection{Automatic decays} A convenient option is if the user did not have to specify the decay mode by hand, but if they were generated automatically. \whizard\ does have this option: the flag \ttt{?auto\_decays} can be set to \ttt{true}, and is taking care of that. In that case the list for the decay processes of the particle marked as unstable is left empty (we take a $W^-$ again as example): \begin{code} unstable Wm () { ?auto_decays = true } \end{code} \whizard\ then inspects at the local position within the \sindarin\ input file where that \ttt{unstable} statement appears the masses of all the particles of the active physics model in order to determine which decays are possible. It then calculates their partial widths. There are a few options to customize the decays. The integer variable \ttt{auto\_decays\_multiplicity} allows to set the maximal multiplicity of the final states considered in the auto decay option. The defaul value of that variable is \ttt{2}; please be quite careful when setting this to values larger than that. If you do so, the flag \ttt{?auto\_decays\_radiative} allows to specify whether final states simply containing additional resolved gluons or photons are taken into account or not. For the example above, you almost hit the PDG value for the $W$ total width: \begin{code} | Unstable particle W-: computed branching ratios: | decay_a24_1: 3.3337068E-01 d, ubar | decay_a24_2: 3.3325864E-01 s, cbar | decay_a24_3: 1.1112356E-01 e-, nuebar | decay_a24_4: 1.1112356E-01 mu-, numubar | decay_a24_5: 1.1112356E-01 tau-, nutaubar | Total width = 2.0478471E+00 GeV (computed) | = 2.0490000E+00 GeV (preset) | Decay options: helicity treated exactly \end{code} \subsubsection{Future shorter notation for decays} {\color{red} In an upcoming \whizard\ version there will be a shorter and more concise notation already in the process definition for such decays, which, however, is current not yet implemented. The two first examples above will then be shorter and have this form:} \begin{code} process wj = u, gl => (Wp => E1, n1), d \end{code} {\color{red} as well as } \begin{code} process eett = e1, E1 => (t => (Wp => E2, n2), b), tbar \end{code} %%%%% \subsection{Event formats} As mentioned above, the internal \whizard\ event format is a machine-dependent event format. There are a series of human-readable ASCII event formats that are supported: very verbose formats intended for debugging, formats that have been agreed upon during the Les Houches workshops like LHA and LHEF, or formats that are steered through external packages like HepMC. More details about event formats can be found in Sec.~\ref{sec:eventformats}. %%%%%%%%%%%%%%% \section{Analysis and Visualization} \label{sec:analysis} \sindarin\ natively supports basic methods of data analysis and visualization which are frequently used in high-energy physics studies. Data generated during script execution, in particular simulated event samples, can be analyzed to evaluate further observables, fill histograms, and draw two-dimensional plots. So the user does not have to rely on his/her own external graphical analysis method (like e.g. \ttt{gnuplot} or \ttt{ROOT} etc.), but can use methods that automatically ship with \whizard. In many cases, the user, however, clearly will use his/her own analysis machinery, especially experimental collaborations. In the following sections, we first summarize the available data structures, before we consider their graphical display. \subsection{Observables} Analyses in high-energy physics often involve averages of quantities other than a total cross section. \sindarin\ supports this by its \ttt{observable} objects. An \ttt{observable} is a container that collects a single real-valued variable with a statistical distribution. It is declared by a command of the form \begin{quote} \begin{footnotesize} \ttt{observable \emph{analysis-tag}} \end{footnotesize} \end{quote} where \ttt{\emph{analysis-tag}} is an identifier that follows the same rules as a variable name. Once the observable has been declared, it can be filled with values. This is done via the \ttt{record} command: \begin{quote} \begin{footnotesize} \ttt{record \emph{analysis-tag} (\emph{value})} \end{footnotesize} \end{quote} To make use of this, after values have been filled, we want to perform the actual analysis and display the results. For an observable, these are the mean value and the standard deviation. There is the command \ttt{write\_analysis}: \begin{quote} \begin{footnotesize} \ttt{write\_analysis (\emph{analysis-tag})} \end{footnotesize} \end{quote} Here is an example: \begin{quote} \begin{footnotesize} \begin{verbatim} observable obs record obs (1.2) record obs (1.3) record obs (2.1) record obs (1.4) write_analysis (obs) \end{verbatim} \end{footnotesize} \end{quote} The result is displayed on screen: \begin{quote} \begin{footnotesize} \begin{verbatim} ############################################################################### # Observable: obs average = 1.500000000000E+00 error[abs] = 2.041241452319E-01 error[rel] = 1.360827634880E-01 n_entries = 4 \end{verbatim} \end{footnotesize} \end{quote} \subsection{The analysis expression} \label{subsec:analysis} The most common application is the computation of event observables -- for instance, a forward-backward asymmetry -- during simulation. To this end, there is an \ttt{analysis} expression, which behaves very similar to the \ttt{cuts} expression. It is defined either globally \begin{quote} \begin{footnotesize} \ttt{analysis = \emph{logical-expr}} \end{footnotesize} \end{quote} or as a local option to the \ttt{simulate} or \ttt{rescan} commands which generate and handle event samples. If this expression is defined, it is not evaluated immediately, but it is evaluated once for each event in the sample. In contrast to the \ttt{cuts} expression, the logical value of the \ttt{analysis} expression is discarded; the expression form has been chosen just by analogy. To make this useful, there is a variant of the \ttt{record} command, namely a \ttt{record} function with exactly the same syntax. As an example, here is a calculation of the forward-backward symmetry in a process \ttt{ee\_mumu} with final state $\mu^+\mu^-$: \begin{quote} \begin{footnotesize} \begin{verbatim} observable a_fb analysis = record a_fb (eval sgn (Pz) ["mu-"]) simulate (ee_mumu) { luminosity = 1 / 1 fbarn } \end{verbatim} \end{footnotesize} \end{quote} The logical return value of \ttt{record} -- which is discarded here -- is \ttt{true} if the recording was successful. In case of histograms (see below) it is true if the value falls within bounds, false otherwise. Note that the function version of \ttt{record} can be used anywhere in expressions, not just in the \ttt{analysis} expression. When \ttt{record} is called for an observable or histogram in simulation mode, the recorded value is weighted appropriately. If \ttt{?unweighted} is true, the weight is unity, otherwise it is the event weight. The \ttt{analysis} expression can involve any other construct that can be expressed as an expression in \sindarin. For instance, this records the energy of the 4th hardest jet in a histogram \ttt{pt\_dist}, if it is in the central region: \begin{quote} \begin{footnotesize} \begin{verbatim} analysis = record pt_dist (eval E [extract index 4 [sort by - Pt [select if -2.5 < Eta < 2.5 [colored]]]]) \end{verbatim} \end{footnotesize} \end{quote} Here, if there is no 4th jet in the event which satisfies the criterion, the result will be an undefined value which is not recorded. In that case, \ttt{record} evaluates to \ttt{false}. Selection cuts can be part of the analysis expression: \begin{code} analysis = if any Pt > 50 GeV [lepton] then record jet_energy (eval E [collect [jet]]) endif \end{code} Alternatively, we can specify a separate selection expression: \begin{code} selection = any Pt > 50 GeV [lepton] analysis = record jet_energy (eval E [collect [jet]]) \end{code} The former version writes all events to file (if requested), but applies the analysis expression only to the selected events. This allows for the simultaneous application of different selections to a single event sample. The latter version applies the selection to all events before they are analyzed or written to file. The analysis expression can make use of all variables and constructs that are defined at the point where it is evaluated. In particular, it can make use of the particle content and kinematics of the hard process, as in the example above. In addition to the predefined variables and those defined by the user, there are the following variables which depend on the hard process. Some of them are constants, some vary event by event: \begin{quote} \begin{tabular}{ll} integer: &\ttt{event\_index} \\ integer: &\ttt{process\_num\_id} \\ string: &\ttt{\$process\_id} \\ integer: &\ttt{n\_in}, \ttt{n\_out}, \ttt{n\_tot} \\ real: &\ttt{sqrts}, \ttt{sqrts\_hat} \\ real: &\ttt{sqme}, \ttt{sqme\_ref} \\ real: &\ttt{event\_weight}, \ttt{event\_excess} \end{tabular} \end{quote} The \ttt{process\_num\_id} is the numeric ID as used by external programs, while the process index refers to the current library. By default, the two are identical. The process index itself is not available as a predefined observable. The \ttt{sqme} and \ttt{sqme\_ref} values indicate the squared matrix element and the reference squared matrix element, respectively. The latter applies when comparing with a reference sample (the \ttt{rescan} command). \ttt{record} evaluates to a logical, so several \ttt{record} functions may be concatenated by the logical operators \ttt{and} or \ttt{or}. However, since usually the further evaluation should not depend on the return value of \ttt{record}, it is more advisable to concatenate them by the semicolon (\ttt{;}) operator. This is an operator (\emph{not} a statement separator or terminator) that connects two logical expressions and evaluates both of them in order. The lhs result is discarded, the result is the value of the rhs: \begin{quote} \begin{footnotesize} \begin{verbatim} analysis = record hist_pt (eval Pt [lepton]) ; record hist_ct (eval cos (Theta) [lepton]) \end{verbatim} \end{footnotesize} \end{quote} \subsection{Histograms} \label{sec:histogram} In \sindarin, a histogram is declared by the command \begin{quote} \begin{footnotesize} \ttt{histogram \emph{analysis-tag} (\emph{lower-bound}, \emph{upper-bound})} \end{footnotesize} \end{quote} This creates a histogram data structure for an (unspecified) observable. The entries are organized in bins between the real values \ttt{\emph{lower-bound}} and \ttt{\emph{upper-bound}}. The number of bins is given by the value of the intrinsic integer variable \ttt{n\_bins}, the default value is 20. The \ttt{histogram} declaration supports an optional argument, so the number of bins can be set locally, for instance \begin{quote} \begin{footnotesize} \ttt{histogram pt\_distribution (0 GeV, 500 GeV) \{ n\_bins = 50 \}} \end{footnotesize} \end{quote} Sometimes it is more convenient to set the bin width directly. This can be done in a third argument to the \ttt{histogram} command. \begin{quote} \begin{footnotesize} \ttt{histogram pt\_distribution (0 GeV, 500 GeV, 10 GeV)} \end{footnotesize} \end{quote} If the bin width is specified this way, it overrides the setting of \ttt{n\_bins}. The \ttt{record} command or function fills histograms. A single call \begin{quote} \begin{footnotesize} \ttt{record (\emph{real-expr})} \end{footnotesize} \end{quote} puts the value of \ttt{\emph{real-expr}} into the appropriate bin. If the call is issued during a simulation where \ttt{unweighted} is false, the entry is weighted appropriately. If the value is outside the range specified in the histogram declaration, it is put into one of the special underflow and overflow bins. The \ttt{write\_analysis} command prints the histogram contents as a table in blank-separated fixed columns. The columns are: $x$ (bin midpoint), $y$ (bin contents), $\Delta y$ (error), excess weight, and $n$ (number of entries). The output also contains comments initiated by a \verb|#| sign, and following the histogram proper, information about underflow and overflow as well as overall contents is added. \subsection{Plots} \label{sec:plot} While a histogram stores only summary information about a data set, a \ttt{plot} stores all data as $(x,y)$ pairs, optionally with errors. A plot declaration is as simple as \begin{quote} \begin{footnotesize} \ttt{plot \emph{analysis-tag}} \end{footnotesize} \end{quote} Like observables and histograms, plots are filled by the \ttt{record} command or expression. To this end, it can take two arguments, \begin{quote} \begin{footnotesize} \ttt{record (\emph{x-expr}, \emph{y-expr})} \end{footnotesize} \end{quote} or up to four: \begin{quote} \begin{footnotesize} \ttt{record (\emph{x-expr}, \emph{y-expr}, \emph{y-error})} \\ \ttt{record (\emph{x-expr}, \emph{y-expr}, \emph{y-error-expr}, \emph{x-error-expr})} \end{footnotesize} \end{quote} Note that the $y$ error comes first. This is because applications will demand errors for the $y$ value much more often than $x$ errors. The plot output, again written by \ttt{write\_analysis} contains the four values for each point, again in the ordering $x,y,\Delta y, \Delta x$. \subsection{Analysis Output} There is a default format for piping information into observables, histograms, and plots. In older versions of \whizard\ there was a first version of a custom format, which was however rather limited. A more versatile custom output format will be coming soon. \begin{enumerate} \item By default, the \ttt{write\_analysis} command prints all data to the standard output. The data are also written to a default file with the name \ttt{whizard\_analysis.dat}. Output is redirected to a file with a different name if the variable \ttt{\$out\_file} has a nonempty value. If the file is already open, the output will be appended to the file, and it will be kept open. If the file is not open, \ttt{write\_analysis} will open the output file by itself, overwriting any previous file with the same name, and close it again after data have been written. The command is able to print more than one dataset, following the syntax \begin{quote} \begin{footnotesize} \ttt{write\_analysis (\emph{analysis-tag1}, \emph{analysis-tag2}, \ldots) \{ \emph{options} \}} \end{footnotesize} \end{quote} The argument in brackets may also be empty or absent; in this case, all currently existing datasets are printed. The default data format is suitable for compiling analysis data by \whizard's built-in \gamelan\ graphics driver (see below and particularly Chap.~\ref{chap:visualization}). Data are written in blank-separated fixed columns, headlines and comments are initiated by the \verb|#| sign, and each data set is terminated by a blank line. However, external programs often require special formatting. The internal graphics driver \gamelan\ of \whizard\ is initiated by the \ttt{compile\_analysis} command. Its syntax is the same, and it contains the \ttt{write\_analysis} if that has not been separately called (which is unnecessary). For more details about the \gamelan\ graphics driver and data visualization within \whizard, confer Chap.~\ref{chap:visualization}. \item Custom format. Not yet (re-)implemented in a general form. \end{enumerate} \section{Custom Input/Output} \label{sec:I/O} \whizard\ is rather chatty. When you run examples or your own scripts, you will observe that the program echoes most operations (assignments, commands, etc.) on the standard output channel, i.e., on screen. Furthermore, all screen output is copied to a log file which by default is named \ttt{whizard.log}. For each integration run, \whizard\ writes additional process-specific information to a file \ttt{\var{tag}.log}, where \ttt{\var{tag}} is the process name. Furthermore, the \ttt{write\_analysis} command dumps analysis data -- tables for histograms and plots -- to its own set of files, cf.\ Sec.~\ref{sec:analysis}. However, there is the occasional need to write data to extra files in a custom format. \sindarin\ deals with that in terms of the following commands: \subsection{Output Files} \subsubsection{open\_out} \begin{syntax} open\_out (\var{filename}) \\ open\_out (\var{filename}) \{ \var{options} \} \end{syntax} Open an external file for writing. If the file exists, it is overwritten without warning, otherwise it is created. Example: \begin{code} open_out ("my_output.dat") \end{code} \subsubsection{close\_out} \begin{syntax} close\_out (\var{filename}) \\ close\_out (\var{filename}) \{ \var{options} \} \end{syntax} Close an external file that is open for writing. Example: \begin{code} close_out ("my_output.dat") \end{code} \subsection{Printing Data} \subsubsection{printf} \begin{syntax} printf \var{format-string-expr} \\ printf \var{format-string-expr} (\var{data-objects}) \end{syntax} Format \ttt{\var{data-objects}} according to \ttt{\var{format-string-expr}} and print the resulting string to standard output if the string variable \ttt{\$out\_file} is undefined. If \ttt{\$out\_file} is defined and the file with this name is open for writing, print to this file instead. Print a newline at the end if \ttt{?out\_advance} is true, otherwise don't finish the line. The \ttt{\var{format-string-expr}} must evaluate to a string. Formatting follows a subset of the rules for the \ttt{printf(3)} command in the \ttt{C} language. The supported rules are: \begin{itemize} \item All characters are printed as-is, with the exception of embedded conversion specifications. \item Conversion specifications are initiated by a percent (\verb|%|) sign and followed by an optional prefix flag, an optional integer value, an optional dot followed by another integer, and a mandatory letter as the conversion specifier. \item A percent sign immediately followed by another percent sign is interpreted as a single percent sign, not as a conversion specification. \item The number of conversion specifiers must be equal to the number of data objects. The data types must also match. \item The first integer indicates the minimum field width, the second one the precision. The field is expanded as needed. \item The conversion specifiers \ttt{d} and \ttt{i} are equivalent, they indicate an integer value. \item The conversion specifier \ttt{e} indicates a real value that should be printed in exponential notation. \item The conversion specifier \ttt{f} indicates a real value that should be printed in decimal notation without exponent. \item The conversion specifier \ttt{g} indicates a real value that should be printed either in exponential or in decimal notation, depending on its value. \item The conversion specifier \ttt{s} indicates a logical or string value that should be printed as a string. \item Possible prefixes are \verb|#| (alternate form, mandatory decimal point for reals), \verb|0| (zero padding), \verb|-| (left adjusted), \verb|+| (always print sign), `\verb| |' (print space before a positive number). \end{itemize} For more details, consult the \verb|printf(3)| manpage. Note that other conversions are not supported and will be rejected by \whizard. The data arguments are numeric, logical or string variables or expressions. Numeric expressions must be enclosed in parantheses. Logical expressions must be enclosed in parantheses prefixed by a question mark \verb|?|. String expressions must be enclosed in parantheses prefixed by a dollar sign \verb|$|. These forms behave as anonymous variables. Note that for simply printing a text string, you may call \ttt{printf} with just a format string and no data arguments. Examples: \begin{code} printf "The W mass is %8f GeV" (mW) int i = 2 int j = 3 printf "%i + %i = %i" (i, j, (i+j)) string $directory = "/usr/local/share" string $file = "foo.dat" printf "File path: %s/%s" ($directory, $file) \end{code} There is a related \ttt{sprintf} function, cf.~Sec.~\ref{sec:sprintf}. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{WHIZARD at next-to-leading order} \subsection{Prerequisites} A full NLO computation requires virtual matrix elements obtained from loop diagrams. Since \oMega\ cannot calculate such diagrams, external programs are used. \whizard\ has a generic interface to matrix-element generators that are BLHA-compatible. Explicit implementations exist for \gosam, \openloops\ and \recola. %%%%% \subsubsection{Setting up \gosam} The installation of \gosam\ is detailed on the HepForge page \url{https://gosam/hepforge.org}. We mention here some of the steps necessary to get it to be linked with \whizard. {\bf Bug in \gosam\ installation scripts:} In many versions of \gosam\ there is a bug in the installation scripts that is only relevant if \gosam\ is installed with superuser privileges. Then all files in \ttt{\$installdir/share/golem} do not have read privileges for normal users. These privileges must be given manually to all files in that directory. Prerequisites for \gosam\ to produce code for one-loop matrix elements are the scientific algebra program \ttt{form} and the generator of loop topologies and diagrams, \ttt{qgraf}. These can be accessed via their respective webpages \url{http://www.nikhef.nl/~form/} and \url{http://cfif.ist.utl.pt/~paulo/qgraf.html}. Note also that both \ttt{Java} and the Java runtime environment have to be installed in order for \gosam\ to properly work. Furthermore, \ttt{libtool} needs to be installed. A more convenient way to install \gosam, is the automatic installation script \url{https://gosam.hepforge.org/gosam_installer.py}. %%%%% \subsubsection{Setting up \openloops} \label{sec:openloops-setup} The installation of \openloops\ is explained in detail on the HepForge page \url{https://openloops.hepforge.org}. In the following, the main steps for usage with \whizard\ are summarized. Please note that at the moment, \openloops\ cannot be installed such that in almost all cases the explicit \openloops\ package directory has to be set via \ttt{--with-openloops=}. \openloops\ can be checked out with \begin{code} git clone https://gitlab.com/openloops/OpenLoops.git \end{code} Note that \whizard\ only supports \openloops\ version that are at least 2.1.1 or newer. Alternatively, one can use the public beta version of \openloops, which can be checked out by the command \begin{code} git clone -b public_beta https://gitlab.com/openloops/OpenLoops.git \end{code} The program can be build by running \ttt{scons} or \ttt{./scons}, a local version that is included in the \openloops\ directory. This produces the script \ttt{./openloops}, which is the main hook for the further usage of the program. \openloops\ works by downloading prebuild process libraries, which have to be installed for each individual process. This requires the file \ttt{openloops.cfg}, which should contain the following content: \begin{code} [OpenLoops] process\_repositories=public, whizard\\ compile\_extra=1 \end{code} The first line instructs \openloops\ to also look for process libraries in an additional lepton collider repository. The second line triggers the inclusion of $N+1$-particle tree-level matrix elements in the process directory, so that a complete NLO calculation including real amplitudes can be performed only with \openloops. The libraries can then be installed via \begin{code} ./openloops libinstall proc_name \end{code} A list of supported library names can be found on the \openloops\ web page. Note that a process library also includes all possible permutated processes. The process library \ttt{ppllj}, for example, can also be used to compute the matrix elements for $e^+ e^- \rightarrow q \bar{q}$ (massless quarks only). The massive case of the top quark is handled in \ttt{eett}. Additionally, there are process libraries for top and gauge boson decays, \ttt{tbw}, \ttt{vjj}, \ttt{tbln} and \ttt{tbqq}. Finally, \openloops\ can be linked to \whizard\ during configuration by including \begin{code} --enable-openloops --with-openloops=$OPENLOOPS_PATH, \end{code} where \ttt{\$OPENLOOPS\_PATH} is the directory the \openloops\ executable is located in. \openloops\ one-loop diagrams can then be used with the \sindarin\ option \begin{code} $loop_me_method = "openloops". \end{code} The functional tests which check the \openloops\ functionality require the libraries \ttt{ppllj}, \ttt{eett} and \ttt{tbw} to be installed (note that \ttt{eett} is not contained in \ttt{ppll}). During the configuration of \whizard, it is automatically checked that these two libraries, as well as the option \ttt{compile\_extra=1}, are present. \subsubsection{\openloops\ \sindarin\ flags} Several \sindarin\ options exist to control the behavior of \openloops. \begin{itemize} \item \ttt{openloops\_verbosity}:\\ Decide how much \openloops\ output is printed. Can have values 0, 1 and 2. \item \ttt{?openloops\_use\_cms}:\\ Activates the complex mass scheme. For computations with decaying resonances like the top quark or W or Z bosons, this is the preferred option to avoid gauge-dependencies. \item \ttt{openloops\_phs\_tolerance}:\\ Controls the exponent of \ttt{extra psp\_tolerance} in the BLHA interface, which is the numerical tolerance for the on-shell condition of external particles \item \ttt{openloops\_switch\_off\_muon\_yukawa}:\\ Sets the Yukawa coupling of muons to zero in order to assure agreement with \oMega, which is possibly used for other components and per default does not take $H\mu\mu$ couplings into account. \item \ttt{openloops\_stability\_log}:\\ Creates the directory \ttt{stability\_log}, which contains information about the performance of the matrix elements. Possible values are \begin{itemize} \item 0: No output (default), \item 1: On finish() call, \item 2: Adaptive, \item 3: Always \end{itemize} \item \ttt{?openloops\_use\_collier}: Use Collier as the reduction method (default true). \end{itemize} %%%%% \subsubsection{Setting up \recola} \label{sec:recola-setup} The installation of \recola\ is explained in detail on the HepForge page \url{https://recola.hepforge.org}. In the following the main steps for usage with \whizard\ are summarized. The minimal required version number of \recola\ is 1.3.0. \recola\ can be linked to \whizard\ during configuration by including \begin{code} --enable-recola \end{code} In case the \recola\ library is not in a standard path or a path accessible in the \ttt{LD\_LIBRARY\_PATH} (or \ttt{DYLD\_LIBRARY\_PATH}) of the operating system, then the option \begin{code} --with-recola=$RECOLA_PATH \end{code} can be set, where \ttt{\$RECOLA\_PATH} is the directory the \recola\ library is located in. \recola\ can then be used with the \sindarin\ option \begin{code} $method = "recola" \end{code} or any other of the matrix element methods. Note that there might be a clash of the \collier\ libraries when you have \collier\ installed both via \recola\ and via \openloops, but have compiled them with different \fortran\ compilers. %%%%% \subsection{NLO cross sections} An NLO computation can be switched on in \sindarin\ with \begin{code} process proc_nlo = in1, in2 => out1, ..., outN { nlo_calculation = }, \end{code} where the \ttt{nlo\_calculation} can be followed by a list of strings specifying the desired NLO-components to be integrated, i.e. \ttt{born}, \ttt{real}, \ttt{virtual}, \ttt{dglap}, (for hadron collisions) or \ttt{mismatch} (for the soft mismatch in resonance-aware computations) and \ttt{full}. The \ttt{full} option switches on all components and is required if the total NLO result is desired. For example, specifying \begin{code} nlo_calculation = born, virtual \end{code} will result in the computation of the Born and virtual component. The integration can be carried out in two different modes: Combined and separate integration. In the separate integration mode, each component is integrated individually, allowing for a good overview of their contributions to the total cross section and a fine tuned control over the iterations in each component. In the combined integration mode, all components are added up during integration so that the sum of them is evaluated. Here, only one integration will be displayed. The default method is the separate integration. The convergence of the integration can crucially be influenced by the presence of resonances. A better convergence is in this case achieved activating the resonance-aware FKS subtraction, \begin{code} $fks_mapping_type = "resonances". \end{code} This mode comes with an additional integration component, the so-called soft mismatch. Note that you can modify the number of iterations in each component with the multipliers: \begin{itemize} \item \ttt{mult\_call\_real} multiplies the number of calls to be used in the integration of the real component. A reasonable choice is \ttt{10.0} as the real phase-space is more complicated than the Born but the matrix elements evaluate faster than the virtuals. \item \ttt{mult\_call\_virt} multiplies the number of calls to be used in the integration of the virtual component. A reasonable choice is \ttt{0.5} to make sure that the fast Born component only contributes a negligible MC error compared to the real and virtual components. \item \ttt{mult\_call\_dglap} multiplies the number of calls to be used in the integration of the DGLAP component. \end{itemize} \subsection{Fixed-order NLO events} \label{ss:fixedorderNLOevents} Fixed-order NLO events can also be produced in three different modes: Combined weighted, combined unweighted and separated weighted. \begin{itemize} \item \textbf{Combined weighted}\\ In the combined mode, one single integration grid is produced, from which events are generated with the total NLO weight. The corresponding event file contains $N$ events with born-like kinematics and weight equal to $\mathcal{B} + \mathcal{V} + \sum_{\alpha_r} \mathcal{C}_{\alpha_r}$, where $\mathcal{B}$ is the Born matrix element, $\mathcal{V}$ is the virtual matrix element and $\mathcal{C}_{\alpha_r}$ are the subtraction terms in each singular region. For resonance-aware processes, also the mismatch value is added. Each born-like event is followed by $N_{\text{phs}}$ associated events with real kinematics, i.e. events where one additional QCD particle is present. The corresponding real matrix-elements $\mathcal{R}_\alpha$ form the weight of these events. $N_{\text{phs}}$ the number of distinct phase spaces. Two phase spaces are distinct if they share the same resonance history but have different emitters. So, two $\alpha_r$ can share the same phase space index. The combined event mode is activated by \begin{code} ?combined_nlo_integration = true ?unweighted = false ?fixed_order_nlo_events = true \end{code} Moreover, the process must be specified at next-to-leading-order in its definition using \ttt{nlo\_calculation = full}. \whizard\ then proceeds as in the usual simulation mode. I.e. it first checks whether integration grids are already present and uses them if they fit. Otherwise, it starts an integration. \item \textbf{Combined unweighted}\\ The unweighted combined events can be generated by using the \powheg\ mode, cf. also the next subsection, but disabling the additional radiation and Sudakov factors with the \ttt{?powheg\_disable\_sudakov} switch: \begin{code} ?combined_nlo_integration = true ?powheg_matching = true ?powheg_disable_sudakov = true \end{code} This will produce events with Born kinematics and unit weights (as \ttt{?unweighted} is \ttt{true} by default). The events are unweighted by using $\mathcal{B} + \mathcal{V} + \sum_{\alpha_r} (\mathcal{C}_{\alpha_r} + \mathcal{R}_{\alpha_r})$. Of course, this only works when these weights are positive over the full phase-space, which is not guaranteed for all scales and regions at NLO. However, for many processes perturbation theory works nicely and this is not an issue. \item \textbf{Separate weighted}\\ In the separate mode, grids and events are generated for each individual component of the NLO process. This method is preferable for complicated processes, since it allows to individually tune each grid generation. Moreover, the grid generation is then trivially parallelized. The event files either contain only Born kinematics with weight $\mathcal{B}$ or $\mathcal{V}$ (and mismatch in case of a resonance-aware process) or mixed Born and real kinematics for the real component like in the combined mode. However, the Born events have only the weight $\sum_{\alpha_r} \mathcal{C}_{\alpha_r}$ in this case. The separate event mode is activated by \begin{code} ?unweighted = false ?negative_weights = true ?fixed_order_nlo_events = true \end{code} Note that negative weights have to be switched on because, in contrast to the combined mode, the total cross sections of the individual components can be negative. Also, the desired component has to appear in the process NLO specification, e.g. using \ttt{nlo\_calculation = real}. \end{itemize} Weighted fixed-order NLO events are supported by any output format that supports weights like the \ttt{HepMC} format and unweighted NLO events work with any format. The output can either be written to disk or put into a FIFO to interface it to an analysis program without writing events to file. The weights in the real event output, both in the combined and separate weighted mode, are divided by a factor $N_{\text{phs}} + 1$. This is to account for the fact that we artificially increase the number of events in the output file. Thus, the sum of all event weights correctly reproduces the total cross section. \subsection{\powheg\ matching} To match the NLO computation with a parton shower, \whizard\ supports the \powheg\ matching. It generates a distribution according to \begin{align} \label{eq:powheg} \text{d}\sigma &= \text{d}\Phi_n \,{\bar{B}_{\text{s}}}\,\biggl( {\Delta_{\text{s}}}(p_T^{\text{min}}\bigr) + \text{d}\Phi_{\text{rad}}\,{\Delta_{\text{s}}}(k_{\text{T}}(\Phi_{\text{rad}})\bigr) {\frac{R_{\text{s}}}B}\biggr) \quad \text{where} \\ {\bar{B}_{\text{s}}} &= {B} + {\mathcal{V}} + \text{d}\Phi_{\text{rad}}\, {\mathcal{R}_{\text{s}}} \quad \text{and} \\ {\Delta_{\text{s}}}(p_T) &= \exp\left[- \int{\text{d}\Phi_{\text{rad}}} {\frac{R_{\text{s}}}{B}}\; \theta\left(k_T^2(\Phi_{\text{rad}}) - p_T^2\right)\right]\;. \end{align} The subscript s refers to the singular part of the real component, cf. to the next subsection. Eq.~\eqref{eq:powheg} produces either no or one additional emission. These events can then either be analyzed directly or passed on to the parton shower\footnote{E.g. \pythiaeight\ has explicit examples for \powheg\ input, see also \url{http://home.thep.lu.se/Pythia/pythia82html/POWHEGMerging.html}.} for the full simulation. You activate this with \begin{code} ?fixed_order_nlo_events = false ?combined_nlo_integration = true ?powheg_matching = true \end{code} The $p_T^{\text{min}}$ of Eq.~\eqref{eq:powheg} can be set with \ttt{powheg\_pt\_min}. It sets the minimal scale for the \powheg\ evolution and should be of order 1 GeV and set accordingly in the interfaced shower. The maximal scale is currently given by \ttt{sqrts} but should in the future be changeable with \ttt{powheg\_pt\_min}. Note that the \powheg\ event generation needs an additional grid for efficient event generation that is automatically generated during integration. Further options that steer the efficiency of this grid are \ttt{powheg\_grid\_size\_xi} and \ttt{powheg\_grid\_size\_y}. \subsection{Separation of finite and singular contributions} For both the pure NLO computations as well as the \powheg\ event generation, \whizard\ supports the partitioning of the real into finite and singular contributions with the flag \begin{code} ?nlo_use_real_partition = true \end{code} The finite contributions, which by definition should not contain soft or collinear emissions, will then integrate like a ordinary LO integration with one additional particle. Similarly, the event generation will produce only real events without subtraction terms with Born kinematics for this additional finite component. The \powheg\ event generation will also only use the singular parts. The current implementation uses the following parametrization \begin{align} R &= R_{\text{fin}} + R_{\text{sing}} \;,\\ R_{\text{sing}} &= R F(\Phi_{n+1}) \;,\\ R_{\text{fin}} &= R (1-F(\Phi_{n+1})) \;,\\ F(\Phi_{n+1}) &= \begin{cases} 1 & \text{if} \quad\exists\,(i,j)\in\mathcal{P}_{\text{FKS}}\quad \text{with} \quad \sqrt{(p_i+p_j)^2} < h + m_i + m_j \\ 0 & \text{else} \end{cases} \;. \end{align} Thus, a point is {singular ($F=1$)}, if {any} of the {FKS tuples} forms an {invariant mass} that is {smaller than the hardness scale $h$}. This parameter is controlled in \sindarin\ with \ttt{real\_partition\_scale}. This simplifies in {massless case} to \begin{align} F(\Phi_{n+1}) = \begin{cases} 1 & \text{if} \;\exists\,(i,j)\in\mathcal{P}_{\text{FKS}}\quad \text{with} \quad 2 E_i E_j (1-\cos\theta_{ij}) < h^2 \\ 0 & \text{else} \end{cases} \;. \end{align} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Random number generators} \label{chap:rng} \section{General remarks} \label{sec:rng} The random number generators (RNG) are one of the crucialer points of Monte Carlo calculations, hence, giving those their ``randomness''. A decent multipurpose random generator covers \begin{itemize} \item reproducibility \item large period \item fast generation \item independence \end{itemize} of the random numbers. Therefore, special care is taken for the choice of the RNGs in \whizard{}. It is stated that \whizard{} utilizes \textit{pseudo}-RNGs, which are based on one (or more) recursive algorithm(s) and start-seed(s) to have reproducible sequences of numbers. In contrast, a genuine random generator relies on physical processes. \whizard\ ships with two completely different random number generators which can be selected by setting the \sindarin\ option \begin{code} $rng_method = "rng_tao" \end{code} Although, \whizard{} sets a default seed, it is adviced to use a different one \begin{code} seed = 175368842 \end{code} note that some RNGs do not allow certain seed values (e.g. zero seed). \section{The TAO Random Number Generator} \label{sec:tao} The TAO (``The Art Of'') random number generator is a lagged Fibonacci generator based upon (signed) 32-bit integer arithmetic and was proposed by Donald E. Knuth and is implemented in the \vamp\ package. The TAO random number generator is the default RNG of \whizard{}, but can additionally be set as \sindarin\ option \begin{code} $rng_method = rng_tao \end{code} The TAO random number generators is a subtractive lagged Fibonacci generator \begin{equation*} x_{j} = \left( x_{j-k} - x_{j-L} \right) \mod 2^{30} \end{equation*} with lags $k = 100$ and $l = 37$ and period length $\rho = 2^{30} - 2$. \section{The RNGStream Generator} \label{sec:rngstream} The RNGStream \cite{L_Ecuyer:2002} was originally implemented in \cpp\ with floating point arithmetic and has been ported to \fortranOThree{}. The RNGstream can be selected by the \sindarin\ option \begin{code} $rng_method = "rng_stream" \end{code} The RNGstream supports multiple independent streams and substreams of random numbers which can be directly accessed. The main advantage of the RNGStream lies in the domain of parallelization where different worker have to access different parts of the random number stream to ensure numerical reproducibility. The RNGstream provides exactly this property with its (sub)stream-driven model. Unfortunately, the RNGStream can only be used in combination with \vamptwo{}. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Integration Methods} \section{The Monte-Carlo integration routine: \ttt{VAMP}} \label{sec:vamp} \vamp\ \cite{Ohl:1998jn} is a multichannel extension of the \vegas\ \cite{Lepage:1980dq} algorithm. For all possible singularities in the integrand, suitable maps and integration channels are chosen which are then weighted and superimposed to build the phase space parameterization. Both grids and weights are modified in the adaption phase of the integration. The multichannel integration algorithm is implemented as a \fortranNinetyFive\ library with the task of mapping out the integrand and finding suitable parameterizations being completely delegated to the calling program (\whizard\ core in this case). This makes the actual \vamp\ library completely agnostic of the model under consideration. \section{The next generation integrator: \ttt{VAMP2}} \label{sec:vamp2} \vamptwo\ is a modern implementation of the integrator package \vamp\ written in \fortranOThree\, providing the same features. The backbone integrator is still \vegas\ \cite{Lepage:1980dq}, although implemented differently as in \vamp{}. The main advantage over \vamp\ is the overall faster integration due to the usage of \fortranOThree{}, the possible usage of different random number generators and the complete parallelization of \vegas\ and the multichannel integration. \vamptwo{} can be set by the \sindarin{} option \begin{code} $integration_method = "vamp2" \end{code} It is said that the generated grids between \vamp{} and \vamptwo{} are incompatible. \subsection{Multichannel integration} \label{sec:multi-channel} The usual matrix elements do not factorise with respect to their integration variables, thus making an direct integration ansatz with VEGAS unfavorable.\footnote{One prerequisite for the VEGAS algorithm is that the integral factorises, and such produces only the best results for those.} Instead, we apply the multichannel ansatz and let VEGAS integrate each channel in a factorising mapping. The different structures of the matrix element are separated by a partition of unity and the respective mappings, such that each structure factorise at least once. We define the mappings $\phi_i : U \mapsto \Omega$, where $U$ is the unit hypercube and $\Omega$ the physical phase space. We refer to each mapping as a \textit{channel}. Each channel then gives rise to a probability density $g_i : U \mapsto [0, \infty)$, normalised to unity \begin{equation*} \int_0^1 g_i(\phi_i^{-1}(p)) \left| \frac{\partial \phi_i^{-1}}{\partial p} \right| \mathrm{d}\mu(p) = 1, \quad g_i(\phi_i^{-1}(p)) \geq 0, \end{equation*} written for a phase space point $p$ using the mapping $\phi_i$. The \textit{a-priori} channel weights $\alpha_i$ are defined as partition of unity by $\sum_{i\in I} \alpha_i = 1$ and $0 \leq \alpha_i \leq 1$. The overall probability density $g$ of a random sample is then obtained by \begin{equation*} g(p) = \sum_{i \in I} \alpha_i g_i(\phi_i^{-1}(p)) \left| \frac{\partial \phi_i^{-1}}{\partial p} \right|, \end{equation*} which is also a non-negative and normalized probability density. We reformulate the integral \begin{equation*} I(f) = \sum_{i \in I} \alpha_i \int_\Omega g_i(\phi_i^{-1}(p)) \left| \frac{\partial \phi_i^{-1}}{\partial p} \right| \frac{f(p)}{g(p)} \mathrm{d}\mu(p). \end{equation*} The actual integration of each channel is then done by VEGAS, which shapes the $g_i$. \subsection{VEGAS} \label{sec:vegas} VEGAS is an adaptive and iterative Monte Carlo algorithm for integration using importance sampling. After each iteration, VEGAS adapts the probability density $g_i$ using information collected while sampling. For independent integration variables, the probability density factorises $g_i = \prod_{j = 1}^{d} g_{i,j}$ for each integration axis and each (independent) $g_{i,j}$ is defined by a normalised step function \begin{equation*} g_{i,j} (x_j) = \frac{1}{N\Delta x_{j,k}}, \quad x_{j,k} - \Delta x_{j,k} \leq x_{j} < x_{j,k}, \end{equation*} where the steps are $0 = x_{j, 0} < \cdots < x_{j,k} < \cdots < x_{j,N} = 1$ for each dimension $j$. The algorithm randomly selects for each dimension a bin and a position inside the bin and calculates the respective $g_{i,j}$. \subsection{Channel equivalences} \label{sec:equivalences} The automated mulitchannel phasespace configuration can lead to a surplus of degrees of freedom, e.g. for a highly complex process with a large number of channels (VBS). In order to marginalize the redundant degrees of freedom of phasespace configuration, the adaptation distribution of the grids are aligned in accordance to their phasespace relation, hence the binning of the grids is equialized. These equivalences are activated by default for \vamp{} and \vamptwo{}, but can be steered by: \begin{code} ?use_vamp_equivalences = true \end{code} Be aware, that the usage of equivalences are currently only possible for LO processes. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Phase space parameterizations} \section{General remarks} \whizard\ as a default performs an adaptive multi-channel Monte-Carlo integration. Besides its default phase space algorithm, \ttt{wood}, to be detailed in Sec.~\ref{sec:wood}, \whizard\ contains a phase space method \ttt{phs\_none} which is a dummy method that is intended for setups of processes where no phase space integration is needed, but the program flow needs a (dummy) integrator for internal consistency. Then, for testing purposes, there is a single-channel phase space integrator, \ttt{phs\_single}. From version 2.6.0 of \whizard\ on, there is also a second implementation of the \ttt{wood} phase space algorithm, called \ttt{fast\_wood}, cf. Sec.~\ref{sec:fast_wood}, whose implementation differs technically and which therefore solves certain technical flaws of the \ttt{wood} implementation. Additionally, \whizard\ supports single-channel, flat phase-space using RAMBO (on diet). %%% \section{The flat method: \ttt{rambo}} \label{sec:rambo} The \ttt{RAMBO} algorithm produces a flat phase-space with constant volume for massless particles. \ttt{RAMBO} was originally published in \cite{Kleiss:1985gy}. We use the slim version, called \ttt{RAMBO} on diet, published in \cite{Platzer:2013esa}. The overall weighting efficiency of the algorithm is unity for massless final-state particles. For the massive case, the weighting efficiency of unity will decrease rendering the algorithm less efficient. But in most cases, the invariants are in regions of phase space where they are much larger than the masses of the final-state particles. We provide the \ttt{RAMBO} mainly for cross checking our implementation and do not recommend it for real world application, even though it can be used as one. The \ttt{RAMBO} method becomes useful as a fall-back option if the standard algorithm fails for physical reasons, see, e.g., Sec.~\ref{sec:ps_anomalous}. %%% \section{The default method: \ttt{wood}} \label{sec:wood} The \ttt{wood} algorithm classifies different phase space channels according to their importance for a full scattering or decay process following heuristic rules. For that purpose, \whizard\ investigates the kinematics of the different channels depending on the total center-of-mass energy (or the mass of the decaying particle) and the masses of the final-state particles. The \ttt{wood} phase space inherits its name from the naming schemes of structures of increasing complexities, namely trees, forests and groves. Simply stated, a phase-space forest is a collection of phase-space trees. A phase-space tree is a parameterization for a valid channel in the multi-channel adaptive integration, and each variable in the a tree corresponds to an integration dimension, defined by an appropriate mapping of the $(0,1)$ interval of the unit hypercube to the allowed range of the corresponding integration variable. The whole set of these phase-space trees, collected in a phase-space forest object hence contains all parameterizations of the phase space that \whizard\ will use for a single hard process. Note that processes might contain flavor sums of particles in the final state. As \whizard\ will use the same phase space parameterization for all channels for this set of subprocesses, all particles in those flavor sums have to have the same mass. E.g. in the definition of a "light" jet consisting of the first five quarks and antiquarks, \begin{code} alias jet = u:d:s:c:b:U:D:S:C:B \end{code} all quarks including strange, charm and bottom have to be massless for the phase-space integration. \whizard\ can treat processes with subprocesses having final-state particles with different masses in an "additive" way, where each subprocess will become a distinct component of the whole process. Each process component will get its own phase-space parameterization, such that they can allow for different masses. E.g. in a 4-flavor scheme for massless $u,d,s,c$ quarks one can write \begin{code} alias jet = u:d:s:c:U:D:S:C process eeqq = e1, E1 => (jet, jet) + (b, B) \end{code} In that case, the parameterizations will be for massless final state quarks for the first subprocess, and for massive $b$ quarks for the second subprocess. In general, for high-energy lepton colliders, the difference would not matter much, but performing the integration e.g. for $\sqrt{s} = 11$ GeV, the difference will be tremendous. \whizard\ avoids inconsistent phase-space parameterizations in that way. As a multi-particle process will contain hundred or thousands of different channels, the different integration channels (trees) are grouped into so called {\em groves}. All channels/trees in the same grove share a common weight for the phase-space integration, following the assumption that they are related by some approximate symmetry. The \vamp\ adaptive multi-channel integrator (cf. Sec.~\ref{sec:vamp}) allows for equivalences between different integration channels. This means that trees/channels that are related by an exact symmetry are connected by an array of these equivalences. The phase-space setup, i.e. the detailed structure of trees and forests, are written by \whizard\ into a phase-space file that has the same name as the corresponding process (or process component) with the suffix \ttt{.phs}. For the \ttt{wood} phase-space method this file is written by a \fortran\ module which constructs a similar tree-like structure as the directed acyclical graphs (DAGs) in the \oMega\ matrix element generator but in a less efficient way. In some very rare cases with externally generated models (cf. Chapter~\ref{chap:extmodels}) the phase-space generation has been reported to fail as \whizard\ could not find a valid phase-space channel. Such pathological cases cannot occur for the hard-coded model implementations inside \whizard. They can only happen if there are in principle two different Feynman diagrams contributing to the same phase-space channel and \whizard\ considers the second one as extremely subleading (and would hence drop it). If for some reason however the first Feynman diagram is then absent, no phase-space channel could be found. This problem cannot occur with the \ttt{fast\_wood} implementation discussed in the next section, cf.~\ref{sec:fast_wood}. The \ttt{wood} algorithms orders the different groves of phase-space channels according to a heuristic importance depending on the kinematic properties of the different phase-space channels in the groves. A phase-space (\ttt{.phs}) file looks typically like this: \begin{code} process sm_i1 ! List of subprocesses with particle bincodes: ! 8 4 1 2 ! e+ e- => mu+ mu- ! 8 4 1 2 md5sum_process = "1B3B7A30C24664A73D3D027382CFB4EF" md5sum_model_par = "7656C90A0B2C4325AD911301DACF50EB" md5sum_phs_config = "6F72D447E8960F50FDE4AE590AD7044B" sqrts = 1.000000000000E+02 m_threshold_s = 5.000000000000E+01 m_threshold_t = 1.000000000000E+02 off_shell = 2 t_channel = 6 keep_nonresonant = T ! Multiplicity = 2, no resonances, 0 logs, 0 off-shell, s-channel graph grove #1 ! Channel #1 tree 3 ! Multiplicity = 1, 1 resonance, 0 logs, 0 off-shell, s-channel graph grove #2 ! Channel #2 tree 3 map 3 s_channel 23 ! Z \end{code} The first line contains the process name, followed by a list of subprocesses with the external particles and their binary codes. Then there are three lines of MD5 check sums, used for consistency checks. \whizard\ (unless told otherwise) will check for the existence of a phase-space file, and if the check sum matches, it will reuse the existing file and not generate it again. Next, there are several kinematic parameters, namely the center-of-mass energy of the process, \ttt{sqrts}, and two mass thresholds, \ttt{m\_threshold\_s} and \ttt{m\_threshold\_t}. The latter two are kinematical thresholds, below which \whizard\ will consider $s$-channel and $t$-channel-like kinematic configurations as effectively massless, respectively. The default values shown in the example have turned out to be optimal values for Standard Model particles. The two integers \ttt{off\_shell} and \ttt{t\_channel} give the number of off-shell lines and of $t$-channel lines that \whizard\ will allow for finding valid phase-space channels, respectively. This neglects extremley multi-peripheral background-like diagram constellations which are very subdominamnt compared to resonant signal processes. The final flag specifies whether \whizard\ will keep non-resonant phase-space channels (default), or whether it will focus only on resonant situations. After this header, there is a list of all groves, i.e. collections of phase-space channels which are connected by quasi-symmetries, together with the corresponding multiplicity of subchannels in that grove. In the phase-space file behind the multiplicity, \whizard\ denotes the number of (massive) resonances, logarithmcally enhanced kinematics (e.g. collinear regions), and number of off-shell lines, respectively. The final entry in the grove header notifies whether the diagrams in that grove have $s$-channel topologies, or count the number of corresponding $t$-channel lines. Another example is shown here, \begin{code} ! Multiplicity = 3, no resonances, 2 logs, 0 off-shell, 1 t-channel line grove #1 ! Channel #1 tree 3 12 map 3 infrared 22 ! A map 12 t_channel 2 ! u ! Channel #2 tree 3 11 map 3 infrared 22 ! A map 11 t_channel 2 ! u ! Channel #3 tree 3 20 map 3 infrared 22 ! A map 20 t_channel 2 ! u ! Channel #4 tree 3 19 map 3 infrared 22 ! A map 19 t_channel 2 ! u \end{code} where \whizard\ notifies in different situations a photon exchange as \ttt{infrared}. So it detects a possible infrared singularity where a particle can become arbitrarily soft. Such a situation can tell the user that there might be a cut necessary in order to get a meaningful integration result. The phase-space setup that is generated and used by the \ttt{wood} phase-space method can be visualized using the \sindarin\ option \begin{code} ?vis_channels = true \end{code} The \ttt{wood} phase-space method can be invoked with the \sindarin\ command \begin{code} $phs_method = "wood" \end{code} Note that this line is unnecessary, as \ttt{wood} is the default phase-space method of \whizard. %%%%% \section{A new method: \ttt{fast\_wood}} \label{sec:fast_wood} This method (which is available from version 2.6.0 on) is an alternative implementation of the \ttt{wood} phase-space algorithm. It uses the recursive structures inside the \oMega\ matrix element generator to generate all the structures needed for the different phase-space channels. In that way, it can avoid some of the bottlenecks of the \ttt{wood} \fortran\ implementation of the algorithm. On the other hand, it is only available if the \oMega\ matrix element generator has been enabled (which is the default for \whizard). The \ttt{fast\_wood} method is then invoked via \begin{code} ?omega_write_phs_output = true $phs_method = "fast_wood" \end{code} The first option is necessary in order to tell \oMega\ to write out the output needed for the \ttt{fast\_wood} parser in order to generate the phase-space file. This is not enabled by default in order not to generate unnecessary files in case the default method \ttt{wood} is used. So the \ttt{fast\_wood} implementation of the \ttt{wood} phase-space algorithm parses the tree-like represenation of the recursive set of one-particle off-shell wave functions that make up the whole amplitude inside \oMega\ in the form of a directed acyclical graph (DAG) in order to generate the phase-space (\ttt{.phs}) file (cf. Sec.~\ref{sec:wood}). In that way, the algorithm makes sure that only phase-space channels are generated for which there are indeed (sub)amplitudes in the matrix elements, and this also allows to exclude vetoed channels due to restrictions imposed on the matrix elements from the phase-space setup (cf. next Sec.~\ref{sec:ps_restrictions}). %%%%% \section{Phase space respecting restrictions on subdiagrams} \label{sec:ps_restrictions} The \fortran\ implementation of the \ttt{wood} phase-space does not know anything about possible restrictions that maybe imposed on the \oMega\ matrix elements, cf. Sec.~\ref{sec:process options}. Consequently, the \ttt{wood} phase space also generates phase-space channels that might be absent when restrictions are imposed. This is not a principal problem, as in the adaptation of the phase-space channels \whizard's integrator \vamp\ will recognize that there is zero weight in that channel and will drop the channel (stop sampling in that channel) after some iterations. However, this is a waste of ressources as it is in principle known that this channel is absent. Using the \ttt{fast\_wood} phase-space algorithm (cf. Sec.~\ref{sec:fast_wood} will take restrictions into account, as \oMega\ will not generate trees for channels that are removed with the restrictions command. So it advisable for the user in the case of very complicated processes with restrictions to use the \ttt{fast\_wood} phase-space method to make \whizard\ generation and integration of the phase space less cumbersome. %%%%% \section{Phase space for processes forbidden at tree level} \label{sec:ps_anomalous} The phase-space generators \ttt{wood} and \ttt{fast\_wood} are intended for tree-level processes with their typical patterns of singularities, which can be read off from Feynman graphs. They can and should be used for loop-induced or for externally provided matrix elements as long as \whizard\ does not provide a dedicated phase-space module. Some scattering processes do not occur at tree level but become allowed if loop effects are included in the calculation. A simple example is the elastic QED process \begin{displaymath} A\quad A \longrightarrow A\quad A \end{displaymath} which is mediated by a fermion loop. Similarly, certain applications provide externally provided or hand-taylored matrix-element code that replaces the standard \oMega\ code. Currently, \whizard's phase-space parameterization is nevertheless tied to the \oMega\ generator, so for tree-level forbidden processes the phase-space construction process will fail. There are two possible solutions for this problem: \begin{enumerate} \item It is possible to provide the phase-space parameterization information externally, by supplying an appropriately formatted \ttt{.phs} file, bypassing the automatic algorithm. Assuming that this phase-space file has been named \ttt{my\_phase\_space.phs}, the \sindarin\ code should contain the following: \begin{code} ?rebuild_phase_space = false $phs_file = "my_phase_space.phs" \end{code} Regarding the contents of this file, we recommend to generate an appropriate \ttt{.phs} for a similar setup, using the standard algorithm. The generated file can serve as a template, which can be adapted to the particular case. In detail, the \ttt{.phs} file consists of entries that specify the process, then a standard header which contains MD5 sums and such -- these variables must be present but their values are irrelevant for the present case --, and finally at least one \ttt{grove} with \ttt{tree} entries that specify the parameterization. Individual parameterizations are built from the final-state and initial-state momenta (in this order) which we label in binary form as $1,2,4,8,\dots$. The actual tree consists of iterative fusions of those external lines. Each fusion is indicated by the number that results from adding the binary codes of the external momenta that contribute to it. For instance, a valid phase-space tree for the process $AA\to AA$ is given by the simple entry \begin{code} tree 3 \end{code} which indicates that the final-state momenta $1$ and $2$ are combined to a fusion $1+2=3$. The setup is identical to a process such as $e^+e^-\to\mu^+\mu^-$ below the $Z$ threshold. Hence, we can take the \ttt{.phs} file for the latter process, replace the process tag, and use it as an external phase-space file. \item For realistic applications of \whizard\ together with one-loop matrix-element providers, the actual number of final-state particles may be rather small, say $2,3,4$. Furthermore, one-loop processes which are forbidden at tree level do not contain soft or collinear singularities. In this situation, the \ttt{RAMBO} phase-space integration method, cf.\ Sec.~\ref{sec:rambo} is a viable alternative which does not suffer from the problem. \end{enumerate} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Methods for Hard Interactions} \label{chap:hardint} The hard interaction process is the core of any physics simulation within an MC event generator. One tries to describe the dominant particle interaction in the physics process of interest at a given order in perturbation theory, thereby making use of field-theoretic factorization theorems, especially for QCD, in order to separate non-perturbative physics like parton distribution functions (PDFs) or fragmentation functions from the perturbative part. Still, it is in many cases not possible to describe the perturbative part completely by means of fixed-order hard matrix elements: in soft and/or collinear regions of phase space, multiple emission of gluons and quarks (in general QCD jets) and photons necessitates a resummation, as large logarithms accompany the perturbative coupling constants and render fixed-order perturbation theory unreliable. The resummation of these large logarithms can be done analytically or (semi-)numerically, however, usually only for very inclusive quantities. At the level of exclusive events, these phase space regions are the realm of (QCD and also QED) parton showers that approximate multi-leg matrix elements from the hard perturbative into to the soft-/collinear regime. The hard matrix elements are then the core building blocks of the physics description inside the MC event generator. \whizard\ generates these hard matrix elements at tree-level (or sometimes for loop-induced processes using effective operators as insertions) as leading-order processes. This is done by the \oMega\ subpackage that is automatically called by \whizard. Besides these physical matrix elements, there exist a couple of methods to generate dummy matrix elements for testing purposes, or for generating beam profiles and using them with externally linked special matrix elements. Especially for one-loop processes (next-to-leading order for tree-allowed processes or leading-order for loop-induced processes), \whizard\ allows to use matrix elements from external providers, so called OLP programs (one-loop providers). Of course, all of these external packages can also generate tree-level matrix elements, which can then be used as well in \whizard. We start the discussion with the two different options for test matrix elements, internal test matrix elements with no generated compiled code in Sec.~\ref{sec:test_me} and so called template matrix elements with actual \fortran\ code that is compiled and linked, and can also be modified by the user in Sec.~\ref{sec:template_me}. Then, we move to the main matrix element method by the matrix element generator \oMega\ in Sec.~\ref{sec:omega_me}. Matrix elements from the external matrix element generators are discussed in the order of which interfaces for the external tools have been implemented: \gosam\ in Sec.~\ref{sec:gosam_me}, \openloops\ in Sec.~\ref{sec:openloops_me}, and \recola\ in Sec.~\ref{sec:recola_me}. %%%%% \section{Internal test matrix elements} \label{sec:test_me} This method is merely for internal consistency checks inside \whizard, and is not really intended to be utilized by the user. The method is invoked by \begin{code} $method = "unit_test" \end{code} This particular method is only applicable for the internal test model \ttt{Test.mdl}, which just contains a Higgs boson and a top quark. Technically, it will also works within model specifications for the Standard Model, or the Minimal Supersymmetric Standard Model (MSSM), or all models which contain particles named as \ttt{H} and \ttt{t} with PDG codes 25 and 6, respectively. So, the models \ttt{QED} and {QCD} will not work. Irrespective of what is given in the \sindarin\ file as a scattering input process, \whizard\ will always take the process \begin{code} model = SM process = H, H => H, H \end{code} or for the test model: \begin{code} model = Test process = s, s => s, s \end{code} as corresponding process. (This is the same process, just with differing nomenclature in the different models). No matrix element code is generated and compiled, the matrix element is completely internal, included in the \whizard\ executable (or library), with a unit value for the squared amplitude. The integration will always be performed for this particularly process, even if the user provides a different process for that method. Hence, the result will always be the volume of the relativistic two-particle phase space. The only two parameters that influence the result are the collider energy, \ttt{sqrts}, and the mass of the Higgs particle with PDG code 25 (this mass parameter can be changed in the model \ttt{Test} as \ttt{ms}, while it would be \ttt{mH} in the Standard Model \ttt{SM}. It is also possible to use a test matrix element, again internal, for decay processes, where again \whizard\ will take a predefined process: \begin{code} model = SM process = H => t, tbar \end{code} in the \ttt{SM} model or \begin{code} model = Test process = s => f, fbar \end{code} Again, this is the same process with PDG codes $25 \to 6 \; -6$ in the corresponding models. Note that in the model \ttt{SM} the mass of the quark is set via the variable \ttt{mtop}, while it is \ttt{mf} in the model \ttt{Test}. Besides the fact that the user always gets a fixed process and cannot modify any matrix element code by hand, one can do all things as for a normal process like generating events, different weights, testing rebuild flags, using different setups and reweight events accordingly. Also factorized processes with production and decay can be tested that way. In order to avoid confusion, it is highly recommended to use this method \ttt{unit\_test} only with the test model setup, model \ttt{Test}. On the technical side, the method \ttt{unit\_test} does not produce a process library (at least not an externally linked one), and also not a makefile in order to modify any process files (which anyways do not exist for that method). Except for the logfiles and the phase space file, all files are internal. %%%%% \section{Template matrix elements} \label{sec:template_me} Much more versatile for the user than the previous matrix element method in~\ref{sec:test_me}, are two different methods with constant template matrix elements. These are written out as \fortran\ code by the \whizard\ main executable (or library), providing an interface that is (almost) identical to the matrix element code produced by the \oMega\ generator (cf. the next section, Sec.~\ref{sec:omega_me}. There are actually two different methods for that purpose, providing matrix elements with different normalizations: \begin{code} $method = "template" \end{code} generates matrix elements which give after integration over phase space exactly one. Of course, for multi-particle final states the integration can fluctuate numerically and could then give numbers that are only close to one but not exactly one. Furthermore, the normalization is not exact if any of the external particles have non-zero masses, or there are any cuts involved. But otherwise, the integral from \whizard\ should give unity irrespective of the number of final state particles. In contrast to this, the second method, \begin{code} $method = "template_unity" \end{code} gives a unit matrix elements, or rather a matrix element that contains helicity and color averaging factors for the initial state and the square root of the factorials of identical final state particles in the denominator. Hence, integration over the final state momentum configuration gives a cross section that corresponds to the volume of the $n$-particle final state phase space, divided by the corresponding flux factor, resulting in \begin{equation} \sigma(s, 2 \to 2,0) = \frac{3.8937966\cdot 10^{11}}{16\pi} \cdot \frac{1}{s \text{[GeV]}^2} \; \text{fb} \end{equation} for the massless case and \begin{equation} \sigma(s, 2 \to 2,m_i) = \frac{3.8937966\cdot 10^{11}}{16\pi} \cdot \sqrt{\frac{\lambda (s,m_3^2,m_4^2)}{\lambda (s,m_1^2,m_2^2)}} \cdot \frac{1}{s \text{[GeV]}^2} \; \text{fb} \end{equation} for the massive case. Here, $m_1$ and $m_2$ are the masses of the incoming, $m_3$ and $m_4$ the masses of the outgoing particles, and $\lambda(x,y,z) = x^2 + y^2 + z^2 - 2xy - 2xz - 2yz$. For the general massless case with no cuts, the integral should be exactly \begin{equation} \sigma(s, 2\to n, 0) = \frac{(2\pi)^4}{2 s}\Phi_n(s) = \frac{1}{16\pi s}\,\frac{\Phi_n(s)}{\Phi_2(s)}, \end{equation} where the volume of the massless $n$-particle phase space is given by \begin{equation}\label{phi-n} \Phi_n(s) = \frac{1}{4(2\pi)^5} \left(\frac{s}{16\pi^2}\right)^{n-2} \frac{1}{(n-1)!(n-2)!}. \end{equation} For $n\neq2$ the phase space volume is dimensionful, so the units of the integral are $\fb\times\GeV^{2(n-2)}$. (Note that for physical matrix elements this is compensated by momentum factors from wave functions, propagators, vertices and possibly dimensionful coupling constants, but here the matrix element is just equal to unity.) Note that the phase-space integration for the \ttt{template} and \ttt{template\_unity} matrix element methods is organized in the same way as it would be for the real $2\to n$ process. Since such a phase space parameterization is not optimized for the constant matrix element that is supplied instead, good convergence is not guaranteed. (Setting \ttt{?stratified = true} may be helpful here.) The possibility to call a dummy matrix element with this method allows to histogram spectra or structure functions: Choose a trivial process such as $uu\to dd$, select the \ttt{template\_unity} method, switch on structure functions for one (or both) beams, and generate events. The distribution of the final-state mass squared reflects the $x$ dependence of the selected structure function. Furthermore, the constant in the source code of the unit matrix elements can be easily modified by the user with their \fortran\ code in order to study customized matrix elements. Just rerun \whizard\ with the \ttt{--recompile} option after the modification of the matrix element code. Both methods, \ttt{template} and \ttt{template\_unity} will also work even if no \ocaml\ compiler is found or used and consequently the \oMega\ matrix elemente generator (cf. Sec.~\ref{sec:omega_me} is disable. The methods produce a process library for their corresponding processes, and a makefile, by which \whizard\ steers compilation and linking of the process source code. %%%%% \section{The O'Mega matrix elements} \label{sec:omega_me} \oMega\ is a subpackage of \whizard, written in \ocaml, which can produce matrix elements for a wide class of implemented physics models (cf. Sec.~\ref{sec:smandfriends} and \ref{sec:bsmmodels} for a list of all implemented physics models), and even almost arbitrary models when using external Lagrange level tools, cf. Chap.~\ref{chap:extmodels}. There are two different variants for matrix elements from \oMega: the first one is invoked as \begin{code} $method = "omega" \end{code} and is the default method for \whizard. It produces matrix element as \fortran\ code which is then compiled and linked. An alternative method, which for the moment is only available for the Standard Model and its variants as well models which are quite similar to the SM, e.g. the Two-Higgs doublet model or the Higgs-singlet extension. This method is taken when setting \begin{code} $method = "ovm" \end{code} The acronym \ttt{ovm} stands for \oMega\ Virtual Machine (OVM). The first (default) method (\ttt{omega}) of \oMega\ matrix elements produces \fortran\ code for the matrix elements,that is compiled by the same compiler with which \whizard\ has been compiled. The OVM method (\ttt{ovm}) generates an \ttt{ASCII} file with so called op code for operations. These are just numbers which tell what numerical operations are to be performed on momenta, wave functions and vertex expression in order to yield a complex number for the amplitude. The op codes are interpreted by the OVM in the same as a Java Virtual Machine. In both cases, a compiled \fortran\ is generated which for the \ttt{omega} method contains the full expression for the matrix element as \fortran\ code, while for the \ttt{ovm} method this is the driver file of the OVM. Hence, for the \ttt{ovm} method this file always has roughly the same size irrespective of the complexity of the process. For the \ttt{ovm} method, there will also be the \ttt{ASCII} file that contains the op codes, which has a name with an \ttt{.hbc} suffix: \ttt{.hbc}. For both \oMega\ methods, there will be a process library created as for the template matrix elements (cf. Sec.~\ref{sec:template_me}) named \ttt{default\_lib.f90} which can be given a user-defined name using the \ttt{library = ""} command. Again, for both methods \ttt{omega} and \ttt{ovm}, a makefile named \ttt{\_lib.makefile} is generated by which \whizard\ steers compilation, linking and clean-up of the process sources. This makefile can handily be adapted by the user in case she or he wants to modify the source code for the process (in the case of the source code method). Note that \whizard's default ME method via \oMega\ allows the user to specify many different options either globally for all processes in the \sindarin, or locally for each process separately in curly brackets behind the corresponding process definition. Examples are \begin{itemize} \item Restrictions for the matrix elements like the exclusion of intermediate resonances, the appearance of specific vertices or coupling constants in the matrix elments. For more details on this cf. Sec.~\ref{subsec:restrictions}. \item Choice of a specific scheme for the width of massive intermediate resonances, whether to use constant width, widths only in $s$-channel like kinematics (this is the default), a fudged-width scheme or the complex-mass scheme. The latter is actually steered as a specific scheme of the underlying model and not with a specific \oMega\ command. \item Choice of the electroweak gauge for the amplitude. The default is the unitary gauge. \end{itemize} With the exception of the restrictions steered by the \ttt{\$restrictions = ""} string expression, these options have to be set in their specific \oMega\ syntax verbatim via the string command \ttt{\$omega\_flags = ""}. %%%%% \section{Interface to GoSam} \label{sec:gosam_me} One of the supported methods for automated matrix elements from external providers is for the \gosam\ package. This program package which is a combination of \python\ scripts and \fortran\ libraries, allows both for tree and one-loop matrix elements (which is leading or next-to-leading order, depending on whether the corresponding process is allowed at the tree level or not). In principle, the advanced version of \gosam\ also allows for the evaluation of two-loop virtual matrix elements, however, this is currently not supported in \whizard. This method is invoked via the command \begin{code} $method = "gosam" \end{code} Of course, this will only work correctly of \gosam\ with all its subcomponents has been correctly found during configuration of \whizard\ and then subsequently correctly linked. In order to generate the tables for spin, flavor and color states for the corresponding process, first \oMega\ is called to provide \fortran\ code for the interfaces to all the metadata for the process(es) to be evaluated. Next, the \gosam\ \python\ script is automatically invoked that first checks for the necessary ingredients to produce, compile and link the \gosam\ matrix elements. These are the the \ttt{Qgraf} topology generator for the diagrams, \ttt{Form} to perform algebra, the \ttt{Samurai}, \ttt{AVHLoop}, \ttt{QCDLoop} and \ttt{Ninja} libraries for Passarino-Veltman reduction, one-loop tensor integrals etc. As a next step, \gosam\ automatically writes and executes a \ttt{configure} script, and then it exchanges the Binoth Les Houches accord (BLHA) contract files between \whizard\ and itself~\cite{Binoth:2010xt,Alioli:2013nda} to check whether it actually generate code for the demanded process at the given order. Note that the contract and answer files do not have to be written by the user by hand, but are generated automatically within the program work flow initiated by the original \sindarin\ script. \gosam\ then generates \fortran\ code for the different components of the processes, compiles it and links it into a library, which is then automatically accessible (as an external process library) from inside \whizard. The phase space setup and the integration as well as the LO (and NLO) event generation work then in exactly the same way as for \oMega\ matrix elements. As an NLO calculation consists of different components for the Born, the real correction, the virtual correction, the subtraction part and possible further components depending on the details of the calculation, there is the possible to separately choose the matrix element method for those components via the keywords \ttt{\$loop\_me\_method}, \ttt{\$real\_tree\_me\_method}, \ttt{\$correlation\_me\_method} etc. These keywords overwrite the master switch of the \ttt{\$method} keyword. For more information on the switches and details of the functionality of \gosam, cf. \url{http://gosam.hepforge.org}. %%%%% \section{Interface to Openloops} \label{sec:openloops_me} Very similar to the case of \gosam, cf. Sec.~\ref{sec:gosam_me}, is the case for \openloops\ matrix elements. Also here, first \oMega\ is called in order to provide an interface for the spin, flavor and color degrees of freedom for the corresponding process. Information exchange between \whizard\ and \openloops\ then works in the same automatic way as for \gosam\ via the BLHA interface. This matrix element method is invoked via \begin{code} $method = "openloops" \end{code} This again is the master switch that will tell \whizard\ to use \openloops\ for all components, while there are special keywords to tailor-make the setup for the different components of an NLO calculation (cf. Sec.~\ref{sec:gosam_me}. The main difference between \openloops\ and \gosam\ is that for \openloops\ there is no process code to be generated, compiled and linked for a process, but a precompiled library is called and linked, e.g. \ttt{ppllj} for the Drell-Yan process. Of course, this library has to be installed on the system, but if that is not the case, the user can execute the \openloops\ script in the source directory of \openloops\ to download, compile and link the corresponding dynamic library. This limits (for the moment) the usage of \openloops\ to processes where pre-existint libraries for that specific processes have been generated by the \openloops\ authors. A new improved generator for general process libraries for \openloops\ will get rid of that restriction. For more information on the installation, switches and details of the functionality of \openloops, cf. \url{http://openloops.hepforge.org}. %%%%% \section{Interface to Recola} \label{sec:recola_me} The third one-loop provider (OLP) for external matrix elements that is supported by \whizard, is \recola. In contrast to \gosam, cf. Sec.~\ref{sec:gosam_me}, and \openloops, cf. Sec.~\ref{sec:openloops_me}, \recola\ does not use a BLHA interface to exchange information with \whizard, but its own tailor-made C interoperable library interface to communicate to the Monte Carlo side. \recola\ matrix elements are called for via \begin{code} $method = "recola" \end{code} \recola\ uses a highly efficient algorithm to generate process code for LO and NLO SM amplitudes in a fully recursive manner. At the moment, the setup of the interface within \whizard\ does not allow to invoke more than one different process in \recola: this would lead to a repeated initialization of the main setup of \recola\ and would consequently crash it. It is foreseen in the future to have a safeguard mechanism inside \whizard\ in order to guarantee initialization of \recola\ only once, but this is not yet implemented. Further information on the installation, details and parameters of \recola\ can be found at \url{http://recola.hepforge.org}. %%%%% \section{Special applications} \label{sec:special_me} There are also special applications with combinations of matrix elements from different sources for dedicated purposes like e.g. for the matched top--anti-top threshold in $e^+e^-$. For this special application which depending on the order of the matching takes only \oMega\ matrix elements or at NLO combines amplitudes from \oMega\ and \openloops, is invoked by the method: \begin{code} $method = "threshold" \end{code} \newpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Implemented physics} \label{chap:physics} %%%%% \section{The hard interaction models} In this section, we give a brief overview over the different incarnations of models for the description of the realm of subatomic particles and their interactions inside \whizard. In Sec.~\ref{sec:smandfriends}, the Standard Model (SM) itself and straightforward extensions and modifications thereof in the gauge, fermionic and Higgs sector are described. Then, Sec.~\ref{sec:bsmmodels} gives a list and short description of all genuine beyond the SM models (BSM) that are currently implemented in \whizard\ and its matrix element generator \oMega. Additional models beyond that can be integrated and handled via the interfaces to external tools like \sarah\ and \FeynRules, or the universal model format \UFO, cf. Chap.~\ref{chap:extmodels}. %%%%%%%%%%%%%%% \subsection{The Standard Model and friends} \label{sec:smandfriends} %%%% \subsection{Beyond the Standard Model} \label{sec:bsmmodels} \begin{table} \begin{center} \begin{tabular}{|l|l|l|} \hline MODEL TYPE & with CKM matrix & trivial CKM \\ \hline\hline Yukawa test model & \tt{---} & \tt{Test} \\ \hline QED with $e,\mu,\tau,\gamma$ & \tt{---} & \tt{QED} \\ QCD with $d,u,s,c,b,t,g$ & \tt{---} & \tt{QCD} \\ Standard Model & \tt{SM\_CKM} & \tt{SM} \\ SM with anomalous gauge couplings & \tt{SM\_ac\_CKM} & \tt{SM\_ac} \\ SM with $Hgg$, $H\gamma\gamma$, $H\mu\mu$, $He^+e^-$ & \tt{SM\_Higgs\_CKM} & \tt{SM\_Higgs} \\ SM with bosonic dim-6 operators & \tt{---} & \tt{SM\_dim6} \\ SM with charge 4/3 top & \tt{---} & \tt{SM\_top} \\ SM with anomalous top couplings & \tt{---} & \tt{SM\_top\_anom} \\ SM with anomalous Higgs couplings & \tt{---} & \tt{SM\_rx}/\tt{NoH\_rx}/\tt{SM\_ul} \\\hline SM extensions for $VV$ scattering & \tt{---} & \tt{SSC}/\tt{AltH}/\tt{SSC\_2}/\tt{SSC\_AltT} \\\hline SM with $Z'$ & \tt{---} & \tt{Zprime} \\ \hline Two-Higgs Doublet Model & \tt{THDM\_CKM} & \tt{THDM} \\ \hline\hline MSSM & \tt{MSSM\_CKM} & \tt{MSSM} \\ \hline MSSM with gravitinos & \tt{---} & \tt{MSSM\_Grav} \\ \hline NMSSM & \tt{NMSSM\_CKM} & \tt{NMSSM} \\ \hline extended SUSY models & \tt{---} & \tt{PSSSM} \\ \hline\hline Littlest Higgs & \tt{---} & \tt{Littlest} \\ \hline Littlest Higgs with ungauged $U(1)$ & \tt{---} & \tt{Littlest\_Eta} \\ \hline Littlest Higgs with $T$ parity & \tt{---} & \tt{Littlest\_Tpar} \\ \hline Simplest Little Higgs (anomaly-free) & \tt{---} & \tt{Simplest} \\ \hline Simplest Little Higgs (universal) & \tt{---} & \tt{Simplest\_univ} \\ \hline\hline SM with graviton & \tt{---} & \tt{Xdim} \\ \hline UED & \tt{---} & \tt{UED} \\ \hline ``SQED'' with gravitino & \tt{---} & \tt{GravTest} \\ \hline Augmentable SM template & \tt{---} & \tt{Template} \\ \hline \end{tabular} \end{center} \caption{\label{tab:models} List of models available in \whizard. There are pure test models or models implemented for theoretical investigations, a long list of SM variants as well as a large number of BSM models.} \end{table} \subsubsection{Strongly Interacting Models and Composite Models} Higgsless models have been studied extensively before the Higgs boson discovery at the LHC Run I in 2012 in order to detect possible loopholes in the electroweak Higgs sector discovery potential of this collider. The Threesite Higgsless Model is one of the simplest incarnations of these models, and was one of the first BSM models beyond SUSY and Little Higgs models that have been implemented in \whizard~\cite{Speckner:2010zi}. It is also called the Minimal Higgsless Model (MHM)~\cite{Chivukula:2006cg} is a minimal deconstructed Higgsless model which contains only the first resonance in the tower of Kaluza-Klein modes of a Higgsless extra-dimensional model. It is a non-renormalizable, effective theory whose gauge group is an extension of the SM with an extra $SU(2)$ gauge group. The breaking of the extended electroweak gauge symmetry is accomplished by a set of nonlinear sigma fields which represent the effects of physics at a higher scale and make the theory nonrenormalizable. The physical vector boson spectrum contains the usual photon, $W^\pm$ and $Z$ bosons as well as a $W'^\pm$ and $Z'$ boson. Additionally, a new set of heavy fermions are introduced to accompany the new gauge group ``site'' which mix to form the physical eigenstates. This mixing is controlled by the small mixing parameter $\epsilon_L$ which is adjusted to satisfy constraints from precision observables, such as the S parameter~\cite{Chivukula:2005xm}. Here, additional weak gauge boson production at the LHC was one of the focus of the studies with \whizard~\cite{Ohl:2008ri}. \subsubsection{Supersymmetric Models} \whizard/\oMega\ was the first multi-leg matrix-element/event generator to include the full Minimal Supersymmetric Standard Model (MSSM), and also the NMSSM. The SUSY implementations in \whizard\ have been extensively tested~\cite{Ohl:2002jp,Reuter:2009ex}, and have been used for many theoretical and experimental studies (some prime examples being~\cite{Kalinowski:2008fk,Robens:2008sa,Hagiwara:2005wg}. \subsubsection{Little Higgs Models} \subsubsection{Inofficial models} There have been several models that have been included within the \whizard/\oMega\ framework but never found their way into the official release series. One famous example is the non-commutative extension of the SM, the NCSM. There have been several studies, e.g. simulations on the $s$-channel production of a $Z$ boson at the photon collider option of the ILC~\cite{Ohl:2004tn}. Also, the production of electroweak gauge bosons at the LHC in the framework of the NCSM have been studied~\cite{Ohl:2010zf}. %%%%%%%%%%%%%%% \section{The SUSY Les Houches Accord (SLHA) interface} \label{sec:slha} To be filled in ...~\cite{Skands:2003cj,AguilarSaavedra:2005pw,Allanach:2008qq}. The neutralino sector deserves special attention. After diagonalization of the mass matrix expresssed in terms of the gaugino and higgsino eigenstates, the resulting mass eigenvalues may be either negative or positive. In this case, two procedures can be followed. Either the masses are rendered positive and the associated mixing matrix gets purely imaginary entries or the masses are kept signed, the mixing matrix in this case being real. According to the SLHA agreement, the second option is adopted. For a specific eigenvalue, the phase is absorbed into the definition of the relevant eigenvector, rendering the mass negative. However, \whizard\ has not yet officially tested for negative masses. For external SUSY models (cf.~Chap.~\ref{chap:extmodels}) this means, that one must be careful using a SLHA file with explicit factors of the complex unity in the mixing matrix, and on the other hand, real and positive masses for the neutralinos. For the hard-coded SUSY models, this is completely handled internally. Especially Ref.~\cite{Hagiwara:2005wg} discusses the details of the neutralino (and chargino) mixing matrix. %%%%%%%%%%%%%%%% \section{Lepton Collider Beam Spectra} \label{sec:beamspectra} For the simulation of lepton collider beam spectra there are two dedicated tools, \circeone\ and \circetwo\ that have been written as in principle independent tools. Both attempt to describe the details of electron (and positron) beams in a realistic lepton collider environment. Due to the quest for achieving high peak luminosities at $e^+e^-$ machines, the goal is to make the spatial extension of the beam as small as possible but keeping the area of the beam roughly constant. This is achieved by forcing the beams in the final focus into the shape of a quasi-2D bunch. Due to the high charge density in that bunch, the bunch electron distribution is modified by classical electromagnetic radiation, so called {\em beamstrahlung}. The two \circe\ packages are intended to perform a simulation of this beamstrahlung and its consequences on the electron beam spectrum as realistic as possible. More details about the two packages can be found in their stand-alone documentations. We will discuss the basic features of lepton-collider beam simulations in the next two sections, including the technicalities of passing simulations of the machine beam setup to \whizard. This will be followed by a section on the simulation of photon collider spectra, included for historical reasons. %%%%% \subsection{\circeone} While the bunches in a linear collider cross only once, due to their small size they experience a strong beam-beam effect. There is a code to simulate the impact of this effect on luminosity and background, called \ttt{GuineaPig++}~\cite{Schulte:1998au,Schulte:1999tx,Schulte:2007zz}. This takes into account the details of the accelerator, the final focus etc. on the structure of the beam and the main features of the resulting energy spectrum of the electrons and positrons. It offers the state-of-the-art simulation of lepton-collider beam spectra as close as possible to reality. However, for many high-luminosity simulations, event files produced with \ttt{GuineaPig++} are usually too small, in the sense that not enough independent events are available for physics simulations. Lepton collider beam spectra do peak at the nominal beam energy ($\sqrt{s}/2$) of the collider, and feature very steeply falling tails. Such steeply falling distributions are very poorly mapped by histogrammed distributions with fixed bin widths. The main working assumption to handle such spectra are being followed within \circeone: \begin{enumerate} \label{circe1_assumptions} \item The beam spectra for the two beams $P_1$ and $P_2$ factorize (here $x_1$ and $x_2$ are the energy fractions of the two beams, respectively): \begin{equation*} D_{P_1P_2} (x_1, x_2) = D_{P_1} (x_1) \cdot D_{P_2} (x_2) \end{equation*} \item The peak is described with a delta distribution, and the tail with a power law: \begin{equation*} D(x) = d \cdot \delta(1-x) \; + \; c \cdot x^\alpha \, (1-x)^\beta \end{equation*} \end{enumerate} The two powers $\alpha$ and $\beta$ are the main coefficients that can be tuned in order to describe the spectrum with \circeone\ as close as possible as the original \ttt{GuineaPig++} spectrum. More details about how \circeone\ works and what it does can be found in its own write-up in \ttt{circe1/share/doc}. \subsection{\circetwo} The two conditions listed in \ref{circe1_assumptions} are too restrictive and hence insufficient to describe more complicated lepton-collider beam spectra, as they e.g. occur in the CLIC drive-beam design. Here, the two beams are highly correlated and also a power-law description does not give good enough precision for the tails. To deal with these problems, \circetwo\ starts with a two-dimensional histogram featuring factorized, but variable bin widths in order to simulate the steep parts of the distributions. The limited statistics from too small \ttt{GuineaPig++} event output files leads to correlated fluctuations that would leave strange artifacts in the distributions. To abandon them, Gaussian filters are applied to smooth out the correlated fluctuations. Here care has to be taken when going from the continuum in $x$ momentum fraction space to the corresponding \begin{figure} \centering \includegraphics{circe2-smoothing} \caption{\label{fig:circe2-smoothing} Smoothing the bin at the $x_{e^+} = 1$ boundary with Gaussian filters of 3 and 10 bins width compared to no smoothing.} \end{figure} boundaries: separate smoothing procedures are being applied to the bins in the continuum region and those in the boundary in order to avoid artificial unphysical beam energy spreads. Fig.~\ref{fig:circe2-smoothing} shows the smoothing of the distribution for the bin at the $x_{e^+} = 1$ boundary. The blue dots show the direct \ttt{GuineaPig++} output comprising the fluctuations due to the low statistics. Gaussian filters with widths of 3 and 10 bins, respectively, have been applied (orange and green dots, resp.). While there is still considerable fluctuation for 3 bin width Gaussian filtering, the distribution is perfectly smooth for 10 bin width. Hence, five bin widths seem a reasonable compromise for histograms with a total of 100 bins. Note that the bins are not equidistant, but shrink with a power law towards the $x_{e^-} = 1$ boundary on the right hand side of Fig.~\ref{fig:circe2-smoothing}. \whizard\ ships (inside its subpackage \circetwo) with prepared beam spectra ready to be used within \circetwo\ for the ILC beam spectra used in the ILC TDR~\cite{Behnke:2013xla,Baer:2013cma,Adolphsen:2013jya,Adolphsen:2013kya,Behnke:2013lya}. These comprise the designed staging energies of 200 GeV, 230 GeV, 250 GeV, 350 GeV, and 500 GeV. Note that all of these spectra up to now do not take polarization of the original beams on the beamstrahlung into account, but are polarization-averaged. For backwards compatibility, also the 500 GeV spectra for the TESLA design~\cite{AguilarSaavedra:2001rg,Richard:2001qm}, here both for polarized and polarization-averaged cases, are included. Correlated spectra for CLIC staging energies like 350 GeV, 1400 GeV and 3000 GeV are not yet (as of version 2.2.4) included in the \whizard\ distribution. In the following we describe how to obtain such files with the tools included in \whizard (resp. \circetwo). The procedure is equivalent to the so-called \ttt{lumi-linker} construction used by Timothy Barklow (SLAC) together with the legacy version \whizard\ttt{ 1.95}. The workflow to produce such files is to run \ttt{GuineaPig++} with the following input parameters: \begin{Code} do_lumi = 7; num_lumi = 100000000; num_lumi_eg = 100000000; num_lumi_gg = 100000000; \end{Code} This demands from \ttt{GuineaPig++} the generation of distributions for the $e^-e^+$, $e^\mp \gamma$, and $\gamma\gamma$ components of the beamstrahlung's spectrum, respectively. These are the files \ttt{lumi.ee.out}, \ttt{lumi.eg.out}, \ttt{lumi.ge.out}, and \ttt{lumi.gg.out}, respectively. These contain pairs $(E_1, E_2)$ of beam energies, {\em not} fractions of the original beam energy. Huge event numbers are out in here, as \ttt{GuineaPig++} will produce only a small fraction due to a very low generation efficiency. The next step is to transfer these output files from \ttt{GuineaPig++} into input files used with \circetwo. This is done by means of the tool \ttt{circe\_tool.opt} that is installed together with the \whizard\ main binary and libraries. The user should run this executable with the following input file: \begin{Code} { file="ilc500/ilc500.circe" # to be loaded by WHIZARD { design="ILC" roots=500 bins=100 scale=250 # E in [0,1] { pid/1=electron pid/2=positron pol=0 # unpolarized e-/e+ events="ilc500/lumi.ee.out" columns=2 # <= Guinea-Pig lumi = 1564.763360 # <= Guinea-Pig iterations = 10 # adapting bins smooth = 5 [0,1) [0,1) # Gaussian filter 5 bins smooth = 5 [1] [0,1) smooth = 5 [0,1) [1] } } } \end{Code} The first line defines the output file, that later can be read in into the beamstrahlung's description of \whizard\ (cf. below). Then, in the second line the design of the collider (here: ILC for 500 GeV center-of-mass energy, with the number of bins) is specified. The next line tells the tool to take the unpolarized case, then the \ttt{GuineaPig++} parameters (event file and luminosity) are set. In the last three lines, details concerning the adaptation of the simulation as well as the smoothing procedure are being specified: the number of iterations in the adaptation procedure, and for the smoothing with the Gaussian filter first in the continuum and then at the two edges of the spectrum. For more details confer the documentation in the \circetwo\ subpackage. This produces the corresponding input files that can be used within \whizard\ to describe beamstrahlung for lepton colliders, using a \sindarin\ input file like: \begin{Code} beams = e1, E1 => circe2 $circe2_file = "ilc500.circe" $circe2_design = "ILC" ?circe2_polarized = false \end{Code} %%%%% \subsection{Photon Collider Spectra} For details confer the complete write-up of the \circetwo\ subpackage. %%%%% \section{Transverse momentum for ISR photons} \label{sec:isr-photon-handler} The structure functions that describe the splitting of a beam particle into a particle pair, of which one enters the hard interaction and the other one is radiated, are defined and evaluated in the strict collinear approximation. In particular, this holds for the ISR structure function which describes the radiation of photons off a charged particle in the initial state. The ISR structure function that is used by \whizard\ is understood to be inclusive, i.e., it implicitly contains an integration over transverse momentum. This approach is to be used for computing a total cross section via \ttt{integrate}. In \whizard, it is possible to unfold this integration, as a transformation that is applied by \ttt{simulate} step, event by event. The resulting modified events will show a proper logarithmic momentum-transfer ($Q^2$) distribution for the radiated photons. The recoil is applied to the hard-interaction system, such that four-momentum and $\sqrt{\hat s}$ are conserved. The distribution is cut off by $Q_{\text{max}}^2$ (cf. \ttt{isr\_q\_max}) for large momentum transfer, and smoothly by the parton mass (cf.\ \ttt{isr\_mass}) for small momentum transfer. To activate this modification, set \begin{Code} ?isr_handler = true $isr_handler_mode = "recoil" \end{Code} before, or as an option to, the \ttt{simulate} command. Limitations: the current implementation of the $p_T$ modification works only for the symmetric double-ISR case, i.e., both beams have to be charged particles with identical mass (e.g., $e^+e^-$). The mode \ttt{recoil} generates exactly one photon per beam, i.e., it modifies the momentum of the single collinear photon that the ISR structure function implementation produces, for each beam. (It is foreseen that further modes or options will allow to generate multiple photons. Alternatively, the \pythia\ shower can be used to simulate multiple photons radiated from the initial state.) %%%%% \section{Transverse momentum for the EPA approximation} \label{sec:epa-beam-handler} For the equivalent-photon approximation (EPA), which is also defined in the collinear limit, recoil momentum can be inserted into generated events in an entirely analogous way. The appropriate settings are \begin{Code} ?epa_handler = true $epa_handler_mode = "recoil" \end{Code} Limitations: as for ISR, the current implementation of the $p_T$ modification works only for the symmetric double-EPA case. Both incoming particles of the hard process must be photons, while both beams must be charged particles with identical mass (e.g., $e^+e^-$). Furthermore, the current implementation does not respect the kinematical limit parameter \verb|epa_q_min|, it has to be set to zero. In effect, the lower $Q^2$ cutoff is determined by the beam-particle mass \verb|epa_mass|, and the upper cutoff is either given by $Q_{\text{max}}$ (the parameter \verb|epa_q_max|), or by the limit $\sqrt{s}$ if this is not set. It is possible to combine the ISR and EPA handlers, for processes where ISR is active for one of the beams, EPA for the other beam. For this scenario to work, both handler switches must be on, and both mode strings must coincide. The parameters are set separately for ISR and EPA, as described above. %%%%% \section{Resonances and continuum} \subsection{Complete matrix elements} Many elementary physical processes are composed of contributions that can be qualified as (multiply) \emph{resonant} or \emph{continuum}. For instance, the amplitude for the process $e^+e^-\to q\bar q q\bar q$, evaluated at tree level in perturbation theory, contains Feynman diagrams with zero, one, or two $W$ and $Z$ bosons as virtual lines. If the kinematical constraints allow this, two vector bosons can become simultaneously on-shell in part of phase space. To a first approximation, this situation is understood as $W^+W^-$ or $ZZ$ production with subsequent decay. The kinematical distributions show distinct resonances in the quark-pair spectra. Other graphs contain only one s-channel $W/Z$ boson, or none at all, such as graphs with $q\bar q$ production and subsequent gluon radiation, splitting into another $q\bar q$ pair. A \whizard\ declaration of the form \begin{Code} process q4 = e1, E1 => u, U, d, D \end{Code} produces the full set of graphs for the selected final state, which after squaring and integrating yields the exact tree-level result for the process. The result contains all doubly and singly resonant parts, with correct resonance shapes, as well as the continuum contribution and all interference. This is, to given order in perturbation theory, the best possible approximation to the true result. \subsection{Processes restricted to resonances} For an intuitive separation of a two-boson ``signal'' contribution, it is possible to restrict the set of graphs to a certain intermediate state. For instance, the declaration \begin{Code} process q4_zz = e1, E1 => u, U, d, D { $restrictions = "3+4~Z && 5+6~Z" } \end{Code} generates an amplitude that contains only those Feynman graphs where the specified quarks are connected to a $Z$ virtual line. The result may be understood as $ZZ$ production with subsequent decay, where the $Z$ resonances exhibit a Breit-Wigner shape. Combining this with the analogous $W^+W^-$ restricted process, the user can generate ``signal'' processes. Adding both ``signal'' cross sections $WW$ and $ZZ$ will result in a reasonable approximation to the exact tree-level cross section. The amplitude misses the single-resonant and continuum contributions, and the squared amplitude misses the interference terms, however. More importantly, the restricted processes as such are not gauge-invariant (with respect to the electroweak gauge group), and they are no longer dominant away from resonant kinematics. We therefore strongly recommend that such restricted processes are always accompanied by a cut setup that restricts the kinematics to an approximately on-shell pattern for both resonances. For instance: \begin{Code} cuts = all 85 GeV < M < 95 GeV [u:U] and all 85 GeV < M < 95 GeV [d:D] \end{Code} In this region, the gauge-dependent and continuum contributions are strictly subdominant. Away from the resonance(s), the results for a restricted process are meaningless, and the full process has to be computed instead. \subsection{Factorized processes} Another method for obtaining the signal contribution is a proper factorization into resonance production and decay. We would have to generate a production process and two decay processes: \begin{Code} process z_uu = Z => u, U process z_dd = Z => d, D process zz = e1, E1 => Z, Z \end{Code} All three processes must be integrated. The integration results are partial decay widths and the $ZZ$ production cross section, respectively. (Note that cut expressions in \sindarin\ apply to all integrations, so make sure that no production-process cuts are active when integrating the decay processes.) During a later event-generation step, the $Z$ decays can then be activated by declaring the $Z$ as unstable, \begin{Code} unstable Z (z_uu, z_dd) \end{Code} and then simulating the production process \begin{Code} simulate (zz) \end{Code} The generated events will consist of four-fermion final states, including all combinations of both decay modes. It is important to note that in this setup, the invariant $u\bar u$ and $d\bar d$ masses will be always \emph{exactly} equal to the $Z$ mass. There is no Breit-Wigner shape involved. However, in this approximation the results are gauge-invariant, as there is no off-shell contribution involved. For further details on factorized processes and spin correlations, cf.\ Sec.~\ref{sec:spin-correlations}. \subsection{Resonance insertion in the event record} From the above discussion, we may conclude that it is always preferable to compute the complete process for a given final state, as long as this is computationally feasible. However, in the simulation step this approach also has a drawback. Namely, if a parton-shower module (see below) is switched on, the parton-shower algorithm relies on event details in order to determine the radiation pattern of gluons and further splitting. In the generated event records, the full-process events carry the signature of non-resonant continuum production with no intermediate resonances. The parton shower will thus start the evolution at the process energy scale, the total available energy. By contrast, for an electroweak production and decay process, the evolution should start only at the vector boson mass, $m_Z$. In effect, even though the resonant contribution of $WW$ and $ZZ$ constitutes the bulk of the cross section, the radiation pattern follows the dynamics of four-quark continuum production. In general, the number of radiated hadrons will be too high. \begin{figure} \begin{center} \includegraphics[width=.41\textwidth]{resonance_e_gam} \includegraphics[width=.41\textwidth]{resonance_n_charged} \\ \includegraphics[width=.41\textwidth]{resonance_n_hadron} \includegraphics[width=.41\textwidth]{resonance_n_particles} \\ \includegraphics[width=.41\textwidth]{resonance_n_photons} \includegraphics[width=.41\textwidth]{resonance_n_visible} \end{center} \caption{The process $e^+e^- \to jjjj$ at 250 GeV center-of-mass energy is compared transferring the partonic events naively to the parton shower, i.e. without respecting any intermediate resonances (red lines). The blue lines show the process factorized into $WW$ production and decay, where the shower knows the origin of the two jet pairs. The orange and dark green lines show the resonance treatment as mentioned in the text, with \ttt{resonance\_on\_shell\_limit = 1} and \ttt{= 4}, respectively. \pythiasix\ parton shower and hadronization with the OPAL tune have been used. The observables are: photon energy distribution and number of charged tracks (upper line left/right, number of hadrons and total number of particles (middle left/right), and number of photons and neutral particles (lower line left/right).} \end{figure} To overcome this problem, there is a refinement of the process description available in \whizard. By modifying the process declaration to \begin{Code} ?resonance_history = true resonance_on_shell_limit = 4 process q4 = e1, E1 => u, U, d, D \end{Code} we advise the program to produce not just the complete matrix element, but also all possible restricted matrix elements containing resonant intermediate states. This has no effect at all on the integration step, and thus on the total cross section. However, when subsequently events are generated with this setting, the program checks, for each event, the kinematics and determines the set of potentially resonant contributions. The criterion is whether the off-shellness of a particular would-be resonance is less than the resonance width multiplied by the value of \verb|resonance_on_shell_limit| (default value $=4$). For the set of resonance histories which pass this criterion (which can be empty), their respective squared matrix element is related to the full-process matrix element. The ratio is interpreted as a probability. The random-number generator then selects one or none of the resonance histories, and modifies the event record accordingly. In effect, for an appropriate fraction of the events, depending on the kinematics, the parton-shower module is provided with resonance information, so it can adjust the radiation pattern accordingly. It has to be mentioned that generating the matrix-element code for all possible resonance histories takes additional computing resources. In the current default setup, this feature is switched off. It has to be explicitly activated via the \verb|?resonance_history| flag. Also, the feature can be activated or deactivated individually for each process, such as in \begin{Code} ?resonance_history = true process q4_with_res = e1, E1 => u, U, d, D { ?resonance_history = true } process q4_wo_res = e1, E1 => u, U, d, D { ?resonance_history = false } \end{Code} If the flag is \verb|false| for a process, no resonance code will be generated. Similarly, the flag has to be globally or locally active when \verb|simulate| is called, such that the feature takes effect for event generation. There are two additional parameters that can fine-tune the conditions for resonance insertion in the event record. Firstly, the parameter \verb|resonance_on_shell_turnoff|, if nonzero, enables a Gaussian suppression of the probability for resonance insertion. For instance, setting \begin{Code} ?resonance_history = true resonance_on_shell_turnoff = 4 resonance_on_shell_limit = 8 \end{Code} will reduce the probability for the event to be qualified as resonant by $e^{-1}= 37\,\%$ if the kinematics is off-shell by four units of the width, and by $e^{-4}=2\,\%$ at eight units of the width. Beyond this point, the setting of the \verb|resonance_on_shell_limit| parameter eliminates resonance insertion altogether. In effect, the resonance-background transition is realized in a smooth way. Secondly, within the resonant-kinematics range the probability for qualifying the event as background can be reduced by the parameter \verb|resonance_background_factor| (default value $=1$) to a number between zero and one. Setting this to zero means that the event will be necessarily qualified as resonant, if it falls within the resonant-kinematics range. Note that if an event, by the above mechanism, is identified as following a certain resonance history, the assigned color flow will be chosen to match the resonance history, not the complete matrix element. This may result in a reassignment of color flow with respect to the original partonic event. Finally, we mention the order of execution: any additional matrix element code is compiled and linked when \verb|compile| is executed for the processes in question. If this command is omitted, the \verb|simulate| command will trigger compilation. \section{Parton showers and Hadronization} In order to produce sensible events, final state QCD (and also QED) radiation has to be considered as well as the binding of strongly interacting partons into mesons and baryons. Furthermore, final state hadronic resonances undergo subsequent decays into those particles showing up in (or traversing) the detector. The latter are mostly pions, kaons, photons, electrons and muons. The physics associated with these topics can be divided into the perturbative part which is the regime of the parton shower, and the non-perturbative part which is the regime for the hadronization. \whizard\ comes with its own two different parton shower implementations, an analytic and a so-called $k_T$-ordered parton shower that will be detailed in the next section. Note that in general it is not advisable to use different shower and hadronization methods, or in other words, when using shower and hadronization methods from different programs these would have to be tuned together again with the corresponding data. Parton showers are approximations to full matrix elements taking only the leading color flow into account, and neglecting all interferences between different amplitudes leading to the same exclusive final state. They rely on the QCD (and QED) splitting functions to describe the emissions of partons off other partons. This is encoded in the so-called Sudakov form factor~\cite{Sudakov:1954sw}: \begin{equation*} \Delta( t_1, t_2) = \exp \left[ \int\limits_{t_1}^{t_2} \mbox{d} t \int\limits_{z_-}^{z_+} \mbox{d} z \frac{\alpha_s}{2 \pi t} P(z) \right] \end{equation*} This gives the probability for a parton to evolve from scale $t_2$ to $t_1$ without any further emissions of partons. $t$ is the evolution parameter of the shower, which can be a parton energy, an emission angle, a virtuality, a transverse momentum etc. The variable $z$ relates the two partons after the branching, with the most common choice being the ratio of energies of the parton after and before the branching. For final-state radiation brachings occur after the hard interaction, the evolution of the shower starts at the scale of the hard interaction, $t \sim \hat{s}$, down to a cut-off scale $t = t_{\text{cut}}$ that marks the transition to the non-perturbative regime of hadronization. In the space-like evolution for the initial-state shower, the evolution is from a cut-off representing the factorization scale for the parton distribution functions (PDFs) to the inverse of the hard process scale, $-\hat{s}$. Technically, this evolution is then backwards in (shower) time~\cite{Sjostrand:1985xi}, leading to the necessity to include the PDFs in the Sudakov factors. The main switches for the shower and hadronization which are realized as transformations on the partonic events within \whizard\ are \ttt{?allow\_shower} and \ttt{?allow\_hadronization}, which are true by default and only there for technical reasons. Next, different shower and hadronization methods can be chosen within \whizard: \begin{code} $shower_method = "WHIZARD" $hadronization_method = "PYTHIA6" \end{code} The snippet above shows the default choices in \whizard\, namely \whizard's intrinsic parton shower, but \pythiasix\ as hadronization tool. (Note that \whizard\ does not have its own hadronization module yet.) The usage of \pythiasix\ for showering and hadronization will be explained in Sec.~\ref{sec:pythia6}, while the two different implementations of the \whizard\ homebrew parton showers are discussed in Sec.~\ref{sec:ktordered} and~\ref{sec:analytic}, respectively. %%%%% \subsection{The $k_T$-ordered parton shower} \label{sec:ktordered} %%%%% \subsection{The analytic parton shower} \label{sec:analytic} %%%%% \subsection{Parton shower and hadronization from \pythiasix} \label{sec:pythia6} Development of the \pythiasix\ generator for parton shower and hadronization (the \fortran\ version) has been discontinued by the authors several years ago. Hence, the final release of that program is frozen. This allowed to ship this final version, v6.427, with the \whizard\ distribution without the need of updating it all the time. One of the main reasons for that inclusion -- besides having the standard tool for showering and hadronization for decays at hand -- is to allow for backwards validation within \whizard\ particularly for the event samples generated for the development of linear collider physics: first for TESLA, JLC and NLC, and later on for the Conceptual and Technical Design Report for ILC, for the Conceptual Design Report for CLIC as well as for the Letters of Intent for the LC detectors, ILD and SiD. Usually, an external parton shower and hadronization program (PS) is steered via the transfer of event files that are given to the PS via LHE events, while the PS program then produces hadron level events, usually in HepMC format. These can then be directed towards a full or fast detector simulation program. As \pythiasix\ has been completely integrated inside the \whizard\ framework, the showered or more general hadron level events can be returned to and kept inside \whizard's internal event record, and hence be used in \whizard's internal event analysis. In that way, the events can be also written out in event formats that are not supported by \pythiasix, e.g. \ttt{LCIO} via the output capabilities of \whizard. There are several switches to directly steer \pythiasix\ (the values in brackets correspond to the \pythiasix\ variables): \begin{code} ps_mass_cutoff = 1 GeV [PARJ(82)] ps_fsr_lambda = 0.29 GeV [PARP(72)] ps_isr_lambda = 0.29 GeV [PARP(61)] ps_max_n_flavors = 5 [MSTJ(45)] ?ps_isr_alphas_running = true [MSTP(64)] ?ps_fsr_alphas_running = true [MSTJ(44)] ps_fixed_alphas = 0.2 [PARU(111)] ?ps_isr_angular_ordered = true [MSTP(62)] ps_isr_primordial_kt_width = 1.5 GeV [PARP(91)] ps_isr_primordial_kt_cutoff = 5.0 GeV [PARP(93)] ps_isr_z_cutoff = 0.999 [1-PARP(66)] ps_isr_minenergy = 2 GeV [PARP(65)] ?ps_isr_only_onshell_emitted_partons = true [MSTP(63)] \end{code} The values given above are the default values. The first value corresponds to the \pythiasix\ parameter \ttt{PARJ(82)}, its squared being the minimal virtuality that is allowed for the parton shower, i.e. the cross-over to the hadronization. The same parameter is used also for the \whizard\ showers. \ttt{ps\_fsr\_lambda} is the equivalent of \ttt{PARP(72)} and is the $\Lambda_{\text{QCD}}$ for the final state shower. The corresponding variable for the initial state shower is called \ttt{PARP(61)} in \pythiasix. By the next variable (\ttt{MSTJ(45)}), the maximal number of flavors produced in splittings in the shower is given, together with the number of active flavors in the running of $\alpha_s$. \ttt{?ps\_isr\_alphas\_running} which corresponds to \ttt{MSTP(64)} in \pythiasix\ determines whether or net a running $\alpha_s$ is taken in the space-like initial state showers. The same variable for the final state shower is \ttt{MSTJ(44)}. For fixed $\alpha_s$, the default value is given by \ttt{ps\_fixed\_alpha}, corresponding to \ttt{PARU(111)}. \ttt{MSTP(62)} determines whether the ISR shower is angular order, i.e. whether angles are increasing towards the hard interaction. This is per default true, and set in the variable \ttt{?ps\_isr\_angular\_ordered}. The width of the distribution for the primordial (intrinsic) $k_T$ distribution (which is a non-perturbative quantity) is the \pythiasix\ variable \ttt{PARP(91)}, while in \whizard\ it is given by \ttt{pythia\_isr\_primordial\_kt\_width}. The next variable (\ttt{PARP(93}) gives the upper cutoff for that distribution, which is 5 GeV per default. For splitting in space-like showers, there is a cutoff on the $z$ variable named \ttt{ps\_isr\_z\_cutoff} in \whizard. This corresponds to one minus the value of the \pythiasix\ parameter \ttt{PARP(66)}. \ttt{PARP(65)}, on the other hand, gives the minimal (effective) energy for a time-like or on-shell emitted parton on a space-like QCD shower, given by the \sindarin\ parameter \ttt{ps\_isr\_minenergy}. Whether or not partons emitted from space-like showers are allowed to be only on-shell is given by \ttt{?ps\_isr\_only\_onshell\_emitted\_partons}, \ttt{MSTP(63)} in \pythiasix\ language. For more details confer the \pythiasix\ manual~\cite{Sjostrand:2006za}. Any other non-standard \pythiasix\ parameter can be fed into the parton shower via the string variable \begin{code} $ps_PYTHIA_PYGIVE = "...." \end{code} Variables set here get preference over the ones set explicitly by dedicated \sindarin\ commands. For example, the OPAL tune for hadronic final states can be set via: \begin{code} $ps_PYTHIA_PYGIVE = "MSTJ(28)=0; PMAS(25,1)=120.; PMAS(25,2)=0.3605E-02; MSTJ(41)=2; MSTU(22)=2000; PARJ(21)=0.40000; PARJ(41)=0.11000; PARJ(42)=0.52000; PARJ(81)=0.25000; PARJ(82)=1.90000; MSTJ(11)=3; PARJ(54)=-0.03100; PARJ(55)=-0.00200; PARJ(1)=0.08500; PARJ(3)=0.45000; PARJ(4)=0.02500; PARJ(2)=0.31000; PARJ(11)=0.60000; PARJ(12)=0.40000; PARJ(13)=0.72000; PARJ(14)=0.43000; PARJ(15)=0.08000; PARJ(16)=0.08000; PARJ(17)=0.17000; MSTP(3)=1;MSTP(71)=1" \end{code} \vspace{0.5cm} A very common error that appears quite often when using \pythiasix\ for SUSY or any other model having a stable particle that serves as a possible Dark Matter candidate, is the following warning/error message: \begin{Code} Advisory warning type 3 given after 0 PYEXEC calls: (PYRESD:) Failed to decay particle 1000022 with mass 15.000 ****************************************************************************** ****************************************************************************** *** FATAL ERROR: Simulation: failed to generate valid event after 10000 tries ****************************************************************************** ****************************************************************************** \end{Code} In that case, \pythiasix\ gets a stable particle (here the lightest neutralino with the PDG code 1000022) handed over and does not know what to do with it. Particularly, it wants to treat it as a heavy resonance which should be decayed, but does not know how do that. After a certain number of tries (in the example abobe 10k), \whizard\ ends with a fatal error telling the user that the event transformation for the parton shower in the simulation has failed without producing a valid event. The solution to work around that problem is to let \pythiasix\ know that the neutralino (or any other DM candidate) is stable by means of \begin{code} $ps_PYTHIA_PYGIVE = "MDCY(C1000022,1)=0" \end{code} Here, 1000022 has to be replaced by the stable dark matter candidate or long-lived particle in the user's favorite model. Also note that with other options being passed to \pythiasix\, the \ttt{MDCY} option above has to be added to an existing \ttt{\$ps\_PYTHIA\_PYGIVE} command separated by a semicolon. %%%%% \subsection{Parton shower and hadronization from \pythiaeight} \subsection{Other tools for parton shower and hadronization} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{More on Event Generation} \label{chap:events} In order to perform a physics analysis with \whizard\ one has to generate events. This seems to be a trivial statement, but as there have been any questions like "My \whizard\ does not produce plots -- what has gone wrong?" we believe that repeating that rule is worthwile. Of course, it is not mandatory to use \whizard's own analysis set-up, the user can always choose to just generate events and use his/her own analysis package like \ttt{ROOT}, or \ttt{TopDrawer}, or you name it for the analysis. Accordingly, we first start to describe how to generate events and what options there are -- different event formats, renaming output files, using weighted or unweighted events with different normalizations. How to re-use and manipulate already generated event samples, how to limit the number of events per file, etc. etc. \section{Event generation} To explain how event generation works, we again take our favourite example, $e^+e^- \to \mu^+ \mu^-$, \begin{verbatim} process eemm = e1, E1 => e2, E2 \end{verbatim} The command to trigger generation of events is \ttt{simulate () \{ \}}, so in our case -- neglecting any options for now -- simply: \begin{verbatim} simulate (eemm) \end{verbatim} When you run this \sindarin\ file you will experience a fatal error: \ttt{FATAL ERROR: Colliding beams: sqrts is zero (please set sqrts)}. This is because \whizard\ needs to compile and integrate the process \ttt{eemm} first before event simulation, because it needs the information of the corresponding cross section, phase space parameterization and grids. It does both automatically, but you have to provide \whizard\ with the beam setup, or at least with the center-of-momentum energy. A corresponding \ttt{integrate} command like \begin{verbatim} sqrts = 500 GeV integrate (eemm) { iterations = 3:10000 } \end{verbatim} obviously has to appear {\em before} the corresponding \ttt{simulate} command (otherwise you would be punished by the same error message as before). Putting things in the correct order results in an output like: \begin{footnotesize} \begin{verbatim} | Reading model file '/usr/local/share/whizard/models/SM.mdl' | Preloaded model: SM | Process library 'default_lib': initialized | Preloaded library: default_lib | Reading commands from file 'bla.sin' | Process library 'default_lib': recorded process 'eemm' sqrts = 5.000000000000E+02 | Integrate: current process library needs compilation | Process library 'default_lib': compiling ... | Process library 'default_lib': keeping makefile | Process library 'default_lib': keeping driver | Process library 'default_lib': active | Process library 'default_lib': ... success. | Integrate: compilation done | RNG: Initializing TAO random-number generator | RNG: Setting seed for random-number generator to 29912 | Initializing integration for process eemm: | ------------------------------------------------------------------------ | Process [scattering]: 'eemm' | Library name = 'default_lib' | Process index = 1 | Process components: | 1: 'eemm_i1': e-, e+ => mu-, mu+ [omega] | ------------------------------------------------------------------------ | Beam structure: [any particles] | Beam data (collision): | e- (mass = 5.1099700E-04 GeV) | e+ (mass = 5.1099700E-04 GeV) | sqrts = 5.000000000000E+02 GeV | Phase space: generating configuration ... | Phase space: ... success. | Phase space: writing configuration file 'eemm_i1.phs' | Phase space: 2 channels, 2 dimensions | Phase space: found 2 channels, collected in 2 groves. | Phase space: Using 2 equivalences between channels. | Phase space: wood Warning: No cuts have been defined. | OpenMP: Using 8 threads | Starting integration for process 'eemm' | Integrate: iterations = 3:10000 | Integrator: 2 chains, 2 channels, 2 dimensions | Integrator: Using VAMP channel equivalences | Integrator: 10000 initial calls, 20 bins, stratified = T | Integrator: VAMP |=============================================================================| | It Calls Integral[fb] Error[fb] Err[%] Acc Eff[%] Chi2 N[It] | |=============================================================================| 1 9216 4.2833237E+02 7.14E-02 0.02 0.02* 40.29 2 9216 4.2829071E+02 7.08E-02 0.02 0.02* 40.29 3 9216 4.2838304E+02 7.04E-02 0.02 0.02* 40.29 |-----------------------------------------------------------------------------| 3 27648 4.2833558E+02 4.09E-02 0.01 0.02 40.29 0.43 3 |=============================================================================| | Time estimate for generating 10000 events: 0d:00h:00m:04s | Creating integration history display eemm-history.ps and eemm-history.pdf | Starting simulation for process 'eemm' | Simulate: using integration grids from file 'eemm_m1.vg' | RNG: Initializing TAO random-number generator | RNG: Setting seed for random-number generator to 29913 | OpenMP: Using 8 threads | Simulation: requested number of events = 0 | corr. to luminosity [fb-1] = 0.0000E+00 | Events: writing to raw file 'eemm.evx' | Events: generating 0 unweighted, unpolarized events ... | Events: event normalization mode '1' | ... event sample complete. | Events: closing raw file 'eemm.evx' | There were no errors and 1 warning(s). | WHIZARD run finished. |=============================================================================| \end{verbatim} \end{footnotesize} So, \whizard\ tells you that it has entered simulation mode, but besides this, it has not done anything. The next step is that you have to demand event generation -- there are two ways to do this: you could either specify a certain number, say 42, of events you want to have generated by \whizard, or you could provide a number for an integrated luminosity of some experiment. (Note, that if you choose to take both options, \whizard\ will take the one which gives the larger event sample. This, of course, depends on the given process(es) -- as well as cuts -- and its corresponding cross section(s).) The first of these options is set with the command: \ttt{n\_events = }, the second with \ttt{luminosity = }. Another important point already stated several times in the manual is that \whizard\ follows the commands in the steering \sindarin\ file in a chronological order. Hence, a given number of events or luminosity {\em after} a \ttt{simulate} command will be ignored -- or are relevant only for any \ttt{simulate} command potentially following further down in the \sindarin\ file. So, in our case, try: \begin{verbatim} n_events = 500 luminosity = 10 simulate (eemm) \end{verbatim} Per default, numbers for integrated luminosity are understood as inverse femtobarn. So, for the cross section above this would correspond to 4283 events, clearly superseding the demand for 500 events. After reducing the luminosity number from ten to one inverse femtobarn, 500 is the larger number of events taken by \whizard\ for event generation. Now \whizard\ tells you: \begin{verbatim} | Simulation: requested number of events = 500 | corr. to luminosity [fb-1] = 1.1673E+00 | Events: reading from raw file 'eemm.evx' | Events: reading 500 unweighted, unpolarized events ... | Events: event normalization mode '1' | ... event file terminates after 0 events. | Events: appending to raw file 'eemm.evx' | Generating remaining 500 events ... | ... event sample complete. | Events: closing raw file 'eemm.evx' \end{verbatim} I.e., it evaluates the luminosity to which the sample of 500 events would correspond to, which is now, of course, bigger than the $1 \fb^{-1}$ explicitly given for the luminosity. Furthermore, you can read off that a file \ttt{whizard.evx} has been generated, containing the demanded 500 events. (It was there before containing zero events, because to \ttt{n\_events} or \ttt{luminosity} value had been set. \whizard\ then tried to get the events first from file before generating new ones). Files with the suffix \ttt{.evx} are binary format event files, using a machine-dependent \whizard-specific event file format. Before we list the event formats supported by \whizard, the next two sections will tell you more about unweighted and weighted events as well as different possibilities to normalize events in \whizard. As already explained for the libraries, as well as the phase space and grid files in Chap.~\ref{chap:sindarin}, \whizard\ is trying to re-use as much information as possible. This is of course also true for the event files. There are special MD5 check sums testing the integrity and compatibility of the event files. If you demand for a process for which an event file already exists (as in the example above, though it was empty) equally many or less events than generated before, \whizard\ will not generate again but re-use the existing events (as already explained, the events are stored in a \whizard-own binary event format, i.e. in a so-called \ttt{.evx} file. If you suppress generation of that file, as will be described in subsection \ref{sec:eventformats} then \whizard\ has to generate events all the time). From version v2.2.0 of \whizard\ on, the program is also able to read in event from different event formats. However, most event formats do not contain as many information as \whizard's internal format, and a complete reconstruction of the events might not be possible. Re-using event files is very practical for doing several different analyses with the same data, especially if there are many and big data samples. Consider the case, there is an event file with 200 events, and you now ask \whizard\ to generate 300 events, then it will re-use the 200 events (if MD5 check sums are OK!), generate the remaining 100 events and append them to the existing file. If the user for some reason, however, wants to regenerate events (i.e. ignoring possibly existing events), there is the command option \ttt{whizard --rebuild-events}. %%%%%%%%% \section{Unweighted and weighted events} \whizard\ is able to generate unweighted events, i.e. events that are distributed uniformly and each contribute with the same event weight to the whole sample. This is done by mapping out the phase space of the process under consideration according to its different phase space channels (which each get their own weights), and then unweighting the sample of weighted events. Only a sample of unweighted events could in principle be compared to a real data sample from some experiment. The seventh column in the \whizard\ iteration/adaptation procedure tells you about the efficiency of the grids, i.e. how well the phase space is mapped to a flat function. The better this is achieved, the higher the efficiency becomes, and the closer the weights of the different phase space channels are to uniformity. This means, for higher efficiency less weighted events ("calls") are needed to generate a single unweighted event. An efficiency of 10 \% means that ten weighted events are needed to generate one single unweighted event. After the integration is done, \whizard\ uses the duration of calls during the adaptation to estimate a time interval needed to generate 10,000 unweighted events. The ability of the adaptive multi-channel Monte Carlo decreases with the number of integrations, i.e. with the number of final state particles. Adding more and more final state particles in general also increases the complexity of phase space, especially its singularity structure. For a $2 \to 2$ process the efficiency is roughly of the order of several tens of per cent. As a rule of thumb, one can say that with every additional pair of final state particle the average efficiency one can achieve decreases by a factor of five to ten. The default of \whizard\ is to generate {\em unweighted} events. One can use the logical variable \ttt{?unweighted = false} to disable unweighting and generate weighted events. (The command \ttt{?unweighted = true} is a tautology, because \ttt{true} is the default for this variable.) Note that again this command has to appear {\em before} the corresponding \ttt{simulate} command, otherwise it will be ignored or effective only for any \ttt{simulate} command appearing later in the \sindarin\ file. In the unweighted procedure, \whizard\ is keeping track of the highest weight that has been appeared during the adaptation, and the efficiency for the unweighting has been estimated from the average value of the sampling function compared to the maximum value. In principle, during event generation no events should be generated whose sampling function value exceeds the maximum function value encountered during the grid adaptation. Sometimes, however, there are numerical fluctuations and such events are happening. They are called {\em excess events}. \whizard\ does keep track of these excess events during event generation and will report about them, e.g.: \begin{code} Warning: Encountered events with excess weight: 9 events ( 0.090 %) | Maximum excess weight = 6.083E-01 | Average excess weight = 2.112E-04 \end{code} Whenever in an event generation excess events appear, this shows that the adaptation of the sampling function has not been perfect. When the number of excess weights is a finite number of percent, you should inspect the phase-space setup and try to improve its settings to get a better adaptation. Generating \emph{weighted} events is, of course, much faster if the same number of events is requested. Each event carries a weight factor which is taken into account for any internal analysis (histograms), and written to file if an external file format has been selected. The file format must support event weights. In a weighted event sample, there is typically a fraction of events which effectively have weight zero, namely those that have been created by the phase-space sampler but do not pass the requested cuts. In the default setup, those events are silently dropped, such that the events written to file or available for analysis all have nonzero weight. However, dropping such events affects the overall normalization. If this has happened, the program will issue a warning of the form \begin{code} | Dropped events (weight zero) = 1142 (total 2142) Warning: All event weights must be rescaled by f = 4.66853408E-01 \end{code} This factor has to be applied by hand to any external event files (and to internally generated histograms). The program cannot include the factor in the event records, because it is known only after all events have been generated. To avoid this problem, there is the logical flag \ttt{?keep\_failed\_events} which tells \whizard\ not to drop events with weight zero. The normalization will be correct, but the event sample will include invalid events which have to be vetoed by their zero weight, before any operations on the event record are performed. %%%%%%%%% \section{Choice on event normalizations} There are basically four different choices to normalize event weights ($\braket{\ldots}$ denotes the average): \begin{enumerate} \item $\braket{w_i} = 1$, \qquad\qquad $\Braket{\sum_i w_i} = N$ \item $\braket{w_i} = \sigma$, \qquad\qquad $\Braket{\sum_i w_i} = N \times \sigma$ \item $\braket{w_i} = 1/N$, \quad\qquad $\Braket{\sum_i w_i} = 1$ \item $\braket{w_i} = \sigma/N$, \quad\qquad $\Braket{\sum_i w_i} = \sigma$ \end{enumerate} So the four options are to have the average weight equal to unity, to the cross section of the corresponding process, to one over the number of events, or the cross section over the event calls. In these four cases, the event weights sum up to the event number, the event number times the cross section, to unity, and to the cross section, respectively. Note that neither of these really guarantees that all event weights individually lie in the interval $0 \leq w_i \leq 1$. The user can steer the normalization of events by using in \sindarin\ input files the string variable \ttt{\$sample\_normalization}. The default is \ttt{\$sample\_normalization = "auto"}, which uses option 1 for unweighted and 2 for weighted events, respectively. Note that this is also what the Les Houches Event Format (LHEF) demands for both types of events. This is \whizard's preferred mode, also for the reason, that event normalizations are independent from the number of events. Hence, event samples can be cut or expanded without further need to adjust the normalization. The unit normalization (option 1) can be switched on also for weighted events by setting the event normalization variable equal to \ttt{"1"}. Option 2 can be demanded by setting \ttt{\$sample\_normalization = "sigma"}. Options 3 and 4 can be set by \ttt{"1/n"} and \ttt{"sigma/n"}, respectively. \whizard\ accepts small and capital letters for these expressions. In the following section we show some examples when discussing the different event formats available in \whizard. %%%%%%%%% \section{Event selection} The \ttt{selection} expression (cf.\ Sec.~\ref{subsec:analysis}) reduces the event sample during generation or rescanning, selecting only events for which the expression evaluates to \ttt{true}. Apart from internal analysis, the selection also applies to writing external files. For instance, the following code generates a $e^+e^-\to W^+W^-$ sample with longitudinally polarized $W$ bosons only: \begin{footnotesize} \begin{verbatim} process ww = "e+", "e-" => "W-", "W+" polarized "W+" polarized "W-" ?polarized_events = true sqrts = 500 selection = all Hel == 0 ["W+":"W-"] simulate (ww) { n_events = 1000 } \end{verbatim} \end{footnotesize} The number of events that end up in the sample on file is equal to the number of events with longitudinally polarized $W$s in the generated sample, so the file will contain less than 1000 events. %%%%%%%%% \section{Supported event formats} \label{sec:eventformats} Event formats can either be distinguished whether they are plain text (i.e. ASCII) formats or binary formats. Besides this, one can classify event formats according to whether they are natively supported by \whizard\ or need some external program or library to be linked. Table~\ref{tab:eventformats} gives a complete list of all event formats available in \whizard. The second column shows whether these are ASCII or binary formats, the third column contains brief remarks about the corresponding format, while the last column tells whether external programs or libraries are needed (which is the case only for the HepMC formats). \begin{table} \begin{center} \begin{tabular}{|l||l|l|r|}\hline Format & Type & remark & ext. \\\hline ascii & ASCII & \whizard\ verbose format & no \\ Athena & ASCII & variant of HEPEVT & no \\ debug & ASCII & most verbose \whizard\ format & no \\ evx & binary & \whizard's home-brew & no \\ HepMC & ASCII & HepMC format & yes \\ HEPEVT & ASCII & \whizard~1 style & no \\ LCIO & ASCII & LCIO format & yes \\ LHA & ASCII & \whizard~1/old Les Houches style &no \\ LHEF & ASCII & Les Houches accord compliant & no \\ long & ASCII & variant of HEPEVT & no \\ mokka & ASCII & variant of HEPEVT & no \\ short & ASCII & variant of HEPEVT & no \\ StdHEP (HEPEVT) & binary & based on HEPEVT common block & no \\ StdHEP (HEPRUP/EUP) & binary & based on HEPRUP/EUP common block & no \\ Weight stream & ASCII & just weights & no \\ \hline \end{tabular} \end{center} \caption{\label{tab:eventformats} Event formats supported by \whizard, classified according to ASCII/binary formats and whether an external program or library is needed to generate a file of this format. For both the HEPEVT and the LHA format there is a more verbose variant. } \end{table} The "\ttt{.evx}'' is \whizard's native binary event format. If you demand event generation and do not specify anything further, \whizard\ will write out its events exclusively in this binary format. So in the examples discussed in the previous chapters (where we omitted all details about event formats), in all cases this and only this internal binary format has been generated. The generation of this raw format can be suppressed (e.g. if you want to have only one specific event file type) by setting the variable \verb|?write_raw = false|. However, if the raw event file is not present, \whizard\ is not able to re-use existing events (e.g. from an ASCII file) and will regenerate events for a given process. Note that from version v2.2.0 of \whizard\ on, the program is able to (partially) reconstruct complete events also from other formats than its internal format (e.g. LHEF), but this is still under construction and not yet complete. Other event formats can be written out by setting the variable \ttt{sample\_format = }, where \ttt{} can be any of the following supported variables: \begin{itemize} \item \ttt{ascii}: a quite verbose ASCII format which contains lots of information (an example is shown in the appendix). \newline Standard suffix: \ttt{.evt} \item \ttt{debug}: an even more verbose ASCII format intended for debugging which prints out also information about the internal data structures \newline Standard suffix: \ttt{.debug} \item \ttt{hepevt}: ASCII format that writes out a specific incarnation of the HEPEVT common block (\whizard~1 back-compatibility) \newline Standard suffix: \ttt{.hepevt} \item \ttt{hepevt\_verb}: more verbose version of \ttt{hepevt} (\whizard~1 back-compatibility) \newline Standard suffix: \ttt{.hepevt.verb} \item \ttt{short}: abbreviated variant of the previous HEPEVT (\whizard\ 1 back-compatibility) \newline Standard suffix: \ttt{.short.evt} \item \ttt{long}: HEPEVT variant that contains a little bit more information than the short format but less than HEPEVT (\whizard\ 1 back-compatibility) \newline Standard suffix: \ttt{.long.evt} \item \ttt{athena}: HEPEVT variant suitable for read-out in the ATLAS ATHENA software environment (\whizard\ 1 back-compatibility) \newline Standard suffix: \ttt{.athena.evt} \item \ttt{mokka}: HEPEVT variant suitable for read-out in the MOKKA ILC software environment \newline Standard suffix: \ttt{.mokka.evt} \item \ttt{lcio}: LCIO ASCII format (only available if LCIO is installed and correctly linked) \newline Standard suffix: \ttt{.lcio} \item \ttt{lha}: Implementation of the Les Houches Accord as it was in the old MadEvent and \whizard~1 \newline Standard suffix: \ttt{.lha} \item \ttt{lha\_verb}: more verbose version of \ttt{lha} \newline Standard suffix: \ttt{.lha.verb} \item \ttt{lhef}: Formatted Les Houches Accord implementation that contains the XML headers \newline Standard suffix: \ttt{.lhe} \item \ttt{hepmc}: HepMC ASCII format (only available if HepMC is installed and correctly linked) \newline Standard suffix: \ttt{.hepmc} \item \ttt{stdhep}: StdHEP binary format based on the HEPEVT common block \newline Standard suffix: \ttt{.hep} \item \ttt{stdhep\_up}: StdHEP binary format based on the HEPRUP/HEPEUP common blocks \newline Standard suffix: \ttt{.up.hep} \item \ttt{stdhep\_ev4}: StdHEP binary format based on the HEPEVT/HEPEV4 common blocks \newline Standard suffix: \ttt{.ev4.hep} \item \ttt{weight\_stream}: Format that prints out only the event weight (and maybe alternative ones) \newline Standard suffix: \ttt{.weight.dat} \end{itemize} Of course, the variable \ttt{sample\_format} can contain more than one of the above identifiers, in which case more than one different event file format is generated. The list above also shows the standard suffixes for these event formats (remember, that the native binary format of \whizard\ does have the suffix \ttt{.evx}). (The suffix of the different event formats can even be changed by the user by setting the corresponding variable \ttt{\$extension\_lhef = "foo"} or \ttt{\$extension\_ascii\_short = "bread"}. The dot is automatically included.) The name of the corresponding event sample is taken to be the string of the name of the first process in the \ttt{simulate} statement. Remember, that conventionally the events for all processes in one \ttt{simulate} statement will be written into one single event file. So \ttt{simulate (proc1, proc2)} will write events for the two processes \ttt{proc1} and \ttt{proc2} into one single event file with name \ttt{proc1.evx}. The name can be changed by the user with the command \ttt{\$sample = ""}. The commands \ttt{\$sample} and \ttt{sample\_format} are both accepted as optional arguments of a \ttt{simulate} command, so e.g. \ttt{simulate (proc) \{ \$sample = "foo" sample\_format = hepmc \}} generates an event sample in the HepMC format for the process \ttt{proc} in the file \ttt{foo.hepmc}. Examples for event formats, for specifications of the event formats correspond the different accords and publications~\footnote{Some event formats, based on the \ttt{HEPEVT} or \ttt{HEPEUP} common blocks, use fixed-form ASCII output with a two-digit exponent for real numbers. There are rare cases (mainly, ISR photons) where the event record can contain numbers with absolute value less than $10^{-99}$. Since those numbers are not representable in that format, \whizard\ will set all non-zero numbers below that value to $\pm 10^{-99}$, when filling either common block. Obviously, such values are physically irrelevant, but in the output they are representable and distinguishable from zero.}: \paragraph{HEPEVT:} The HEPEVT is an ASCII event format that does not contain an event file header. There is a one-line header for each single event, containing four entries. The number of particles in the event (\ttt{ISTHEP}), which is four for a fictitious example process $hh\to hh$, but could be larger if e.g. beam remnants are demanded to be included in the event. The second entry and third entry are the number of outgoing particles and beam remnants, respectively. The event weight is the last entry. For each particle in the event there are three lines: the first one is the status according to the HEPEVT format, \ttt{ISTHEP}, the second one the PDG code, \ttt{IDHEP}, then there are the one or two possible mother particle, \ttt{JMOHEP}, the first and last possible daughter particle, \ttt{JDAHEP}, and the polarization. The second line contains the three momentum components, $p_x$, $p_y$, $p_z$, the particle energy $E$, and its mass, $m$. The last line contains the position of the vertex in the event reconstruction. \begin{scriptsize} \begin{verbatim} 4 2 0 3.0574068604E+08 2 25 0 0 3 4 0 0.0000000000E+00 0.0000000000E+00 4.8412291828E+02 5.0000000000E+02 1.2500000000E+02 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 2 25 0 0 3 4 0 0.0000000000E+00 0.0000000000E+00 -4.8412291828E+02 5.0000000000E+02 1.2500000000E+02 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 1 25 1 2 0 0 0 -1.4960220911E+02 -4.6042825611E+02 0.0000000000E+00 5.0000000000E+02 1.2500000000E+02 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 1 25 1 2 0 0 0 1.4960220911E+02 4.6042825611E+02 0.0000000000E+00 5.0000000000E+02 1.2500000000E+02 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 \end{verbatim} \end{scriptsize} \paragraph{ASCII SHORT:} This is basically the same as the HEPEVT standard, but very much abbreviated. The header line for each event is identical, but the first line per particle does only contain the PDG and the polarization, while the vertex information line is omitted. \begin{scriptsize} \begin{verbatim} 4 2 0 3.0574068604E+08 25 0 0.0000000000E+00 0.0000000000E+00 4.8412291828E+02 5.0000000000E+02 1.2500000000E+02 25 0 0.0000000000E+00 0.0000000000E+00 -4.8412291828E+02 5.0000000000E+02 1.2500000000E+02 25 0 -1.4960220911E+02 -4.6042825611E+02 0.0000000000E+00 5.0000000000E+02 1.2500000000E+02 25 0 1.4960220911E+02 4.6042825611E+02 0.0000000000E+00 5.0000000000E+02 1.2500000000E+02 \end{verbatim} \end{scriptsize} \paragraph{ASCII LONG:} Identical to the ASCII short format, but after each event there is a line containg two values: the value of the sample function to be integrated over phase space, so basically the squared matrix element including all normalization factors, flux factor, structure functions etc. \begin{scriptsize} \begin{verbatim} 4 2 0 3.0574068604E+08 25 0 0.0000000000E+00 0.0000000000E+00 4.8412291828E+02 5.0000000000E+02 1.2500000000E+02 25 0 0.0000000000E+00 0.0000000000E+00 -4.8412291828E+02 5.0000000000E+02 1.2500000000E+02 25 0 -1.4960220911E+02 -4.6042825611E+02 0.0000000000E+00 5.0000000000E+02 1.2500000000E+02 25 0 1.4960220911E+02 4.6042825611E+02 0.0000000000E+00 5.0000000000E+02 1.2500000000E+02 1.0000000000E+00 1.0000000000E+00 \end{verbatim} \end{scriptsize} \paragraph{ATHENA:} Quite similar to the HEPEVT ASCII format. The header line, however, does contain only two numbers: an event counter, and the number of particles in the event. The first line for each particle lacks the polarization information (irrelevant for the ATHENA environment), but has as leading entry an ordering number counting the particles in the event. The vertex information line has only the four relevant position entries. \begin{scriptsize} \begin{verbatim} 0 4 1 2 25 0 0 3 4 0.0000000000E+00 0.0000000000E+00 4.8412291828E+02 5.0000000000E+02 1.2500000000E+02 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 2 2 25 0 0 3 4 0.0000000000E+00 0.0000000000E+00 -4.8412291828E+02 5.0000000000E+02 1.2500000000E+02 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 3 1 25 1 2 0 0 -1.4960220911E+02 -4.6042825611E+02 0.0000000000E+00 5.0000000000E+02 1.2500000000E+02 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 4 1 25 1 2 0 0 1.4960220911E+02 4.6042825611E+02 0.0000000000E+00 5.0000000000E+02 1.2500000000E+02 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 \end{verbatim} \end{scriptsize} \paragraph{MOKKA:} Quite similar to the ASCII short format, but the event entries are the particle status, the PDG code, the first and last daughter, the three spatial components of the momentum, as well as the mass. \begin{scriptsize} \begin{verbatim} 4 2 0 3.0574068604E+08 2 25 3 4 0.0000000000E+00 0.0000000000E+00 4.8412291828E+02 1.2500000000E+02 2 25 3 4 0.0000000000E+00 0.0000000000E+00 -4.8412291828E+02 1.2500000000E+02 1 25 0 0 -1.4960220911E+02 -4.6042825611E+02 0.0000000000E+00 1.2500000000E+02 1 25 0 0 1.4960220911E+02 4.6042825611E+02 0.0000000000E+00 1.2500000000E+02 \end{verbatim} \end{scriptsize} \paragraph{LHA:} This is the implementation of the Les Houches Accord, as it was used in \whizard\ 1 and the old MadEvent. There is a first line containing six entries: 1. the number of particles in the event, \ttt{NUP}, 2. the subprocess identification index, \ttt{IDPRUP}, 3. the event weight, \ttt{XWGTUP}, 4. the scale of the process, \ttt{SCALUP}, 5. the value or status of $\alpha_{QED}$, \ttt{AQEDUP}, 6. the value for $\alpha_s$, \ttt{AQCDUP}. The next seven lines contain as many entries as there are particles in the event: the first one has the PDG codes, \ttt{IDUP}, the next two the first and second mother of the particles, \ttt{MOTHUP}, the fourth and fifth line the two color indices, \ttt{ICOLUP}, the next one the status of the particle, \ttt{ISTUP}, and the last line the polarization information, \ttt{ISPINUP}. At the end of the event there are as lines for each particles with the counter in the event and the four-vector of the particle. For more information on this event format confer~\cite{LesHouches}. \begin{scriptsize} \begin{verbatim} 25 25 5.0000000000E+02 5.0000000000E+02 -1 -1 -1 -1 3 1 1.0000000000E-01 1.0000000000E-03 1.0000000000E+00 42 4 1 3.0574068604E+08 1.000000E+03 -1.000000E+00 -1.000000E+00 25 25 25 25 0 0 1 1 0 0 2 2 0 0 0 0 0 0 0 0 -1 -1 1 1 9 9 9 9 1 5.0000000000E+02 0.0000000000E+00 0.0000000000E+00 4.8412291828E+02 2 5.0000000000E+02 0.0000000000E+00 0.0000000000E+00 -4.8412291828E+02 3 5.0000000000E+02 -1.4960220911E+02 -4.6042825611E+02 0.0000000000E+00 4 5.0000000000E+02 1.4960220911E+02 4.6042825611E+02 0.0000000000E+00 \end{verbatim} \end{scriptsize} \paragraph{LHEF:} This is the modern version of the Les Houches accord event format (LHEF), for the details confer the corresponding publication~\cite{LHEF}. \begin{scriptsize} \begin{verbatim}
WHIZARD 3.0.0_alpha
25 25 5.0000000000E+02 5.0000000000E+02 -1 -1 -1 -1 3 1 1.0000000000E-01 1.0000000000E-03 1.0000000000E+00 42 4 42 3.0574068604E+08 1.0000000000E+03 -1.0000000000E+00 -1.0000000000E+00 25 -1 0 0 0 0 0.0000000000E+00 0.0000000000E+00 4.8412291828E+02 5.0000000000E+02 1.2500000000E+02 0.0000000000E+00 9.0000000000E+00 25 -1 0 0 0 0 0.0000000000E+00 0.0000000000E+00 -4.8412291828E+02 5.0000000000E+02 1.2500000000E+02 0.0000000000E+00 9.0000000000E+00 25 1 1 2 0 0 -1.4960220911E+02 -4.6042825611E+02 0.0000000000E+00 5.0000000000E+02 1.2500000000E+02 0.0000000000E+00 9.0000000000E+00 25 1 1 2 0 0 1.4960220911E+02 4.6042825611E+02 0.0000000000E+00 5.0000000000E+02 1.2500000000E+02 0.0000000000E+00 9.0000000000E+00
\end{verbatim} \end{scriptsize} Note that for the LHEF format, there are different versions according to the different stages of agreement. They can be addressed from within the \sindarin\ file by setting the string variable \ttt{\$lhef\_version} to one of (at the moment) three values: \ttt{"1.0"}, \ttt{"2.0"}, or \ttt{"3.0"}. The examples above corresponds (as is indicated in the header) to the version \ttt{"1.0"} of the LHEF format. Additional information in form of alternative squared matrix elements or event weights in the event are the most prominent features of the other two more advanced versions. For more details confer the literature. \vspace{.5cm} Sample files for the default ASCII format as well as for the debug event format are shown in the appendix. %%%%%%%%% \section[Interfaces to Parton Showers, Matching and Hadronization]{Interfaces to Parton Showers, Matching\\and Hadronization} This section describes the interfaces to the internal parton shower as well as the parton shower and hadronization routines from \pythia. Moreover, our implementation of the MLM matching making use of the parton showers is described. Sample \sindarin\ files are located in the \ttt{share/examples} directory. All input files come in two versions, one using the internal shower, ending in \ttt{W.sin}, and one using \pythia's shower, ending in \ttt{P.sin}. Thus we state all file names as ending with \ttt{X.sin}, where \ttt{X} has to be replaced by either \ttt{W} or \ttt{P}. The input files include \ttt{EENoMatchingX.sin} and \ttt{DrellYanNoMatchingX.sin} for $e^+ e^- \to hadrons$ and $p\bar{p} \to Z$ without matching. The corresponding \sindarin\ files with matching enabled are \ttt{EEMatching2X.sin} to \ttt{EEMatching5X.sin} for $e^+ e^- \to hadrons$ with a different number of partons included in the matrix element and \ttt{DrallYanMatchingX.sin} for Drell-Yan with one matched emission. \subsection{Parton Showers and Hadronization} From version 2.1 onwards, \whizard\ contains an implementation of an analytic parton shower as presented in \cite{Kilian:2011ka}, providing the opportunity to perform the parton shower from whithin \whizard. Moreover, an interface to \pythia\ is included, which can be used to delegate the parton shower to \pythia. The same interface can be used to hadronize events using the generated events using \pythia's hadronization routines. Note that by \pythia's default, when performing initial-state radiation multiple interactions are included and when performing the hadronization hadronic decays are included. If required, these additional steps have to be switched off using the corresponding arguments for \pythia's \ttt{PYGIVE} routine vie the \ttt{\$ps\_PYTHIA\_PYGIVE} string. Note that from version 2.2.4 on the earlier flag \ttt{--enable-shower} flag has been abandoned, and there is only a flag to either compile or not compile the interally attached \pythia\ttt{6} package (\ttt{--enable-pythia6}) last release of the \fortran\ \pythia, v6.427) as well as the interface. It can be invoked by the following \sindarin\ keywords:\\[2ex] % \centerline{\begin{tabular}{|l|l|} \hline\ttt{?ps\_fsr\_active = true} & master switch for final-state parton showers\\\hline \ttt{?ps\_isr\_active = true} & master switch for initial-state parton showers\\\hline \ttt{?ps\_taudec\_active = true} & master switch for $\tau$ decays (at the moment only via \ttt{TAUOLA}\\\hline \ttt{?hadronization\_active = true} & master switch to enable hadronization\\\hline \ttt{\$shower\_method = "PYTHIA6"} & switch to use \pythiasix's parton shower instead of \\ & \whizard's own shower\\\hline \end{tabular}}\mbox{} \vspace{4mm} If either \ttt{?ps\_fsr\_active} or \ttt{?ps\_isr\_active} is set to \verb|true|, the event will be transferred to the internal shower routines or the \pythia\ data structures, and the chosen shower steps (initial- and final-state radiation) will be performed. If hadronization is enabled via the \ttt{?hadronization\_active} switch, \whizard\ will call \pythia's hadronization routine. The hadron\-ization can be applied to events showered using the internal shower or showered using \pythia's shower routines, as well as unshowered events. Any necessary transfer of event data to \pythia\ is automatically taken care of within \whizard's shower interface. The resulting (showered and/or hadronized) event will be transferred back to \whizard, the former final particles will be marked as intermediate. The analysis can be applied to a showered and/or hadronized event just like in the unshowered/unhadronized case. Any event file can be used and will contain the showered/hadronized event. Settings for the internal analytic parton shower are set via the following \sindarin\ variables:\\[2ex] \begin{description} \item[\ttt{ps\_mass\_cutoff}] The cut-off in virtuality, below which, partons are assumed to radiate no more. Used for both ISR and FSR. Given in $\mbox{GeV}$. (Default = 1.0) \item[\ttt{ps\_fsr\_lambda}] The value for $\Lambda$ used in calculating the value of the running coupling constant $\alpha_S$ for Final State Radiation. Given in $\mbox{GeV}$. (Default = 0.29) \item[\ttt{ps\_isr\_lambda}] The value for $\Lambda$ used in calculating the value of the running coupling constant $\alpha_S$ for Initial State Radiation. Given in $\mbox{GeV}$. (Default = 0.29) \item[\ttt{ps\_max\_n\_flavors}] Number of quark flavours taken into account during shower evolution. Meaningful choices are 3 to include $u,d,s$-quarks, 4 to include $u,d,s,c$-quarks and 5 to include $u,d,s,c,b$-quarks. (Default = 5) \item[\ttt{?ps\_isr\_alphas\_running}] Switch to decide between a constant $\alpha_S$, given by \ttt{ps\_fixed\_alphas}, and a running $\alpha_S$, calculated using \ttt{ps\_isr\_lambda} for ISR. (Default = true) \item[\ttt{?ps\_fsr\_alphas\_running}] Switch to decide between a constant $\alpha_S$, given by \ttt{ps\_fixed\_alphas}, and a running $\alpha_S$, calculated using \ttt{ps\_fsr\_lambda} for FSR. (Default = true) \item[\ttt{ps\_fixed\_alphas}] Fixed value of $\alpha_S$ for the parton shower. Used if either one of the variables \ttt{?ps\_fsr\_alphas\_running} or \ttt{?ps\_isr\_alphas\_running} are set to \verb|false|. (Default = 0.0) \item[\ttt{?ps\_isr\_angular\_ordered}] Switch for angular ordered ISR. (Default = true )\footnote{The FSR is always simulated with angular ordering enabled.} \item[\ttt{ps\_isr\_primordial\_kt\_width}] The width in $\mbox{GeV}$ of the Gaussian assumed to describe the transverse momentum of partons inside the proton. Other shapes are not yet implemented. (Default = 0.0) \item[\ttt{ps\_isr\_primordial\_kt\_cutoff}] The maximal transverse momentum in $\mbox{GeV}$ of a parton inside the proton. Used as a cut-off for the Gaussian. (Default = 5.0) \item[\ttt{ps\_isr\_z\_cutoff}] Maximal $z$-value in initial state branchings. (Default = 0.999) \item[\ttt{ps\_isr\_minenergy}] Minimal energy in $\mbox{GeV}$ of an emitted timelike or final parton. Note that the energy is not calculated in the labframe but in the center-of-mas frame of the two most initial partons resolved so far, so deviations may occur. (Default = 1.0) \item[\ttt{ps\_isr\_tscalefactor}] Factor for the starting scale in the initial state shower evolution. ( Default = 1.0 ) \item[\ttt{?ps\_isr\_only\_onshell\_emitted\_partons}] Switch to allow only for on-shell emitted partons, thereby rejecting all possible final state parton showers starting from partons emitted during the ISR. (Default = false) \end{description} Settings for the \pythia\ are transferred using the following \sindarin\ variables:\\[2ex] \centerline{\begin{tabular}{|l|l|} \hline\ttt{?ps\_PYTHIA\_verbose} & if set to false, output from \pythia\ will be suppressed\\\hline \ttt{\$ps\_PYTHIA\_PYGIVE} & a string containing settings transferred to \pythia's \ttt{PYGIVE} subroutine.\\ & The format is explained in the \pythia\ manual. The limitation to 100 \\ & characters mentioned there does not apply here, the string is split \\ & appropriately before being transferred to \pythia.\\\hline \end{tabular}}\mbox{} \vspace{4mm} Note that the included version of \pythia\ uses \lhapdf\ for initial state radiation whenever this is available, but the PDF set has to be set manually in that case using the keyword \ttt{ps\_PYTHIA\_PYGIVE}. \subsection{Parton shower -- Matrix Element Matching} Along with the inclusion of the parton showers, \whizard\ includes an implementation of the MLM matching procedure. For a detailed description of the implemented steps see \cite{Kilian:2011ka}. The inclusion of MLM matching still demands some manual settings in the \sindarin\ file. For a given base process and a matching of $N$ additional jets, all processes that can be obtained by attaching up to $N$ QCD splittings, either a quark emitting a gluon or a gluon splitting into two quarks ar two gluons, have to be manually specified as additional processes. These additional processes need to be included in the \ttt{simulate} statement along with the original process. The \sindarin\ variable \ttt{mlm\_nmaxMEjets} has to be set to the maximum number of additional jets $N$. Moreover additional cuts have to be specified for the additional processes. \begin{verbatim} alias quark = u:d:s:c alias antiq = U:D:S:C alias j = quark:antiq:g ?mlm_matching = true mlm_ptmin = 5 GeV mlm_etamax = 2.5 mlm_Rmin = 1 cuts = all Dist > mlm_Rmin [j, j] and all Pt > mlm_ptmin [j] and all abs(Eta) < mlm_etamax [j] \end{verbatim} Note that the variables \ttt{mlm\_ptmin}, \ttt{mlm\_etamax} and \ttt{mlm\_Rmin} are used by the matching routine. Thus, replacing the variables in the \ttt{cut} expression and omitting the assignment would destroy the matching procedure. The complete list of variables introduced to steer the matching procedure is as follows: \begin{description} \item[\ttt{?mlm\_matching\_active}] Master switch to enable MLM matching. (Default = false) \item[\ttt{mlm\_ptmin}] Minimal transverse momentum, also used in the definition of a jet \item[\ttt{mlm\_etamax}] Maximal absolute value of pseudorapidity $\eta$, also used in defining a jet \item[\ttt{mlm\_Rmin}] Minimal $\eta-\phi$ distance $R_{min}$ \item[\ttt{mlm\_nmaxMEjets}] Maximum number of jets $N$ \item[\ttt{mlm\_ETclusfactor}] Factor to vary the jet definition. Should be $\geq 1$ for complete coverage of phase space. (Default = 1) \item[\ttt{mlm\_ETclusminE}] Minimal energy in the variation of the jet definition \item[\ttt{mlm\_etaclusfactor}] Factor in the variation of the jet definition. Should be $\leq 1$ for complete coverage of phase space. (Default = 1) \item[\ttt{mlm\_Rclusfactor}] Factor in the variation of the jet definition. Should be $\ge 1$ for complete coverage of phase space. (Default = 1) \end{description} The variation of the jet definition is a tool to asses systematic uncertainties introduced by the matching procedure (See section 3.1 in \cite{Kilian:2011ka}). %%%%%%%%% \section{Rescanning and recalculating events} \label{sec:rescan} In the simplest mode of execution, \whizard\ handles its events at the point where they are generated. It can apply event transforms such as decays or shower (see above), it can analyze the events, calculate and plot observables, and it can output them to file. However, it is also possible to apply two different operations to those events in parallel, or to reconsider and rescan an event sample that has been previously generated. We first discuss the possibilities that \ttt{simulate} offers. For each event, \whizard\ calculates the matrix element for the hard interaction, supplements this by Jacobian and phase-space factors in order to obtain the event weight, optionally applies a rejection step in order to gather uniformly weighted events, and applies the cuts and analysis setup. We may ask about the event matrix element or weight, or the analysis result, that we would have obtained for a different setting. To this end, there is an \ttt{alt\_setup} option. This option allows us to recalculate, event by event, the matrix element, weight, or analysis contribution with a different parameter set but identical kinematics. For instance, we may evaluate a distribution for both zero and non-zero anomalous coupling \ttt{fw} and enter some observable in separate histograms: \begin{footnotesize} \begin{verbatim} simulate (some_proc) { fw = 0 analysis = record hist1 (eval Pt [H]) alt_setup = { fw = 0.01 analysis = record hist2 (eval Pt [H]) } } \end{verbatim} \end{footnotesize} In fact, the \ttt{alt\_setup} object is not restricted to a single code block (enclosed in curly braces) but can take a list of those, \begin{footnotesize} \begin{verbatim} alt_setup = { fw = 0.01 }, { fw = 0.02 }, ... \end{verbatim} \end{footnotesize} Each block provides the environment for a separate evaluation of the event data. The generation of these events, i.e., their kinematics, is still steered by the primary environment. The \ttt{alt\_setup} blocks may modify various settings that affect the evaluation of an event, including physical parameters, PDF choice, cuts and analysis, output format, etc. This must not (i.e., cannot) affect the kinematics of an event, so don't modify particle masses. When applying cuts, they can only reduce the generated event sample, so they apply on top of the primary cuts for the simulation. Alternatively, it is possible to \ttt{rescan} a sample that has been generated by a previous \ttt{simulate} command: \begin{footnotesize} \begin{verbatim} simulate (some_proc) { $sample = "my_events" analysis = record hist1 (eval Pt [H]) } ?update_sqme = true ?update_weight = true rescan "my_events" (some_proc) { fw = 0.01 analysis = record hist2 (eval Pt [H]) } rescan "my_events" (some_proc) { fw = 0.05 analysis = record hist3 (eval Pt [H]) } \end{verbatim} \end{footnotesize} In more complicated situation, rescanning is more transparent and offers greater flexibility than doing all operations at the very point of event generation. Combining these features with the \ttt{scan} looping construct, we already cover a considerable range of applications. (There are limitations due to the fact that \sindarin\ doesn't provide array objects, yet.) Note that the \ttt{rescan} construct also allows for an \ttt{alt\_setup} option. You may generate a new sample by rescanning, for which you may choose any output format: \begin{footnotesize} \begin{verbatim} rescan "my_events" (some_proc) { selection = all Pt > 100 GeV [H] $sample = "new_events" sample_format = lhef } \end{verbatim} \end{footnotesize} The event sample that you rescan need not be an internal raw \whizard\ file, as above. You may rescan a LHEF file, \begin{footnotesize} \begin{verbatim} rescan "lhef_events" (proc) { $rescan_input_format = "lhef" } \end{verbatim} \end{footnotesize} This file may have any origin, not necessarily from \whizard. To understand such an external file, \whizard\ must be able to reconstruct the hard process and match it to a process with a known name (e.g., \ttt{proc}), that has been defined in the \sindarin\ script previously. Within its limits, \whizard\ can thus be used for translating an event sample from one format to another format. There are three important switches that control the rescanning behavior. They can be set or unset independently. \begin{itemize} \item \ttt{?update\_sqme} (default: false). If true, \whizard\ will recalculate the hard matrix element for each event. When applying an analysis, the recalculated squared matrix element (averaged and summed over quantum numbers as usual) is available as the variable \ttt{sqme\_prc}. This may be related to \ttt{sqme\_ref}, the corresponding value in the event file, if available. (For the \ttt{alt\_env} option, this switch is implied.) \item \ttt{?update\_weight} (default: false). If true, \whizard\ will recalculate the event weight according to the current environment and apply this to the event. In particular, the user may apply a \ttt{reweight} expression. In an analysis, the new weight value is available as \ttt{weight\_prc}, to be related to \ttt{weight\_ref} from the sample. The updated weight will be applied for histograms and averages. An unweighted event sample will thus be transformed into a weighted event sample. (This switch is also implied for the \ttt{alt\_env} option.) \item \ttt{?update\_event} (default: false). If true, \whizard\ will generate a new decay chain etc., if applicable. That is, it reuses just the particles in the hard process. Otherwise, the complete event is kept as it is written to file. \end{itemize} For these options to make sense, \whizard\ must have access to a full process object, so the \sindarin\ script must contain not just a definition but also a \ttt{compile} command for the matrix elements in question. If an event file (other than raw format) contains several processes as a mixture, they must be identifiable by a numeric ID. \whizard\ will recognize the processes if their respective \sindarin\ definitions contain appropriate \ttt{process\_num\_id} options, such as \begin{footnotesize} \begin{verbatim} process foo = u, ubar => d, dbar { process_num_id = 42 } \end{verbatim} \end{footnotesize} Certain event-file formats, such as LHEF, support alternative matrix-element values or weights. \whizard\ can thus write both original and recalculated matrix-element and weight values. Other formats support only a single event weight, so the \ttt{?update\_weight} option is necessary for a visible effect. External event files in formats such as LHEF, HepMC, or LCIO, also may carry information about the value of the strong coupling $\alpha_s$ and the energy scale of each event. This information will also be provided by \whizard\ when writing external event files. When such an event file is rescanned, the user has the choice to either user the $\alpha_s$ value that \whizard\ defines in the current context (or the method for obtaining an event-specific running $\alpha_s$ value), or override this for each event by using the value in the event file. The corresponding parameter is \ttt{?use\_alphas\_from\_file}, which is false by default. Analogously, the parameter \ttt{?use\_scale\_from\_file} may be set to override the scale definition in the current context. Obviously, these settings influence matrix-element recalculation and therefore require \ttt{?update\_sqme} to be set in order to become operational. %%%%%%%%% \section{Negative weight events} For usage at NLO refer to Subsection~\ref{ss:fixedorderNLOevents}. In case, you have some other mechanism to produce events with negative weights (e.g. with the \ttt{weight = {\em }} command), keep in mind that you should activate \ttt{?negative\_weights = true} and \ttt{unweighted = false}. The generation of unweighted events with varying sign (also known as events and counter events) is currently not supported. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Internal Data Visualization} \label{chap:visualization} \section{GAMELAN} The data values and tables that we have introduced in the previous section can be visualized using built-in features of \whizard. To be precise, \whizard\ can write \LaTeX\ code which incorporates code in the graphics language GAMELAN to produce a pretty-printed account of observables, histograms, and plots. GAMELAN is a macro package for MetaPost, which is part of the \TeX/\LaTeX\ family. MetaPost, a derivative of Knuth's MetaFont language for font design, is usually bundled with the \TeX\ distribution, but might need a separate switch for installation. The GAMELAN macros are contained in a subdirectory of the \whizard\ package. Upon installation, they will be installed in the appropriate directory, including the \ttt{gamelan.sty} driver for \LaTeX. \whizard\ uses a subset of GAMELAN's graphics macros directly, but it allows for access to the full package if desired. An (incomplete) manual for GAMELAN can be found in the \ttt{share/doc} subdirectory of the \whizard\ system. \whizard\ itself uses a subset of the GAMELAN capabilities, interfaced by \sindarin\ commands and parameters. They are described in this chapter. To process analysis output beyond writing tables to file, the \ttt{write\_analysis} command described in the previous section should be replaced by \ttt{compile\_analysis}, with the same syntax: \begin{quote} \begin{footnotesize} \ttt{compile\_analysis (\emph{analysis-tags}) \{ \ttt{\emph{options}} \}} \end{footnotesize} \end{quote} where \ttt{\emph{analysis-tags}}, a comma-separated list of analysis objects, is optional. If there are no tags, all analysis objects are processed. The \ttt{\emph{options}} script of local commands is also optional, of course. This command will perform the following actions: \begin{enumerate} \item It writes a data file in default format, as \ttt{write\_analysis} would do. The file name is given by \ttt{\$out\_file}, if nonempty. The file must not be already open, since the command needs a self-contained file, but the name is otherwise arbitrary. If the value of \ttt{\$out\_file} is empty, the default file name is \ttt{whizard\_analysis.dat}. \item It writes a driver file for the chosen datasets, whose name is derived from the data file by replacing the file extension of the data file with the extension \ttt{.tex}. The driver file is a \LaTeX\ source file which contains embedded GAMELAN code that handles the selected graphics data. In the \LaTeX\ document, there is a separate section for each contained dataset. Furthermore, a process-/analysis-specific makefile with the name \ttt{\_ana.makefile} is created that can be used to generate postscript or PDF output from the \LaTeX\ source. If the steering flag \ttt{?analysis\_file\_only} is set to \ttt{true}, then the \LaTeX\ file and the makefile are only written, but no execution of the makefile resulting in compilation of the \LaTeX\ code (see the next item) is invoked. \item As mentioned above, if the flag \ttt{?analysis\_file\_only} is set to \ttt{false} (which is the default), the driver file is processed by \LaTeX (invoked by calling the makefile with the name \ttt{\_ana.makefile}), which generates an appropriate GAMELAN source file with extension \ttt{.mp}. This code is executed (calling GAMELAN/MetaPost, and again \LaTeX\ for typesetting embedded labels). There is a second \LaTeX\ pass (automatically done by the makefile) which collects the results, and finally conversion to PostScript and PDF formats. \end{enumerate} The resulting PostScript or PDF file -- the file name is the name of the data file with the extension replaced by \ttt{.ps} or \ttt{.pdf}, respectively -- can be printed or viewed with an appropriate viewer such as \ttt{gv}. The viewing command is not executed automatically by \whizard. Note that \LaTeX\ will write further files with extensions \ttt{.log}, \ttt{.aux}, and \ttt{.dvi}, and GAMELAN will produce auxiliary files with extensions \ttt{.ltp} and \ttt{.mpx}. The log file in particular, could overwrite \whizard's log file if the basename is identical. Be careful to use a value for \ttt{\$out\_file} which is not likely to cause name clashes. \subsection{User-specific changes} In the case, that the \sindarin\ \ttt{compile\_analysis} command is invoked and the flag named \ttt{?analysis\_file\_only} is not changed from its default value \ttt{false}, \whizard\ calls the process-/analysis-specific makefile triggering the compilation of the \LaTeX\ code and the GAMELAN plots and histograms. If the user wants to edit the analysis output, for example changing captions, headlines, labels, properties of the plots, graphs and histograms using GAMELAN specials etc., this is possible and the output can be regenerated using the makefile. The user can also directly invoke the GAMELAN script, \ttt{whizard-gml}, that is installed in the binary directly along with the \whizard\ binary and other scripts. Note however, that the \LaTeX\ environment for the specific style files have to be set by hand (the command line invocation in the makefile does this automatically). Those style files are generally written into \ttt{share/texmf/whizard/} directory. The user can execute the commands in the same way as denoted in the process-/analysis-specific makefile by hand. %%%%% \section{Histogram Display} %%%%% \section{Plot Display} \section{Graphs} \label{sec:graphs} Graphs are an additional type of analysis object. In contrast to histograms and plots, they do not collect data directly, but they rather act as containers for graph elements, which are copies of existing histograms and plots. Their single purpose is to be displayed by the GAMELAN driver. Graphs are declared by simple assignments such as \begin{quote} \begin{footnotesize} \ttt{graph g1 = hist1} \\ \ttt{graph g2 = hist2 \& hist3 \& plot1} \end{footnotesize} \end{quote} The first declaration copies a single histogram into the graph, the second one copies two histograms and a plot. The syntax for collecting analysis objects uses the \ttt{\&} concatenation operator, analogous to string concatenation. In the assignment, the rhs must contain only histograms and plots. Further concatenating previously declared graphs is not supported. After the graph has been declared, its contents can be written to file (\ttt{write\_analysis}) or, usually, compiledd by the \LaTeX/GAMELAN driver via the \ttt{compile\_analysis} command. The graph elements on the right-hand side of the graph assignment are copied with their current data content. This implies a well-defined order of statements: first, histograms and plots are declared, then they are filled via \ttt{record} commands or functions, and finally they can be collected for display by graph declarations. A simple graph declaration without options as above is possible, but usually there are option which affect the graph display. There are two kinds of options: graph options and drawing options. Graph options apply to the graph as a whole (title, labels, etc.) and are placed in braces on the lhs of the assigment. Drawing options apply to the individual graph elements representing the contained histograms and plots, and are placed together with the graph element on the rhs of the assignment. Thus, the complete syntax for assigning multiple graph elements is \begin{quote} \begin{footnotesize} \ttt{graph \emph{graph-tag} \{ \emph{graph-options} \}} \\ \ttt{= \emph{graph-element-tag1} \{ \emph{drawing-options1} \}} \\ \ttt{\& \emph{graph-element-tag2} \{ \emph{drawing-options2} \}} \\ \ldots \end{footnotesize} \end{quote} This form is recommended, but graph and drawing options can also be set as global parameters, as usual. We list the supported graph and drawing options in Tables~\ref{tab:graph-options} and \ref{tab:drawing-options}, respectively. \begin{table} \caption{Graph options. The content of strings of type \LaTeX\ must be valid \LaTeX\ code (containing typesetting commands such as math mode). The content of strings of type GAMELAN must be valid GAMELAN code. If a graph bound is kept \emph{undefined}, the actual graph bound is determined such as not to crop the graph contents in the selected direction.} \label{tab:graph-options} \begin{center} \begin{tabular}{|l|l|l|l|} \hline Variable & Default & Type & Meaning \\ \hline\hline \ttt{\$title} & \ttt{""} & \LaTeX & Title of the graph = subsection headline \\ \hline \ttt{\$description} & \ttt{""} & \LaTeX & Description text for the graph \\ \hline \ttt{\$x\_label} & \ttt{""} & \LaTeX & $x$-axis label \\ \hline \ttt{\$y\_label} & \ttt{""} & \LaTeX & $y$-axis label \\ \hline \ttt{graph\_width\_mm} & 130 & Integer & graph width (on paper) in mm \\ \hline \ttt{graph\_height\_mm} & 90 & Integer & graph height (on paper) in mm \\ \hline \ttt{?x\_log} & false & Logical & Whether the $x$-axis scale is linear or logarithmic \\ \hline \ttt{?y\_log} & false & Logical & Whether the $y$-axis scale is linear or logarithmic \\ \hline \ttt{x\_min} & \emph{undefined} & Real & Lower bound for the $x$ axis \\ \hline \ttt{x\_max} & \emph{undefined} & Real & Upper bound for the $x$ axis \\ \hline \ttt{y\_min} & \emph{undefined} & Real & Lower bound for the $y$ axis \\ \hline \ttt{y\_max} & \emph{undefined} & Real & Upper bound for the $y$ axis \\ \hline \ttt{gmlcode\_bg} & \ttt{""} & GAMELAN & Code to be executed before drawing \\ \hline \ttt{gmlcode\_fg} & \ttt{""} & GAMELAN & Code to be executed after drawing \\ \hline \end{tabular} \end{center} \end{table} \begin{table} \caption{Drawing options. The content of strings of type GAMELAN must be valid GAMELAN code. The behavior w.r.t. the flags with \emph{undefined} default value depends on the type of graph element. Histograms: draw baseline, piecewise, fill area, draw curve, no errors, no symbols; Plots: no baseline, no fill, draw curve, no errors, no symbols.} \label{tab:drawing-options} \begin{center} \begin{tabular}{|l|l|l|l|} \hline Variable & Default & Type & Meaning \\ \hline\hline \ttt{?draw\_base} & \emph{undefined} & Logical & Whether to draw a baseline for the curve \\ \hline \ttt{?draw\_piecewise} & \emph{undefined} & Logical & Whether to draw bins separately (histogram) \\ \hline \ttt{?fill\_curve} & \emph{undefined} & Logical & Whether to fill area between baseline and curve \\ \hline \ttt{\$fill\_options} & \ttt{""} & GAMELAN & Options for filling the area \\ \hline \ttt{?draw\_curve} & \emph{undefined} & Logical & Whether to draw the curve as a line \\ \hline \ttt{\$draw\_options} & \ttt{""} & GAMELAN & Options for drawing the line \\ \hline \ttt{?draw\_errors} & \emph{undefined} & Logical & Whether to draw error bars for data points \\ \hline \ttt{\$err\_options} & \ttt{""} & GAMELAN & Options for drawing the error bars \\ \hline \ttt{?draw\_symbols} & \emph{undefined} & Logical & Whether to draw symbols at data points \\ \hline \ttt{\$symbol} & Black dot & GAMELAN & Symbol to be drawn \\ \hline \ttt{gmlcode\_bg} & \ttt{""} & GAMELAN & Code to be executed before drawing \\ \hline \ttt{gmlcode\_fg} & \ttt{""} & GAMELAN & Code to be executed after drawing \\ \hline \end{tabular} \end{center} \end{table} \section{Drawing options} The options for coloring lines, filling curves, or choosing line styles make use of macros in the GAMELAN language. At this place, we do not intend to give a full account of the possiblities, but we rather list a few basic features that are likely to be useful for drawing graphs. \subsubsection{Colors} GAMELAN knows about basic colors identified by name: \begin{center} \ttt{black}, \ttt{white}, \ttt{red}, \ttt{green}, \ttt{blue}, \ttt{cyan}, \ttt{magenta}, \ttt{yellow} \end{center} More generically, colors in GAMELAN are RGB triplets of numbers (actually, numeric expressions) with values between 0 and 1, enclosed in brackets: \begin{center} \ttt{(\emph{r}, \emph{g}, \emph{b})} \end{center} To draw an object in color, one should apply the construct \ttt{withcolor \emph{color}} to its drawing code. The default color is always black. Thus, this will make a plot drawn in blue: \begin{quote} \begin{footnotesize} \ttt{\$draw\_options = "withcolor blue"} \end{footnotesize} \end{quote} and this will fill the drawing area of some histogram with an RGB color: \begin{quote} \begin{footnotesize} \ttt{\$fill\_options = "withcolor (0.8, 0.7, 1)"} \end{footnotesize} \end{quote} \subsubsection{Dashes} By default, lines are drawn continuously. Optionally, they can be drawn using a \emph{dash pattern}. Predefined dash patterns are \begin{center} \ttt{evenly}, \ttt{withdots}, \ttt{withdashdots} \end{center} Going beyond the predefined patterns, a generic dash pattern has the syntax \begin{center} \ttt{dashpattern (on \emph{l1} off \emph{l2} on} \ldots \ttt{)} \end{center} with an arbitrary repetition of \ttt{on} and \ttt{off} clauses. The numbers \ttt{\emph{l1}}, \ttt{\emph{l2}}, \ldots\ are lengths measured in pt. To apply a dash pattern, the option syntax \ttt{dashed \emph{dash-pattern}} should be used. Options strings can be concatenated. Here is how to draw in color with dashes: \begin{quote} \begin{footnotesize} \ttt{\$draw\_options = "withcolor red dashed evenly"} \end{footnotesize} \end{quote} and this draws error bars consisting of intermittent dashes and dots: \begin{quote} \begin{footnotesize} \ttt{\$err\_options = "dashed (withdashdots scaled 0.5)"} \end{footnotesize} \end{quote} The extra brackets ensure that the scale factor $1/2$ is applied only the dash pattern. \subsubsection{Hatching} Areas (e.g., below a histogram) can be filled with plain colors by the \ttt{withcolor} option. They can also be hatched by stripes, optionally rotated by some angle. The syntax is completely analogous to dashes. There are two predefined \emph{hatch patterns}: \begin{center} \ttt{withstripes}, \ttt{withlines} \end{center} and a generic hatch pattern is written \begin{center} \ttt{hatchpattern (on \emph{w1} off \emph{w2} on} \ldots \ttt{)} \end{center} where the numbers \ttt{\emph{l1}}, \ttt{\emph{l2}}, \ldots\ determine the widths of the stripes, measured in pt. When applying a hatch pattern, the pattern may be rotated by some angle (in degrees) and scaled. This looks like \begin{quote} \begin{footnotesize} \ttt{\$fill\_options = "hatched (withstripes scaled 0.8 rotated 60)"} \end{footnotesize} \end{quote} \subsubsection{Smooth curves} Plot points are normally connected by straight lines. If data are acquired by statistical methods, such as Monte Carlo integration, this is usually recommended. However, if a plot is generated using an analytic mathematical formula, or with sufficient statistics to remove fluctuations, it might be appealing to connect lines by some smooth interpolation. GAMELAN can switch on spline interpolation by the specific drawing option \ttt{linked smoothly}. Note that the results can be surprising if the data points do have sizable fluctuations or sharp kinks. \subsubsection{Error bars} Plots and histograms can be drawn with error bars. For histograms, only vertical error bars are supported, while plot points can have error bars in $x$ and $y$ direction. Error bars are switched on by the \ttt{?draw\_errors} flag. There is an option to draw error bars with ticks: \ttt{withticks} and an alternative option to draw arrow heads: \ttt{witharrows}. These can be used in the \ttt{\$err\_options} string. \subsubsection{Symbols} To draw symbols at plot points (or histogram midpoints), the flag \ttt{?draw\_symbols} has to be switched on. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Fast Detector Simulation and External Analysis} \label{chap:ext_anal} Events from a Monte Carlo event generator are further used in an analysis, most often combined with a detector simulation. Event files from the generator are then classified whether they are (i) parton level (coming from the hard matrix element) for which mostly LHE or \hepmc\ event formats are used, particle level (after parton shower and hadronization) - usually in \hepmc\ or \lcio\ format -, or detector level objects. The latter is the realm of packages like \ROOT\ or specific software from the experimental software frameworks. While detailed experimental studies take into account the best-possible detector description in a so-called full simulation via \geant\ which takes several seconds per event, fast studies are made with parameterized fast detector simulations like in \delphes\ or \texttt{SGV}. In the following, we discuss the options to interface external packages for these purposes or to pipe events from \whizard\ to such external packages. %%%%% \section{Interfacing ROOT} \label{sec:root} One of the most distributed analysis framework is \ROOT~\cite{Brun:1997pa}. In \whizard\ for the moment there is no direct interface to the \ROOT\ framework. The easiest way to write out particle-level events in the \ROOT\ or \ttt{RootTree} format is to use \whizard's interface to \hepmcthree: this modern incarnation of the \hepmc\ format has different writer classes, where the writer class for \ROOT\ and \ttt{RootTree} files is supported by \whizard's \hepmcthree\ interface. For this to work, one only has to make sure that \hepmcthree\ has been built with \ROOT\ support, and that the \whizard\ \ttt{configure} has to detect the \ROOT\ setup on the computing environment. For more details cf. the installation section~\ref{sec:hepmc}. If this has been successfully linked, then \whizard\ can use its own \hepmcthree\ interface to write out \ROOT\ or \ttt{RootTree} formats. This can be done by setting the following options in the \sindarin\ files: \begin{code} $hepmc3_mode = "Root" \end{code} or \begin{code} $hepmc3_mode = "RootTree" \end{code} For more details cf.~the \ROOT\ manual and documentation therein. %%%%% \section{Interfacing RIVET} \label{sec:rivet} \rivet~\cite{Buckley:2010ar} is a very mighty analysis framework which has been developed to make experimental analyses from the LHC experiments available for non-collaboration members. It can be easily used to analyze events and produce high-quality plots for differential distributions and experimental observables. Since version 3~\cite{Bierlich:2019rhm} there is now also a lot of functionality that comes very handy for plotting differential distributions at fixed order in NLO calculations, e.g. negative weights in bins or how to treat imperfectly balanced events and counterevents close to bin boundaries etc. For the moment, \whizard\ does not have a dedicated interface to \rivet, so the preferred method is to write out events, best in the \hepmc\ or \hepmcthree\ format and then read them into \rivet. A more sophisticated interface is foreseen for a future version of \whizard, while there are already development versions where \whizard\ detects all the \rivet\ infrastructure and libraries. But they are not yet used. For more details and practical examples cf.~the \rivet\ manual. This describes in detail especially the \rivet\ installation. A typical error that occurs on systems where no \ROOT\ is installed (cf.~Sec.~\ref{sec:root}) is the one these \ttt{Missing TPython.h} missing headers. Then \rivet\ can nevertheless be easily built without \ROOT\ support by setting \begin{code} --disable-root \end{code} in the \ttt{rivet-bootstrap} script. For an installation of \rivet\ it is favorable to include the location of the \rivet\ \python\ scripts in the \ttt{PYTHONPATH} environment variable. They can be accessed from the \rivet\ configuration script as \begin{code} /rivet-config --pythonpath \end{code} If the \python\ path is not known within the environment variables, then one commonly encounters error like \ttt{No module named rivet} or \ttt{Import error: no module named yoda} when running \rivet\ scripts like e.g. \ttt{yodamerge}. If you use a \rivet\ version older than \ttt{v3.1.1} there is no support for \hepmcthree\ yet, so when using \hepmcthree\ with \whizard\ please use the backwards compatibility mode of \hepmcthree in the \sindarin\ file: \begin{code} $hepmc3_mode = "HepMC2" \end{code} When using MPI parallelized runs of \whizard\ there will a large number of different \ttt{.hepmc} files (also if some grid architecture has produced these event files in junks). Then one has to first merge these event files. Here, we quickly explain how to steer \rivet\ for your own analysis. For more details, please confer the \rivet\ manual. \begin{enumerate} \item The command \begin{code} rivet-mkanalysis \end{code} creates a template \rivet\ plugin for the analysis \ttt{.cc}, a template info file \ttt{.info} amd a template file for the plot generation \ttt{.plot}. Note that this overwrites potentially existing files in this folder with the same name. \item Now, analysis statements like e.g. cuts etc. can be implemented in \ttt{.cc}. For analysis of parton-level events without parton showering, the cuts can be equivalent to those in \whizard, i.e. the generator-level cuts can be as strict as the analysis cuts to avoid generating unnecessary events. If parton showering is applied it is better to have looser generator than analysis cuts to avoid undesired plot artifacts. \item Next, one executes the command (the shared library name might be different e.g. on Darwin or BSD OS) \begin{code} rivet-buildplugin Rivet.so .cc \end{code} This creates an executable \rivet\ analysis library \ttt{Rivet.so}. The custom analysis should now appear in the output of \begin{code} rivet --list \end{code} If this is not the case, the analysis path has to be exported first as \ttt{RIVET\_ANALYSIS\_PATH=\$PWD}. \item We are now ready to use the custom analysis to analyze the \ttt{.hepmc} events by executing the command \begin{code} rivet --pwd --analysis= -o .yoda \end{code} and save the produced histograms of the analysis in the \ttt{.yoda} format. In general the option \ttt{--ignore-beams} for \rivet\ should be used to prevent \rivet\ to stumble over beam remnants. This is also relevant for lepton collider processes with electron PDFs. For a large number of events, event files can become very big. To avoid writing them all on disk, a FIFO for the \ttt{} can be used. \item Different \ttt{yoda} files can now be merged into a single file using the command \begin{code} _full.yoda _01.yoda ... \end{code} This should be applied e.g. for the case of fixed-order NLO differential distributions where Born, real and virtual components have been generated separately. \item Finally, plots can be produced: after listing all the histograms to be plotted in the plot file \ttt{.plot}, the command \begin{code} rivet-mkhtml _full.yoda \end{code} translates the \ttt{.yoda} file into a histogram file in the \ttt{.dat} format. These plots can either be visually enhanced by modifying the \ttt{.plot} file as is described on the webpage \url{https://rivet.hepforge.org/make-plots.html}, or by using any other external plotting tool like e.g. \ttt{Gnuplot} for the \ttt{.dat} files. \end{enumerate} Clearly, this gives only a rough sketch on how to use \rivet\ for an analysis. For more details, please consult the \rivet\ webpage and the \rivet\ manual. %%%%% \vspace{1cm} \section{Fast Detector Simulation with DELPHES} \label{sec:delphes} Fast detector simulation allows relatively quick checks whether experimental analyses actually work in a semi-realistic detector study. There are some older tools for fast simulation like e.g.~\ttt{PGS} (which is no longer actively maintained) and \ttt{SGV} which is default fast simulation for ILC studies. For LHC and general future hadron collider studies, \delphes~\cite{deFavereau:2013fsa} is the most commonly used tool for fast detector simulation. The details on how to obtain and build \delphes\ can be obtained from their webpage, \url{https://cp3.irmp.ucl.ac.be/projects/delphes}. It depends both on~\ttt{Tcl/Tk} as well as \ROOT~(cf. Sec.~\ref{sec:root}. Interfacing any Monte Carlo event generator with a fast detector simulation like \delphes\ is rather trivial: \delphes\ ships with up to five executables \begin{code} DelphesHepMC DelphesLHEF DelphesPythia8 DelphesROOT DelphesSTDHEP \end{code} \ttt{DelphesPythia8} is a direct interface between \pythiaeight\ and \delphes, so detector-level events are directly produced via an API interface between \pythiaeight\ and \delphes. This is the most convenient method which is foreseen for \whizard, however not yet implemented. The other four binaries take input files in the \hepmc, LHE, \stdhep\ and \ROOT\ format, apply a fast detector simulation according to the chosen input file and give a \ROOT\ detector-level event file as output. Executing one of the binaries above without options, the following message will be displayed: \begin{code} ./DelphesHepMC Usage: DelphesHepMC config_file output_file [input_file(s)] config_file - configuration file in Tcl format, output_file - output file in ROOT format, input_file(s) - input file(s) in HepMC format, with no input_file, or when input_file is -, read standard input. \end{code} Using \delphes\ with \hepmc\ event files then works as \begin{code} ./DelphesHepMC cards/delphes_card_ATLAS.tcl output.root input.hepmc \end{code} For \stdhep\ files which are directly by \whizard\ without external packages (only assuming that the XDR C libraries are present on the system), execute \begin{code} ./DelphesSTDHEP cards/delphes_card_ILD.tcl delphes_output.root input.hep \end{code} For LHE files as input, use \begin{code} ./DelphesLHEF cards/delphes_card_CLICdet_Stage1.tcl delphes_output.root input.lhef \end{code} and for \ROOT\ (particle-level) files use \begin{code} ./DelphesROOT cards/delphes_card_CMS.tcl delphes_output.root input.root \end{code} In the \delphes\ cards directory, there is a long list of supported input files for existing and future detectors, a few of which we have displayed here. \delphes\ detector-level output files can then be analyzed with \ROOT\ as described in the \delphes\ manual. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{User Interfaces for WHIZARD} \label{chap:userint} \section{Command Line and \sindarin\ Input Files} \label{sec:cmdline-options} The standard way of using \whizard\ involves a command script written in \sindarin. This script is executed by \whizard\ by mentioning it on the command line: \begin{interaction} whizard script-name.sin \end{interaction} You may specify several script files on the command line; they will be executed consecutively. If there is no script file, \whizard\ will read commands from standard input. Hence, this is equivalent: \begin{interaction} cat script-name.sin | whizard \end{interaction} When executed from the command line, \whizard\ accepts several options. They are given in long form, i.e., they begin with two dashes. Values that belong to options follow the option string, separated either by whitespace or by an equals sign. Hence, \ttt{--prefix /usr} and \ttt{--prefix=/usr} are equivalent. Some options are also available in short form, a single dash with a single letter. Short-form options can be concatenated, i.e., a dash followed by several option letters. The first set of options is intended for normal operation. \begin{description} \item[\ttt{--debug AREA}]: Switch on debug output for \ttt{AREA}. \ttt{AREA} can be one of \whizard's source directories or \ttt{all}. \item[\ttt{--debug2 AREA}]: Switch on more verbose debug output for \ttt{AREA}. \item[\ttt{--single-event}]: Only compute one phase-space point (for debugging). \item[\ttt{--execute COMMANDS}]: Execute \ttt{COMMANDS} as a script before the script file (see below). Short version: \ttt{-e} \item[\ttt{--file CMDFILE}]: Execute commands in \ttt{CMDFILE} before the main script file (see below). Short version: \ttt{-f} \item[\ttt{--help}]: List the available options and exit. Short version: \ttt{-h} \item[\ttt{--interactive}]: Run \whizard\ interactively. See Sec.~\ref{sec:whish}. Short version: \ttt{-i}. \item[\ttt{--library LIB}]: Preload process library \ttt{LIB} (instead of the default \ttt{processes}). Short version: \ttt{-l}. \item[\ttt{--localprefix DIR}]: Search in \ttt{DIR} for local models. Default is \ttt{\$HOME/.whizard}. \item[\ttt{--logfile \ttt{FILE}}]: Write log to \ttt{FILE}. Default is \ttt{whizard.log}. Short version: \ttt{-L}. \item[\ttt{--logging}]: Start logging on startup (default). \item[\ttt{--model MODEL}]: Preload model \ttt{MODEL}. Default is the Standard Model \ttt{SM}. Short version: \ttt{-m}. \item[\ttt{--no-banner}]: Do not display banner at startup. \item[\ttt{--no-library}]: Do not preload a library. \item[\ttt{--no-logfile}]: Do not write a logfile. \item[\ttt{--no-logging}]: Do not issue information into the logfile. \item[\ttt{--no-model}]: Do not preload a specific physics model. \item[\ttt{--no-rebuild}]: Do not force a rebuild. \item[\ttt{--query VARIABLE}]: Display documentation of \ttt{VARIABLE}. Short version: \ttt{-q}. \item[\ttt{--rebuild}]: Do not preload a process library and do all calculations from scratch, even if results exist. This combines all rebuild options. Short version: \ttt{-r}. \item[\ttt{--rebuild-library}]: Rebuild the process library, even if code exists. \item[\ttt{--rebuild-phase-space}]: Rebuild the phase space setup, even if it exists. \item[\ttt{--rebuild-grids}]: Redo the integration, even if previous grids and results exist. \item[\ttt{--rebuild-events}]: Redo event generation, discarding previous event files. \item[\ttt{--show-config}]: Show build-time configuration. \item[\ttt{--version}]: Print version information and exit. Short version: \ttt{-V}. \item[-]: Any further options are interpreted as file names. \end{description} The second set of options refers to the configuration. They are relevant when dealing with a relocated \whizard\ installation, e.g., on a batch systems. \begin{description} \item[\ttt{--prefix DIR}]: Specify the actual location of the \whizard\ installation, including all subdirectories. \item[\ttt{--exec-prefix DIR}]: Specify the actual location of the machine-specific parts of the \whizard\ installation (rarely needed). \item[\ttt{--bindir DIR}]: Specify the actual location of the executables contained in the \whizard\ installation (rarely needed). \item[\ttt{--libdir DIR}]: Specify the actual location of the libraries contained in the \whizard\ installation (rarely needed). \item[\ttt{--includedir DIR}]: Specify the actual location of the include files contained in the \whizard\ installation (rarely needed). \item[\ttt{--datarootdir DIR}]: Specify the actual location of the data files contained in the \whizard\ installation (rarely needed). \item[\ttt{--libtool LOCAL\_LIBTOOL}]: Specify the actual location and name of the \ttt{libtool} script that should be used by \whizard. \item[\ttt{--lhapdfdir DIR}]: Specify the actual location and of the \lhapdf\ installation that should be used by \whizard. \end{description} The \ttt{--execute} and \ttt{--file} options allow for fine-tuning the command flow. The \whizard\ main program will concatenate all commands given in \ttt{--execute} commands together with all commands contained in \ttt{--file} options, in the order they are encountered, as a contiguous command stream that is executed \emph{before} the main script (in the example above, \ttt{script-name.sin}). Regarding the \ttt{--execute} option, commands that contain blanks must be enclosed in matching single- or double-quote characters since the individual tokens would otherwise be intepreted as separate option strings. Unfortunately, a Unix/Linux shell interpreter will strip quotes before handing the command string over to the program. In that situation, the quote-characters must be quoted themselves, or the string must be enclosed in quotes twice. Either version should work as a command line interpreted by the shell: \begin{interaction} whizard --execute \'int my_flag = 1\' script-name.sin whizard --execute "'int my_flag = 1'" script-name.sin \end{interaction} \section{WHISH -- The \whizard\ Shell/Interactive mode} \label{sec:whish} \whizard\ can be also run in the interactive mode using its own shell environment. This is called the \whizard\ Shell (WHISH). For this purpose, one starts with the command \begin{interaction} /home/user$ whizard --interactive \end{interaction} or \begin{interaction} /home/user$ whizard -i \end{interaction} \whizard\ will preload the Standard Model and display a command prompt: \begin{interaction} whish? \end{interaction} You now can enter one or more \sindarin\ commands, just as if they were contained in a script file. The commands are compiled and executed after you hit the ENTER key. When done, you get a new prompt. The WHISH can be closed by the \ttt{quit} command: \begin{verbatim} whish? quit \end{verbatim} Obviously, each input must be self-contained: commands must be complete, and conditionals or scans must be closed on the same line. If \whizard\ is run without options and without a script file, it also reads commands interactively, from standard input. The difference is that in this case, interactive input is multi-line, terminated by \ttt{Ctrl-D}, the script is then compiled and executed as a whole, and \whizard\ terminates. In WHISH mode, each input line is compiled and executed individually. Furthermore, fatal errors are masked, so in case of error the program does not terminate but returns to the WHISH command line. (The attempt to recover may fail in some circumstances, however.) \section{Graphical user interface} \emph{This is still experimental.} \whizard\ ships with a graphical interface that can be steered in a browser of your choice. It is located in \ttt{share/gui}. To use it, you have to run \ttt{npm install} (which will install javascript libraries locally in that folder) and \ttt{npm start} (which will start a local web server on your machine) in that folder. More technical details and how to get \ttt{npm} is discussed in \ttt{share/gui/README.md}. When it is running, you can access the GUI by entering \ttt{localhost:3000} as address in your browser. The GUI is separated into different tabs for basic settings, integration, simulation, cuts, scans, NLO and beams. You can select and enter what you are interested in and the GUI will produce a \sindarin\ file. You can use the GUI to run WHIZARD with that \sindarin\ or just produce it with the GUI and then tweak it further with an editor. In case you run it in the GUI, the log file will be updated in the browser as it is produced. Any \sindarin\ features that are not supported by the GUI can be added directly as "Additional Code". -\section{WHIZARD as a library} +\section{\whizard\ as a library} -\emph{This is planned, but not implemented yet.} -%%%%% +The compiled \whizard\ program consists of two libraries (\ttt{libwhizard} and +\ttt{libomega}). In the standard setup, these are linked to a short main +program which deals with command line options and top-level administration. +This is the stand-alone \ttt{whizard} executable program. + +Alternatively, it is possible to link the libraries to a different main +program of the user's choice. The user program can take complete control of +the \whizard\ features. The \ttt{libwhizard} library provides an API, a +well-defined set of procedures which can be called from a foreign main +program. The supported languages are Fortran, C, and C++. Using the C API, +any other language which supports linking against C libraries can also be +interfaced. + +\subsection{Fortran main program} + +To link a Fortran main program with the \whizard\ library, the following steps +must be performed: +\begin{enumerate} +\item + Configure, build and install \whizard\ as normal. +\item + Include code for accessing \whizard\ functionality in the user program. + The code should initialize + \whizard, execute the intended commands, and finalize. For an example, see + below. +\item + Compile the user program. The user program must be + compiled with the same Fortran compiler that has been used for the \whizard\ + build. + + If necessary, specify an option that finds the + installed \whizard\ module files. + For instance, if \whizard\ has been installed in \ttt{whizard-path}, this + should read + \begin{code} + -Iwhizard-path/lib/mod/whizard + \end{code} +\item + Link the program (or compile-link in a single step). If necessary, specify + options that find the installed \whizard\ and \oMega\ libraries. For + instance, if \whizard\ has been installed in \ttt{whizard-path}, this should + read + \begin{code} + -Lwhizard-path/lib -lwhizard -lwhizard_prebuilt -lomega + \end{code} + On some systems, you may have to replace \ttt{lib} by \ttt{lib64}. + + Such an example compile-link could look like + \begin{code} + gfortran manual_example_api.f90 -Lwhizard-path/lib -lwhizard -lwhizard_prebuilt -lomega + \end{code} + + If \whizard\ has been compiled with a non-default Fortran compiler, you may + have to explicitly link the appropriate Fortran run-time libraries. + + The \ttt{tirpc} library is used by the \ttt{StdHEP} subsystem for \ttt{xdr} + functionality. This library should be present on the host + system. This library needs only be linked of the SunRPC library is + not installed on the system. + + If additional libraries such as + \hepmc\ are enabled in the \whizard\ configuration, it may be necessary to + provide extra options for linking those. + + An example here looks like + \begin{code} + gfortran manual_example_api.f90 -Lwhizard-path/lib -lwhizard + -lwhizard_prebuilt -lomega -lHepMC3 -lHepMC3rootIO -llcio + \end{code} + +\item + Run the program. If necessary, provide the path to the installed shared + libraries. For instance, if \whizard\ has been installed in + \ttt{whizard-path}, this should read + \begin{code} + export LD_LIBRARY_PATH="whizard-path/lib:$LD_LIBRARY_PATH" + \end{code} + On some systems, you may have to replace \ttt{lib} by \ttt{lib64}, as above. + + The \whizard\ subsystem will work with input and output + files in the current working directory, unless asked to do otherwise. +\end{enumerate} +Below is an example program, adapted from \whizard's internal unit-test suite. +The user program controls the \whizard\ workflow in the same way as a +\sindarin\ script would do. The commands are a mixture of \sindarin\ command +calls and functionality for passing information between the \whizard\ +subsystem and the host program. +In particular, the program can process generated events one-by-one. +\begin{code} +program main + + ! WHIZARD API as a module + use api + + ! Standard numeric types + use iso_fortran_env, only: real64, int32 + + implicit none + + ! WHIZARD and event-sample objects + type(whizard_api_t) :: whizard + type(simulation_api_t) :: sample + + ! Local variables + real(real64) :: integral, error + real(real64) :: sqme, weight + integer(int32) :: idx + integer(int32) :: i, it_begin, it_end + + ! Initialize WHIZARD, setting some global option + call whizard%option ("model", "QED") + call whizard%init () + + ! Define a process, set some variables + call whizard%command ("process mupair = e1, E1 => e2, E2") + call whizard%set_var ("sqrts", 100._real64) + call whizard%set_var ("seed", 0) + + ! Generate matrix-element code, integrate and retrieve result + call whizard%command ("integrate (mupair)") + call whizard%get_integration_result ("mupair", integral, error) + + ! Print result + print 1, "cross section =", integral / 1000, "pb" + print 1, "error =", error / 1000, "pb" +1 format (2x,A,1x,F5.1,1x,A) +2 format (2x,A,1x,L1) + + ! Settings for event generation + call whizard%set_var ("$sample", "mupair_events") + call whizard%set_var ("n_events", 2) + + ! Create an event-sample object and generate events + call whizard%new_sample ("mupair", sample) + call sample%open (it_begin, it_end) + do i = it_begin, it_end + call sample%next_event () + call sample%get_event_index (idx) + call sample%get_weight (weight) + call sample%get_sqme (sqme) + print "(A,I0)", "Event #", idx + print 3, "sqme =", sqme + print 3, "weight =", weight +3 format (2x,A,1x,ES10.3) + end do + + ! Finalize the event-sample object + call sample%close () + + ! Finalize the WHIZARD object + call whizard%final () + +end program main +\end{code} +The API provides the following commands as Fortran subroutines. Most of them +are used in the example above. + +\subsubsection{Module} +There is only one module from the \whizard\ package which must be +\texttt{use}d by the user program: +\begin{quote} + \tt use api +\end{quote} +You may \texttt{use} any other \whizard\ module in our program, all module +files are part of the installation. Be aware, +however, that all other modules are considered internal. Unless explictly +mentioned in this manual, interfaces are +not documented here and may change between versions. + +Changes to the \ttt{api} module, if any, will be documented here. + +\subsubsection{Master object} +All functionality is accessed via a master API object which should be declared +as follows: +\begin{quote} + \tt type(whizard\_api\_t) :: whizard +\end{quote} +There should be only one master object. + +\subsubsection{Pre-Initialization options} +Before initializing the API object, it is possible to provide options. The +available options mirror the command-line options of the stand-alone program, +cf.\ Sec.~\ref{sec:cmdline-options}. +\begin{quote} + \tt call whizard\%option (\textit{key}, \textit{value}) +\end{quote} +All keys and values are Fortran character strings. The following options are +available. For all options, default values exist as listed in +Sec.~\ref{sec:cmdline-options}. +\begin{description} +\item[\tt model] Model that should be preloaded. +\item[\tt library] Name of the library where matrix-element code should end up. +\item[\tt logfile] Name of the logfile that \whizard\ will write. +\item[\tt job\_id] Name of the current job; can be used for writing unique output + files. +\item[\tt unpack] Comma-separated list of files to be uncompressed and unpacked + (via \ttt{tar} and \ttt{gzip}) when \ttt{init} is called on the API object. +\item[\tt pack] Comma-separated list of files or directories to be packed and + compressed when \ttt{final} is called. +\item[\tt rebuild] All of the following: +\item[\tt rebuild\_library] Force rebuilding a matrix-element code library, + overwriting results from a previous run. +\item[\tt recompile] Force recompiling the matrix-element code library. +\item[\tt rebuild\_grids] Force reproducing integration passes. +\item[\tt rebuild\_events] Force regenerating event samples. +\end{description} + +\subsubsection{Initialization and finalization} +After options have been set, the system is initialized via +\begin{quote} + \tt call whizard\%init +\end{quote} +Once initialized, \whizard\ can execute commands as listed below. When this +is complete, clean up by +\begin{quote} + \tt call whizard\%final +\end{quote} + +\subsubsection{Variables and values} + +In the API, \whizard\ requires numeric data types according to the IEEE +standard, which is available to Fortran in the \ttt{iso\_fortran\_env} +intrinsic module. Strictly speaking, integer data must have type \ttt{int32}, +and real data must have type \ttt{real64}. + +For most systems and default compiler settings, it +is not really necessary to \ttt{use} the ISO module and its data types. +Integers map to default Fortran \ttt{integer}, +and real values map to default Fortran \ttt{double precision}. + +As an +alternative, you may \ttt{use} the \whizard\ internal \ttt{kinds} module which +declares a \ttt{real(default)} type +\begin{quote} + \tt use kinds, only: default +\end{quote} +On most systems, this will be equivalent +to \ttt{real(real64)}. + +To set a \sindarin\ variable, use the function that corresponds to the data +type: +\begin{quote} + \tt call whizard\%set\_var (\textit{name}, \textit{value}) +\end{quote} +The name is a Fortran string which has to be equal to the name of the +corresponding \sindarin\ variable, including any prefix character (\$ or ?). +The value depends on the type of the \sindarin\ +variable. + +To retrieve the current value of a variable: +\begin{quote} + \tt call whizard\%get\_var (\textit{name}, \textit{var}) +\end{quote} +The variable must be declared as \ttt{integer}, \ttt{real(real64)}, +\ttt{logical}, or +\ttt{character(:), allocatable}. This depends on the \sindarin\ variable type. + +\subsubsection{Commands} +Any \sindarin\ command can be called via +\begin{quote} + \tt call whizard\%command (\textit{command}) +\end{quote} +\ttt{\it command} is a Fortran character string, as it would appear +in a \sindarin\ script. + +This includes, in particular, the important commands \ttt{process}, +\ttt{integrate}, and \ttt{simulate}. You may also set variables that way. + +\subsubsection{Retrieving cross-section results} +This call returns the results (integration and error) from a preceding +integration run for the process \textit{process-name}: +\begin{quote} + \tt call whizard\%get\_integration\_result ("\textit{process-name}", + integral, error) +\end{quote} +There is also an optional argument \ttt{known} of type \ttt{logical} which is +set if the integration run was successful, so integral and error are +meaningful. + + + +\subsubsection{Event-sample object} +A \ttt{simulate} command will produce an event sample. With the appropriate +settings, the sample will be written to file in any chosen format, to be +post-processed when it is complete. + +However, a possible purpose of using the \whizard\ API is to process events one-by-one +when they are generated. To this end, there is an event-sample handle, which +can be declared in this way: +\begin{quote} + \tt type(simulation\_api\_t) :: sample +\end{quote} +An instance \ttt{sample} of this type is created by this factory method: +\begin{quote} + \tt call whizard\%new\_sample ("\textit{process-name(s)}", sample) +\end{quote} +The command accepts a comma-separated list of process names which should be +included in the event sample. + +To start event generation for this sample, call +\begin{quote} + \tt call sample\%open (\textit{it\_begin}, \textit{it\_end} ) +\end{quote} +where the two output parameters (integers) \ttt{\it it\_begin} and \ttt{\it it\_end} +provide the bounds for an event loop in the calling program. (In serial mode, +the bounds are equal to 1 and \ttt{n\_events}, respectively, but in an MPI +parallel environment, they depend on the computing node.) + +This command generates a new event, to be enclosed within an event loop: +\begin{quote} + \tt call sample\%next\_event +\end{quote} +The event will be available by format-specific access methods, see below. + +This command closes and deletes an event sample after the event loop has +completed: +\begin{quote} + \tt call sample\%close +\end{quote} + +\subsubsection{Retrieving event data} + +After a call to \ttt{next\_event}, the sample object can be queried for +specific event data. +\begin{quote} + \tt call sample\%get\_event\_index (\textit{value}) +\end{quote} +returns the index (integer counter) of the current event. +\begin{quote} + \tt call sample\%get\_process\_index (\textit{value}) + \\ + \tt call sample\%get\_process\_id (\textit{value}) +\end{quote} +returns the numeric (string) ID of the hard process, respectively, that was +generated in this event. The variables must be declared as \ttt{integer} and +\ttt{character(:), allocatable}, respectively. + +The following methods return \ttt{real(real64)} values. +\begin{quote} + \tt call sample\%get\_sqrts (\textit{value}) +\end{quote} +returns the $\sqrt{s}$ value of this event. +\begin{quote} + \tt call sample\%get\_fac\_scale (\textit{value}) +\end{quote} +returns the factorization scale of this event (\textit{value}). +\begin{quote} + \tt call sample\%get\_alpha\_s (\textit{value}) +\end{quote} +returns the value of the strong coupling for this event (\textit{value}). +\begin{quote} + \tt call sample\%get\_sqme (\textit{value}) +\end{quote} +returns the value of the squared matrix element (summed over final states and +averaged over initial states). +\begin{quote} + \tt call sample\%get\_weight (\textit{value}) +\end{quote} +returns the Monte-Carlo weight of this event. + +Access to the event record depends on the event format that has been +selected. The format must allow access to individual events via data +structures in memory. There are three cases where such structures exist and +are accessible: +\begin{enumerate} +\item + If the event format uses a COMMON block, event data is accessible + via this COMMON block, which must be declared in the calling routine. +\item + The \hepmc\ event format communicates via a C++ object. In Fortran, there + is a wrapper which has to be declared as + \begin{quote} + \tt type(hepmc\_event\_t) :: hepmc\_event + \end{quote} + To activate this handle, the \ttt{next\_event} call must reference it as + an argument: + \begin{quote} + \tt call sample\%next\_event (hepmc\_event) + \end{quote} + The \whizard\ module \ttt{hepmc\_interface} contains procedures which can + work with this record. A pointer to the actual C++ object can be retrieved + as a Fortran + \ttt{c\_ptr} object as follows: + \begin{quote} + \tt + type(c\_ptr) :: hepmc\_ptr + \\ + \dots + \\ + hepmc\_ptr = hepmc\_event\_get\_c\_ptr (hepmc\_event) + \end{quote} +\item + The \lcio\ event format also communicates via a C++ object. The access + methods are entirely analogous, replacing \ttt{hepmc} by \ttt{lcio} in all + calls and names. +\end{enumerate} + + +\subsection{C main program} +To link a C main program with the \whizard\ library, the following steps +must be performed: +\begin{enumerate} +\item + Configure, build and install \whizard\ as normal. +\item + Include code for accessing \whizard\ functionality in the user program. + The code should initialize + \whizard, execute the intended commands, and finalize. For an example, see + below. +\item + Compile the user program with the option that finds the WHIZARD C/C++ + interface header file. + For instance, if \whizard\ has been installed in \ttt{whizard-path}, this + should read + \begin{code} + -Iwhizard-path/include + \end{code} +\item + Link the program with the necessary libraries (or compile-link in a single + step). If + \whizard\ has been installed in a system path, this should work + automatically. If + \whizard\ has been installed in a non-default \ttt{whizard-path}, these + are the options: + \begin{code} + -Lwhizard-path/lib -lwhizard -lwhizard_prebuilt -lomega -ltirpc + \end{code} + On some systems, you may have to replace \ttt{lib} by \ttt{lib64}. + + If \whizard\ has been compiled with a non-default Fortran compiler, you may + have to explicitly link the appropriate Fortran run-time libraries. + + The \ttt{tirpc} library is used by the \ttt{StdHEP} subsystem for \ttt{xdr} + functionality. This library should be present on the host + system. Cf. the corresponding remarks in the section for a + \fortran\ main program. + + If additional libraries such as + \hepmc\ are enabled in the \whizard\ configuration, it may be necessary to + provide extra options for linking those. + +\item + Run the program. If necessary, provide the path to the installed shared + libraries. For instance, if \whizard\ has been installed in + \ttt{whizard-path}, this should read + \begin{code} + export LD_LIBRARY_PATH="whizard-path/lib:$LD_LIBRARY_PATH" + \end{code} + On some systems, you may have to replace \ttt{lib} by \ttt{lib64}, as above. + + The \whizard\ subsystem will work with input and output + files in the current working directory, unless asked to do otherwise. +\end{enumerate} +Below is an example program, adapted from \whizard's internal unit-test suite. +The user program controls the \whizard\ workflow in the same way as a +\sindarin\ script would do. The commands are a mixture of \sindarin\ command +calls and functionality for passing information between the \whizard\ +subsystem and the host program. +In particular, the program can process generated events one-by-one. +\begin{code} +#include +#include "whizard.h" + +int main( int argc, char* argv[] ) +{ + /* WHIZARD and event-sample objects */ + void* wh; + void* sample; + + /* Local variables */ + double integral, error; + double sqme, weight; + int idx; + int it, it_begin, it_end; + + /* Initialize WHIZARD, setting some global option */ + whizard_create( &wh ); + whizard_option( &wh, "model", "QED" ); + whizard_init( &wh ); + + /* Define a process, set some variables */ + whizard_command( &wh, "process mupair = e1, E1 => e2, E2" ); + whizard_set_double( &wh, "sqrts", 10. ); + whizard_set_int( &wh, "seed", 0 ); + + /* Generate matrix-element code, integrate and retrieve result */ + whizard_command( &wh, "integrate (mupair)" ); + + /* Print result */ + whizard_get_integration_result( &wh, "mupair", &integral, &error); + printf( " cross section = %5.1f pb\n", integral / 1000. ); + printf( " error = %5.1f pb\n", error / 1000. ); + + /* Settings for event generation */ + whizard_set_char( &wh, "$sample", "mupair_events" ); + whizard_set_int( &wh, "n_events", 2 ); + + /* Create an event-sample object and generate events */ + whizard_new_sample( &wh, "mupair", &sample ); + whizard_sample_open( &sample, &it_begin, &it_end ); + for (it=it_begin; it<=it_end; it++) { + whizard_sample_next_event( &sample ); + whizard_sample_get_event_index( &sample, &idx ); + whizard_sample_get_weight( &sample, &weight ); + whizard_sample_get_sqme( &sample, &sqme ); + printf( "Event #%d\n", idx ); + printf( " sqme = %10.3e\n", sqme ); + printf( " weight = %10.3e\n", weight ); + } + + /* Finalize the event-sample object */ + whizard_sample_close( &sample ); + + /* Finalize the WHIZARD object */ + whizard_final( &wh ); +} +\end{code} + +\subsubsection{Header} +The necessary declarations are imported by the directive +\begin{quote} + \tt \#include "whizard.h" +\end{quote} + +\subsubsection{Master object} +All functionality is accessed via a master API object which should be declared +as a \ttt{void*} pointer: +\begin{quote} + \tt void* wh; +\end{quote} +The object must be explicitly created: +\begin{quote} + \tt whizard\_create( \&wh ); +\end{quote} +There should be only one master object. + +\subsubsection{Pre-Initialization options} +Before initializing the API object, it is possible to provide options. The +available options mirror the command-line options of the stand-alone program, +cf.\ Sec.~\ref{sec:cmdline-options}. +\begin{quote} + \tt whizard\_option( \&wh, \textit{key}, \textit{value} ); +\end{quote} +All keys and values are null-terminated C character strings. The available +options are +listed above in the Fortran interface documentation. + +\subsubsection{Initialization and finalization} +After options have been set, the system is initialized via +\begin{quote} + \tt whizard\_init( \&wh ); +\end{quote} +Once initialized, \whizard\ can execute commands as listed below. When this +is complete, clean up by +\begin{quote} + \tt whizard\_final( \&wh ); +\end{quote} + +\subsubsection{Variables and values} + +In the API, \whizard\ requires numeric data types according to the IEEE +standard. Integers map to C \ttt{int}, and real values map to C +\ttt{double}. Logical values map to C \ttt{int} interpreted as \ttt{bool}, +and string values map to null-terminated C strings. + +To set a \sindarin\ variable of appropriate type: +\begin{quote} + \tt whizard\_set\_int ( \&wh, \textit{name}, \textit{value} ); + \\ + \tt whizard\_set\_double ( \&wh, \textit{name}, \textit{value} ); + \\ + \tt whizard\_set\_bool ( \&wh, \textit{name}, \textit{value} ); + \\ + \tt whizard\_set\_char ( \&wh, \textit{name}, \textit{value} ); +\end{quote} +\textit{name} is declared \ttt{const char*}. It must match the corresponding +\sindarin\ variable name, including any prefix character (\$ or ?). +\textit{value} is declared \ttt{const double/int/char*}. + +To retrieve the current value of a variable: +\begin{quote} + \tt whizard\_get\_int ( \&wh, \textit{name}, \&\textit{var} ); + \\ + \tt whizard\_get\_double ( \&wh, \textit{name}, \&\textit{var} ); + \\ + \tt whizard\_get\_bool ( \&wh, \textit{name}, \&\textit{var} ); + \\ + \tt whizard\_get\_char ( \&wh, \textit{name}, \textit{var}, \textit{len} ); +\end{quote} +Here, \ttt{\it var} is a C variable of appropriate type. In the character +case, \ttt{\it var} is a C character array declared as +\ttt{\it var}[\ttt{\it len}]. The functions return zero if the \sindarin\ +variable has a known value. + +\subsubsection{Commands} +Any \sindarin\ command can be called via +\begin{quote} + \tt whizard\_command( \&wh, \textit{command} ); +\end{quote} +\ttt{\it command} is a null-terminated C string that contains commands as they +would appear in a \sindarin\ script. + +This includes, in particular, the important commands \ttt{process}, +\ttt{integrate}, and \ttt{simulate}. You may also set variables that way. + +\subsubsection{Retrieving cross-section results} +This call returns the results (integration and error) from a preceding +integration run for the process \textit{process-name}: +\begin{quote} + \tt whizard\_get\_integration\_result( \&wh, "\textit{process-name}", + \&\textit{integral}, \&\textit{error}) +\end{quote} +\ttt{\it integral} and \ttt{\it error} are C variables of type \ttt{double}. +The function returns zero if the integration run was successful, so integral +and error are meaningful. + +\subsubsection{Event-sample object} +A \ttt{simulate} command will produce an event sample. With the appropriate +settings, the sample will be written to file in any chosen format, to be +post-processed when it is complete. + +However, a possible purpose of using the \whizard\ API is to process events one-by-one +when they are generated. To this end, there is an event-sample handle, which +can be declared in this way: +\begin{quote} + \tt void* \textit{sample}; +\end{quote} +An instance \ttt{\it sample} of this type is created by this factory method: +\begin{quote} + \tt whizard\_new\_sample( \&wh, "\textit{process-name(s)}", \&\textit{sample}); +\end{quote} +The command accepts a comma-separated list of process names which should be +included in the event sample. + +To start event generation for this sample, call +\begin{quote} + \tt whizard\_sample\_open( \&\textit{sample}, \&\textit{it\_begin}, + \&\textit{it\_end} ); +\end{quote} +where the two output variables (\ttt{int}) \ttt{\it it\_begin} and +\ttt{\it it\_end} +provide the bounds for an event loop in the calling program. (In serial mode, +the bounds are equal to 1 and \ttt{n\_events}, respectively, but in an MPI +parallel environment, they depend on the computing node.) + +This command generates a new event, to be enclosed within an event loop: +\begin{quote} + \tt whizard\_sample\_next\_event( \&\textit{sample} ); +\end{quote} +The event will be available by format-specific access methods, see below. + +This command closes and deletes an event sample after the event loop has +completed: +\begin{quote} + \tt whizard\_sample\_close( \&\textit{sample} ); +\end{quote} + +\subsubsection{Retrieving event data} + +After a call to \ttt{whizard\_sample\_next\_event}, the sample object can be +queried for specific event data. +\begin{quote} + \tt whizard\_sample\_get\_event\_index( \&\textit{sample}, \&\textit{value} ); + \\ + \tt whizard\_sample\_get\_process\_index( \&\textit{sample}, \&\textit{value} ); + \\ + \tt whizard\_sample\_get\_process\_id( \&\textit{sample}, \textit{value}, \textit{len} ); + \\ + \tt whizard\_sample\_get\_sqrts( \&\textit{sample}, \&\textit{value} ); + \\ + \tt whizard\_sample\_get\_fac\_scale( \&\textit{sample}, \&\textit{value} ); + \\ + \tt whizard\_sample\_get\_alpha\_s( \&\textit{sample}, \&\textit{value} ); + \\ + \tt whizard\_sample\_get\_sqme( \&\textit{sample}, \&\textit{value} ); + \\ + \tt whizard\_sample\_get\_weight( \&\textit{sample}, \&\textit{value} ); +\end{quote} +where the \ttt{\it value} is a variable of appropriate type (see above). + +Event data are stored in a format-specific way. This may be a COMMON block, +or a \hepmc\ or \lcio\ event record. In the latter cases, cf.\ the C++ API +below for access information. + +\subsection{C++ main program} +To link a C++ main program with the \whizard\ library, the following steps +must be performed: +\begin{enumerate} +\item + Configure, build and install \whizard\ as normal. +\item + Include code for accessing \whizard\ functionality in the user program. + The code should initialize + \whizard, execute the intended commands, and finalize. For an example, see + below. +\item + Compile the user program with the option that finds the WHIZARD C/C++ interface + header file. + For instance, if \whizard\ has been installed in \ttt{whizard-path}, this + should read + \begin{code} + -Iwhizard-path/include + \end{code} +\item + Link the program with the necessary libraries (or compile-link in a single + step). If + \whizard\ has been installed in a system path, this should work + automatically. If + \whizard\ has been installed in a non-default \ttt{whizard-path}, these + are the options: + \begin{code} + -Lwhizard-path/lib -lwhizard -lwhizard_prebuilt -lomega -ltirpc + \end{code} + On some systems, you may have to replace \ttt{lib} by \ttt{lib64}. + + If \whizard\ has been compiled with a non-default Fortran compiler, you may + have to explicitly link the appropriate Fortran run-time libraries. + + The \ttt{tirpc} library is used by the \ttt{StdHEP} subsystem for \ttt{xdr} + functionality. This + library should be present on the host system. + + If additional libraries such as + \hepmc\ are enabled in the \whizard\ configuration, it may be necessary to + provide extra options for linking those. +\item + Run the program. If necessary, provide the path to the installed shared + libraries. For instance, if \whizard\ has been installed in + \ttt{whizard-path}, this should read + \begin{code} + export LD_LIBRARY_PATH="whizard-path/lib:$LD_LIBRARY_PATH" + \end{code} + On some systems, you may have to replace \ttt{lib} by \ttt{lib64}, as above. + + The \whizard\ subsystem will work with input and output + files in the current working directory, unless asked to do otherwise. +\end{enumerate} +Below is an example program, adapted from \whizard's internal unit-test suite. +The user program controls the \whizard\ workflow in the same way as a +\sindarin\ script would do. The commands are a mixture of \sindarin\ command +calls and functionality for passing information between the \whizard\ +subsystem and the host program. +In particular, the program can process generated events one-by-one. +\begin{code} +#include +#include +#include "whizard.h" + +int main( int argc, char* argv[] ) +{ + // WHIZARD and event-sample objects + Whizard* whizard; + WhizardSample* sample; + + // Local variables + double integral, error; + double sqme, weight; + int idx; + int it, it_begin, it_end; + + // Initialize WHIZARD, setting some global option + whizard = new Whizard(); + whizard->option( "model", "QED" ); + whizard->init(); + + // Define a process, set some variables + whizard->command( "process mupair = e1, E1 => e2, E2" ); + whizard->set_double( "sqrts", 10. ); + whizard->set_int( "seed", 0 ); + + // Generate matrix-element code, integrate and retrieve result + whizard->command( "integrate (mupair)" ); + + // Print result + whizard->get_integration_result( "mupair", &integral, &error ); + printf( " cross section = %5.1f pb\n", integral / 1000. ); + printf( " error = %5.1f pb\n", error / 1000. ); + + // Settings for event generation + whizard->set_string( "$sample", "mupair_events" ); + whizard->set_int( "n_events", 2 ); + + // Create an event-sample object and generate events + sample = whizard->new_sample( "mupair" ); + sample->open( &it_begin, &it_end ); + for (it=it_begin; it<=it_end; it++) { + sample->next_event(); + idx = sample->get_event_index(); + weight = sample->get_weight(); + sqme = sample->get_sqme(); + printf( "Event #%d\n", idx ); + printf( " sqme = %10.3e\n", sqme ); + printf( " weight = %10.3e\n", weight ); + } + + // Finalize the event-sample object + sample->close(); + delete sample; + + // Finalize the WHIZARD object + delete whizard; +} +\end{code} + +\subsubsection{Header} +The necessary declarations are imported by the directive +\begin{quote} + \tt \#include "whizard.h" +\end{quote} + +\subsubsection{Master object} +All functionality is accessed via a master API object which should be declared +as follows: +\begin{quote} + \tt Whizard* whizard; +\end{quote} +The constructor takes no arguments: +\begin{quote} + \tt whizard = new Whizard(); +\end{quote} +There should be only one master object. + +\subsubsection{Pre-Initialization options} +Before initializing the API object, it is possible to provide options. The +available options mirror the command-line options of the stand-alone program, +cf.\ Sec.~\ref{sec:cmdline-options}. +\begin{quote} + \tt whizard->option( \textit{key}, \textit{value} ); +\end{quote} +All keys and values are C++ strings. The available options are +listed above in the Fortran interface documentation. + +\subsubsection{Initialization and finalization} +After options have been set, the system is initialized via +\begin{quote} + \tt whizard->init(); +\end{quote} +Once initialized, \whizard\ can execute commands as listed below. When all +is complete, delete the \whizard\ object. This will call the destructor that +correctly finalizes the \whizard\ workflow. + +\subsubsection{Variables and values} + +In the API, \whizard\ requires numeric data types according to the IEEE +standard. Integers map to C \ttt{int}, and real values map to C +\ttt{double}. Logical values map to C \ttt{int} interpreted as \ttt{bool}, +and string values map to C++ \ttt{string}. + +To set a \sindarin\ variable of appropriate type: +\begin{quote} + \tt whizard->set\_int ( \textit{name}, \textit{value} ); + \\ + \tt whizard->set\_double ( \textit{name}, \textit{value} ); + \\ + \tt whizard->set\_bool ( \textit{name}, \textit{value} ); + \\ + \tt whizard->set\_string ( \textit{name}, \textit{value} ); +\end{quote} +\textit{name} is a C++ string value. It must match the corresponding +\sindarin\ variable name, including any prefix character (\$ or ?). +\textit{value} is a \ttt{double/int/string}, respectively. + +To retrieve the current value of a variable: +\begin{quote} + \tt whizard->get\_int ( \textit{name}, \&\textit{var} ); + \\ + \tt whizard->get\_double ( \textit{name}, \&\textit{var} ); + \\ + \tt whizard->get\_bool ( \textit{name}, \&\textit{var} ); + \\ + \tt whizard->get\_string ( \textit{name}, \&\textit{var} ); +\end{quote} +Here, \ttt{\it var} is a C variable of appropriate type. The functions return +zero if the \sindarin\ variable has a known value. + +\subsubsection{Commands} +Any \sindarin\ command can be called via +\begin{quote} + \tt whizard->command( \textit{command} ); +\end{quote} +\ttt{\it command} is a C++ string value that contains commands as they +would appear in a \sindarin\ script. + +This includes, in particular, the important commands \ttt{process}, +\ttt{integrate}, and \ttt{simulate}. You may also set variables that way. + +\subsubsection{Retrieving cross-section results} +This call returns the results (integration and error) from a preceding +integration run for the process \textit{process-name}: +\begin{quote} + \tt whizard->get\_integration\_result( "\textit{process-name}", + \&\textit{integral}, \&\textit{error} ); +\end{quote} +\ttt{\it integral} and \ttt{\it error} are variables of type \ttt{double}. +The function returns zero if the integration run was successful, so integral +and error are meaningful. + +\subsubsection{Event-sample object} +A \ttt{simulate} command will produce an event sample. With the appropriate +settings, the sample will be written to file in any chosen format, to be +post-processed when it is complete. + +However, a possible purpose of using the \whizard\ API is to process events one-by-one +when they are generated. To this end, there is an event-sample handle, which +can be declared in this way: +\begin{quote} + \tt WhizardSample* {sample}; +\end{quote} +An instance \ttt{\it sample} of this type is created by this factory method: +\begin{quote} + \tt {sample} = whizard->new\_sample( "\textit{process-name(s)}" ); +\end{quote} +The command accepts a comma-separated list of process names which should be +included in the event sample. + +To start event generation for this sample, call +\begin{quote} + \tt sample->open( \&\textit{it\_begin}, + \&\textit{it\_end}); +\end{quote} +where the two output variables (\ttt{int}) \ttt{\it it\_begin} and +\ttt{\it it\_end} +provide the bounds for an event loop in the calling program. (In serial mode, +the bounds are equal to 1 and \ttt{n\_events}, respectively, but in an MPI +parallel environment, they depend on the computing node.) + +This command generates a new event, to be enclosed within an event loop: +\begin{quote} + \tt sample->next\_event(); +\end{quote} +The event will be available by format-specific access methods, see below. + +This command closes and deletes an event sample after the event loop has +completed: +\begin{quote} + \tt sample->close(); +\end{quote} + +\subsubsection{Retrieving event data} + +After a call to \ttt{sample->next\_event}, the sample object can be +queried for specific event data. +\begin{quote} + \tt value = sample->get\_event\_index(); + \\ + \tt value = sample->get\_process\_index(); + \\ + \tt value = sample->get\_process\_id(); + \\ + \tt value = sample->get\_sqrts(); + \\ + \tt value = sample->get\_fac\_scale(); + \\ + \tt value = sample->get\_alpha\_s(); + \\ + \tt value = sample->get\_sqme(); + \\ + \tt value = sample->get\_weight(); +\end{quote} +where the \ttt{\it value} is a variable of appropriate type (see above). + +Event data are stored in a format-specific way. This may be a \hepmc\ or +\lcio\ C++ event record. + +For interfacing with the \hepmc\ event record, the appropriate declarations +must be in place, e.g., +\begin{quote} + \tt \#include "HepMC/GenEvent.h" + \\ + using namespace HepMC; +\end{quote} +An event-record object must be declared, +\begin{quote} + \tt GenEvent* evt; +\end{quote} +and the \whizard\ event call must take the event as an argument +\begin{quote} + \tt sample->next\_event ( \&evt ); +\end{quote} +This will create a new \ttt{evt} object. +Then, the \hepmc\ event record can be accessed via its own methods. After +an event has been processed, the event record should be deleted +\begin{quote} + \tt delete evt; +\end{quote} + +Analogously, for interfacing with the \lcio\ event record, the appropriate declarations +must be in place, e.g., +\begin{quote} + \tt + \#include "lcio.h" + \\ + \#include "IMPL/LCEventImpl.h" + \\ + using namespace lcio; +\end{quote} +An event-record object must be declared, +\begin{quote} + \tt LCEvent* evt; +\end{quote} +and the \whizard\ event call must take the event as an argument +\begin{quote} + \tt sample->next\_event ( \&evt ); +\end{quote} +This will create a new \ttt{evt} object. +Then, the \lcio\ event record can be accessed via its own methods. After +an event has been processed, the event record should be deleted +\begin{quote} + \tt delete evt; +\end{quote} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Examples} \label{chap:examples} In this chapter we discuss the running and steering of \whizard\ with the help of several examples. These examples can be found in the \ttt{share/examples} directory of your installation. All of these examples are also shown on the \whizard\ Wiki page: \url{https://whizard.hepforge.org/trac/wiki}. \section{$Z$ lineshape at LEP I} By this example, we demonstrate how a scan over collision energies works, using as example the measurement of the $Z$ lineshape at LEP I in 1989. The \sindarin\ script for this example, \ttt{Z-lineshape.sin} can be found in the \ttt{share/examples} folder of the \whizard\ installation. We first use the Standard model as physics model: \begin{code} model = SM \end{code} Aliases for electron, muon and their antiparticles as leptons and those including the photon as particles in general are introduced: \begin{code} alias lep = e1:E1:e2:E2 alias prt = lep:A \end{code} Next, the two processes are defined, \eemm, and the same with an explicit QED photon: $e^+e^- \to \mu^+\mu^-\gamma$, \begin{code} process bornproc = e1, E1 => e2, E2 process rc = e1, E1 => e2, E2, A compile \end{code} and the processes are compiled. Now, we define some very loose cuts to avoid singular regions in phase space, name an infrared cutoff of 100 MeV for all particles, a cut on the angular separation from the beam axis and a di-particle invariant mass cut which regularizes collinear singularities: \begin{code} cuts = all E >= 100 MeV [prt] and all abs (cos(Theta)) <= 0.99 [prt] and all M2 >= (1 GeV)^2 [prt, prt] \end{code} For the graphical analysis, we give a description and labels for the $x$- and $y$-axis in \LaTeX\ syntax: \begin{code} $description = "A WHIZARD Example" $x_label = "$\sqrt{s}$/GeV" $y_label = "$\sigma(s)$/pb" \end{code} We define two plots for the lineshape of the \eemm\ process between 88 and 95 GeV, \begin{code} $title = "The Z Lineshape in $e^+e^-\to\mu^+\mu^-$" plot lineshape_born { x_min = 88 GeV x_max = 95 GeV } \end{code} and the same for the radiative process with an additional photon: \begin{code} $title = "The Z Lineshape in $e^+e^-\to\mu^+\mu^-\gamma$" plot lineshape_rc { x_min = 88 GeV x_max = 95 GeV } \end{code} %$ The next part of the \sindarin\ file actually performs the scan: \begin{code} scan sqrts = ((88.0 GeV => 90.0 GeV /+ 0.5 GeV), (90.1 GeV => 91.9 GeV /+ 0.1 GeV), (92.0 GeV => 95.0 GeV /+ 0.5 GeV)) { beams = e1, E1 integrate (bornproc) { iterations = 2:1000:"gw", 1:2000 } record lineshape_born (sqrts, integral (bornproc) / 1000) integrate (rc) { iterations = 5:3000:"gw", 2:5000 } record lineshape_rc (sqrts, integral (rc) / 1000) } \end{code} So from 88 to 90 GeV, we go in 0.5 GeV steps, then from 90 to 92 GeV in tenth of GeV, and then up to 95 GeV again in half a GeV steps. The partonic beam definition is redundant. Then, the born process is integrated, using a certain specification of calls with adaptation of grids and weights, as well as a final pass. The lineshape of the Born process is defined as a \ttt{record} statement, generating tuples of $\sqrt{s}$ and the Born cross section (converted from femtobarn to picobarn). The same happens for the radiative $2\to3$ process with a bit more iterations because of the complexity, and the definition of the corresponding lineshape record. If you run the \sindarin\ script, you will find an output like: \begin{scriptsize} \begin{Verbatim}[frame=single] | Process library 'default_lib': loading | Process library 'default_lib': ... success. $description = "A WHIZARD Example" $x_label = "$\sqrt{s}$/GeV" $y_label = "$\sigma(s)$/pb" $title = "The Z Lineshape in $e^+e^-\to\mu^+\mu^-$" x_min = 8.800000000000E+01 x_max = 9.500000000000E+01 $title = "The Z Lineshape in $e^+e^-\to\mu^+\mu^-\gamma$" x_min = 8.800000000000E+01 x_max = 9.500000000000E+01 sqrts = 8.800000000000E+01 | RNG: Initializing TAO random-number generator | RNG: Setting seed for random-number generator to 10713 | Initializing integration for process bornproc: | ------------------------------------------------------------------------ | Process [scattering]: 'bornproc' | Library name = 'default_lib' | Process index = 1 | Process components: | 1: 'bornproc_i1': e-, e+ => mu-, mu+ [omega] | ------------------------------------------------------------------------ | Beam structure: e-, e+ | Beam data (collision): | e- (mass = 5.1099700E-04 GeV) | e+ (mass = 5.1099700E-04 GeV) | sqrts = 8.800000000000E+01 GeV | Phase space: generating configuration ... | Phase space: ... success. | Phase space: writing configuration file 'bornproc_i1.phs' | Phase space: 1 channels, 2 dimensions | Phase space: found 1 channel, collected in 1 grove. | Phase space: Using 1 equivalence between channels. | Phase space: wood | Applying user-defined cuts. | OpenMP: Using 8 threads | Starting integration for process 'bornproc' | Integrate: iterations = 2:1000:"gw", 1:2000 | Integrator: 1 chains, 1 channels, 2 dimensions | Integrator: Using VAMP channel equivalences | Integrator: 1000 initial calls, 20 bins, stratified = T | Integrator: VAMP |=============================================================================| | It Calls Integral[fb] Error[fb] Err[%] Acc Eff[%] Chi2 N[It] | |=============================================================================| 1 800 2.5881432E+05 1.85E+03 0.72 0.20* 48.97 2 800 2.6368495E+05 9.25E+02 0.35 0.10* 28.32 |-----------------------------------------------------------------------------| 2 1600 2.6271122E+05 8.28E+02 0.32 0.13 28.32 5.54 2 |-----------------------------------------------------------------------------| 3 1988 2.6313791E+05 5.38E+02 0.20 0.09* 35.09 |-----------------------------------------------------------------------------| 3 1988 2.6313791E+05 5.38E+02 0.20 0.09 35.09 |=============================================================================| | Time estimate for generating 10000 events: 0d:00h:00m:05s [.......] \end{Verbatim} \end{scriptsize} %$ and then the integrations for the other energy points of the scan will \begin{figure} \centering \includegraphics[width=.47\textwidth]{Z-lineshape_1} \includegraphics[width=.47\textwidth]{Z-lineshape_2} \caption{\label{fig:zlineshape} $Z$ lineshape in the dimuon final state (left), and with an additional photon (right)} \end{figure} follow, and finally the same is done for the radiative process as well. At the end of the \sindarin\ script we compile the graphical \whizard\ analysis and direct the data for the plots into the file \ttt{Z-lineshape.dat}: \begin{code} compile_analysis { $out_file = "Z-lineshape.dat" } \end{code} %$ In this case there is no event generation, but simply the cross section values for the scan are dumped into a data file: \begin{scriptsize} \begin{Verbatim}[frame=single] $out_file = "Z-lineshape.dat" | Opening file 'Z-lineshape.dat' for output | Writing analysis data to file 'Z-lineshape.dat' | Closing file 'Z-lineshape.dat' for output | Compiling analysis results display in 'Z-lineshape.tex' \end{Verbatim} \end{scriptsize} %$ Fig.~\ref{fig:zlineshape} shows the graphical \whizard\ output of the $Z$ lineshape in the dimuon final state from the scan on the left, and the same for the radiative process with an additional photon on the right. %%%%%%%%%%%%%%% \section{$W$ pairs at LEP II} This example which can be found as file \ttt{LEP\_cc10.sin} in the \ttt{share/examples} directory, shows $W$ pair production in the semileptonic mode at LEP II with its final energy of 209 GeV. Because there are ten contributing Feynman diagrams, the process has been dubbed CC10: charged current process with 10 diagrams. We work within the Standard Model: \begin{code} model = SM \end{code} Then the process is defined, where no flavor summation is done for the jets here: \begin{code} process cc10 = e1, E1 => e2, N2, u, D \end{code} A compilation statement is optional, and then we set the muon mass to zero: \begin{code} mmu = 0 \end{code} The final LEP center-of-momentum energy of 209 GeV is set: \begin{code} sqrts = 209 GeV \end{code} Then, we integrate the process: \begin{code} integrate (cc10) { iterations = 12:20000 } \end{code} Running the \sindarin\ file up to here, results in the output: \begin{scriptsize} \begin{Verbatim}[frame=single] | Process library 'default_lib': loading | Process library 'default_lib': ... success. SM.mmu = 0.000000000000E+00 sqrts = 2.090000000000E+02 | RNG: Initializing TAO random-number generator | RNG: Setting seed for random-number generator to 31255 | Initializing integration for process cc10: | ------------------------------------------------------------------------ | Process [scattering]: 'cc10' | Library name = 'default_lib' | Process index = 1 | Process components: | 1: 'cc10_i1': e-, e+ => mu-, numubar, u, dbar [omega] | ------------------------------------------------------------------------ | Beam structure: [any particles] | Beam data (collision): | e- (mass = 5.1099700E-04 GeV) | e+ (mass = 5.1099700E-04 GeV) | sqrts = 2.090000000000E+02 GeV | Phase space: generating configuration ... | Phase space: ... success. | Phase space: writing configuration file 'cc10_i1.phs' | Phase space: 25 channels, 8 dimensions | Phase space: found 25 channels, collected in 7 groves. | Phase space: Using 25 equivalences between channels. | Phase space: wood Warning: No cuts have been defined. | OpenMP: Using 8 threads | Starting integration for process 'cc10' | Integrate: iterations = 12:20000 | Integrator: 7 chains, 25 channels, 8 dimensions | Integrator: Using VAMP channel equivalences | Integrator: 20000 initial calls, 20 bins, stratified = T | Integrator: VAMP |=============================================================================| | It Calls Integral[fb] Error[fb] Err[%] Acc Eff[%] Chi2 N[It] | |=============================================================================| 1 19975 6.4714908E+02 2.17E+01 3.36 4.75* 2.33 2 19975 7.3251876E+02 2.45E+01 3.34 4.72* 2.17 3 19975 6.7746497E+02 2.39E+01 3.52 4.98 1.77 4 19975 7.2075198E+02 2.41E+01 3.34 4.72* 1.76 5 19975 6.5976152E+02 2.26E+01 3.43 4.84 1.46 6 19975 6.6633310E+02 2.26E+01 3.39 4.79* 1.43 7 19975 6.7539385E+02 2.29E+01 3.40 4.80 1.43 8 19975 6.6754027E+02 2.11E+01 3.15 4.46* 1.41 9 19975 7.3975817E+02 2.52E+01 3.40 4.81 1.53 10 19975 7.2284275E+02 2.39E+01 3.31 4.68* 1.47 11 19975 6.5476917E+02 2.18E+01 3.33 4.71 1.33 12 19975 7.2963866E+02 2.54E+01 3.48 4.92 1.46 |-----------------------------------------------------------------------------| 12 239700 6.8779583E+02 6.69E+00 0.97 4.76 1.46 2.18 12 |=============================================================================| | Time estimate for generating 10000 events: 0d:00h:01m:16s | Creating integration history display cc10-history.ps and cc10-history.pdf \end{Verbatim} \end{scriptsize} \begin{figure} \centering \includegraphics[width=.6\textwidth]{cc10_1} \\\vspace{5mm} \includegraphics[width=.6\textwidth]{cc10_2} \caption{Histogram of the dijet invariant mass from the CC10 $W$ pair production at LEP II, peaking around the $W$ mass (upper plot), and of the muon energy (lower plot).} \label{fig:cc10} \end{figure} The next step is event generation. In order to get smooth distributions, we set the integrated luminosity to 10 fb${}^{-1}$. (Note that LEP II in its final year 2000 had an integrated luminosity of roughly 0.2 fb${}^{-1}$.) \begin{code} luminosity = 10 \end{code} With the simulated events corresponding to those 10 inverse femtobarn we want to perform a \whizard\ analysis: we are going to plot the dijet invariant mass, as well as the energy of the outgoing muon. For the plot of the analysis, we define a description and label the $y$ axis: \begin{code} $description = "A WHIZARD Example. Charged current CC10 process from LEP 2." $y_label = "$N_{\textrm{events}}$" \end{code} We also use \LaTeX-syntax for the title of the first plot and the $x$-label, and then define the histogram of the dijet invariant mass in the range around the $W$ mass from 70 to 90 GeV in steps of half a GeV: \begin{code} $title = "Di-jet invariant mass $M_{jj}$ in $e^+e^- \to \mu^- \bar\nu_\mu u \bar d$" $x_label = "$M_{jj}$/GeV" histogram m_jets (70 GeV, 90 GeV, 0.5 GeV) \end{code} And we do the same for the second histogram of the muon energy: \begin{code} $title = "Muon energy $E_\mu$ in $e^+e^- \to \mu^- \bar\nu_\mu u \bar d$" $x_label = "$E_\mu$/GeV" histogram e_muon (0 GeV, 209 GeV, 4) \end{code} Now, we define the \ttt{analysis} consisting of two \ttt{record} statements initializing the two observables that are plotted as histograms: \begin{code} analysis = record m_jets (eval M [u,D]); record e_muon (eval E [e2]) \end{code} At the very end, we perform the event generation \begin{code} simulate (cc10) \end{code} and finally the writing and compilation of the analysis in a named data file: \begin{code} compile_analysis { $out_file = "cc10.dat" } \end{code} This event generation part screen output looks like this: \begin{scriptsize} \begin{Verbatim}[frame=single] luminosity = 1.000000000000E+01 $description = "A WHIZARD Example. Charged current CC10 process from LEP 2." $y_label = "$N_{\textrm{events}}$" $title = "Di-jet invariant mass $M_{jj}$ in $e^+e^- \to \mu^- \bar\nu_\mu u \bar d$" $x_label = "$M_{jj}$/GeV" $title = "Muon energy $E_\mu$ in $e^+e^- \to \mu^- \bar\nu_\mu u \bar d$" $x_label = "$E_\mu$/GeV" | Starting simulation for process 'cc10' | Simulate: using integration grids from file 'cc10_m1.vg' | RNG: Initializing TAO random-number generator | RNG: Setting seed for random-number generator to 9910 | OpenMP: Using 8 threads | Simulation: using n_events as computed from luminosity value | Events: writing to raw file 'cc10.evx' | Events: generating 6830 unweighted, unpolarized events ... | Events: event normalization mode '1' | ... event sample complete. Warning: Encountered events with excess weight: 39 events ( 0.571 %) | Maximum excess weight = 1.027E+00 | Average excess weight = 6.764E-04 | Events: closing raw file 'cc10.evx' $out_file = "cc10.dat" | Opening file 'cc10.dat' for output | Writing analysis data to file 'cc10.dat' | Closing file 'cc10.dat' for output | Compiling analysis results display in 'cc10.tex' \end{Verbatim} \end{scriptsize} %$ Then comes the \LaTeX\ output of the compilation of the graphical analysis. Fig.~\ref{fig:cc10} shows the two histograms as the are produced as result of the \whizard\ internal graphical analysis. %%%%%%%%%%%%%%% \section{Higgs search at LEP II} This example can be found under the name \ttt{LEP\_higgs.sin} in the \ttt{share/doc} folder of \whizard. It displays different search channels for a very light would-be SM Higgs boson of mass 115 GeV at the LEP II machine at its highest energy it finally achieved, 209 GeV. First, we use the Standard Model: \begin{code} model = SM \end{code} Then, we define aliases for neutrinos, antineutrinos, light quarks and light anti-quarks: \begin{code} alias n = n1:n2:n3 alias N = N1:N2:N3 alias q = u:d:s:c alias Q = U:D:S:C \end{code} Now, we define the signal process, which is Higgsstrahlung, \begin{code} process zh = e1, E1 => Z, h \end{code} the missing-energy channel, \begin{code} process nnbb = e1, E1 => n, N, b, B \end{code} and finally the 4-jet as well as dilepton-dijet channels: \begin{code} process qqbb = e1, E1 => q, Q, b, B process bbbb = e1, E1 => b, B, b, B process eebb = e1, E1 => e1, E1, b, B process qqtt = e1, E1 => q, Q, e3, E3 process bbtt = e1, E1 => b, B, e3, E3 compile \end{code} and we compile the code. We set the center-of-momentum energy to the highest energy LEP II achieved, \begin{code} sqrts = 209 GeV \end{code} For the Higgs boson, we take the values of a would-be SM Higgs boson with mass of 115 GeV, which would have had a width of a bit more than 3 MeV: \begin{code} mH = 115 GeV wH = 3.228 MeV \end{code} We take a running $b$ quark mass to take into account NLO corrections to the $Hb\bar b$ vertex, while all other fermions are massless: \begin{code} mb = 2.9 GeV me = 0 ms = 0 mc = 0 \end{code} \begin{scriptsize} \begin{Verbatim}[frame=single] | Process library 'default_lib': loading | Process library 'default_lib': ... success. sqrts = 2.090000000000E+02 SM.mH = 1.150000000000E+02 SM.wH = 3.228000000000E-03 SM.mb = 2.900000000000E+00 SM.me = 0.000000000000E+00 SM.ms = 0.000000000000E+00 SM.mc = 0.000000000000E+00 \end{Verbatim} \end{scriptsize} To avoid soft-collinear singular phase-space regions, we apply an invariant mass cut on light quark pairs: \begin{code} cuts = all M >= 10 GeV [q,Q] \end{code} Now, we integrate the signal process as well as the combined signal and background processes: \begin{code} integrate (zh) { iterations = 5:5000} integrate(nnbb,qqbb,bbbb,eebb,qqtt,bbtt) { iterations = 12:20000 } \end{code} \begin{scriptsize} \begin{Verbatim}[frame=single] | RNG: Initializing TAO random-number generator | RNG: Setting seed for random-number generator to 21791 | Initializing integration for process zh: | ------------------------------------------------------------------------ | Process [scattering]: 'zh' | Library name = 'default_lib' | Process index = 1 | Process components: | 1: 'zh_i1': e-, e+ => Z, H [omega] | ------------------------------------------------------------------------ | Beam structure: [any particles] | Beam data (collision): | e- (mass = 0.0000000E+00 GeV) | e+ (mass = 0.0000000E+00 GeV) | sqrts = 2.090000000000E+02 GeV | Phase space: generating configuration ... | Phase space: ... success. | Phase space: writing configuration file 'zh_i1.phs' | Phase space: 1 channels, 2 dimensions | Phase space: found 1 channel, collected in 1 grove. | Phase space: Using 1 equivalence between channels. | Phase space: wood | Applying user-defined cuts. | OpenMP: Using 8 threads | Starting integration for process 'zh' | Integrate: iterations = 5:5000 | Integrator: 1 chains, 1 channels, 2 dimensions | Integrator: Using VAMP channel equivalences | Integrator: 5000 initial calls, 20 bins, stratified = T | Integrator: VAMP |=============================================================================| | It Calls Integral[fb] Error[fb] Err[%] Acc Eff[%] Chi2 N[It] | |=============================================================================| 1 4608 1.6114109E+02 5.52E-04 0.00 0.00* 99.43 2 4608 1.6114220E+02 5.59E-04 0.00 0.00 99.43 3 4608 1.6114103E+02 5.77E-04 0.00 0.00 99.43 4 4608 1.6114111E+02 5.74E-04 0.00 0.00* 99.43 5 4608 1.6114103E+02 5.66E-04 0.00 0.00* 99.43 |-----------------------------------------------------------------------------| 5 23040 1.6114130E+02 2.53E-04 0.00 0.00 99.43 0.82 5 |=============================================================================| [.....] \end{Verbatim} \end{scriptsize} \begin{figure} \centering \includegraphics[width=.48\textwidth]{lep_higgs_1} \includegraphics[width=.48\textwidth]{lep_higgs_2} \\\vspace{5mm} \includegraphics[width=.48\textwidth]{lep_higgs_3} \caption{Upper line: final state $bb + E_{miss}$, histogram of the invisible mass distribution (left), and of the di-$b$ distribution (right). Lower plot: light dijet distribution in the $bbjj$ final state.} \label{fig:lep_higgs} \end{figure} Because the other integrations look rather similar, we refrain from displaying them here, too. As a next step, we define titles, descriptions and axis labels for the histograms we want to generate. There are two of them, one os the invisible mass distribution, the other is the di-$b$-jet invariant mass. Both histograms are taking values between 70 and 130 GeV with bin widths of half a GeV: \begin{code} $description = "A WHIZARD Example. Light Higgs search at LEP. A 115 GeV pseudo-Higgs has been added. Luminosity enlarged by two orders of magnitude." $y_label = "$N_{\textrm{events}}$" $title = "Invisible mass distribution in $e^+e^- \to \nu\bar\nu b \bar b$" $x_label = "$M_{\nu\nu}$/GeV" histogram m_invisible (70 GeV, 130 GeV, 0.5 GeV) $title = "$bb$ invariant mass distribution in $e^+e^- \to \nu\bar\nu b \bar b$" $x_label = "$M_{b\bar b}$/GeV" histogram m_bb (70 GeV, 130 GeV, 0.5 GeV) \end{code} The analysis is initialized by defining the two records for the invisible mass and the invariant mass of the two $b$ jets: \begin{code} analysis = record m_invisible (eval M [n,N]); record m_bb (eval M [b,B]) \end{code} In order to have enough statistics, we enlarge the LEP integrated luminosity at 209 GeV by more than two orders of magnitude: \begin{code} luminosity = 10 \end{code} We start event generation by simulating the process with two $b$ jets and two neutrinos in the final state: \begin{code} simulate (nnbb) \end{code} As a third histogram, we define the dijet invariant mass of two light jets: \begin{code} $title = "Dijet invariant mass distribution in $e^+e^- \to q \bar q b \bar b$" $x_label = "$M_{q\bar q}$/GeV" histogram m_jj (70 GeV, 130 GeV, 0.5 GeV) \end{code} Then we simulate the 4-jet process defining the light-dijet distribution as a local record: \begin{code} simulate (qqbb) { analysis = record m_jj (eval M / 1 GeV [combine [q,Q]]) } \end{code} Finally, we compile the analysis, \begin{code} compile_analysis { $out_file = "lep_higgs.dat" } \end{code} \begin{scriptsize} \begin{Verbatim}[frame=single] | Starting simulation for process 'nnbb' | Simulate: using integration grids from file 'nnbb_m1.vg' | RNG: Initializing TAO random-number generator | RNG: Setting seed for random-number generator to 21798 | OpenMP: Using 8 threads | Simulation: using n_events as computed from luminosity value | Events: writing to raw file 'nnbb.evx' | Events: generating 1070 unweighted, unpolarized events ... | Events: event normalization mode '1' | ... event sample complete. Warning: Encountered events with excess weight: 207 events ( 19.346 %) | Maximum excess weight = 1.534E+00 | Average excess weight = 4.909E-02 | Events: closing raw file 'nnbb.evx' $title = "Dijet invariant mass distribution in $e^+e^- \to q \bar q b \bar b$" $x_label = "$M_{q\bar q}$/GeV" | Starting simulation for process 'qqbb' | Simulate: using integration grids from file 'qqbb_m1.vg' | RNG: Initializing TAO random-number generator | RNG: Setting seed for random-number generator to 21799 | OpenMP: Using 8 threads | Simulation: using n_events as computed from luminosity value | Events: writing to raw file 'qqbb.evx' | Events: generating 4607 unweighted, unpolarized events ... | Events: event normalization mode '1' | ... event sample complete. Warning: Encountered events with excess weight: 112 events ( 2.431 %) | Maximum excess weight = 8.875E-01 | Average excess weight = 4.030E-03 | Events: closing raw file 'qqbb.evx' $out_file = "lep_higgs.dat" | Opening file 'lep_higgs.dat' for output | Writing analysis data to file 'lep_higgs.dat' | Closing file 'lep_higgs.dat' for output | Compiling analysis results display in 'lep_higgs.tex' \end{Verbatim} \end{scriptsize} The graphical analysis of the events generated by \whizard\ are shown in Fig.~\ref{fig:lep_higgs}. In the upper left, the invisible mass distribution in the $b\bar b + E_{miss}$ state is shown, peaking around the $Z$ mass. The upper right shows the $M(b\bar b)$ distribution in the same final state, while the lower plot has the invariant mass distribution of the two non-$b$-tagged (light) jets in the $bbjj$ final state. The latter shows only the $Z$ peak, while the former exhibits the narrow would-be 115 GeV Higgs state. %%%%%%%%%%%%%%% \section{Deep Inelastic Scattering at HERA} %%%%%%%%%%%%%%% \section{$W$ endpoint at LHC} %%%%%%%%%%%%%%% \section{SUSY Cascades at LHC} %%%%%%%%%%%%%%% \section{Polarized $WW$ at ILC} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Technical details -- Advanced Spells} \label{chap:tuning} \section{Efficiency and tuning} Since massless fermions and vector bosons (or almost massless states in a certain approximation) lead to restrictive selection rules for allowed helicity combinations in the initial and final state. To make use of this fact for the efficiency of the \whizard\ program, we are applying some sort of heuristics: \whizard\ dices events into all combinatorially possible helicity configuration during a warm-up phase. The user can specify a helicity threshold which sets the number of zeros \whizard\ should have got back from a specific helicity combination in order to ignore that combination from now on. By that mechanism, typically half up to more than three quarters of all helicity combinations are discarded (and hence the corresponding number of matrix element calls). This reduces calculation time up to more than one order of magnitude. \whizard\ shows at the end of the integration those helicity combinations which finally contributed to the process matrix element. Note that this list -- due to the numerical heuristics -- might very well depend on the number of calls for the matrix elements per iteration, and also on the corresponding random number seed. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{New External Physics Models} \label{chap:extmodels} It is never possible to include all incarnations of physics models that can be described by the maybe weirdest form of a quantum field theory in a tailor-made implementation within a program like \whizard. Users clearly want to be able to use their own special type of model; in order to do so there are external tools to translate models described by their field content and Lagrangian densities into Feynman rules and make them available in an event generator like \whizard. In this chapter, we describe the interfaces to two such external models, \sarah\ and \FeynRules. The \FeynRules\ interface had been started already for the legacy version \whizard\ttt{1} (where it had to be downloaded from \url{https://whizard.hepforge.org} as a separate package), but for the \whizard\ttt{two} release series it has been included in the \FeynRules\ package (from their version v1.6.0 on). Note that there was a regression for the usage of external models (from either \sarah\ or \FeynRules) in the first release of series v2.2, v2.2.0. This has been fixed in all upcoming versions. Besides using \sarah\ or \FeynRules\ via their interfaces, there is now a much easier way to let those programs output model files in the "Universal FeynRules Output" (or \UFO). This option does not have any principle limitations for models, and also does not rely on the never truly constant interfaces between two different tools. Their usage is described in Sec.~\ref{sec:ufo}. %%%%%%%%%%%%%%% \section{New physics models via \sarah} \sarah~\cite{Staub:2008uz,Staub:2009bi,Staub:2010jh,Staub:2012pb,Staub:2013tta} is a \Mathematica~\cite{mathematica} package which derives for a given model the minimum conditions of the vacuum, the mass matrices, and vertices at tree-level as well as expressions for the one-loop corrections for all masses and the full two-loop renormalization group equations (RGEs). The vertices can be exported to be used with \whizard/\oMega. All other information can be used to generate \fortran\ source code for the RGE solution tool and spectrum generator \spheno~\cite{Porod:2003um,Porod:2011nf} to get a spectrum generator for any model. The advantage is that \spheno\ calculates a consistent set of parameters (couplings, masses, rotation matrices, decay widths) which can be used as input for \whizard. \sarah\ and \spheno\ can be also downloaded from the \ttt{HepForge} server: \begin{center} \url{https://sarah.hepforge.org} \\ \url{https://spheno.hepforge.org} \end{center} \subsection{\whizard/\oMega\ model files from \sarah} \subsubsection{Generating the model files} Here we are giving only the information relevant to generate models for \whizard. For more details about the installation of \sarah\ and an exhaustion documentation about its usage, confer the \sarah\ manual. To generate the model files for \whizard/\oMega\ with \sarah, a new \Mathematica\ session has to be started. \sarah\ is loaded via \begin{code} </Output/TMSSM/EWSB/WHIZARD_Omega/ \end{code} and run % \begin{code} ./configure make install \end{code} % By default, the last command installs the compiled model into \verb".whizard" in current user's home directory where it is automatically picked up by \whizard. Alternative installation paths can be specified using the \verb"--prefix" option to \whizard. % \begin{code} ./configure --prefix=/path/to/installation/prefix \end{code} % If the files are installed into the \whizard\ installation prefix, the program will also pick them up automatically, while {\whizard}'s \verb"--localprefix" option must be used to communicate any other choice to \whizard. In case \whizard\ is not available in the binary search path, the \verb"WO_CONFIG" environment variable can be used to point \verb"configure" to the binaries % \begin{code} ./configure WO_CONFIG=/path/to/whizard/binaries \end{code} % More information on the available options and their syntax can be obtained with the \verb"--help" option. After the model is compiled it can be used in \whizard\ as \begin{code} model = tmssm_sarah \end{code} \subsection{Linking \spheno\ and \whizard} As mentioned above, the user can also use \spheno\ to generate spectra for its models. This is done by means of \fortran\ code for \spheno, exported from \sarah. To do so, the user has to apply the command \verb"MakeSPheno[]". For more details about the options of this command and how to compile and use the \spheno\ output, we refer to the \sarah\ manual. \\ As soon as the \spheno\ version for the given model is ready it can be used to generate files with all necessary numerical values for the parameters in a format which is understood by \whizard. For this purpose, the corresponding flag in the Les Houches input file of \spheno\ has to be turned on: \begin{code} Block SPhenoInput # SPheno specific input ... 75 1 # Write WHIZARD files \end{code} Afterwards, \spheno\ returns not only the spectrum file in the standard SUSY Les Houches accord (SLHA) format (for more details about the SLHA and the \whizard\ SLHA interface cf. Sec.~\ref{sec:slha}), but also an additional file called \verb"WHIZARD.par.TMSSM" for our example. This file can be used in the \sindarin\ input file via \begin{code} include ("WHIZARD.par.TMSSM") \end{code} %%%%% \subsection{BSM Toolbox} A convenient way to install \sarah\ together with \whizard, \spheno\ and some other codes are the \ttt{BSM Toolbox} scripts \footnote{Those script have been published under the name SUSY Toolbox but \sarah\ is with version 4 no longer restricted to SUSY models}~\cite{Staub:2011dp}. These scripts are available at \begin{center} \url{https://sarah.hepforge.org/Toolbox.html} \end{center} The \ttt{Toolbox} provides two scripts. First, the \verb"configure" script is used via \begin{code} toolbox-src-dir> mkdir build toolbox-src-dir> cd build toolbox-src-dir> ../configure \end{code} % The \verb"configure" script checks for the requirements of the different packages and downloads all codes. All downloaded archives will be placed in the \verb"tarballs" subdirectory of the directory containing the \verb"configure" script. Command line options can be used to disable specific packages and to point the script to custom locations of compilers and of the \Mathematica\ kernel; a full list of those can be obtained by calling \verb"configure" with the \verb"--help" option. After \verb"configure" finishes successfully, \verb"make" can be called to build all configured packages % \begin{code} toolbox-build-dir> make \end{code} \verb"configure" creates also the second script which automates the implementation of a new model into all packages. The \verb"butler" script takes as argument the name of the model in \sarah, e.g. \begin{code} > ./butler TMSSM \end{code} The \verb"butler" script runs \sarah\ to get the output in the same form as the \whizard/\oMega\ model files and the code for \spheno. Afterwards, it installs the model in all packages and compiles the new \whizard/\oMega\ model files as well as the new \spheno\ module. %%%%% \newpage \section{New physics models via \FeynRules} In this section, we present the interface between the external tool \FeynRules\ \cite{Christensen:2008py,Christensen:2009jx,Duhr:2011se} and \whizard. \FeynRules\ is a \Mathematica~\cite{mathematica} package that allows to derive Feynman rules from any perturbative quantum field theory-based Lagrangian in an automated way. It can be downloaded from \begin{center} \url{http://feynrules.irmp.ucl.ac.be/} \end{center} The input provided by the user is threefold and consists of the Lagrangian defining the model, together with the definitions of all the particles and parameters that appear in the model. Once this information is provided, \FeynRules\ can perform basic checks on the sanity of the implementation (e.g. hermiticity, normalization of the quadratic terms), and finally computes all the interaction vertices associated with the model and store them in an internal format for later processing. After the Feynman rules have been obtained, \FeynRules\ can export the interaction vertices to \whizard\ via a dedicated interface~\cite{Christensen:2010wz}. The interface checks whether all the vertices are compliant with the structures supported by \whizard's matrix element generator \oMega, and discard them in the case they are not supported. The output of the interface consists of a set of files organized in a single directory which can be injected into \whizard/\oMega\ and used as any other built-in models. Together with the model files, a framework is created which allows to communicate the new models to \whizard\ in a well defined way, after which step the model can be used exactly like the built-in ones. This specifically means that the user is not required to manually modify the code of \whizard/\oMega, the models created by the interface can be used directly without any further user intervention. We first describe the installation and general usage of the interface, and then list the general properties like the supported particle types, color quantum numbers and Lorentz structures as well as types of gauge interactions. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Installation and Usage of the \whizard-\FeynRules\ interface} \label{sec:interface-usage} \paragraph{{\bf Installation and basic usage:}} % From \FeynRules\ version 1.6.0 onward, the interface to \whizard\ is part of the \FeynRules\ distribution\footnote{Note that though the main interface of \FeynRules\ to \whizard\ is for the most recent \whizard\ release, but also the legacy branch \whizard\ttt{1} is supported.}. In addition, the latest version of the interface can be downloaded from the \whizard\ homepage on \ttt{HepForge}. There you can also find an installer that can be used to inject the interface into an existing \FeynRules\ installation (which allows to use the interface with the \FeynRules\ release series1.4.x where it is not part of the package). Once installed, the interface can be called and used in the same way \FeynRules' other interfaces described in~\cite{Christensen:2008py}. The details of how to install and use \FeynRules\ itself can be found there,~\cite{Christensen:2008py,Christensen:2009jx,Duhr:2011se}. Here, we only describe how to use the interface to inject new models into \whizard. For example, once the \FeynRules\ environment has been initialized and a model has been loaded, the command \begin{code} WriteWOOutput[L] \end{code} will call the \ttt{FeynmanRules} command to extract the Feynman rules from the Lagrangian \ttt{L}, translate them together with the model data and finally write the files necessary for using the model within \whizard\ to an output directory (the name of which is inferred from the model name by default). Options can be added for further control over the translation process (see Sec.~\ref{app:interface-options}). Instead of using a Lagrangian, it is also possible to call the interface on a pure vertex list. For example, the following command \begin{code} WriteWOOutput[Input -> list] \end{code} will directly translate the vertex list \ttt{list}. Note that this vertex list must be given in flavor-expanded form in order for the interface to process it correctly. The interface also supports the \ttt{WriteWOExtParams} command described in~\cite{Christensen:2008py}. Issuing \begin{code} WriteWOExtParams[filename] \end{code} will write a list of all the external parameters to \ttt{filename}. This is done in the form of a \sindarin\ script. The only option accepted by the command above is the target version of \whizard, set by the option \ttt{WOWhizardVersion}. During execution, the interface will print out a series of messages. It is highly advised to carefully read through this output as it not only summarizes the settings and the location of the output files, but also contains information on any skipped vertices or potential incompatibilities of the model with \whizard. After the interface has run successfully and written the model files to the output directory, the model must be imported into \whizard. For doing so, the model files have to be compiled and can then be installed independently of \whizard. In the simplest scenario, assuming that the output directory is the current working directory and that the \whizard\ binaries can be found in the current \ttt{\$\{PATH\}}, the installation is performed by simply executing \begin{code} ./configure~\&\&~make clean~\&\&~make install \end{code} This will compile the model and install it into the directory \ttt{\$\{HOME\}/.whizard}, making it fully available to \whizard\ without any further intervention. The build system can be adapted to more complicated cases through several options to the \ttt{configure} which are listed in the \ttt{INSTALL} file created in the output directory. A detailed explanation of all options can be found in Sec.~\ref{app:interface-options}. \paragraph{\bf Supported fields and vertices:} The following fields are currently supported by the interface: scalars, Dirac and Majorana fermions, vectors and symmetric tensors. The set of accepted operators, the full list of which can be found in Tab.~\ref{tab-operators}, is a subset of all the operators supported by \oMega. While still limited, this list is sufficient for a large number of BSM models. In addition, a future version of \whizard/\oMega\ will support the definition of completely general Lorentz structures in the model, allowing the interface to translate all interactions handled by \FeynRules. This will be done by means of a parser within \oMega\ of the \ttt{UFO} file format for model files from \FeynRules. \begin{table*}[!t] \centerline{\begin{tabular}{|c|c|} \hline Particle spins & Supported Lorentz structures \\\hline\hline FFS & \parbox{0.7\textwidth}{\raggedright All operators of dimension four are supported. \strut}\\\hline FFV & \parbox[t]{0.7\textwidth}{\raggedright All operators of dimension four are supported. \strut}\\\hline SSS & \parbox{0.7\textwidth}{\raggedright All dimension three interactions are supported. \strut}\\\hline SVV & \parbox[t]{0.7\textwidth}{\raggedright Supported operators:\\ \mbox{}\hspace{5ex}$\begin{aligned} \text{dimension 3:} & \quad\mathcal{O}_3 = V_1^\mu V_{2\mu}\phi \mbox{}\\ \text{dimension 5:} & \quad\mathcal{O}_5 = \phi \left(\partial^\mu V_1^\nu - \partial^\nu V_1^\mu\right) \left(\partial_\mu V_{2\nu} - \partial_\nu V_{2\mu}\right) \end{aligned}$\\ Note that $\mathcal{O}_5$ generates the effective gluon-gluon-Higgs couplings obtained by integrating out heavy quarks. \strut}\\\hline SSV & \parbox[t]{0.7\textwidth}{\raggedright $\left(\phi_1\partial^\mu\phi_2 - \phi_2\partial^\mu\phi_1\right)V_\mu\;$ type interactions are supported. \strut}\\\hline SSVV & \parbox{0.7\textwidth}{\raggedright All dimension four interactions are supported. \strut}\\\hline SSSS & \parbox{0.7\textwidth}{\raggedright All dimension four interactions are supported. \strut}\\\hline VVV & \parbox[t]{0.7\textwidth}{\raggedright All parity-conserving dimension four operators are supported, with the restriction that non-gauge interactions may be split into several vertices and can only be handled if all three fields are mutually different.\strut \strut}\\\hline VVVV & \parbox[t]{0.7\textwidth}{\raggedright All parity conserving dimension four operators are supported. \strut}\\\hline TSS, TVV, TFF & \parbox[t]{0.7\textwidth}{\raggedright The three point couplings in the Appendix of Ref.\ \cite{Han:1998sg} are supported. \strut}\\\hline \end{tabular}} \caption{All Lorentz structures currently supported by the \whizard-\FeynRules\ interface, sorted with respect to the spins of the particles. ``S'' stands for scalar, ``F'' for fermion (either Majorana or Dirac) and ``V'' for vector.} \label{tab-operators} \end{table*} \paragraph{\bf Color:} % Color is treated in \oMega\ in the color flow decomposition, with the flow structure being implicitly determined from the representations of the particles present at the vertex. Therefore, the interface has to strip the color structure from the vertices derived by \FeynRules\ before writing them out to the model files. While this process is straightforward for all color structures which correspond only to a single flow assignment, vertices with several possible flow configurations must be treated with care in order to avoid mismatches between the flows assigned by \oMega\ and those actually encoded in the couplings. To this end, the interface derives the color flow decomposition from the color structure determined by \FeynRules\ and rejects all vertices which would lead to a wrong flow assignment by \oMega\ (these rejections are accompanied by warnings from the interface)\footnote{For the old \whizard\ttt{1} legacy branch, there was a maximum number of external color flows that had to explicitly specified. Essentially, this is $n_8 - \frac{1}{2}n_3$ where $n_8$ is the maximum number of external color octets and $n_3$ is the maximum number of external triplets and antitriplets. This can be set in the \whizard/\FeynRules\ interface by the \ttt{WOMaxNcf} command, whose default is \ttt{4}.}. At the moment, the $SU(3)_C$ representations supported by both \whizard\ and the interface are singlets ($1$), triplets ($3$), antitriplets ($\bar{3}$) and octets ($8$). Tab.~\ref{tab:su3struct} shows all combinations of these representations which can form singlets together with the support status of the respective color structures in \whizard\ and the interface. Although the supported color structures do not comprise all possible singlets, the list is sufficient for a large number of SM extensions. Furthermore, a future revision of \whizard/\oMega\ will allow for explicit color flow assignments, thus removing most of the current restrictions. \begin{table*} \centerline{\begin{tabular}{|c|c|} \hline $SU(3)_C$ representations & Support status \\\hline\hline \parbox[t]{0.2\textwidth}{ \centerline{\begin{tabular}[t]{lll} $111,\quad$ & $\bar{3}31,\quad$ & $\bar{3}38,$ \\ $1111,$ & $\bar{3}311,$ & $\bar{3}381$ \end{tabular}}} & \parbox[t]{0.7\textwidth}{\raggedright\strut Fully supported by the interface\strut} \\\hline $888,\quad 8881$ & \parbox{0.7\textwidth}{\raggedright\strut Supported only if at least two of the octets are identical particles.\strut} \\\hline $881,\quad 8811$ & \parbox{0.7\textwidth}{\raggedright\strut Fully supported by the interface\footnote{% Not available in version 1.95 and earlier. Note that in order to use such couplings in 1.96/97, the \oMega\ option \ttt{2g} must be added to the process definition in \ttt{whizard.prc}.}.\strut} \\\hline $\bar{3}388$ & \parbox{0.7\textwidth}{\raggedright\strut Supported only if the octets are identical particles.\strut} \\\hline $8888$ & \parbox{0.7\textwidth}{\raggedright\strut The only supported flow structure is \begin{equation*} \parbox{21mm}{\includegraphics{flow4}}\cdot\;\Gamma(1,2,3,4) \quad+\quad \text{all acyclic permutations} \end{equation*} where $\Gamma(1,2,3,4)$ represents the Lorentz structure associated with the first flow.\strut} \\\hline \parbox[t]{0.2\textwidth}{ \centerline{\begin{tabular}[t]{lll} $333,\quad$ & $\bar{3}\bar{3}\bar{3},\quad$ & $3331$\\ $\bar{3}\bar{3}\bar{3}1,$ & $\bar{3}\bar{3}33$ \end{tabular}}} & \parbox[t]{0.7\textwidth}{\raggedright\strut Unsupported (at the moment)\strut} \\\hline \end{tabular}} \caption{All possible combinations of three or four $SU(3)_C$ representations supported by \FeynRules\ which can be used to build singlets, together with the support status of the corresponding color structures in \whizard\ and the interface.} \label{tab:su3struct} \end{table*} \paragraph{\bf Running $\alpha_S$:} While a running strong coupling is fully supported by the interface, a choice has to be made which quantities are to be reevaluated when the strong coupling is evolved. By default \ttt{aS}, \ttt{G} (see Ref.~\cite{Christensen:2008py} for the nomenclature regarding the QCD coupling) and any vertex factors depending on them are evolved. The list of internal parameters that are to be recalculated (together with the vertex factors depending on them) can be extended (beyond \ttt{aS} and \ttt{G}) by using the option \ttt{WORunParameters} when calling the interface~\footnote{As the legacy branch, \whizard\ttt{1}, does not support a running strong coupling, this is also vetoed by the interface when using \whizard \ttt{1.x}.}. \paragraph{\bf Gauge choices:} \label{sec:gauge-choices} The interface supports the unitarity, Feynman and $R_\xi$ gauges. The choice of gauge must be communicated to the interface via the option \ttt{WOGauge}. Note that massless gauge bosons are always treated in Feynman gauge. If the selected gauge is Feynman or $R_\xi$, the interface can automatically assign the proper masses to the Goldstone bosons. This behavior is requested by using the \ttt{WOAutoGauge} option. In the $R_\xi$ gauges, the symbol representing the gauge $\xi$ must be communicated to the interface by using the \ttt{WOGaugeSymbol} option (the symbol is automatically introduced into the list of external parameters if \ttt{WOAutoGauge} is selected at the same time). This feature can be used to automatically extend models implemented in Feynman gauge to the $R_\xi$ gauges. Since \whizard\ (at least until the release series 2.3) is a tree-level tool working with helicity amplitudes, the ghost sector is irrelevant for \whizard\ and hence dropped by the interface. \subsection{Options of the \whizard-\FeynRules\ interface} \label{app:interface-options} In the following we present a comprehensive list of all the options accepted by \ttt{WriteWOOutput}. Additionally, we note that all options of the \FeynRules\ command \ttt{FeynmanRules} are accepted by \ttt{WriteWOOutput}, which passes them on to \ttt{FeynmanRules}. \begin{description} \item[\ttt{Input}]\mbox{}\\ An optional vertex list to use instead of a Lagrangian (which can then be omitted). % \item[\ttt{WOWhizardVersion}]\mbox{}\\ Select the \whizard\ version for which code is to be generated. The currently available choices are summarized in Tab.~\ref{tab-wowhizardversion}. %% \begin{table} \centerline{\begin{tabular}{|l|l|} \hline \ttt{WOWhizardVersion} & \whizard\ versions supported \\\hline\hline \ttt{"2.0.3"} (default) & 2.0.3+ \\\hline \ttt{"2.0"} & 2.0.0 -- 2.0.2 \\\hline\hline \ttt{"1.96"} & 1.96+ \qquad (deprecated) \\\hline \ttt{"1.93"} & 1.93 -- 1.95 \qquad (deprecated) \\\hline \ttt{"1.92"} & 1.92 \qquad (deprecated) \\\hline \end{tabular}} \caption{Currently available choices for the \ttt{WOWhizardVersion} option, together with the respective \whizard\ versions supported by them.} \label{tab-wowhizardversion} \end{table} %% This list will expand as the program evolves. To get a summary of all choices available in a particular version of the interface, use the command \ttt{?WOWhizardVersion}. % \item[\ttt{WOModelName}]\mbox{}\\ The name under which the model will be known to \whizard\footnote{For versions 1.9x, model names must start with ``\ttt{fr\_}'' if they are to be picked up by \whizard\ automatically.}. The default is determined from the \FeynRules\ model name. % \item[\ttt{Output}]\mbox{}\\ The name of the output directory. The default is determined from the \FeynRules\ model name. % \item[\ttt{WOGauge}]\mbox{}\\ Gauge choice (\emph{cf.} Sec.~\ref{sec:gauge-choices}). Possible values are: \ttt{WOUnitarity} (default), \ttt{WOFeynman}, \ttt{WORxi} % \item[\ttt{WOGaugeParameter}]\mbox{}\\ The external or internal parameter representing the gauge $\xi$ in the $R_\xi$ gauges (\emph{cf.} Sec.~\ref{sec:gauge-choices}). Default: \ttt{Rxi} % \item[\ttt{WOAutoGauge}]\mbox{}\\ Automatically assign the Goldstone boson masses in the Feynman and $R_\xi$ gauges and automatically append the symbol for $\xi$ to the parameter list in the $R_\xi$ gauges. Default: \ttt{False} % \item[\ttt{WORunParameters}]\mbox{}\\ The list of all internal parameters which will be recalculated if $\alpha_S$ is evolved (see above)\footnote{Not available for versions older than 2.0.0}. Default: \mbox{\ttt{\{aS, G\}}} % \item[\ttt{WOFast}]\mbox{}\\ If the interface drops vertices which are supported, this option can be set to \ttt{False} to enable some more time consuming checks which might aid the identification. Default: \ttt{True} % \item[\ttt{WOMaxCouplingsPerFile}]\mbox{}\\ The maximum number of couplings that are written to a single \fortran\ file. If compilation takes too long or fails, this can be lowered. Default: \ttt{500} % \item[\ttt{WOVerbose}]\mbox{}\\ Enable verbose output and in particular more extensive information on any skipped vertices. Default: \ttt{False} \end{description} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Validation of the interface} The output of the interface has been extensively validated. Specifically, the integrated cross sections for all possible $2\rightarrow 2$ processes in the \FeynRules\ SM, the MSSM and the Three-Site Higgsless Model have been compared between \whizard, \madgraph, and \CalcHep, using the respective \FeynRules\ interfaces as well as the in-house implementations of these models (the Three-Site Higgsless model not being available in \madgraph). Also, different gauges have been checked for \whizard\ and \CalcHep. In all comparisons, excellent agreement within the Monte Carlo errors was achieved. The detailed comparison including examples of the comparison tables can be found in~\cite{Christensen:2010wz}. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Examples for the \whizard-/\FeynRules\ interface} Here, we will use the Standard Model, the MSSM and the Three-Site Higgsless Model as prime examples to explain the usage of the interface. Those are the models that have been used in the validation of the interface in~\cite{Christensen:2010wz}. The examples are constructed to show the application of the different options of the interface and to serve as a starting point for the generation of the user's own \whizard\ versions of other \FeynRules\ models. \subsubsection{\whizard-\FeynRules\ example: Standard Model}\label{sec:usageSM} To start off, we will create {\sc Whizard} 2 versions of the Standard Model as implemented in \FeynRules\ for different gauge choices. \paragraph{SM: Unitarity Gauge} In order to invoke \FeynRules, we change to the corresponding directory and load the program in \Mathematica\ via \begin{code} $FeynRulesPath = SetDirectory[""]; < WOFeynman]; \end{code} The modified gauge is reflected in the output of the interface \begin{code} Short model name is "fr_standard_model" Gauge: Feynman Generating code for WHIZARD / O'Mega version 2.0.3 Maximum number of couplings per FORTRAN module: 500 Extensive lorentz structure checks disabled. \end{code} The summary of the vertex identification now takes the following form \begin{code} processed a total of 163 vertices, kept 139 of them and threw away 24, 24 of which contained ghosts. \end{code} Again, this line tells us that there were no problems --- the only discarded interactions involved the ghost sector which is irrelevant for the tree-level part of \whizard. For a tree-level calculation, the only difference between the different gauges from the perspective of the interface are the gauge boson propagators and the Goldstone boson masses. Therefore, the interface can automatically convert a model in Feynman gauge to a model in $R_\xi$ gauge. To this end, the call to the interface must be changed to \begin{code} WriteWOOutput[LSM, WOGauge -> WORxi, WOAutoGauge -> True]; \end{code} The \verb?WOAutoGauge? argument instructs the interface to automatically \begin{enumerate} \item Introduce a symbol for the gauge parameter $\xi$ into the list of external parameters \item Generate the Goldstone boson masses from those of the associated gauge bosons (ignoring the values provided by \FeynRules) \end{enumerate} The modified setup is again reflected in the interface output \begin{code} Short model name is "fr_standard_model" Gauge: Rxi Gauge symbol: "Rxi" Generating code for WHIZARD / O'Mega version 2.0.3 Maximum number of couplings per FORTRAN module: 500 Extensive lorentz structure checks disabled. \end{code} Note the default choice \verb?Rxi? for the name of the $\xi$ parameter -- this can be modified via the option \verb?WOGaugeParameter?. While the \verb?WOAutoGauge? feature allows to generate $R_\xi$ gauged models from models implemented in Feynman gauge, it is of course also possible to use models genuinely implemented in $R_\xi$ gauge by setting this parameter to \verb?False?. Also, note that the choice of gauge only affects the propagators of massive fields. Massless gauge bosons are always treated in Feynman gauge. \paragraph{Compilation and usage} In order to compile and use the freshly generated model files, change to the output directory which can be determined from the interface output (in this example, it is \verb?fr_standard_model-WO?). Assuming that \whizard\ is available in the binary search path, compilation and installation proceeds as described above by executing \begin{code} ./configure && make && make install \end{code} The model is now ready and can be used similarly to the builtin \whizard\ models. For example, a minimal \whizard\ input file for calculating the $e^+e^- \longrightarrow W^+W^-$ scattering cross section in the freshly generated model would look like \begin{code} model = fr_standard_model process test = "e+", "e-" -> "W+", "W-" sqrts = 500 GeV integrate (test) \end{code} %%%%% \subsubsection{\whizard/\FeynRules\ example: MSSM} In this Section, we illustrate the usage of the interface between {\sc FeynRules} and {\sc Whizard} in the context of the MSSM. All the parameters of the model are then ordered in Les Houches blocks and counters following the SUSY Les Houches Accord (SLHA) \cite{Skands:2003cj,AguilarSaavedra:2005pw,Allanach:2008qq} (cf. also Sec.~\ref{sec:slha}). After having downloaded the model from the \FeynRules\ website, we store it in a new directory, labelled \verb"MSSM", of the model library of the local installation of \FeynRules. The model can then be loaded in \Mathematica\ as in the case of the SM example above \begin{code} $FeynRulesPath = SetDirectory[""]; <True" option of both interface commands \verb"FeynmanRules" and \verb"WriteWOOutput". The Feynman rules of the MSSM are then computed within the \Mathematica\ notebook by \begin{code} rules = FeynmanRules[lag, Exclude4Scalars->True, FlavorExpand->True]; \end{code} where \verb'lag' is the variable containing the Lagrangian. By default, all the parameters of the model are set to the value of \ttt{1}. A complete parameter \ttt{{\em }.dat} file must therefore be loaded. Such a parameter file can be downloaded from the \FeynRules\ website or created by hand by the user, and loaded into \FeynRules\ as \begin{code} ReadLHAFile[Input -> ".dat"]; \end{code} This command does not reduce the size of the model output by removing vertices with vanishing couplings. However, if desired, this task could be done with the \ttt{LoadRestriction} command (see Ref.\ \cite{Fuks:2012im} for details). The vertices are exported to \whizard\ by the command \begin{code} WriteWOOutput[Input -> rules]; \end{code} Note that the numerical values of the parameters of the model can be modified directly from \whizard, without having to generate a second time the \whizard\ model files from \FeynRules. A \sindarin\ script is created by the interface with the help of the instruction \begin{code} WriteWOExtParams["parameters.sin"]; \end{code} and can be further modified according to the needs of the user. \subsubsection{\whizard-\FeynRules\ example: Three-Site Higgsless Model} The Three-Site Higgsless model or Minimal Higgsless model (MHM) has been implemented into \ttt{LanHEP}~\cite{He:2007ge}, \FeynRules\ and independently into \whizard~\cite{Speckner:2010zi}, and the collider phenomenology has been studied by making use of these implementations \cite{He:2007ge,Ohl:2010zf,Speckner:2010zi}. Furthermore, the independent implementations in \FeynRules\ and directly into {\sc Whizard} have been compared and found to agree~\cite{Christensen:2010wz}. After the discovery of a Higgs boson at the LHC in 2012, such a model is not in good agreement with experimental data any more. Here, we simply use it as a guinea pig to describe the handling of a model with non-renormalizable interactions with the \FeynRules\ interface, and discuss how to generate \whizard\ model files for it. The model has been implemented in Feynman gauge as well as unitarity gauge and contains the variable \verb|FeynmanGauge| which can be set to \verb|True| or \verb|False|. When set to \verb|True|, the option \verb|WOGauge-> WOFeynman| must be used, as explained in~\cite{Christensen:2010wz}. $R_\xi$ gauge can also be accomplished with this model by use of the options \verb|WOGauge -> WORxi| and \verb?WOAutoGauge -> True?. Since this model makes use of a nonlinear sigma field of the form \begin{equation} \Sigma = 1 + i\pi - \frac{1}{2}\pi^2+\cdots \end{equation} many higher dimensional operators are included in the model which are not currently not supported by \whizard. Even for a future release of \whizard\ containing general Lorentz structures in interaction vertices, the user would be forced to expand the series only up to a certain order. Although \whizard\ can reject these vertices and print a warning message to the user, it is preferable to remove the vertices right away in the interface by the option \verb|MaxCanonicalDimension->4|. This is passed to the command \verb|FeynmanRules| and restricts the Feynman rules to those of dimension four and smaller\footnote{\ttt{MaxCanonicalDimension} is an option of the \ttt{FeynmanRules} function rather than of the interface, itself. In fact, the interface accepts all the options of {\tt FeynmanRules} and simply passes them on to the latter.}. As the use of different gauges was already illustrated in the SM example, we discuss the model only in Feynman gauge here. We load \FeynRules: \begin{code} $FeynRulesPath = SetDirectory[""]; <"]; LoadModel["3-Site-particles.fr", "3-Site-parameters.fr", "3-Site-lagrangian.fr"]; FeynmanGauge = True; \end{code} where \verb|| is the path to the directory where the MHM model files are stored and where the output of the \whizard\ interface will be written. The \whizard\ interface is then initiated: \begin{code} WriteWOOutput[LGauge, LGold, LGhost, LFermion, LGoldLeptons, LGoldQuarks, MaxCanonicalDimension->4, WOGauge->WOFeynman, WOModelName->"fr_mhm"]; \end{code} where we have also made use of the option \verb|WOModelName| to change the name of the model as seen by \whizard. As in the case of the SM, the interface begins by writing a short informational message: \begin{code} Short model name is "fr_mhm" Gauge: Feynman Generating code for WHIZARD / O'Mega version 2.0.3 Automagically assigning Goldstone boson masses... Maximum number of couplings per FORTRAN module: 500 Extensive lorentz structure checks disabled. \end{code} After calculating the Feynman rules and processing the vertices, the interface gives a summary: \begin{code} processed a total of 922 vertices, kept 633 of them and threw away 289, 289 of which contained ghosts. \end{code} showing that no vertices were missed. The files are stored in the directory \verb|fr_mhm| and are ready to be installed and used with \whizard. %%%%%%%%%%%%%%% \section{New physics models via the \UFO\ file format} \label{sec:ufo} In this section, we describe how to use the {\em Universal FeynRules Output} (\UFO, \cite{Degrande:2011ua}) format for physics models inside \whizard. Please refer the manuals of e.g.~\FeynRules\ manual for details on how to generate a \UFO\ file for your favorite physics model. \UFO\ files are a collection of \ttt{Python} scripts that encode the particles, the couplings, the Lorentz structures, the decays, as well as parameters, vertices and propagators of the corresponding model. They reside in a directory of the exact name of the model they have been created from. If the user wants to generate events for processes from a physics model from a \UFO\ file, then this directory of scripts generated by \FeynRules\ is immediately available if it is a subdirectory of the working directory of \whizard. The directory name will be taken as the model name. (The \UFO-model file name must not start with a non-letter character, i.e. especially not a number. In case such a file name wants to be used at all costs, the model name in the \sindarin\ script has to put in quotation marks, but this is not guaranteed to always work.) Then, a \UFO\ model named, e.g., \ttt{test\_model} is accessed by an extra \ttt{ufo} tag in the model assignment: \begin{Code} model = test_model (ufo) \end{Code} If desired, \whizard\ can access a directory of \UFO\ files elsewhere on the file system. For instance, if \FeynRules\ output resides in the subdirectory \ttt{MyMdl} of \ttt{/home/users/john/ufo}, \whizard\ can use the model named \ttt{MyMdl} as follows \begin{Code} model = MyMdl (ufo ('/home/users/john/my_ufo_models')) \end{Code} that is, the \sindarin\ keyword \ttt{ufo} can take an argument. Note however, that the latter approach can backfire --- in case just the working directory is packed and archived for future reference. %%%%%%%%%%%%%%% \clearpage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \appendix %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{\sindarin\ Reference} In the \sindarin\ language, there are certain pre-defined constructors or commands that cannot be used in different context by the user, which are e.g. \ttt{alias}, \ttt{beams}, \ttt{integrate}, \ttt{simulate} etc. A complete list will be given below. Also units are fixed, like \ttt{degree}, \ttt{eV}, \ttt{keV}, \ttt{MeV}, \ttt{GeV}, and \ttt{TeV}. Again, these tags are locked and not user-redefinable. Their functionality will be listed in detail below, too. Furthermore, a variable with a preceding question mark, ?, is a logical, while a preceding dollar, \$, denotes a character string variable. Also, a lot of unary and binary operators exist, \ttt{+ - $\backslash$ , = : => < > <= >= \^ \; () [] \{\} } \url{==}, as well as quotation marks, ". Note that the different parentheses and brackets fulfill different purposes, which will be explained below. Comments in a line can either be marked by a hash, \#, or an exclamation mark, !. \section{Commands and Operators} We begin the \sindarin\ reference with all commands, operators, functions and constructors. The list of variables (which can be set to change behavior of \whizard) can be found in the next section. \begin{itemize} \item \ttt{+} \newline 1) Arithmetic operator for addition of integers, reals and complex numbers. Example: \ttt{real mm = mH + mZ} (cf. also \ttt{-}, \ttt{*}, \ttt{/}, \ttt{\^{}}). 2) It also adds different particles for inclusive process containers: \ttt{process foo = e1, E1 => (e2, E2) + (e3, E3)}. 3) It also serves as a shorthand notation for the concatenation of ($\to$) \ttt{combine} operations on particles/subevents, e.g. \ttt{cuts = any 170 GeV < M < 180 GeV [b + lepton + invisible]}. %%%%% \item \ttt{-} \newline Arithmetic operator for subtraction of integers, reals and complex numbers. Example: \ttt{real foo = 3.1 - 5.7} (cf. also \ttt{+}, \ttt{*}, \ttt{/}, \ttt{\^{}}). %%%%% \item \ttt{/} \newline Arithmetic operator for division of integers, reals and complex numbers. Example: \ttt{scale = mH / 2} (cf. also \ttt{+}, \ttt{*}, \ttt{-}, \ttt{\^{}}). %%%%% \item \ttt{*} \newline Arithmetic operator for multiplication of integers, reals and complex numbers. Example: \ttt{complex z = 2 * I} (cf. also \ttt{+}, \ttt{/}, \ttt{-}, \ttt{\^{}}). %%%%% \item \ttt{\^{}} \newline Arithmetic operator for exponentiation of integers, reals and complex numbers. Example: \ttt{real z = x\^{}2 + y\^{}2} (cf. also \ttt{+}, \ttt{/}, \ttt{-}, \ttt{\^{}}). %%%%% \item \ttt{<} \newline Arithmetic comparator between values that checks for ordering of two values: \ttt{{\em } < {\em }} tests whether \ttt{{\em val1}} is smaller than \ttt{{\em val2}}. Allowed for integer and real values. Note that this is an exact comparison if \ttt{tolerance} is set to zero. For a finite value of \ttt{tolerance} it is a ``fuzzy'' comparison. (cf. also \ttt{tolerance}, \ttt{<>}, \ttt{==}, \ttt{>}, \ttt{>=}, \ttt{<=}) %%%%% \item \ttt{>} \newline Arithmetic comparator between values that checks for ordering of two values: \ttt{{\em } > {\em }} tests whether \ttt{{\em val1}} is larger than \ttt{{\em val2}}. Allowed for integer and real values. Note that this is an exact comparison if \ttt{tolerance} is set to zero. For a finite value of \ttt{tolerance} it is a ``fuzzy'' comparison. (cf. also \ttt{tolerance}, \ttt{<>}, \ttt{==}, \ttt{>}, \ttt{>=}, \ttt{<=}) %%%%% \item \ttt{<=} \newline Arithmetic comparator between values that checks for ordering of two values: \ttt{{\em } <= {\em }} tests whether \ttt{{\em val1}} is smaller than or equal \ttt{{\em val2}}. Allowed for integer and real values. Note that this is an exact comparison if \ttt{tolerance} is set to zero. For a finite value of \ttt{tolerance} it is a ``fuzzy'' comparison. (cf. also \ttt{tolerance}, \ttt{<>}, \ttt{==}, \ttt{>}, \ttt{<}, \ttt{>=}) %%%%% \item \ttt{>=} \newline Arithmetic comparator between values that checks for ordering of two values: \ttt{{\em } >= {\em }} tests whether \ttt{{\em val1}} is larger than or equal \ttt{{\em val2}}. Allowed for integer and real values. Note that this is an exact comparison if \ttt{tolerance} is set to zero. For a finite value of \ttt{tolerance} it is a ``fuzzy'' comparison. (cf. also \ttt{tolerance}, \ttt{<>}, \ttt{==}, \ttt{>}, \ttt{<}, \ttt{>=}) %%%%% \item \ttt{==} \newline Arithmetic comparator between values that checks for identity of two values: \ttt{{\em } == {\em }}. Allowed for integer and real values. Note that this is an exact comparison if \ttt{tolerance} is set to zero. For a finite value of \ttt{tolerance} it is a ``fuzzy'' comparison. (cf. also \ttt{tolerance}, \ttt{<>}, \ttt{>}, \ttt{<}, \ttt{>=}, \ttt{<=}) %%%%% \item \ttt{<>} \newline Arithmetic comparator between values that checks for two values being unequal: \ttt{{\em } <> {\em }}. Allowed for integer and real values. Note that this is an exact comparison if \ttt{tolerance} is set to zero. For a finite value of \ttt{tolerance} it is a ``fuzzy'' comparison. (cf. also \ttt{tolerance}, \ttt{==}, \ttt{>}, \ttt{<}, \ttt{>=}, \ttt{<=}) %%%%% \item \ttt{!} \newline The exclamation mark tells \sindarin\ that everything that follows in that line should be treated as a comment. It is the same as ($\to$) \ttt{\#}. %%%%% \item \ttt{\#} \newline The hash tells \sindarin\ that everything that follows in that line should be treated as a comment. It is the same as ($\to$) \ttt{!}. %%%%% \item \ttt{\&} \newline Concatenates two or more particle lists/subevents and hence acts in the same way as the subevent function ($\to$) \ttt{join}: \ttt{let @visible = [photon] \& [colored] \& [lepton] in ...}. (cf. also \ttt{join}, \ttt{combine}, \ttt{collect}, \ttt{extract}, \ttt{sort}). %%%%% \item \ttt{\$} \newline Constructor at the beginning of a variable name, \ttt{\${\em }}, that specifies a string variable. %%%%% \item \ttt{@} \newline Constructor at the beginning of a variable name, \ttt{@{\em }}, that specifies a subevent variable, e.g. \ttt{let @W\_candidates = combine ["mu-", "numubar"] in ...}. %%%%% \item \ttt{=} \newline Binary constructor to appoint values to commands, e.g. \ttt{{\em } = {\em }} or \newline \ttt{{\em } {\em } = {\em }}. %%%%% \item \ttt{\%} \newline Constructor that gives the percentage of a number, so in principle multiplies a real number by \ttt{0.01}. Example: \ttt{1.23 \%} is equal to \ttt{0.0123}. %%%%% \item \ttt{:} \newline Separator in alias expressions for particles, e.g. \ttt{alias neutrino = n1:n2:n3:N1:N2:N3}. (cf. also \ttt{alias}) %%%%% \item \ttt{;} \newline Concatenation operator for logical expressions: \ttt{{\em lexpr1} ; {\em lexpr2}}. Evaluates \ttt{{\em lexpr1}} and throws the result away, then evaluates \ttt{{\em lexpr2}} and returns that result. Used in analysis expressions. (cf. also \ttt{analysis}, \ttt{record}) %%%%% \item \ttt{/+} \newline Incrementor for ($\to$) \ttt{scan} ranges, that increments additively, \ttt{scan {\em } = ({\em } => {\em } /+ {\em })}. E.g. \ttt{scan int i = (1 => 5 /+ 2)} scans over the values \ttt{1}, \ttt{3}, \ttt{5}. For real ranges, it divides the interval between upper and lower bound into as many intervals as the incrementor provides, e.g. \ttt{scan real r = (1 => 1.5 /+ 0.2)} runs over \ttt{1.0}, \ttt{1.333}, \ttt{1.667}, \ttt{1.5}. %%%%% \item \ttt{/+/} \newline Incrementor for ($\to$) \ttt{scan} ranges, that increments additively, but the number after the incrementor is the number of steps, not the step size: \ttt{scan {\em } = ({\em } => {\em } /+/ {\em })}. It is only available for real scan ranges, and divides the interval \ttt{{\em } - {\em }} into \ttt{{\em }} steps, e.g. \ttt{scan real r = (1 => 1.5 /+/ 3)} runs over \ttt{1.0}, \ttt{1.25}, \ttt{1.5}. %%%%% \item \ttt{/-} \newline Incrementor for ($\to$) \ttt{scan} ranges, that increments subtractively, \ttt{scan {\em } {\em } = ({\em } => {\em } /- {\em })}. E.g. \ttt{scan int i = (9 => 0 /+ 3)} scans over the values \ttt{9}, \ttt{6}, \ttt{3}, \ttt{0}. For real ranges, it divides the interval between upper and lower bound into as many intervals as the incrementor provides, e.g. \ttt{scan real r = (1 => 0.5 /- 0.2)} runs over \ttt{1.0}, \ttt{0.833}, \ttt{0.667}, \ttt{0.5}. %%%%% \item \ttt{/*} \newline Incrementor for ($\to$) \ttt{scan} ranges, that increments multiplicatively, \ttt{scan {\em } {\em } = ({\em } => {\em } /* {\em })}. E.g. \ttt{scan int i = (1 => 4 /* 2)} scans over the values \ttt{1}, \ttt{2}, \ttt{4}. For real ranges, it divides the interval between upper and lower bound into as many intervals as the incrementor provides, e.g. \ttt{scan real r = (1 => 5 /* 2)} runs over \ttt{1.0}, \ttt{2.236} (i.e. $\sqrt{5}$), \ttt{5.0}. %%%%% \item \ttt{/*/} \newline Incrementor for ($\to$) \ttt{scan} ranges, that increments multiplicatively, but the number after the incrementor is the number of steps, not the step size: \ttt{scan {\em } {\em } = ({\em } => {\em } /*/ {\em })}. It is only available for real scan ranges, and divides the interval \ttt{{\em } - {\em }} into \ttt{{\em }} steps, e.g. \ttt{scan real r = (1 => 9 /*/ 4)} runs over \ttt{1.000}, \ttt{2.080}, \ttt{4.327}, \ttt{9.000}. %%%%% \item \ttt{//} \newline Incrementor for ($\to$) \ttt{scan} ranges, that increments by division, \ttt{scan {\em } {\em } = ({\em } => {\em } // {\em })}. E.g. \ttt{scan int i = (13 => 0 // 3)} scans over the values \ttt{13}, \ttt{4}, \ttt{1}, \ttt{0}. For real ranges, it divides the interval between upper and lower bound into as many intervals as the incrementor provides, e.g. \ttt{scan real r = (5 => 1 // 2)} runs over \ttt{5.0}, \ttt{2.236} (i.e. $\sqrt{5}$), \ttt{1.0}. %%%%% \item \ttt{=>} \newline Binary operator that is used in several different contexts: 1) in process declarations between the particles specifying the initial and final state, e.g. \ttt{process {\em } = {\em }, {\em } => {\em }, ....}; 2) for the specification of beams when structure functions are applied to the beam particles, e.g. \ttt{beams = p, p => pdf\_builtin}; 3) for the specification of the scan range in the \ttt{scan {\em } {\em } = ({\em } => {\em } {\em })} (cf. also \ttt{process}, \ttt{beams}, \ttt{scan}) %%%%% \item \ttt{\%d} \newline Format specifier in analogy to the \ttt{C} language for the print out on screen by the ($\to$) \ttt{printf} or into strings by the ($\to$) \ttt{sprintf} command. It is used for decimal integer numbers, e.g. \ttt{printf "one = \%d" (i)}. The difference between \ttt{\%i} and \ttt{\%d} does not play a role here. (cf. also \ttt{printf}, \ttt{sprintf}, \ttt{\%i}, \ttt{\%e}, \ttt{\%f}, \ttt{\%g}, \ttt{\%E}, \ttt{\%F}, \ttt{\%G}, \ttt{\%s}) %%%%% \item \ttt{\%e} \newline Format specifier in analogy to the \ttt{C} language for the print out on screen by the ($\to$) \ttt{printf} or into strings by the ($\to$) \ttt{sprintf} command. It is used for floating-point numbers in standard form \ttt{[-]d.ddd e[+/-]ddd}. Usage e.g. \ttt{printf "pi = \%e" (PI)}. (cf. also \ttt{printf}, \ttt{sprintf}, \ttt{\%d}, \ttt{\%i}, \ttt{\%f}, \ttt{\%g}, \ttt{\%E}, \ttt{\%F}, \ttt{\%G}, \ttt{\%s}) %%%%% \item \ttt{\%E} \newline Same as ($\to$) \ttt{\%e}, but using upper-case letters. (cf. also \ttt{printf}, \ttt{sprintf}, \ttt{\%d}, \ttt{\%i}, \ttt{\%e}, \ttt{\%f}, \ttt{\%g}, \ttt{\%F}, \ttt{\%G}, \ttt{\%s}) %%%%% \item \ttt{\%f} \newline Format specifier in analogy to the \ttt{C} language for the print out on screen by the ($\to$) \ttt{printf} or into strings by the ($\to$) \ttt{sprintf} command. It is used for floating-point numbers in fixed-point form. Usage e.g. \ttt{printf "pi = \%f" (PI)}. (cf. also \ttt{printf}, \ttt{sprintf}, \ttt{\%d}, \ttt{\%i}, \ttt{\%e}, \ttt{\%g}, \ttt{\%E}, \ttt{\%F}, \ttt{\%G}, \ttt{\%s}) %%%%% \item \ttt{\%F} \newline Same as ($\to$) \ttt{\%f}, but using upper-case letters. (cf. also \ttt{printf}, \ttt{sprintf}, \ttt{\%d}, \ttt{\%i}, \ttt{\%e}, \ttt{\%f}, \ttt{\%g}, \ttt{\%E}, \ttt{\%G}, \ttt{\%s}) %%%%% \item \ttt{\%g} \newline Format specifier in analogy to the \ttt{C} language for the print out on screen by the ($\to$) \ttt{printf} or into strings by the ($\to$) \ttt{sprintf} command. It is used for floating-point numbers in normal or exponential notation, whichever is more approriate. Usage e.g. \ttt{printf "pi = \%g" (PI)}. (cf. also \ttt{printf}, \ttt{sprintf}, \ttt{\%d}, \ttt{\%i}, \ttt{\%e}, \ttt{\%f}, \ttt{\%E}, \ttt{\%F}, \ttt{\%G}, \ttt{\%s}) %%%%% \item \ttt{\%G} \newline Same as ($\to$) \ttt{\%g}, but using upper-case letters. (cf. also \ttt{printf}, \ttt{sprintf}, \ttt{\%d}, \ttt{\%i}, \ttt{\%e}, \ttt{\%f}, \ttt{\%g}, \ttt{\%E}, \ttt{\%F}, \ttt{\%s}) %%%%% \item \ttt{\%i} \newline Format specifier in analogy to the \ttt{C} language for the print out on screen by the ($\to$) \ttt{printf} or into strings by the ($\to$) \ttt{sprintf} command. It is used for integer numbers, e.g. \ttt{printf "one = \%i" (i)}. The difference between \ttt{\%i} and \ttt{\%d} does not play a role here. (cf. \ttt{printf}, \ttt{sprintf}, \ttt{\%d}, \ttt{\%e}, \ttt{\%f}, \ttt{\%g}, \ttt{\%E}, \ttt{\%F}, \ttt{\%G}, \ttt{\%s}) %%%%% \item \ttt{\%s} \newline Format specifier in analogy to the \ttt{C} language for the print out on screen by the ($\to$) \ttt{printf} or into strings by the ($\to$) \ttt{sprintf} command. It is used for logical or string variables e.g. \ttt{printf "foo = \%s" (\$method)}. (cf. \ttt{printf}, \ttt{sprintf}, \ttt{\%d}, \ttt{\%i}, \ttt{\%e}, \ttt{\%f}, \ttt{\%g}, \ttt{\%E}, \ttt{\%F}, \ttt{\%G}) %%%%% \item \ttt{abarn} \newline Physical unit, stating that a number is in attobarns ($10^{-18}$ barn). (cf. also \ttt{nbarn}, \ttt{fbarn}, \ttt{pbarn}) %%%%% \item \ttt{abs} \newline Numerical function that takes the absolute value of its argument: \ttt{abs ({\em })} yields \ttt{|{\em }|}. (cf. also \ttt{conjg}, \ttt{sgn}, \ttt{mod}, \ttt{modulo}) %%%%% \item \ttt{acos} \newline Numerical function \ttt{asin ({\em })} that calculates the arccosine trigonometric function (inverse of \ttt{cos}) of real and complex numerical numbers or variables. (cf. also \ttt{sin}, \ttt{cos}, \ttt{tan}, \ttt{asin}, \ttt{atan}) %%%%% \item \ttt{alias} \newline This allows to define a collective expression for a class of particles, e.g. to define a generic expression for leptons, neutrinos or a jet as \ttt{alias lepton = e1:e2:e3:E1:E2:E3}, \ttt{alias neutrino = n1:n2:n3:N1:N2:N3}, and \ttt{alias jet = u:d:s:c:U:D:S:C:g}, respectively. %%%%% \item \ttt{all} \newline \ttt{all} is a function that works on a logical expression and a list, \ttt{all {\em } [{\em }]}, and returns \ttt{true} if and only if \ttt{log\_expr} is fulfilled for {\em all} entries in \ttt{list}, and \ttt{false} otherwise. Examples: \ttt{all Pt > 100 GeV [lepton]} checks whether all leptons are harder than 100 GeV, \ttt{all Dist > 2 [u:U, d:D]} checks whether all pairs of corresponding quarks are separated in $R$ space by more than 2. Logical expressions with \ttt{all} can be logically combined with \ttt{and} and \ttt{or}. (cf. also \ttt{any}, \ttt{and}, \ttt{no}, and \ttt{or}) %%%%% \item \ttt{alt\_setup} \newline This command allows to specify alternative setups for a process/list of processes, \ttt{alt\_setup = \{ {\em } \} [, \{ {\em } \} , ...]}. An alternative setup can be a resetting of a coupling constant, or different cuts etc. It can be particularly used in a ($\to$) \ttt{rescan} procedure. %%%%% \item \ttt{analysis} \newline This command, \ttt{analysis = {\em }}, allows to define an analysis as a logical expression, with a syntax similar to the ($\to$) \ttt{cuts} or ($\to$) \ttt{selection} command. Note that a ($\to$) formally is a logical expression. %%%%% \item \ttt{and} \newline This is the standard two-place logical connective that has the value true if both of its operands are true, otherwise a value of false. It is applied to logical values, e.g. cut expressions. (cf. also \ttt{all}, \ttt{no}, \ttt{or}). %%%%% \item \ttt{any} \newline \ttt{any} is a function that works on a logical expression and a list, \ttt{any {\em } [{\em }]}, and returns \ttt{true} if \ttt{log\_expr} is fulfilled for any entry in \ttt{list}, and \ttt{false} otherwise. Examples: \ttt{any PDG == 13 [lepton]} checks whether any lepton is a muon, \ttt{any E > 2 * mW [jet]} checks whether any jet has an energy of twice the $W$ mass. Logical expressions with \ttt{any} can be logically combined with \ttt{and} and \ttt{or}. (cf. also \ttt{all}, \ttt{and}, \ttt{no}, and \ttt{or}) %%%%% \item \ttt{as} \newline cf. \ttt{compile} %%%%% \item \ttt{ascii} \newline Specifier for the \ttt{sample\_format} command to demand the generation of the standard \whizard\ verbose/debug ASCII event files. (cf. also \ttt{\$sample}, \ttt{\$sample\_normalization}, \ttt{sample\_format}) %%%%% \item \ttt{asin} \newline Numerical function \ttt{asin ({\em })} that calculates the arcsine trigonometric function (inverse of \ttt{sin}) of real and complex numerical numbers or variables. (cf. also \ttt{sin}, \ttt{cos}, \ttt{tan}, \ttt{acos}, \ttt{atan}) %%%%% \item \ttt{atan} \newline Numerical function \ttt{atan ({\em })} that calculates the arctangent trigonometric function (inverse of \ttt{tan}) of real and complex numerical numbers or variables. (cf. also \ttt{sin}, \ttt{cos}, \ttt{tan}, \ttt{asin}, \ttt{acos}) %%%%% \item \ttt{athena} \newline Specifier for the \ttt{sample\_format} command to demand the generation of the ATHENA variant for HEPEVT ASCII event files. (cf. also \ttt{\$sample}, \ttt{\$sample\_normalization}, \ttt{sample\_format}) %%%%% \item \ttt{beam} \newline Constructor that specifies a particle (in a subevent) as beam particle. It is used in cuts, analyses or selections, e.g. \ttt{cuts = all Theta > 20 degree [beam lepton, lepton]}. (cf. also \ttt{incoming}, \ttt{outgoing}, \ttt{cuts}, \ttt{analysis}, \ttt{selection}, \ttt{record}) %%%%% \item \ttt{beam\_events} \newline Beam structure specifier to read in lepton collider beamstrahlung's spectra from external files as pairs of energy fractions: \ttt{beams: e1, E1 => beam\_events}. Note that this is a pair spectrum that has to be applied to both beams simultaneously. (cf. also \ttt{beams}, \ttt{\$beam\_events\_file}, \ttt{?beam\_events\_warn\_eof}) %%%%% \item \ttt{beams} \newline This specifies the contents and structure of the beams: \ttt{beams = {\em }, {\em } [ => {\em } ....]}. If this command is absent in the input file, \whizard\ automatically takes the two incoming partons (or one for decays) of the corresponding process as beam particles, and no structure functions are applied. Protons and antiprotons as beam particles are predefined as \ttt{p} and \ttt{pbar}, respectively. A structure function, like \ttt{pdf\_builtin}, \ttt{ISR}, \ttt{EPA} and so on are switched on as e.g. \ttt{beams = p, p => lhapdf}. Structure functions can be specified for one of the two beam particles only, of the structure function is not a spectrum. (cf. also \ttt{beams\_momentum}, \ttt{beams\_theta}, \ttt{beams\_phi}, \ttt{beams\_pol\_density}, \ttt{beams\_pol\_fraction}, \ttt{beam\_events}, \ttt{circe1}, \ttt{circe2}, \ttt{energy\_scan}, \ttt{epa}, \ttt{ewa}, \ttt{isr}, \ttt{lhapdf}, \ttt{pdf\_builtin}). %%%%% \item \ttt{beams\_momentum} \newline Command to set the momenta (or energies) for the two beams of a scattering process: \ttt{beams\_momentum = {\em }, {\em }} to allow for asymmetric beam setups (e.g. HERA: \ttt{beams\_momentum = 27.5 GeV, 920 GeV}). Two arguments must be present for a scattering process, but the command can be used with one argument to integrate and simulate a decay of a moving particle. (cf. also \ttt{beams}, \ttt{beams\_theta}, \ttt{beams\_phi}, \ttt{beams\_pol\_density}, \ttt{beams\_pol\_fraction}) %%%%% \item \ttt{beams\_phi} \newline Same as ($\to$) \ttt{beams\_theta}, but to allow for a non-vanishing beam azimuth angle, too. (cf. also \ttt{beams}, \ttt{beams\_theta}, \ttt{beams\_momentum}, \ttt{beams\_pol\_density}, \ttt{beams\_pol\_fraction}) %%%%% \item \ttt{beams\_pol\_density} \newline This command allows to specify the initial state for polarized beams by the syntax: \ttt{beams\_pol\_density = @({\em }), @({\em })}. Two polarization specifiers are mandatory for scattering, while one can be used for decays from polarized probes. The specifier \ttt{{\em }} can be empty (no polarization), has one entry (for a definite helicity/spin orientation), or ranges of entries of a spin density matrix. The command can be used globally, or as a local argument of the \ttt{integrate} command. For detailed information, see Sec.~\ref{sec:initialpolarization}. It is also possible to use variables as placeholders in the specifiers. Note that polarization is assumed to be complete, for partial polarization use ($\to$) \ttt{beams\_pol\_fraction}. (cf. also \ttt{beams}, \ttt{beams\_theta}, \ttt{beams\_phi}, \ttt{beams\_momentum}, \ttt{beams\_pol\_fraction}) %%%%% \item \ttt{beams\_pol\_fraction} \newline This command allows to specify the amount of polarization when using polarized beams ($\to$ \ttt{beams\_pol\_density}). The syntax is: \ttt{beams\_pol\_fraction = {\em }, {\em }}. Two fractions must be present for scatterings, being real numbers between \ttt{0} and \ttt{1}. A specification with percentage is also possible, e.g. \ttt{beams\_pol\_fraction = 80\%, 40\%}. (cf. also \ttt{beams}, \ttt{beams\_theta}, \ttt{beams\_phi}, \ttt{beams\_momentum}, \ttt{beams\_pol\_density}) %%%%% \item \ttt{beams\_theta} \newline Command to set a crossing angle (with respect to the $z$ axis) for one or both of the beams of a scattering process: \ttt{beams\_theta = {\em }, {\em }} to allow for asymmetric beam setups (e.g. \ttt{beams\_angle = 0, 10 degree}). Two arguments must be present for a scattering process, but the command can be used with one argument to integrate and simulate a decay of a moving particle. (cf. also \ttt{beams}, \ttt{beams\_phi}, \ttt{beams\_momentum}, \ttt{beams\_pol\_density}, \ttt{beams\_pol\_fraction}) %%%%% \item \ttt{by} \newline Constructor that replaces the default sorting criterion (according to PDG codes) of the ($\to$) \ttt{sort} function on particle lists/subevents by one given by a unary or binary particle observable: \ttt{sort by {\em } [{\em } [, {\em }] ]}. (cf. also \ttt{sort}, \ttt{extract}, \ttt{join}, \ttt{collect}, \ttt{combine}, \ttt{+}) %%%%% \item \ttt{ceiling} \newline This is a function \ttt{ceiling ({\em })} that gives the least integer greater than or equal to \ttt{{\em }}, e.g. \ttt{int i = ceiling (4.56789)} gives \ttt{i = 5}. (cf. also \ttt{int}, \ttt{nint}, \ttt{floor}) %%%%% \item \ttt{circe1} \newline Beam structure specifier for the \circeone\ structure function for beamstrahlung at a linear lepton collider: \ttt{beams = e1, E1 => circe1}. Note that this is a pair spectrum, so the specifier acts for both beams simultaneously. (cf. also \ttt{beams}, \ttt{?circe1\_photons}, \ttt{?circe1\_photon2}, \ttt{circe1\_sqrts}, \ttt{?circe1\_generate}, \ttt{?circe1\_map}, \ttt{circe1\_eps}, \newline \ttt{circe1\_mapping\_slope}, \ttt{circe1\_ver}, \ttt{circe1\_rev}, \ttt{\$circe1\_acc}, \ttt{circe1\_chat}) %%%%% \item \ttt{circe2} \newline Beam structure specifier for the lepton-collider structure function for photon spectra, \circetwo: \ttt{beams = A, A => circe2}. Note that this is a pair spectrum, an application to only one beam is not possible. (cf. also \ttt{beams}, \ttt{?circe2\_polarized}, \ttt{\$circe2\_file}, \ttt{\$circe2\_design}) %%%%% \item \ttt{clear} \newline This command allows to clear a variable set before: \ttt{clear ({\em })} resets the variable \ttt{{\em }} which could be the \ttt{beams}, the \ttt{unstable} settings, \ttt{sqrts}, any kind of \ttt{cuts} or \ttt{scale} expressions, any user-set variable etc. The syntax of the command is completely analogous to ($\to$) \ttt{show}. %%%%% \item \ttt{close\_out} \newline With the command, \ttt{close\_out ("{\em })} user-defined information like data or ($\to$) \ttt{printf} statements can be written out to a user-defined file. The command closes an I/O stream to an external file \ttt{{\em }}. (cf. also \ttt{open\_out}, \ttt{\$out\_file}, \ttt{printf}) %%%%% \item \ttt{cluster} \newline Command that allows to cluster all particles in a subevent to a set of jets: \ttt{cluster [{\em}]}. It also to cluster particles subject to a certain boolean condition, \ttt{cluster if {\em} [{\em}]}. At the moment only available if the \fastjet\ package is linked. (cf. also \ttt{jet\_r}, \ttt{combine}, \ttt{jet\_algorithm}, \ttt{kt\_algorithm}, \newline \ttt{cambridge\_[for\_passive\_]algorithm}, \ttt{antikt\_algorithm}, \ttt{plugin\_algorithm}, \newline \ttt{genkt\_[for\_passive\_]algorithm}, \ttt{ee\_kt\_algorithm}, \ttt{ee\_genkt\_algorithm}, \ttt{?keep\_flavors\_when\_clustering}) %%%%% \item \ttt{collect} \newline The \ttt{collect [{\em }]} operation collects all particles in the list \ttt{{\em }} into a one-entry subevent with a four-momentum of the sum of all four-momenta of non-overlapping particles in \ttt{{\em }}. (cf. also \ttt{combine}, \ttt{select}, \ttt{extract}, \ttt{sort}) %%%%% \item \ttt{complex} \newline Defines a complex variable. The syntax is e.g. \ttt{complex x = 2 + 3 * I}. (cf.~also \ttt{int}, \ttt{real}) %%%%% \item \ttt{combine} \newline The \ttt{combine [{\em }, {\em }]} operation makes a particle list whose entries are the result of adding (the momenta of) each pair of particles in the two input lists \ttt{list1}, {list2}. For example, \ttt{combine [incoming lepton, lepton]} constructs all mutual pairings of an incoming lepton with an outgoing lepton (an alias for the leptons has to be defined, of course). (cf. also \ttt{collect}, \ttt{select}, \ttt{extract}, \ttt{sort}, \ttt{+}) %%%%% \item \ttt{compile} \newline The \ttt{compile ()} command has no arguments (the parentheses can also been left out: /\ttt{compile ()}. The command is optional, it invokes the compilation of the process(es) (i.e. the matrix element file(s)) to be compiled as a shared library. This shared object file has the standard name \ttt{default\_lib.so} and resides in the \ttt{.libs} subdirectory of the corresponding user workspace. If the user has defined a different library name \ttt{lib\_name} with the \ttt{library} command, then WHIZARD compiles this as the shared object \ttt{.libs/lib\_name.so}. (This allows to split process classes and to avoid too large libraries.) Another possibility is to use the command \ttt{compile as "static\_name"}. This will compile and link the process library in a static way and create the static executable \ttt{static\_name} in the user workspace. (cf. also \ttt{library}) %%%%% \item \ttt{compile\_analysis} \newline The \ttt{compile\_analysis} statement does the same as the \ttt{write\_analysis} command, namely to tell \whizard\ to write the analysis setup by the user for the \sindarin\ input file under consideration. If no \ttt{\$out\_file} is provided, the histogram tables/plot data etc. are written to the default file \ttt{whizard\_analysis.dat}. In addition to \ttt{write\_analysis}, \ttt{compile\_analysis} also invokes the \whizard\ \LaTeX routines for producing postscript or PDF output of the data (unless the flag $\rightarrow$ \ttt{?analysis\_file\_only} is set to \ttt{true}). (cf. also \ttt{\$out\_file}, \ttt{write\_analysis}, \ttt{?analysis\_file\_only}) %%%%% \item \ttt{conjg} \newline Numerical function that takes the complex conjugate of its argument: \ttt{conjg ({\em })} yields \ttt{{\em }$^\ast$}. (cf. also \ttt{abs}, \ttt{sgn}, \ttt{mod}, \ttt{modulo}) %%%%% \item \ttt{cos} \newline Numerical function \ttt{cos ({\em })} that calculates the cosine trigonometric function of real and complex numerical numbers or variables. (cf. also \ttt{sin}, \ttt{tan}, \ttt{asin}, \ttt{acos}, \ttt{atan}) %%%%% \item \ttt{cosh} \newline Numerical function \ttt{cosh ({\em })} that calculates the hyperbolic cosine function of real and complex numerical numbers or variables. Note that its inverse function is part of the \ttt{Fortran2008} status and hence not realized. (cf. also \ttt{sinh}, \ttt{tanh}) %%%%% \item \ttt{count} \newline Subevent function that counts the number of particles or particle pairs in a subevent: \ttt{count [{\em } [, {\em }]]}. This can also be a counting subject to a condition: \ttt{count if {\em } [{\em } [, {\em }]]}. %%%%% \item \ttt{cuts} \newline This command defines the cuts to be applied to certain processes. The syntax is: \ttt{cuts = {\em } {\em } [{\em }]}, where the cut expression must be initialized with a logical classifier \ttt{log\_class} like \ttt{all}, \ttt{any}, \ttt{no}. The logical expression \ttt{log\_expr} contains the cut to be evaluated. Note that this need not only be a kinematical cut expression like \ttt{E > 10 GeV} or \ttt{5 degree < Theta < 175 degree}, but can also be some sort of trigger expression or event selection. Whether the expression is evaluated on particles or pairs of particles depends on whether the discriminating variable is unary or binary, \ttt{Dist} being obviously binary, \ttt{Pt} being unary. Note that some variables are both unary and binary, e.g. the invariant mass $M$. Cut expressions can be connected by the logical connectives \ttt{and} and \ttt{or}. The \ttt{cuts} statement acts on all subsequent process integrations and analyses until a new \ttt{cuts} statement appears. (cf. also \ttt{all}, \ttt{any}, \ttt{Dist}, \ttt{E}, \ttt{M}, \ttt{no}, \ttt{Pt}). %%%%% \item \ttt{debug} \newline Specifier for the \ttt{sample\_format} command to demand the generation of the very verbose \whizard\ ASCII event file format intended for debugging. (cf. also \ttt{\$sample}, \ttt{sample\_format}, \ttt{\$sample\_normalization}) %%%%% \item \ttt{degree} \newline Expression specifying the physical unit of degree for angular variables, e.g. the cut expression function \ttt{Theta}. (if no unit is specified for angular variables, radians are used; cf. \ttt{rad}, \ttt{mrad}). %%%% \item \ttt{Dist} \newline Binary observable specifier, that gives the $\eta$-$\phi$- (pseudorapidity-azimuth) distance $R = \sqrt{(\Delta \eta)^2 + (\Delta\phi)^2}$ between the momenta of the two particles: \ttt{eval Dist [jet, jet]}. (cf. also \ttt{eval}, \ttt{cuts}, \ttt{selection}, \ttt{Theta}, \ttt{Eta}, \ttt{Phi}) %%%%% \item \ttt{dump} \newline Specifier for the \ttt{sample\_format} command to demand the generation of the intrinsic \whizard\ event record format (output of the \ttt{particle\_t} type container). (cf. also \ttt{\$sample}, \ttt{sample\_format}, \ttt{\$sample\_normalization} %%%%% \item \ttt{E} \newline Unary (binary) observable specifier for the energy of a single (two) particle(s), e.g. \ttt{eval E ["W+"]}, \ttt{all E > 200 GeV [b, B]}. (cf. \ttt{eval}, \ttt{cuts}, \ttt{selection}) %%%%% \item \ttt{else} \label{sindarin_else}\newline Constructor for providing an alternative in a conditional clause: \ttt{if {\em } then {\em } else {\em } endif}. (cf. also \ttt{if}, \ttt{elsif}, \ttt{endif}, \ttt{then}). %%%%% \item \ttt{elsif} \newline Constructor for concatenating more than one conditional clause with each other: \ttt{if {\em } then {\em } elsif {\em } then {\em } \ldots endif}. (cf. also \ttt{if}, \ttt{else}, \ttt{endif}, \ttt{then}). %%%%% \item \ttt{endif} \newline Mandatory constructor to conclude a conditional clause: \ttt{if {\em } then \ldots endif}. (cf. also \ttt{if}, \ttt{else}, \ttt{elsif}, \ttt{then}). %%%%% \item \ttt{energy\_scan} \newline Beam structure specifier for the energy scan structure function: \ttt{beams = e1, E1 => energy\_scan}. This pair spectrum that has to be applied to both beams simultaneously can be used to scan over a range of collider energies without using the \ttt{scan} command. (cf. also \ttt{beams}, \ttt{scan}, \ttt{?energy\_scan\_normalize}) %%%%% \item \ttt{epa} \newline Beam structure specifier for the equivalent-photon approximation (EPA), i.e the Weizs\"acker-Williams structure function: e.g. \ttt{beams = e1, E1 => epa} (applied to both beams), or e.g. \ttt{beams = e1, u => epa, none} (applied to only one beam). (cf. also \ttt{beams}, \ttt{epa\_alpha}, \ttt{epa\_x\_min}, \ttt{epa\_mass}, \ttt{epa\_q\_max}, \ttt{epa\_q\_min}, \ttt{?epa\_recoil}, \ttt{?epa\_keep\_energy}) %%%%% \item \ttt{Eta} \newline Unary and also binary observable specifier, that as a unary observable gives the pseudorapidity of a particle momentum. The pseudorapidity is given by $\eta = - \log \left[ \tan (\theta/2) \right]$, where $\theta$ is the angle with the beam direction. As a binary observable, it gives the pseudorapidity difference between the momenta of two particles, where $\theta$ is the enclosed angle: \ttt{eval Eta [e1]}, \ttt{all abs (Eta) < 3.5 [jet, jet]}. (cf. also \ttt{eval}, \ttt{cuts}, \ttt{selection}, \ttt{Rap}, \ttt{abs}) %%%%% \item \ttt{eV} \newline Physical unit, stating that the corresponding number is in electron volt. (cf. also \ttt{keV}, \ttt{meV}, \ttt{MeV}, \ttt{GeV}, \ttt{TeV}) %%%%% \item \ttt{eval} \newline Evaluator that tells \whizard\ to evaluate the following expr: \ttt{eval {\em }}. Examples are: \ttt{eval Rap [e1]}, \ttt{eval M / 1 GeV [combine [q,Q]]} etc. (cf. also \ttt{cuts}, \ttt{selection}, \ttt{record}) %%%%% \item \ttt{ewa} \newline Beam structure specifier for the equivalent-photon approximation (EWA): e.g. \ttt{beams = e1, E1 => ewa} (applied to both beams), or e.g. \ttt{beams = e1, u => ewa, none} (applied to only one beam). (cf. also \ttt{beams}, \ttt{ewa\_x\_min}, \ttt{ewa\_pt\_max}, \ttt{ewa\_mass}, \ttt{?ewa\_keep\_energy}, \ttt{?ewa\_recoil}) %%%%% \item \ttt{exec} \newline Constructor \ttt{exec ("{\em }")} that demands WHIZARD to execute/run the command \ttt{cmd\_name}. For this to work that specific command must be present either in the path of the operating system or as a command in the user workspace. %%%%% \item \ttt{exit} \newline Command to finish the \whizard\ run (and not execute any further code beyond the appearance of \ttt{exit} in the \sindarin\ file. The command (which is the same as $\to$ \ttt{quit}) allows for an argument, \ttt{exit ({\em })}, where the expression can be executed, e.g. a screen message or an exit code. %%%%% \item \ttt{exp} \newline Numerical function \ttt{exp ({\em })} that calculates the exponential of real and complex numerical numbers or variables. (cf. also \ttt{sqrt}, \ttt{log}, \ttt{log10}) %%%%% \item \ttt{expect} \newline The binary function \ttt{expect} compares two numerical expressions whether they fulfill a certain ordering condition or are equal up to a specific uncertainty or tolerance which can bet set by the specifier \ttt{tolerance}, i.e. in principle it checks whether a logical expression is true. The \ttt{expect} function does actually not just check a value for correctness, but also records its result. If failures are present when the program terminates, the exit code is nonzero. The syntax is \ttt{expect ({\em } {\em } {\em })}, where \ttt{{\em }} and \ttt{{\em }} are two numerical values (or corresponding variables) and \ttt{{\em }} is one of the following logical comparators: \ttt{<}, \ttt{>}, \ttt{<=}, \ttt{>=}, \ttt{==}, \ttt{<>}. (cf. also \ttt{<}, \ttt{>}, \ttt{<=}, \ttt{>=}, \ttt{==}, \ttt{<>}, \ttt{tolerance}). %%%%% \item \ttt{extract} \newline Subevent function that either extracts the first element of a particle list/subevent: \ttt{extract [ {\em }]}, or the element at position \ttt{} of the particle list: \ttt{extract {\em index } [ {\em }]}. Negative index values count from the end of the list. (cf. also \ttt{sort}, \ttt{combine}, \ttt{collect}, \ttt{+}, \ttt{index}) %%%%% \item \ttt{factorization\_scale} \newline This is a command, \ttt{factorization\_scale = {\em }}, that sets the factorization scale of a process or list of processes. It overwrites a possible scale set by the ($\to$) \ttt{scale} command. \ttt{{\em }} can be any kinematic expression that leads to a result of momentum dimension one, e.g. \ttt{100 GeV}, \ttt{eval Pt [e1]}. (cf. also \ttt{renormalization\_scale}). %%%%% \item \ttt{false} \newline Constructor stating that a logical expression or variable is false, e.g. \ttt{?{\em } = false}. (cf. also \ttt{true}). %%%%% \item \ttt{fbarn} \newline Physical unit, stating that a number is in femtobarns ($10^{-15}$ barn). (cf. also \ttt{nbarn}, \ttt{abarn}, \ttt{pbarn}) %%%%% \item \ttt{floor} \newline This is a function \ttt{floor ({\em })} that gives the greatest integer less than or equal to \ttt{{\em }}, e.g. \ttt{int i = floor (4.56789)} gives \ttt{i = 4}. (cf. also \ttt{int}, \ttt{nint}, \ttt{ceiling}) %%%%% \item \ttt{gaussian} \newline Beam structure specifier that imposes a Gaussian energy distribution, separately for each beam. The $\sigma$ values are set by \ttt{gaussian\_spread1} and \ttt{gaussian\_spread2}, respectively. %%%%% \item \ttt{GeV} \newline Physical unit, energies in $10^9$ electron volt. This is the default energy unit of WHIZARD. (cf. also \ttt{eV}, \ttt{keV}, \ttt{MeV}, \ttt{meV}, \ttt{TeV}) %%%%% \item \ttt{graph} \newline This command defines the necessary information regarding producing a graph of a function in \whizard's internal graphical \gamelan\ output. The syntax is: \ttt{graph {\em } \{ {\em } \}}. The record with name \ttt{{\em }} has to be defined, either before or after the graph definition. Possible optional arguments of the \ttt{graph} command are the minimal and maximal values of the axes (\ttt{x\_min}, \ttt{x\_max}, \ttt{y\_min}, \ttt{y\_max}). (cf. \ttt{plot}, \ttt{histogram}, \ttt{record}) %%%%% \item \ttt{Hel} \newline Unary observable specifier that allows to specify the helicity of a particle, e.g. \ttt{all Hel == -1 [e1]} in a selection. (cf. also \ttt{eval}, \ttt{cuts}, \ttt{selection}) %%%%% \item \ttt{hepevt} \newline Specifier for the \ttt{sample\_format} command to demand the generation of HEPEVT ASCII event files. (cf. also \ttt{\$sample}, \ttt{sample\_format}) %%%%% \item \ttt{hepevt\_verb} \newline Specifier for the \ttt{sample\_format} command to demand the generation of the extended or verbose version of HEPEVT ASCII event files. (cf. also \ttt{\$sample}, \ttt{sample\_format}) %%%%% \item \ttt{hepmc} \newline Specifier for the \ttt{sample\_format} command to demand the generation of HepMC ASCII event files. Note that this is only available if the HepMC package is installed and correctly linked. (cf. also \ttt{\$sample}, \ttt{sample\_format}, \ttt{?hepmc\_output\_cross\_section}) %%%%% \item \ttt{histogram} \newline This command defines the necessary information regarding plotting data as a histogram, in the form of: \ttt{histogram {\em } \{ {\em } \}}. The record with name \ttt{{\em }} has to be defined, either before or after the histogram definition. Possible optional arguments of the \ttt{histogram} command are the minimal and maximal values of the axes (\ttt{x\_min}, \ttt{x\_max}, \ttt{y\_min}, \ttt{y\_max}). (cf. \ttt{graph}, \ttt{plot}, \ttt{record}) %%%%% \item \ttt{if} \newline Conditional clause with the construction \ttt{if {\em } then {\em } [else {\em } \ldots] endif}. Note that there must be an \ttt{endif} statement. For more complicated expressions it is better to use expressions in parentheses: \ttt{if ({\em }) then \{{\em }\} else \{{\em }\} endif}. Examples are a selection of up quarks over down quarks depending on a logical variable: \ttt{if ?ok then u else d}, or the setting of an integer variable depending on the rapidity of some particle: \ttt{if (eta > 0) then \{ a = +1\} else \{ a = -1\}}. (cf. also \ttt{elsif}, \ttt{endif}, \ttt{then}) %%%%% \item \ttt{in} \newline Second part of the constructor to let a variable be local to an expression. It has the syntax \ttt{let {\em } = {\em } in {\em }}. E.g. \ttt{let int a = 3 in let int b = 4 in {\em }} (cf. also \ttt{let}) %%%%% \item \ttt{include} \newline The \ttt{include} statement, \ttt{include ("file.sin")} allows to include external \sindarin\ files \ttt{file.sin} into the main WHIZARD input file. A standard example is the inclusion of the standard cut file \ttt{default\_cuts.sin}. %%%%% \item \ttt{incoming} \newline Constructor that specifies particles (or subevents) as incoming. It is used in cuts, analyses or selections, e.g. \ttt{cuts = all Theta > 20 degree [incoming lepton, lepton]}. (cf. also \ttt{beam}, \ttt{outgoing}, \ttt{cuts}, \ttt{analysis}, \ttt{selection}, \ttt{record}) %%%%% \item \ttt{index} \newline Specifies the position of the element of a particle to be extracted by the subevent function ($\to$) \ttt{extract}: \ttt{extract {\em index } [ {\em }]}. Negative index values count from the end of the list. (cf. also \ttt{extract}, \ttt{sort}, \ttt{combine}, \ttt{collect}, \ttt{+}) %%%%% \item \ttt{int} \newline 1) This is a constructor to specify integer constants in the input file. Strictly speaking, it is a unary function setting the value \ttt{int\_val} of the integer variable \ttt{int\_var}: \ttt{int {\em } = {\em }}. Note that is mandatory for all user-defined variables. (cf. also \ttt{real} and \ttt{complex}) 2) It is a function \ttt{int ({\em })} that converts real and complex numbers (here their real parts) into integers. (cf. also \ttt{nint}, \ttt{floor}, \ttt{ceiling}) %%%%% \item \ttt{integrate} \newline The \ttt{integrate ({\em }) \{ {\em } \}} command invokes the integration (phase-space generation and Monte-Carlo sampling) of the process \ttt{proc\_name} (which can also be a list of processes) with the integration options \ttt{{\em }}. Possible options are (1) via \ttt{\$integration\_method = "{\em }"} the integration method (the default being VAMP), (2) the number of iterations and calls per integration during the Monte-Carlo phase-space integration via the \ttt{iterations} specifier; (3) goal for the accuracy, error or relative error (\ttt{accuracy\_goal}, \ttt{error\_goal}, \ttt{relative\_error\_goal}). (4) Invoking only phase space generation (\ttt{?phs\_only = true}), (5) making test calls of the matrix element. (cf. also \ttt{iterations}, \ttt{accuracy\_goal}, \ttt{error\_goal}, \ttt{relative\_error\_goal}, \ttt{error\_threshold}) %%%%% \item \ttt{isr} \newline Beam structure specifier for the lepton-collider/QED initial-state radiation (ISR) structure function: e.g. \ttt{beams = e1, E1 => isr} (applied to both beams), or e.g. \ttt{beams = e1, u => isr, none} (applied to only one beam). (cf. also \ttt{beams}, \ttt{isr\_alpha}, \ttt{isr\_q\_max}, \ttt{isr\_mass}, \ttt{isr\_order}, \ttt{?isr\_recoil}, \ttt{?isr\_keep\_energy}) %%%%% \item \ttt{iterations} \qquad (default: internal heuristics) \newline Option to set the number of iterations and calls per iteration during the Monte-Carlo phase-space integration process. The syntax is \ttt{iterations = {\em }:{\em }}. Note that this can be also a list, separated by colons, which breaks up the integration process into passes of the specified number of integrations and calls each. It works for all integration methods. For VAMP, there is the additional option to specify whether grids and channel weights should be adapted during iterations (\ttt{"g"}, \ttt{"w"}, \ttt{"gw"} for both, or \ttt{""} for no adaptation). (cf. also \ttt{integrate}, \ttt{accuracy\_goal}, \ttt{error\_goal}, \ttt{relative\_error\_goal}, \ttt{error\_threshold}). %%%%% \item \ttt{join} \newline Subevent function that concatenates two particle lists/subevents if there is no overlap: \ttt{join [{\em }, {\em }]}. The joining of the two lists can also be made depending on a condition: \ttt{join if {\em } [{\em }, {\em }]}. (cf. also \ttt{\&}, \ttt{collect}, \ttt{combine}, \ttt{extract}, \ttt{sort}, \ttt{+}) %%%%% \item \ttt{keV} \newline Physical unit, energies in $10^3$ electron volt. (cf. also \ttt{eV}, \ttt{meV}, \ttt{MeV}, \ttt{GeV}, \ttt{TeV}) %%%%% \item \ttt{kT} \newline Binary particle observable that represents a jet $k_T$ clustering measure: \ttt{kT [j1, j2]} gives the following kinematic expression: $2 \min(E_{j1}^2, E_{j2}^2) / Q^2 \times (1 - \cos\theta_{j1,j2})$. At the moment, $Q^2 = 1$. %%%%% \item \ttt{let} \newline This allows to let a variable be local to an expression. It has the syntax \ttt{let {\em } = {\em } in {\em }}. E.g. \ttt{let int a = 3 in let int b = 4 in {\em }} (cf. also \ttt{in}) %%%%% \item \ttt{lha} \newline Specifier for the \ttt{sample\_format} command to demand the generation of the \whizard\ version 1 style (deprecated) LHA ASCII event format files. (cf. also \ttt{\$sample}, \newline \ttt{sample\_format}) %%%%% \item \ttt{lhapdf} \newline This is a beams specifier to demand calling \lhapdf\ parton densities as structure functions to integrate processes in hadron collisions. Note that this only works if the external \lhapdf\ library is present and correctly linked. (cf. \ttt{beams}, \ttt{\$lhapdf\_dir}, \ttt{\$lhapdf\_file}, \ttt{lhapdf\_photon}, \ttt{\$lhapdf\_photon\_file}, \ttt{lhapdf\_member}, \ttt{lhapdf\_photon\_scheme}) %%%%% \item \ttt{lhapdf\_photon} \newline This is a beams specifier to demand calling \lhapdf\ parton densities as structure functions to integrate processes in hadron collisions with a photon as initializer of the hard scattering process. Note that this only works if the external \lhapdf\ library is present and correctly linked. (cf. \ttt{beams}, \ttt{lhapdf}, \ttt{\$lhapdf\_dir}, \ttt{\$lhapdf\_file}, \ttt{\$lhapdf\_photon\_file}, \ttt{lhapdf\_member}, \ttt{lhapdf\_photon\_scheme}) %%%%% \item \ttt{lhef} \newline Specifier for the \ttt{sample\_format} command to demand the generation of the Les Houches Accord (LHEF) event format files, with XML headers. There are several different versions of this format, which can be selected via the \ttt{\$lhef\_version} specifier (cf. also \ttt{\$sample}, \ttt{sample\_format}, \ttt{\$lhef\_version}, \ttt{\$lhef\_extension}, \ttt{?lhef\_write\_sqme\_prc}, \newline \ttt{?lhef\_write\_sqme\_ref}, \ttt{?lhef\_write\_sqme\_alt}) %%%%% \item \ttt{library} \newline The command \ttt{library = "{\em }"} allows to specify a separate shared object library archive \ttt{lib\_name.so}, not using the standard library \ttt{default\_lib.so}. Those libraries (when using shared libraries) are located in the \ttt{.libs} subdirectory of the user workspace. Specifying a separate library is useful for splitting up large lists of processes, or to restrict a larger number of different loaded model files to one specific process library. (cf. also \ttt{compile}, \ttt{\$library\_name}) %%%%% \item \ttt{log} \newline Numerical function \ttt{log ({\em })} that calculates the natural logarithm of real and complex numerical numbers or variables. (cf. also \ttt{sqrt}, \ttt{exp}, \ttt{log10}) %%%%% \item \ttt{log10} \newline Numerical function \ttt{log10 ({\em })} that calculates the base 10 logarithm of real and complex numerical numbers or variables. (cf. also \ttt{sqrt}, \ttt{exp}, \ttt{log}) %%%%% \item \ttt{long} \newline Specifier for the \ttt{sample\_format} command to demand the generation of the long variant of HEPEVT ASCII event files. (cf. also \ttt{\$sample}, \ttt{sample\_format}) %%%%% \item \ttt{M} \newline Unary (binary) observable specifier for the (signed) mass of a single (two) particle(s), e.g. \ttt{eval M [e1]}, \ttt{any M = 91 GeV [e2, E2]}. (cf. \ttt{eval}, \ttt{cuts}, \ttt{selection}) %%%%% \item \ttt{M2} \newline Unary (binary) observable specifier for the mass squared of a single (two) particle(s), e.g. \ttt{eval M2 [e1]}, \ttt{all M2 > 2*mZ [e2, E2]}. (cf. \ttt{eval}, \ttt{cuts}, \ttt{selection}) %%%%% \item \ttt{max} \newline Numerical function with two arguments \ttt{max ({\em }, {\em })} that gives the maximum of the two arguments: $\max (var1, var2)$. It can act on all combinations of integer and real variables. Example: \ttt{real heavier\_mass = max (mZ, mH)}. (cf. also \ttt{min}) %%%%% \item \ttt{meV} \newline Physical unit, stating that the corresponding number is in $10^{-3}$ electron volt. (cf. also \ttt{eV}, \ttt{keV}, \ttt{MeV}, \ttt{GeV}, \ttt{TeV}) %%%%% \item \ttt{MeV} \newline Physical unit, energies in $10^6$ electron volt. (cf. also \ttt{eV}, \ttt{keV}, \ttt{meV}, \ttt{GeV}, \ttt{TeV}) %%%%% \item \ttt{min} \newline Numerical function with two arguments \ttt{min ({\em }, {\em })} that gives the minimum of the two arguments: $\min (var1, var2)$. It can act on all combinations of integer and real variables. Example: \ttt{real lighter\_mass = min (mZ, mH)}. (cf. also \ttt{max}) %%%%% \item \ttt{mod} \newline Numerical function for integer and real numbers \ttt{mod (x, y)} that computes the remainder of the division of \ttt{x} by \ttt{y} (which must not be zero). (cf. also \ttt{abs}, \ttt{conjg}, \ttt{sgn}, \ttt{modulo}) %%%%% \item \ttt{model} \qquad (default: \ttt{SM}) \newline With this specifier, \ttt{model = {\em }}, one sets the hard interaction physics model for the processes defined after this model specification. The list of available models can be found in Table \ref{tab:models}. Note that the model specification can appear arbitrarily often in a \sindarin\ input file, e.g. for compiling and running processes defined in different physics models. (cf. also \ttt{\$model\_name}) %%%%% \item \ttt{modulo} \newline Numerical function for integer and real numbers \ttt{modulo (x, y)} that computes the value of $x$ modulo $y$. (cf. also \ttt{abs}, \ttt{conjg}, \ttt{sgn}, \ttt{mod}) %%%%% \item \ttt{mokka} \newline Specifier for the \ttt{sample\_format} command to demand the generation of the MOKKA variant for HEPEVT ASCII event files. (cf. also \ttt{\$sample}, \ttt{sample\_format}) %%%%% \item \ttt{mrad} \newline Expression specifying the physical unit of milliradians for angular variables. This default in \whizard\ is \ttt{rad}. (cf. \ttt{degree}, \ttt{rad}). %%%%% \item \ttt{nbarn} \newline Physical unit, stating that a number is in nanobarns ($10^{-9}$ barn). (cf. also \ttt{abarn}, \ttt{fbarn}, \ttt{pbarn}) %%%%% \item \ttt{n\_in} \newline Integer variable that accesses the number of incoming particles of a process. It can be used in cuts or in an analysis. (cf. also \ttt{sqrts\_hat}, \ttt{cuts}, \ttt{record}, \ttt{n\_out}, \ttt{n\_tot}) %%%%% \item \ttt{Nacl} \newline Unary observable specifier that returns the total number of open anticolor lines of a particle or subevent (i.e., composite particle). Defined only if \ttt{?colorize\_subevt} is true.. (cf. also \ttt{Ncol}, \ttt{?colorize\_subevt}) %%%%% \item \ttt{Ncol} \newline Unary observable specifier that returns the total number of open color lines of a particle or subevent (i.e., composite particle). Defined only if \ttt{?colorize\_subevt} is true.. (cf. also \ttt{Nacl}, \ttt{?colorize\_subevt}) %%%%% \item \ttt{nint} \newline This is a function \ttt{nint ({\em })} that converts real numbers into the closest integer, e.g. \ttt{int i = nint (4.56789)} gives \ttt{i = 5}. (cf. also \ttt{int}, \ttt{floor}, \ttt{ceiling}) %%%%% \item \ttt{no} \newline \ttt{no} is a function that works on a logical expression and a list, \ttt{no {\em } [{\em }]}, and returns \ttt{true} if and only if \ttt{log\_expr} is fulfilled for {\em none} of the entries in \ttt{list}, and \ttt{false} otherwise. Examples: \ttt{no Pt < 100 GeV [lepton]} checks whether no lepton is softer than 100 GeV. It is the logical opposite of the function \ttt{all}. Logical expressions with \ttt{no} can be logically combined with \ttt{and} and \ttt{or}. (cf. also \ttt{all}, \ttt{any}, \ttt{and}, and \ttt{or}) %%%%% \item \ttt{none} \newline Beams specifier that can used to explicitly {\em not} apply a structure function to a beam, e.g. in HERA physics: \ttt{beams = e1, P => none, pdf\_builtin}. (cf. also \ttt{beams}) %%%%% \item \ttt{not} \newline This is the standard logical negation that converts true into false and vice versa. It is applied to logical values, e.g. cut expressions. (cf. also \ttt{and}, \ttt{or}). %%%%% \item \ttt{n\_out} \newline Integer variable that accesses the number of outgoing particles of a process. It can be used in cuts or in an analysis. (cf. also \ttt{sqrts\_hat}, \ttt{cuts}, \ttt{record}, \ttt{n\_in}, \ttt{n\_tot}) %%%%% \item \ttt{n\_tot} \newline Integer variable that accesses the total number of particles (incoming plus outgoing) of a process. It can be used in cuts or in an analysis. (cf. also \ttt{sqrts\_hat}, \ttt{cuts}, \ttt{record}, \ttt{n\_in}, \ttt{n\_out}) %%%%% \item \ttt{observable} \newline With this, \ttt{observable = {\em }}, the user is able to define a variable specifier \ttt{obs\_spec} for observables. These can be reused in the analysis, e.g. as a \ttt{record}, as functions of the fundamental kinematical variables of the processes. (cf. \ttt{analysis}, \ttt{record}) %%%%% \item \ttt{open\_out} \newline With the command, \ttt{open\_out ("{\em })} user-defined information like data or ($\to$) \ttt{printf} statements can be written out to a user-defined file. The command opens an I/O stream to an external file \ttt{{\em }}. (cf. also \ttt{close\_out}, \ttt{\$out\_file}, \ttt{printf}) %%%%% \item \ttt{or} \newline This is the standard two-place logical connective that has the value true if one of its operands is true, otherwise a value of false. It is applied to logical values, e.g. cut expressions. (cf. also \ttt{and}, \ttt{not}). %%%%% \item \ttt{outgoing} \newline Constructor that specifies particles (or subevents) as outgoing. It is used in cuts, analyses or selections, e.g. \ttt{cuts = all Theta > 20 degree [incoming lepton, outgoing lepton]}. Note that the \ttt{outgoing} keyword is redundant and included only for completeness: \ttt{outgoing lepton} has the same meaning as \ttt{lepton}. (cf. also \ttt{beam}, \ttt{incoming}, \ttt{cuts}, \ttt{analysis}, \ttt{selection}, \ttt{record}) %%%%% \item \ttt{P} \newline Unary (binary) observable specifier for the spatial momentum $\sqrt{\vec{p}^2}$ of a single (two) particle(s), e.g. \ttt{eval P ["W+"]}, \ttt{all P > 200 GeV [b, B]}. (cf. \ttt{eval}, \ttt{cuts}, \ttt{selection}) %%%%% \item \ttt{pbarn} \newline Physical unit, stating that a number is in picobarns ($10^{-12}$ barn). (cf. also \ttt{abarn}, \ttt{fbarn}, \ttt{nbarn}) %%%%% \item \ttt{pdf\_builtin} \newline This is a beams specifier for \whizard's internal PDF structure functions to integrate processes in hadron collisions. (cf. \ttt{beams}, \ttt{pdf\_builtin\_photon}, \ttt{\$pdf\_builtin\_file}) %%%%% \item \ttt{pdf\_builtin\_photon} \newline This is a beams specifier for \whizard's internal PDF structure functions to integrate processes in hadron collisions with a photon as initializer of the hard scattering process. (cf. \ttt{beams}, \ttt{\$pdf\_builtin\_file}) %%%%% \item \ttt{PDG} \newline Unary observable specifier that allows to specify the PDG code of a particle, e.g. \ttt{eval PDG [e1]}, giving \ttt{11}. (cf. also \ttt{eval}, \ttt{cuts}, \ttt{selection}) %%%%% \item \ttt{Phi} \newline Unary and also binary observable specifier, that as a unary observable gives the azimuthal angle of a particle's momentum in the detector frame (beam into $+z$ direction). As a binary observable, it gives the azimuthal difference between the momenta of two particles: \ttt{eval Phi [e1]}, \ttt{all Phi > Pi [jet, jet]}. (cf. also \ttt{eval}, \ttt{cuts}, \ttt{selection}, \ttt{Theta}) %%%%% \item \ttt{photon\_isolation} \newline Logical function \ttt{photon\_isolation if {\em } [{\em } , {\em }]} that cuts out event where the photons in \ttt{{\em }} do not fulfill the condition \ttt{{\em }} and are not isolated from hadronic (and electromagnetic) activity, i.e. the photon fragmentation. (cf. also \ttt{cluster}, \ttt{collect}, \ttt{combine}, \ttt{extract}, \ttt{select}, \ttt{sort}, \ttt{+}) %%%%% \item \ttt{Pl} \newline Unary (binary) observable specifier for the longitudinal momentum ($p_z$ in the c.m. frame) of a single (two) particle(s), e.g. \ttt{eval Pl ["W+"]}, \ttt{all Pl > 200 GeV [b, B]}. (cf. \ttt{eval}, \ttt{cuts}, \ttt{selection}) %%%%% \item \ttt{plot} \newline This command defines the necessary information regarding plotting data as a graph, in the form of: \ttt{plot {\em } \{ {\em } \}}. The record with name \ttt{{\em }} has to be defined, either before or after the plot definition. Possible optional arguments of the \ttt{plot} command are the minimal and maximal values of the axes (\ttt{x\_min}, \ttt{x\_max}, \ttt{y\_min}, \ttt{y\_max}). (cf. \ttt{graph}, \ttt{histogram}, \ttt{record}) %%%%% \item \ttt{polarized} \newline Constructor to instruct \whizard\ to retain polarization of the corresponding particles in the generated events: \ttt{polarized {\em } [, {\em } , ...]}. (cf. also \ttt{unpolarized}, \ttt{simulate}, \ttt{?polarized\_events}) %%%%% \item \ttt{printf} \newline Command that allows to print data as screen messages, into logfiles or into user-defined output files: \ttt{printf "{\em }"}. There exist format specifiers, very similar to the \ttt{C} command \ttt{printf}, e.g. \ttt{printf "\%i" (123)}. (cf. also \ttt{open\_out}, \ttt{close\_out}, \ttt{\$out\_file}, \ttt{?out\_advance}, \ttt{sprintf}, \ttt{\%d}, \ttt{\%i}, \ttt{\%e}, \ttt{\%f}, \ttt{\%g}, \ttt{\%E}, \ttt{\%F}, \ttt{\%G}, \ttt{\%s}) %%%%% \item \ttt{process} \newline Allows to set a hard interaction process, either for a decay process with name \ttt{{\em }} as \ttt{process {\em } = {\em } => {\em }, {\em }, ...}, or for a scattering process with name \ttt{{\em } = {\em }, {\em } => {\em }, {\em }, ...}. Note that there can be arbitrarily many processes to be defined in a \sindarin\ input file. There are two options for particle/process sums: flavor sums: \ttt{{\em }:{\em }:...}, where all masses have to be identical, and inclusive sums, \ttt{{\em } + {\em } + ...}. The latter can be done on the level of individual particles, or sums over whole final states. Here, masses can differ, and terms will be translated into different process components. The \ttt{process} command also allows for optional arguments, e.g. to specify a numerical identifier (cf. \ttt{process\_num\_id}), the method how to generate the code for the matrix element(s): \ttt{\$method}, possible methods are either with the \oMega\ matrix element generator, using template matrix elements with different normalizations, or completely internal matrix element; for \oMega\ matrix elements there is also the possibility to specify possible restrictions (cf. \ttt{\$restrictions}). %%%%% \item \ttt{Pt} \newline Unary (binary) observable specifier for the transverse momentum ($\sqrt{p_x^2 + p_y^2}$ in the c.m. frame) of a single (two) particle(s), e.g. \ttt{eval Pt ["W+"]}, \ttt{all Pt > 200 GeV [b, B]}. (cf. \ttt{eval}, \ttt{cuts}, \ttt{selection}) %%%%% \item \ttt{Px} \newline Unary (binary) observable specifier for the $x$-component of the momentum of a single (two) particle(s), e.g. \ttt{eval Px ["W+"]}, \ttt{all Px > 200 GeV [b, B]}. (cf. \ttt{eval}, \ttt{cuts}, \ttt{selection}) %%%%% \item \ttt{Py} \newline Unary (binary) observable specifier for the $y$-component of the momentum of a single (two) particle(s), e.g. \ttt{eval Py ["W+"]}, \ttt{all Py > 200 GeV [b, B]}. (cf. \ttt{eval}, \ttt{cuts}, \ttt{selection}) %%%%% \item \ttt{Pz} \newline Unary (binary) observable specifier for the $z$-component of the momentum of a single (two) particle(s), e.g. \ttt{eval Pz ["W+"]}, \ttt{all Pz > 200 GeV [b, B]}. (cf. \ttt{eval}, \ttt{cuts}, \ttt{selection}) %%%%% \item \ttt{quit} \newline Command to finish the \whizard\ run (and not execute any further code beyond the appearance of \ttt{quit} in the \sindarin\ file. The command (which is the same as $\to$ \ttt{exit}) allows for an argument, \ttt{quit ({\em })}, where the expression can be executed, e.g. a screen message or an quit code. %%%%% \item \ttt{rad} \newline Expression specifying the physical unit of radians for angular variables. This is the default in \whizard. (cf. \ttt{degree}, \ttt{mrad}). %%%%% \item \ttt{Rap} \newline Unary and also binary observable specifier, that as a unary observable gives the rapidity of a particle momentum. The rapidity is given by $y = \frac12 \log \left[ (E + p_z)/(E-p_z) \right]$. As a binary observable, it gives the rapidity difference between the momenta of two particles: \ttt{eval Rap [e1]}, \ttt{all abs (Rap) < 3.5 [jet, jet]}. (cf. also \ttt{eval}, \ttt{cuts}, \ttt{selection}, \ttt{Eta}, \ttt{abs}) %%%%% \item \ttt{read\_slha} \newline Tells \whizard\ to read in an input file in the SUSY Les Houches accord (SLHA), as \ttt{read\_slha ("slha\_file.slha")}. Note that the files for the use in \whizard\ should have the suffix \ttt{.slha}. (cf. also \ttt{write\_slha}, \ttt{?slha\_read\_decays}, \ttt{?slha\_read\_input}, \ttt{?slha\_read\_spectrum}) %%%%% \item \ttt{real} \newline This is a constructor to specify real constants in the input file. Strictly speaking, it is a unary function setting the value \ttt{real\_val} of the real variable \ttt{real\_var}: \ttt{real {\em } = {\em }}. (cf. also \ttt{int} and \ttt{complex}) %%%%% \item \ttt{real\_epsilon}\\ Predefined real; the relative uncertainty intrinsic to the floating point type of the \fortran\ compiler with which \whizard\ has been built. %%%%% \item \ttt{real\_precision}\\ Predefined integer; the decimal precision of the floating point type of the \fortran\ compiler with which \whizard\ has been built. %%%%% \item \ttt{real\_range}\\ Predefined integer; the decimal range of the floating point type of the \fortran\ compiler with which \whizard\ has been built. %%%%% \item \ttt{real\_tiny}\\ Predefined real; the smallest number which can be represented by the floating point type of the \fortran\ compiler with which \whizard\ has been built. %%%%% \item \ttt{record} \newline The \ttt{record} constructor provides an internal data structure in \sindarin\ input files. Its syntax is in general \ttt{record {\em } ({\em })}. The \ttt{{\em }} could be the definition of a tuple of points for a histogram or an \ttt{eval} constructor that tells \whizard\ e.g. by which rule to calculate an observable to be stored in the record \ttt{record\_name}. Example: \ttt{record h (12)} is a record for a histogram defined under the name \ttt{h} with the single data point (bin) at value 12; \ttt{record rap1 (eval Rap [e1])} defines a record with name \ttt{rap1} which has an evaluator to calculate the rapidity (predefined \whizard\ function) of an outgoing electron. (cf. also \ttt{eval}, \ttt{histogram}, \ttt{plot}) %%%%% \item \ttt{renormalization\_scale} \newline This is a command, \ttt{renormalization\_scale = {\em }}, that sets the renormalization scale of a process or list of processes. It overwrites a possible scale set by the ($\to$) \ttt{scale} command. \ttt{{\em }} can be any kinematic expression that leads to a result of momentum dimension one, e.g. \ttt{100 GeV}, \ttt{eval Pt [e1]}. (cf. also \ttt{factorization\_scale}). %%%%% \item \ttt{rescan} \newline This command allows to rescan event samples with modified model parameter, beam structure etc. to recalculate (analysis) observables, e.g.: \newline \ttt{rescan "{\em }" ({\em }) \{ {\em }\}}. \newline \ttt{"{\em }"} is the name of the event file and \ttt{{\em }} is the process whose (existing) event file of arbitrary size that is to be rescanned. Several flags allow to reconstruct the beams ($\to$ \ttt{?recover\_beams}), to reuse only the hard process but rebuild the full events ($\to$ \ttt{?update\_event}), to recalculate the matrix element ($\to$ \ttt{?update\_sqme}) or to recalculate the individual event weight ($\to$ \ttt{?update\_weight}). Further rescan options are redefining model parameter input, or defining a completely new alternative setup ($\to$ \ttt{alt\_setup}) (cf. also \ttt{\$rescan\_input\_format}) %%%%% \item \ttt{results} \newline Only used in the combination \ttt{show (results)}. Forces \whizard\ to print out a results summary for the integrated processes. (cf. also \ttt{show}) %%%%% \item \ttt{reweight} \newline The \ttt{reweight = {\em }} command allows to give for a process or list of processes an alternative weight, given by any kind of scalar expression \ttt{{\em }}, e.g. \ttt{reweight = 0.2} or \ttt{reweight = (eval M2 [e1, E1]) / (eval M2 [e2, E2])}. (cf. also \ttt{alt\_setup}, \ttt{weight}, \ttt{rescan}) %%%%% \item \ttt{sample\_format} \newline Variable that allows the user to specify additional event formats beyond the \whizard\ native binary event format. Its syntax is \ttt{sample\_format = {\em }}, where \ttt{{\em }} can be any of the following specifiers: \ttt{hepevt}, \ttt{hepevt\_verb}, \ttt{ascii}, \ttt{athena}, \ttt{debug}, \ttt{long}, \ttt{short}, \ttt{hepmc}, \ttt{lhef}, \ttt{lha}, \ttt{lha\_verb}, \ttt{stdhep}, \ttt{stdhep\_up}, \texttt{lcio}, \texttt{mokka}. (cf. also \ttt{\$sample}, \ttt{simulate}, \ttt{hepevt}, \ttt{ascii}, \ttt{athena}, \ttt{debug}, \ttt{long}, \ttt{short}, \ttt{hepmc}, \ttt{lhef}, \ttt{lha}, \ttt{stdhep}, \ttt{stdhep\_up}, \texttt{lcio}, \texttt{mokka}, \ttt{\$sample\_normalization}, \ttt{?sample\_pacify}, \newline \ttt{sample\_max\_tries}, \ttt{sample\_split\_n\_evt}, \ttt{sample\_split\_n\_kbytes}) %%%%% \item \ttt{scale} \newline This is a command, \ttt{scale = {\em }}, that sets the kinematic scale of a process or list of processes. Unless overwritten explicitly by ($\to$) \ttt{factorization\_scale} and/or ($\to$) \ttt{renormalization\_scale} it sets both scales. \ttt{{\em }} can be any kinematic expression that leads to a result of momentum dimension one, e.g. \ttt{scale = 100 GeV}, \ttt{scale = eval Pt [e1]}. %%%%% \item \ttt{scan} \newline Constructor to perform loops over variables or scan over processes in the integration procedure. The syntax is \ttt{scan {\em } {\em } ({\em } or {\em } => {\em } /{\em } {\em }) \{ {\em } \}}. The variable \ttt{var} can be specified if it is not a real, e.g. an integer. \ttt{var\_name} is the name of the variable which is also allowed to be a predefined one like \ttt{seed}. For the scan, one can either specify an explicit list of values \ttt{value list}, or use an initial and final value and a rule to increment. The \ttt{scan\_cmd} can either be just a \ttt{show} to print out the scanned variable or the integration of a process. Examples are: \ttt{scan seed (32 => 1 // 2) \{ show (seed\_value) \} }, which runs the seed down in steps 32, 16, 8, 4, 2, 1 (division by two). \ttt{scan mW (75 GeV, 80 GeV => 82 GeV /+ 0.5 GeV, 83 GeV => 90 GeV /* 1.2) \{ show (sw) \} } scans over the $W$ mass for the values 75, 80, 80.5, 81, 81.5, 82, 83 GeV, namely one discrete value, steps by adding 0.5 GeV, and increase by 20 \% (the latter having no effect as it already exceeds the final value). It prints out the corresponding value of the effective mixing angle which is defined as a dependent variable in the model input file(s). \ttt{scan sqrts (500 GeV => 600 GeV /+ 10 GeV) \{ integrate (proc) \} } integrates the process \ttt{proc} in eleven increasing 10 GeV steps in center-of-mass energy from 500 to 600 GeV. (cf. also \ttt{/+}, \ttt{/+/}, \ttt{/-}, \ttt{/*}, \ttt{/*/}, \ttt{//}) %%%%% \item \ttt{select} \newline Subevent function \ttt{select if {\em } [{\em } [ , {\em }]]} that selects all particles in \ttt{{\em }} that satisfy the condition \ttt{{\em }}. The second particle list \ttt{{\em }} is for conditions that depend on binary observables. (cf. also \ttt{collect}, \ttt{combine}, \ttt{extract}, \ttt{sort}, \ttt{+}) %%%%% \item \ttt{select\_b\_jet} \newline Subevent function \ttt{select if {\em } [{\em } [ , {\em }]]} that selects all particles in \ttt{{\em }} that are $b$ jets and satisfy the condition \ttt{{\em }}. The second particle list \ttt{{\em }} is for conditions that depend on binary observables. (cf. also \ttt{cluster}, \ttt{collect}, \ttt{combine}, \ttt{extract}, \ttt{select}, \ttt{sort}, \ttt{+}) %%%%% \item \ttt{select\_c\_jet} \newline Subevent function \ttt{select if {\em } [{\em } [ , {\em }]]} that selects all particles in \ttt{{\em }} that are $c$ jets (but {\em not} $b$ jets) and satisfy the condition \ttt{{\em }}. The second particle list \ttt{{\em }} is for conditions that depend on binary observables. (cf. also \ttt{cluster}, \ttt{collect}, \ttt{combine}, \ttt{extract}, \ttt{select}, \ttt{sort}, \ttt{+}) %%%%% \item \ttt{select\_light\_jet} \newline Subevent function \ttt{select if {\em } [{\em } [ , {\em }]]} that selects all particles in \ttt{{\em }} that are light(-flavor) jets and satisfy the condition \ttt{{\em }}. The second particle list \ttt{{\em }} is for conditions that depend on binary observables. (cf. also \ttt{cluster}, \ttt{collect}, \ttt{combine}, \ttt{extract}, \ttt{select}, \ttt{sort}, \ttt{+}) %%%%% \item \ttt{select\_non\_b\_jet} \newline Subevent function \ttt{select if {\em } [{\em } [ , {\em }]]} that selects all particles in \ttt{{\em }} that are {\em not} $b$ jets ($c$ and light jets) and satisfy the condition \ttt{{\em }}. The second particle list \ttt{{\em }} is for conditions that depend on binary observables. (cf. also \ttt{cluster}, \ttt{collect}, \ttt{combine}, \ttt{extract}, \ttt{select}, \ttt{sort}, \ttt{+}) %%%%% \item \ttt{selection} \newline Command that allows to select particular final states in an analysis selection, \ttt{selection = {\em }}. The term \ttt{log\_expr} can be any kind of logical expression. The syntax matches exactly the one of the ($\to$) \ttt{cuts} command. E.g. \ttt{selection = any PDG == 13} is an electron selection in a lepton sample. %%%%% \item \ttt{sgn} \newline Numerical function for integer and real numbers that gives the sign of its argument: \ttt{sgn ({\em })} yields $+1$ if \ttt{{\em }} is positive or zero, and $-1$ otherwise. (cf. also \ttt{abs}, \ttt{conjg}, \ttt{mod}, \ttt{modulo}) %%%%% \item \ttt{short} \newline Specifier for the \ttt{sample\_format} command to demand the generation of the short variant of HEPEVT ASCII event files. (cf. also \ttt{\$sample}, \ttt{sample\_format}) %%%%% \item \ttt{show} \newline This is a unary function that is operating on specific constructors in order to print them out in the \whizard\ screen output as well as the log file \ttt{whizard.log}. Examples are \ttt{show({\em })} to issue a specific parameter from a model or a constant defined in a \sindarin\ input file, \ttt{show(integral({\em }))}, \ttt{show(library)}, \ttt{show(results)}, or \ttt{show({\em })} for any arbitrary variable. Further possibilities are \ttt{show(real)}, \ttt{show(string)}, \ttt{show(logical)} etc. to allow to show all defined real, string, logical etc. variables, respectively. (cf. also \ttt{library}, \ttt{results}) %%%%% \item \ttt{simulate} \newline This command invokes the generation of events for the process \ttt{proc} by means of \ttt{simulate ({\em })}. Optional arguments: \ttt{\$sample}, \ttt{sample\_format}, \ttt{checkpoint} (cf. also \ttt{integrate}, \ttt{luminosity}, \ttt{n\_events}, \ttt{\$sample}, \ttt{sample\_format}, \ttt{checkpoint}, \ttt{?unweighted}, \ttt{safety\_factor}, \ttt{?negative\_weights}, \ttt{sample\_max\_tries}, \ttt{sample\_split\_n\_evt}, \ttt{sample\_split\_n\_kbytes}) %%%%% \item \ttt{sin} \newline Numerical function \ttt{sin ({\em })} that calculates the sine trigonometric function of real and complex numerical numbers or variables. (cf. also \ttt{cos}, \ttt{tan}, \ttt{asin}, \ttt{acos}, \ttt{atan}) %%%%% \item \ttt{sinh} \newline Numerical function \ttt{sinh ({\em })} that calculates the hyperbolic sine function of real and complex numerical numbers or variables. Note that its inverse function is part of the \ttt{Fortran2008} status and hence not realized. (cf. also \ttt{cosh}, \ttt{tanh}) %%%%% \item \ttt{sort} \newline Subevent function that allows to sort a particle list/subevent either by increasing PDG code: \ttt{sort [{\em }]} (particles first, then antiparticles). Alternatively, it can sort according to a unary or binary particle observable (in that case there is a second particle list, where the first particle is taken as a reference): \ttt{sort by {\em } [{\em } [, {\em }]]}. (cf. also \ttt{extract}, \ttt{combine}, \ttt{collect}, \ttt{join}, \ttt{by}, \ttt{+}) %%%%% \item \ttt{sprintf} \newline Command that allows to print data into a string variable: \ttt{sprintf "{\em }"}. There exist format specifiers, very similar to the \ttt{C} command \ttt{sprintf}, e.g. \ttt{sprintf "\%i" (123)}. (cf. \ttt{printf}, \ttt{\%d}, \ttt{\%i}, \ttt{\%e}, \ttt{\%f}, \ttt{\%g}, \ttt{\%E}, \ttt{\%F}, \ttt{\%G}, \ttt{\%s}) %%%%% \item \ttt{sqrt} \newline Numerical function \ttt{sqrt ({\em })} that calculates the square root of real and complex numerical numbers or variables. (cf. also \ttt{exp}, \ttt{log}, \ttt{log10}) %%%%% \item \ttt{sqrts\_hat} \newline Real variable that accesses the partonic energy of a hard-scattering process. It can be used in cuts or in an analysis, e.g. \ttt{cuts = sqrts\_hat > {\em } [ {\em } ]}. The physical unit can be one of the following \ttt{eV}, \ttt{keV}, \ttt{MeV}, \ttt{GeV}, and \ttt{TeV}. (cf. also \ttt{sqrts}, \ttt{cuts}, \ttt{record}) %%%%% \item \ttt{stable} \newline This constructor allows particles in the final states of processes in decay cascade set-up to be set as stable, and not letting them decay. The syntax is \ttt{stable {\em }} (cf. also \ttt{unstable}) %%%%% \item \ttt{stdhep} \newline Specifier for the \ttt{sample\_format} command to demand the generation of binary StdHEP event files based on the HEPEVT common block. (cf. also \ttt{\$sample}, \ttt{sample\_format}) %%%%% \item \ttt{stdhep\_up} \newline Specifier for the \ttt{sample\_format} command to demand the generation of binary StdHEP event files based on the HEPRUP/HEPEUP common blocks. (cf. also \ttt{\$sample}, \ttt{sample\_format}) %%%%% \item \ttt{tan} \newline Numerical function \ttt{tan ({\em })} that calculates the tangent trigonometric function of real and complex numerical numbers or variables. (cf. also \ttt{sin}, \ttt{cos}, \ttt{asin}, \ttt{acos}, \ttt{atan}) %%%%% \item \ttt{tanh} \newline Numerical function \ttt{tanh ({\em })} that calculates the hyperbolic tangent function of real and complex numerical numbers or variables. Note that its inverse function is part of the \ttt{Fortran2008} status and hence not realized. (cf. also \ttt{cosh}, \ttt{sinh}) %%%%% \item \ttt{TeV} \newline Physical unit, for energies in $10^{12}$ electron volt. (cf. also \ttt{eV}, \ttt{keV}, \ttt{MeV}, \ttt{meV}, \ttt{GeV}) %%%% \item \ttt{then} \newline Mandatory phrase in a conditional clause: \ttt{if {\em } then {\em } \ldots endif}. (cf. also \ttt{if}, \ttt{else}, \ttt{elsif}, \ttt{endif}). %%%%% \item \ttt{Theta} \newline Unary and also binary observable specifier, that as a unary observable gives the angle between a particle's momentum and the beam axis ($+z$ direction). As a binary observable, it gives the angle enclosed between the momenta of the two particles: \ttt{eval Theta [e1]}, \ttt{all Theta > 30 degrees [jet, jet]}. (cf. also \ttt{eval}, \ttt{cuts}, \ttt{selection}, \ttt{Phi}, \ttt{Theta\_star}) %%%%% \item \ttt{Theta\_star} \newline Binary observable specifier, that gives the polar angle enclosed between the momenta of the two particles in the rest frame of the mother particle (momentum sum of the two particle): \ttt{eval Theta\_star [jet, jet]}. (cf. also \ttt{eval}, \ttt{cuts}, \ttt{selection}, \ttt{Theta}) %%%%% \item \ttt{true} \newline Constructor stating that a logical expression or variable is true, e.g. \ttt{?{\em } = true}. (cf. also \ttt{false}). %%%%% \item \ttt{unpolarized} \newline Constructor to force \whizard\ to discard polarization of the corresponding particles in the generated events: \ttt{unpolarized {\em } [, {\em } , ...]}. (cf. also \ttt{polarized}, \ttt{simulate}, \ttt{?polarized\_events}) %%%%% \item \ttt{unstable} \newline This constructor allows to let final state particles of the hard interaction undergo a subsequent (cascade) decay (in the on-shell approximation). For this the user has to define the list of desired \begin{figure} \begin{Verbatim}[frame=single] process zee = Z => e1, E1 process zuu = Z => u, U process zz = e1, E1 => Z, Z compile integrate (zee) { iterations = 1:100 } integrate (zuu) { iterations = 1:100 } sqrts = 500 GeV integrate (zz) { iterations = 3:5000, 2:5000 } unstable Z (zee, zuu) \end{Verbatim} \caption{\label{fig:ex_unstable} \sindarin\ input file for unstable particles and inclusive decays.} \end{figure} decay channels as \ttt{unstable {\em } ({\em }, {\em }, ....)}, where \ttt{mother} is the mother particle, and the argument is a list of decay channels. Note that -- unless the \ttt{?auto\_decays = true} flag has been set -- these decay channels have to be provided by the user as in the example in Fig. \ref{fig:ex_unstable}. First, the $Z$ decays to electrons and up quarks are generated, then $ZZ$ production at a 500 GeV ILC is called, and then both $Z$s are decayed according to the probability distribution of the two generated decay matrix elements. This obviously allows also for inclusive decays. (cf. also \ttt{stable}, \ttt{?auto\_decays}) %%%%% \item \ttt{weight} \newline This is a command, \ttt{weight = {\em }}, that allows to specify a weight for a process or list of processes. \ttt{{\em }} can be any expression that leads to a scalar result, e.g. \ttt{weight = 0.2}, \ttt{weight = eval Pt [jet]}. (cf. also \ttt{rescan}, \ttt{alt\_setup}, \ttt{reweight}) %%%%% \item \ttt{write\_analysis} \newline The \ttt{write\_analysis} statement tells \whizard\ to write the analysis setup by the user for the \sindarin\ input file under consideration. If no \ttt{\$out\_file} is provided, the histogram tables/plot data etc. are written to the default file \ttt{whizard\_analysis.dat}. Note that the related command \ttt{compile\_analysis} does the same as \ttt{write\_analysis} but in addition invokes the \whizard\ \LaTeX routines for producing postscript or PDF output of the data. (cf. also \ttt{\$out\_file}, \ttt{compile\_analysis}) %%%%% \item \ttt{write\_slha} \newline Demands \whizard\ to write out a file in the SUSY Les Houches accord (SLHA) format. (cf. also \ttt{read\_slha}, \ttt{?slha\_read\_decays}, \ttt{?slha\_read\_input}, \ttt{?slha\_read\_spectrum}) %%%%% \end{itemize} \section{Variables} \subsection{Rebuild Variables} \begin{itemize} \item \ttt{?rebuild\_events} \qquad (default: \ttt{false}) \newline This logical variable, if set \ttt{true} triggers \whizard\ to newly create an event sample, even if nothing seems to have changed, including the MD5 checksum. This can be used when manually manipulating some settings. (cf also \ttt{?rebuild\_grids}, \ttt{?rebuild\_library}, \ttt{?rebuild\_phase\_space}) %%%%% \item \ttt{?rebuild\_grids} \qquad (default: \ttt{false}) \newline The logical variable \ttt{?rebuild\_grids} forces \whizard\ to newly create the VAMP grids when using VAMP as an integration method, even if they are already present. (cf. also \ttt{?rebuild\_events}, \ttt{?rebuild\_library}, \ttt{?rebuild\_phase\_space}) %%%%% \item \ttt{?rebuild\_library} \qquad (default: \ttt{false}) \newline The logical variable \ttt{?rebuild\_library = true/false} specifies whether the library(-ies) for the matrix element code for processes is re-generated (incl. possible Makefiles etc.) by the corresponding ME method (e.g. if the process has been changed, but not its name). This can also be set as a command-line option \ttt{whizard --rebuild}. The default is \ttt{false}, i.e. code is never re-generated if it is present and the MD5 checksum is valid. (cf. also \ttt{?recompile\_library}, \ttt{?rebuild\_grids}, \ttt{?rebuild\_phase\_space}) %%%%% \item \ttt{?rebuild\_phase\_space} \qquad (default: \ttt{false}) \newline This logical variable, if set \ttt{true}, triggers recreation of the phase space file by \whizard\. (cf. also \ttt{?rebuild\_events}, \ttt{?rebuild\_grids}, \ttt{?rebuild\_library}) %%%%% \item \ttt{?recompile\_library} \qquad (default: \ttt{false}) \newline The logical variable \ttt{?recompile\_library = true/false} specifies whether the library(-ies) for the matrix element code for processes is re-compiled (e.g. if the process code has been manually modified by the user). This can also be set as a command-line option \ttt{whizard --recompile}. The default is \ttt{false}, i.e. code is never re-compiled if its corresponding object file is present. (cf. also \ttt{?rebuild\_library}) %%%%% \end{itemize} \subsection{Standard Variables} \begin{itemize} \input{variables} \end{itemize} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \clearpage \section*{Acknowledgements} We would like to thank E.~Boos, R.~Chierici, K.~Desch, M.~Kobel, F.~Krauss, P.M.~Manakos, N.~Meyer, K.~M\"onig, H.~Reuter, T.~Robens, S.~Rosati, J.~Schumacher, M.~Schumacher, and C.~Schwinn who contributed to \whizard\ by their suggestions, bits of codes and valuable remarks and/or used several versions of the program for real-life applications and thus helped a lot in debugging and improving the code. Special thanks go to A.~Vaught and J.~Weill for their continuos efforts on improving the g95 and gfortran compilers, respectively. %\end{fmffile} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% References %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\baselineskip15pt \begin{thebibliography}{19} \bibitem{PYTHIA} T.~Sj\"ostrand, Comput.\ Phys.\ Commun.\ \textbf{82} (1994) 74. \bibitem{comphep} A.~Pukhov, \emph{et al.}, Preprint INP MSU 98-41/542, \ttt{hep-ph/9908288}. \bibitem{madgraph} T.~Stelzer and W.F.~Long, Comput.\ Phys.\ Commun.\ \textbf{81} (1994) 357. \bibitem{omega} T.~Ohl, \emph{Proceedings of the Seventh International Workshop on Advanced Computing and Analysis Technics in Physics Research}, ACAT 2000, Fermilab, October 2000, IKDA-2000-30, \ttt{hep-ph/0011243}; M.~Moretti, Th.~Ohl, and J.~Reuter, LC-TOOL-2001-040 \bibitem{VAMP} T.~Ohl, {\em Vegas revisited: Adaptive Monte Carlo integration beyond factorization}, Comput.\ Phys.\ Commun.\ {\bf 120}, 13 (1999) [arXiv:hep-ph/9806432]. %%CITATION = CPHCB,120,13;%% \bibitem{CIRCE} T.~Ohl, {\em CIRCE version 1.0: Beam spectra for simulating linear collider physics}, Comput.\ Phys.\ Commun.\ {\bf 101}, 269 (1997) [arXiv:hep-ph/9607454]. %%CITATION = CPHCB,101,269;%% %\cite{Gribov:1972rt} \bibitem{Gribov:1972rt} V.~N.~Gribov and L.~N.~Lipatov, {\em e+ e- pair annihilation and deep inelastic e p scattering in perturbation theory}, Sov.\ J.\ Nucl.\ Phys.\ {\bf 15}, 675 (1972) [Yad.\ Fiz.\ {\bf 15}, 1218 (1972)]. %%CITATION = SJNCA,15,675;%% %\cite{Kuraev:1985hb} \bibitem{Kuraev:1985hb} E.~A.~Kuraev and V.~S.~Fadin, {\em On Radiative Corrections to e+ e- Single Photon Annihilation at High-Energy}, Sov.\ J.\ Nucl.\ Phys.\ {\bf 41}, 466 (1985) [Yad.\ Fiz.\ {\bf 41}, 733 (1985)]. %%CITATION = SJNCA,41,466;%% %\cite{Skrzypek:1990qs} \bibitem{Skrzypek:1990qs} M.~Skrzypek and S.~Jadach, {\em Exact and approximate solutions for the electron nonsinglet structure function in QED}, Z.\ Phys.\ C {\bf 49}, 577 (1991). %%CITATION = ZEPYA,C49,577;%% %\cite{Schulte:1998au} \bibitem{Schulte:1998au} D.~Schulte, {\em Beam-beam simulations with Guinea-Pig}, eConf C {\bf 980914}, 127 (1998). %%CITATION = ECONF,C980914,127;%% %\cite{Schulte:1999tx} \bibitem{Schulte:1999tx} D.~Schulte, {\em Beam-beam simulations with GUINEA-PIG}, CERN-PS-99-014-LP. %%CITATION = CERN-PS-99-014-LP;%% %\cite{Schulte:2007zz} \bibitem{Schulte:2007zz} D.~Schulte, M.~Alabau, P.~Bambade, O.~Dadoun, G.~Le Meur, C.~Rimbault and F.~Touze, {\em GUINEA PIG++ : An Upgraded Version of the Linear Collider Beam Beam Interaction Simulation Code GUINEA PIG}, Conf.\ Proc.\ C {\bf 070625}, 2728 (2007). %%CITATION = CONFP,C070625,2728;%% %\cite{Behnke:2013xla} \bibitem{Behnke:2013xla} T.~Behnke, J.~E.~Brau, B.~Foster, J.~Fuster, M.~Harrison, J.~M.~Paterson, M.~Peskin and M.~Stanitzki {\it et al.}, {\em The International Linear Collider Technical Design Report - Volume 1: Executive Summary}, arXiv:1306.6327 [physics.acc-ph]. %%CITATION = ARXIV:1306.6327;%% %\cite{Baer:2013cma} \bibitem{Baer:2013cma} H.~Baer, T.~Barklow, K.~Fujii, Y.~Gao, A.~Hoang, S.~Kanemura, J.~List and H.~E.~Logan {\it et al.}, {\em The International Linear Collider Technical Design Report - Volume 2: Physics}, arXiv:1306.6352 [hep-ph]. %%CITATION = ARXIV:1306.6352;%% %\cite{Adolphsen:2013jya} \bibitem{Adolphsen:2013jya} C.~Adolphsen, M.~Barone, B.~Barish, K.~Buesser, P.~Burrows, J.~Carwardine, J.~Clark and H\'{e}l\`{e}n.~M.~Durand {\it et al.}, {\em The International Linear Collider Technical Design Report - Volume 3.I: Accelerator \& in the Technical Design Phase}, arXiv:1306.6353 [physics.acc-ph]. %%CITATION = ARXIV:1306.6353;%% %\cite{Adolphsen:2013kya} \bibitem{Adolphsen:2013kya} C.~Adolphsen, M.~Barone, B.~Barish, K.~Buesser, P.~Burrows, J.~Carwardine, J.~Clark and H\'{e}l\`{e}n.~M.~Durand {\it et al.}, {\em The International Linear Collider Technical Design Report - Volume 3.II: Accelerator Baseline Design}, arXiv:1306.6328 [physics.acc-ph]. %%CITATION = ARXIV:1306.6328;%% %\cite{Behnke:2013lya} \bibitem{Behnke:2013lya} T.~Behnke, J.~E.~Brau, P.~N.~Burrows, J.~Fuster, M.~Peskin, M.~Stanitzki, Y.~Sugimoto and S.~Yamada {\it et al.}, %``The International Linear Collider Technical Design Report - Volume 4: Detectors,'' arXiv:1306.6329 [physics.ins-det]. %%CITATION = ARXIV:1306.6329;%% %\cite{Aicheler:2012bya} \bibitem{Aicheler:2012bya} M.~Aicheler, P.~Burrows, M.~Draper, T.~Garvey, P.~Lebrun, K.~Peach and N.~Phinney {\it et al.}, {\em A Multi-TeV Linear Collider Based on CLIC Technology : CLIC Conceptual Design Report}, CERN-2012-007. %%CITATION = CERN-2012-007;%% %\cite{Lebrun:2012hj} \bibitem{Lebrun:2012hj} P.~Lebrun, L.~Linssen, A.~Lucaci-Timoce, D.~Schulte, F.~Simon, S.~Stapnes, N.~Toge and H.~Weerts {\it et al.}, {\em The CLIC Programme: Towards a Staged e+e- Linear Collider Exploring the Terascale : CLIC Conceptual Design Report}, arXiv:1209.2543 [physics.ins-det]. %%CITATION = ARXIV:1209.2543;%% %\cite{Linssen:2012hp} \bibitem{Linssen:2012hp} L.~Linssen, A.~Miyamoto, M.~Stanitzki and H.~Weerts, {\em Physics and Detectors at CLIC: CLIC Conceptual Design Report}, arXiv:1202.5940 [physics.ins-det]. %%CITATION = ARXIV:1202.5940;%% %\cite{vonWeizsacker:1934sx} \bibitem{vonWeizsacker:1934sx} C.~F.~von Weizs\"acker, {\em Radiation emitted in collisions of very fast electrons}, Z.\ Phys.\ {\bf 88}, 612 (1934). %%CITATION = ZEPYA,88,612;%% %\cite{Williams:1934ad} \bibitem{Williams:1934ad} E.~J.~Williams, {\em Nature of the high-energy particles of penetrating radiation and status of ionization and radiation formulae}, Phys.\ Rev.\ {\bf 45}, 729 (1934). %%CITATION = PHRVA,45,729;%% %\cite{Budnev:1974de} \bibitem{Budnev:1974de} V.~M.~Budnev, I.~F.~Ginzburg, G.~V.~Meledin and V.~G.~Serbo, {\em The Two photon particle production mechanism. Physical problems. Applications. Equivalent photon approximation}, Phys.\ Rept.\ {\bf 15} (1974) 181. %%CITATION = PRPLC,15,181;%% %\cite{Ginzburg:1981vm} \bibitem{Ginzburg:1981vm} I.~F.~Ginzburg, G.~L.~Kotkin, V.~G.~Serbo and V.~I.~Telnov, {\em Colliding gamma e and gamma gamma Beams Based on the Single Pass Accelerators (of Vlepp Type)}, Nucl.\ Instrum.\ Meth.\ {\bf 205}, 47 (1983). %%CITATION = NUIMA,205,47;%% %\cite{Telnov:1989sd} \bibitem{Telnov:1989sd} V.~I.~Telnov, {\em Problems of Obtaining $\gamma \gamma$ and $\gamma \epsilon$ Colliding Beams at Linear Colliders}, Nucl.\ Instrum.\ Meth.\ A {\bf 294}, 72 (1990). %%CITATION = NUIMA,A294,72;%% %\cite{Telnov:1995hc} \bibitem{Telnov:1995hc} V.~I.~Telnov, {\em Principles of photon colliders}, Nucl.\ Instrum.\ Meth.\ A {\bf 355}, 3 (1995). %%CITATION = NUIMA,A355,3;%% %\cite{AguilarSaavedra:2001rg} \bibitem{AguilarSaavedra:2001rg} J.~A.~Aguilar-Saavedra {\it et al.} [ECFA/DESY LC Physics Working Group Collaboration], {\em TESLA: The Superconducting electron positron linear collider with an integrated x-ray laser laboratory. Technical design report. Part 3. Physics at an e+ e- linear collider}, hep-ph/0106315. %%CITATION = HEP-PH/0106315;%% %\cite{Richard:2001qm} \bibitem{Richard:2001qm} F.~Richard, J.~R.~Schneider, D.~Trines and A.~Wagner, {\em TESLA, The Superconducting Electron Positron Linear Collider with an Integrated X-ray Laser Laboratory, Technical Design Report Part 1 : Executive Summary}, hep-ph/0106314. %%CITATION = HEP-PH/0106314;%% %\cite{Sudakov:1954sw} \bibitem{Sudakov:1954sw} V.~V.~Sudakov, %``Vertex parts at very high-energies in quantum electrodynamics,'' Sov.\ Phys.\ JETP {\bf 3}, 65 (1956) [Zh.\ Eksp.\ Teor.\ Fiz.\ {\bf 30}, 87 (1956)]. %%CITATION = SPHJA,3,65;%% \cite{Sjostrand:1985xi} \bibitem{Sjostrand:1985xi} T.~Sjostrand, %``A Model for Initial State Parton Showers,'' Phys.\ Lett.\ {\bf 157B}, 321 (1985). doi:10.1016/0370-2693(85)90674-4 %%CITATION = doi:10.1016/0370-2693(85)90674-4;%% %\cite{Sjostrand:2006za} \bibitem{Sjostrand:2006za} T.~Sjostrand, S.~Mrenna and P.~Z.~Skands, %``PYTHIA 6.4 Physics and Manual,'' JHEP {\bf 0605}, 026 (2006) doi:10.1088/1126-6708/2006/05/026 [hep-ph/0603175]. %%CITATION = doi:10.1088/1126-6708/2006/05/026;%% %\cite{Ohl:1998jn} \bibitem{Ohl:1998jn} T.~Ohl, {\em Vegas revisited: Adaptive Monte Carlo integration beyond factorization}, Comput.\ Phys.\ Commun.\ {\bf 120}, 13 (1999) [hep-ph/9806432]. %%CITATION = HEP-PH/9806432;%% %\cite{Lepage:1980dq} \bibitem{Lepage:1980dq} G.~P.~Lepage, %``Vegas: An Adaptive Multidimensional Integration Program,'' CLNS-80/447. %%CITATION = CLNS-80/447;%% \bibitem{HDECAY} A.~Djouadi, J.~Kalinowski, M.~Spira, Comput.\ Phys.\ Commun.\ \textbf{108} (1998) 56-74. %\cite{Beyer:2006hx} \bibitem{Beyer:2006hx} M.~Beyer, W.~Kilian, P.~Krstono\v{s}ic, K.~M\"onig, J.~Reuter, E.~Schmidt and H.~Schr\"oder, {\em Determination of New Electroweak Parameters at the ILC - Sensitivity to New Physics}, Eur.\ Phys.\ J.\ C {\bf 48}, 353 (2006) [hep-ph/0604048]. %%CITATION = HEP-PH/0604048;%% %\cite{Alboteanu:2008my} \bibitem{Alboteanu:2008my} A.~Alboteanu, W.~Kilian and J.~Reuter, {\em Resonances and Unitarity in Weak Boson Scattering at the LHC}, JHEP {\bf 0811}, 010 (2008) [arXiv:0806.4145 [hep-ph]]. %%CITATION = ARXIV:0806.4145;%% %\cite{Binoth:2010xt} \bibitem{Binoth:2010xt} T.~Binoth {\it et al.}, %``A Proposal for a standard interface between Monte Carlo tools and one-loop programs,'' Comput.\ Phys.\ Commun.\ {\bf 181}, 1612 (2010) doi:10.1016/j.cpc.2010.05.016 [arXiv:1001.1307 [hep-ph]]. %%CITATION = doi:10.1016/j.cpc.2010.05.016;%% %\cite{Alioli:2013nda} \bibitem{Alioli:2013nda} S.~Alioli {\it et al.}, %``Update of the Binoth Les Houches Accord for a standard interface %between Monte Carlo tools and one-loop programs,'' Comput.\ Phys.\ Commun.\ {\bf 185}, 560 (2014) doi:10.1016/j.cpc.2013.10.020 [arXiv:1308.3462 [hep-ph]]. %%CITATION = doi:10.1016/j.cpc.2013.10.020;%% %\cite{Speckner:2010zi} \bibitem{Speckner:2010zi} C.~Speckner, {\em LHC Phenomenology of the Three-Site Higgsless Model}, PhD thesis, arXiv:1011.1851 [hep-ph]. %%CITATION = ARXIV:1011.1851;%% %\cite{Chivukula:2006cg} \bibitem{Chivukula:2006cg} R.~S.~Chivukula, B.~Coleppa, S.~Di Chiara, E.~H.~Simmons, H.~-J.~He, M.~Kurachi and M.~Tanabashi, {\em A Three Site Higgsless Model}, Phys.\ Rev.\ D {\bf 74}, 075011 (2006) [hep-ph/0607124]. %%CITATION = HEP-PH/0607124;%% %\cite{Chivukula:2005xm} \bibitem{Chivukula:2005xm} R.~S.~Chivukula, E.~H.~Simmons, H.~-J.~He, M.~Kurachi and M.~Tanabashi, {\em Ideal fermion delocalization in Higgsless models}, Phys.\ Rev.\ D {\bf 72}, 015008 (2005) [hep-ph/0504114]. %%CITATION = HEP-PH/0504114;%% %\cite{Ohl:2008ri} \bibitem{Ohl:2008ri} T.~Ohl and C.~Speckner, {\em Production of Almost Fermiophobic Gauge Bosons in the Minimal Higgsless Model at the LHC}, Phys.\ Rev.\ D {\bf 78}, 095008 (2008) [arXiv:0809.0023 [hep-ph]]. %%CITATION = ARXIV:0809.0023;%% %\cite{Ohl:2002jp} \bibitem{Ohl:2002jp} T.~Ohl and J.~Reuter, {\em Clockwork SUSY: Supersymmetric Ward and Slavnov-Taylor identities at work in Green's functions and scattering amplitudes}, Eur.\ Phys.\ J.\ C {\bf 30}, 525 (2003) [hep-th/0212224]. %%CITATION = HEP-TH/0212224;%% %\cite{Reuter:2009ex} \bibitem{Reuter:2009ex} J.~Reuter and F.~Braam, {\em The NMSSM implementation in WHIZARD}, AIP Conf.\ Proc.\ {\bf 1200}, 470 (2010) [arXiv:0909.3059 [hep-ph]]. %%CITATION = ARXIV:0909.3059;%% %\cite{Kalinowski:2008fk} \bibitem{Kalinowski:2008fk} J.~Kalinowski, W.~Kilian, J.~Reuter, T.~Robens and K.~Rolbiecki, {\em Pinning down the Invisible Sneutrino}, JHEP {\bf 0810}, 090 (2008) [arXiv:0809.3997 [hep-ph]]. %%CITATION = ARXIV:0809.3997;%% %\cite{Robens:2008sa} \bibitem{Robens:2008sa} T.~Robens, J.~Kalinowski, K.~Rolbiecki, W.~Kilian and J.~Reuter, {\em (N)LO Simulation of Chargino Production and Decay}, Acta Phys.\ Polon.\ B {\bf 39}, 1705 (2008) [arXiv:0803.4161 [hep-ph]]. %%CITATION = ARXIV:0803.4161;%% %\cite{Kilian:2004pp} \bibitem{Kilian:2004pp} W.~Kilian, D.~Rainwater and J.~Reuter, {\em Pseudo-axions in little Higgs models}, Phys.\ Rev.\ D {\bf 71}, 015008 (2005) [hep-ph/0411213]. %%CITATION = HEP-PH/0411213;%% %\cite{Kilian:2006eh} \bibitem{Kilian:2006eh} W.~Kilian, D.~Rainwater and J.~Reuter, {\em Distinguishing little-Higgs product and simple group models at the LHC and ILC}, Phys.\ Rev.\ D {\bf 74}, 095003 (2006) [Erratum-ibid.\ D {\bf 74}, 099905 (2006)] [hep-ph/0609119]. %%CITATION = HEP-PH/0609119;%% %\cite{Ohl:2004tn} \bibitem{Ohl:2004tn} T.~Ohl and J.~Reuter, {\em Testing the noncommutative standard model at a future photon collider}, Phys.\ Rev.\ D {\bf 70}, 076007 (2004) [hep-ph/0406098]. %%CITATION = HEP-PH/0406098;%% %\cite{Ohl:2010zf} \bibitem{Ohl:2010zf} T.~Ohl and C.~Speckner, {\em The Noncommutative Standard Model and Polarization in Charged Gauge Boson Production at the LHC}, Phys.\ Rev.\ D {\bf 82}, 116011 (2010) [arXiv:1008.4710 [hep-ph]]. %%CITATION = ARXIV:1008.4710;%% \bibitem{LesHouches} E.~Boos {\it et al.}, {\em Generic user process interface for event generators}, arXiv:hep-ph/0109068. %%CITATION = HEP-PH/0109068;%% \bibitem{Skands:2003cj} P.~Z.~Skands {\it et al.}, {\em SUSY Les Houches Accord: Interfacing SUSY Spectrum Calculators, Decay Packages, and Event Generators}, JHEP {\bf 0407}, 036 (2004) [arXiv:hep-ph/0311123]. %%CITATION = JHEPA,0407,036;%% %\cite{AguilarSaavedra:2005pw} \bibitem{AguilarSaavedra:2005pw} J.~A.~Aguilar-Saavedra, A.~Ali, B.~C.~Allanach, R.~L.~Arnowitt, H.~A.~Baer, J.~A.~Bagger, C.~Balazs and V.~D.~Barger {\it et al.}, {\em Supersymmetry parameter analysis: SPA convention and project}, Eur.\ Phys.\ J.\ C {\bf 46}, 43 (2006) [hep-ph/0511344]. %%CITATION = HEP-PH/0511344;%% %\cite{Allanach:2008qq} \bibitem{Allanach:2008qq} B.~C.~Allanach, C.~Balazs, G.~Belanger, M.~Bernhardt, F.~Boudjema, D.~Choudhury, K.~Desch and U.~Ellwanger {\it et al.}, %``SUSY Les Houches Accord 2,'' Comput.\ Phys.\ Commun.\ {\bf 180}, 8 (2009) [arXiv:0801.0045 [hep-ph]]. %%CITATION = ARXIV:0801.0045;%% \bibitem{LHEF} J.~Alwall {\it et al.}, {\em A standard format for Les Houches event files}, Comput.\ Phys.\ Commun.\ {\bf 176}, 300 (2007) [arXiv:hep-ph/0609017]. %%CITATION = CPHCB,176,300;%% \bibitem{Hagiwara:2005wg} K.~Hagiwara {\it et al.}, {\em Supersymmetry simulations with off-shell effects for LHC and ILC}, Phys.\ Rev.\ D {\bf 73}, 055005 (2006) [arXiv:hep-ph/0512260]. %%CITATION = PHRVA,D73,055005;%% \bibitem{Allanach:2002nj} B.~C.~Allanach {\it et al.}, {\em The Snowmass points and slopes: Benchmarks for SUSY searches}, in {\it Proc. of the APS/DPF/DPB Summer Study on the Future of Particle Physics (Snowmass 2001) } ed. N.~Graf, Eur.\ Phys.\ J.\ C {\bf 25} (2002) 113 [eConf {\bf C010630} (2001) P125] [arXiv:hep-ph/0202233]. %%CITATION = HEP-PH 0202233;%% \bibitem{PeskinSchroeder} M.E. Peskin, D.V.Schroeder, {\em An Introduction to Quantum Field Theory}, Addison-Wesley Publishing Co., 1995. \bibitem{stdhep} L.~Garren, {\em StdHep, Monte Carlo Standardization at FNAL}, Fermilab CS-doc-903, \url{http://cd-docdb.fnal.gov/cgi-bin/ShowDocument?docid=903} %\cite{Frixione:1998jh} \bibitem{Frixione:1998jh} S.~Frixione, %``Isolated photons in perturbative QCD,'' Phys.\ Lett.\ B {\bf 429}, 369 (1998) doi:10.1016/S0370-2693(98)00454-7 [hep-ph/9801442]. %%CITATION = doi:10.1016/S0370-2693(98)00454-7;%% \bibitem{LHAPDF} W.~Giele {\it et al.}, {\em The QCD / SM working group: Summary report}, arXiv:hep-ph/0204316; %%CITATION = HEP-PH/0204316;%% M.~R.~Whalley, D.~Bourilkov and R.~C.~Group, {\em The Les Houches Accord PDFs (LHAPDF) and Lhaglue}, arXiv:hep-ph/0508110; %%CITATION = HEP-PH/0508110;%% D.~Bourilkov, R.~C.~Group and M.~R.~Whalley, {\em LHAPDF: PDF use from the Tevatron to the LHC}, arXiv:hep-ph/0605240. %%CITATION = HEP-PH/0605240;%% \bibitem{HepMC} M.~Dobbs and J.~B.~Hansen, {\em The HepMC C++ Monte Carlo event record for High Energy Physics}, Comput.\ Phys.\ Commun.\ {\bf 134}, 41 (2001). %%CITATION = CPHCB,134,41;%% %\cite{Boos:2004kh} \bibitem{Boos:2004kh} E.~Boos {\it et al.} [CompHEP Collaboration], %``CompHEP 4.4: Automatic computations from Lagrangians to events,'' Nucl.\ Instrum.\ Meth.\ A {\bf 534}, 250 (2004) [hep-ph/0403113]. %%CITATION = HEP-PH/0403113;%% %493 citations counted in INSPIRE as of 12 May 2014 % Parton distributions %\cite{Pumplin:2002vw} \bibitem{Pumplin:2002vw} J.~Pumplin, D.~R.~Stump, J.~Huston {\it et al.}, {\em New generation of parton distributions with uncertainties from global QCD analysis}, JHEP {\bf 0207}, 012 (2002). [hep-ph/0201195]. %\cite{Martin:2004dh} \bibitem{Martin:2004dh} A.~D.~Martin, R.~G.~Roberts, W.~J.~Stirling {\it et al.}, {\em Parton distributions incorporating QED contributions}, Eur.\ Phys.\ J.\ {\bf C39}, 155-161 (2005). [hep-ph/0411040]. %\cite{Martin:2009iq} \bibitem{Martin:2009iq} A.~D.~Martin, W.~J.~Stirling, R.~S.~Thorne {\it et al.}, {\em Parton distributions for the LHC}, Eur.\ Phys.\ J.\ {\bf C63}, 189-285 (2009). [arXiv:0901.0002 [hep-ph]]. %\cite{Lai:2010vv} \bibitem{Lai:2010vv} H.~L.~Lai, M.~Guzzi, J.~Huston, Z.~Li, P.~M.~Nadolsky, J.~Pumplin and C.~P.~Yuan, {\em New parton distributions for collider physics}, Phys.\ Rev.\ D {\bf 82}, 074024 (2010) [arXiv:1007.2241 [hep-ph]]. %%CITATION = PHRVA,D82,074024;%% %\cite{Owens:2012bv} \bibitem{Owens:2012bv} J.~F.~Owens, A.~Accardi and W.~Melnitchouk, {\em Global parton distributions with nuclear and finite-$Q^2$ corrections}, Phys.\ Rev.\ D {\bf 87}, no. 9, 094012 (2013) [arXiv:1212.1702 [hep-ph]]. %%CITATION = ARXIV:1212.1702;%% %\cite{Accardi:2016qay} \bibitem{Accardi:2016qay} A.~Accardi, L.~T.~Brady, W.~Melnitchouk, J.~F.~Owens and N.~Sato, %``Constraints on large-$x$ parton distributions from new weak boson production and deep-inelastic scattering data,'' arXiv:1602.03154 [hep-ph]. %%CITATION = ARXIV:1602.03154;%% %\cite{Harland-Lang:2014zoa} \bibitem{Harland-Lang:2014zoa} L.~A.~Harland-Lang, A.~D.~Martin, P.~Motylinski and R.~S.~Thorne, %``Parton distributions in the LHC era: MMHT 2014 PDFs,'' arXiv:1412.3989 [hep-ph]. %%CITATION = ARXIV:1412.3989;%% %\cite{Dulat:2015mca} \bibitem{Dulat:2015mca} S.~Dulat {\it et al.}, %``The CT14 Global Analysis of Quantum Chromodynamics,'' arXiv:1506.07443 [hep-ph]. %%CITATION = ARXIV:1506.07443;%% %\cite{Salam:2008qg} \bibitem{Salam:2008qg} G.~P.~Salam and J.~Rojo, {\em A Higher Order Perturbative Parton Evolution Toolkit (HOPPET)}, Comput.\ Phys.\ Commun.\ {\bf 180}, 120 (2009) [arXiv:0804.3755 [hep-ph]]. %%CITATION = ARXIV:0804.3755;%% %\cite{Kilian:2011ka} \bibitem{Kilian:2011ka} W.~Kilian, J.~Reuter, S.~Schmidt and D.~Wiesler, {\em An Analytic Initial-State Parton Shower}, JHEP {\bf 1204} (2012) 013 [arXiv:1112.1039 [hep-ph]]. %%CITATION = ARXIV:1112.1039;%% %\cite{Staub:2008uz} \bibitem{Staub:2008uz} F.~Staub, {\em Sarah}, arXiv:0806.0538 [hep-ph]. %%CITATION = ARXIV:0806.0538;%% %\cite{Staub:2009bi} \bibitem{Staub:2009bi} F.~Staub, {\em From Superpotential to Model Files for FeynArts and CalcHep/CompHep}, Comput.\ Phys.\ Commun.\ {\bf 181}, 1077 (2010) [arXiv:0909.2863 [hep-ph]]. %%CITATION = ARXIV:0909.2863;%% %\cite{Staub:2010jh} \bibitem{Staub:2010jh} F.~Staub, {\em Automatic Calculation of supersymmetric Renormalization Group Equations and Self Energies}, Comput.\ Phys.\ Commun.\ {\bf 182}, 808 (2011) [arXiv:1002.0840 [hep-ph]]. %%CITATION = ARXIV:1002.0840;%% %\cite{Staub:2012pb} \bibitem{Staub:2012pb} F.~Staub, {\em SARAH 3.2: Dirac Gauginos, UFO output, and more}, Computer Physics Communications {\bf 184}, pp. 1792 (2013) [Comput.\ Phys.\ Commun.\ {\bf 184}, 1792 (2013)] [arXiv:1207.0906 [hep-ph]]. %%CITATION = ARXIV:1207.0906;%% %\cite{Staub:2013tta} \bibitem{Staub:2013tta} F.~Staub, {\em SARAH 4: A tool for (not only SUSY) model builders}, Comput.\ Phys.\ Commun.\ {\bf 185}, 1773 (2014) [arXiv:1309.7223 [hep-ph]]. %%CITATION = ARXIV:1309.7223;%% \bibitem{mathematica} \Mathematica\ is a registered trademark of Wolfram Research, Inc., Champain, IL, USA. %\cite{Porod:2003um} \bibitem{Porod:2003um} W.~Porod, {\em SPheno, a program for calculating supersymmetric spectra, SUSY particle decays and SUSY particle production at e+ e- colliders}, Comput.\ Phys.\ Commun.\ {\bf 153}, 275 (2003) [hep-ph/0301101]. %%CITATION = HEP-PH/0301101;%% %\cite{Porod:2011nf} \bibitem{Porod:2011nf} W.~Porod and F.~Staub, {\em SPheno 3.1: Extensions including flavour, CP-phases and models beyond the MSSM}, Comput.\ Phys.\ Commun.\ {\bf 183}, 2458 (2012) [arXiv:1104.1573 [hep-ph]]. %%CITATION = ARXIV:1104.1573;%% %\cite{Staub:2011dp} \bibitem{Staub:2011dp} F.~Staub, T.~Ohl, W.~Porod and C.~Speckner, %``A Tool Box for Implementing Supersymmetric Models,'' Comput.\ Phys.\ Commun.\ {\bf 183}, 2165 (2012) [arXiv:1109.5147 [hep-ph]]. %%CITATION = ARXIV:1109.5147;%% %%%%% FeynRules %%%%% %\cite{Christensen:2008py} \bibitem{Christensen:2008py} N.~D.~Christensen and C.~Duhr, {\em FeynRules - Feynman rules made easy}, Comput.\ Phys.\ Commun.\ {\bf 180}, 1614 (2009) [arXiv:0806.4194 [hep-ph]]. %%CITATION = ARXIV:0806.4194;%% %\cite{Christensen:2009jx} \bibitem{Christensen:2009jx} N.~D.~Christensen, P.~de Aquino, C.~Degrande, C.~Duhr, B.~Fuks, M.~Herquet, F.~Maltoni and S.~Schumann, {\em A Comprehensive approach to new physics simulations}, Eur.\ Phys.\ J.\ C {\bf 71}, 1541 (2011) [arXiv:0906.2474 [hep-ph]]. %%CITATION = ARXIV:0906.2474;%% %\cite{Duhr:2011se} \bibitem{Duhr:2011se} C.~Duhr and B.~Fuks, %``A superspace module for the FeynRules package,'' Comput.\ Phys.\ Commun.\ {\bf 182}, 2404 (2011) [arXiv:1102.4191 [hep-ph]]. %%CITATION = ARXIV:1102.4191;%% %\cite{Christensen:2010wz} \bibitem{Christensen:2010wz} N.~D.~Christensen, C.~Duhr, B.~Fuks, J.~Reuter and C.~Speckner, {\em Introducing an interface between WHIZARD and FeynRules}, Eur.\ Phys.\ J.\ C {\bf 72}, 1990 (2012) [arXiv:1010.3251 [hep-ph]]. %%CITATION = ARXIV:1010.3251;%% %\cite{Degrande:2011ua} \bibitem{Degrande:2011ua} C.~Degrande, C.~Duhr, B.~Fuks, D.~Grellscheid, O.~Mattelaer and T.~Reiter, %``UFO - The Universal FeynRules Output,'' Comput.\ Phys.\ Commun.\ {\bf 183}, 1201 (2012) doi:10.1016/j.cpc.2012.01.022 [arXiv:1108.2040 [hep-ph]]. %%CITATION = doi:10.1016/j.cpc.2012.01.022;%% %\cite{Han:1998sg} \bibitem{Han:1998sg} T.~Han, J.~D.~Lykken and R.~-J.~Zhang, {\em On Kaluza-Klein states from large extra dimensions}, Phys.\ Rev.\ D {\bf 59}, 105006 (1999) [hep-ph/9811350]. %%CITATION = HEP-PH/9811350;%% %\cite{Fuks:2012im} \bibitem{Fuks:2012im} B.~Fuks, {\em Beyond the Minimal Supersymmetric Standard Model: from theory to phenomenology}, Int.\ J.\ Mod.\ Phys.\ A {\bf 27}, 1230007 (2012) [arXiv:1202.4769 [hep-ph]]. %%CITATION = ARXIV:1202.4769;%% %\cite{He:2007ge} \bibitem{He:2007ge} H.~-J.~He, Y.~-P.~Kuang, Y.~-H.~Qi, B.~Zhang, A.~Belyaev, R.~S.~Chivukula, N.~D.~Christensen and A.~Pukhov {\it et al.}, {\em CERN LHC Signatures of New Gauge Bosons in Minimal Higgsless Model}, Phys.\ Rev.\ D {\bf 78}, 031701 (2008) [arXiv:0708.2588 [hep-ph]]. %%CITATION = ARXIV:0708.2588;%% %%%%% WHIZARD NLO %%%%% %\cite{Kilian:2006cj} \bibitem{Kilian:2006cj} W.~Kilian, J.~Reuter and T.~Robens, {\em NLO Event Generation for Chargino Production at the ILC}, Eur.\ Phys.\ J.\ C {\bf 48}, 389 (2006) [hep-ph/0607127]. %%CITATION = HEP-PH/0607127;%% %\cite{Binoth:2010ra} \bibitem{Binoth:2010ra} J.~R.~Andersen {\it et al.} [SM and NLO Multileg Working Group Collaboration], {\em Les Houches 2009: The SM and NLO Multileg Working Group: Summary report}, arXiv:1003.1241 [hep-ph]. %%CITATION = ARXIV:1003.1241;%% %\cite{Butterworth:2010ym} \bibitem{Butterworth:2010ym} J.~M.~Butterworth, A.~Arbey, L.~Basso, S.~Belov, A.~Bharucha, F.~Braam, A.~Buckley and M.~Campanelli {\it et al.}, {\em Les Houches 2009: The Tools and Monte Carlo working group Summary Report}, arXiv:1003.1643 [hep-ph], arXiv:1003.1643 [hep-ph]. %%CITATION = ARXIV:1003.1643;%% %\cite{Binoth:2009rv} \bibitem{Binoth:2009rv} T.~Binoth, N.~Greiner, A.~Guffanti, J.~Reuter, J.-P.~.Guillet and T.~Reiter, {\em Next-to-leading order QCD corrections to pp --> b anti-b b anti-b + X at the LHC: the quark induced case}, Phys.\ Lett.\ B {\bf 685}, 293 (2010) [arXiv:0910.4379 [hep-ph]]. %%CITATION = ARXIV:0910.4379;%% %\cite{Greiner:2011mp} \bibitem{Greiner:2011mp} N.~Greiner, A.~Guffanti, T.~Reiter and J.~Reuter, {\em NLO QCD corrections to the production of two bottom-antibottom pairs at the LHC} Phys.\ Rev.\ Lett.\ {\bf 107}, 102002 (2011) [arXiv:1105.3624 [hep-ph]]. %% CITATION = ARXIV:1105.3624;%% %\cite{L_Ecuyer:2002} \bibitem{L_Ecuyer:2002} P.~L\'{e}Ecuyer, R.~Simard, E.~J.~Chen, and W.~D.~Kelton, {\em An Object-Oriented Random-Number Package with Many Long Streams and Substreams}, Operations Research, vol. 50, no. 6, pp. 1073-1075, Dec. 2002. %\cite{Platzer:2013esa} \bibitem{Platzer:2013esa} S.~Pl\"atzer, {\em RAMBO on diet}, [arXiv:1308.2922 [hep-ph]]. %% CITATION = ARXIV:1308.2922;%% %\cite{Kleiss:1991rn} \bibitem{Kleiss:1991rn} R.~Kleiss and W.~J.~Stirling, {\em Massive multiplicities and Monte Carlo}, Nucl.\ Phys.\ B {\bf 385}, 413 (1992). doi:10.1016/0550-3213(92)90107-M %%CITATION = doi:10.1016/0550-3213(92)90107-M;%% %\cite{Kleiss:1985gy} \bibitem{Kleiss:1985gy} R.~Kleiss, W.~J.~Stirling and S.~D.~Ellis, {\em A New Monte Carlo Treatment of Multiparticle Phase Space at High-energies}, Comput.\ Phys.\ Commun.\ {\bf 40} (1986) 359. doi:10.1016/0010-4655(86)90119-0 %% CITATION = doi:10.1016/0010-4655(86)90119-0;%% %\cite{Brun:1997pa} \bibitem{Brun:1997pa} R.~Brun and F.~Rademakers, {\em ROOT: An object oriented data analysis framework}, Nucl. Instrum. Meth. A \textbf{389}, 81-86 (1997) doi:10.1016/S0168-9002(97)00048-X %\cite{Buckley:2010ar} \bibitem{Buckley:2010ar} A.~Buckley, J.~Butterworth, L.~Lonnblad, D.~Grellscheid, H.~Hoeth, J.~Monk, H.~Schulz and F.~Siegert, {\em Rivet user manual}, Comput. Phys. Commun. \textbf{184}, 2803-2819 (2013) doi:10.1016/j.cpc.2013.05.021 [arXiv:1003.0694 [hep-ph]]. %\cite{Bierlich:2019rhm} \bibitem{Bierlich:2019rhm} C.~Bierlich, A.~Buckley, J.~Butterworth, C.~H.~Christensen, L.~Corpe, D.~Grellscheid, J.~F.~Grosse-Oetringhaus, C.~Gutschow, P.~Karczmarczyk, J.~Klein, L.~Lönnblad, C.~S.~Pollard, P.~Richardson, H.~Schulz and F.~Siegert, {\em Robust Independent Validation of Experiment and Theory: Rivet version 3}, SciPost Phys. \textbf{8}, 026 (2020) doi:10.21468/SciPostPhys.8.2.026 [arXiv:1912.05451 [hep-ph]]. %\cite{deFavereau:2013fsa} \bibitem{deFavereau:2013fsa} J.~de Favereau \textit{et al.} [DELPHES 3], {\em DELPHES 3, A modular framework for fast simulation of a generic collider experiment}, JHEP \textbf{02}, 057 (2014) doi:10.1007/JHEP02(2014)057 [arXiv:1307.6346 [hep-ex]] \end{thebibliography} \end{document} Index: trunk/share/doc/Makefile.am =================================================================== --- trunk/share/doc/Makefile.am (revision 8428) +++ trunk/share/doc/Makefile.am (revision 8429) @@ -1,303 +1,305 @@ ## Makefile.am -- Makefile for WHIZARD ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## ## The WHIZARD documented source is assembled from various directories ## defined outside the DISTRIBUTION environment as modern autotools ## versions complain otherwise w_srcdir = $(top_srcdir)/src -VPATH = $(srcdir):$(w_srcdir)/noweb-frame:$(w_srcdir)/utilities:$(w_srcdir)/testing:$(w_srcdir)/system:$(w_srcdir)/combinatorics:$(w_srcdir)/parsing:$(w_srcdir)/rng:$(w_srcdir)/expr_base:$(w_srcdir)/physics:$(w_srcdir)/qed_pdf:$(w_srcdir)/qft:$(w_srcdir)/types:$(w_srcdir)/matrix_elements:$(w_srcdir)/particles:$(w_srcdir)/beams:$(w_srcdir)/me_methods:$(w_srcdir)/events:$(w_srcdir)/phase_space:$(w_srcdir)/vegas:$(w_srcdir)/mci:$(w_srcdir)/fks:$(w_srcdir)/gosam:$(w_srcdir)/openloops:$(w_srcdir)/blha:$(w_srcdir)/shower:$(w_srcdir)/muli:$(w_srcdir)/variables:$(w_srcdir)/model_features:$(w_srcdir)/threshold:$(w_srcdir)/process_integration:$(w_srcdir)/matching:$(w_srcdir)/transforms:$(w_srcdir)/whizard-core +VPATH = $(srcdir):$(w_srcdir)/noweb-frame:$(w_srcdir)/utilities:$(w_srcdir)/testing:$(w_srcdir)/system:$(w_srcdir)/combinatorics:$(w_srcdir)/parsing:$(w_srcdir)/rng:$(w_srcdir)/expr_base:$(w_srcdir)/physics:$(w_srcdir)/qed_pdf:$(w_srcdir)/qft:$(w_srcdir)/types:$(w_srcdir)/matrix_elements:$(w_srcdir)/particles:$(w_srcdir)/beams:$(w_srcdir)/me_methods:$(w_srcdir)/events:$(w_srcdir)/phase_space:$(w_srcdir)/vegas:$(w_srcdir)/mci:$(w_srcdir)/fks:$(w_srcdir)/gosam:$(w_srcdir)/openloops:$(w_srcdir)/blha:$(w_srcdir)/shower:$(w_srcdir)/muli:$(w_srcdir)/variables:$(w_srcdir)/model_features:$(w_srcdir)/threshold:$(w_srcdir)/process_integration:$(w_srcdir)/matching:$(w_srcdir)/transforms:$(w_srcdir)/whizard-core:$(w_srcdir)/main:$(w_srcdir)/api ## The primary targets if DISTRIBUTION ## The manual source has to be distributed dist_noinst_DATA = manual.tex $(PACKAGE).tex \ book.hva custom.hva fancysection.hva Whizard-Logo.jpg \ $(MANUAL_PICS) dep2dot.py MANUAL_PICS = \ proc_4f-history.pdf whizstruct.pdf cc10_1.pdf \ cc10_2.pdf Z-lineshape_1.pdf Z-lineshape_2.pdf \ flow4.pdf lep_higgs_1.pdf \ lep_higgs_2.pdf lep_higgs_3.pdf circe2-smoothing.pdf \ resonance_e_gam.pdf resonance_n_charged.pdf \ resonance_n_hadron.pdf resonance_n_particles.pdf \ resonance_n_photons.pdf resonance_n_visible.pdf if NOWEB_AVAILABLE dist_pdf_DATA = manual.pdf $(PACKAGE).pdf gamelan_manual.pdf else dist_pdf_DATA = manual.pdf gamelan_manual.pdf endif else dist_pdf_DATA = endif pdf-local: manual.pdf $(PACKAGE).pdf gamelan_manual.pdf if DISTRIBUTION if HEVEA_AVAILABLE html_DATA = manual.html index.html endif HEVEA_AVAILABLE endif DISTRIBUTION GML=../../src/gamelan/whizard-gml --math=scaled -halt-on-error --gmldir ../../src/gamelan LATEX_STYLES = \ noweb.sty thophys.sty gamelan.sty hevea.sty TEX_FLAGS = "$$TEXINPUTS:$(top_srcdir)/share/doc" EXTRA_DIST = $(LATEX_STYLES) ## don't try to run the files in parallel (TeXLive 2009 doesn't like it) manual.pdf: $(PACKAGE).pdf $(PACKAGE).pdf: gamelan_manual.pdf $(WHIZARD_DEPENDENCY_GRAPHS_PDF) overview.pdf manual.pdf: variables.tex variables.tex: ../../src/whizard ../../src/whizard --generate-variables-tex > variables.tex gamelan_manual.pdf: gamelan.sty SUFFIXES: .dot .tex .pdf .dot.pdf: @if $(AM_V_P); then :; else echo " DOT " $@; fi $(AM_V_at)$(DOT) -Tpdf $< > $@ if DISTRIBUTION WHIZARD_DEPENDENCY_GRAPHS_DOT = \ blha.dot \ beams.dot \ combinatorics.dot \ events.dot \ expr_base.dot \ fks.dot \ gosam.dot \ matching.dot \ matrix_elements.dot \ vegas.dot \ mci.dot \ me_methods.dot \ model_features.dot \ muli.dot \ openloops.dot \ parsing.dot \ particles.dot \ phase_space.dot \ physics.dot \ qed_pdf.dot \ process_integration.dot \ qft.dot \ rng.dot \ shower.dot \ system.dot \ testing.dot \ threshold.dot \ transforms.dot \ types.dot \ utilities.dot \ variables.dot \ - whizard-core.dot + whizard-core.dot \ + main.dot \ + api.dot WHIZARD_DEPENDENCY_GRAPHS_PDF = $(WHIZARD_DEPENDENCY_GRAPHS_DOT:.dot=.pdf) all-dots: $(WHIZARD_DEPENDENCY_GRAPHS_DOT) overview.dot $(WHIZARD_DEPENDENCY_GRAPHS_DOT): @rm -f $@ @if $(AM_V_P); then \ $(top_srcdir)/share/doc/dep2dot.py \ ../../src/`echo $@ | sed 's/.dot//'`/Makefile.depend > $@; else \ echo " DEP2DOT " $@; \ $(top_srcdir)/share/doc/dep2dot.py \ ../../src/`echo $@ | sed 's/.dot//'`/Makefile.depend > $@; fi overview.dot: @rm -f $@ @if $(AM_V_P); then \ list=''; \ for dep in $(WHIZARD_DEPENDENCY_GRAPHS_DOT); do \ list="$$list ../../src/`echo $$dep | sed 's/.dot//'`/Makefile.depend"; \ done ; \ $(top_srcdir)/share/doc/dep2dot.py $$list > $@; else \ echo " DEP2DOT " $@; \ list=''; \ for dep in $(WHIZARD_DEPENDENCY_GRAPHS_DOT); do \ list="$$list ../../src/`echo $$dep | sed 's/.dot//'`/Makefile.depend"; \ done ; \ $(top_srcdir)/share/doc/dep2dot.py $$list > $@; fi dist_noinst_DATA += $(WHIZARD_DEPENDENCY_GRAPHS_DOT) overview.dot endif ## Rules for creating PDF if DISTRIBUTION if PDFLATEX_AVAILABLE .tex.pdf: @if $(AM_V_P); then TEXINPUTS=$(TEX_FLAGS) $(PDFLATEX) $<; else \ echo " PDFLATEX " $<; TEXINPUTS=$(TEX_FLAGS) $(PDFLATEX) $< >/dev/null; fi @if $(AM_V_P); then \ while grep 'Rerun to get cross-references right\.' $*.log; \ do TEXINPUTS=$(TEX_FLAGS) $(PDFLATEX) $<; \ done; else \ echo " PDFLATEX " $< "(for cross-references)"; \ while grep 'Rerun to get cross-references right\.' $*.log >/dev/null; \ do TEXINPUTS=$(TEX_FLAGS) $(PDFLATEX) $< >/dev/null; \ done; \ fi @if test -r $*.mp; then \ if $(AM_V_P); then $(GML) $*; else echo " GML " $*; $(GML) $* >/dev/null; fi; \ fi @if $(AM_V_P); then TEXINPUTS=$(TEX_FLAGS) $(PDFLATEX) $<; else \ echo " PDFLATEX " $<; TEXINPUTS=$(TEX_FLAGS) $(PDFLATEX) $< >/dev/null; fi endif PDFLATEX_AVAILABLE endif DISTRIBUTION ## Rules for creating HTML if HEVEA_AVAILABLE HEVEAOPTS = -exec xxdate.exe -I $(top_srcdir)/share/doc \ book.hva fancysection.hva custom.hva HACHAOPTS = -tocbis if DISTRIBUTION index.html: manual.html @if $(AM_V_P); then $(HACHA) $(HACHAOPTS) -o index.html manual.html; else \ echo " HACHA " $@; $(HACHA) $(HACHAOPTS) -o index.html manual.html >/dev/null 2>&1; fi manual.html: variables.tex manual.tex $(MANUAL_PICS) @if $(AM_V_P); then TEXINPUTS=$(TEX_FLAGS) $(HEVEA) -fix $(HEVEAOPTS) manual.tex; else \ echo " HEVEA " $@; \ TEXINPUTS=$(TEX_FLAGS) $(HEVEA) -s -fix $(HEVEAOPTS) manual.tex >/dev/null 2>&1; fi @if $(AM_V_P); then TEXINPUTS=$(TEX_FLAGS) $(IMAGEN) -pdf manual; else \ echo " IMAGEN manual"; TEXINPUTS=$(TEX_FLAGS) $(IMAGEN) -pdf manual >/dev/null 2>&1; fi ### There are no Feynman diagrams at the moment inside the manual. # $(MPOST) manualpics.mp @if $(AM_V_P); then TEXINPUTS=$(TEX_FLAGS) $(HEVEA) -fix $(HEVEAOPTS) manual.tex; else \ echo " HEVEA " $@; TEXINPUTS=$(TEX_FLAGS) $(HEVEA) -s -fix $(HEVEAOPTS) manual.tex; fi else @echo "HEVEA not available. The HTML manual cannot be made" endif !DISTRIBUTION endif HEVEA_AVAILABLE if NOWEB_AVAILABLE WHIZARD_NOWEB_SRC = \ whizard-prelude.nw \ utilities.nw \ testing.nw \ system.nw \ combinatorics.nw \ parsing.nw rng.nw physics.nw qed_pdf.nw qft.nw \ types.nw \ matrix_elements.nw \ particles.nw \ beams.nw \ me_methods.nw \ events.nw \ phase_space.nw \ vegas.nw \ mci.nw \ shower.nw muli.nw \ blha.nw gosam.nw \ openloops.nw fks.nw \ model_features.nw \ threshold.nw \ process_integration.nw \ matching.nw \ transforms.nw \ whizard.nw \ whizard-postlude.nw $(PACKAGE).tex: $(WHIZARD_NOWEB_SRC) -rm -f $@ @if $(AM_V_P); then :; else echo " NOWEAVE " $@; fi $(AM_V_at)$(NOWEAVE) -delay $^ | $(CPIF) $@ gamelan.sty: $(top_srcdir)/src/gamelan/gamelan.nw @if $(AM_V_P); then :; else echo " NOTANGLE " $@; fi $(AM_V_at)$(NOTANGLE) -R$@ $< | $(CPIF) $@ endif NOWEB_AVAILABLE ## Cleanup tasks mostlyclean-latex: -rm -f *.aux *.log *.dvi *.toc *.idx *.out *.ltp *.mp *.mpx *.glo \ gamelan_manual.[1-9] gamelan_manual.[1-9][0-9] \ manual.pdf gamelan_manual.pdf \ $(WHIZARD_DEPENDENCY_GRAPHS_DOT) $(WHIZARD_DEPENDENCY_GRAPHS_PDF) \ overview.dot overview.pdf variables.tex -test "$(srcdir)" != "." && rm -f $(PACKAGE).pdf clean-latex: maintainer-clean-latex: -rm manual.pdf gamelan_manual.pdf if NOWEB_AVAILABLE mostlyclean-whizard: -rm -f $(PACKAGE).tex $(PACKAGE).pdf gamelan.sty maintainer-clean-whizard: else mostlyclean-whizard: maintainer-clean-whizard: endif .PHONY: mostlyclean-latex clean-latex maintainer-clean-latex .PHONY: mostlyclean-whizard maintainer-clean-whizard mostlyclean-html: -rm -f *.haux *.htoc *.css index.html contents_motif.gif \ next_motif.gif previous_motif.gif contents_motif.svg \ next_motif.svg previous_motif.svg manual*.html manual*.png \ manual.image.tex clean-html: maintainer-clean-html: -rm -f manual*.html index.html contents_motif.gif \ next_motif.gif previous_motif.gif contents_motif.svg \ next_motif.svg previous_motif.svg .PHONY: mostlyclean-html clean-html maintainer-clean-html ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets mostlyclean-local: mostlyclean-latex mostlyclean-html mostlyclean-whizard clean-local: clean-latex clean-html maintainer-clean-local: maintainer-clean-latex maintainer-clean-html \ maintainer-clean-whizard maintainer-clean-backup if !DISTRIBUTION install-data-hook: -$(INSTALL) -m 644 manual.pdf $(DESTDIR)$(datarootdir)/doc/whizard -$(INSTALL) -m 644 $(PACKAGE).pdf $(DESTDIR)$(datarootdir)/doc/whizard -$(INSTALL) -m 644 gamelan_manual.pdf $(DESTDIR)$(datarootdir)/doc/whizard uninstall-hook: -rm -f $(DESTDIR)/$(datarootdir)/doc/whizard/manual.pdf -rm -f $(DESTDIR)/$(datarootdir)/doc/whizard/$(PACKAGE).pdf -rm -f $(DESTDIR)/$(datarootdir)/doc/whizard/gamelan_manual.pdf endif ######################################################################## ## The End. ######################################################################## Index: trunk/vamp/tests/Makefile.am =================================================================== --- trunk/vamp/tests/Makefile.am (revision 8428) +++ trunk/vamp/tests/Makefile.am (revision 8429) @@ -1,112 +1,112 @@ # Makefile.am -- ######################################################################## ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ######################################################################## AM_FCFLAGS = -I$(top_builddir)/vamp/src AM_LDFLAGS = KINDS = $(top_builddir)/vamp/src/kinds.lo LIBVAMP = $(top_builddir)/vamp/src/libvamp.la TESTS = tao_test EXTRA_PROGRAMS = tao_test tao_test_SOURCES = tao_test.f90 tao_test_LDADD = $(KINDS) $(LIBVAMP) TESTS += vamp_test EXTRA_PROGRAMS += vamp_test vamp_test_SOURCES = vamp_test.f90 constants.f90 kinematics.f90 coordinates.f90 vamp_test_LDADD = $(KINDS) $(LIBVAMP) TESTS += vamp_test0 EXTRA_PROGRAMS += vamp_test0 vamp_test0_SOURCES = vamp_test0.f90 vamp_test0_LDADD = $(KINDS) $(LIBVAMP) VPATH = $(srcdir):$(top_builddir)/vamp/src:$(top_srcdir)/vamp/src SOURCE_FILES = \ tao_test.f90 vamp_test0.f90 vamp_test.f90 \ constants.f90 kinematics.f90 coordinates.f90 # Fortran90 module files are generated at the same time as object files -.$(OBJEXT).$(FC_MODULE_EXT): +.$(OBJEXT).$(FCMOD): @: # touch $@ ######################################################################## # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE ######################################################################## @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: $(SOURCE_FILES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.$(OBJEXT): /' \ -e 's/, *only:.*//' \ -e 's/, *&//' \ -e 's/, *.*=>.*//' \ -e 's/ *$$/.$(OBJEXT)/' ; \ done > $@ DISTCLEANFILES = Makefile.depend ######################################################################## # noweb ######################################################################## NOTANGLE_IT = \ $(NOTANGLE) -R'[[$(@F)]]' $(top_srcdir)/vamp/src/prelude.nw $^ \ | $(CPIF) $@ SUFFIXES = .nw .f90 .nw.f90: $(NOTANGLE_IT) tao_test.f90: tao_random_numbers.nw $(NOTANGLE_IT) clean-local: rm -f $(EXTRA_PROGRAMS) - rm -f *.$(FC_MODULE_EXT) *.g90 + rm -f *.$(FCMOD) *.g90 rm -f *.mod tmp.tao *.d *.grid *.grids if FC_SUBMODULES -rm -f *.smod endif ######################################################################## # The End. ######################################################################## Index: trunk/vamp/src/Makefile.am =================================================================== --- trunk/vamp/src/Makefile.am (revision 8428) +++ trunk/vamp/src/Makefile.am (revision 8429) @@ -1,187 +1,193 @@ # Makefile.am -- ######################################################################## ## ## Process this file with automake to produce Makefile.in # # Copyright (C) 1999-2020 by # Wolfgang Kilian # Thorsten Ohl # Juergen Reuter # with contributions from # cf. main AUTHORS file # # WHIZARD is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # WHIZARD is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ######################################################################## depend_filter_extra = -e 's/iso_fortran_env\.lo//' NOWEB_SOURCE_FILES = \ divisions.f90 \ vamp.f90 \ exceptions.f90 \ tao_random_numbers.f90 \ tao52_random_numbers.f90 \ specfun.f90 \ vamp_stat.f90 \ histograms.f90 \ utils.f90 \ linalg.f90 \ products.f90 \ $(sources_extra) SOURCE_FILES = $(NOWEB_SOURCE_FILES) MODULE_FILES = \ - divisions.$(FC_MODULE_EXT) \ - vamp.$(FC_MODULE_EXT) \ - kinds.$(FC_MODULE_EXT) \ - exceptions.$(FC_MODULE_EXT) \ - tao_random_numbers.$(FC_MODULE_EXT) \ - tao52_random_numbers.$(FC_MODULE_EXT) \ - specfun.$(FC_MODULE_EXT) \ - vamp_stat.$(FC_MODULE_EXT) \ - histograms.$(FC_MODULE_EXT) \ - utils.$(FC_MODULE_EXT) \ - linalg.$(FC_MODULE_EXT) \ - products.$(FC_MODULE_EXT) \ + divisions.$(FCMOD) \ + vamp.$(FCMOD) \ + kinds.$(FCMOD) \ + exceptions.$(FCMOD) \ + tao_random_numbers.$(FCMOD) \ + tao52_random_numbers.$(FCMOD) \ + specfun.$(FCMOD) \ + vamp_stat.$(FCMOD) \ + histograms.$(FCMOD) \ + utils.$(FCMOD) \ + linalg.$(FCMOD) \ + products.$(FCMOD) \ $(modules_extra) \ - # vamp_grid.$(FC_MODULE_EXT) \ - # vamp_equivalences.$(FC_MODULE_EXT) + vamp_grid_type.$(FCMOD) \ + vamp_rest.$(FCMOD) \ + vamp_equivalences.$(FCMOD) NOWEB_FILES = \ prelude.nw postlude.nw \ divisions.nw vamp.nw \ vamp_kinds.nw constants.nw exceptions.nw \ tao_random_numbers.nw \ specfun.nw vamp_stat.nw histograms.nw utils.nw \ linalg.nw products.nw kinematics.nw coordinates.nw \ vampi.nw mpi90.nw vamp_test.nw vamp_test0.nw \ application.nw sample.nw -moduleexecincludedir = $(pkgincludedir)/../vamp -# if FC_MPI -# lib_LTLIBRARIES = libvamp.la libvampi.la -# libvamp_la_SOURCES = $(SOURCE_FILES) -# libvampi_la_SOURCES = mpi90.f90 vampi.f90 -# nodist_moduleexecinclude_DATA = $(MODULE_FILES) # mpi90.$(FC_MODULE_EXT) vampi.$(FC_MODULE_EXT) -# else !FC_MPI +# Modules and installation +# Install twice: once for vamp +execvampmoddir = $(fmoddir)/vamp +nodist_execvampmod_HEADERS = $(MODULE_FILES) + +# Once for whizard +execmoddir = $(fmoddir)/whizard +nodist_execmod_HEADERS = $(MODULE_FILES) + lib_LTLIBRARIES = libvamp.la libvamp_la_SOURCES = $(SOURCE_FILES) -nodist_moduleexecinclude_DATA = $(MODULE_FILES) -# endif !FC_MPI EXTRA_DIST = $(NOWEB_FILES) $(SOURCE_FILES) iso_fortran_env_stub.f90 # Fortran90 module files are generated at the same time as object files -.lo.$(FC_MODULE_EXT): +.lo.$(FCMOD): @: # touch $@ +# Explicit dependencies +vamp_grid_type.$(FCMOD): vamp.lo +vamp_rest.$(FCMOD): vamp.lo +vamp_equivalences.$(FCMOD): vamp.lo + ######################################################################## # Fortran Compilers ######################################################################## AM_FCFLAGS = ######################################################################## ## Default Fortran compiler options ## Profiling if FC_USE_PROFILING AM_FCFLAGS += $(FCFLAGS_PROFILING) endif ## OpenMP if FC_USE_OPENMP AM_FCFLAGS += $(FCFLAGS_OPENMP) endif ######################################################################## # noweb ######################################################################## NOTANGLE_IT = \ $(NOTANGLE) -R'[[$(@F)]]' $(srcdir)/prelude.nw $^ | $(CPIF) $@ -SUFFIXES = .nw .lo .$(FC_MODULE_EXT) +SUFFIXES = .nw .lo .$(FCMOD) .nw.f90: $(NOTANGLE_IT) tao52_random_numbers.f90: tao_random_numbers.nw $(NOTANGLE_IT) ######################################################################## # The following line just says # include Makefile.depend # but in a portable fashion (depending on automake's AM_MAKE_INCLUDE ######################################################################## @am__include@ @am__quote@Makefile.depend@am__quote@ Makefile.depend: $(SOURCE_FILES) @rm -f $@ for src in $^; do \ module="`basename $$src | sed 's/\.f[90][0358]//'`"; \ grep '^ *use ' $$src \ | grep -v '!NODEP!' \ | sed -e 's/^ *use */'$$module'.lo: /' \ -e 's/, *only:.*//' \ -e 's/, *&//' \ -e 's/, *.*=>.*//' \ -e 's/ *$$/.lo/' \ $(depend_filter_extra) ; \ done > $@ DISTCLEANFILES = Makefile.depend kinds.f90 ######################################################################## ## Non-standard cleanup tasks ## Remove sources that can be recreated using NOWEB if NOWEB_AVAILABLE maintainer-clean-noweb: -rm -f $(NOWEB_SOURCE_FILES) endif .PHONY: maintainer-clean-noweb ## Remove those sources also if builddir and srcdir are different if NOWEB_AVAILABLE clean-noweb: test "$(srcdir)" != "." && rm -f $(NOWEB_SOURCE_FILES) || true endif .PHONY: clean-noweb ## Remove F90 module files clean-local: clean-noweb - -rm -f *.$(FC_MODULE_EXT) + -rm -f *.$(FCMOD) if FC_SUBMODULES -rm -f *.smod endif ## Remove backup files maintainer-clean-backup: -rm -f *~ .PHONY: maintainer-clean-backup ## Register additional clean targets maintainer-clean-local: maintainer-clean-noweb maintainer-clean-backup ######################################################################## # MPI ######################################################################## ### ### # The -mismatch_all is for mpi_send() etc. ### MPIFC = mpif90 ### MPIFCFLAGS = # -mismatch_all