Skip to content

Commit

Permalink
Run a test to create an RNTuple EDM4hep file
Browse files Browse the repository at this point in the history
and add explanations in the README.
  • Loading branch information
jmcarcell committed Aug 27, 2024
1 parent 7ffc2d4 commit f796f4c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ with tools that consume JSON.
Use `edm4hep2json --help` to see the available options for selecting which parts
of the input file should be part of the output.

## Example files

Example EDM4hep files can be obtained from the Continuous Integration (CI)
workflows. From the EDM4hep github page, go to Actions -> Key4hep build, click
one of the runs (the latest scheduled is preferred) and they will appear at the
bottom, under Artifacts.


## Contributing

Contributions and bug reports are welcome! See our [contributing guidelines](doc/contributing.md) if you want to contribute code to EDM4hep.
10 changes: 5 additions & 5 deletions scripts/createEDM4hepFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
frames = 3 # How many frames or events will be written
vectorsize = 5 # For vector members, each vector member will have this size
counter = count() # next(counter) will return 0, 1, 2, ...
# used to generate the dummy data
output_file = "output.root"

parser = argparse.ArgumentParser(description="Create a file with EDM4hep data")
parser.add_argument(
"--rntuple", action="store_true", help="Use a ROOT ntuple instead of EDM4hep"
)
parser.add_argument(
"--output-file", type=str, help="Output file name", default="edm4hep.root"
)
args = parser.parse_args()
output_file = args.output_file

if args.rntuple:
try:
Expand Down Expand Up @@ -78,9 +80,7 @@
particle.setMomentumAtEndpoint(
edm4hep.Vector3d(next(counter), next(counter), next(counter))
)
particle.setSpin(
edm4hep.Vector3f(next(counter), next(counter), next(counter))
)
particle.setSpin(edm4hep.Vector3f(next(counter), next(counter), next(counter)))
particle.setColorFlow(edm4hep.Vector2i(next(counter), next(counter)))

particles[0].addToDaughters(particles[1])
Expand Down
5 changes: 4 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ function(set_test_env _testname)
)
endfunction()

add_test(NAME "Create an EDM4hep data file" COMMAND python ${PROJECT_SOURCE_DIR}/scripts/createEDM4hepFile.py)
add_test(NAME "Create an EDM4hep data file" COMMAND python ${PROJECT_SOURCE_DIR}/scripts/createEDM4hepFile.py --output-file edm4hep_example.root)
set_test_env("Create an EDM4hep data file")

add_test(NAME "Create an EDM4hep data file (RNTuple)" COMMAND python ${PROJECT_SOURCE_DIR}/scripts/createEDM4hepFile.py --rntuple --output-file edm4hep_example_rntuple.root)
set_test_env("Create an EDM4hep data file (RNTuple)")

add_executable(write_events write_events.cc)
target_include_directories(write_events PUBLIC ${PROJECT_SOURCE_DIR}/edm4hep )
target_link_libraries(write_events edm4hep podio::podioRootIO)
Expand Down

0 comments on commit f796f4c

Please sign in to comment.