@@ -571,7 +571,9 @@ bound_track_parameters<transform3_type>::covariance_type directly_differentiate(
571
571
const scalar detector_length, const field_t & field,
572
572
const scalar overstep_tolerance, const scalar on_surface_tolerance,
573
573
const scalar rk_tolerance, const scalar constraint_step,
574
- const std::array<scalar, 5u > hs, std::array<bool , 25 >& convergence) {
574
+ const std::array<scalar, 5u > hs,
575
+ std::array<unsigned int , 5u >& num_iterations,
576
+ std::array<bool , 25 >& convergence) {
575
577
576
578
// Return Jacobian
577
579
bound_covariance_type differentiated_jacobian;
@@ -610,6 +612,7 @@ bound_track_parameters<transform3_type>::covariance_type directly_differentiate(
610
612
ridder.run (nvec1, nvec2, delta, p, i, differentiated_jacobian);
611
613
612
614
if (ridder.is_complete ()) {
615
+ num_iterations[i] = p;
613
616
break ;
614
617
}
615
618
}
@@ -684,6 +687,7 @@ void evaluate_jacobian_difference(
684
687
std::ofstream& file, scalar& ref_rel_diff, bool use_field_gradient,
685
688
bool do_inspect, const bool use_precal_values = false ,
686
689
[[maybe_unused]] bound_covariance_type precal_diff_jacobi = {},
690
+ [[maybe_unused]] std::array<unsigned int , 5u > precal_num_iterations = {},
687
691
[[maybe_unused]] std::array<bool , 25u > precal_convergence = {}) {
688
692
689
693
const auto phi0 = track.phi ();
@@ -735,22 +739,29 @@ void evaluate_jacobian_difference(
735
739
<< " ," << final_param.phi () << " ," << final_param.theta () << " ,"
736
740
<< final_param.qop () << " ," ;
737
741
738
- std::array<bool , 25u > convergence;
739
742
bound_covariance_type differentiated_jacobian;
743
+ std::array<unsigned int , 5u > num_iterations;
744
+ std::array<bool , 25u > convergence;
740
745
741
746
if (use_precal_values) {
742
- convergence = precal_convergence;
743
747
differentiated_jacobian = precal_diff_jacobi;
748
+ num_iterations = precal_num_iterations;
749
+ convergence = precal_convergence;
744
750
} else {
745
751
differentiated_jacobian = directly_differentiate<propagator_t , field_t >(
746
752
trk_count, reference_param, det, detector_length, field,
747
753
overstep_tolerance, on_surface_tolerance, rk_tolerance_dis,
748
- constraint_step, hs, convergence);
754
+ constraint_step, hs, num_iterations, convergence);
749
755
}
750
756
751
757
bool total_convergence =
752
758
(std::count (convergence.begin (), convergence.end (), false ) == 0 );
753
759
760
+ // Ridders number of iterations
761
+ for (unsigned int i = 0 ; i < 5u ; i++) {
762
+ file << num_iterations[i] << " ," ;
763
+ }
764
+
754
765
// Convergence
755
766
file << total_convergence << " ," ;
756
767
for (unsigned int i = 0 ; i < 25u ; i++) {
@@ -1098,7 +1109,7 @@ void evaluate_jacobian_difference_helix(
1098
1109
* ****************************/
1099
1110
1100
1111
bound_covariance_type differentiated_jacobian;
1101
-
1112
+ std::array< unsigned int , 5u > num_iterations;
1102
1113
std::array<bool , 25u > convergence;
1103
1114
1104
1115
for (unsigned int i = 0u ; i < 5u ; i++) {
@@ -1128,6 +1139,7 @@ void evaluate_jacobian_difference_helix(
1128
1139
ridder.run (nvec1, nvec2, delta, p, i, differentiated_jacobian);
1129
1140
1130
1141
if (ridder.is_complete ()) {
1142
+ num_iterations[i] = p;
1131
1143
break ;
1132
1144
}
1133
1145
}
@@ -1151,6 +1163,11 @@ void evaluate_jacobian_difference_helix(
1151
1163
<< getter::element (bound_vec, e_bound_theta, 0u ) << " ,"
1152
1164
<< getter::element (bound_vec, e_bound_qoverp, 0u ) << " ," ;
1153
1165
1166
+ // Ridders number of iterations
1167
+ for (unsigned int i = 0 ; i < 5u ; i++) {
1168
+ file << num_iterations[i] << " ," ;
1169
+ }
1170
+
1154
1171
// Convergence
1155
1172
file << total_convergence << " ," ;
1156
1173
for (unsigned int i = 0 ; i < 25u ; i++) {
@@ -1224,6 +1241,13 @@ void setup_csv_header_jacobian(std::ofstream& file) {
1224
1241
// Final Parameter at the destination surface
1225
1242
file << " l0_F,l1_F,phi_F,theta_F,qop_F," ;
1226
1243
1244
+ // Number of iterations to complete the numerical differentiation
1245
+ file << " num_iterations_l0,"
1246
+ << " num_iterations_l1,"
1247
+ << " num_iterations_phi,"
1248
+ << " num_iterations_theta,"
1249
+ << " num_iterations_qop," ;
1250
+
1227
1251
// Convergence
1228
1252
file << " total_convergence," ;
1229
1253
file << " dl0dl0_C,dl0dl1_C,dl0dphi_C,dl0dtheta_C,dl0dqop_C," ;
@@ -1767,13 +1791,14 @@ int main(int argc, char** argv) {
1767
1791
1768
1792
if (rk_tolerance_iterate_mode) {
1769
1793
1794
+ std::array<unsigned int , 5u > num_iterations;
1770
1795
std::array<bool , 25u > convergence;
1771
1796
auto differentiated_jacobian =
1772
1797
directly_differentiate<inhom_field_rect_propagator_t >(
1773
1798
track_count, rect_bparam, rect_det_w_mat,
1774
1799
detector_length, inhom_bfield, overstep_tol,
1775
1800
on_surface_tol, rk_tol_dis, constraint_step_size,
1776
- h_sizes_rect, convergence);
1801
+ h_sizes_rect, num_iterations, convergence);
1777
1802
1778
1803
for (std::size_t i = 0u ; i < log10_tols.size (); i++) {
1779
1804
@@ -1784,7 +1809,7 @@ int main(int argc, char** argv) {
1784
1809
std::pow (10 .f , log10_tols[i]), rk_tol_dis,
1785
1810
constraint_step_size, h_sizes_rect, rect_files[i],
1786
1811
ref_rel_diff, true , do_inspect, true ,
1787
- differentiated_jacobian, convergence);
1812
+ differentiated_jacobian, num_iterations, convergence);
1788
1813
1789
1814
dqopdqop_rel_diffs_rect[i].push_back (ref_rel_diff);
1790
1815
}
@@ -1848,13 +1873,14 @@ int main(int argc, char** argv) {
1848
1873
1849
1874
if (rk_tolerance_iterate_mode) {
1850
1875
1876
+ std::array<unsigned int , 5u > num_iterations;
1851
1877
std::array<bool , 25u > convergence;
1852
1878
auto differentiated_jacobian =
1853
1879
directly_differentiate<inhom_field_wire_propagator_t >(
1854
1880
track_count, wire_bparam, wire_det_w_mat,
1855
1881
detector_length, inhom_bfield, overstep_tol,
1856
1882
on_surface_tol, rk_tol_dis, constraint_step_size,
1857
- h_sizes_wire, convergence);
1883
+ h_sizes_wire, num_iterations, convergence);
1858
1884
1859
1885
for (std::size_t i = 0u ; i < log10_tols.size (); i++) {
1860
1886
// Wire Inhomogeneous field with Material
@@ -1864,7 +1890,7 @@ int main(int argc, char** argv) {
1864
1890
std::pow (10 .f , log10_tols[i]), rk_tol_dis,
1865
1891
constraint_step_size, h_sizes_wire, wire_files[i],
1866
1892
ref_rel_diff, true , do_inspect, true ,
1867
- differentiated_jacobian, convergence);
1893
+ differentiated_jacobian, num_iterations, convergence);
1868
1894
1869
1895
dqopdqop_rel_diffs_wire[i].push_back (ref_rel_diff);
1870
1896
}
0 commit comments