diff --git a/CMakeLists.txt b/CMakeLists.txt index 19a80d224de..8de1cad5ecf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,9 @@ option(USE_EXTERNAL_CATCH2 "Link against an external Catch2 v3 static library, o option(FCCANALYSES_DOCUMENTATION "Whether or not to create doxygen doc target." ON) +set(WITH_SOURCE ON CACHE STRING "Enable EDM4hep RDataSource") +set_property(CACHE WITH_SOURCE PROPERTY STRINGS ON OFF) + #--- Set a better default for installation directory--------------------------- if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}/install" CACHE PATH "default install path" FORCE) @@ -147,7 +150,9 @@ install(DIRECTORY examples DESTINATION ${CMAKE_INSTALL_PREFIX}/share/examples) #--- Descend into subdirectories ---------------------------------------------- -add_subdirectory(e4hsource) +if(WITH_SOURCE) + add_subdirectory(e4hsource) +endif() set(ADDONS_LIBRARIES CACHE STRING "List of external libraries the RDF utilities will be linked against") add_subdirectory(addons) diff --git a/analyzers/dataframe/FCCAnalyses/Association.h b/analyzers/dataframe/FCCAnalyses/Association.h index 2c28725745e..41a4dded61d 100644 --- a/analyzers/dataframe/FCCAnalyses/Association.h +++ b/analyzers/dataframe/FCCAnalyses/Association.h @@ -13,7 +13,7 @@ namespace FCCAnalyses :: Association { * \param pdg Desired PDG ID of the partile. */ struct sel_PDG { - sel_PDG(const int pdg); + explicit sel_PDG(const int pdg); const int m_pdg; template T operator() ( @@ -30,7 +30,7 @@ namespace FCCAnalyses :: Association { struct sel_absPDG { const int m_pdg; - sel_absPDG(const int pdg) : m_pdg(pdg) { + explicit sel_absPDG(const int pdg) : m_pdg(pdg) { if (m_pdg < 0) { throw std::invalid_argument( "Association::sel_absPDG: Received negative value!"); @@ -61,7 +61,7 @@ namespace FCCAnalyses :: Association { * \param pdg Desired generator status of the partile. */ struct sel_genStatus { - sel_genStatus(const int status); + explicit sel_genStatus(const int status); const int m_status; template T operator() ( diff --git a/e4hsource/src/EDM4hepDataSource.cxx b/e4hsource/src/EDM4hepDataSource.cxx index 5edc8bf770b..7d359686f3f 100644 --- a/e4hsource/src/EDM4hepDataSource.cxx +++ b/e4hsource/src/EDM4hepDataSource.cxx @@ -50,15 +50,15 @@ namespace FCCAnalyses { for (const auto& filePath : m_filePathList) { // Check if file exists - if (!std::filesystem::exists(filePath)) { - throw std::runtime_error("EDM4hepDataSource: Provided file \"" - + filePath + "\" does not exist!"); - } + // Warning: file can be coming from web or eos + // if (!std::filesystem::exists(filePath)) { + // throw std::runtime_error("EDM4hepDataSource: Provided file \"" + // + filePath + "\" does not exist!"); + // } // Check if the provided file contains required metadata - TFile infile = TFile(filePath.data(), "READ"); - auto metadata = infile.Get("podio_metadata"); - infile.Close(); + std::unique_ptr inFile(TFile::Open(filePath.data(), "READ")); + auto metadata = inFile->Get("podio_metadata"); if (!metadata) { throw std::runtime_error( "EDM4hepDataSource: Provided file is missing podio metadata!"); diff --git a/e4hsource/src/EDM4hepLegacySource.cxx b/e4hsource/src/EDM4hepLegacySource.cxx index b4b87ca875c..46951d106fe 100644 --- a/e4hsource/src/EDM4hepLegacySource.cxx +++ b/e4hsource/src/EDM4hepLegacySource.cxx @@ -50,10 +50,11 @@ namespace FCCAnalyses { for (const auto& filePath : m_filePathList) { // Check if file exists - if (!std::filesystem::exists(filePath)) { - throw std::runtime_error("EDM4hepLegacySource: Provided file \"" + filePath - + "\" does not exist!"); - } + // File can be comming from remote + // if (!std::filesystem::exists(filePath)) { + // throw std::runtime_error("EDM4hepLegacySource: Provided file \"" + filePath + // + "\" does not exist!"); + // } // Check if the provided file contains required metadata TFile infile = TFile(filePath.data(), "READ"); diff --git a/e4hsource/test/stages_source.py b/e4hsource/test/stages_source.py index 78a68b14b3a..867caf9d7be 100644 --- a/e4hsource/test/stages_source.py +++ b/e4hsource/test/stages_source.py @@ -16,8 +16,8 @@ # How to read input files useDataSource = True -testFile = '/eos/experiment/fcc/ee/generation/DelphesEvents/winter2023/' \ - 'IDEA/p8_ee_WW_ecm240/events_192112516.root' +testFile = 'https://fccsw.web.cern.ch/fccsw/testsamples/fccanalyses/' \ + 'events_192112516.root' # RDFanalysis class where the use defines the operations on the TTree # (mandatory) diff --git a/man/man1/fccanalysis-build.1 b/man/man1/fccanalysis-build.1 index 517166dfa74..c494649ef9d 100644 --- a/man/man1/fccanalysis-build.1 +++ b/man/man1/fccanalysis-build.1 @@ -8,6 +8,7 @@ [\fB\-h\fR | \fB\-\-help\fR] [\fB\-c\fR] [\fB\-j\fR \fIBUILD_THREADS\fR] +[\fB\-\-no\-source\fR] .SH DESCRIPTION .B fccanalysis\-build will build the whole FCCAnalyses framework\&. @@ -24,7 +25,10 @@ Prints short help message and exits\&. Completely clean build directory before compilation\&. .TP \fB\-j\fR \fIBUILD_THREADS\fR, \fB\-\-build\-threads\fR \fIBUILD_THREADS\fR -Specify number of threads used when compiling (equivalent to `make -j`) +Specify number of threads used when compiling (equivalent to `make -j`)\&. +.TP +.B \-\-no\-source +Do not build EDM4hep RDataSource\&. .SH SEE ALSO fccanalysis(1), fccanalysis\-test(7), cmake(1) .SH BUGS diff --git a/python/build_analysis.py b/python/build_analysis.py index 16777630b42..15ad6273035 100644 --- a/python/build_analysis.py +++ b/python/build_analysis.py @@ -61,9 +61,13 @@ def build_analysis(mainparser): LOGGER.info('Creating build directory...') os.makedirs(build_path) - run_subprocess(['cmake', '-DCMAKE_INSTALL_PREFIX=../install', - '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON', '..'], - local_dir + '/build') + build_cmd = ['cmake', '..', '-DCMAKE_INSTALL_PREFIX=../install', + '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON'] + + if args.no_source: + build_cmd += ['-DWITH_SOURCE=OFF'] + + run_subprocess(build_cmd, local_dir + '/build') if not install_path.is_dir(): LOGGER.info('Creating install directory...') diff --git a/python/parsers.py b/python/parsers.py index 63332f703c2..30082e22e77 100644 --- a/python/parsers.py +++ b/python/parsers.py @@ -47,6 +47,12 @@ def setup_build_parser(parser): default=1, help='number of threads when building (equivalent to `make -j`)' ) + build_args.add_argument( + '--no-source', + action='store_true', + default=False, + help='do not build EDM4hep RDataSource' + ) def setup_test_parser(parser): diff --git a/python/run_analysis.py b/python/run_analysis.py index ff56f1f1d00..b8a661f4353 100644 --- a/python/run_analysis.py +++ b/python/run_analysis.py @@ -316,7 +316,11 @@ def run_rdf(rdf_module, ''' if args.use_data_source: LOGGER.info('Loading events through EDM4hep RDataSource...') - ROOT.gSystem.Load("libe4hsource") + if ROOT.gSystem.Load("libe4hsource") < 0: + LOGGER.error('Unable to load EDM4hep RDataSource library!\n' + 'Aborting...') + sys.exit(3) + if ROOT.loadEDM4hepDataSource(): LOGGER.debug('EDM4hep RDataSource loaded.') try: @@ -337,7 +341,7 @@ def run_rdf(rdf_module, 'RDataSource!\n%s', excp) sys.exit(3) else: - dframe = ROOT.RDataFrame("events", input_list) + dframe = ROOT.RDataFrame("events", input_list) # limit number of events processed if args.nevents > 0: @@ -788,7 +792,11 @@ def run_histmaker(args, rdf_module, anapath): if args.use_data_source: LOGGER.info('Loading events through EDM4hep RDataSource...') - ROOT.gSystem.Load("libe4hsource") + if ROOT.gSystem.Load("libe4hsource") < 0: + LOGGER.error('Unable to load EDM4hep RDataSource library!\n' + 'Aborting...') + sys.exit(3) + if ROOT.loadEDM4hepDataSource(): LOGGER.debug('EDM4hep RDataSource loaded.') try: diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 62410fc7d9f..91fd67d7632 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,10 +6,13 @@ 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_integration_test("e4hsource/test/histmaker_source.py") -add_integration_test("e4hsource/test/stages_source.py") -add_standalone_test("e4hsource/test/standalone.py") -# add_standalone_test("e4hsource/test/standalone_legacy.py") + +if(WITH_SOURCE) + add_integration_test("e4hsource/test/histmaker_source.py") + add_integration_test("e4hsource/test/stages_source.py") + add_standalone_test("e4hsource/test/standalone.py") + # add_standalone_test("e4hsource/test/standalone_legacy.py") +endif() add_standalone_test("examples/FCCee/fullSim/caloNtupleizer/analysis.py") diff --git a/tests/unittest/CMakeLists.txt b/tests/unittest/CMakeLists.txt index 485ff7e46bf..0403208297c 100644 --- a/tests/unittest/CMakeLists.txt +++ b/tests/unittest/CMakeLists.txt @@ -9,7 +9,9 @@ add_executable(unittest unittest.cpp algorithms.cpp ReconstructedParticle.cpp ) -target_link_libraries(unittest PUBLIC FCCAnalyses gfortran PRIVATE Catch2::Catch2WithMain) +target_link_libraries(unittest PUBLIC FCCAnalyses + gfortran + PRIVATE Catch2::Catch2WithMain) target_include_directories(unittest PUBLIC ${VDT_INCLUDE_DIR}) target_compile_definitions(unittest PUBLIC "-DTEST_INPUT_DATA_DIR=${TEST_INPUT_DATA_DIR}") include(Catch)