diff --git a/tests/scripts/run_standalone_converter.sh b/tests/scripts/run_standalone_converter.sh index 67663ce5..d37c914d 100755 --- a/tests/scripts/run_standalone_converter.sh +++ b/tests/scripts/run_standalone_converter.sh @@ -8,9 +8,11 @@ TEST_INPUT_DIR=${TEST_DIR}/inputFiles TEST_OUTPUT_DIR=testOutputs mkdir -p ${TEST_OUTPUT_DIR} -input_file=${TEST_INPUT_DIR}/${input_file_base} -output_file=${TEST_OUTPUT_DIR}/${input_file_base/.slcio/.edm4hep.root} -patch_file=${TEST_OUTPUT_DIR}/${input_file_base/.slcio/_colls.txt} +input_file=${input_file_base} +output_file=${input_file_base/.slcio/.edm4hep.root} +patch_file=${input_file_base/.slcio/_colls.txt} + +echo ${input_file_base} echo "Creating the patch file for the standalone converter" check_missing_cols --minimal ${input_file} > ${patch_file} diff --git a/tests/src/CompareEDM4hepLCIO.cc b/tests/src/CompareEDM4hepLCIO.cc index 8854dbd2..dd40aa5a 100644 --- a/tests/src/CompareEDM4hepLCIO.cc +++ b/tests/src/CompareEDM4hepLCIO.cc @@ -255,10 +255,13 @@ bool compare( for (int iCont = 0; iCont < lcioElem->getNMCContributions(); ++iCont) { const auto& edmContrib = edmContributions[iCont]; ASSERT_COMPARE_VALS( - lcioElem->getEnergyCont(iCont), edmContrib.getEnergy(), "energy in CaloHitContribution " << iCont); + lcioElem->getEnergyCont(iCont), edmContrib.getEnergy(), "energy in CaloHitContribution " + std::to_string(iCont)); ASSERT_COMPARE_VALS( - lcioElem->getStepPosition(iCont), edmContrib.getStepPosition(), "stepPosition in CaloHitContribution " << iCont); - ASSERT_COMPARE_VALS(lcioElem->getTimeCont(iCont), edmContrib.getTime(), "time in CaloHitContribution " << iCont); + lcioElem->getStepPosition(iCont), + edmContrib.getStepPosition(), + "stepPosition in CaloHitContribution " + std::to_string(iCont)); + ASSERT_COMPARE_VALS( + lcioElem->getTimeCont(iCont), edmContrib.getTime(), "time in CaloHitContribution " + std::to_string(iCont)); if (!compareRelation( lcioElem->getParticleCont(iCont), diff --git a/tests/src/ComparisonUtils.h b/tests/src/ComparisonUtils.h index fbe6ed85..3ac9dc74 100644 --- a/tests/src/ComparisonUtils.h +++ b/tests/src/ComparisonUtils.h @@ -140,11 +140,51 @@ VECTOR2_COMPARE(float, edm4hep::Vector2f) // Macro for comparing the return types of the different functions and return // false if they are not equal while also emitting a message -#define ASSERT_COMPARE_VALS(lcioV, edm4hepV, msg) \ - if ((lcioV) != (edm4hepV)) { \ - std::cerr << msg << " (LCIO: " << (lcioV) << ", EDM4hep: " << (edm4hepV) << ")" << std::endl; \ - return false; \ + +// Only enable for vectors +template +struct has_size_method : std::false_type {}; + +template +struct has_size_method().size())>> : std::true_type {}; + +template +bool ASSERT_COMPARE_VALS_TEMPLATE(LCIO lcioV, EDM4hep edm4hepV, const std::string& msg) +{ + if constexpr (has_size_method::value) { + for (size_t i = 0; i < (edm4hepV).size(); ++i) { + if ((std::isnan((lcioV)[i]) != std::isnan((edm4hepV)[i])) || ((lcioV)[i] != (edm4hepV)[i])) { + std::cerr << msg << " at index i: (LCIO: " << (lcioV) << ", EDM4hep: " << (edm4hepV) << ")" << std::endl; + return false; + } + } + } + else if constexpr ((std::is_same_v) || std::is_same_v) { + for (size_t i = 0; i < 3; ++i) { + if ((std::isnan((lcioV)[i]) != std::isnan((edm4hepV)[i])) || ((lcioV)[i] != (edm4hepV)[i])) { + std::cerr << msg << " at index i: (LCIO: " << (lcioV) << ", EDM4hep: " << (edm4hepV) << ")" << std::endl; + return false; + } + } + } + else if constexpr ((std::is_same_v) || std::is_same_v) { + for (size_t i = 0; i < 2; ++i) { + if ((std::isnan((lcioV)[i]) != std::isnan((edm4hepV)[i])) || ((lcioV)[i] != (edm4hepV)[i])) { + std::cerr << msg << " at index i: (LCIO: " << (lcioV) << ", EDM4hep: " << (edm4hepV) << ")" << std::endl; + return false; + } + } + } + else { + if ((std::isnan((lcioV)) != std::isnan((edm4hepV))) || ((lcioV) != (edm4hepV))) { + std::cerr << msg << " (LCIO: " << (lcioV) << ", EDM4hep: " << (edm4hepV) << ")" << std::endl; + return false; + } } + return true; +} + +#define ASSERT_COMPARE_VALS(lcioV, edm4hepV, msg) return ASSERT_COMPARE_VALS_TEMPLATE(lcioV, edm4hepV, msg); #define ASSERT_COMPARE(lcioE, edm4hepE, func, msg) \ { \