Skip to content

Commit d01aa7c

Browse files
committed
Add a test with the clic reconstruction
1 parent 9ecff5e commit d01aa7c

File tree

3 files changed

+48
-30
lines changed

3 files changed

+48
-30
lines changed

k4MarlinWrapper/examples/clicRec_e4h_input.py

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
from Configurables import LcioEvent, MarlinProcessorWrapper
2525
from k4MarlinWrapper.parseConstants import *
2626

27+
from Configurables import ToolSvc, Lcio2EDM4hepTool, EDM4hep2LcioTool
28+
from Configurables import k4DataSvc, PodioInput, PodioOutput, EventDataSvc
29+
30+
from k4FWCore import ApplicationMgr, IOSvc
31+
2732
algList = []
2833

2934

@@ -33,22 +38,32 @@
3338

3439
parseConstants(CONSTANTS)
3540

36-
37-
# For converters
38-
from Configurables import ToolSvc, Lcio2EDM4hepTool, EDM4hep2LcioTool
39-
40-
41-
from Configurables import k4DataSvc, PodioInput
42-
43-
evtsvc = k4DataSvc("EventDataSvc")
44-
evtsvc.input = os.path.join(
45-
"$TEST_DIR/inputFiles/", os.environ.get("INPUTFILE", "ttbar_edm4hep_frame.root")
41+
parser.add_argument(
42+
"--iosvc", action="store_true", default=False, help="Use IOSvc instead of PodioDataSvc"
4643
)
47-
48-
49-
inp = PodioInput("InputReader")
50-
inp.OutputLevel = DEBUG
51-
44+
parser.add_argument("--rec-output", default=False, help="Output file name for the REC file")
45+
parser.add_argument("--dst-output", default=False, help="Output file name for the DST file")
46+
47+
args = parser.parse_known_args()[0]
48+
49+
if args.iosvc:
50+
evtsvc = EventDataSvc("EventDataSvc")
51+
iosvc = IOSvc()
52+
iosvc.Input = os.path.join(
53+
"$TEST_DIR/inputFiles/", os.environ.get("INPUTFILE", "ttbar_edm4hep_frame.root")
54+
)
55+
iosvc.Output = "my_output.root"
56+
else:
57+
evtsvc = k4DataSvc("EventDataSvc")
58+
evtsvc.input = os.path.join(
59+
"$TEST_DIR/inputFiles/", os.environ.get("INPUTFILE", "ttbar_edm4hep_frame.root")
60+
)
61+
62+
inp = PodioInput("InputReader")
63+
inp.OutputLevel = DEBUG
64+
65+
out = PodioOutput("PodioOutput", filename="my_output.root")
66+
out.outputCommands = ["keep *"]
5267

5368
MyAIDAProcessor = MarlinProcessorWrapper("MyAIDAProcessor")
5469
MyAIDAProcessor.OutputLevel = WARNING
@@ -2429,14 +2444,6 @@
24292444
}
24302445

24312446

2432-
# Write output to EDM4hep
2433-
from Configurables import PodioOutput
2434-
2435-
out = PodioOutput("PodioOutput", filename="my_output.root")
2436-
out.outputCommands = ["keep *"]
2437-
2438-
2439-
algList.append(inp)
24402447
algList.append(MyAIDAProcessor)
24412448
algList.append(EventNumber)
24422449
algList.append(InitDD4hep)
@@ -2486,8 +2493,8 @@
24862493
# # algList.append(VertexFinderUnconstrained) # Config.VertexUnconstrainedON
24872494
algList.append(Output_REC)
24882495
algList.append(Output_DST)
2489-
algList.append(out)
24902496

2491-
from Configurables import ApplicationMgr
2497+
if not args.iosvc:
2498+
algList = [inp] + algList + [out]
24922499

24932500
ApplicationMgr(TopAlg=algList, EvtSel="NONE", EvtMax=3, ExtSvc=[evtsvc], OutputLevel=WARNING)

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ set_tests_properties ( same_num_io
7878

7979
# Test clicReconstruction with EDM4hep input and output
8080
ExternalData_Add_Test( marlinwrapper_tests NAME clicRec_edm4hep_input COMMAND bash -c "${CMAKE_CURRENT_SOURCE_DIR}/scripts/clicRec_e4h_input.sh DATA{${PROJECT_SOURCE_DIR}/test/input_files/ttbar_20240223_edm4hep.root}")
81+
ExternalData_Add_Test( marlinwrapper_tests NAME clicRec_edm4hep_input_iosvc COMMAND bash -c "${CMAKE_CURRENT_SOURCE_DIR}/scripts/clicRec_e4h_input.sh DATA{${PROJECT_SOURCE_DIR}/test/input_files/ttbar_20240223_edm4hep.root} --iosvc")
8182

8283
# Run clicReconstruction sequence with LCIO input and output, no converters, with inter-event parallelism
8384
ExternalData_Add_Test( marlinwrapper_tests NAME clicRec_lcio_mt COMMAND bash -c "${CMAKE_CURRENT_SOURCE_DIR}/scripts/clicRec_lcio_mt.sh DATA{${PROJECT_SOURCE_DIR}/test/input_files/testSimulation.slcio}")

test/scripts/clicRec_e4h_input.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,17 @@ set -eu
2323

2424
cd CLICPerformance/clicConfig
2525

26-
k4run $EXAMPLE_DIR/clicRec_e4h_input.py --EventDataSvc.input=$1
26+
if [ "$2" = "--iosvc" ]; then
27+
iosvc="_iosvc"
28+
echo "Running with IO service"
29+
file_arg = "--IOSvc.Input=$1"
30+
elif [ -n "$2" ]; then
31+
echo "Wrong argument $2"
32+
else
33+
echo "Running without IO service"
34+
file_arg = "EventDataSvc.input=$1"
35+
fi
36+
k4run $EXAMPLE_DIR/clicRec_e4h_input.py $file_arg --rec-output Output_REC_e4h_input$iosvc.slcio --dst-output Output_DST_e4h_input$iosvc.slcio
2737

2838
input_num_events=$(python $TEST_DIR/python/root_num_events.py $1)
2939
output_num_events=$(python $TEST_DIR/python/root_num_events.py my_output.root)
@@ -35,14 +45,14 @@ if [ "$input_num_events" != "$output_num_events" ]; then
3545
fi
3646

3747
# Second check: contents (at least superficially)
38-
echo "Comparing contents of Output_REC_e4h_input.slcio"
39-
if ! diff <(anajob Output_REC_e4h_input.slcio) $TEST_DIR/inputFiles/anajob_Output_REC.expected; then
48+
echo "Comparing contents of Output_REC_e4h_input$iosvc.slcio"
49+
if ! diff <(anajob Output_REC_e4h_input$iosvc.slcio) $TEST_DIR/inputFiles/anajob_Output_REC.expected; then
4050
echo "File contents of REC slcio file are not as expected"
4151
exit 1
4252
fi
4353

44-
echo "Comparing contents of Output_DST_e4h_input.slcio"
45-
if ! diff <(anajob Output_DST_e4h_input.slcio) $TEST_DIR/inputFiles/anajob_Output_DST.expected; then
54+
echo "Comparing contents of Output_DST_e4h_input$iosvc.slcio"
55+
if ! diff <(anajob Output_DST_e4h_input$iosvc.slcio) $TEST_DIR/inputFiles/anajob_Output_DST.expected; then
4656
echo "File contents of DST slcio file are not as expected"
4757
exit 1
4858
fi

0 commit comments

Comments
 (0)