From e74cd78b3547d541a26ae9341bbb8c1997698594 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <andrii.verbytskyi@mpp.mpg.de> Date: Tue, 21 Mar 2023 11:20:44 +0100 Subject: [PATCH] Implement suggestion from Leif: padding cross-sections with zeros by default so the number of cross-sections match the number of weights --- doc/doxygen/modules.txt | 2 +- src/ReaderAsciiHepMC2.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/doxygen/modules.txt b/doc/doxygen/modules.txt index 34859496..35e5320a 100644 --- a/doc/doxygen/modules.txt +++ b/doc/doxygen/modules.txt @@ -40,7 +40,7 @@ in the HepMC2 style. This is pre-3.2.6 default behaviour. Otherwise, the cross-section vector will be expanded to the size of event weights. This is 3.2.6+ default behaviour. If present, "fill_crosssections_value"/"fill_crosssections_error" values will be inserted into the cross-section vector. - Otherwise, the nominal cross-section and error will be used. + Otherwise, the cross-sections and errors will be filled with zeros. "particle_flows_are_separated" diff --git a/src/ReaderAsciiHepMC2.cc b/src/ReaderAsciiHepMC2.cc index 446ea62c..f9418acf 100644 --- a/src/ReaderAsciiHepMC2.cc +++ b/src/ReaderAsciiHepMC2.cc @@ -609,8 +609,8 @@ bool ReaderAsciiHepMC2::parse_xs_info(GenEvent &evt, const char *buf) { if ( !(cursor = strchr(cursor+1, ' ')) ) return false; const double xs_err = atof(cursor); const size_t all = m_options.count("keep_single_crosssection") ? size_t{1} : std::max(evt.weights().size(),size_t{1}); - const double xs_val_dummy = m_options.count("fill_crosssections_value") ? std::strtod(m_options.at("fill_crosssections_value").c_str(),nullptr) : xs_val; - const double xs_err_dummy = m_options.count("fill_crosssections_error") ? std::strtod(m_options.at("fill_crosssections_error").c_str(),nullptr) : xs_err; + const double xs_val_dummy = m_options.count("fill_crosssections_value") ? std::strtod(m_options.at("fill_crosssections_value").c_str(),nullptr) : 0.0; + const double xs_err_dummy = m_options.count("fill_crosssections_error") ? std::strtod(m_options.at("fill_crosssections_error").c_str(),nullptr) : 0.0; xs->set_cross_section(std::vector<double>(all,xs_val_dummy), std::vector<double>(all,xs_err_dummy)); xs->set_xsec(0,xs_val); xs->set_xsec_err(0,xs_err); -- GitLab