diff --git a/cmake/FCCAnalysesFunctions.cmake b/cmake/FCCAnalysesFunctions.cmake index ee0dd42740..bba689564c 100644 --- a/cmake/FCCAnalysesFunctions.cmake +++ b/cmake/FCCAnalysesFunctions.cmake @@ -58,6 +58,20 @@ function(add_generic_test _testname _testcmd) TEST_INPUT_DATA_DIR=${TEST_INPUT_DATA_DIR}) endfunction() +function(add_standalone_test _testname) + add_test(NAME fccanalysis_standalone_${_testname} + COMMAND python ${_testname} --test + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + set_property(TEST fccanalysis_standalone_${_testname} APPEND PROPERTY ENVIRONMENT + LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/e4hsource:${CMAKE_BINARY_DIR}/analyzers/dataframe:$ENV{LD_LIBRARY_PATH} + PYTHONPATH=${CMAKE_SOURCE_DIR}/python:$ENV{PYTHONPATH} + PATH=${CMAKE_SOURCE_DIR}/bin:${CMAKE_BINARY_DIR}:$ENV{PATH} + ROOT_INCLUDE_PATH=${CMAKE_BINARY_DIR}/e4hsource:${CMAKE_SOURCE_DIR}/analyzers/dataframe:$ENV{ROOT_INCLUDE_PATH} + TEST_INPUT_DATA_DIR=${TEST_INPUT_DATA_DIR} + ) +endfunction() + macro(fccanalyses_addon_build _name) set(options) set(one_val) diff --git a/examples/FCCee/fullSim/caloNtupleizer/analysis.py b/examples/FCCee/fullSim/caloNtupleizer/analysis.py index 27ef7ae63a..c2a56f14e8 100644 --- a/examples/FCCee/fullSim/caloNtupleizer/analysis.py +++ b/examples/FCCee/fullSim/caloNtupleizer/analysis.py @@ -20,7 +20,11 @@ def str2bool(v): parser = argparse.ArgumentParser() -parser.add_argument("-inputFiles", default = 'ALLEGRO_sim_digi_reco.root', help = "Input rootfiles (can be a single file or a regex)", type = str) +parser.add_argument("-inputFiles", type=str, + default='ALLEGRO_sim_digi_reco.root', + help="Input rootfiles (can be a single file or a regex)") +parser.add_argument("-t", "--test", action="store_true", default=False, + help="Run over pre-defined test file") parser.add_argument("-outputFolder", default = os.path.join("outputs", date.today().strftime("%y%m%d")), help = "Output folder for the rootfiles", type = str) parser.add_argument("-storeCellBranches", default = True, help="Whether or not to store cell information", type = str2bool) parser.add_argument("-cellBranchNames", default = ["ECalBarrelPositionedCells"], help="Name of the cell branch in the input rootfile. Must have position information!", type = str) @@ -29,7 +33,8 @@ def str2bool(v): parser.add_argument("-storeClusterCellsBranches", default = False, help="Whether or not to store cluster cells information", type = str2bool) parser.add_argument("-clusterCellsBranchNames", default = ["PositionedCaloClusterCells"], help="Name of the cluster-attached-cells branches in the input rootfile. Order must follow -clusterBranchNames and the cells must have positions attached!", type = str, nargs = '+') parser.add_argument("-storeGenBranches", default = True, help="Whether or not to store gen information", type = str2bool) -parser.add_argument("-genBranchName", default = "MCParticles", help="Name of the gen particle branch in the input rootfile", type = str) +parser.add_argument("-genBranchName", type=str, default="MCParticles", + help="Name of the gen particle branch in the input rootfile") parser.add_argument("-storeSimParticleSecondaries", default = False, help="Whether to store the SimParticleSecondaries information", type = str2bool) parser.add_argument("-simParticleSecondariesNames", default = ["SimParticleSecondaries"], help = "name of the SimParticleSecondaries branch", type = str, nargs = '+') parser.add_argument("-useGeometry", default = True, help="Whether or not to load the FCCSW geometry. Used to get the detector segmentation for e.g. the definition of the cell layer index.", type = str2bool) @@ -191,8 +196,14 @@ def run(self): df2.Snapshot("events", self.outname, branchList) +if args.test: + filelist = ["https://fccsw.web.cern.ch/fccsw/testsamples/fccanalyses/ALLEGRO_sim_digi_reco.root"] +else: + filelist = glob.glob(args.inputFiles) -filelist = glob.glob(args.inputFiles) +if not filelist: + print('No input found! Aborting...') + sys.exit(3) fileListRoot = ROOT.vector('string')() print ("Input files:") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9cae25a5d1..45361f115a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,5 +7,7 @@ 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") + # TODO: make this test run in the spack build environment #add_generic_test(build_new_case_study "tests/build_new_case_study.sh")