Skip to content

Commit

Permalink
Fix the HepPDT related cmake warning and make sure that all tests bui…
Browse files Browse the repository at this point in the history
…ld (#367)

* Make sure that FindHepPDT module is available

* Remove unnecessary FindHepMC module

* Ensure HepMC 3.3 and make test build again with it
  • Loading branch information
tmadlener authored Sep 17, 2024
1 parent 76ae71f commit a98fad0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 52 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ include(cmake/Key4hepConfig.cmake)
# - Use GNU-style hierarchy for installing build products
include(GNUInstallDirs)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include(cmake/EDM4HEPBuild.cmake)
edm4hep_set_linker_flags()

Expand Down
34 changes: 0 additions & 34 deletions cmake/FindHepMC.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ IF(TARGET ROOT::ROOTDataFrame)
endif()


find_package(HepMC3)
find_package(HepMC3 3.3)

This comment has been minimized.

Copy link
@jmcarcell

jmcarcell Sep 17, 2024

Contributor

Sorry for the late check but this 3.3 should not be necessary, passing shared_ptr to add_particle_in or add_particle_out has been there since 3.0.0. Did you check this or was the 3.3 coming from the current version? I get locally some warnings so for me it's worth it to remove it.

This comment has been minimized.

Copy link
@tmadlener

tmadlener Sep 17, 2024

Author Contributor

I simply went with 3.3 because that is what we have and build (and hence are sure that it works). I didn't check with lower versions. Given that we only need this for the tests, I think it's OK to leave 3.3, but we can also relax it a bit.

This comment has been minimized.

Copy link
@jmcarcell

jmcarcell Sep 17, 2024

Contributor

I'll make a quick PR to relax it only because it's annoying for me since locally I have a slightly older HepMC3 and I get a warning each time I run CMake.

find_package(HepPDT)

if(HepMC3_FOUND AND HepPDT_FOUND )
Expand Down
34 changes: 17 additions & 17 deletions test/hepmc/edm4hep_testhepmc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
// and converting it to the edm4hep data model
//////////////////////////////////////////////////////////////////////////

#include <iostream>
#include <memory>
#include <unordered_map>
#include "edm4hep/MCParticleCollection.h"

#include "HepMC3/GenEvent.h"
#include "HepMC3/GenParticle.h"
Expand All @@ -19,7 +17,9 @@
#include "podio/Frame.h"
#include "podio/ROOTWriter.h"

#include "edm4hep/MCParticleCollection.h"
#include <iostream>
#include <memory>
#include <unordered_map>

using namespace HepMC3;

Expand Down Expand Up @@ -65,39 +65,39 @@ int main() {
// #

// First create the event container
auto evt = new GenEvent();
auto evt = std::make_unique<GenEvent>();
// define the units
evt->set_units(HepMC3::Units::GEV, HepMC3::Units::MM);
//
// create vertex 1 and vertex 2, together with their inparticles
GenVertex* v1 = new GenVertex();
auto v1 = std::make_shared<GenVertex>();
evt->add_vertex(v1);
v1->add_particle_in(new GenParticle(FourVector(0, 0, 7000, 7000), 2212, 3));
GenVertex* v2 = new GenVertex();
v1->add_particle_in(std::make_shared<GenParticle>(FourVector(0, 0, 7000, 7000), 2212, 3));
auto v2 = std::make_shared<GenVertex>();
evt->add_vertex(v2);
v2->add_particle_in(new GenParticle(FourVector(0, 0, -7000, 7000), 2212, 3));
v2->add_particle_in(std::make_shared<GenParticle>(FourVector(0, 0, -7000, 7000), 2212, 3));
//
// create the outgoing particles of v1 and v2
GenParticle* p3 = new GenParticle(FourVector(.750, -1.569, 32.191, 32.238), 1, 3);
auto p3 = std::make_shared<GenParticle>(FourVector(.750, -1.569, 32.191, 32.238), 1, 3);
v1->add_particle_out(p3);
GenParticle* p4 = new GenParticle(FourVector(-3.047, -19., -54.629, 57.920), -2, 3);
auto p4 = std::make_shared<GenParticle>(FourVector(-3.047, -19., -54.629, 57.920), -2, 3);
v2->add_particle_out(p4);
//
// create v3
GenVertex* v3 = new GenVertex();
auto v3 = std::make_shared<GenVertex>();
evt->add_vertex(v3);
v3->add_particle_in(p3);
v3->add_particle_in(p4);
v3->add_particle_out(new GenParticle(FourVector(-3.813, 0.113, -1.833, 4.233), 22, 1));
GenParticle* p5 = new GenParticle(FourVector(1.517, -20.68, -20.605, 85.925), -24, 3);
v3->add_particle_out(std::make_shared<GenParticle>(FourVector(-3.813, 0.113, -1.833, 4.233), 22, 1));
auto p5 = std::make_shared<GenParticle>(FourVector(1.517, -20.68, -20.605, 85.925), -24, 3);
v3->add_particle_out(p5);
//
// create v4
GenVertex* v4 = new GenVertex(FourVector(0.12, -0.3, 0.05, 0.004));
auto v4 = std::make_shared<GenVertex>(FourVector(0.12, -0.3, 0.05, 0.004));
evt->add_vertex(v4);
v4->add_particle_in(p5);
v4->add_particle_out(new GenParticle(FourVector(-2.445, 28.816, 6.082, 29.552), 1, 1));
v4->add_particle_out(new GenParticle(FourVector(3.962, -49.498, -26.687, 56.373), -2, 1));
v4->add_particle_out(std::make_shared<GenParticle>(FourVector(-2.445, 28.816, 6.082, 29.552), 1, 1));
v4->add_particle_out(std::make_shared<GenParticle>(FourVector(3.962, -49.498, -26.687, 56.373), -2, 1));
//
// the event is complete, we now print it out to the screen
Print::content(*evt);
Expand Down

0 comments on commit a98fad0

Please sign in to comment.