Skip to content

Commit

Permalink
Adding ntupleizer test
Browse files Browse the repository at this point in the history
  • Loading branch information
kjvbrt committed Feb 28, 2024
1 parent 053794c commit b0132a3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
14 changes: 14 additions & 0 deletions cmake/FCCAnalysesFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 14 additions & 3 deletions examples/FCCee/fullSim/caloNtupleizer/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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:")
Expand Down
2 changes: 2 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit b0132a3

Please sign in to comment.