Skip to content

Commit 86a36f4

Browse files
authored
Merge pull request #700 from beomki-yeo/convergence-test
Print ridders results and make all tracks converged
2 parents ec3c836 + d68f494 commit 86a36f4

File tree

3 files changed

+89
-32
lines changed

3 files changed

+89
-32
lines changed

tests/integration_tests/cpu/propagator/jacobian_validation.cpp

+23-12
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const std::array<scalar, 5u> h_sizes_rect{3e0f, 3e0f, 2e-2f, 1e-3f, 1e-3f};
6060
const std::array<scalar, 5u> h_sizes_wire{3e0f, 3e0f, 2e-2f, 1e-3f, 1e-3f};
6161

6262
// Ridders' algorithm setup
63-
constexpr const unsigned int Nt = 50u;
63+
constexpr const unsigned int Nt = 100u;
6464
const std::array<scalar, 5u> safe{5.0f, 5.0f, 5.0f, 5.0f, 5.0f};
6565
const std::array<scalar, 5u> con{1.2f, 1.2f, 1.2f, 1.2f, 1.2f};
6666
constexpr const scalar big = std::numeric_limits<scalar>::max();
@@ -94,6 +94,18 @@ std::uniform_int_distribution<int> rand_bool(0, 1);
9494
std::uniform_real_distribution<scalar> rand_gamma(0.f,
9595
2.f * constant<scalar>::pi);
9696

97+
// Correlation factor in the range of [-10%, 10%]
98+
constexpr scalar min_corr = -0.1f;
99+
constexpr scalar max_corr = 0.1f;
100+
101+
// Values for sampling standard deviation
102+
const std::array<scalar, 6u> stddevs_sampling{50.f * unit<scalar>::um,
103+
50.f * unit<scalar>::um,
104+
1.f * unit<scalar>::mrad,
105+
1.f * unit<scalar>::mrad,
106+
0.01f,
107+
1.f * unit<scalar>::ns};
108+
97109
// surface types
98110
using rect_type = rectangle2D;
99111
using wire_type = line_square;
@@ -244,23 +256,22 @@ bound_covariance_type get_random_initial_covariance(const scalar ini_qop) {
244256
bound_covariance_type ini_cov =
245257
matrix_operator().template zero<e_bound_size, e_bound_size>();
246258

247-
// Correlation factor in the range of [-10%, 10%]
248-
scalar min_corr = -0.1f;
249-
scalar max_corr = 0.1f;
250259
// Random correction factor
251260
std::uniform_real_distribution<scalar> rand_corr(min_corr, max_corr);
252261

262+
// Distribution for sampling standard deviations
253263
std::normal_distribution<scalar> rand_l0(0.f * unit<scalar>::um,
254-
50.f * unit<scalar>::um);
264+
stddevs_sampling[0u]);
255265
std::normal_distribution<scalar> rand_l1(0.f * unit<scalar>::um,
256-
50.f * unit<scalar>::um);
266+
stddevs_sampling[1u]);
257267
std::normal_distribution<scalar> rand_phi(0.f * unit<scalar>::mrad,
258-
1.f * unit<scalar>::mrad);
268+
stddevs_sampling[2u]);
259269
std::normal_distribution<scalar> rand_theta(0.f * unit<scalar>::mrad,
260-
1.f * unit<scalar>::mrad);
261-
std::normal_distribution<scalar> rand_qop(0.f, 0.01f * ini_qop);
270+
stddevs_sampling[3u]);
271+
std::normal_distribution<scalar> rand_qop(0.f,
272+
stddevs_sampling[4u] * ini_qop);
262273
std::normal_distribution<scalar> rand_time(0.f * unit<scalar>::ns,
263-
1.f * unit<scalar>::ns);
274+
stddevs_sampling[5u]);
264275

265276
/*
266277
// Typical stddev range taken from the figures of ATL-PHYS-PUB-2021-024 and
@@ -1902,9 +1913,9 @@ int main(int argc, char** argv) {
19021913
EXPECT_EQ(dqopdqop_rel_diffs_rect[i].size(), n_tracks);
19031914
EXPECT_EQ(dqopdqop_rel_diffs_wire[i].size(), n_tracks);
19041915

1905-
EXPECT_GE(statistics::mean(dqopdqop_rel_diffs_rect[i]), 1e-10f);
1916+
EXPECT_GE(statistics::mean(dqopdqop_rel_diffs_rect[i]), 1e-12f);
19061917
EXPECT_LE(statistics::mean(dqopdqop_rel_diffs_rect[i]), 1e-2f);
1907-
EXPECT_GE(statistics::mean(dqopdqop_rel_diffs_wire[i]), 1e-10f);
1918+
EXPECT_GE(statistics::mean(dqopdqop_rel_diffs_wire[i]), 1e-12f);
19081919
EXPECT_LE(statistics::mean(dqopdqop_rel_diffs_wire[i]), 1e-2f);
19091920
}
19101921
}

tests/validation/root/jacobian_comparison.C

+11-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ double y_min = -15;
4343
double y_max = 10;
4444
double y_margin = 0;
4545
double header_size = 0.05;
46-
std::array<float, 4> ldim{0.545075, 0.621849, 0.942404, 0.881048};
46+
std::array<float, 4> ldim{0.54424, 0.621849, 0.942404, 0.880252};
4747
double pad_x0 = 0.00;
4848
double pad_x1 = 1;
4949
double pad_y0 = 0.00;
@@ -171,6 +171,14 @@ TH1D* get_histogram(std::string name, const int n_labels,
171171

172172
auto rdf = ROOT::RDF::FromCSV(csv_name);
173173
auto rdf_means = get_means(rdf);
174+
175+
// Count the number of non-convergence event
176+
auto conv_success = rdf.Filter("total_convergence == 1").Count();
177+
auto conv_failure = rdf.Filter("total_convergence == 0").Count();
178+
179+
std::cout << "Convergence events: " << *conv_success << std::endl;
180+
std::cout << "Non-convergence events: " << *conv_failure << std::endl;
181+
174182
TH1D* histo = new TH1D(histo_name.c_str(), histo_name.c_str(), 3, 0, 3);
175183
histo->GetYaxis()->SetRangeUser(y_min - y_margin, y_max + y_margin);
176184
histo->GetYaxis()->SetLabelSize(0);
@@ -225,7 +233,7 @@ void draw_pad(const std::string& pad_name) {
225233
void draw_text(const std::string& text) {
226234

227235
const float x1 = 1.23427;
228-
const float y1 = 6.511;
236+
const float y1 = 6.44408;
229237

230238
TLatex* ttext = new TLatex(0.f, 0.f, text.c_str());
231239
ttext->SetTextFont(132);
@@ -266,7 +274,7 @@ void jacobian_comparison() {
266274

267275
gStyle->SetOptTitle(0);
268276
const std::array<float, 2> cdim{1200, 500};
269-
const std::array<int, 4> markers{kOpenCross, kOpenTriangleUp, kOpenSquare,
277+
const std::array<int, 4> markers{kOpenCross, kOpenSquare, kOpenTriangleUp,
270278
kOpenCircle};
271279
const std::array<int, 4> hues{kOrange + 8, kMagenta + 1, kAzure,
272280
kGreen + 2};

tests/validation/root/rk_tolerance_comparison.C

+55-17
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ double title_font_size_rk_tol = 0.046;
5050
int title_font = 132;
5151
int label_font = 132;
5252
int legend_font = 132;
53-
double marker_size = 1.9;
5453
double pad_x0 = 0.005f;
5554
double pad_x1 = 1.f;
5655
double pad_y0 = 0.005f;
@@ -189,7 +188,9 @@ void draw_graphs(const std::string header_title, const std::string geom_title,
189188
TGraph* gr[25];
190189
TMultiGraph* mg = new TMultiGraph();
191190

192-
const std::array<int, 5u> marker_styles = {7, 2, 5, 27, 32};
191+
const std::array<int, 5u> marker_styles = {7, 2, 5, 27, 25};
192+
const std::array<double, 5u> marker_sizes = {2.135, 2.135, 2.135, 2.135,
193+
1.49};
193194
const std::array<int, 5u> line_styles = {1, 3, 2, 7, 4};
194195
const std::array<int, 5u> hues = {kOrange + 2, kPink + 5, kBlue + 2,
195196
kCyan + 2, kGreen + 2};
@@ -211,7 +212,7 @@ void draw_graphs(const std::string header_title, const std::string geom_title,
211212
const int m = i % 5;
212213

213214
gr[i]->SetMarkerStyle(marker_styles[n]);
214-
gr[i]->SetMarkerSize(marker_size);
215+
gr[i]->SetMarkerSize(marker_sizes[n]);
215216
gr[i]->SetLineStyle(line_styles[m]);
216217
gr[i]->SetMarkerColor(hues[m]);
217218
gr[i]->SetLineColor(hues[m]);
@@ -247,6 +248,10 @@ void draw_graphs(const std::string header_title, const std::string geom_title,
247248
double x_max = x_vec.back();
248249

249250
if (x_vec.size() > 10) {
251+
if (x_vec.size() == 13) {
252+
x_margin = 2;
253+
}
254+
250255
x_min = x_min - x_margin;
251256
x_max = x_max + x_margin;
252257
mg->GetXaxis()->SetLimits(x_min, x_max);
@@ -255,13 +260,23 @@ void draw_graphs(const std::string header_title, const std::string geom_title,
255260

256261
mg->Draw("APL");
257262

258-
auto ga = new TGaxis(x_vec.front(), yaxis_min - yaxis_margin,
259-
x_vec.back(), yaxis_min - yaxis_margin,
260-
x_vec.front(), x_vec.back(), 405, "N");
261-
ga->SetLabelFont(label_font);
262-
ga->SetLabelSize(label_font_size_rk_tol);
263-
ga->SetLabelOffset(-0.0065);
264-
ga->Draw();
263+
if (x_vec.size() == 11) {
264+
auto ga = new TGaxis(x_vec.front(), yaxis_min - yaxis_margin,
265+
x_vec.back(), yaxis_min - yaxis_margin,
266+
x_vec.front(), x_vec.back(), 405, "N");
267+
ga->SetLabelFont(label_font);
268+
ga->SetLabelSize(label_font_size_rk_tol);
269+
ga->SetLabelOffset(-0.0065);
270+
ga->Draw();
271+
} else if (x_vec.size() == 13) {
272+
auto ga = new TGaxis(x_vec.front(), yaxis_min - yaxis_margin,
273+
x_vec.back(), yaxis_min - yaxis_margin,
274+
x_vec.front(), x_vec.back(), 304, "N");
275+
ga->SetLabelFont(label_font);
276+
ga->SetLabelSize(label_font_size_rk_tol);
277+
ga->SetLabelOffset(-0.0065);
278+
ga->Draw();
279+
}
265280

266281
mg->GetYaxis()->SetLabelSize(0);
267282
mg->GetYaxis()->SetTickLength(0);
@@ -284,6 +299,10 @@ void draw_graphs(const std::string header_title, const std::string geom_title,
284299
double rk_title_deltaX =
285300
(x_vec.back() - x_vec.front()) * rk_title_offset_fraction;
286301

302+
if (x_vec.size() == 13) {
303+
rk_title_deltaX = -0.2;
304+
}
305+
287306
legend->Draw();
288307
draw_text(rk_title_deltaX + x_vec.front(), rk_title_y, rk_ygap,
289308
rk_header_text_size, rk_geom_text_size, header_title, geom_title);
@@ -309,6 +328,11 @@ void draw_mean_step_size(const std::string header_title,
309328
gr->GetXaxis()->SetTitle("log_{10}(#font[12]{#tau} [mm])");
310329
gr->GetYaxis()->SetTitle("log_{10}(Mean of avg. step size [mm])");
311330
gr->GetXaxis()->SetLimits(x_vec.front() - 0.5, x_vec.back() + 0.5);
331+
332+
if (x_vec.size() == 13) {
333+
ymin = -4;
334+
}
335+
312336
gr->GetYaxis()->SetRangeUser(ymin, ymax);
313337
gr->GetYaxis()->SetNdivisions(505);
314338
gr->GetXaxis()->SetLabelSize(label_font_size_step);
@@ -327,18 +351,32 @@ void draw_mean_step_size(const std::string header_title,
327351
gr->GetYaxis()->SetLabelFont(label_font);
328352

329353
if (x_vec.size() > 10) {
330-
gr->GetXaxis()->SetLimits(x_vec.front() - 1, x_vec.back() + 1);
354+
if (x_vec.size() == 13) {
355+
x_margin = 2;
356+
}
357+
358+
gr->GetXaxis()->SetLimits(x_vec.front() - x_margin,
359+
x_vec.back() + x_margin);
331360
gr->GetXaxis()->SetLabelSize(0);
332361
gr->GetXaxis()->SetTickLength(0);
333362

334363
gr->Draw("APL");
335364

336-
auto ga = new TGaxis(x_vec.front(), ymin, x_vec.back(), ymin,
337-
x_vec.front(), x_vec.back(), 405, "N");
338-
ga->SetLabelFont(label_font);
339-
ga->SetLabelSize(label_font_size_step);
340-
ga->SetLabelOffset(x_label_offset);
341-
ga->Draw();
365+
if (x_vec.size() == 11) {
366+
auto ga = new TGaxis(x_vec.front(), ymin, x_vec.back(), ymin,
367+
x_vec.front(), x_vec.back(), 405, "N");
368+
ga->SetLabelFont(label_font);
369+
ga->SetLabelSize(label_font_size_step);
370+
ga->SetLabelOffset(x_label_offset);
371+
ga->Draw();
372+
} else if (x_vec.size() == 13) {
373+
auto ga = new TGaxis(x_vec.front(), ymin, x_vec.back(), ymin,
374+
x_vec.front(), x_vec.back(), 304, "N");
375+
ga->SetLabelFont(label_font);
376+
ga->SetLabelSize(label_font_size_step);
377+
ga->SetLabelOffset(x_label_offset);
378+
ga->Draw();
379+
}
342380

343381
} else {
344382
gr->Draw();

0 commit comments

Comments
 (0)