From 8d857b59d1229d0df10676290155b26ed2969cc1 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 4 Jul 2026 16:16:24 +0200 Subject: [PATCH 01/11] Hyperlinks for Link section --- mcxtrace-comps/optics/Filter.comp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/mcxtrace-comps/optics/Filter.comp b/mcxtrace-comps/optics/Filter.comp index be8e6e5c9..e9938fc7a 100644 --- a/mcxtrace-comps/optics/Filter.comp +++ b/mcxtrace-comps/optics/Filter.comp @@ -45,17 +45,12 @@ * refraction: [0/1] If nonzero, refraction is enabled. (Only functional for box-geometery.) * * %Link -* Meshlab https://www.meshlab.net/ -* %Link -* Geomview and Object File Format (OFF) -* %Link -* Java version of Geomview (display only) jroff.jar -* %Link -* qhull -* %Linkink -* Powercrust https://www.cs.ucdavis.edu/~amenta/powercrust.html -* %Link -* material datafile obtained from http://physics.nist.gov/cgi-bin/ffast/ffast.pl +* Meshlab +* Geomview and Object File Format (OFF) +* jroff.jar - Java version of Geomview (display only) +* qhull +* Powercrust +* material datafile obtained from NIST FFast * %End *******************************************************************************/ DEFINE COMPONENT Filter From a968648698b41164db7287e7b2f2bdde07f8adf0 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 4 Jul 2026 16:32:31 +0200 Subject: [PATCH 02/11] Filter: new mu_col input for giving mu-column in case of 'special' files. --- mcxtrace-comps/optics/Filter.comp | 35 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/mcxtrace-comps/optics/Filter.comp b/mcxtrace-comps/optics/Filter.comp index e9938fc7a..203f527ed 100644 --- a/mcxtrace-comps/optics/Filter.comp +++ b/mcxtrace-comps/optics/Filter.comp @@ -42,7 +42,8 @@ * material_datafile: [str] File where the material parameters for the filter may be found. Format is similar to what may be found off the NIST website. [Be.txt] * geometry: [str] File containing the polygon definition of a general shape object. When xwidth is also given, the object is rescaled accordingly (OFF/PLY) * fixed_delta:[0/1] Use a fixed delta to compute refraction - useful for debugging. -* refraction: [0/1] If nonzero, refraction is enabled. (Only functional for box-geometery.) +* mu_col: [idx] Column index to pick up absorption length mu, counted from 0. Use with non-standard input file, e.g. 2-3 column files. -1 means attempt autodetect. +* refraction: [0/1] If nonzero, refraction is enabled. (Only functional for basic geometries, does not yet work for OFF) * * %Link * Meshlab @@ -56,7 +57,7 @@ DEFINE COMPONENT Filter SETTING PARAMETERS (refraction=0,fixed_delta=0,string material_datafile="Be.txt", - string geometry=0,xwidth=0,yheight=0,zdepth=0,radius=0) + string geometry=0,xwidth=0,yheight=0,zdepth=0,radius=0, int mu_col=-1) /* X-ray parameters: (x,y,z,kx,ky,kz,phi,t,Ex,Ey,Ez,p) */ @@ -158,24 +159,22 @@ INITIALIZE fprintf (stderr, "Warning(%s): %s not found in header of %s, set to 1\n", NAME_CURRENT_COMP, "rho", material_datafile); rho = 1; } - if (table.columns == 2) { - /*If we are using a 2 column format assume only attenuation and read from last column. - I.e. set the delta prefactor to 0*/ - mu_c = 1; - delta_prefactor = 0; - } else if (table.columns == 3) { - /*If we are using a 3 column format assume only attenuation and read from second column. - I.e. set the delta prefactor to 0*/ - mu_c = 1; - delta_prefactor = 0; - } else if (table.columns == 4) { - /*If we are using a 4 column format assume only attenuation and read from last column. - I.e. set the delta prefactor to 0*/ - mu_c = 3; - delta_prefactor = 0; - } else { + if (table.columns <6 || table.columns >=8 ) { + // "Few or many" columns, use mu_col to pinpoint mu column location + if (mu_col==-1 || mu_col>=table.columns) { + fprintf (stderr, "Error(%s): Found %i columns in %s. Did NOT detect known NIST file format. Please give a relevant mu_col value to define the mu-column! Exit!\n", NAME_CURRENT_COMP, table.columns, material_datafile); + } else { + mu_c=mu_col; + delta_prefactor = 0; + } + } else if (table.columns == 6) { + // "Legacy" NIST format mu_c = 5; delta_prefactor = NA * (rho * 1e-24) / Ar * 2.0 * M_PI * RE; + } else if (table.columns == 7) { + // "Updated" NIST format + mu_c = 6; + delta_prefactor = NA * (rho * 1e-24) / Ar * 2.0 * M_PI * RE; } if (10 * (double)mcget_ncount () > (table.max_x - table.min_x) / (table.step_x)) { /*it is probably worth Rebinning*/ From c6cdda73128091f9367fb8aa950924ae4ba1ad87 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 4 Jul 2026 16:43:56 +0200 Subject: [PATCH 03/11] Exit if we can not reliably determine file format and mu_col not given. --- mcxtrace-comps/optics/Filter.comp | 1 + 1 file changed, 1 insertion(+) diff --git a/mcxtrace-comps/optics/Filter.comp b/mcxtrace-comps/optics/Filter.comp index 203f527ed..7762cb020 100644 --- a/mcxtrace-comps/optics/Filter.comp +++ b/mcxtrace-comps/optics/Filter.comp @@ -163,6 +163,7 @@ INITIALIZE // "Few or many" columns, use mu_col to pinpoint mu column location if (mu_col==-1 || mu_col>=table.columns) { fprintf (stderr, "Error(%s): Found %i columns in %s. Did NOT detect known NIST file format. Please give a relevant mu_col value to define the mu-column! Exit!\n", NAME_CURRENT_COMP, table.columns, material_datafile); + exit(-1); } else { mu_c=mu_col; delta_prefactor = 0; From 794e8d8900ea20fdba95be97dd405e5b50526b13 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 4 Jul 2026 16:52:07 +0200 Subject: [PATCH 04/11] "Many columns -> NIST" but add support for mu_col use --- mcxtrace-comps/optics/Filter.comp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/mcxtrace-comps/optics/Filter.comp b/mcxtrace-comps/optics/Filter.comp index 7762cb020..a14f3ecfe 100644 --- a/mcxtrace-comps/optics/Filter.comp +++ b/mcxtrace-comps/optics/Filter.comp @@ -159,22 +159,25 @@ INITIALIZE fprintf (stderr, "Warning(%s): %s not found in header of %s, set to 1\n", NAME_CURRENT_COMP, "rho", material_datafile); rho = 1; } - if (table.columns <6 || table.columns >=8 ) { + if (table.columns <6) { // "Few or many" columns, use mu_col to pinpoint mu column location if (mu_col==-1 || mu_col>=table.columns) { fprintf (stderr, "Error(%s): Found %i columns in %s. Did NOT detect known NIST file format. Please give a relevant mu_col value to define the mu-column! Exit!\n", NAME_CURRENT_COMP, table.columns, material_datafile); exit(-1); } else { - mu_c=mu_col; + mu_c = mu_col; delta_prefactor = 0; } - } else if (table.columns == 6) { - // "Legacy" NIST format - mu_c = 5; - delta_prefactor = NA * (rho * 1e-24) / Ar * 2.0 * M_PI * RE; - } else if (table.columns == 7) { - // "Updated" NIST format - mu_c = 6; + } else if (table.columns >= 6) { + // ... fingers crossed this is "Legacy" NIST format + if (mu_col==-1) { + mu_c = 5; + } else if (mu_col (table.max_x - table.min_x) / (table.step_x)) { From cb29fb011706054ba62766c836662420eaedba11 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 4 Jul 2026 17:01:08 +0200 Subject: [PATCH 05/11] Set mu_col for "non-NIST" filter inputfiles --- mcxtrace-comps/examples/NBI/NBI_Lab_TOMO/NBI_Lab_TOMO.instr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mcxtrace-comps/examples/NBI/NBI_Lab_TOMO/NBI_Lab_TOMO.instr b/mcxtrace-comps/examples/NBI/NBI_Lab_TOMO/NBI_Lab_TOMO.instr index d39785c81..c83849693 100644 --- a/mcxtrace-comps/examples/NBI/NBI_Lab_TOMO/NBI_Lab_TOMO.instr +++ b/mcxtrace-comps/examples/NBI/NBI_Lab_TOMO/NBI_Lab_TOMO.instr @@ -101,7 +101,7 @@ ROTATED (0,Omega,0) RELATIVE Origin //chess king COMPONENT king =Filter( - material_datafile="Glass.dat", geometry="king.off",xwidth=1.5e-2,yheight=1.5e-2,zdepth=1.5e-2) + material_datafile="Glass.dat", mu_col=2, geometry="king.off",xwidth=1.5e-2,yheight=1.5e-2,zdepth=1.5e-2) AT(0,0,0) RELATIVE sample_mnt ROTATED (rx,ry,rz) RELATIVE sample_mnt @@ -111,7 +111,7 @@ COMPONENT e_mon1 = E_monitor( AT(0,0,d_sample_det-15e-3) RELATIVE sample_mnt COMPONENT filter_air=Filter( - material_datafile="FilterAir_1mm.dat",xwidth=detw,yheight=deth,zdepth=1e-3*10) + material_datafile="FilterAir_1mm.dat" mu_col=2,xwidth=detw,yheight=deth,zdepth=1e-3*10) AT(0,0,d_sample_det-20e-3+1e-3-0.2) RELATIVE sample_mnt COMPONENT filter_Al=Filter( From fe98dfda9f03c71b4f43e3fccbdb4381798f9544 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 4 Jul 2026 17:05:07 +0200 Subject: [PATCH 06/11] Use mu_col for relevant %Examples in Filter_test --- .../Test_Filter/Test_Filter.instr | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/mcxtrace-comps/examples/Tests_optics/Test_Filter/Test_Filter.instr b/mcxtrace-comps/examples/Tests_optics/Test_Filter/Test_Filter.instr index 2b5be7003..6814fe3f7 100644 --- a/mcxtrace-comps/examples/Tests_optics/Test_Filter/Test_Filter.instr +++ b/mcxtrace-comps/examples/Tests_optics/Test_Filter/Test_Filter.instr @@ -16,24 +16,25 @@ * Test instrument for checking the Filter.comp component * * %Parameters -* filter_mat: [] Chemical symbol of the filter material -* thickness: [m] thickness of the filter block -* L0: [AA] centre wavlength of the source -* DL: [AA] half width of the (uniform) wavelength distribution -* F2: [1] add a 2nd filter component further away +* filter_mat: [] Chemical symbol / datafile of the filter material +* thickness: [m] thickness of the filter block +* L0: [AA] centre wavlength of the source +* DL: [AA] half width of the (uniform) wavelength distribution +* F2: [1] add a 2nd filter component further away +* mu_col: [idx] Index of mu-column (from 0) in datafile (required for some inputs). * * %Example: DL=4.9 L0=5 filter_mat="Si.txt" Detector: l_mon1_I=1.31502e-07 * %Example: DL=4.9 L0=5 filter_mat="Rh.txt" Detector: l_mon1_I=4.04921e-29 * %Example: -n5e6 DL=4.9 L0=5 filter_mat="Ti.txt" F2=1 Detector: l_mon1_I=1.14111e-08 * %Example: DL=4.9 L0=5 filter_mat="Al.txt" Detector: l_mon1_I=1.04427e-07 -* %Example: DL=4.9 L0=5 filter_mat="Glass.dat" Detector: l_mon1_I=1.645e-06 +* %Example: DL=4.9 L0=5 filter_mat="Glass.dat" mu_col=2 Detector: l_mon1_I=1.645e-06 * %Example: DL=4.9 L0=5 filter_mat="Be.txt" Detector: l_mon1_I=0.000412661 -* %Example: DL=4.9 L0=5 filter_mat="FilterAir_1mm.dat" Detector: l_mon1_I=4.96145e-05 +* %Example: DL=4.9 L0=5 filter_mat="FilterAir_1mm.dat" mu_col=2 Detector: l_mon1_I=4.96145e-05 * * %End *******************************************************************************/ -DEFINE INSTRUMENT Test_Filter(string filter_mat="Rh.txt",thickness=100e-6,L0=1,DL=0.1, F2=0) +DEFINE INSTRUMENT Test_Filter(string filter_mat="Rh.txt",thickness=100e-6,L0=1,DL=0.1, F2=0, int mu_col=-1) DECLARE %{ @@ -61,12 +62,12 @@ COMPONENT l_mon0 = L_monitor( AT (0,0,1e-6) RELATIVE Source COMPONENT filter = Filter( - material_datafile=filter_mat, xwidth=0.1,yheight=0.1,zdepth=thickness + material_datafile=filter_mat, mu_col=mu_col, xwidth=0.1, yheight=0.1, zdepth=thickness ) AT (0,0,0.5) RELATIVE Source COMPONENT filter2 = Filter( - material_datafile=filter_mat,xwidth=0.1, yheight=0.1, zdepth=thickness + material_datafile=filter_mat, mu_col=mu_col, xwidth=0.1, yheight=0.1, zdepth=thickness ) WHEN(F2) AT (0,0,0.5+thickness+1e-3) RELATIVE Source From 70dbcd1f2168211338e7007efeb4b88a1edc3747 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 4 Jul 2026 17:09:43 +0200 Subject: [PATCH 07/11] Apply mccode-clangformat --- mcxtrace-comps/optics/Filter.comp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/mcxtrace-comps/optics/Filter.comp b/mcxtrace-comps/optics/Filter.comp index a14f3ecfe..30f8651ce 100644 --- a/mcxtrace-comps/optics/Filter.comp +++ b/mcxtrace-comps/optics/Filter.comp @@ -159,24 +159,27 @@ INITIALIZE fprintf (stderr, "Warning(%s): %s not found in header of %s, set to 1\n", NAME_CURRENT_COMP, "rho", material_datafile); rho = 1; } - if (table.columns <6) { + if (table.columns < 6) { // "Few or many" columns, use mu_col to pinpoint mu column location - if (mu_col==-1 || mu_col>=table.columns) { - fprintf (stderr, "Error(%s): Found %i columns in %s. Did NOT detect known NIST file format. Please give a relevant mu_col value to define the mu-column! Exit!\n", NAME_CURRENT_COMP, table.columns, material_datafile); - exit(-1); + if (mu_col == -1 || mu_col >= table.columns) { + fprintf (stderr, + "Error(%s): Found %i columns in %s. Did NOT detect known NIST file format. Please give a relevant mu_col value to define the mu-column! Exit!\n", + NAME_CURRENT_COMP, table.columns, material_datafile); + exit (-1); } else { mu_c = mu_col; delta_prefactor = 0; } } else if (table.columns >= 6) { // ... fingers crossed this is "Legacy" NIST format - if (mu_col==-1) { + if (mu_col == -1) { mu_c = 5; - } else if (mu_col Date: Sat, 4 Jul 2026 17:20:53 +0200 Subject: [PATCH 08/11] Add missing comma in NBI_Lab_TOMO --- mcxtrace-comps/examples/NBI/NBI_Lab_TOMO/NBI_Lab_TOMO.instr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcxtrace-comps/examples/NBI/NBI_Lab_TOMO/NBI_Lab_TOMO.instr b/mcxtrace-comps/examples/NBI/NBI_Lab_TOMO/NBI_Lab_TOMO.instr index c83849693..dc190d790 100644 --- a/mcxtrace-comps/examples/NBI/NBI_Lab_TOMO/NBI_Lab_TOMO.instr +++ b/mcxtrace-comps/examples/NBI/NBI_Lab_TOMO/NBI_Lab_TOMO.instr @@ -111,7 +111,7 @@ COMPONENT e_mon1 = E_monitor( AT(0,0,d_sample_det-15e-3) RELATIVE sample_mnt COMPONENT filter_air=Filter( - material_datafile="FilterAir_1mm.dat" mu_col=2,xwidth=detw,yheight=deth,zdepth=1e-3*10) + material_datafile="FilterAir_1mm.dat", mu_col=2,xwidth=detw,yheight=deth,zdepth=1e-3*10) AT(0,0,d_sample_det-20e-3+1e-3-0.2) RELATIVE sample_mnt COMPONENT filter_Al=Filter( From ab6320eb38527d6270fdf09090a04abb77360812 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 4 Jul 2026 17:33:27 +0200 Subject: [PATCH 09/11] mu seems to have been in col 1 in these files in fact --- mcxtrace-comps/examples/NBI/NBI_Lab_TOMO/NBI_Lab_TOMO.instr | 4 ++-- .../examples/Tests_optics/Test_Filter/Test_Filter.instr | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mcxtrace-comps/examples/NBI/NBI_Lab_TOMO/NBI_Lab_TOMO.instr b/mcxtrace-comps/examples/NBI/NBI_Lab_TOMO/NBI_Lab_TOMO.instr index dc190d790..79dc1a537 100644 --- a/mcxtrace-comps/examples/NBI/NBI_Lab_TOMO/NBI_Lab_TOMO.instr +++ b/mcxtrace-comps/examples/NBI/NBI_Lab_TOMO/NBI_Lab_TOMO.instr @@ -101,7 +101,7 @@ ROTATED (0,Omega,0) RELATIVE Origin //chess king COMPONENT king =Filter( - material_datafile="Glass.dat", mu_col=2, geometry="king.off",xwidth=1.5e-2,yheight=1.5e-2,zdepth=1.5e-2) + material_datafile="Glass.dat", mu_col=1, geometry="king.off",xwidth=1.5e-2,yheight=1.5e-2,zdepth=1.5e-2) AT(0,0,0) RELATIVE sample_mnt ROTATED (rx,ry,rz) RELATIVE sample_mnt @@ -111,7 +111,7 @@ COMPONENT e_mon1 = E_monitor( AT(0,0,d_sample_det-15e-3) RELATIVE sample_mnt COMPONENT filter_air=Filter( - material_datafile="FilterAir_1mm.dat", mu_col=2,xwidth=detw,yheight=deth,zdepth=1e-3*10) + material_datafile="FilterAir_1mm.dat", mu_col=1,xwidth=detw,yheight=deth,zdepth=1e-3*10) AT(0,0,d_sample_det-20e-3+1e-3-0.2) RELATIVE sample_mnt COMPONENT filter_Al=Filter( diff --git a/mcxtrace-comps/examples/Tests_optics/Test_Filter/Test_Filter.instr b/mcxtrace-comps/examples/Tests_optics/Test_Filter/Test_Filter.instr index 6814fe3f7..c6b856257 100644 --- a/mcxtrace-comps/examples/Tests_optics/Test_Filter/Test_Filter.instr +++ b/mcxtrace-comps/examples/Tests_optics/Test_Filter/Test_Filter.instr @@ -27,9 +27,9 @@ * %Example: DL=4.9 L0=5 filter_mat="Rh.txt" Detector: l_mon1_I=4.04921e-29 * %Example: -n5e6 DL=4.9 L0=5 filter_mat="Ti.txt" F2=1 Detector: l_mon1_I=1.14111e-08 * %Example: DL=4.9 L0=5 filter_mat="Al.txt" Detector: l_mon1_I=1.04427e-07 -* %Example: DL=4.9 L0=5 filter_mat="Glass.dat" mu_col=2 Detector: l_mon1_I=1.645e-06 +* %Example: DL=4.9 L0=5 filter_mat="Glass.dat" mu_col=1 Detector: l_mon1_I=1.645e-06 * %Example: DL=4.9 L0=5 filter_mat="Be.txt" Detector: l_mon1_I=0.000412661 -* %Example: DL=4.9 L0=5 filter_mat="FilterAir_1mm.dat" mu_col=2 Detector: l_mon1_I=4.96145e-05 +* %Example: DL=4.9 L0=5 filter_mat="FilterAir_1mm.dat" mu_col=1 Detector: l_mon1_I=4.96145e-05 * * %End *******************************************************************************/ From 13eaf84db588407ca4d056db6b75b1a47badce42 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 4 Jul 2026 17:38:57 +0200 Subject: [PATCH 10/11] Correct url --- mcxtrace-comps/optics/Filter.comp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcxtrace-comps/optics/Filter.comp b/mcxtrace-comps/optics/Filter.comp index 30f8651ce..9dff4cc03 100644 --- a/mcxtrace-comps/optics/Filter.comp +++ b/mcxtrace-comps/optics/Filter.comp @@ -47,7 +47,7 @@ * * %Link * Meshlab -* Geomview and Object File Format (OFF) +* Geomview and Object File Format (OFF) * jroff.jar - Java version of Geomview (display only) * qhull * Powercrust From 0b8047b138c793c6080c7784a5780c66ef0b87d8 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sat, 4 Jul 2026 17:42:20 +0200 Subject: [PATCH 11/11] More fixes for comp header --- mcxtrace-comps/optics/Filter.comp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mcxtrace-comps/optics/Filter.comp b/mcxtrace-comps/optics/Filter.comp index 9dff4cc03..e18918147 100644 --- a/mcxtrace-comps/optics/Filter.comp +++ b/mcxtrace-comps/optics/Filter.comp @@ -46,12 +46,12 @@ * refraction: [0/1] If nonzero, refraction is enabled. (Only functional for basic geometries, does not yet work for OFF) * * %Link -* Meshlab -* Geomview and Object File Format (OFF) +* Meshlab - viewer for OFF files +* Geomview and Object File Format (OFF) - OFF file definition and examples * jroff.jar - Java version of Geomview (display only) -* qhull -* Powercrust -* material datafile obtained from NIST FFast +* Qhull - for calculating a convex hull from points. +* Powercrust - for reconstructing a solid geometry from a point cloud. +* Most material datafile inpus may obtained from NIST FFast * %End *******************************************************************************/ DEFINE COMPONENT Filter