-
Notifications
You must be signed in to change notification settings - Fork 10
Experimental: Implement feature of hit animation #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7ac4b1a
1c7ab7b
8c16491
73e821c
2232170
d7c1ec4
85a8fde
0fe99f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,6 +150,9 @@ In any Processor: | |
| // float x1,float y1,float z1, | ||
| // unsigned type,unsigned width,unsigned color); | ||
|
|
||
| // hit rendering is delayed by the time "t" (in seconds). Produce animation effect. "Show FPS" must be switched on. | ||
| // void ced_hit_ID_animate(float x,float y,float z, float t, unsigned type, unsigned size, unsigned color, unsigned id); | ||
|
|
||
|
|
||
| to define colors is better use gimp - it gives that crasy numbers easily | ||
|
|
||
|
|
@@ -178,9 +181,79 @@ to define colors is better use gimp - it gives that crasy numbers easily | |
| // at the end of event | ||
| ced_draw_event(); // Make clean up screen before drawing | ||
|
|
||
| ## Using the CED client library with EDM4hep files in python: | ||
|
|
||
| One must use key4hep environment, e.g.: | ||
| ```bash | ||
| source /cvmfs/sw.hsf.org/key4hep/setup.sh | ||
| # or | ||
| # source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh | ||
| ``` | ||
|
|
||
| ```python | ||
| import os | ||
| import cppyy | ||
| from podio import root_io | ||
|
|
||
| # User Config | ||
| COMPACT_PATH="<path-to-compact-file>" | ||
| EDM4HEP_FILE = "<path-to-edm4hep-file>" | ||
| TRACKER_HIT_COLS = ["<name-of-tracker-hit-col-1>", "<name-of-tracker-hit-col-2>", "<...>"] | ||
| CALO_HIT_COLS = ["<name-of-calo-hit-col-1>", "<name-of-calo-hit-col-2>", "<...>"] | ||
|
|
||
| # Load dependencies | ||
| for path in os.environ["CMAKE_PREFIX_PATH"].split(":"): | ||
| inlcude_dir = os.path.join(path, "include") | ||
| if os.path.isdir(inlcude_dir): | ||
| cppyy.add_include_path( inlcude_dir ) | ||
|
|
||
| if "/marlinutil/" in path: | ||
| cppyy.add_include_path( os.path.join(path, "include", "marlinutil") ) | ||
|
Comment on lines
+205
to
+211
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably don't need all of them, I would assume, but writing that filtering in this example is probably too much details.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we definitely don't need all of them. I, actually would love to filter them here, but if I start from a small subset of libs, the seg. faults are quite cryptic so, for me it is even hard to add libs one-by-one... Ideally, if The fact that the # Load dependencies
libs = ["ced", "dd4hep", "marlinutil", "<libs-DDMarlinCED-depends-on>"]
for path in os.environ["CMAKE_PREFIX_PATH"].split(":"):
if not any(lib in path for lib in libs):
continue
inlcude_dir = os.path.join(path, "include")
if os.path.isdir(inlcude_dir):
cppyy.add_include_path( inlcude_dir )
if "/marlinutil/" in path:
cppyy.add_include_path( os.path.join(path, "include", "marlinutil") ) |
||
|
|
||
| cppyy.include("ced_cli.h") | ||
| cppyy.include("DDMarlinCED.h") | ||
| from cppyy.gbl import ced_client_init, ced_register_elements | ||
| from cppyy.gbl import ced_new_event, ced_send_event, ced_selected_id_noblock | ||
| from cppyy.gbl import ced_hit_ID, ced_hit_ID_animate, CED_HIT_POINT | ||
| std = cppyy.gbl.std | ||
| DDMarlinCED = cppyy.gbl.DDMarlinCED | ||
|
|
||
| det_compact_file = os.path.join( os.environ["k4geo_DIR"], COMPACT_PATH ) | ||
| detector = cppyy.gbl.dd4hep.Detector.getInstance() | ||
| detector.fromCompact(det_compact_file) | ||
|
|
||
| ced_client_init("localhost", 7286) | ||
| ced_register_elements() | ||
|
|
||
| reader = root_io.Reader(EDM4HEP_FILE) | ||
| for event in reader.get("events"): | ||
| ced_new_event() | ||
|
|
||
| DDMarlinCED.drawDD4hepDetector( detector, False, std.vector[std.string]() ) | ||
|
|
||
| layer = 1 # layer under which hits are displayed | ||
| animated_layer = 2 | ||
| size = 5 # size of the hits | ||
| color = 0x000000 # hex color of the hits | ||
| # Draw all reconstructed hits in layer #1 and animate them in layer #2 | ||
| for col in TRACKER_HIT_COLS + CALO_HIT_COLS: | ||
| for hit in event.get(col): | ||
| pos = hit.getPosition() | ||
| t = hit.getTime() | ||
| ced_hit_ID(pos.x, pos.y, pos.z, CED_HIT_POINT, layer, size, color, 0) | ||
| ced_hit_ID_animate(pos.x, pos.y, pos.z, t, CED_HIT_POINT, animated_layer, size, color, 0) | ||
|
|
||
| ced_send_event() | ||
|
|
||
| # ced_selected_id_noblock() can be used to return id of the picked object. | ||
| # A more involved example with kbhit instead of pyhton's input() would be needed to use it. | ||
| # picked_id = ced_selected_id_noblock() | ||
|
|
||
| input("Press enter to draw next event") | ||
| ``` | ||
|
|
||
| ## License and Copyright | ||
| Copyright (C) 2005-2017, CED Authors | ||
| Copyright (C) 2005-2026, CED Authors | ||
|
|
||
| CED is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.