Skip to content

Commit ec59cae

Browse files
author
Vakho Tsulaia
committed
TMP commit
Extra checks and printouts
1 parent d704197 commit ec59cae

File tree

2 files changed

+48
-7
lines changed

2 files changed

+48
-7
lines changed

tests/unit_tests/device/cuda/detector_cuda.cpp

+27-7
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,39 @@ TEST(detector_cuda, detector_alignment) {
129129
// for populating this vector take all transforms of the detector
130130
// and shift them by the same translation
131131
typename detector_host_t::transform_container tf_store_aligned_host;
132+
typename decltype(det_host)::transform_container::context_type ctx{};
132133

133-
point3 shift{.100000f * unit<scalar>::mm, .200000f * unit<scalar>::mm,
134-
.300000f * unit<scalar>::mm};
134+
point3 shift{.1f * unit<scalar>::mm, .2f * unit<scalar>::mm,
135+
.3f * unit<scalar>::mm};
135136

136137
tf_store_aligned_host.reserve(
137138
det_host.transform_store().size(),
138-
typename decltype(det_host)::transform_container::context_type{});
139+
ctx);
139140

140141
for (const auto& tf : det_host.transform_store()) {
141-
point3 shifted = tf.translation() + shift;
142+
point3 shifted{tf.translation()[0] + shift[0],
143+
tf.translation()[1] + shift[1],
144+
tf.translation()[2] + shift[2]};
142145
tf_store_aligned_host.push_back(
143-
transform_t{shifted, tf.x(), tf.y(), tf.z()});
146+
transform_t{shifted, tf.x(), tf.y(), tf.z(),false});
144147
}
145148

149+
std::cout << "Comparing translations STEP1" << std::endl;
150+
for (unsigned int i = 0u; i < tf_store_aligned_host.size(ctx); i++) {
151+
auto trstatic = det_host.transform_store().at(i,ctx).translation();
152+
auto traligned = tf_store_aligned_host.at(i,ctx).translation();
153+
auto trdiff = traligned - trstatic;
154+
std::cout << "SHIFT (" << trdiff[0] << "," << trdiff[1] << "," << trdiff[2] << ")" << std::endl;
155+
}
156+
/*
157+
// Corrected shift
158+
auto tr0_static = det_host.transform_store().at(0,ctx).translation();
159+
auto tr0_aligned = tf_store_aligned_host.at(0,ctx).translation();
160+
auto tr0_diff = tr0_aligned-tr0_static;
161+
point3 shift_corrected{tr0_diff[0],tr0_diff[1],tr0_diff[2]};
162+
std::cout << "Corrected shift : " << tr0_diff[0] << " " << tr0_diff[1] << " " << tr0_diff[2] << std::endl;
163+
*/
164+
146165
// copy the vector of aligned transforms to the device
147166
// again, use synchronous copy and fixed size buffers
148167
auto tf_buff_aligned =
@@ -173,10 +192,11 @@ TEST(detector_cuda, detector_alignment) {
173192
surfacexf_data_static, surfacexf_data_aligned);
174193

175194
// check that the relevant transforms have been properly shifted
176-
for (unsigned int i = 0u; i < surfacexf_device_static.size(); i++) {
195+
// std::cout << "Comparing translations STEP3" << std::endl;
196+
for (unsigned int i = 0u; i < 20; i++) {
177197
auto translation_static = surfacexf_device_static[i].translation();
178198
auto translation_aligned = surfacexf_device_aligned[i].translation();
179199
auto translation_diff = translation_aligned - translation_static;
180-
EXPECT_POINT3_NEAR(translation_diff, shift, 1e-5);
200+
EXPECT_POINT3_NEAR(translation_diff, shift, 1e-6);
181201
}
182202
}

tests/unit_tests/device/cuda/detector_cuda_kernel.cu

+21
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,28 @@ __global__ void detector_alignment_test_kernel(
127127
surfacexf_data_static);
128128
vecmem::device_vector<transform_t> surfacexf_device_aligned(
129129
surfacexf_data_aligned);
130+
/*
131+
printf("Comparing translations STEP2\n");
132+
for (unsigned int i = 0u; i < 20; i++) {
133+
const auto sf = tracking_surface{det_device_static,
134+
det_device_static.surfaces()[i]};
135+
auto trstat = sf.transform(ctx).translation();
136+
const auto af = tracking_surface{det_device_aligned,
137+
det_device_aligned.surfaces()[i]};
138+
auto tralig = af.transform(ctx).translation();
139+
if(fabs(tralig[0]-trstat[0]-.1f)>1e-6
140+
|| fabs(tralig[1]-trstat[1]-.2f)>1e-6
141+
|| fabs(tralig[2]-trstat[2]-.3f)>1e-6) {
142+
printf("[%f,%f,%f] - [%f,%f,%f] = [%f,%f,%f]\n",
143+
tralig[0],tralig[1],tralig[2],
144+
trstat[0],trstat[1],trstat[2],
145+
fabs(tralig[0]-trstat[0]),
146+
fabs(tralig[1]-trstat[1]),
147+
fabs(tralig[2]-trstat[2]));
148+
}
130149
150+
}
151+
*/
131152
// copy surface transforms into relevant vectors
132153
for (unsigned int i = 0u; i < det_device_static.surfaces().size(); i++) {
133154
const auto sf = tracking_surface{det_device_static,

0 commit comments

Comments
 (0)