Skip to content

Commit 6b30f4d

Browse files
authored
Merge pull request #283 from fmauger/fix-vertex_extrapolation_on_Bi_calib_sources
Add test for flreconstruct fix issue #281
2 parents d96cc14 + d705425 commit 6b30f4d

File tree

5 files changed

+226
-20
lines changed

5 files changed

+226
-20
lines changed

modules/ChargedParticleTracking/ChargedParticleTracking/vertex_extrapolation_driver.cc

+52-15
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ namespace snemo {
436436
DT_LOG_DEBUG(logPrio, "Direction (world) : " << geomtools::to_xyz(direction) );
437437
DT_LOG_DEBUG(logPrio, "Distance ref->end : " << distRef2End / CLHEP::mm << " mm");
438438
DT_LOG_DEBUG(logPrio, "XY-distance ref->end : " << distRef2End_Xy / CLHEP::mm << " mm");
439-
440439
for (int iBlockType : blockTypes) {
441440
DT_LOG_DEBUG(logPrio, "Scanning block type=" << iBlockType << "...");
442441
const std::vector<geomtools::geom_id> * blockGidsPtr = nullptr;
@@ -1069,8 +1068,10 @@ namespace snemo {
10691068

10701069
// Optimization for strip scanning:
10711070
if (use_foils or use_calib_src) {
1072-
DT_LOG_DEBUG(logPrio, "Searching line intercept on source submodule #" << _sourceSubmoduleGid_ << "...");
1073-
const geomtools::geom_info & srcSubmodGinfo = geoManager().get_mapping().get_geom_info(_sourceSubmoduleGid_);
1071+
DT_LOG_DEBUG(logPrio, "Searching line intercept on source submodule #"
1072+
<< _sourceSubmoduleGid_ << "...");
1073+
const geomtools::geom_info & srcSubmodGinfo =
1074+
geoManager().get_mapping().get_geom_info(_sourceSubmoduleGid_);
10741075
const geomtools::logical_volume & srcSubmodLog = srcSubmodGinfo.get_logical();
10751076
const geomtools::i_shape_3d & srcSubmodShape = srcSubmodLog.get_shape();
10761077
const geomtools::placement & srcSubmodPlacement = srcSubmodGinfo.get_world_placement();
@@ -1248,6 +1249,7 @@ namespace snemo {
12481249
padVtxInfo.tolerance = _intercept_tolerance_;
12491250
sourcePadInterceptSuccess = true;
12501251
if (datatools::logger::is_debug(logPrio)) {
1252+
DT_LOG_DEBUG(logPrio, "Line intercept is :");
12511253
padVtxInfo.print(std::cerr, "[debug] ");
12521254
}
12531255
DT_LOG_DEBUG(logPrio, "padVtxInfo.distance_xy = " << padVtxInfo.distance_xy / CLHEP::mm << " mm");
@@ -1421,7 +1423,7 @@ namespace snemo {
14211423
calibrationSpotVtxInfo.gid = sourceCalibrationSpotGid;
14221424
calibrationSpotVtxInfo.face_intercept = srcCalibrationSpotFii;
14231425
if (srcCalibrationSpotExtrapolationDist > 0.0) {
1424-
calibrationSpotVtxInfo.distance = srcCalibrationSpotExtrapolationDist;
1426+
calibrationSpotVtxInfo.distance = srcCalibrationSpotExtrapolationDist;
14251427
calibrationSpotVtxInfo.distance_xy = srcCalibrationSpotExtrapolationDist_Xy;
14261428
} else {
14271429
calibrationSpotVtxInfo.distance = 0.0;
@@ -1547,8 +1549,10 @@ namespace snemo {
15471549

15481550
// Optimization for strip scanning:
15491551
if (use_foils or use_calib_src) {
1550-
DT_LOG_DEBUG(logPrio, "Searching line intercept on source submodule #" << _sourceSubmoduleGid_ << "...");
1551-
const geomtools::geom_info & srcSubmodGinfo = geoManager().get_mapping().get_geom_info(_sourceSubmoduleGid_);
1552+
DT_LOG_DEBUG(logPrio, "Searching line intercept on source submodule #"
1553+
<< _sourceSubmoduleGid_ << "...");
1554+
const geomtools::geom_info & srcSubmodGinfo =
1555+
geoManager().get_mapping().get_geom_info(_sourceSubmoduleGid_);
15521556
const geomtools::logical_volume & srcSubmodLog = srcSubmodGinfo.get_logical();
15531557
const geomtools::i_shape_3d & srcSubmodShape = srcSubmodLog.get_shape();
15541558
const geomtools::placement & srcSubmodPlacement = srcSubmodGinfo.get_world_placement();
@@ -1595,11 +1599,37 @@ namespace snemo {
15951599
}
15961600
minStripId = std::max(minStripId, (int16_t) (minId - 1));
15971601
maxStripId = std::min(maxStripId, (int16_t) (maxId + 1));
1598-
sourceSubmoduleLineExtrapolationSuccess = true;
1602+
1603+
// 2024-05-13, FM: NEW:
1604+
// Calib track range:
1605+
minId = 100000;
1606+
maxId = -100000;
1607+
for (uint32_t iTrack = 0; iTrack < _sourceCalibTrackGids_.size(); iTrack++) {
1608+
const geomtools::geom_id & sourceCalibTrackGid = _sourceCalibTrackGids_[iTrack];
1609+
const geomtools::geom_info & sourceCalibTrackGinfo = geoManager().get_mapping().get_geom_info(sourceCalibTrackGid);
1610+
const geomtools::placement & sourceCalibTrackPlacement = sourceCalibTrackGinfo.get_world_placement();
1611+
double yTrack = sourceCalibTrackPlacement.get_translation().y();
1612+
if (std::abs(yTrack - yImpact) < _max_source_extrapolation_xy_length_) {
1613+
int32_t sourceTrackId = (int32_t) sourceCalibTrackGid.get(1);
1614+
if (sourceTrackId > maxId) {
1615+
maxId = sourceTrackId;
1616+
}
1617+
if (sourceTrackId < minId) {
1618+
minId = sourceTrackId;
1619+
}
1620+
}
1621+
minTrackId = std::max(minTrackId, (int16_t) (minId - 1));
1622+
maxTrackId = std::min(maxTrackId, (int16_t) (maxId + 1));
1623+
}
1624+
sourceSubmoduleLineExtrapolationSuccess = true;
15991625
} else {
16001626
DT_LOG_DEBUG(logPrio, "No line intercept on the source submodule #" << _sourceSubmoduleGid_);
16011627
}
16021628
} // if (sourceSubmoduleLineExtrapolationSuccess)
1629+
DT_LOG_DEBUG(logPrio, "minStripId=" << minStripId);
1630+
DT_LOG_DEBUG(logPrio, "maxStripId=" << maxStripId);
1631+
DT_LOG_DEBUG(logPrio, "minTrackId=" << minTrackId);
1632+
DT_LOG_DEBUG(logPrio, "maxTrackId=" << maxTrackId);
16031633

16041634
if (useSourceSubmoduleHelixExtrapolation and not sourceSubmoduleLineExtrapolationSuccess) {
16051635
snemo::geometry::helix_intercept hIntercept(helix,
@@ -1621,9 +1651,12 @@ namespace snemo {
16211651
int32_t minId = +100000;
16221652
int32_t maxId = -100000;
16231653
// Find candidate source strips
1654+
DT_LOG_DEBUG(logPrio, "Scanning strips...");
16241655
for (uint32_t iStrip = 0; iStrip < _sourceStripGids_.size(); iStrip++) {
16251656
const geomtools::geom_id & sourceStripGid = _sourceStripGids_[iStrip];
1626-
const geomtools::geom_info & sourceStripGinfo = geoManager().get_mapping().get_geom_info(sourceStripGid);
1657+
DT_LOG_DEBUG(logPrio, " Source strip GID : " << sourceStripGid);
1658+
const geomtools::geom_info & sourceStripGinfo
1659+
= geoManager().get_mapping().get_geom_info(sourceStripGid);
16271660
const geomtools::placement & sourceStripPlacement = sourceStripGinfo.get_world_placement();
16281661
double yStripWorld = sourceStripPlacement.get_translation().y();
16291662
if (std::abs(yStripWorld - yImpactWorld) < _max_source_extrapolation_xy_length_) {
@@ -1662,6 +1695,7 @@ namespace snemo {
16621695
continue;
16631696
}
16641697
if ((int32_t) sourceStripId < minStripId or (int32_t) sourceStripId > maxStripId) {
1698+
DT_LOG_DEBUG(logPrio, " Pass source strip GID : " << sourceStripGid << "...");
16651699
continue;
16661700
}
16671701
DT_LOG_DEBUG(logPrio, "Searching helix intercept on strip #" << sourceStripId);
@@ -1769,6 +1803,7 @@ namespace snemo {
17691803
double distRef2Impact_Xy = (srcPadImpactWorld_Xy - refPoint_Xy).mag();
17701804
double extrapolationDist_Xy = distRef2Impact_Xy - distRef2End_Xy;
17711805
DT_LOG_DEBUG(logPrio, "extrapolationDist_Xy = " << extrapolationDist_Xy / CLHEP::mm << " mm");
1806+
// Result:
17721807
padVtxInfo.category = snemo::geometry::vertex_info::CATEGORY_ON_SOURCE_FOIL;
17731808
padVtxInfo.from = iFrom;
17741809
padVtxInfo.extrapolation_mode = vertex_info::EXTRAPOLATION_LINE;
@@ -2036,11 +2071,14 @@ namespace snemo {
20362071
calibSpotFii.set_impact(calibSpotWorldImpact);
20372072
double calibSpotDistRef2Impact = (calibSpotWorldImpact - refPoint).mag();
20382073
double calibSpotExtrapolationDist = calibSpotDistRef2Impact - distRef2End;
2039-
// XY extrapolation:
2074+
DT_LOG_DEBUG(logPrio, "calibSpotExtrapolationDist = "
2075+
<< calibSpotExtrapolationDist / CLHEP::mm << " mm");
2076+
// XY extrapolation:
20402077
geomtools::vector_2d calibSpotImpact_Xy(calibSpotWorldImpact.x(), calibSpotWorldImpact.y());
20412078
double calibSpotDistRef2Impact_Xy = (calibSpotImpact_Xy - refPoint_Xy).mag();
20422079
double calibSpotExtrapolationDist_Xy = calibSpotDistRef2Impact_Xy - distRef2End_Xy;
2043-
// Result:
2080+
DT_LOG_DEBUG(logPrio, "calibSpotExtrapolationDist_Xy = " << calibSpotExtrapolationDist_Xy / CLHEP::mm << " mm");
2081+
// Result:
20442082
vertex_info calibSpotVtxInfo;
20452083
calibSpotVtxInfo.category = snemo::geometry::vertex_info::CATEGORY_ON_SOURCE_FOIL;
20462084
calibSpotVtxInfo.from = iFrom;
@@ -2104,8 +2142,8 @@ namespace snemo {
21042142
DT_LOG_DEBUG(logPrio, "Helix intercept is to far from the calibration source spot");
21052143
} // extrapolation distance check
21062144
} // if (success)
2107-
} // if (useCalibrationSpotHelixExtrapolation...
2108-
} // for (uint32_t iStrip
2145+
} // if (useCalibrationSpotHelixExtrapolation...)
2146+
} // for (uint32_t iStrip...)
21092147
} // if (use_calib_src)
21102148

21112149
_post_process_source_vertex_(srcVertexes);
@@ -2502,7 +2540,6 @@ namespace snemo {
25022540
{
25032541
// Prefix "VED" stands for "Vertex Extrapolation Driver" :
25042542
datatools::logger::declare_ocd_logging_configuration(ocd_, "fatal", "VED.");
2505-
25062543
{
25072544
// // Description of the 'VED.use_linear_extrapolation' configuration property :
25082545
// datatools::configuration_property_description &cpd = ocd_.add_property_info();
@@ -2521,9 +2558,9 @@ namespace snemo {
25212558
}
25222559
}
25232560

2524-
} // end of namespace reconstruction
2561+
} // end of namespace reconstruction
25252562

2526-
} // end of namespace snemo
2563+
} // end of namespace snemo
25272564

25282565
/* OCD support */
25292566
#include <datatools/object_configuration_description.h>

programs/flreconstruct/tests/CMakeLists.txt

+12-2
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,20 @@ set_falaise_test_environment(flreconstruct-fix-issue-201)
155155

156156

157157
# Tests dedicated to the validation of fixes
158-
# - Validation of issue #281 fix
158+
# - Validation of issue #281 fix (test #1)
159159
add_test(NAME flreconstruct-fix-issue281
160160
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/fix-issue281/run.sh
161-
--work-dir "${CMAKE_CURRENT_BINARY_DIR}"
161+
--work-dir "${CMAKE_CURRENT_BINARY_DIR}/fix-issue281"
162162
--cfg-dir "${CMAKE_CURRENT_SOURCE_DIR}/fix-issue281"
163163
)
164164
set_falaise_test_environment(flreconstruct-fix-issue281)
165+
166+
167+
# Tests dedicated to the validation of fixes
168+
# - Validation of issue #281 fix (test #2)
169+
add_test(NAME flreconstruct-fix-issue281-2
170+
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/fix-issue281/run2.sh
171+
--work-dir "${CMAKE_CURRENT_BINARY_DIR}/fix-issue281-2"
172+
--cfg-dir "${CMAKE_CURRENT_SOURCE_DIR}/fix-issue281"
173+
)
174+
set_falaise_test_environment(flreconstruct-fix-issue281-2)

programs/flreconstruct/tests/fix-issue281/pipeline.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,5 @@
9393
VED.max_calo_extrapolation.xy_length : real as length = 15.0 cm
9494
VED.max_source_extrapolation.xy_length : real as length = 30.0 cm
9595
VED.vertex_source_extrapolation.extend_y : real = 1.0
96-
VED.vertex_source_extrapolation.extend_z : real = 1.0
96+
VED.vertex_source_extrapolation.extend_z : real = 2.0
9797
AFD.minimal_delayed_time : real as time = 13 us
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
#!/bin/bash
2+
#
3+
# Author: F. Mauger
4+
# Date: 2024-05-13
5+
#
6+
# Test of the issue #281 fix
7+
# =========================
8+
#
9+
# This test must be run after Falaise installation and setup.
10+
#
11+
# Contents
12+
# --------
13+
#
14+
# * ``config/simu.conf`` : main configuration file for flsimulate
15+
# * ``config/reco.conf ``: main configuration file for flreconstruct
16+
# * ``run.sh`` : test script
17+
#
18+
# Run the test script
19+
# -------------------
20+
#
21+
# flsimulate and flreconstruct must be in the PATH.
22+
# cd in the directory containing the script:
23+
#
24+
# $ ./run.sh [--work-dir /tmp/${USER}/fltest-issue281] [--visu]
25+
# $ echo $?
26+
#
27+
28+
echo >&2 "[debug] PATH = '${PATH}'"
29+
30+
label="run-fix-issue281-2"
31+
with_visu=0
32+
work_dir=""
33+
cfg_dir=""
34+
with_magfield=1
35+
36+
function parse_cl_opts()
37+
{
38+
while [ -n "$1" ]; do
39+
local opt="$1"
40+
if [ "${opt}" == "--work-dir" ]; then
41+
shift 1
42+
work_dir="$1"
43+
elif [ "${opt}" == "--cfg-dir" ]; then
44+
shift 1
45+
cfg_dir="$1"
46+
# elif [ "${arg}" = "-m" ]; then
47+
# with_magfield=0
48+
# elif [ "${arg}" = "-M" ]; then
49+
# with_magfield=1
50+
elif [ "${opt}" == "--visu" ]; then
51+
with_visu=1
52+
else
53+
echo >&2 "[error] Invalid command line option '${opt}'! Abort!"
54+
return 1
55+
fi
56+
shift 1
57+
done
58+
return 0
59+
}
60+
61+
parse_cl_opts $@
62+
if [ $? -ne 0 ]; then
63+
exit 1
64+
fi
65+
66+
if [ -z "${work_dir}" ]; then
67+
work_dir="_work.d"
68+
fi
69+
if [ -z "${cfg_dir}" ]; then
70+
cfg_dir="."
71+
fi
72+
73+
#########################################
74+
export FLWORKDIR="${work_dir}/${label}"
75+
76+
echo >&2 "[info] cfg_dir = '${cfg_dir}'"
77+
echo >&2 "[info] work_dir = '${work_dir}'"
78+
echo >&2 "[info] FLWORKDIR = '${FLWORKDIR}'"
79+
echo >&2 "[info] with_magfield = '${with_magfield}'"
80+
81+
function my_exit()
82+
{
83+
local error_code="$1"
84+
shift 1
85+
local error_msg="$@"
86+
if [ -n "${error_msg}" ]; then
87+
echo >&2 "[error] $@"
88+
fi
89+
if [ -d ${FLWORKDIR} ]; then
90+
rm -fr ${FLWORKDIR}
91+
fi
92+
exit ${error_code}
93+
}
94+
95+
which flsimulate > /dev/null 2>&1
96+
if [ $? -ne 0 ]; then
97+
my_exit 1 "flsimulate is not available! Abort!"
98+
fi
99+
100+
if [ ! -d ${FLWORKDIR} ]; then
101+
mkdir -p ${FLWORKDIR}
102+
fi
103+
cp -f ${cfg_dir}/pipeline.conf ${FLWORKDIR}/pipeline.conf
104+
105+
echo >&2 "[info] Running flsimulate-configure..."
106+
# flsimulate-configure --no-gui \
107+
# -s "geometry:layout/if_basic/magnetic_field=${with_magfield}" \
108+
# -s "vertexes:generator=source_pads_bulk" \
109+
# -s "primary_events:generator=Se82.0nubb" \
110+
# -s "simulation:output_profile=all_details" \
111+
# -o "${FLWORKDIR}/fix-issue281.vprofile"
112+
flsimulate-configure --no-gui \
113+
-i "${cfg_dir}/fix-issue281.vprofile" \
114+
-s "geometry:layout/if_basic/magnetic_field=${with_magfield}" \
115+
-o "${FLWORKDIR}/fix-issue281.vprofile"
116+
if [ $? -ne 0 ]; then
117+
my_exit 1 "flsimulate-configure failed! Abort!"
118+
fi
119+
120+
echo >&2 "[info] Dump '${FLWORKDIR}/fix-issue281.vprofile' :"
121+
cat ${FLWORKDIR}/fix-issue281.vprofile
122+
echo >&2 ""
123+
124+
echo >&2 "[info] Running flsimulate..."
125+
flsimulate -c ${cfg_dir}/simu.conf -o ${FLWORKDIR}/fix-issue281-2.brio
126+
if [ $? -ne 0 ]; then
127+
my_exit 1 "flsimulate failed! Abort!"
128+
fi
129+
130+
echo >&2 "[info] Running flreconstruct..."
131+
flreconstruct \
132+
-p ${cfg_dir}/reco.conf \
133+
-i ${FLWORKDIR}/fix-issue281-2.brio \
134+
-o ${FLWORKDIR}/fix-issue281-rec-2.brio \
135+
> ${FLWORKDIR}/reco.log 2>&1
136+
if [ $? -ne 0 ]; then
137+
my_exit 1 "flreconstruct failed! Abort!"
138+
fi
139+
echo >&2 ""
140+
141+
if [ ${with_visu} -eq 1 ]; then
142+
echo >&2 "[info] Running flvisualize..."
143+
flvisualize \
144+
--variant-profile "${FLWORKDIR}/fix-issue281.vprofile" \
145+
-i ${FLWORKDIR}/fix-issue281-rec-2.brio \
146+
--focus-on-roi \
147+
--show-simulated-vertex 1 \
148+
--show-simulated-tracks 1 \
149+
--show-simulated-hits 1 \
150+
--show-calibrated-hits 1 \
151+
--show-calibrated-info 1 \
152+
--show-tracker-clustered-hits 1 \
153+
--show-tracker-trajectories 1 \
154+
--show-particle-tracks 1
155+
fi
156+
157+
my_exit 0
158+
159+
# end

programs/flreconstruct/tests/fix-issue281/simu.conf

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Author: F. Mauger <[email protected]>
2-
# Date: 2024-05-13
2+
# Date: 2024-05-15
33
# Format: datatools::multi_properties
44
# Description: Sample configuration script for flsimulate (Falaise 3.0.0)
55
# Supports: SuperNEMO Demonstrator Simulation setup version 2.1
@@ -14,7 +14,7 @@
1414
#@config Basic system setup
1515

1616
#@description Number of events to simulate (default: 1)
17-
numberOfEvents : integer = 200
17+
numberOfEvents : integer = 100
1818

1919

2020
#########################################################

0 commit comments

Comments
 (0)