Skip to content

Commit

Permalink
Fix most warnings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Feb 20, 2024
1 parent 6211587 commit c6c7aa3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 36 deletions.
2 changes: 1 addition & 1 deletion tests/compare_contents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int main(int argc, char* argv[])
return 1;
}

if (edmEvent.get(name)->size() != lcioColl->getNumberOfElements()) {
if (edmEvent.get(name)->size() != (unsigned) lcioColl->getNumberOfElements()) {
std::cerr << "Collection " << name << " has different sizes. LCIO: " << lcioColl->getNumberOfElements()
<< ", EDM4hep: " << coll->size() << std::endl;
return 1;
Expand Down
32 changes: 13 additions & 19 deletions tests/src/CompareEDM4hepLCIO.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ auto to64BitCellID(LcioT* obj)

// ================= CalorimeterHit ================

bool compare(
const EVENT::CalorimeterHit* lcioElem,
const edm4hep::CalorimeterHit& edm4hepElem,
const ObjectMappings& objectMaps)
bool compare(const EVENT::CalorimeterHit* lcioElem, const edm4hep::CalorimeterHit& edm4hepElem, const ObjectMappings&)
{
const auto lcioCellID = to64BitCellID(lcioElem);
ASSERT_COMPARE_VALS(lcioCellID, edm4hepElem.getCellID(), "cellID in CalorimeterHit");
Expand Down Expand Up @@ -155,7 +152,7 @@ bool compare(const EVENT::ParticleID* lcioElem, const edm4hep::ParticleID& edm4h
bool compare(
const EVENT::RawCalorimeterHit* lcioElem,
const edm4hep::RawCalorimeterHit& edm4hepElem,
const ObjectMappings& objectMaps)
const ObjectMappings&)
{
const auto lcioCellID = to64BitCellID(lcioElem);
ASSERT_COMPARE_VALS(lcioCellID, edm4hepElem.getCellID(), "cellID in RawCalorimeterHit");
Expand Down Expand Up @@ -250,7 +247,8 @@ bool compare(

// Contributions are not part of the "proper LCIO"
const auto edmContributions = edm4hepElem.getContributions();
ASSERT_COMPARE_VALS(lcioElem->getNMCContributions(), edmContributions.size(), "number of CaloHitContributions");
ASSERT_COMPARE_VALS(
(unsigned) lcioElem->getNMCContributions(), edmContributions.size(), "number of CaloHitContributions");

for (int iCont = 0; iCont < lcioElem->getNMCContributions(); ++iCont) {
const auto& edmContrib = edmContributions[iCont];
Expand Down Expand Up @@ -290,7 +288,8 @@ bool compare(
const edm4hep::SimTrackerHit& edm4hepElem,
const ObjectMappings& objectMaps)
{
ASSERT_COMPARE(lcioElem, edm4hepElem, getCellID, "cellID in SimTrackerHit");
const auto lcioCellID = to64BitCellID(lcioElem);
ASSERT_COMPARE_VALS(lcioCellID, edm4hepElem.getCellID(), "cellID in SimTrackerHit");
ASSERT_COMPARE(lcioElem, edm4hepElem, getEDep, "EDep in SimTrackerHit");
ASSERT_COMPARE(lcioElem, edm4hepElem, getTime, "time in SimTrackerHit");
ASSERT_COMPARE(lcioElem, edm4hepElem, getPathLength, "pathLength in SimTrackerHit");
Expand All @@ -313,9 +312,10 @@ bool compare(

// ================= TPCHit ================

bool compare(const EVENT::TPCHit* lcioElem, const edm4hep::RawTimeSeries& edm4hepElem, const ObjectMappings& objectMaps)
bool compare(const EVENT::TPCHit* lcioElem, const edm4hep::RawTimeSeries& edm4hepElem, const ObjectMappings&)
{
ASSERT_COMPARE(lcioElem, edm4hepElem, getCellID, "cellID in TPCHit");
const uint64_t lcioCellID = lcioElem->getCellID();
ASSERT_COMPARE_VALS(lcioCellID, edm4hepElem.getCellID(), "cellID in TPCHit");
ASSERT_COMPARE(lcioElem, edm4hepElem, getQuality, "quality in TPCHit");
ASSERT_COMPARE(lcioElem, edm4hepElem, getTime, "time in TPCHit");
ASSERT_COMPARE(lcioElem, edm4hepElem, getCharge, "charge in TPCHit");
Expand Down Expand Up @@ -412,10 +412,7 @@ bool compare(

// ================= TrackerHit ================

bool compare(
const EVENT::TrackerHit* lcioElem,
const edm4hep::TrackerHit3D& edm4hepElem,
const ObjectMappings& objectMaps)
bool compare(const EVENT::TrackerHit* lcioElem, const edm4hep::TrackerHit3D& edm4hepElem, const ObjectMappings&)
{
const auto lcioCellID = to64BitCellID(lcioElem);
ASSERT_COMPARE_VALS(lcioCellID, edm4hepElem.getCellID(), "cellID in TrackerHit");
Expand All @@ -440,10 +437,7 @@ bool compare(

// ================= TrackerHitPlane ================

bool compare(
const EVENT::TrackerHitPlane* lcioElem,
const edm4hep::TrackerHitPlane& edm4hepElem,
const ObjectMappings& objectMaps)
bool compare(const EVENT::TrackerHitPlane* lcioElem, const edm4hep::TrackerHitPlane& edm4hepElem, const ObjectMappings&)
{
const auto lcioCellID = to64BitCellID(lcioElem);
ASSERT_COMPARE_VALS(lcioCellID, edm4hepElem.getCellID(), "cellID in TrackerHitPlane");
Expand Down Expand Up @@ -503,12 +497,12 @@ bool compare(

bool compareEventHeader(const EVENT::LCEvent* lcevt, const podio::Frame* edmEvent)
{

const auto& edmEventHeader = edmEvent->get<edm4hep::EventHeaderCollection>("EventHeader")[0];

ASSERT_COMPARE(lcevt, edmEventHeader, getEventNumber, "Event Number is not the same");
ASSERT_COMPARE(lcevt, edmEventHeader, getRunNumber, "Run Number is not the same");
ASSERT_COMPARE(lcevt, edmEventHeader, getTimeStamp, "TimeStamp in EventHeader is not the same");
const uint64_t lcioTimeStamp = lcevt->getTimeStamp();
ASSERT_COMPARE_VALS(lcioTimeStamp, edmEventHeader.getTimeStamp(), "TimeStamp in EventHeader is not the same");
ASSERT_COMPARE(lcevt, edmEventHeader, getWeight, "Weight in EventHeader is not the same");

return true;
Expand Down
8 changes: 3 additions & 5 deletions tests/src/ComparisonUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,10 @@ inline bool nanSafeComp(T x, U y)

// Only enable for vectors
template<typename T, typename = void>
struct has_size_method : std::false_type {
};
struct has_size_method : std::false_type {};

template<typename T>
struct has_size_method<T, std::void_t<decltype(std::declval<T>().size())>> : std::true_type {
};
struct has_size_method<T, std::void_t<decltype(std::declval<T>().size())>> : std::true_type {};

template<typename T, typename... Ts>
constexpr bool isAnyOf = (std::is_same_v<T, Ts> || ...);
Expand Down Expand Up @@ -178,7 +176,7 @@ inline bool compareRelation(
// not fill relations if the original relations in LCIO were empty
const auto nonNullLcio =
std::count_if(lcioRange.begin(), lcioRange.end(), [](const auto e) { return e != nullptr; });
if (nonNullLcio != edm4hepRange.size()) {
if ((unsigned) nonNullLcio != edm4hepRange.size()) {
std::cerr << msg << " different sizes (even after taking null values into account)" << std::endl;
return false;
}
Expand Down
18 changes: 9 additions & 9 deletions tests/src/EDM4hep2LCIOUtilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ constexpr auto createCov()
return i * (2 * N - i - 1) / 2 + j;
};

for (int i = 0; i < N; ++i) {
for (int j = 0; j < i; ++j) {
for (auto i = 0u; i < N; ++i) {
for (auto j = 0u; j < i; ++j) {
const auto index = to_lower_tri(i, j);
result[index] = i + 10 * j;
}
Expand Down Expand Up @@ -313,11 +313,11 @@ edm4hep::ClusterCollection createClusters(
}
}

for (const auto [cluIdx, hitIdx] : clusterHitIdcs) {
for (const auto& [cluIdx, hitIdx] : clusterHitIdcs) {
clusterColl[cluIdx].addToHits(caloHits[hitIdx]);
}

for (const auto [targetI, sourceI] : clusterHitIdcs) {
for (const auto& [targetI, sourceI] : clusterClusterIdcs) {
clusterColl[targetI].addToClusters(clusterColl[sourceI]);
}

Expand All @@ -332,11 +332,11 @@ podio::Frame createExampleEvent()
const auto& mcParticles =
event.put(createMCParticles(test_config::nMCParticles, test_config::mcpParentIdcs), "mcParticles");
const auto& caloHits = event.put(createCalorimeterHits(test_config::nCaloHits), "caloHits");
const auto& rawCaloHits = event.put(createRawCalorimeterHits(test_config::nRawCaloHits), "rawCaloHits");
const auto& tpcHits = event.put(createTPCHits(test_config::nTPCHits, test_config::nTPCRawWords), "tpcHits");
event.put(createRawCalorimeterHits(test_config::nRawCaloHits), "rawCaloHits");
event.put(createTPCHits(test_config::nTPCHits, test_config::nTPCRawWords), "tpcHits");
const auto& trackerHits = event.put(createTrackerHits(test_config::nTrackerHits), "trackerHits");
const auto& trackerHitPlanes = event.put(createTrackerHitPlanes(test_config::nTrackerHits), "trackerHitPlanes");
const auto& tracks = event.put(
event.put(createTrackerHitPlanes(test_config::nTrackerHits), "trackerHitPlanes");
event.put(
createTracks(
test_config::nTracks,
test_config::nSubdetectorHitNumbers,
Expand All @@ -356,7 +356,7 @@ podio::Frame createExampleEvent()

auto [tmpSimCaloHits, tmpCaloHitConts] = createSimCalorimeterHits(
test_config::nSimCaloHits, test_config::nCaloHitContributions, mcParticles, test_config::simCaloHitMCIdcs);
const auto& simCaloHits = event.put(std::move(tmpSimCaloHits), "simCaloHits");
event.put(std::move(tmpSimCaloHits), "simCaloHits");
event.put(std::move(tmpCaloHitConts), "caloHitContributions");

return event;
Expand Down
4 changes: 2 additions & 2 deletions tests/src/EDM4hep2LCIOUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace podio {
namespace test_config {
constexpr static int nMCParticles = 5; ///< The number of MCParticles to generate

using IdxPair = std::pair<std::size_t, std::size_t>;
using IdxPair = std::pair<int, int>;
/// How to create the MC particle hierarchy, e.g. {4, 0} means that mc[4] will
/// have mc[0] as a parent, and mc[0] will get mc[4] as a daughter
const static std::vector<IdxPair> mcpParentIdcs = {{4, 0}, {4, 1}, {3, 2}, {3, 0}, {3, 1}, {2, 1}};
Expand All @@ -61,7 +61,7 @@ namespace test_config {
constexpr static int nCaloHitContributions = 4; ///< The number of CalorimeterHit Contributions
/// idcs to setup relations between SimCalorimeterHits, CaloHitContributions
/// and MCParticles (in this order)
using CaloContIdx = std::tuple<std::size_t, std::size_t, std::size_t>;
using CaloContIdx = std::tuple<int, int, int>;
/// The index values to use for setting up the relations
const static std::vector<CaloContIdx> simCaloHitMCIdcs = {
{0, 0, 0},
Expand Down

0 comments on commit c6c7aa3

Please sign in to comment.