From 6a18882c0ad50f671532b767f257e8f182841be1 Mon Sep 17 00:00:00 2001 From: Juraj Smiesko Date: Thu, 19 Sep 2024 13:27:16 +0200 Subject: [PATCH] Adding C++ analysis tests --- analyzers/dataframe/src/SmearObjects.cc | 6 +- cmake/FCCAnalysesFunctions.cmake | 2 +- examples/data_source/standalone.py | 34 +++++----- man/man1/fccanalysis-run.1 | 2 +- tests/CMakeLists.txt | 43 ++----------- tests/integration/CMakeLists.txt | 59 +++++++++++++++++ .../data_source.cxx} | 64 +++++++++---------- .../data_source_associations.cxx} | 54 ++++++++-------- .../low_level_associations.cxx} | 42 ++++++------ .../low_level_edm4hep.cxx} | 48 +++++++------- tests/unittest/CMakeLists.txt | 2 +- 11 files changed, 181 insertions(+), 175 deletions(-) create mode 100644 tests/integration/CMakeLists.txt rename tests/{data_source/test_source.cxx => integration/data_source.cxx} (56%) rename tests/{data_source/test_source_associations.cxx => integration/data_source_associations.cxx} (80%) rename tests/{data_source/test_low_level_associations.cxx => integration/low_level_associations.cxx} (50%) rename tests/{data_source/test_low_level.cxx => integration/low_level_edm4hep.cxx} (58%) diff --git a/analyzers/dataframe/src/SmearObjects.cc b/analyzers/dataframe/src/SmearObjects.cc index 7c3a5056f1..27e7d29477 100644 --- a/analyzers/dataframe/src/SmearObjects.cc +++ b/analyzers/dataframe/src/SmearObjects.cc @@ -151,8 +151,7 @@ ROOT::VecOps::RVec SmearedTracks::operator()( smeared_track.covMatrix = covMatrix_edm4hep; - // if (m_debug) { - if (false) { + if (m_debug) { std::cout << std::endl << "Original track " << track.D0 << " " << track.phi << " " << track.omega << " " << track.Z0 << " " << track.tanLambda @@ -293,8 +292,7 @@ TVectorD CovSmear(TVectorD x, TMatrixDSym C, TRandom *ran, bool debug = false) { TVectorD r(Nvec); for (Int_t i = 0; i < Nvec; i++) r(i) = ran->Gaus(0.0, 1.0); // Array of normal random numbers - // if (debug) - if (false) + if (debug) std::cout << " random nb " << ran->Gaus(0.0, 1.0) << std::endl; TVectorD xOut = x + DCv * (Ut * r); // Observed parameter vector // diff --git a/cmake/FCCAnalysesFunctions.cmake b/cmake/FCCAnalysesFunctions.cmake index 86c7dbb65a..234a52605a 100644 --- a/cmake/FCCAnalysesFunctions.cmake +++ b/cmake/FCCAnalysesFunctions.cmake @@ -47,7 +47,7 @@ endfunction() function(add_generic_test _testname _testcmd) add_test(NAME ${_testname} - COMMAND ${_testcmd} + COMMAND sh -c ${_testcmd} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT diff --git a/examples/data_source/standalone.py b/examples/data_source/standalone.py index 570355bc77..522411ba8f 100644 --- a/examples/data_source/standalone.py +++ b/examples/data_source/standalone.py @@ -1,5 +1,5 @@ ''' -Standalone test of EDM4hep RDataSource in Python. +Example of standalone FCCAnalyses script using podio::DataSource. ''' import ROOT @@ -13,39 +13,37 @@ def main(): input_list = ['https://fccsw.web.cern.ch/fccsw/testsamples/edm4hep1/' 'p8_ee_WW_ecm240_edm4hep.root'] - ROOT.gSystem.Load("libFCCAnalyses") + ROOT.gSystem.Load('libFCCAnalyses') if ROOT.dummyLoader: - print('----> Debug: Found FCCAnalyses library.') - print("----> Info: Loading analyzers from libFCCAnalyses... ",) + print('----> DEBUG: Found FCCAnalyses library.') + print('----> INFO: Loading analyzers from libFCCAnalyses... ',) if ROOT.podio.DataSource: - print('----> Debug: Found Podio ROOT DataSource.') - print('----> Info: Loading events through podio::DataSource...') + print('----> DEBUG: Found Podio ROOT DataSource.') + print('----> INFO: Loading events through podio::DataSource...') try: dframe = ROOT.podio.CreateDataFrame(input_list) except TypeError as excp: - print('----> Error: Unable to build dataframe!') + print('----> ERROR: Unable to build dataframe!') print(excp) dframe2 = dframe.Define( - "electron_truth", - "recoParticle::selPDG(11)(MCRecoAssociations)") + 'electron_truth', + 'recoParticle::selPDG(11)(MCRecoAssociations)') dframe3 = dframe2.Define( - "electron_truth_pt", - "recoParticle::getPt(electron_truth)") + 'electron_truth_pt', + 'recoParticle::getPt(electron_truth)') - dframe4 = dframe3.Filter("electron_truth_pt.size() < 3") + dframe4 = dframe3.Filter('electron_truth_pt.size() < 3') count = dframe4.Count() - dframe4.Snapshot("events", "output.root", {"electron_truth_pt"}) - # dframe4.Snapshot("events", "output.root", {"electron_truth", - # "electron_truth_pt"}) + dframe4.Snapshot('events', 'output.root', ['electron_truth_pt']) - print("---------------------") - print("Nuber of events: ", count.GetValue()) + print('---------------------') + print('Number of events: ', count.GetValue()) -if __name__ == "__main__": +if __name__ == '__main__': main() diff --git a/man/man1/fccanalysis-run.1 b/man/man1/fccanalysis-run.1 index 3f7dd89939..3ef54a0873 100644 --- a/man/man1/fccanalysis-run.1 +++ b/man/man1/fccanalysis-run.1 @@ -48,7 +48,7 @@ Specify max number of events to process\&. Run over the test file\&. .TP .B \-\-use-data-source -Load events through EDM4hep RDataSource\&. +Load events through podio::DataSource\&. .TP .B \-\-bench Output benchmark results to a JSON file\&. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1509dcbe25..a55b624139 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,54 +2,21 @@ add_subdirectory(unittest) add_subdirectory(benchmark) +add_subdirectory(integration) + add_integration_test("examples/FCCee/higgs/mH-recoil/mumu/analysis_stage1.py") add_integration_test("examples/FCCee/flavour/Bc2TauNu/analysis_B2TauNu_truth.py") add_integration_test("examples/FCCee/test/jet_constituents.py") add_integration_test("examples/FCCee/vertex_lcfiplus/analysis_V0.py") +add_standalone_test("examples/FCCee/fullSim/caloNtupleizer/analysis.py") + if(WITH_SOURCE) + add_standalone_test("examples/data_source/standalone.py") add_integration_test("examples/data_source/histmaker_source.py") add_integration_test("examples/data_source/stages_source.py") add_integration_test("examples/data_source/analysis_stage1.py") - add_standalone_test("examples/data_source/standalone.py") endif() -add_standalone_test("examples/FCCee/fullSim/caloNtupleizer/analysis.py") - -# C++ Analyses - -# podio::DataSource -add_executable(test_data_source ${CMAKE_SOURCE_DIR}/tests/data_source/test_source.cxx) -target_include_directories(test_data_source PRIVATE ${CMAKE_SOURCE_DIR}/include) -target_link_libraries(test_data_source podio::podioDataSource - EDM4HEP::edm4hep -) - -add_executable(test_source_associations - ${CMAKE_SOURCE_DIR}/tests/data_source/test_source_associations.cxx) -target_include_directories(test_source_associations PRIVATE - ${CMAKE_SOURCE_DIR}/include) -target_link_libraries(test_source_associations podio::podioDataSource - EDM4HEP::edm4hep - FCCAnalyses -) - -# Low level access -add_executable(test_low_level ${CMAKE_SOURCE_DIR}/tests/data_source/test_low_level.cxx) -target_link_libraries(test_low_level ROOT::ROOTDataFrame - podio::podioDataSource - EDM4HEP::edm4hep - EDM4HEP::edm4hepDict -) - -add_executable(test_low_level_associations - ${CMAKE_SOURCE_DIR}/tests/data_source/test_low_level_associations.cxx) -target_link_libraries(test_low_level_associations ROOT::ROOTDataFrame - podio::podioDataSource - EDM4HEP::edm4hep - EDM4HEP::edm4hepDict - FCCAnalyses -) - # TODO: make this test run in the spack build environment #add_generic_test(build_new_case_study "tests/build_new_case_study.sh") diff --git a/tests/integration/CMakeLists.txt b/tests/integration/CMakeLists.txt new file mode 100644 index 0000000000..59b426f534 --- /dev/null +++ b/tests/integration/CMakeLists.txt @@ -0,0 +1,59 @@ +# Low level EDM4hep access +add_executable(low_level_edm4hep + ${CMAKE_SOURCE_DIR}/tests/integration/low_level_edm4hep.cxx +) +target_link_libraries(low_level_edm4hep ROOT::ROOTDataFrame + podio::podioDataSource + EDM4HEP::edm4hep + EDM4HEP::edm4hepDict +) +add_generic_test( + low_level_edm4hep + "${CMAKE_CURRENT_BINARY_DIR}/low_level_edm4hep 1" + "https://fccsw.web.cern.ch/fccsw/testsamples/edm4hep1/p8_ee_WW_ecm240_edm4hep.root" +) + +add_executable( + low_level_associations + ${CMAKE_SOURCE_DIR}/tests/integration/low_level_associations.cxx) +target_link_libraries(low_level_associations ROOT::ROOTDataFrame + podio::podioDataSource + EDM4HEP::edm4hep + EDM4HEP::edm4hepDict + FCCAnalyses +) +add_generic_test( + low_level_associations + "${CMAKE_CURRENT_BINARY_DIR}/low_level_associations 1" + "https://fccsw.web.cern.ch/fccsw/testsamples/edm4hep1/p8_ee_WW_ecm240_edm4hep.root" +) + +if(WITH_SOURCE) + add_executable(data_source + ${CMAKE_SOURCE_DIR}/tests/integration/data_source.cxx) + target_include_directories(data_source PRIVATE ${CMAKE_SOURCE_DIR}/include) + target_link_libraries(data_source podio::podioDataSource + EDM4HEP::edm4hep + ) + add_generic_test( + data_source + "${CMAKE_CURRENT_BINARY_DIR}/data_source 1" + "https://fccsw.web.cern.ch/fccsw/testsamples/edm4hep1/p8_ee_WW_ecm240_edm4hep.root" + ) + + add_executable( + data_source_associations + ${CMAKE_SOURCE_DIR}/tests/integration/data_source_associations.cxx + ) + target_include_directories(data_source_associations PRIVATE + ${CMAKE_SOURCE_DIR}/include) + target_link_libraries(data_source_associations podio::podioDataSource + EDM4HEP::edm4hep + FCCAnalyses + ) + add_generic_test( + data_source_associations + "${CMAKE_CURRENT_BINARY_DIR}/data_source_associations 1" + "https://fccsw.web.cern.ch/fccsw/testsamples/edm4hep1/p8_ee_WW_ecm240_edm4hep.root" + ) +endif() diff --git a/tests/data_source/test_source.cxx b/tests/integration/data_source.cxx similarity index 56% rename from tests/data_source/test_source.cxx rename to tests/integration/data_source.cxx index 1f21cfa69e..0efacd7ccf 100644 --- a/tests/data_source/test_source.cxx +++ b/tests/integration/data_source.cxx @@ -9,12 +9,12 @@ // EDM4hep #include -#include +#include #include #include #include -edm4hep::MCParticleCollection selElectrons(edm4hep::MCParticleCollection& inParticles) { +edm4hep::MCParticleCollection selElectrons(const edm4hep::MCParticleCollection& inParticles) { edm4hep::MCParticleCollection electrons; electrons.setSubsetCollection(); for (auto particle: inParticles) { @@ -28,17 +28,17 @@ edm4hep::MCParticleCollection selElectrons(edm4hep::MCParticleCollection& inPart } struct selPDG { - selPDG(int pdg = 11, bool chargeConjugateAllowed = true); + selPDG(int pdg, bool chargeConjugateAllowed); const int m_pdg; const bool m_chargeConjugateAllowed; - edm4hep::MCParticleCollection operator() (edm4hep::MCParticleCollection& inParticles); + edm4hep::MCParticleCollection operator() (const edm4hep::MCParticleCollection& inParticles); }; selPDG::selPDG(int pdg, bool chargeConjugateAllowed) : m_pdg(pdg), m_chargeConjugateAllowed(chargeConjugateAllowed) {}; -edm4hep::MCParticleCollection selPDG::operator() (edm4hep::MCParticleCollection& inParticles) { +edm4hep::MCParticleCollection selPDG::operator() (const edm4hep::MCParticleCollection& inParticles) { edm4hep::MCParticleCollection result; result.setSubsetCollection(); for (auto particle: inParticles) { @@ -57,7 +57,7 @@ edm4hep::MCParticleCollection selPDG::operator() (edm4hep::MCParticleCollection& return result; } -ROOT::VecOps::RVec getPx(edm4hep::MCParticleCollection& inParticles) { +ROOT::VecOps::RVec getPx(const edm4hep::MCParticleCollection& inParticles) { ROOT::VecOps::RVec result; for (auto particle: inParticles) { result.push_back(particle.getMomentum().x); @@ -87,12 +87,12 @@ edm4hep::MCParticleCollection get_stable_particles_from_decay(edm4hep::MCParticl edm4hep::MCParticle get_mcParticle( const edm4hep::ReconstructedParticle& recoParticle, - const edm4hep::MCRecoParticleAssociationCollection& assocColl) { + const edm4hep::RecoMCParticleLinkCollection& assocColl) { edm4hep::MCParticle no_result; for (const auto& assoc: assocColl) { - if (assoc.getRec() == recoParticle) { - return assoc.getSim(); + if (assoc.getFrom() == recoParticle) { + return assoc.getTo(); } } @@ -100,35 +100,31 @@ edm4hep::MCParticle get_mcParticle( } -int main(int argc, char *argv[]) { - // auto verbosity = ROOT::Experimental::RLogScopedVerbosity(ROOT::Detail::RDF::RDFLogChannel(), ROOT::Experimental::ELogLevel::kInfo); +int main(int argc, const char *argv[]) { + auto verbosity = ROOT::Experimental::RLogScopedVerbosity( + ROOT::Detail::RDF::RDFLogChannel(), + ROOT::Experimental::ELogLevel::kInfo + ); - int nCPU = 4; + int nThreads = 1; if (argc > 1) { - nCPU = atoi(argv[1]); + nThreads = atoi(argv[1]); } - std::vector filePathList; - std::string filePathBase = "/home/jsmiesko/source/FCCAnalyses/inputs/"; - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_10.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_11.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_12.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_1.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_2.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_3.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_4.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_5.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_6.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_7.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_8.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_9.edm4hep.root"); - - ROOT::EnableImplicitMT(nCPU); - - ROOT::RDataFrame rdf(std::make_unique(filePathList)); + if (nThreads > 1) { + ROOT::EnableImplicitMT(nThreads); + } + + std::string filePath = "https://fccsw.web.cern.ch/fccsw/testsamples/" + "edm4hep1/p8_ee_WW_ecm240_edm4hep.root"; + if (argc > 2) { + filePath = argv[2]; + } + + ROOT::RDataFrame rdf(std::make_unique(filePath)); // rdf.Describe().Print(); - std::cout << std::endl; + // std::cout << std::endl; std::cout << "Info: Num. of slots: " << rdf.GetNSlots() << std::endl; @@ -144,9 +140,9 @@ int main(int argc, char *argv[]) { auto canvas = std::make_unique("canvas", "Canvas", 450, 450); h_particles_px->Draw(); - canvas->Print("source_particles_px.pdf"); + canvas->Print("/tmp/source_particles_px.pdf"); h_electrons_px->Draw(); - canvas->Print("source_electrons_px.pdf"); + canvas->Print("/tmp/source_electrons_px.pdf"); return EXIT_SUCCESS; } diff --git a/tests/data_source/test_source_associations.cxx b/tests/integration/data_source_associations.cxx similarity index 80% rename from tests/data_source/test_source_associations.cxx rename to tests/integration/data_source_associations.cxx index bf743034ee..18df8a7b8b 100644 --- a/tests/data_source/test_source_associations.cxx +++ b/tests/integration/data_source_associations.cxx @@ -23,7 +23,7 @@ #include "edm4hep/TrackState.h" #include "edm4hep/TrackCollection.h" #include "edm4hep/ReconstructedParticleCollection.h" -#include "edm4hep/MCRecoParticleAssociationCollection.h" +#include "edm4hep/RecoMCParticleLinkCollection.h" // FCCAnalyses #include "FCCAnalyses/SmearObjects.h" @@ -68,7 +68,7 @@ struct SmearedTracks { float smear_z0, float smear_tlambda, bool debug); ROOT::VecOps::RVec operator()( - const edm4hep::MCRecoParticleAssociationCollection &mcRecoAssoc); + const edm4hep::RecoMCParticleLinkCollection &mcRecoLink); }; @@ -88,7 +88,7 @@ SmearedTracks::SmearedTracks(float smear_d0, float smear_phi, float smear_omega, ROOT::VecOps::RVec SmearedTracks::operator() ( - const edm4hep::MCRecoParticleAssociationCollection &mcRecoAssoc) { + const edm4hep::RecoMCParticleLinkCollection &mcRecoLink) { // returns a vector of TrackStates that is parallel to the collection of full // tracks (alltracks), i.e. same number of entries, same order. The method @@ -105,9 +105,9 @@ SmearedTracks::operator() ( zero(k) = 0.; } - for (const auto &assoc : mcRecoAssoc) { - const auto &recoParticle = assoc.getRec(); - const auto &mcParticle = assoc.getSim(); + for (const auto &assoc : mcRecoLink) { + const auto &recoParticle = assoc.getFrom(); + const auto &mcParticle = assoc.getTo(); if (recoParticle.getTracks().size() < 1) { continue; @@ -225,7 +225,10 @@ SmearedTracks::operator() ( int main(int argc, char *argv[]) { - // auto verbosity = ROOT::Experimental::RLogScopedVerbosity(ROOT::Detail::RDF::RDFLogChannel(), ROOT::Experimental::ELogLevel::kInfo); + auto verbosity = ROOT::Experimental::RLogScopedVerbosity( + ROOT::Detail::RDF::RDFLogChannel(), + ROOT::Experimental::ELogLevel::kInfo + ); bool success = gInterpreter->Declare("#include \"edm4hep/TrackState.h\""); if (!success) { @@ -234,32 +237,25 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; } - int nCPU = 4; + int nThreads = 1; if (argc > 1) { - nCPU = atoi(argv[1]); + nThreads = atoi(argv[1]); + } + + if (nThreads > 1) { + ROOT::EnableImplicitMT(nThreads); + } + + std::string filePath = "https://fccsw.web.cern.ch/fccsw/testsamples/" + "edm4hep1/p8_ee_WW_ecm240_edm4hep.root"; + if (argc > 2) { + filePath = argv[2]; } - std::vector filePathList; - std::string filePathBase = "/home/jsmiesko/source/FCCAnalyses/inputs/"; - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_10.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_11.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_12.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_1.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_2.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_3.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_4.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_5.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_6.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_7.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_8.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_9.edm4hep.root"); - - ROOT::EnableImplicitMT(nCPU); - - ROOT::RDataFrame rdf(std::make_unique(filePathList)); + ROOT::RDataFrame rdf(std::make_unique(filePath)); // rdf.Describe().Print(); - std::cout << std::endl; + // std::cout << std::endl; std::cout << "Info: Num. of slots: " << rdf.GetNSlots() << std::endl; @@ -277,7 +273,7 @@ int main(int argc, char *argv[]) { auto canvas = std::make_unique("canvas", "Canvas", 450, 450); h_smeared_tracks_omega->Draw(); - canvas->Print("source_smeared_tracks_omega.pdf"); + canvas->Print("/tmp/source_smeared_tracks_omega.pdf"); return EXIT_SUCCESS; } diff --git a/tests/data_source/test_low_level_associations.cxx b/tests/integration/low_level_associations.cxx similarity index 50% rename from tests/data_source/test_low_level_associations.cxx rename to tests/integration/low_level_associations.cxx index b21ffabe1e..6a14bc67df 100644 --- a/tests/data_source/test_low_level_associations.cxx +++ b/tests/integration/low_level_associations.cxx @@ -11,8 +11,11 @@ #include "FCCAnalyses/ReconstructedParticle2MC.h" -int main(int argc, char *argv[]) { - // auto verbosity = ROOT::Experimental::RLogScopedVerbosity(ROOT::Detail::RDF::RDFLogChannel(), ROOT::Experimental::ELogLevel::kInfo); +int main(int argc, const char *argv[]) { + auto verbosity = ROOT::Experimental::RLogScopedVerbosity( + ROOT::Detail::RDF::RDFLogChannel(), + ROOT::Experimental::ELogLevel::kInfo + ); bool success = gInterpreter->Declare("#include \"edm4hep/TrackState.h\""); if (!success) { @@ -21,37 +24,30 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; } - int nCPU = 4; + int nThreads = 1; if (argc > 1) { - nCPU = atoi(argv[1]); + nThreads = atoi(argv[1]); } - std::vector filePathList; - std::string filePathBase = "/home/jsmiesko/source/FCCAnalyses/inputs/"; - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_10.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_11.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_12.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_1.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_2.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_3.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_4.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_5.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_6.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_7.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_8.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_9.edm4hep.root"); + if (nThreads > 1) { + ROOT::EnableImplicitMT(nThreads); + } - ROOT::EnableImplicitMT(nCPU); + std::string filePath = "https://fccsw.web.cern.ch/fccsw/testsamples/" + "edm4hep1/p8_ee_WW_ecm240_edm4hep.root"; + if (argc > 2) { + filePath = argv[2]; + } - ROOT::RDataFrame rdf("events", filePathList); + ROOT::RDataFrame rdf("events", filePath); // rdf.Describe().Print(); // std::cout << std::endl; std::cout << "Info: Num. of slots: " << rdf.GetNSlots() << std::endl; - auto rdf2 = rdf.Alias("MCRecoAssociations0", "_MCRecoAssociations_rec.index"); - auto rdf3 = rdf2.Alias("MCRecoAssociations1", "_MCRecoAssociations_sim.index"); + auto rdf2 = rdf.Alias("MCRecoAssociations0", "_MCRecoAssociations_from.index"); + auto rdf3 = rdf2.Alias("MCRecoAssociations1", "_MCRecoAssociations_to.index"); auto rdf4 = rdf3.Define( "RP_MC_index", FCCAnalyses::ReconstructedParticle2MC::getRP2MC_index, @@ -71,7 +67,7 @@ int main(int argc, char *argv[]) { auto canvas = std::make_unique("canvas", "Canvas", 450, 450); h_smeared_tracks_omega->Draw(); - canvas->Print("low_level_smeared_tracks_omega.pdf"); + canvas->Print("/tmp/low_level_smeared_tracks_omega.pdf"); return EXIT_SUCCESS; } diff --git a/tests/data_source/test_low_level.cxx b/tests/integration/low_level_edm4hep.cxx similarity index 58% rename from tests/data_source/test_low_level.cxx rename to tests/integration/low_level_edm4hep.cxx index 79baa8b6bd..659f0f47d3 100644 --- a/tests/data_source/test_low_level.cxx +++ b/tests/integration/low_level_edm4hep.cxx @@ -19,7 +19,7 @@ ROOT::VecOps::RVec selElectrons(ROOT::VecOps::RVec operator() (ROOT::VecOps::RVec& inParticles); @@ -58,35 +58,31 @@ ROOT::VecOps::RVec getPx(ROOT::VecOps::RVec inPa } -int main(int argc, char *argv[]) { - // auto verbosity = ROOT::Experimental::RLogScopedVerbosity(ROOT::Detail::RDF::RDFLogChannel(), ROOT::Experimental::ELogLevel::kInfo); +int main(int argc, const char *argv[]) { + auto verbosity = ROOT::Experimental::RLogScopedVerbosity( + ROOT::Detail::RDF::RDFLogChannel(), + ROOT::Experimental::ELogLevel::kInfo + ); - int nCPU = 4; + int nThreads = 1; if (argc > 1) { - nCPU = atoi(argv[1]); + nThreads = atoi(argv[1]); } - std::vector filePathList; - std::string filePathBase = "/home/jsmiesko/source/FCCAnalyses/inputs/"; - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_10.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_11.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_12.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_1.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_2.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_3.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_4.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_5.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_6.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_7.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_8.edm4hep.root"); - filePathList.emplace_back(filePathBase + "p8_ee_WW_ecm240/p8_ee_WW_ecm240_9.edm4hep.root"); - - ROOT::EnableImplicitMT(nCPU); - - ROOT::RDataFrame rdf("events", filePathList); + if (nThreads > 1) { + ROOT::EnableImplicitMT(nThreads); + } + + std::string filePath = "https://fccsw.web.cern.ch/fccsw/testsamples/" + "edm4hep1/p8_ee_WW_ecm240_edm4hep.root"; + if (argc > 2) { + filePath = argv[2]; + } + + ROOT::RDataFrame rdf("events", filePath); // rdf.Describe().Print(); - std::cout << std::endl; + // std::cout << std::endl; std::cout << "Info: Num. of slots: " << rdf.GetNSlots() << std::endl; @@ -102,9 +98,9 @@ int main(int argc, char *argv[]) { auto canvas = std::make_unique("canvas", "Canvas", 450, 450); h_particles_px->Draw(); - canvas->Print("low_level_particles_px.pdf"); + canvas->Print("/tmp/low_level_particles_px.pdf"); h_electrons_px->Draw(); - canvas->Print("low_level_electrons_px.pdf"); + canvas->Print("/tmp/low_level_electrons_px.pdf"); return EXIT_SUCCESS; } diff --git a/tests/unittest/CMakeLists.txt b/tests/unittest/CMakeLists.txt index 0403208297..4f364b052b 100644 --- a/tests/unittest/CMakeLists.txt +++ b/tests/unittest/CMakeLists.txt @@ -1,6 +1,6 @@ find_catch_instance() -# The unittests are a bit better and they are labelled so we can put together a +# The unittests are a bit better and they are labeled so we can put together a # list of labels that we want to ignore set(filter_tests "")