diff --git a/DDG4/hepmc/HepMC3FileReader.cpp b/DDG4/hepmc/HepMC3FileReader.cpp index 927471453fb21a4908fad9c8e7eea1b29ef80c2e..72d6445410cbe07076ea31c9047a87159cc2a085 100644 --- a/DDG4/hepmc/HepMC3FileReader.cpp +++ b/DDG4/hepmc/HepMC3FileReader.cpp @@ -45,19 +45,28 @@ namespace dd4hep { if(attr.second.size() > 1 or inAttr.first != 0){ strstr << "_" << inAttr.first; } - auto attr_as_int = std::dynamic_pointer_cast<HepMC3::IntAttribute>(inAttr.second); - auto attr_as_flt = std::dynamic_pointer_cast<HepMC3::FloatAttribute>(inAttr.second); - if(attr_as_int) { - m_intValues[strstr.str()] = {attr_as_int->value()}; - } else if(attr_as_flt) { - m_fltValues[strstr.str()] = {attr_as_flt->value()}; + if(auto int_attr = std::dynamic_pointer_cast<HepMC3::IntAttribute>(inAttr.second)) { + m_intValues[strstr.str()] = {int_attr->value()}; + } else if(auto flt_attr = std::dynamic_pointer_cast<HepMC3::FloatAttribute>(inAttr.second)) { + m_fltValues[strstr.str()] = {flt_attr->value()}; + } else if(auto dbl_attr = std::dynamic_pointer_cast<HepMC3::DoubleAttribute>(inAttr.second)) { + m_dblValues[strstr.str()] = {dbl_attr->value()}; } else { // anything else m_strValues[strstr.str()] = {inAttr.second->unparsed_string()}; } } } - } + if (const auto& weights = genEvent.weights(); !weights.empty()) { + m_dblValues["EventWeights"] = weights; + } + // Not using the GenEven::weight_names here because that checks for + // emptyness and throws in that case. We don't care if we get an empty + // vector at this point + if (genEvent.run_info() && !genEvent.run_info()->weight_names().empty()) { + m_strValues["EventWeightNames"] = genEvent.weight_names(); + } + } /// Base class to read hepmc3 event files /** diff --git a/DDG4/include/DDG4/EventParameters.h b/DDG4/include/DDG4/EventParameters.h index 4dded17cd4131abbb2e7979b31f311e5ef9ed7a7..ee1d08649109784de79209865a4b682408c932a2 100644 --- a/DDG4/include/DDG4/EventParameters.h +++ b/DDG4/include/DDG4/EventParameters.h @@ -35,6 +35,7 @@ namespace dd4hep { std::map<std::string, std::vector<int>> m_intValues {}; std::map<std::string, std::vector<float>> m_fltValues {}; std::map<std::string, std::vector<std::string>> m_strValues {}; + std::map<std::string, std::vector<double>> m_dblValues {}; public: /// Initializing constructor @@ -61,6 +62,8 @@ namespace dd4hep { auto const& fltParameters() const { return m_fltValues; } /// Get the string event parameters auto const& strParameters() const { return m_strValues; } + /// Get the double event parameters + auto const& dblParameters() const { return m_dblValues; } };