diff --git a/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_space/Unit_test_abs_logger_1D_space.instr b/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_space/Unit_test_abs_logger_1D_space.instr
index 9e20200e1a..3b98a73761 100644
--- a/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_space/Unit_test_abs_logger_1D_space.instr
+++ b/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_space/Unit_test_abs_logger_1D_space.instr
@@ -21,6 +21,7 @@
* Often used for detectors.
*
* %Example: Detector: abs_logger_1D_I=1.12609e-09
+* %Example: Detector: abs_logger_1D_con_I=4.95914e-13
*
* %End
*******************************************************************************/
@@ -62,16 +63,16 @@ AT (0,0,0) RELATIVE Origin
COMPONENT geometry_center = Arm()
AT (0,0,2.0) RELATIVE source
-COMPONENT box = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
+COMPONENT box_geometry = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
AT (-0.03,0,-0.05) RELATIVE geometry_center
-COMPONENT sphere = Union_sphere(radius=0.05, priority=6, material_string="material")
+COMPONENT sphere_geometry = Union_sphere(radius=0.05, priority=6, material_string="material")
AT (0.03,0,-0.04) RELATIVE geometry_center
-COMPONENT cylinder = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
+COMPONENT cylinder_geometry = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
AT (-0.03,0,0.02) RELATIVE geometry_center
-COMPONENT cone = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
+COMPONENT cone_geometry = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
AT (0.03,0,0.07) RELATIVE geometry_center
// Insert loggers to be tested here
@@ -79,9 +80,23 @@ COMPONENT abs_logger_1D = Union_abs_logger_1D_space(
yheight=0.2, n=100,
filename="Union_abs_logger_1D_space.dat")
AT (0,0,0) RELATIVE geometry_center
+
+// This logger will be affected by a conditional, impacts code path
+COMPONENT abs_logger_1D_con = Union_abs_logger_1D_space(
+ yheight=0.2, n=100,
+ filename="Union_abs_logger_1D_space_con.dat")
+AT (0,0,0) RELATIVE geometry_center
+
+// Conditional that takes right part of transmitted beam
+COMPONENT PSD_conditional = Union_conditional_PSD(
+ xwidth=0.1, yheight=0.2,
+ target_loggers="abs_logger_1D_con")
+AT (-0.05,0,1.0) RELATIVE geometry_center
+// Master at odd position to ensure that does not impact results
COMPONENT master = Union_master()
-AT(0,0,0) RELATIVE geometry_center
+AT(3, 0, -1) RELATIVE geometry_center
+ROTATED(20, -5, 8) RELATIVE geometry_center
COMPONENT transmission = PSD_monitor(
xwidth=0.1, yheight=0.08, nx=200, ny=200,
diff --git a/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_space_event/Unit_test_abs_logger_1D_space_event.instr b/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_space_event/Unit_test_abs_logger_1D_space_event.instr
index bbe08d2830..e05e8c73fe 100644
--- a/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_space_event/Unit_test_abs_logger_1D_space_event.instr
+++ b/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_space_event/Unit_test_abs_logger_1D_space_event.instr
@@ -58,25 +58,38 @@ AT (0,0,0) RELATIVE Origin
COMPONENT geometry_center = Arm()
AT (0,0,2.0) RELATIVE source
-COMPONENT box = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
+COMPONENT box_geometry = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
AT (-0.03,0,-0.05) RELATIVE geometry_center
-COMPONENT sphere = Union_sphere(radius=0.05, priority=6, material_string="material")
+COMPONENT sphere_geometry = Union_sphere(radius=0.05, priority=6, material_string="material")
AT (0.03,0,-0.04) RELATIVE geometry_center
-COMPONENT cylinder = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
+COMPONENT cylinder_geometry = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
AT (-0.03,0,0.02) RELATIVE geometry_center
-COMPONENT cone = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
+COMPONENT cone_geometry = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
AT (0.03,0,0.07) RELATIVE geometry_center
-COMPONENT abs_logger_1D = Union_abs_logger_1D_space_event(
+COMPONENT abs_logger_1D_space_event = Union_abs_logger_1D_space_event(
yheight=0.2, n=100, fake_event=1,
filename="Union_abs_logger_1D_space_event.dat")
AT (0,0,0) RELATIVE geometry_center
+
+COMPONENT abs_logger_1D_space_event_con = Union_abs_logger_1D_space_event(
+ yheight=0.2, n=100, fake_event=1,
+ filename="Union_abs_logger_1D_space_event_con.dat")
+AT (0,0,0) RELATIVE geometry_center
+
+// Conditional that takes right part of transmitted beam
+COMPONENT PSD_conditional = Union_conditional_PSD(
+ xwidth=0.1, yheight=0.2,
+ target_loggers="abs_logger_1D_space_event_con")
+AT (-0.05,0,1.0) RELATIVE geometry_center
+// Master at odd position to ensure that does not impact results
COMPONENT master = Union_master()
-AT(0,0,0) RELATIVE geometry_center
+AT (3, 0, -1) RELATIVE geometry_center
+ROTATED (20, -5, 8) RELATIVE geometry_center
COMPONENT transmission = PSD_monitor(
xwidth=0.1, yheight=0.08, nx=200, ny=200,
diff --git a/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_space_tof/Unit_test_abs_logger_1D_space_tof.instr b/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_space_tof/Unit_test_abs_logger_1D_space_tof.instr
index ef5394dd29..1d4b33629a 100644
--- a/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_space_tof/Unit_test_abs_logger_1D_space_tof.instr
+++ b/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_space_tof/Unit_test_abs_logger_1D_space_tof.instr
@@ -20,6 +20,7 @@
* time of absorption in a histogram.
*
* %Example: Detector: abs_logger_1D_space_tof_I=1.12682e-09
+* %Example: Detector: abs_logger_1D_space_tof_con_I=5.38067e-13
*
* %End
*******************************************************************************/
@@ -53,38 +54,52 @@ COMPONENT Origin = Progress_bar()
AT (0,0,0) ABSOLUTE
COMPONENT source = Source_div(
- xwidth=0.02, yheight=0.002,
- focus_aw=0.01, focus_ah=0.01,
- E0=10, dE=0.1)
+ xwidth=0.02, yheight=0.002,
+ focus_aw=0.01, focus_ah=0.01,
+ E0=10, dE=0.1)
AT (0,0,0) RELATIVE Origin
COMPONENT geometry_center = Arm()
AT (0,0,2.0) RELATIVE source
-COMPONENT box = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
+COMPONENT box_geometry = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
AT (-0.03,0,-0.05) RELATIVE geometry_center
-COMPONENT sphere = Union_sphere(radius=0.05, priority=6, material_string="material")
+COMPONENT sphere_geometry = Union_sphere(radius=0.05, priority=6, material_string="material")
AT (0.03,0,-0.04) RELATIVE geometry_center
-COMPONENT cylinder = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
+COMPONENT cylinder_geometry = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
AT (-0.03,0,0.02) RELATIVE geometry_center
-COMPONENT cone = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
+COMPONENT cone_geometry = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
AT (0.03,0,0.07) RELATIVE geometry_center
COMPONENT abs_logger_1D_space_tof = Union_abs_logger_1D_space_tof(
- yheight=0.2, n=100,
- time_min=0.0013, time_max=0.0022, time_bins=1000,
- filename="Union_abs_logger_1D_space_tof.dat")
+ yheight=0.2, n=100,
+ time_min=0.0013, time_max=0.0022, time_bins=1000,
+ filename="Union_abs_logger_1D_space_tof.dat")
AT (0,0,0) RELATIVE geometry_center
-
+
+COMPONENT abs_logger_1D_space_tof_con = Union_abs_logger_1D_space_tof(
+ yheight=0.2, n=100,
+ time_min=0.0013, time_max=0.0022, time_bins=1000,
+ filename="Union_abs_logger_1D_space_tof_con.dat")
+AT (0,0,0) RELATIVE geometry_center
+
+// Conditional that takes right part of transmitted beam
+COMPONENT PSD_conditional = Union_conditional_PSD(
+ xwidth=0.1, yheight=0.2,
+ target_loggers="abs_logger_1D_space_tof_con")
+AT (-0.05,0,1.0) RELATIVE geometry_center
+
+// Master at odd position to ensure that does not impact results
COMPONENT master = Union_master()
-AT(0,0,0) RELATIVE geometry_center
+AT (3, 0, -1) RELATIVE geometry_center
+ROTATED (20, -5, 8) RELATIVE geometry_center
COMPONENT transmission = PSD_monitor(
- xwidth=0.1, yheight=0.08, nx=200, ny=200,
- filename="PSD.dat", restore_neutron=1)
+ xwidth=0.1, yheight=0.08, nx=200, ny=200,
+ filename="PSD.dat", restore_neutron=1)
AT (0,0,1) RELATIVE geometry_center
COMPONENT stop = Union_stop()
diff --git a/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_space_tof_to_lambda/Unit_test_abs_logger_1D_space_tof_to_lambda.instr b/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_space_tof_to_lambda/Unit_test_abs_logger_1D_space_tof_to_lambda.instr
index d6b736ffc7..a00f9698ec 100644
--- a/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_space_tof_to_lambda/Unit_test_abs_logger_1D_space_tof_to_lambda.instr
+++ b/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_space_tof_to_lambda/Unit_test_abs_logger_1D_space_tof_to_lambda.instr
@@ -26,8 +26,9 @@
* both the standard view with measured and true wavelength on each axis, and the
* relative where they have been normalized and a value of 1 is expected.
*
-* %Example: Detector: abs_logger_1D_space_tof_to_lambda_I=9.82157e-12
-* %Example: Detector: abs_logger_1D_space_tof_to_lambda_relative_I=1.02297e-11
+* %Example: Detector: abs_logger_1D_space_tof_to_lambda_I=5.40132e-12
+* %Example: Detector: abs_logger_1D_space_tof_to_lambda_relative_I=5.41367e-12
+* %Example: Detector: abs_logger_1D_space_tof_to_lambda_con_I=8.13732e-13
*
* %End
*******************************************************************************/
@@ -57,6 +58,10 @@ COMPONENT material = Union_make_material(my_absorption=4.0,
process_string="incoherent,powder")
AT (0,0,0) ABSOLUTE
+COMPONENT inc_material = Union_make_material(my_absorption=1.0,
+ process_string="incoherent")
+AT (0,0,0) ABSOLUTE
+
COMPONENT Origin = Progress_bar()
AT (0,0,0) ABSOLUTE
@@ -69,46 +74,73 @@ AT (0,0,0) RELATIVE Origin
COMPONENT geometry_center = Arm()
AT (0,0,10.0) RELATIVE source
-COMPONENT sphere = Union_sphere(radius=0.02, priority=6, material_string="material")
+COMPONENT sphere_geometry = Union_sphere(
+ radius=0.02, priority=6, material_string="inc_material", p_interact=0.2,
+ focus_xw=0.1, focus_xh=0.9, target_x=-0.5, target_y=0, target_z=0)
AT (0,0,0) RELATIVE geometry_center
-COMPONENT box = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
+COMPONENT box_geometry = Union_box(
+ xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="inc_material", p_interact=0.2,
+ focus_xw=0.1, focus_xh=0.9, target_x=-0.5, target_y=0, target_z=0)
AT (-0.03,0,-0.01) RELATIVE geometry_center
-COMPONENT cone = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
+COMPONENT cone_geometry = Union_cone(
+ radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="inc_material", p_interact=0.2,
+ focus_xw=0.1, focus_xh=0.9, target_x=-0.5, target_y=0, target_z=0)
AT (0.03,0,0.02) RELATIVE geometry_center
-COMPONENT cylinder = Union_cylinder(radius=0.02, yheight=0.8, priority=7, material_string="material")
-AT (-1.0,0,0.0) RELATIVE geometry_center
+COMPONENT cylinder_geometry = Union_cylinder(
+ radius=0.03, yheight=0.8, priority=7, material_string="material")
+AT (-0.5,0,0.0) RELATIVE geometry_center
COMPONENT abs_logger_1D_space_tof_to_lambda = Union_abs_logger_1D_space_tof_to_lambda(
yheight=0.8, yn=100,
- target_geometry="cylinder",
+ target_geometry="cylinder_geometry",
ref_component=-5,
source_sample_dist=10.0,
lambda_min=2.0, lambda_max=8.0, lambda_bins=200,
filename="Union_abs_logger_1D_space_tof_to_lambda.dat")
-AT (0,0,0) RELATIVE cylinder
+AT (0,0,0) RELATIVE cylinder_geometry
COMPONENT abs_logger_1D_space_tof_to_lambda_relative = Union_abs_logger_1D_space_tof_to_lambda(
yheight=0.8, yn=100,
- target_geometry="cylinder",
+ target_geometry="cylinder_geometry",
ref_component=-6,
source_sample_dist=10.0,
lambda_min=2.0, lambda_max=8.0, lambda_bins=200,
filename="Union_abs_logger_1D_space_tof_to_lambda_relative.dat",
relative_measured=1, relative_min=0.95, relative_max=1.05, relative_bins=100)
-AT (0,0,0) RELATIVE cylinder
+AT (0,0,0) RELATIVE cylinder_geometry
+
+COMPONENT abs_logger_1D_space_tof_to_lambda_con = Union_abs_logger_1D_space_tof_to_lambda(
+ yheight=0.8, yn=100,
+ target_geometry="cylinder_geometry",
+ ref_component=-7,
+ source_sample_dist=10.0,
+ lambda_min=2.0, lambda_max=8.0, lambda_bins=200,
+ filename="Union_abs_logger_1D_space_tof_to_lambda_con.dat")
+AT (0,0,0) RELATIVE cylinder_geometry
+
+COMPONENT conditional_direction = Arm()
+AT (0,0,0) RELATIVE geometry_center
+ROTATED (0,-90,0) RELATIVE geometry_center
+// Conditional in direction of cylinder
+COMPONENT PSD_conditional = Union_conditional_PSD(
+ xwidth=0.2, yheight=1.5,
+ target_loggers="abs_logger_1D_space_tof_to_lambda_con")
+AT (0,0,0.6) RELATIVE conditional_direction
+
+// Master at odd position to ensure that does not impact results
COMPONENT master = Union_master()
-AT(0,0,0) RELATIVE geometry_center
+AT(3,0,-1) RELATIVE geometry_center
+ROTATED(20,-5,8) RELATIVE geometry_center
COMPONENT transmission = PSD_monitor(
xwidth=0.1, yheight=0.08, nx=200, ny=200,
filename="PSD.dat", restore_neutron=1)
AT (0,0,1) RELATIVE geometry_center
-
COMPONENT stop = Union_stop()
AT (0,0,0) ABSOLUTE
diff --git a/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_time/Unit_test_abs_logger_1D_time.instr b/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_time/Unit_test_abs_logger_1D_time.instr
new file mode 100644
index 0000000000..0c8a46a0ab
--- /dev/null
+++ b/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_1D_time/Unit_test_abs_logger_1D_time.instr
@@ -0,0 +1,106 @@
+/*******************************************************************************
+*
+* McStas, neutron ray-tracing package
+* Copyright (C) 1997-2008, All rights reserved
+* Risoe National Laboratory, Roskilde, Denmark
+* Institut Laue Langevin, Grenoble, France
+*
+* Instrument: Unit_test_abs_logger_1D_time
+*
+* %Identification
+* Written by: Mads Bertelsen
+* Date: April 2026
+* Origin: ESS
+* %INSTRUMENT_SITE: Tests_union
+*
+* Test of Union 1D time absorption logger
+*
+* %Description
+* Test instrument for the Union 1D absorption logger component that can log
+* absorbed intensity as a function of time.
+*
+* %Example: Detector: Union_abs_logger_1D_time_I=5.66453e-09
+* %Example: Detector: Union_abs_logger_1D_time_con_I=2.80778e-12
+*
+* %End
+*******************************************************************************/
+
+DEFINE INSTRUMENT Unit_test_abs_logger_1D_time()
+
+DECLARE
+%{
+%}
+
+INITIALIZE
+%{
+%}
+
+TRACE
+
+COMPONENT init = Union_init()
+AT (0,0,0) ABSOLUTE
+
+COMPONENT incoherent = Incoherent_process(sigma=0.2, packing_factor=1, unit_cell_volume=66.4)
+AT (0,0,0) ABSOLUTE
+
+COMPONENT powder = Powder_process(reflections="Cu2MnAl.laz")
+AT (0,0,0) ABSOLUTE
+
+COMPONENT material = Union_make_material(my_absorption=4.0,
+ process_string="incoherent,powder")
+AT (0,0,0) ABSOLUTE
+
+COMPONENT Origin = Progress_bar()
+ AT (0,0,0) ABSOLUTE
+
+COMPONENT source = Source_div(
+ xwidth=0.02, yheight=0.002,
+ focus_aw=0.01, focus_ah=0.01,
+ E0=10, dE=0.1)
+AT (0,0,0) RELATIVE Origin
+
+COMPONENT geometry_center = Arm()
+AT (0,0,2.0) RELATIVE source
+
+COMPONENT box_geometry = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
+AT (-0.03,0,-0.05) RELATIVE geometry_center
+
+COMPONENT sphere_geometry = Union_sphere(radius=0.05, priority=6, material_string="material")
+AT (0.03,0,-0.04) RELATIVE geometry_center
+
+COMPONENT cylinder_geometry = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
+AT (-0.03,0,0.02) RELATIVE geometry_center
+
+COMPONENT cone_geometry = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
+AT (0.03,0,0.07) RELATIVE geometry_center
+
+COMPONENT Union_abs_logger_1D_time = Union_logger_1D(
+ min_value=0.0013, max_value=0.0022, n1=200,
+ filename="Union_abs_logger_1D_time.dat")
+AT (0,0,0) RELATIVE geometry_center
+
+COMPONENT Union_abs_logger_1D_time_con = Union_logger_1D(
+ min_value=0.0013, max_value=0.0022, n1=200,
+ filename="Union_abs_logger_1D_time_con.dat")
+AT (0,0,0) RELATIVE geometry_center
+
+// Conditional that takes right part of transmitted beam
+COMPONENT PSD_conditional = Union_conditional_PSD(
+ xwidth=0.1, yheight=0.2,
+ target_loggers="Union_abs_logger_1D_time_con")
+AT (-0.05,0,1.0) RELATIVE geometry_center
+
+// Master at odd position to ensure that does not impact results
+COMPONENT master = Union_master()
+AT (3, 0, -1) RELATIVE geometry_center
+ROTATED (20, -5, 8) RELATIVE geometry_center
+
+COMPONENT transmission = PSD_monitor(
+ xwidth=0.1, yheight=0.08, nx=200, ny=200,
+ filename="PSD.dat", restore_neutron=1)
+AT (0,0,1) RELATIVE geometry_center
+
+COMPONENT stop = Union_stop()
+AT (0,0,0) ABSOLUTE
+
+END
diff --git a/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_2D_space/Unit_test_abs_logger_2D_space.instr b/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_2D_space/Unit_test_abs_logger_2D_space.instr
index 44049ea3fa..73cd964e66 100644
--- a/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_2D_space/Unit_test_abs_logger_2D_space.instr
+++ b/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_2D_space/Unit_test_abs_logger_2D_space.instr
@@ -19,6 +19,7 @@
* Test of absorption logger with basic geometry from Unit_test_loggers_base.
*
* %Example: Detector: Union_abs_logger_2D_space_zx_I=1.1258e-09
+* %Example: Detector: Union_abs_logger_2D_space_zx_con_I=5.22667e-13
*
* %End
*******************************************************************************/
@@ -60,16 +61,16 @@ AT (0,0,0) RELATIVE Origin
COMPONENT geometry_center = Arm()
AT (0,0,2.0) RELATIVE source
-COMPONENT box = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
+COMPONENT box_geometry = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
AT (-0.03,0,-0.05) RELATIVE geometry_center
-COMPONENT sphere = Union_sphere(radius=0.05, priority=6, material_string="material")
+COMPONENT sphere_geometry = Union_sphere(radius=0.05, priority=6, material_string="material")
AT (0.03,0,-0.04) RELATIVE geometry_center
-COMPONENT cylinder = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
+COMPONENT cylinder_geometry = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
AT (-0.03,0,0.02) RELATIVE geometry_center
-COMPONENT cone = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
+COMPONENT cone_geometry = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
AT (0.03,0,0.07) RELATIVE geometry_center
COMPONENT Union_abs_logger_2D_space_zx = Union_abs_logger_2D_space(
@@ -83,9 +84,23 @@ COMPONENT Union_abs_logger_2D_space_zy = Union_abs_logger_2D_space(
D_direction_2="y", D2_min=-0.1, D2_max=0.1, n2=200,
filename="Union_abs_logger_2D_space_zy.dat")
AT (0,0,0) RELATIVE geometry_center
+
+COMPONENT Union_abs_logger_2D_space_zx_con = Union_abs_logger_2D_space(
+ D_direction_1="z", D1_min=-0.15, D1_max=0.15, n1=200,
+ D_direction_2="x", D2_min=-0.1, D2_max=0.1, n2=200,
+ filename="Union_abs_logger_2D_space_zx_con.dat")
+AT (0,0,0) RELATIVE geometry_center
+
+// Conditional that takes right part of transmitted beam
+COMPONENT PSD_conditional = Union_conditional_PSD(
+ xwidth=0.1, yheight=0.2,
+ target_loggers="Union_abs_logger_2D_space_zx_con")
+AT (-0.05,0,1.0) RELATIVE geometry_center
+// Master at odd position to ensure that does not impact results
COMPONENT master = Union_master()
-AT(0,0,0) RELATIVE geometry_center
+AT (3, 0, -1) RELATIVE geometry_center
+ROTATED (20, -5, 8) RELATIVE geometry_center
COMPONENT transmission = PSD_monitor(
xwidth=0.1, yheight=0.08, nx=200, ny=200,
diff --git a/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_event/Unit_test_abs_logger_event.instr b/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_event/Unit_test_abs_logger_event.instr
index 9984185fef..f6297c943a 100644
--- a/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_event/Unit_test_abs_logger_event.instr
+++ b/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_event/Unit_test_abs_logger_event.instr
@@ -59,23 +59,34 @@ AT (0,0,0) RELATIVE Origin
COMPONENT geometry_center = Arm()
AT (0,0,2.0) RELATIVE source
-COMPONENT box = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
+COMPONENT box_geometry = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
AT (-0.03,0,-0.05) RELATIVE geometry_center
-COMPONENT sphere = Union_sphere(radius=0.05, priority=6, material_string="material")
+COMPONENT sphere_geometry = Union_sphere(radius=0.05, priority=6, material_string="material")
AT (0.03,0,-0.04) RELATIVE geometry_center
-COMPONENT cylinder = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
+COMPONENT cylinder_geometry = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
AT (-0.03,0,0.02) RELATIVE geometry_center
-COMPONENT cone = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
+COMPONENT cone_geometry = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
AT (0.03,0,0.07) RELATIVE geometry_center
COMPONENT Union_abs_logger_event = Union_abs_logger_event(filename="Union_abs_logger_event")
AT (0,0,0) RELATIVE geometry_center
+
+COMPONENT Union_abs_logger_event_con = Union_abs_logger_event(filename="Union_abs_logger_event_con")
+AT (0,0,0) RELATIVE geometry_center
+// Conditional that takes right part of transmitted beam
+COMPONENT PSD_conditional = Union_conditional_PSD(
+ xwidth=0.1, yheight=0.2,
+ target_loggers="Union_abs_logger_event_con")
+AT (-0.05,0,1.0) RELATIVE geometry_center
+
+// Master at odd position to ensure that does not impact results
COMPONENT master = Union_master()
-AT(0,0,0) RELATIVE geometry_center
+AT (3, 0, -1) RELATIVE geometry_center
+ROTATED (20, -5, 8) RELATIVE geometry_center
COMPONENT transmission = PSD_monitor(
xwidth=0.1, yheight=0.08, nx=200, ny=200,
diff --git a/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_nD/Unit_test_abs_logger_nD.instr b/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_nD/Unit_test_abs_logger_nD.instr
index 4c3bb33528..aee5455bdd 100644
--- a/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_nD/Unit_test_abs_logger_nD.instr
+++ b/mcstas-comps/examples/Tests_union/Unit_test_abs_logger_nD/Unit_test_abs_logger_nD.instr
@@ -21,6 +21,7 @@
* geometry, leaving the ray positions where they were.
*
* %Example: Detector: abs_logger_nD_I=1.58102e-09
+* %Example: Detector: abs_logger_nD_con_I=2.11523e-12
*
* %End
*******************************************************************************/
@@ -59,16 +60,16 @@ AT (0,0,0) RELATIVE Origin
COMPONENT geometry_center = Arm()
AT (0,0,2.0) RELATIVE source
-COMPONENT box = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
+COMPONENT box_geometry = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
AT (-0.03,0,-0.05) RELATIVE geometry_center
-COMPONENT sphere = Union_sphere(radius=0.05, priority=6, material_string="material")
+COMPONENT sphere_geometry = Union_sphere(radius=0.05, priority=6, material_string="material")
AT (0.03,0,-0.04) RELATIVE geometry_center
-COMPONENT cylinder = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
+COMPONENT cylinder_geometry = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
AT (-0.03,0,0.02) RELATIVE geometry_center
-COMPONENT cone = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
+COMPONENT cone_geometry = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
AT (0.03,0,0.07) RELATIVE geometry_center
COMPONENT abs_logger_nD = Union_abs_logger_nD(
@@ -76,9 +77,23 @@ COMPONENT abs_logger_nD = Union_abs_logger_nD(
options="preivous, y limits=[-0.1 0.1] bins=100",
filename="Union_abs_logger_nD.dat")
AT (0,0,0) RELATIVE geometry_center
-
-COMPONENT master = Union_master(verbal=0)
-AT(0,0,0) RELATIVE geometry_center
+
+COMPONENT abs_logger_nD_con = Union_abs_logger_nD(
+ xwidth=0.1, yheight=0.02,
+ options="preivous, y limits=[-0.1 0.1] bins=100",
+ filename="Union_abs_logger_nD_con.dat")
+AT (0,0,0) RELATIVE geometry_center
+
+// Conditional that takes right part of transmitted beam
+COMPONENT PSD_conditional = Union_conditional_PSD(
+ xwidth=0.1, yheight=0.2,
+ target_loggers="abs_logger_nD_con")
+AT (-0.05,0,1.0) RELATIVE geometry_center
+
+// Master at odd position to ensure that does not impact results
+COMPONENT master = Union_master()
+AT (3,0,-1) RELATIVE geometry_center
+ROTATED (20,-5,8) RELATIVE geometry_center
COMPONENT transmission = PSD_monitor(
xwidth=0.1, yheight=0.08, nx=200, ny=200,
diff --git a/mcstas-comps/examples/Tests_union/Unit_test_logger_1D/Unit_test_logger_1D.instr b/mcstas-comps/examples/Tests_union/Unit_test_logger_1D/Unit_test_logger_1D.instr
index c0eb0a240e..582db3de5a 100644
--- a/mcstas-comps/examples/Tests_union/Unit_test_logger_1D/Unit_test_logger_1D.instr
+++ b/mcstas-comps/examples/Tests_union/Unit_test_logger_1D/Unit_test_logger_1D.instr
@@ -19,6 +19,9 @@
* Test instrument for the Union 1D logger component that can log scattering
* intensity as a function of one of several quantities, here time.
*
+* %Example: Detector: Union_logger_1D_I=5.65843e-09
+* %Example: Detector: Union_logger_1D_con_I=2.73754e-12
+*
* %End
*******************************************************************************/
@@ -59,25 +62,38 @@ AT (0,0,0) RELATIVE Origin
COMPONENT geometry_center = Arm()
AT (0,0,2.0) RELATIVE source
-COMPONENT box = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
+COMPONENT box_geometry = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
AT (-0.03,0,-0.05) RELATIVE geometry_center
-COMPONENT sphere = Union_sphere(radius=0.05, priority=6, material_string="material")
+COMPONENT sphere_geometry = Union_sphere(radius=0.05, priority=6, material_string="material")
AT (0.03,0,-0.04) RELATIVE geometry_center
-COMPONENT cylinder = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
+COMPONENT cylinder_geometry = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
AT (-0.03,0,0.02) RELATIVE geometry_center
-COMPONENT cone = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
+COMPONENT cone_geometry = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
AT (0.03,0,0.07) RELATIVE geometry_center
COMPONENT Union_logger_1D = Union_logger_1D(
variable="time", min_value=0.0013, max_value=0.0022, n1=200,
filename="Union_logger_1D.dat")
AT (0,0,0) RELATIVE geometry_center
+
+COMPONENT Union_logger_1D_con = Union_logger_1D(
+ variable="time", min_value=0.0013, max_value=0.0022, n1=200,
+ filename="Union_logger_1D_con.dat")
+AT (0,0,0) RELATIVE geometry_center
+
+// Conditional that takes right part of transmitted beam
+COMPONENT PSD_conditional = Union_conditional_PSD(
+ xwidth=0.1, yheight=0.2,
+ target_loggers="Union_logger_1D_con")
+AT (-0.05,0,1.0) RELATIVE geometry_center
COMPONENT master = Union_master()
-AT(0,0,0) RELATIVE geometry_center
+AT (12,-2,4) RELATIVE geometry_center
+ROTATED (22, -47, 7) RELATIVE geometry_center
+
COMPONENT transmission = PSD_monitor(
xwidth=0.1, yheight=0.08, nx=200, ny=200,
diff --git a/mcstas-comps/examples/Tests_union/Unit_test_logger_2DQ/Unit_test_logger_2DQ.instr b/mcstas-comps/examples/Tests_union/Unit_test_logger_2DQ/Unit_test_logger_2DQ.instr
index aae533534f..844209f833 100644
--- a/mcstas-comps/examples/Tests_union/Unit_test_logger_2DQ/Unit_test_logger_2DQ.instr
+++ b/mcstas-comps/examples/Tests_union/Unit_test_logger_2DQ/Unit_test_logger_2DQ.instr
@@ -20,6 +20,9 @@
* using the 2DQ logger that histograms occurances of the scattering vectors for
* scattering events in the Union system projected onto a chosen 2D plane.
*
+* %Example: Detector: Detector: Union_logger_2DQ_I=5.66139e-09
+* %Example: Detector: Union_logger_2DQ_con_I=2.77306e-12
+*
* %End
*******************************************************************************/
@@ -60,27 +63,40 @@ AT (0,0,0) RELATIVE Origin
COMPONENT geometry_center = Arm()
AT (0,0,2.0) RELATIVE source
-COMPONENT box = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
+COMPONENT box_geometry = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
AT (-0.03,0,-0.05) RELATIVE geometry_center
-COMPONENT sphere = Union_sphere(radius=0.05, priority=6, material_string="material")
+COMPONENT sphere_geometry = Union_sphere(radius=0.05, priority=6, material_string="material")
AT (0.03,0,-0.04) RELATIVE geometry_center
-COMPONENT cylinder = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
+COMPONENT cylinder_geometry = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
AT (-0.03,0,0.02) RELATIVE geometry_center
-COMPONENT cone = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
+COMPONENT cone_geometry = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
AT (0.03,0,0.07) RELATIVE geometry_center
-// Insert loggers to be tested here
COMPONENT Union_logger_2DQ = Union_logger_2DQ(
Q_direction_1="z", Q1_min=-5.0, Q1_max=5.0, n1=200,
Q_direction_2="x", Q2_min=-5.0, Q2_max=5.0, n2=200,
filename="Union_logger_2DQ.dat")
AT (0,0,0) RELATIVE geometry_center
+
+COMPONENT Union_logger_2DQ_con = Union_logger_2DQ(
+ Q_direction_1="z", Q1_min=-5.0, Q1_max=5.0, n1=200,
+ Q_direction_2="x", Q2_min=-5.0, Q2_max=5.0, n2=200,
+ filename="Union_logger_2DQ_con.dat")
+AT (0,0,0) RELATIVE geometry_center
+
+// Conditional that takes right part of transmitted beam
+COMPONENT PSD_conditional = Union_conditional_PSD(
+ xwidth=0.1, yheight=0.2,
+ target_loggers="Union_logger_2DQ_con")
+AT (-0.05,0,1.0) RELATIVE geometry_center
COMPONENT master = Union_master()
-AT(0,0,0) RELATIVE geometry_center
+AT (12,-2,4) RELATIVE geometry_center
+ROTATED (22, -47, 7) RELATIVE geometry_center
+
COMPONENT transmission = PSD_monitor(
xwidth=0.1, yheight=0.08, nx=200, ny=200,
diff --git a/mcstas-comps/examples/Tests_union/Unit_test_logger_2D_kf/Unit_test_logger_2D_kf.instr b/mcstas-comps/examples/Tests_union/Unit_test_logger_2D_kf/Unit_test_logger_2D_kf.instr
index 8bdf41dd4f..8c85821940 100644
--- a/mcstas-comps/examples/Tests_union/Unit_test_logger_2D_kf/Unit_test_logger_2D_kf.instr
+++ b/mcstas-comps/examples/Tests_union/Unit_test_logger_2D_kf/Unit_test_logger_2D_kf.instr
@@ -20,6 +20,9 @@
* wavevector after each scattering event, projects it onto a specified 2D plane
* and histograms these using the scattered intensity.
*
+* %Example: Detector: Union_logger_2D_kf_I=5.65899e-09
+* %Example: Detector: Union_logger_2D_kf_con_I=2.52412e-12
+*
* %End
*******************************************************************************/
@@ -60,16 +63,16 @@ AT (0,0,0) RELATIVE Origin
COMPONENT geometry_center = Arm()
AT (0,0,2.0) RELATIVE source
-COMPONENT box = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
+COMPONENT box_geometry = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
AT (-0.03,0,-0.05) RELATIVE geometry_center
-COMPONENT sphere = Union_sphere(radius=0.05, priority=6, material_string="material")
+COMPONENT sphere_geometry = Union_sphere(radius=0.05, priority=6, material_string="material")
AT (0.03,0,-0.04) RELATIVE geometry_center
-COMPONENT cylinder = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
+COMPONENT cylinder_geometry = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
AT (-0.03,0,0.02) RELATIVE geometry_center
-COMPONENT cone = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
+COMPONENT cone_geometry = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
AT (0.03,0,0.07) RELATIVE geometry_center
COMPONENT Union_logger_2D_kf = Union_logger_2D_kf(
@@ -77,9 +80,22 @@ COMPONENT Union_logger_2D_kf = Union_logger_2D_kf(
Q_direction_2="x", Q2_min=-3.0, Q2_max=3.0, n2=200,
filename="Union_logger_2D_kf.dat")
AT (0,0,0) RELATIVE geometry_center
+
+COMPONENT Union_logger_2D_kf_con = Union_logger_2D_kf(
+ Q_direction_1="z", Q1_min=-3.0, Q1_max=3.0, n1=200,
+ Q_direction_2="x", Q2_min=-3.0, Q2_max=3.0, n2=200,
+ filename="Union_logger_2D_kf_con.dat")
+AT (0,0,0) RELATIVE geometry_center
+
+// Conditional that takes right part of transmitted beam
+COMPONENT PSD_conditional = Union_conditional_PSD(
+ xwidth=0.1, yheight=0.2,
+ target_loggers="Union_logger_2D_kf_con")
+AT (-0.05,0,1.0) RELATIVE geometry_center
COMPONENT master = Union_master()
-AT(0,0,0) RELATIVE geometry_center
+AT (12,-2,4) RELATIVE geometry_center
+ROTATED (22, -47, 7) RELATIVE geometry_center
COMPONENT transmission = PSD_monitor(
xwidth=0.1, yheight=0.08, nx=200, ny=200,
diff --git a/mcstas-comps/examples/Tests_union/Unit_test_logger_2D_kf_time/Unit_test_logger_2D_kf_time.instr b/mcstas-comps/examples/Tests_union/Unit_test_logger_2D_kf_time/Unit_test_logger_2D_kf_time.instr
index 14c9b0363b..68af16a48f 100644
--- a/mcstas-comps/examples/Tests_union/Unit_test_logger_2D_kf_time/Unit_test_logger_2D_kf_time.instr
+++ b/mcstas-comps/examples/Tests_union/Unit_test_logger_2D_kf_time/Unit_test_logger_2D_kf_time.instr
@@ -20,6 +20,9 @@
* scattering event in a 2D plane, and these are further distributed into a number
* of time bins so the time evolution of final wavevectors can be monitored.
*
+* %Example: Detector: Union_logger_2D_kf_time_I=3.82325e-09
+* %Example: Detector: Union_logger_2D_kf_time_con_I=1.82363e-12
+*
* %End
*******************************************************************************/
@@ -60,28 +63,42 @@ AT (0,0,0) RELATIVE Origin
COMPONENT geometry_center = Arm()
AT (0,0,2.0) RELATIVE source
-COMPONENT box = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
+COMPONENT box_geometry = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
AT (-0.03,0,-0.05) RELATIVE geometry_center
-COMPONENT sphere = Union_sphere(radius=0.05, priority=6, material_string="material")
+COMPONENT sphere_geometry = Union_sphere(radius=0.05, priority=6, material_string="material")
AT (0.03,0,-0.04) RELATIVE geometry_center
-COMPONENT cylinder = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
+COMPONENT cylinder_geometry = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
AT (-0.03,0,0.02) RELATIVE geometry_center
-COMPONENT cone = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
+COMPONENT cone_geometry = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
AT (0.03,0,0.07) RELATIVE geometry_center
-// Insert loggers to be tested here
COMPONENT Union_logger_2D_kf_time = Union_logger_2D_kf_time(
Q_direction_1="z", Q1_min=-3.0, Q1_max=3.0, n1=200,
Q_direction_2="x", Q2_min=-3.0, Q2_max=3.0, n2=200,
time_bins=5, time_min=0.0014, time_max=0.0018,
filename="Union_logger_2D_kf_time.dat")
AT (0,0,0) RELATIVE geometry_center
+
+COMPONENT Union_logger_2D_kf_time_con = Union_logger_2D_kf_time(
+ Q_direction_1="z", Q1_min=-3.0, Q1_max=3.0, n1=200,
+ Q_direction_2="x", Q2_min=-3.0, Q2_max=3.0, n2=200,
+ time_bins=5, time_min=0.0014, time_max=0.0018,
+ filename="Union_logger_2D_kf_time_con.dat")
+AT (0,0,0) RELATIVE geometry_center
+
+// Conditional that takes right part of transmitted beam
+COMPONENT PSD_conditional = Union_conditional_PSD(
+ xwidth=0.1, yheight=0.2,
+ target_loggers="Union_logger_2D_kf_time_con")
+AT (-0.05,0,1.0) RELATIVE geometry_center
COMPONENT master = Union_master()
-AT(0,0,0) RELATIVE geometry_center
+AT (12,-2,4) RELATIVE geometry_center
+ROTATED (22, -47, 7) RELATIVE geometry_center
+
COMPONENT transmission = PSD_monitor(
xwidth=0.1, yheight=0.08, nx=200, ny=200,
diff --git a/mcstas-comps/examples/Tests_union/Unit_test_logger_2D_space/Unit_test_logger_2D_space.instr b/mcstas-comps/examples/Tests_union/Unit_test_logger_2D_space/Unit_test_logger_2D_space.instr
index a5272795a3..67133c85b6 100644
--- a/mcstas-comps/examples/Tests_union/Unit_test_logger_2D_space/Unit_test_logger_2D_space.instr
+++ b/mcstas-comps/examples/Tests_union/Unit_test_logger_2D_space/Unit_test_logger_2D_space.instr
@@ -20,7 +20,8 @@
* projected onto a plane spanned by two of the coordinate axis, for
* example z and x.
*
-* %Example: Detector: Union_logger_2D_space_zx_I=5.6604e-09
+* %Example: Detector: Union_logger_2D_space_zx_I=5.66106e-09
+* %Example: Detector: Union_logger_2D_space_zy_con_I=2.59083e-12
*
* %End
*******************************************************************************/
@@ -62,16 +63,16 @@ AT (0,0,0) RELATIVE Origin
COMPONENT geometry_center = Arm()
AT (0,0,2.0) RELATIVE source
-COMPONENT box = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
+COMPONENT box_geometry = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
AT (-0.03,0,-0.05) RELATIVE geometry_center
-COMPONENT sphere = Union_sphere(radius=0.05, priority=6, material_string="material")
+COMPONENT sphere_geometry = Union_sphere(radius=0.05, priority=6, material_string="material")
AT (0.03,0,-0.04) RELATIVE geometry_center
-COMPONENT cylinder = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
+COMPONENT cylinder_geometry = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
AT (-0.03,0,0.02) RELATIVE geometry_center
-COMPONENT cone = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
+COMPONENT cone_geometry = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
AT (0.03,0,0.07) RELATIVE geometry_center
COMPONENT Union_logger_2D_space_zx = Union_logger_2D_space(
@@ -85,9 +86,22 @@ COMPONENT Union_logger_2D_space_zy = Union_logger_2D_space(
D_direction_2="y", D2_min=-0.1, D2_max=0.1, n2=200,
filename="Union_logger_2D_space_zy.dat")
AT (0,0,0) RELATIVE geometry_center
+
+COMPONENT Union_logger_2D_space_zy_con = Union_logger_2D_space(
+ D_direction_1="z", D1_min=-0.15, D1_max=0.15, n1=200,
+ D_direction_2="y", D2_min=-0.1, D2_max=0.1, n2=200,
+ filename="Union_logger_2D_space_zy_con.dat")
+AT (0,0,0) RELATIVE geometry_center
+
+// Conditional that takes right part of transmitted beam
+COMPONENT PSD_conditional = Union_conditional_PSD(
+ xwidth=0.1, yheight=0.2,
+ target_loggers="Union_logger_2D_space_zy_con")
+AT (-0.05,0,1.0) RELATIVE geometry_center
COMPONENT master = Union_master()
-AT(0,0,0) RELATIVE geometry_center
+AT (12,-2,4) RELATIVE geometry_center
+ROTATED (22, -47, 7) RELATIVE geometry_center
COMPONENT transmission = PSD_monitor(
xwidth=0.1, yheight=0.08, nx=200, ny=200,
diff --git a/mcstas-comps/examples/Tests_union/Unit_test_logger_2D_space_time/Unit_test_logger_2D_space_time.instr b/mcstas-comps/examples/Tests_union/Unit_test_logger_2D_space_time/Unit_test_logger_2D_space_time.instr
index 63e4dca22e..54284f4910 100644
--- a/mcstas-comps/examples/Tests_union/Unit_test_logger_2D_space_time/Unit_test_logger_2D_space_time.instr
+++ b/mcstas-comps/examples/Tests_union/Unit_test_logger_2D_space_time/Unit_test_logger_2D_space_time.instr
@@ -21,6 +21,9 @@
* chosen by the user. This is furthermore split into several timesteps so
* the time dependency of scattering in the Union system can be monitored.
*
+* %Example: Detector: Union_logger_2D_space_time_I=3.33764e-09
+* %Example: Detector: Union_logger_2D_space_time_con_I=1.36393e-12
+*
* %End
*******************************************************************************/
@@ -61,16 +64,16 @@ AT (0,0,0) RELATIVE Origin
COMPONENT geometry_center = Arm()
AT (0,0,2.0) RELATIVE source
-COMPONENT box = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
+COMPONENT box_geometry = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
AT (-0.03,0,-0.05) RELATIVE geometry_center
-COMPONENT sphere = Union_sphere(radius=0.05, priority=6, material_string="material")
+COMPONENT sphere_geometry = Union_sphere(radius=0.05, priority=6, material_string="material")
AT (0.03,0,-0.04) RELATIVE geometry_center
-COMPONENT cylinder = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
+COMPONENT cylinder_geometry = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
AT (-0.03,0,0.02) RELATIVE geometry_center
-COMPONENT cone = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
+COMPONENT cone_geometry = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
AT (0.03,0,0.07) RELATIVE geometry_center
COMPONENT Union_logger_2D_space_time = Union_logger_2D_space_time(
@@ -79,9 +82,23 @@ COMPONENT Union_logger_2D_space_time = Union_logger_2D_space_time(
time_bins=10, time_min=0.0014, time_max=0.0020,
filename="Union_logger_2D_space_time.dat")
AT (0,0,0) RELATIVE geometry_center
+
+COMPONENT Union_logger_2D_space_time_con = Union_logger_2D_space_time(
+ D_direction_1="z", D1_min=-0.15, D1_max=0.15, n1=200,
+ D_direction_2="x", D2_min=-0.1, D2_max=0.1, n2=200,
+ time_bins=10, time_min=0.0014, time_max=0.0020,
+ filename="Union_logger_2D_space_time_con.dat")
+AT (0,0,0) RELATIVE geometry_center
+
+// Conditional that takes right part of transmitted beam
+COMPONENT PSD_conditional = Union_conditional_PSD(
+ xwidth=0.1, yheight=0.2,
+ target_loggers="Union_logger_2D_space_time_con")
+AT (-0.05,0,1.0) RELATIVE geometry_center
COMPONENT master = Union_master()
-AT(0,0,0) RELATIVE geometry_center
+AT (12,-2,4) RELATIVE geometry_center
+ROTATED (22, -47, 7) RELATIVE geometry_center
COMPONENT transmission = PSD_monitor(
xwidth=0.1, yheight=0.08, nx=200, ny=200,
diff --git a/mcstas-comps/examples/Tests_union/Unit_test_logger_3D_space/Unit_test_logger_3D_space.instr b/mcstas-comps/examples/Tests_union/Unit_test_logger_3D_space/Unit_test_logger_3D_space.instr
index d14227739f..73f7eea487 100644
--- a/mcstas-comps/examples/Tests_union/Unit_test_logger_3D_space/Unit_test_logger_3D_space.instr
+++ b/mcstas-comps/examples/Tests_union/Unit_test_logger_3D_space/Unit_test_logger_3D_space.instr
@@ -19,6 +19,9 @@
* Tests the 3D space logger that makes a number of 2D slices, integrating over
* some thickness depending on the number of bins in the 3rd dimension.
*
+* %Example: Detector: Union_logger_3D_space_I=1.3301e-09
+* %Example: Detector: Union_logger_3D_space_con_I=1.68735e-13
+*
* %End
*******************************************************************************/
@@ -59,28 +62,43 @@ AT (0,0,0) RELATIVE Origin
COMPONENT geometry_center = Arm()
AT (0,0,2.0) RELATIVE source
-COMPONENT box = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
+COMPONENT box_geometry = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
AT (-0.03,0,-0.05) RELATIVE geometry_center
-COMPONENT sphere = Union_sphere(radius=0.05, priority=6, material_string="material")
+COMPONENT sphere_geometry = Union_sphere(radius=0.05, priority=6, material_string="material")
AT (0.03,0,-0.04) RELATIVE geometry_center
-COMPONENT cylinder = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
+COMPONENT cylinder_geometry = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
AT (-0.03,0,0.02) RELATIVE geometry_center
-COMPONENT cone = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
+COMPONENT cone_geometry = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
AT (0.03,0,0.07) RELATIVE geometry_center
// Insert loggers to be tested here
COMPONENT Union_logger_3D_space = Union_logger_3D_space(
D_direction_1="x", D1_min=-0.10, D1_max=0.10, n1=200,
D_direction_2="y", D2_min=-0.10, D2_max=0.10, n2=200,
- D_direction_3="z", D3_min=-0.09, D3_max=0.14, n2=200,
+ D_direction_3="z", D3_min=-0.09, D3_max=0.14, n2=10,
filename="Union_logger_3D_space.dat")
AT (0,0,0) RELATIVE geometry_center
+
+// Insert loggers to be tested here
+COMPONENT Union_logger_3D_space_con = Union_logger_3D_space(
+ D_direction_1="x", D1_min=-0.10, D1_max=0.10, n1=200,
+ D_direction_2="y", D2_min=-0.10, D2_max=0.10, n2=200,
+ D_direction_3="z", D3_min=-0.09, D3_max=0.14, n2=5,
+ filename="Union_logger_3D_space_con.dat")
+AT (0,0,0) RELATIVE geometry_center
+
+// Conditional that takes right part of transmitted beam
+COMPONENT PSD_conditional = Union_conditional_PSD(
+ xwidth=0.1, yheight=0.2,
+ target_loggers="Union_logger_3D_space_con")
+AT (-0.05,0,1.0) RELATIVE geometry_center
COMPONENT master = Union_master()
-AT(0,0,0) RELATIVE geometry_center
+AT (12,-2,4) RELATIVE geometry_center
+ROTATED (22, -47, 7) RELATIVE geometry_center
COMPONENT transmission = PSD_monitor(
xwidth=0.1, yheight=0.08, nx=200, ny=200,
diff --git a/mcstas-comps/examples/Tests_union/Unit_test_loggers_base/Unit_test_loggers_base.instr b/mcstas-comps/examples/Tests_union/Unit_test_loggers_base/Unit_test_loggers_base.instr
index ef355d76a1..ec4fa55eaf 100644
--- a/mcstas-comps/examples/Tests_union/Unit_test_loggers_base/Unit_test_loggers_base.instr
+++ b/mcstas-comps/examples/Tests_union/Unit_test_loggers_base/Unit_test_loggers_base.instr
@@ -61,22 +61,23 @@ AT (0,0,0) RELATIVE Origin
COMPONENT geometry_center = Arm()
AT (0,0,2.0) RELATIVE source
-COMPONENT box = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
+COMPONENT box_geometry = Union_box(xwidth=0.10, yheight=0.15, zdepth=0.03, priority=5, material_string="material")
AT (-0.03,0,-0.05) RELATIVE geometry_center
-COMPONENT sphere = Union_sphere(radius=0.05, priority=6, material_string="material")
+COMPONENT sphere_geometry = Union_sphere(radius=0.05, priority=6, material_string="material")
AT (0.03,0,-0.04) RELATIVE geometry_center
-COMPONENT cylinder = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
+COMPONENT cylinder_geometry = Union_cylinder(radius=0.045, yheight=0.1, priority=7, material_string="material")
AT (-0.03,0,0.02) RELATIVE geometry_center
-COMPONENT cone = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
+COMPONENT cone_geometry = Union_cone(radius_top=0.02, radius_bottom=0.055, yheight=0.09, priority=8, material_string="material")
AT (0.03,0,0.07) RELATIVE geometry_center
// Insert loggers to be tested here
COMPONENT master = Union_master()
-AT(0,0,0) RELATIVE geometry_center
+AT (12,-2,4) RELATIVE geometry_center
+ROTATED (22, -47, 7) RELATIVE geometry_center
COMPONENT transmission = PSD_monitor(
xwidth=0.1, yheight=0.08, nx=200, ny=200,
diff --git a/mcstas-comps/share/union-lib.c b/mcstas-comps/share/union-lib.c
index 755352aefd..2cf6cd45e1 100755
--- a/mcstas-comps/share/union-lib.c
+++ b/mcstas-comps/share/union-lib.c
@@ -355,11 +355,6 @@ struct abs_logger_struct {
// Contains hard copy of logger_data_union since the size is the same as a pointer.
union abs_logger_data_union data_union;
- // Position and rotation of the abs_logger
- Coords position;
- Rotation rotation;
- Rotation t_rotation;
-
int abs_logger_extend_index; // Contain index conditional_extend_array defined in master that can be acsessed from extend section.
struct conditional_list_struct conditional_list;
@@ -5936,7 +5931,7 @@ int cone_overlaps_cylinder(struct geometry_struct *geometry_cone,struct geometry
if (dist_spheres > sphere_1_radius + sphere_2_radius){
- printf("\nSpherical method determined that cones are too far away for intersection to be relevant\n");
+ //printf("\nSpherical method determined that cones are too far away for intersection to be relevant\n");
return 0;
}
diff --git a/mcstas-comps/union/NCrystal_process.comp b/mcstas-comps/union/NCrystal_process.comp
index 7e4144c827..6c494a788d 100644
--- a/mcstas-comps/union/NCrystal_process.comp
+++ b/mcstas-comps/union/NCrystal_process.comp
@@ -73,7 +73,6 @@
* %P
* INPUT PARAMETERS:
* cfg: [str] NCrystal material configuration string (details on this page).
-* packing_factor: [1] Material packing factor
* interact_fraction: [1] How large a part of the scattering events should use this process 0-1 (sum of all processes in material = 1)
* init: [string] Name of Union_init component (typically "init", default)
*
@@ -115,7 +114,7 @@
DEFINE COMPONENT NCrystal_process // Remember to change the name of process here
-SETTING PARAMETERS(string cfg = "", packing_factor=1, interact_fraction=-1, string init="init")
+SETTING PARAMETERS(string cfg = "", interact_fraction=-1, string init="init")
DEPENDENCY "@NCRYSTALFLAGS@"
SHARE
@@ -124,7 +123,11 @@ SHARE
#error "The Union_init component must be included before this NCrystal_process component"
#endif
+ #if defined(WIN32) || defined(_WIN32)
+ #include "NCrystal\\ncrystal.h"
+ #else
#include "NCrystal/ncrystal.h"
+ #endif
#include "stdio.h"
#include "stdlib.h"
#ifndef NCMCERR2
@@ -207,24 +210,22 @@ SHARE
dir[2] = k_initial[2] / k_mag;
double vsq2ekin = data_transfer.pointer_to_a_NCrystal_physics_storage_struct->ncrystal_convfact_vsq2ekin;
- double ekin, delta_ekin, v2, absv;
+ double ekin, ekin_final, v2, absv;
ekin = vsq2ekin * K2V * k_mag * K2V * k_mag;
- delta_ekin = 0.0;
+ ekin_final = 0.0;
// Call NCrystal library, dirout and delta_ekin is updated
- ncrystal_genscatter (data_transfer.pointer_to_a_NCrystal_physics_storage_struct->stored_params.scat, ekin, (const double (*)[3]) & dir, &dirout, &delta_ekin);
-
- if (delta_ekin) {
- ekin += delta_ekin;
- if (ekin <= 0) {
- // not expected to happen much, but an interaction could in principle bring the neutron to rest.
- return 0; // Eqivalent to ABSORB
- }
- v2 = data_transfer.pointer_to_a_NCrystal_physics_storage_struct->ncrystal_convfact_ekin2vsq * ekin;
- absv = sqrt (v2);
- k_mag = absv * V2K;
+ ncrystal_samplescatter (data_transfer.pointer_to_a_NCrystal_physics_storage_struct->stored_params.scat, ekin, (const double (*)[3]) & dir, &ekin_final, &dirout);
+
+ if (ekin_final <= 0) {
+ // not expected to happen much, but an interaction could in principle bring the neutron to rest.
+ return 0; // Eqivalent to ABSORB
}
+ v2 = data_transfer.pointer_to_a_NCrystal_physics_storage_struct->ncrystal_convfact_ekin2vsq * ekin_final;
+ absv = sqrt (v2);
+ k_mag = absv * V2K;
+
k_final[0] = dirout[0] * k_mag;
k_final[1] = dirout[1] * k_mag;
k_final[2] = dirout[2] * k_mag;
@@ -323,10 +324,6 @@ INITIALIZE
ncrystal_setbuiltinrandgen_withseed (mcseed);
#endif
- /* access powder packingfactor (nb: always 1.0 for non-powders): */
- // Union change: multiplying by Union packing_factor
- double packingfactor = ncrystal_decodecfg_packfact (cfg) * packing_factor;
-
/* access crystal structure to get number density (natoms/volume): */
ncrystal_info_t info = ncrystal_create_info (cfg);
@@ -342,13 +339,12 @@ INITIALIZE
// numberdensity is the atomic number density in units of Aa^-3=1e30m^3, and
// given that we have cross-sections in barn (1e-28m^2) and want to generate
// distances in meters with -log(R)/(numberdensity*xsect), we get the unit
- // conversion factor of 0.01. We also apply the powder packing factor here (it
- // is guaranteed to be non-zero):
+ // conversion factor of 0.01.
// Union change: In NCrystal_sample density factor is negative for easier sampling,
// but as the sampling is performed in the master we use a positive sign for the
// density factor as this is more intuitive.
- params.density_factor = 0.01 / (numberdensity * packingfactor);
+ params.density_factor = 0.01 / numberdensity;
params.inv_density_factor = 1.0 / params.density_factor;
#else
@@ -367,7 +363,7 @@ INITIALIZE
// Union change: In NCrystal_sample density factor is negative for easier sampling,
// but as the sampling is performed in the master we use a positive sign for the
// density factor as this is more intuitive.
- params.density_factor = 0.01 * cell_volume / (cell_atnum * packingfactor);
+ params.density_factor = 0.01 * cell_volume / cell_atnum;
params.inv_density_factor = 1.0 / params.density_factor;
#endif
diff --git a/mcstas-comps/union/Powder_process.comp b/mcstas-comps/union/Powder_process.comp
index 0512d24d31..0242ea690a 100755
--- a/mcstas-comps/union/Powder_process.comp
+++ b/mcstas-comps/union/Powder_process.comp
@@ -262,6 +262,8 @@ SHARE
info->compname););
/* allocate line_data array */
list = (struct line_data_union*)malloc (size * sizeof (struct line_data_union));
+ if (!list)
+ exit (fprintf (stderr, "Powder_process: ERROR allocating memory (read_line_data_union)\n"));
for (i = 0; i < size; i++) {
/* printf("Reading in line %i\n",i);*/
diff --git a/mcstas-comps/union/Union_abs_logger_1D_space.comp b/mcstas-comps/union/Union_abs_logger_1D_space.comp
index 2a92299d03..cd1cb0ff41 100644
--- a/mcstas-comps/union/Union_abs_logger_1D_space.comp
+++ b/mcstas-comps/union/Union_abs_logger_1D_space.comp
@@ -113,7 +113,6 @@ SHARE
Coords position;
Rotation rotation;
- Rotation t_rotation;
};
// record_to_temp
@@ -143,11 +142,15 @@ SHARE
if (add_point == 1) {
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+
int i;
double value, dummy1, dummy2;
// value = position.y; // define makes this not work
- coords_get (*position, &dummy1, &value, &dummy2);
+ coords_get (transformed_ray_position, &dummy1, &value, &dummy2);
// Find bin in histogram
if (value > storage->Detector_1D.min && value < storage->Detector_1D.max) {
@@ -168,6 +171,8 @@ SHARE
struct temp_1D_abs_data_struct temporary_storage;
temporary_storage.num_elements = storage->temp_1D_abs_data.num_elements;
temporary_storage.elements = malloc (temporary_storage.num_elements * sizeof (struct temp_1D_abs_data_element_struct));
+ if (!temporary_storage.elements)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space: %s: ERROR allocating memory (record_to_temp_1D_abs)\n", abs_logger->name));
for (index = 0; index < storage->temp_1D_abs_data.num_elements; index++) {
temporary_storage.elements[index].index = storage->temp_1D_abs_data.elements[index].index;
@@ -180,6 +185,8 @@ SHARE
// allocate larger array (10 larger)
storage->temp_1D_abs_data.allocated_elements = 10 + storage->temp_1D_abs_data.num_elements;
storage->temp_1D_abs_data.elements = malloc (storage->temp_1D_abs_data.allocated_elements * sizeof (struct temp_1D_abs_data_element_struct));
+ if (!storage->temp_1D_abs_data.elements)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space: %s: ERROR allocating memory (record_to_temp_1D_abs)\n", abs_logger->name));
// copy back from temp
for (index = 0; index < storage->temp_1D_abs_data.num_elements; index++) {
@@ -234,13 +241,16 @@ SHARE
}
if (add_point == 1) {
- // printf("storage was set \n");
+
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
int i;
double value, dummy1, dummy2;
// value = position.y; // define makes this not work
- coords_get (*position, &dummy1, &value, &dummy2);
+ coords_get (transformed_ray_position, &dummy1, &value, &dummy2);
// Find bin in histogram
if (value > storage->Detector_1D.min && value < storage->Detector_1D.max) {
@@ -393,8 +403,16 @@ INITIALIZE
// Remember to take special care when deallocating this array
this_abs_storage.Detector_1D.Array_N = malloc (n * sizeof (double));
+ if (!this_abs_storage.Detector_1D.Array_N)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
+
this_abs_storage.Detector_1D.Array_p = malloc (n * sizeof (double));
+ if (!this_abs_storage.Detector_1D.Array_p)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
+
this_abs_storage.Detector_1D.Array_p2 = malloc (n * sizeof (double));
+ if (!this_abs_storage.Detector_1D.Array_p2)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
int l1, l2;
for (l1 = 0; l1 < n; l1++) { // n is technically a double, but this works fine
@@ -420,6 +438,8 @@ INITIALIZE
// Added 17/11/2016, allocating some elements in initialize makes code during trace simpler
this_abs_storage.temp_1D_abs_data.allocated_elements = 10;
this_abs_storage.temp_1D_abs_data.elements = malloc (this_abs_storage.temp_1D_abs_data.allocated_elements * sizeof (struct temp_1D_abs_data_element_struct));
+ if (!this_abs_storage.temp_1D_abs_data.elements)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
if (_getcomp_index (init) < 0) {
fprintf (stderr, "Union_abs_logger_1D_space:%s: Error identifying Union_init component, %s is not a known component name.\n", NAME_CURRENT_COMP, init);
@@ -429,14 +449,11 @@ INITIALIZE
struct global_positions_to_transform_list_struct* global_positions_to_transform_list = COMP_GETPAR3 (Union_init, init, global_positions_to_transform_list);
struct global_rotations_to_transform_list_struct* global_rotations_to_transform_list = COMP_GETPAR3 (Union_init, init, global_rotations_to_transform_list);
// Test position and rotation stored in a data storage, and pointers assigned to transform lists
- this_abs_logger.position = POS_A_CURRENT_COMP;
- add_position_pointer_to_list (global_positions_to_transform_list, &this_abs_logger.position);
-
- rot_copy (this_abs_logger.rotation, ROT_A_CURRENT_COMP);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_logger.rotation);
+ this_abs_storage.position = POS_A_CURRENT_COMP;
+ add_position_pointer_to_list (global_positions_to_transform_list, &this_abs_storage.position);
- rot_transpose (ROT_A_CURRENT_COMP, this_abs_logger.t_rotation);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_logger.t_rotation);
+ rot_copy (this_abs_storage.rotation, ROT_A_CURRENT_COMP);
+ add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_storage.rotation);
// printf("past direction choices sanitation \n");
diff --git a/mcstas-comps/union/Union_abs_logger_1D_space_event.comp b/mcstas-comps/union/Union_abs_logger_1D_space_event.comp
index a099ad614c..5fdd6587cb 100644
--- a/mcstas-comps/union/Union_abs_logger_1D_space_event.comp
+++ b/mcstas-comps/union/Union_abs_logger_1D_space_event.comp
@@ -139,7 +139,6 @@ SHARE
Coords position;
Rotation rotation;
- Rotation t_rotation;
};
// record_to_temp
@@ -169,9 +168,13 @@ SHARE
if (add_point == 1) {
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+
int i;
double given_x_pos, given_y_pos, given_z_pos;
- coords_get (*position, &given_x_pos, &given_y_pos, &given_z_pos);
+ coords_get (transformed_ray_position, &given_x_pos, &given_y_pos, &given_z_pos);
given_x_pos = 0.0; // 1D monitor, always in center x bin
double given_x_vel, given_y_vel, given_z_vel;
@@ -199,6 +202,8 @@ SHARE
struct temp_abs_1D_event_data_struct temporary_storage;
temporary_storage.num_elements = storage->temp_abs_1D_event_data.num_elements;
temporary_storage.elements = malloc (temporary_storage.num_elements * sizeof (struct temp_abs_1D_event_data_element_struct));
+ if (!temporary_storage.elements)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space_event: %s: ERROR allocating memory (record_to_temp_abs_1D_event)\n", abs_logger->name));
int index;
for (index = 0; index < storage->temp_abs_1D_event_data.num_elements; index++) {
@@ -222,6 +227,8 @@ SHARE
storage->temp_abs_1D_event_data.allocated_elements = 10 + storage->temp_abs_1D_event_data.num_elements;
storage->temp_abs_1D_event_data.elements
= malloc (storage->temp_abs_1D_event_data.allocated_elements * sizeof (struct temp_abs_1D_event_data_element_struct));
+ if (!storage->temp_abs_1D_event_data.elements)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space_event: %s: ERROR allocating memory (record_to_temp_abs_1D_event)\n", abs_logger->name));
// copy back from temp
for (index = 0; index < storage->temp_abs_1D_event_data.num_elements; index++) {
@@ -293,10 +300,13 @@ SHARE
}
if (add_point == 1) {
- // printf("storage was set \n");
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+ int i;
double given_x_pos, given_y_pos, given_z_pos;
- coords_get (*position, &given_x_pos, &given_y_pos, &given_z_pos);
+ coords_get (transformed_ray_position, &given_x_pos, &given_y_pos, &given_z_pos);
given_x_pos = 0.0; // 1D monitor, always in center x bin
double given_x_vel, given_y_vel, given_z_vel;
@@ -518,18 +528,17 @@ INITIALIZE
this_abs_storage.temp_abs_1D_event_data.allocated_elements = 10;
this_abs_storage.temp_abs_1D_event_data.elements
= malloc (this_abs_storage.temp_abs_1D_event_data.allocated_elements * sizeof (struct temp_abs_1D_event_data_element_struct));
+ if (!this_abs_storage.temp_abs_1D_event_data.elements)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space_event: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
struct global_positions_to_transform_list_struct* global_positions_to_transform_list = COMP_GETPAR3 (Union_init, init, global_positions_to_transform_list);
struct global_rotations_to_transform_list_struct* global_rotations_to_transform_list = COMP_GETPAR3 (Union_init, init, global_rotations_to_transform_list);
// Test position and rotation stored in a data storage, and pointers assigned to transform lists
- this_abs_logger.position = POS_A_CURRENT_COMP;
- add_position_pointer_to_list (global_positions_to_transform_list, &this_abs_logger.position);
-
- rot_copy (this_abs_logger.rotation, ROT_A_CURRENT_COMP);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_logger.rotation);
+ this_abs_storage.position = POS_A_CURRENT_COMP;
+ add_position_pointer_to_list (global_positions_to_transform_list, &this_abs_storage.position);
- rot_transpose (ROT_A_CURRENT_COMP, this_abs_logger.t_rotation);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_logger.t_rotation);
+ rot_copy (this_abs_storage.rotation, ROT_A_CURRENT_COMP);
+ add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_storage.rotation);
// Adding fake event to combat MPI writing bug
if (fake_event) {
diff --git a/mcstas-comps/union/Union_abs_logger_1D_space_tof.comp b/mcstas-comps/union/Union_abs_logger_1D_space_tof.comp
index a2dcb4afd5..b321f4c2d7 100644
--- a/mcstas-comps/union/Union_abs_logger_1D_space_tof.comp
+++ b/mcstas-comps/union/Union_abs_logger_1D_space_tof.comp
@@ -113,6 +113,9 @@ SHARE
struct temp_1D_time_abs_data_struct temp_1D_time_abs_data;
int order;
int order_in_this_volume;
+
+ Coords position;
+ Rotation rotation;
};
// record_to_temp
@@ -141,13 +144,16 @@ SHARE
}
if (add_point == 1) {
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
double p1, p2;
double dummy1, dummy2;
// value = position.y; // define makes this not work
- coords_get (*position, &dummy1, &p1, &dummy2);
+ coords_get (transformed_ray_position, &dummy1, &p1, &dummy2);
p2 = time;
int i, j;
@@ -173,6 +179,8 @@ SHARE
struct temp_1D_time_abs_data_struct temporary_storage;
temporary_storage.num_elements = storage->temp_1D_time_abs_data.num_elements;
temporary_storage.elements = malloc (temporary_storage.num_elements * sizeof (struct temp_1D_time_abs_data_element_struct));
+ if (!temporary_storage.elements)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space_tof: %s: ERROR allocating memory (record_to_temp_1D_time_abs)\n", abs_logger->name));
for (index = 0; index < storage->temp_1D_time_abs_data.num_elements; index++) {
temporary_storage.elements[index].index_1 = storage->temp_1D_time_abs_data.elements[index].index_1;
@@ -187,6 +195,8 @@ SHARE
storage->temp_1D_time_abs_data.allocated_elements = 10 + storage->temp_1D_time_abs_data.num_elements;
storage->temp_1D_time_abs_data.elements
= malloc (storage->temp_1D_time_abs_data.allocated_elements * sizeof (struct temp_1D_time_abs_data_element_struct));
+ if (!storage->temp_1D_time_abs_data.elements)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space_tof: %s: ERROR allocating memory (record_to_temp_1D_time_abs)\n", abs_logger->name));
// copy back from temp
for (index = 0; index < storage->temp_1D_time_abs_data.num_elements; index++) {
@@ -243,13 +253,16 @@ SHARE
}
if (add_point == 1) {
- // printf("storage was set \n");
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+
double p1, p2;
double dummy1, dummy2;
// value = position.y; // define makes this not work
- coords_get (*position, &dummy1, &p1, &dummy2);
+ coords_get (transformed_ray_position, &dummy1, &p1, &dummy2);
p2 = time;
int i, j;
@@ -369,10 +382,15 @@ SHARE
// allocate space for actual data
// double *data = malloc(sizeof(double) * count_x * count_y);
double* data = malloc (sizeof (double) * (count_x + 1) * (count_y + 1));
+ if (!data)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space_tof: ERROR allocating memory (allocate2Ddouble_1D_time_abs)\n"));
// create array or pointers to first elem in each 2D row
// double **ptr_array = malloc(sizeof(double*) * count_x);
double** ptr_array = malloc (sizeof (double*) * (count_x + 1));
+ if (!ptr_array)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space_tof: ERROR allocating memory (allocate2Ddouble_1D_time_abs)\n"));
+
for (i = 0; i < count_x; i++) {
ptr_array[i] = data + (i * count_y);
}
@@ -481,6 +499,8 @@ INITIALIZE
this_abs_storage.temp_1D_time_abs_data.allocated_elements = 10;
this_abs_storage.temp_1D_time_abs_data.elements
= malloc (this_abs_storage.temp_1D_time_abs_data.allocated_elements * sizeof (struct temp_1D_time_abs_data_element_struct));
+ if (!this_abs_storage.temp_1D_time_abs_data.elements)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space_tof: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
if (_getcomp_index (init) < 0) {
fprintf (stderr, "Union_abs_logger_1D_space_tof:%s: Error identifying Union_init component, %s is not a known component name.\n", NAME_CURRENT_COMP, init);
@@ -490,14 +510,11 @@ INITIALIZE
struct global_positions_to_transform_list_struct* global_positions_to_transform_list = COMP_GETPAR3 (Union_init, init, global_positions_to_transform_list);
struct global_rotations_to_transform_list_struct* global_rotations_to_transform_list = COMP_GETPAR3 (Union_init, init, global_rotations_to_transform_list);
// Test position and rotation stored in a data storage, and pointers assigned to transform lists
- this_abs_logger.position = POS_A_CURRENT_COMP;
- add_position_pointer_to_list (global_positions_to_transform_list, &this_abs_logger.position);
-
- rot_copy (this_abs_logger.rotation, ROT_A_CURRENT_COMP);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_logger.rotation);
+ this_abs_storage.position = POS_A_CURRENT_COMP;
+ add_position_pointer_to_list (global_positions_to_transform_list, &this_abs_storage.position);
- rot_transpose (ROT_A_CURRENT_COMP, this_abs_logger.t_rotation);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_logger.t_rotation);
+ rot_copy (this_abs_storage.rotation, ROT_A_CURRENT_COMP);
+ add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_storage.rotation);
// printf("past direction choices sanitation \n");
diff --git a/mcstas-comps/union/Union_abs_logger_1D_space_tof_to_lambda.comp b/mcstas-comps/union/Union_abs_logger_1D_space_tof_to_lambda.comp
index 25082cff5a..4469011a5a 100644
--- a/mcstas-comps/union/Union_abs_logger_1D_space_tof_to_lambda.comp
+++ b/mcstas-comps/union/Union_abs_logger_1D_space_tof_to_lambda.comp
@@ -153,10 +153,13 @@ SHARE
Coords sample_pos;
int transformed;
// Coords *logger_position;
- Coords logger_position;
- Rotation* logger_rotation;
+ // Coords logger_position;
+ // Rotation* logger_rotation;
double source_to_sample_dist;
int relative;
+
+ Coords position;
+ Rotation rotation;
};
// record_to_temp
@@ -184,10 +187,15 @@ SHARE
add_point = 0;
}
+ // From master to local coordinate system
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+
// Bin y_position
int y_bin;
double dummy1, y_pos, dummy2;
- coords_get (*position, &dummy1, &y_pos, &dummy2);
+ coords_get (transformed_ray_position, &dummy1, &y_pos, &dummy2);
if (y_pos > storage->y_min && y_pos < storage->y_max) {
add_point = 1;
@@ -207,9 +215,8 @@ SHARE
// Transform sample_pos to logger coordinate system
if (storage->transformed == 0) {
- // storage->sample_pos = coords_sub(storage->sample_pos, *(storage->logger_position));
- storage->sample_pos = coords_sub (storage->sample_pos, storage->logger_position);
- storage->sample_pos = rot_apply (*(storage->logger_rotation), storage->sample_pos);
+ storage->sample_pos = coords_sub (storage->sample_pos, storage->position);
+ storage->sample_pos = rot_apply (storage->rotation, storage->sample_pos);
storage->transformed = 1;
}
@@ -247,6 +254,9 @@ SHARE
struct temp_1D_time_to_lambda_abs_data_struct temporary_storage;
temporary_storage.num_elements = storage->temp_1D_time_to_lambda_abs_data.num_elements;
temporary_storage.elements = malloc (temporary_storage.num_elements * sizeof (struct temp_1D_time_to_lambda_abs_data_element_struct));
+ if (!temporary_storage.elements)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space_tof_to_lambda: %s: ERROR allocating memory (record_to_temp_1D_time_to_lambda_abs)\n",
+ abs_logger->name));
for (index = 0; index < storage->temp_1D_time_to_lambda_abs_data.num_elements; index++) {
temporary_storage.elements[index].index_1 = storage->temp_1D_time_to_lambda_abs_data.elements[index].index_1;
@@ -261,6 +271,9 @@ SHARE
storage->temp_1D_time_to_lambda_abs_data.allocated_elements = 10 + storage->temp_1D_time_to_lambda_abs_data.num_elements;
storage->temp_1D_time_to_lambda_abs_data.elements
= malloc (storage->temp_1D_time_to_lambda_abs_data.allocated_elements * sizeof (struct temp_1D_time_to_lambda_abs_data_element_struct));
+ if (!storage->temp_1D_time_to_lambda_abs_data.elements)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space_tof_to_lambda: %s: ERROR allocating memory (record_to_temp_1D_time_to_lambda_abs)\n",
+ abs_logger->name));
// copy back from temp
for (index = 0; index < storage->temp_1D_time_to_lambda_abs_data.num_elements; index++) {
@@ -316,10 +329,14 @@ SHARE
add_point = 0;
}
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+
// Bin y_position
int y_bin;
double dummy1, y_pos, dummy2;
- coords_get (*position, &dummy1, &y_pos, &dummy2);
+ coords_get (transformed_ray_position, &dummy1, &y_pos, &dummy2);
if (y_pos > storage->y_min && y_pos < storage->y_max) {
add_point = 1;
@@ -339,9 +356,8 @@ SHARE
// Transform sample_pos to logger coordinate system
if (storage->transformed == 0) {
- // storage->sample_pos = coords_sub(storage->sample_pos, *(storage->logger_position));
- storage->sample_pos = coords_sub (storage->sample_pos, storage->logger_position);
- storage->sample_pos = rot_apply (*(storage->logger_rotation), storage->sample_pos);
+ storage->sample_pos = coords_sub (storage->sample_pos, storage->position);
+ storage->sample_pos = rot_apply (storage->rotation, storage->sample_pos);
storage->transformed = 1;
}
@@ -478,9 +494,14 @@ SHARE
// allocate space for actual data
double* data = malloc (sizeof (double) * (count_x + 1) * (count_y + 1));
+ if (!data)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space_tof_to_lambda: ERROR allocating memory (allocate2Ddouble_1D_time_to_lambda_abs)\n"));
// create array or pointers to first elem in each 2D row
double** ptr_array = malloc (sizeof (double*) * count_x);
+ if (!ptr_array)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space_tof_to_lambda: ERROR allocating memory (allocate2Ddouble_1D_time_to_lambda_abs)\n"));
+
// double **ptr_array = malloc(sizeof(double*) * (count_x+1));
for (i = 0; i < count_x; i++) {
ptr_array[i] = data + (i * count_y);
@@ -683,6 +704,8 @@ INITIALIZE
this_abs_storage.temp_1D_time_to_lambda_abs_data.allocated_elements = 10;
this_abs_storage.temp_1D_time_to_lambda_abs_data.elements
= malloc (this_abs_storage.temp_1D_time_to_lambda_abs_data.allocated_elements * sizeof (struct temp_1D_time_to_lambda_abs_data_element_struct));
+ if (!this_abs_storage.temp_1D_time_to_lambda_abs_data.elements)
+ exit (fprintf (stderr, "Union_abs_logger_1D_space_tof_to_lambda: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
if (_getcomp_index (init) < 0) {
fprintf (stderr, "Union_abs_logger_1D_space_tof_to_lambda:%s: Error identifying Union_init component, %s is not a known component name.\n", NAME_CURRENT_COMP,
@@ -693,17 +716,12 @@ INITIALIZE
struct global_positions_to_transform_list_struct* global_positions_to_transform_list = COMP_GETPAR3 (Union_init, init, global_positions_to_transform_list);
struct global_rotations_to_transform_list_struct* global_rotations_to_transform_list = COMP_GETPAR3 (Union_init, init, global_rotations_to_transform_list);
// Test position and rotation stored in a data storage, and pointers assigned to transform lists
- this_abs_logger.position = POS_A_CURRENT_COMP;
- add_position_pointer_to_list (global_positions_to_transform_list, &this_abs_logger.position);
- this_abs_storage.logger_position = POS_A_CURRENT_COMP;
- add_position_pointer_to_list (global_positions_to_transform_list, &this_abs_storage.logger_position);
- rot_copy (this_abs_logger.rotation, ROT_A_CURRENT_COMP);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_logger.rotation);
- this_abs_storage.logger_rotation = &this_abs_logger.rotation;
+ this_abs_storage.position = POS_A_CURRENT_COMP;
+ add_position_pointer_to_list (global_positions_to_transform_list, &this_abs_storage.position);
- rot_transpose (ROT_A_CURRENT_COMP, this_abs_logger.t_rotation);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_logger.t_rotation);
+ rot_copy (this_abs_storage.rotation, ROT_A_CURRENT_COMP);
+ add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_storage.rotation);
// Get the position from a component instance
this_abs_storage.sample_pos = POS_A_COMP_INDEX (INDEX_CURRENT_COMP + ref_component);
diff --git a/mcstas-comps/union/Union_abs_logger_1D_time.comp b/mcstas-comps/union/Union_abs_logger_1D_time.comp
index fe1cd22cda..4023fe0cf8 100644
--- a/mcstas-comps/union/Union_abs_logger_1D_time.comp
+++ b/mcstas-comps/union/Union_abs_logger_1D_time.comp
@@ -114,10 +114,6 @@ SHARE
int order;
int order_in_this_volume;
int order_process_in_this_volume;
-
- Coords position;
- Rotation rotation;
- Rotation t_rotation;
};
// record_to_temp
@@ -171,6 +167,8 @@ SHARE
struct temp_time_abs_data_struct temporary_storage;
temporary_storage.num_elements = storage->temp_time_abs_data.num_elements;
temporary_storage.elements = malloc (temporary_storage.num_elements * sizeof (struct temp_time_abs_data_element_struct));
+ if (!temporary_storage.elements)
+ exit (fprintf (stderr, "Union_abs_logger_1D_time: %s: ERROR allocating memory (record_to_temp_time_abs)\n", abs_logger->name));
for (index = 0; index < storage->temp_time_abs_data.num_elements; index++) {
temporary_storage.elements[index].index = storage->temp_time_abs_data.elements[index].index;
@@ -183,6 +181,8 @@ SHARE
// allocate larger array (10 larger)
storage->temp_time_abs_data.allocated_elements = 10 + storage->temp_time_abs_data.num_elements;
storage->temp_time_abs_data.elements = malloc (storage->temp_time_abs_data.allocated_elements * sizeof (struct temp_time_abs_data_element_struct));
+ if (!storage->temp_time_abs_data.elements)
+ exit (fprintf (stderr, "Union_abs_logger_1D_time: %s: ERROR allocating memory (record_to_temp_time_abs)\n", abs_logger->name));
// copy back from temp
for (index = 0; index < storage->temp_time_abs_data.num_elements; index++) {
@@ -395,8 +395,16 @@ INITIALIZE
// Remember to take special care when deallocating this array
this_abs_storage.Detector_1D.Array_N = malloc (n * sizeof (double));
+ if (!this_abs_storage.Detector_1D.Array_N)
+ exit (fprintf (stderr, "Union_abs_logger_1D_time: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
+
this_abs_storage.Detector_1D.Array_p = malloc (n * sizeof (double));
+ if (!this_abs_storage.Detector_1D.Array_p)
+ exit (fprintf (stderr, "Union_abs_logger_1D_time: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
+
this_abs_storage.Detector_1D.Array_p2 = malloc (n * sizeof (double));
+ if (!this_abs_storage.Detector_1D.Array_p2)
+ exit (fprintf (stderr, "Union_abs_logger_1D_time: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
int l1, l2;
for (l1 = 0; l1 < n; l1++) { // n is technically a double, but this works fine
@@ -423,24 +431,14 @@ INITIALIZE
this_abs_storage.temp_time_abs_data.allocated_elements = 10;
this_abs_storage.temp_time_abs_data.elements
= malloc (this_abs_storage.temp_time_abs_data.allocated_elements * sizeof (struct temp_time_abs_data_element_struct));
+ if (!this_abs_storage.temp_time_abs_data.elements)
+ exit (fprintf (stderr, "Union_abs_logger_1D_time: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
if (_getcomp_index (init) < 0) {
fprintf (stderr, "Union_abs_logger_1D_time:%s: Error identifying Union_init component, %s is not a known component name.\n", NAME_CURRENT_COMP, init);
exit (-1);
}
- struct global_positions_to_transform_list_struct* global_positions_to_transform_list = COMP_GETPAR3 (Union_init, init, global_positions_to_transform_list);
- struct global_rotations_to_transform_list_struct* global_rotations_to_transform_list = COMP_GETPAR3 (Union_init, init, global_rotations_to_transform_list);
- // Test position and rotation stored in a data storage, and pointers assigned to transform lists
- this_abs_logger.position = POS_A_CURRENT_COMP;
- add_position_pointer_to_list (global_positions_to_transform_list, &this_abs_logger.position);
-
- rot_copy (this_abs_logger.rotation, ROT_A_CURRENT_COMP);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_logger.rotation);
-
- rot_transpose (ROT_A_CURRENT_COMP, this_abs_logger.t_rotation);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_logger.t_rotation);
-
// printf("past direction choices sanitation \n");
// Book keeping
diff --git a/mcstas-comps/union/Union_abs_logger_2D_space.comp b/mcstas-comps/union/Union_abs_logger_2D_space.comp
index 74ce4c19f7..69c24cf643 100644
--- a/mcstas-comps/union/Union_abs_logger_2D_space.comp
+++ b/mcstas-comps/union/Union_abs_logger_2D_space.comp
@@ -127,7 +127,6 @@ SHARE
Coords position;
Rotation rotation;
- Rotation t_rotation;
};
// record_to_temp
@@ -156,29 +155,26 @@ SHARE
}
if (add_point == 1) {
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
double p1, p2;
// dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input. "x" "y" "z".
if (storage->dim_1_choice == 0)
- // p1 = position->x - storage->position.x;
- p1 = position->x;
+ p1 = transformed_ray_position.x;
else if (storage->dim_1_choice == 1)
- // p1 = position->y;
- p1 = position->y - storage->position.y;
+ p1 = transformed_ray_position.y;
else if (storage->dim_1_choice == 2)
- // p1 = position->z - storage->position.z;
- p1 = position->z;
+ p1 = transformed_ray_position.z;
if (storage->dim_2_choice == 0)
- // p2 = position->x - storage->position.x;
- p2 = position->x;
+ p2 = transformed_ray_position.x;
else if (storage->dim_2_choice == 1)
- // p2 = position->y - storage->position.y;
- p2 = position->y;
+ p2 = transformed_ray_position.y;
else if (storage->dim_2_choice == 2)
- // p2 = position->z - storage->position.z;
- p2 = position->z;
+ p2 = transformed_ray_position.z;
int i, j;
@@ -203,6 +199,8 @@ SHARE
struct temp_2D_abs_data_struct temporary_storage;
temporary_storage.num_elements = storage->temp_2D_abs_data.num_elements;
temporary_storage.elements = malloc (temporary_storage.num_elements * sizeof (struct temp_2D_abs_data_element_struct));
+ if (!temporary_storage.elements)
+ exit (fprintf (stderr, "Union_abs_logger_2D_space: %s: ERROR allocating memory (record_to_temp_2D_abs)\n", abs_logger->name));
for (index = 0; index < storage->temp_2D_abs_data.num_elements; index++) {
temporary_storage.elements[index].index_1 = storage->temp_2D_abs_data.elements[index].index_1;
@@ -216,6 +214,8 @@ SHARE
// allocate larger array (10 larger)
storage->temp_2D_abs_data.allocated_elements = 10 + storage->temp_2D_abs_data.num_elements;
storage->temp_2D_abs_data.elements = malloc (storage->temp_2D_abs_data.allocated_elements * sizeof (struct temp_2D_abs_data_element_struct));
+ if (!storage->temp_2D_abs_data.elements)
+ exit (fprintf (stderr, "Union_abs_logger_2D_space: %s: ERROR allocating memory (record_to_temp_2D_abs)\n", abs_logger->name));
// copy back from temp
for (index = 0; index < storage->temp_2D_abs_data.num_elements; index++) {
@@ -272,29 +272,26 @@ SHARE
}
if (add_point == 1) {
- // printf("storage was set \n");
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+
double p1, p2;
// dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input. "x" "y" "z".
if (storage->dim_1_choice == 0)
- // p1 = position->x - storage->position.x;
- p1 = position->x;
+ p1 = transformed_ray_position.x;
else if (storage->dim_1_choice == 1)
- // p1 = position->y;
- p1 = position->y - storage->position.y;
+ p1 = transformed_ray_position.y;
else if (storage->dim_1_choice == 2)
- // p1 = position->z - storage->position.z;
- p1 = position->z;
+ p1 = transformed_ray_position.z;
if (storage->dim_2_choice == 0)
- // p2 = position->x - storage->position.x;
- p2 = position->x;
+ p2 = transformed_ray_position.x;
else if (storage->dim_2_choice == 1)
- // p2 = position->y - storage->position.y;
- p2 = position->y;
+ p2 = transformed_ray_position.y;
else if (storage->dim_2_choice == 2)
- // p2 = position->z - storage->position.z;
- p2 = position->z;
+ p2 = transformed_ray_position.z;
int i, j;
@@ -411,9 +408,14 @@ SHARE
// allocate space for actual data
double* data = malloc (sizeof (double) * count_x * count_y);
+ if (!data)
+ exit (fprintf (stderr, "Union_abs_logger_2D_space: ERROR allocating memory (allocate2Ddouble_2D_abs)\n"));
// create array or pointers to first elem in each 2D row
double** ptr_array = malloc (sizeof (double*) * count_x);
+ if (!ptr_array)
+ exit (fprintf (stderr, "Union_abs_logger_2D_space: ERROR allocating memory (allocate2Ddouble_2D_abs)\n"));
+
for (i = 0; i < count_x; i++) {
ptr_array[i] = data + (i * count_y);
}
@@ -558,6 +560,8 @@ INITIALIZE
// Added 17/11/2016, allocating some elements in initialize makes code during trace simpler
this_abs_storage.temp_2D_abs_data.allocated_elements = 10;
this_abs_storage.temp_2D_abs_data.elements = malloc (this_abs_storage.temp_2D_abs_data.allocated_elements * sizeof (struct temp_2D_abs_data_element_struct));
+ if (!this_abs_storage.temp_2D_abs_data.elements)
+ exit (fprintf (stderr, "Union_abs_logger_2D_space: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
if (_getcomp_index (init) < 0) {
fprintf (stderr, "Union_abs_logger_2D_space:%s: Error identifying Union_init component, %s is not a known component name.\n", NAME_CURRENT_COMP, init);
@@ -567,14 +571,11 @@ INITIALIZE
struct global_positions_to_transform_list_struct* global_positions_to_transform_list = COMP_GETPAR3 (Union_init, init, global_positions_to_transform_list);
struct global_rotations_to_transform_list_struct* global_rotations_to_transform_list = COMP_GETPAR3 (Union_init, init, global_rotations_to_transform_list);
// Test position and rotation stored in a data storage, and pointers assigned to transform lists
- this_abs_logger.position = POS_A_CURRENT_COMP;
- add_position_pointer_to_list (global_positions_to_transform_list, &this_abs_logger.position);
-
- rot_copy (this_abs_logger.rotation, ROT_A_CURRENT_COMP);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_logger.rotation);
+ this_abs_storage.position = POS_A_CURRENT_COMP;
+ add_position_pointer_to_list (global_positions_to_transform_list, &this_abs_storage.position);
- rot_transpose (ROT_A_CURRENT_COMP, this_abs_logger.t_rotation);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_logger.t_rotation);
+ rot_copy (this_abs_storage.rotation, ROT_A_CURRENT_COMP);
+ add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_storage.rotation);
// printf("past direction choices sanitation \n");
diff --git a/mcstas-comps/union/Union_abs_logger_event.comp b/mcstas-comps/union/Union_abs_logger_event.comp
index e75ac3e63b..3d325c0f2a 100644
--- a/mcstas-comps/union/Union_abs_logger_event.comp
+++ b/mcstas-comps/union/Union_abs_logger_event.comp
@@ -144,7 +144,6 @@ SHARE
Coords position;
Rotation rotation;
- Rotation t_rotation;
};
double
@@ -186,22 +185,26 @@ SHARE
add_point = 0;
}
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+
if (storage->stored_xwidth != 0) {
- if (position->x < 0.5 * storage->stored_xwidth && position->x > -0.5 * storage->stored_xwidth)
+ if (transformed_ray_position.x < 0.5 * storage->stored_xwidth && transformed_ray_position.x > -0.5 * storage->stored_xwidth)
add_point = 1;
else
add_point = 0;
}
if (storage->stored_yheight != 0) {
- if (position->y < 0.5 * storage->stored_yheight && position->y > -0.5 * storage->stored_yheight)
+ if (transformed_ray_position.y < 0.5 * storage->stored_yheight && transformed_ray_position.y > -0.5 * storage->stored_yheight)
add_point = 1;
else
add_point = 0;
}
if (storage->stored_zdepth != 0) {
- if (position->z < 0.5 * storage->stored_zdepth && position->z > -0.5 * storage->stored_xwidth)
+ if (transformed_ray_position.z < 0.5 * storage->stored_zdepth && transformed_ray_position.z > -0.5 * storage->stored_xwidth)
add_point = 1;
else
add_point = 0;
@@ -212,7 +215,7 @@ SHARE
int i;
double given_x_pos, given_y_pos, given_z_pos;
double used_x_pos, used_y_pos, used_z_pos;
- coords_get (*position, &given_x_pos, &given_y_pos, &given_z_pos);
+ coords_get (transformed_ray_position, &given_x_pos, &given_y_pos, &given_z_pos);
if (storage->stored_xbins != 0) {
used_x_pos = round_to_nearest_bin (given_x_pos, storage->stored_xwidth, storage->stored_xbins);
@@ -257,6 +260,8 @@ SHARE
struct temp_abs_event_data_struct temporary_storage;
temporary_storage.num_elements = storage->temp_abs_event_data.num_elements;
temporary_storage.elements = malloc (temporary_storage.num_elements * sizeof (struct temp_abs_event_data_element_struct));
+ if (!temporary_storage.elements)
+ exit (fprintf (stderr, "Union_abs_logger_event: %s: ERROR allocating memory (record_to_temp_abs_event)\n", abs_logger->name));
int index;
for (index = 0; index < storage->temp_abs_event_data.num_elements; index++) {
@@ -279,6 +284,8 @@ SHARE
// allocate larger array (10 larger)
storage->temp_abs_event_data.allocated_elements = 10 + storage->temp_abs_event_data.num_elements;
storage->temp_abs_event_data.elements = malloc (storage->temp_abs_event_data.allocated_elements * sizeof (struct temp_abs_event_data_element_struct));
+ if (!storage->temp_abs_event_data.elements)
+ exit (fprintf (stderr, "Union_abs_logger_event: %s: ERROR allocating memory (record_to_temp_abs_event)\n", abs_logger->name));
// copy back from temp
for (index = 0; index < storage->temp_abs_event_data.num_elements; index++) {
@@ -349,33 +356,37 @@ SHARE
add_point = 0;
}
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+
if (storage->stored_xwidth != 0) {
- if (position->x < 0.5 * storage->stored_xwidth && position->x > -0.5 * storage->stored_xwidth)
+ if (transformed_ray_position.x < 0.5 * storage->stored_xwidth && transformed_ray_position.x > -0.5 * storage->stored_xwidth)
add_point = 1;
else
add_point = 0;
}
if (storage->stored_yheight != 0) {
- if (position->y < 0.5 * storage->stored_yheight && position->y > -0.5 * storage->stored_yheight)
+ if (transformed_ray_position.y < 0.5 * storage->stored_yheight && transformed_ray_position.y > -0.5 * storage->stored_yheight)
add_point = 1;
else
add_point = 0;
}
if (storage->stored_zdepth != 0) {
- if (position->z < 0.5 * storage->stored_zdepth && position->z > -0.5 * storage->stored_xwidth)
+ if (transformed_ray_position.z < 0.5 * storage->stored_zdepth && transformed_ray_position.z > -0.5 * storage->stored_xwidth)
add_point = 1;
else
add_point = 0;
}
if (add_point == 1) {
- // printf("storage was set \n");
+ int i;
double given_x_pos, given_y_pos, given_z_pos;
double used_x_pos, used_y_pos, used_z_pos;
- coords_get (*position, &given_x_pos, &given_y_pos, &given_z_pos);
+ coords_get (transformed_ray_position, &given_x_pos, &given_y_pos, &given_z_pos);
if (storage->stored_xbins != 0) {
used_x_pos = round_to_nearest_bin (given_x_pos, storage->stored_xwidth, storage->stored_xbins);
@@ -613,6 +624,8 @@ INITIALIZE
this_abs_storage.temp_abs_event_data.allocated_elements = 10;
this_abs_storage.temp_abs_event_data.elements
= malloc (this_abs_storage.temp_abs_event_data.allocated_elements * sizeof (struct temp_abs_event_data_element_struct));
+ if (!this_abs_storage.temp_abs_event_data.elements)
+ exit (fprintf (stderr, "Union_abs_logger_event: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
if (_getcomp_index (init) < 0) {
fprintf (stderr, "Union_abs_logger_event:%s: Error identifying Union_init component, %s is not a known component name.\n", NAME_CURRENT_COMP, init);
@@ -622,14 +635,11 @@ INITIALIZE
struct global_positions_to_transform_list_struct* global_positions_to_transform_list = COMP_GETPAR3 (Union_init, init, global_positions_to_transform_list);
struct global_rotations_to_transform_list_struct* global_rotations_to_transform_list = COMP_GETPAR3 (Union_init, init, global_rotations_to_transform_list);
// Test position and rotation stored in a data storage, and pointers assigned to transform lists
- this_abs_logger.position = POS_A_CURRENT_COMP;
- add_position_pointer_to_list (global_positions_to_transform_list, &this_abs_logger.position);
-
- rot_copy (this_abs_logger.rotation, ROT_A_CURRENT_COMP);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_logger.rotation);
+ this_abs_storage.position = POS_A_CURRENT_COMP;
+ add_position_pointer_to_list (global_positions_to_transform_list, &this_abs_storage.position);
- rot_transpose (ROT_A_CURRENT_COMP, this_abs_logger.t_rotation);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_logger.t_rotation);
+ rot_copy (this_abs_storage.rotation, ROT_A_CURRENT_COMP);
+ add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_storage.rotation);
// Book keeping
this_abs_logger.abs_logger_extend_index = logger_conditional_extend_index;
diff --git a/mcstas-comps/union/Union_abs_logger_nD.comp b/mcstas-comps/union/Union_abs_logger_nD.comp
index fd3fbf5e86..d765f1e0fa 100644
--- a/mcstas-comps/union/Union_abs_logger_nD.comp
+++ b/mcstas-comps/union/Union_abs_logger_nD.comp
@@ -176,7 +176,6 @@ SHARE
Coords position;
Rotation rotation;
- Rotation t_rotation;
};
// record_to_temp
@@ -206,14 +205,19 @@ SHARE
if (add_point == 1) {
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+
int i;
double given_x_pos, given_y_pos, given_z_pos;
- coords_get (*position, &given_x_pos, &given_y_pos, &given_z_pos);
+ coords_get (transformed_ray_position, &given_x_pos, &given_y_pos, &given_z_pos);
+
+ Coords k_coords = make_position (k);
+ Coords transformed_k_coords = rot_apply (storage->rotation, k_coords);
double given_x_vel, given_y_vel, given_z_vel;
- given_x_vel = k[0] * K2V;
- given_y_vel = k[1] * K2V;
- given_z_vel = k[2] * K2V;
+ coords_get (coords_scalar_mult (transformed_k_coords, K2V), &given_x_vel, &given_y_vel, &given_z_vel);
if (storage->temp_abs_nD_data.num_elements < storage->temp_abs_nD_data.allocated_elements) {
@@ -235,6 +239,8 @@ SHARE
struct temp_abs_nD_data_struct temporary_storage;
temporary_storage.num_elements = storage->temp_abs_nD_data.num_elements;
temporary_storage.elements = malloc (temporary_storage.num_elements * sizeof (struct temp_abs_nD_data_element_struct));
+ if (!temporary_storage.elements)
+ exit (fprintf (stderr, "Union_abs_logger_nD: %s: ERROR allocating memory (record_to_temp_abs_nD)\n", abs_logger->name));
int index;
for (index = 0; index < storage->temp_abs_nD_data.num_elements; index++) {
@@ -257,6 +263,8 @@ SHARE
// allocate larger array (10 larger)
storage->temp_abs_nD_data.allocated_elements = 10 + storage->temp_abs_nD_data.num_elements;
storage->temp_abs_nD_data.elements = malloc (storage->temp_abs_nD_data.allocated_elements * sizeof (struct temp_abs_nD_data_element_struct));
+ if (!storage->temp_abs_nD_data.elements)
+ exit (fprintf (stderr, "Union_abs_logger_nD: %s: ERROR allocating memory (record_to_temp_abs_nD)\n", abs_logger->name));
// copy back from temp
for (index = 0; index < storage->temp_abs_nD_data.num_elements; index++) {
@@ -328,14 +336,19 @@ SHARE
}
if (add_point == 1) {
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+ int i;
double given_x_pos, given_y_pos, given_z_pos;
- coords_get (*position, &given_x_pos, &given_y_pos, &given_z_pos);
+ coords_get (transformed_ray_position, &given_x_pos, &given_y_pos, &given_z_pos);
+
+ Coords k_coords = make_position (k);
+ Coords transformed_k_coords = rot_apply (storage->rotation, k_coords);
double given_x_vel, given_y_vel, given_z_vel;
- given_x_vel = k[0] * K2V;
- given_y_vel = k[1] * K2V;
- given_z_vel = k[2] * K2V;
+ coords_get (coords_scalar_mult (transformed_k_coords, K2V), &given_x_vel, &given_y_vel, &given_z_vel);
_class_particle _localparticle;
@@ -518,6 +531,8 @@ INITIALIZE INHERIT Monitor_nD EXTEND
this_abs_storage.temp_abs_nD_data.allocated_elements = 10;
this_abs_storage.temp_abs_nD_data.elements = malloc (this_abs_storage.temp_abs_nD_data.allocated_elements * sizeof (struct temp_abs_nD_data_element_struct));
+ if (!this_abs_storage.temp_abs_nD_data.elements)
+ exit (fprintf (stderr, "Union_abs_logger_nD: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
if (_getcomp_index (init) < 0) {
fprintf (stderr, "Union_abs_logger_nD:%s: Error identifying Union_init component, %s is not a known component name.\n", NAME_CURRENT_COMP, init);
@@ -527,14 +542,11 @@ INITIALIZE INHERIT Monitor_nD EXTEND
struct global_positions_to_transform_list_struct* global_positions_to_transform_list = COMP_GETPAR3 (Union_init, init, global_positions_to_transform_list);
struct global_rotations_to_transform_list_struct* global_rotations_to_transform_list = COMP_GETPAR3 (Union_init, init, global_rotations_to_transform_list);
// Test position and rotation stored in a data storage, and pointers assigned to transform lists
- this_abs_logger.position = POS_A_CURRENT_COMP;
- add_position_pointer_to_list (global_positions_to_transform_list, &this_abs_logger.position);
-
- rot_copy (this_abs_logger.rotation, ROT_A_CURRENT_COMP);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_logger.rotation);
+ this_abs_storage.position = POS_A_CURRENT_COMP;
+ add_position_pointer_to_list (global_positions_to_transform_list, &this_abs_storage.position);
- rot_transpose (ROT_A_CURRENT_COMP, this_abs_logger.t_rotation);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_logger.t_rotation);
+ rot_copy (this_abs_storage.rotation, ROT_A_CURRENT_COMP);
+ add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_abs_storage.rotation);
// Book keeping
this_abs_logger.abs_logger_extend_index = logger_conditional_extend_index;
diff --git a/mcstas-comps/union/Union_conditional_PSD.comp b/mcstas-comps/union/Union_conditional_PSD.comp
index f52d57478e..04a3429a71 100644
--- a/mcstas-comps/union/Union_conditional_PSD.comp
+++ b/mcstas-comps/union/Union_conditional_PSD.comp
@@ -425,7 +425,7 @@ INITIALIZE
}
// Add a pointer to this conditional function to the list of conditionals for this logger
- add_function_to_conditional_list (&found_logger->conditional_list, &conditional_function_PSD, &this_data_union);
+ add_function_to_conditional_list (&found_abs_logger->conditional_list, &conditional_function_PSD, &this_data_union);
}
} else {
diff --git a/mcstas-comps/union/Union_conditional_standard.comp b/mcstas-comps/union/Union_conditional_standard.comp
index 109cbb81e0..c7754562b1 100644
--- a/mcstas-comps/union/Union_conditional_standard.comp
+++ b/mcstas-comps/union/Union_conditional_standard.comp
@@ -477,7 +477,7 @@ INITIALIZE
}
// Add a pointer to this conditional function to the list of conditionals for this logger
- add_function_to_conditional_list (&found_logger->conditional_list, &conditional_function_standard, &this_data_union);
+ add_function_to_conditional_list (&found_abs_logger->conditional_list, &conditional_function_standard, &this_data_union);
}
/*
for (loop_index=0;loop_indextemp_1D_data.num_elements;
temporary_storage.elements = malloc (temporary_storage.num_elements * sizeof (struct temp_1D_data_element_struct));
+ if (!temporary_storage.elements)
+ exit (fprintf (stderr, "Union_logger_1D: %s: ERROR allocating memory (record_to_temp_1D)\n", logger->name));
for (index = 0; index < storage->temp_1D_data.num_elements; index++) {
temporary_storage.elements[index].index = storage->temp_1D_data.elements[index].index;
@@ -178,6 +180,8 @@ SHARE
// allocate larger array (10 larger)
storage->temp_1D_data.allocated_elements = 10 + storage->temp_1D_data.num_elements;
storage->temp_1D_data.elements = malloc (storage->temp_1D_data.allocated_elements * sizeof (struct temp_1D_data_element_struct));
+ if (!storage->temp_1D_data.elements)
+ exit (fprintf (stderr, "Union_logger_1D: %s: ERROR allocating memory (record_to_temp_1D)\n", logger->name));
// copy back from temp
for (index = 0; index < storage->temp_1D_data.num_elements; index++) {
@@ -445,8 +449,16 @@ INITIALIZE
// Remember to take special care when deallocating this array
this_storage.Detector_1D.Array_N = malloc (n1 * sizeof (double));
+ if (!this_storage.Detector_1D.Array_N)
+ exit (fprintf (stderr, "Union_logger_1D: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
+
this_storage.Detector_1D.Array_p = malloc (n1 * sizeof (double));
+ if (!this_storage.Detector_1D.Array_p)
+ exit (fprintf (stderr, "Union_logger_1D: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
+
this_storage.Detector_1D.Array_p2 = malloc (n1 * sizeof (double));
+ if (!this_storage.Detector_1D.Array_p2)
+ exit (fprintf (stderr, "Union_logger_1D: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
int l1, l2;
for (l1 = 0; l1 < n1; l1++) { // n1 is technically a double, but this works fine
@@ -484,6 +496,8 @@ INITIALIZE
this_storage.temp_1D_data.num_elements = 0;
this_storage.temp_1D_data.allocated_elements = 10;
this_storage.temp_1D_data.elements = malloc (this_storage.temp_1D_data.allocated_elements * sizeof (struct temp_1D_data_element_struct));
+ if (!this_storage.temp_1D_data.elements)
+ exit (fprintf (stderr, "Union_logger_1D: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
// printf("past direction choices sanitation \n");
diff --git a/mcstas-comps/union/Union_logger_2DQ.comp b/mcstas-comps/union/Union_logger_2DQ.comp
index 0641e44ee7..5fbb7104b5 100644
--- a/mcstas-comps/union/Union_logger_2DQ.comp
+++ b/mcstas-comps/union/Union_logger_2DQ.comp
@@ -107,6 +107,8 @@ SHARE
int order;
int order_in_this_volume;
int order_process_in_this_volume;
+
+ Rotation rotation;
};
// record_to_temp
@@ -144,11 +146,18 @@ SHARE
if (add_point == 1) {
+ // k_new given in master coordinates, transform to local
+ // Done here instead of master to save performance, avoid unecessary transforms
+ Coords q_master = coords_sub (make_position (k_old), make_position (k_new));
+ Coords q_local_coords = rot_apply (storage->rotation, q_master);
+ double q_local_double[3];
+ coords_get (q_local_coords, &q_local_double[0], &q_local_double[1], &q_local_double[2]);
+
double q1, q2;
// dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input. "x" "y" "z".
- q1 = k_old[storage->dim_1_choice] - k_new[storage->dim_1_choice];
- q2 = k_old[storage->dim_2_choice] - k_new[storage->dim_2_choice];
+ q1 = q_local_double[storage->dim_1_choice];
+ q2 = q_local_double[storage->dim_2_choice];
int i, j;
@@ -173,6 +182,8 @@ SHARE
struct temp_2DQ_data_struct temporary_storage;
temporary_storage.num_elements = storage->temp_2DQ_data.num_elements;
temporary_storage.elements = malloc (temporary_storage.num_elements * sizeof (struct temp_2DQ_data_element_struct));
+ if (!temporary_storage.elements)
+ exit (fprintf (stderr, "Union_logger_2DQ: %s: ERROR allocating memory (record_to_temp_2DQ)\n", logger->name));
for (index = 0; index < storage->temp_2DQ_data.num_elements; index++) {
temporary_storage.elements[index].index_1 = storage->temp_2DQ_data.elements[index].index_1;
@@ -186,6 +197,8 @@ SHARE
// allocate larger array (10 larger)
storage->temp_2DQ_data.allocated_elements = 10 + storage->temp_2DQ_data.num_elements;
storage->temp_2DQ_data.elements = malloc (storage->temp_2DQ_data.allocated_elements * sizeof (struct temp_2DQ_data_element_struct));
+ if (!storage->temp_2DQ_data.elements)
+ exit (fprintf (stderr, "Union_logger_2DQ: %s: ERROR allocating memory (record_to_temp_2DQ)\n", logger->name));
// copy back from temp
for (index = 0; index < storage->temp_2DQ_data.num_elements; index++) {
@@ -250,12 +263,19 @@ SHARE
}
if (add_point == 1) {
- // printf("storage was set \n");
+
+ // k_new given in master coordinates, transform to local
+ // Done here instead of master to save performance, avoid unecessary transforms
+ Coords q_master = coords_sub (make_position (k_old), make_position (k_new));
+ Coords q_local_coords = rot_apply (storage->rotation, q_master);
+ double q_local_double[3];
+ coords_get (q_local_coords, &q_local_double[0], &q_local_double[1], &q_local_double[2]);
+
double q1, q2;
// dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input "x" "y" "z".
- q1 = k_old[storage->dim_1_choice] - k_new[storage->dim_1_choice];
- q2 = k_old[storage->dim_2_choice] - k_new[storage->dim_2_choice];
+ q1 = q_local_double[storage->dim_1_choice];
+ q2 = q_local_double[storage->dim_2_choice];
int i, j;
@@ -410,15 +430,13 @@ SHARE
// allocate space for actual data
double* data = malloc (sizeof (double) * count_x * count_y);
+ if (!data)
+ exit (fprintf (stderr, "Union_logger_2DQ: ERROR allocating memory (allocate2Ddouble)\n"));
// create array or pointers to first elem in each 2D row
double** ptr_array = malloc (sizeof (double*) * count_x);
- if (data == NULL || ptr_array == NULL) {
- free (data);
- free (ptr_array);
- printf ("\nERROR: ptr array or data not allocated in Union_logger_2DQ\n");
- exit (1);
- }
+ if (!ptr_array)
+ exit (fprintf (stderr, "Union_logger_2DQ: ERROR allocating memory (allocate2Ddouble)\n"));
for (i = 0; i < count_x; i++) {
ptr_array[i] = data + (i * count_y);
}
@@ -560,6 +578,8 @@ INITIALIZE
this_storage.temp_2DQ_data.num_elements = 0;
this_storage.temp_2DQ_data.allocated_elements = 10;
this_storage.temp_2DQ_data.elements = malloc (this_storage.temp_2DQ_data.allocated_elements * sizeof (struct temp_2DQ_data_element_struct));
+ if (!this_storage.temp_2DQ_data.elements)
+ exit (fprintf (stderr, "Union_logger_2DQ: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
// printf("past direction choices sanitation \n");
@@ -591,6 +611,12 @@ INITIALIZE
exit (-1);
}
+ // Global variables retrieved from init component
+ struct global_rotations_to_transform_list_struct* global_rotations_to_transform_list = COMP_GETPAR3 (Union_init, init, global_rotations_to_transform_list);
+
+ rot_copy (this_storage.rotation, ROT_A_CURRENT_COMP);
+ add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_storage.rotation);
+
// In order to run the logger at the right times, pointers to this logger is stored in each volume it logs,
// and additionally for each avaiable process. If a process is not logged, the pointer is simply not stored.
struct pointer_to_global_geometry_list* global_geometry_list = COMP_GETPAR3 (Union_init, init, global_geometry_list);
diff --git a/mcstas-comps/union/Union_logger_2D_kf.comp b/mcstas-comps/union/Union_logger_2D_kf.comp
index b6be29e97f..1255d5db55 100644
--- a/mcstas-comps/union/Union_logger_2D_kf.comp
+++ b/mcstas-comps/union/Union_logger_2D_kf.comp
@@ -104,6 +104,8 @@ SHARE
int order;
int order_in_this_volume;
int order_process_in_this_volume;
+
+ Rotation rotation;
};
// record_to_temp
@@ -140,12 +142,18 @@ SHARE
}
if (add_point == 1) {
+ // k_new given in master coordinates, transform to local
+ // Done here instead of master to save performance, avoid unecessary transforms
+ Coords k_new_master = make_position (k_new);
+ Coords k_new_local = rot_apply (storage->rotation, k_new_master);
+ double k_new_local_double[3];
+ coords_get (k_new_local, &k_new_local_double[0], &k_new_local_double[1], &k_new_local_double[2]);
double q1, q2;
// dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input. "x" "y" "z".
- q1 = k_new[storage->dim_1_choice];
- q2 = k_new[storage->dim_2_choice];
+ q1 = k_new_local_double[storage->dim_1_choice];
+ q2 = k_new_local_double[storage->dim_2_choice];
int i, j;
@@ -170,6 +178,8 @@ SHARE
struct temp_2D_kf_data_struct temporary_storage;
temporary_storage.num_elements = storage->temp_2D_kf_data.num_elements;
temporary_storage.elements = malloc (temporary_storage.num_elements * sizeof (struct temp_2D_kf_data_element_struct));
+ if (!temporary_storage.elements)
+ exit (fprintf (stderr, "Union_logger_2D_kf: %s: ERROR allocating memory (record_to_temp_2D_kf)\n", logger->name));
for (index = 0; index < storage->temp_2D_kf_data.num_elements; index++) {
temporary_storage.elements[index].index_1 = storage->temp_2D_kf_data.elements[index].index_1;
@@ -183,6 +193,8 @@ SHARE
// allocate larger array (10 larger)
storage->temp_2D_kf_data.allocated_elements = 10 + storage->temp_2D_kf_data.num_elements;
storage->temp_2D_kf_data.elements = malloc (storage->temp_2D_kf_data.allocated_elements * sizeof (struct temp_2D_kf_data_element_struct));
+ if (!storage->temp_2D_kf_data.elements)
+ exit (fprintf (stderr, "Union_logger_2D_kf: %s: ERROR allocating memory (record_to_temp_2D_kf)\n", logger->name));
// copy back from temp
for (index = 0; index < storage->temp_2D_kf_data.num_elements; index++) {
@@ -247,12 +259,18 @@ SHARE
}
if (add_point == 1) {
- // printf("storage was set \n");
+ // k_new given in master coordinates, transform to local
+ // Done here instead of master to save performance, avoid unecessary transforms
+ Coords k_new_master = make_position (k_new);
+ Coords k_new_local = rot_apply (storage->rotation, k_new_master);
+ double k_new_local_double[3];
+ coords_get (k_new_local, &k_new_local_double[0], &k_new_local_double[1], &k_new_local_double[2]);
+
double q1, q2;
- // dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input "x" "y" "z".
- q1 = k_new[storage->dim_1_choice];
- q2 = k_new[storage->dim_2_choice];
+ // dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input. "x" "y" "z".
+ q1 = k_new_local_double[storage->dim_1_choice];
+ q2 = k_new_local_double[storage->dim_2_choice];
int i, j;
@@ -407,9 +425,14 @@ SHARE
// allocate space for actual data
double* data = malloc (sizeof (double) * count_x * count_y);
+ if (!data)
+ exit (fprintf (stderr, "Union_logger_2D_kf: ERROR allocating memory (allocate2Ddouble_2D_kf)\n"));
// create array or pointers to first elem in each 2D row
double** ptr_array = malloc (sizeof (double*) * count_x);
+ if (!ptr_array)
+ exit (fprintf (stderr, "Union_logger_2D_kf: ERROR allocating memory (allocate2Ddouble_2D_kf)\n"));
+
for (i = 0; i < count_x; i++) {
ptr_array[i] = data + (i * count_y);
}
@@ -552,6 +575,8 @@ INITIALIZE
this_storage.temp_2D_kf_data.num_elements = 0;
this_storage.temp_2D_kf_data.allocated_elements = 10;
this_storage.temp_2D_kf_data.elements = malloc (this_storage.temp_2D_kf_data.allocated_elements * sizeof (struct temp_2D_kf_data_element_struct));
+ if (!this_storage.temp_2D_kf_data.elements)
+ exit (fprintf (stderr, "Union_logger_2D_kf: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
// printf("past direction choices sanitation \n");
@@ -588,6 +613,12 @@ INITIALIZE
exit (-1);
}
+ // Global variables retrieved from init component
+ struct global_rotations_to_transform_list_struct* global_rotations_to_transform_list = COMP_GETPAR3 (Union_init, init, global_rotations_to_transform_list);
+
+ rot_copy (this_storage.rotation, ROT_A_CURRENT_COMP);
+ add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_storage.rotation);
+
// In order to run the logger at the right times, pointers to this logger is stored in each volume it logs,
// and additionally for each avaiable process. If a process is not logged, the pointer is simply not stored.
struct pointer_to_global_geometry_list* global_geometry_list = COMP_GETPAR3 (Union_init, init, global_geometry_list);
diff --git a/mcstas-comps/union/Union_logger_2D_kf_time.comp b/mcstas-comps/union/Union_logger_2D_kf_time.comp
index e3d370374c..2e13a9d533 100644
--- a/mcstas-comps/union/Union_logger_2D_kf_time.comp
+++ b/mcstas-comps/union/Union_logger_2D_kf_time.comp
@@ -110,6 +110,8 @@ SHARE
int order;
int order_in_this_volume;
int order_process_in_this_volume;
+
+ Rotation rotation;
};
// record_to_temp
@@ -147,11 +149,18 @@ SHARE
if (add_point == 1) {
+ // k_new given in master coordinates, transform to local
+ // Done here instead of master to save performance, avoid unecessary transforms
+ Coords k_new_master = make_position (k_new);
+ Coords k_new_local = rot_apply (storage->rotation, k_new_master);
+ double k_new_local_double[3];
+ coords_get (k_new_local, &k_new_local_double[0], &k_new_local_double[1], &k_new_local_double[2]);
+
double p1, p2;
// dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input. "x" "y" "z".
- p1 = k_new[storage->dim_1_choice];
- p2 = k_new[storage->dim_2_choice];
+ p1 = k_new_local_double[storage->dim_1_choice];
+ p2 = k_new_local_double[storage->dim_2_choice];
int i, j, k;
@@ -179,6 +188,8 @@ SHARE
struct temp_2D_kf_t_data_struct temporary_storage;
temporary_storage.num_elements = storage->temp_2D_kf_t_data.num_elements;
temporary_storage.elements = malloc (temporary_storage.num_elements * sizeof (struct temp_2D_kf_t_data_element_struct));
+ if (!temporary_storage.elements)
+ exit (fprintf (stderr, "Union_logger_2D_kf_time: %s: ERROR allocating memory (record_to_temp_2D_kf_t)\n", logger->name));
for (index = 0; index < storage->temp_2D_kf_t_data.num_elements; index++) {
temporary_storage.elements[index].index_1 = storage->temp_2D_kf_t_data.elements[index].index_1;
@@ -193,6 +204,8 @@ SHARE
// allocate larger array (10 larger)
storage->temp_2D_kf_t_data.allocated_elements = 10 + storage->temp_2D_kf_t_data.num_elements;
storage->temp_2D_kf_t_data.elements = malloc (storage->temp_2D_kf_t_data.allocated_elements * sizeof (struct temp_2D_kf_t_data_element_struct));
+ if (!storage->temp_2D_kf_t_data.elements)
+ exit (fprintf (stderr, "Union_logger_2D_kf_time: %s: ERROR allocating memory (record_to_temp_2D_kf_t)\n", logger->name));
// copy back from temp
for (index = 0; index < storage->temp_2D_kf_t_data.num_elements; index++) {
@@ -259,12 +272,18 @@ SHARE
}
if (add_point == 1) {
- // printf("storage was set \n");
+ // k_new given in master coordinates, transform to local
+ // Done here instead of master to save performance, avoid unecessary transforms
+ Coords k_new_master = make_position (k_new);
+ Coords k_new_local = rot_apply (storage->rotation, k_new_master);
+ double k_new_local_double[3];
+ coords_get (k_new_local, &k_new_local_double[0], &k_new_local_double[1], &k_new_local_double[2]);
+
double p1, p2;
// dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input. "x" "y" "z".
- p1 = k_new[storage->dim_1_choice];
- p2 = k_new[storage->dim_2_choice];
+ p1 = k_new_local_double[storage->dim_1_choice];
+ p2 = k_new_local_double[storage->dim_2_choice];
int i, j, k;
@@ -424,12 +443,21 @@ SHARE
allocate3Ddouble_2D_kf_t (int count_x, int count_y, int count_z, double* storage) {
// double *storage = malloc(count_x * count_y * count_z * sizeof(double));
storage = malloc (count_x * count_y * count_z * sizeof (double));
+ if (!storage)
+ exit (fprintf (stderr, "Union_logger_2D_kf_time: ERROR allocating memory (allocate3Ddouble_2D_kf_t)\n"));
+
double* alloc = storage;
double*** x;
int i, j;
x = malloc (count_x * sizeof (*x));
+ if (!x)
+ exit (fprintf (stderr, "Union_logger_2D_kf_time: ERROR allocating memory (allocate3Ddouble_2D_kf_t)\n"));
+
for (i = 0; i < count_x; i++) {
x[i] = malloc (count_y * sizeof (**x));
+ if (!x[i])
+ exit (fprintf (stderr, "Union_logger_2D_kf_time: ERROR allocating memory (allocate3Ddouble_2D_kf_t)\n"));
+
for (j = 0; j < count_y; j++) {
x[i][j] = alloc;
alloc += count_z;
@@ -619,6 +647,8 @@ INITIALIZE
this_storage.temp_2D_kf_t_data.num_elements = 0;
this_storage.temp_2D_kf_t_data.allocated_elements = 10;
this_storage.temp_2D_kf_t_data.elements = malloc (this_storage.temp_2D_kf_t_data.allocated_elements * sizeof (struct temp_2D_kf_t_data_element_struct));
+ if (!this_storage.temp_2D_kf_t_data.elements)
+ exit (fprintf (stderr, "Union_logger_2D_kf_time: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
// printf("past direction choices sanitation \n");
@@ -655,6 +685,12 @@ INITIALIZE
exit (-1);
}
+ // Global variables retrieved from init component
+ struct global_rotations_to_transform_list_struct* global_rotations_to_transform_list = COMP_GETPAR3 (Union_init, init, global_rotations_to_transform_list);
+
+ rot_copy (this_storage.rotation, ROT_A_CURRENT_COMP);
+ add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_storage.rotation);
+
// In order to run the logger at the right times, pointers to this logger is stored in each volume it logs,
// and additionally for each avaiable process. If a process is not logged, the pointer is simply not stored.
struct pointer_to_global_geometry_list* global_geometry_list = COMP_GETPAR3 (Union_init, init, global_geometry_list);
diff --git a/mcstas-comps/union/Union_logger_2D_space.comp b/mcstas-comps/union/Union_logger_2D_space.comp
index eabd95406f..b6e6353ae8 100644
--- a/mcstas-comps/union/Union_logger_2D_space.comp
+++ b/mcstas-comps/union/Union_logger_2D_space.comp
@@ -111,7 +111,6 @@ SHARE
Coords position;
Rotation rotation;
- Rotation t_rotation;
};
// record_to_temp
@@ -152,20 +151,24 @@ SHARE
double p1, p2;
p1 = p2 = 0;
- // dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input. "x" "y" "z".
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+
+ // dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input "x" "y" "z".
if (storage->dim_1_choice == 0)
- p1 = position->x - storage->position.x;
+ p1 = transformed_ray_position.x;
else if (storage->dim_1_choice == 1)
- p1 = position->y - storage->position.y;
+ p1 = transformed_ray_position.y;
else if (storage->dim_1_choice == 2)
- p1 = position->z - storage->position.z;
+ p1 = transformed_ray_position.z;
if (storage->dim_2_choice == 0)
- p2 = position->x - storage->position.x;
+ p2 = transformed_ray_position.x;
else if (storage->dim_2_choice == 1)
- p2 = position->y - storage->position.y;
+ p2 = transformed_ray_position.y;
else if (storage->dim_2_choice == 2)
- p2 = position->z - storage->position.z;
+ p2 = transformed_ray_position.z;
int i, j;
@@ -190,6 +193,8 @@ SHARE
struct temp_2DS_data_struct temporary_storage;
temporary_storage.num_elements = storage->temp_2DS_data.num_elements;
temporary_storage.elements = malloc (temporary_storage.num_elements * sizeof (struct temp_2DS_data_element_struct));
+ if (!temporary_storage.elements)
+ exit (fprintf (stderr, "Union_logger_2D_space: %s: ERROR allocating memory (record_to_temp_2DS)\n", logger->name));
for (index = 0; index < storage->temp_2DS_data.num_elements; index++) {
temporary_storage.elements[index].index_1 = storage->temp_2DS_data.elements[index].index_1;
@@ -203,6 +208,8 @@ SHARE
// allocate larger array (10 larger)
storage->temp_2DS_data.allocated_elements = 10 + storage->temp_2DS_data.num_elements;
storage->temp_2DS_data.elements = malloc (storage->temp_2DS_data.allocated_elements * sizeof (struct temp_2DS_data_element_struct));
+ if (!storage->temp_2DS_data.elements)
+ exit (fprintf (stderr, "Union_logger_2D_space: %s: ERROR allocating memory (record_to_temp_2DS)\n", logger->name));
// copy back from temp
for (index = 0; index < storage->temp_2DS_data.num_elements; index++) {
@@ -271,26 +278,24 @@ SHARE
double p1, p2;
p1 = p2 = 0;
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+
// dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input "x" "y" "z".
if (storage->dim_1_choice == 0)
- p1 = position->x - storage->position.x;
- // p1 = position->x;
+ p1 = transformed_ray_position.x;
else if (storage->dim_1_choice == 1)
- p1 = position->y - storage->position.y;
- // p1 = position->y;
+ p1 = transformed_ray_position.y;
else if (storage->dim_1_choice == 2)
- p1 = position->z - storage->position.z;
- // p1 = position->z;
+ p1 = transformed_ray_position.z;
if (storage->dim_2_choice == 0)
- p2 = position->x - storage->position.x;
- // p2 = position->x;
+ p2 = transformed_ray_position.x;
else if (storage->dim_2_choice == 1)
- p2 = position->y - storage->position.y;
- // p2 = position->y;
+ p2 = transformed_ray_position.y;
else if (storage->dim_2_choice == 2)
- p2 = position->z - storage->position.z;
- // p2 = position->z;
+ p2 = transformed_ray_position.z;
int i, j;
@@ -448,15 +453,14 @@ SHARE
// allocate space for actual data
double* data = malloc (sizeof (double) * count_x * count_y);
+ if (!data)
+ exit (fprintf (stderr, "Union_logger_2D_space: ERROR allocating memory (allocate2Ddouble_2DS)\n"));
// create array or pointers to first elem in each 2D row
double** ptr_array = malloc (sizeof (double*) * count_x);
- if (data == NULL || ptr_array == NULL) {
- free (data);
- free (ptr_array);
- printf ("\nERROR: ptr array or data not allocated in Union_logger_2D_space\n");
- exit (1);
- }
+ if (!ptr_array)
+ exit (fprintf (stderr, "Union_logger_2D_space: ERROR allocating memory (allocate2Ddouble_2DS)\n"));
+
for (i = 0; i < count_x; i++) {
ptr_array[i] = data + (i * count_y);
}
@@ -601,6 +605,8 @@ INITIALIZE
// Added 17/11/2016, allocating some elements in initialize makes code during trace simpler
this_storage.temp_2DS_data.allocated_elements = 10;
this_storage.temp_2DS_data.elements = malloc (this_storage.temp_2DS_data.allocated_elements * sizeof (struct temp_2DS_data_element_struct));
+ if (!this_storage.temp_2DS_data.elements)
+ exit (fprintf (stderr, "Union_logger_2D_space: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
if (_getcomp_index (init) < 0) {
fprintf (stderr, "Union_logger_2D_space:%s: Error identifying Union_init component, %s is not a known component name.\n", NAME_CURRENT_COMP, init);
@@ -616,9 +622,6 @@ INITIALIZE
rot_copy (this_storage.rotation, ROT_A_CURRENT_COMP);
add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_storage.rotation);
- rot_transpose (ROT_A_CURRENT_COMP, this_storage.t_rotation);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_storage.t_rotation);
-
// printf("past direction choices sanitation \n");
// Book keeping
diff --git a/mcstas-comps/union/Union_logger_2D_space_time.comp b/mcstas-comps/union/Union_logger_2D_space_time.comp
index a206d578b2..30186e9127 100644
--- a/mcstas-comps/union/Union_logger_2D_space_time.comp
+++ b/mcstas-comps/union/Union_logger_2D_space_time.comp
@@ -113,7 +113,6 @@ SHARE
Coords position;
Rotation rotation;
- Rotation t_rotation;
};
// record_to_temp
@@ -154,20 +153,24 @@ SHARE
double p1, p2;
p1 = p2 = 0;
- // dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input. "x" "y" "z".
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+
+ // dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input "x" "y" "z".
if (storage->dim_1_choice == 0)
- p1 = position->x - storage->position.x;
+ p1 = transformed_ray_position.x;
else if (storage->dim_1_choice == 1)
- p1 = position->y - storage->position.y;
+ p1 = transformed_ray_position.y;
else if (storage->dim_1_choice == 2)
- p1 = position->z - storage->position.z;
+ p1 = transformed_ray_position.z;
if (storage->dim_2_choice == 0)
- p2 = position->x - storage->position.x;
+ p2 = transformed_ray_position.x;
else if (storage->dim_2_choice == 1)
- p2 = position->y - storage->position.y;
+ p2 = transformed_ray_position.y;
else if (storage->dim_2_choice == 2)
- p2 = position->z - storage->position.z;
+ p2 = transformed_ray_position.z;
int i, j, k;
@@ -195,6 +198,8 @@ SHARE
struct temp_2DS_t_data_struct temporary_storage;
temporary_storage.num_elements = storage->temp_2DS_t_data.num_elements;
temporary_storage.elements = malloc (temporary_storage.num_elements * sizeof (struct temp_2DS_t_data_element_struct));
+ if (!temporary_storage.elements)
+ exit (fprintf (stderr, "Union_logger_2D_space_time: %s: ERROR allocating memory (record_to_temp_2DS_t)\n", logger->name));
for (index = 0; index < storage->temp_2DS_t_data.num_elements; index++) {
temporary_storage.elements[index].index_1 = storage->temp_2DS_t_data.elements[index].index_1;
@@ -209,6 +214,8 @@ SHARE
// allocate larger array (10 larger)
storage->temp_2DS_t_data.allocated_elements = 10 + storage->temp_2DS_t_data.num_elements;
storage->temp_2DS_t_data.elements = malloc (storage->temp_2DS_t_data.allocated_elements * sizeof (struct temp_2DS_t_data_element_struct));
+ if (!storage->temp_2DS_t_data.elements)
+ exit (fprintf (stderr, "Union_logger_2D_space_time: %s: ERROR allocating memory (record_to_temp_2DS_t)\n", logger->name));
// copy back from temp
for (index = 0; index < storage->temp_2DS_t_data.num_elements; index++) {
@@ -279,26 +286,24 @@ SHARE
double p1, p2;
p1 = p2 = 0;
- // dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input. "x" "y" "z".
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+
+ // dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input "x" "y" "z".
if (storage->dim_1_choice == 0)
- p1 = position->x - storage->position.x;
- // p1 = position->x;
+ p1 = transformed_ray_position.x;
else if (storage->dim_1_choice == 1)
- p1 = position->y - storage->position.y;
- // p1 = position->y;
+ p1 = transformed_ray_position.y;
else if (storage->dim_1_choice == 2)
- p1 = position->z - storage->position.z;
- // p1 = position->z;
+ p1 = transformed_ray_position.z;
if (storage->dim_2_choice == 0)
- p2 = position->x - storage->position.x;
- // p2 = position->x;
+ p2 = transformed_ray_position.x;
else if (storage->dim_2_choice == 1)
- p2 = position->y - storage->position.y;
- // p2 = position->y;
+ p2 = transformed_ray_position.y;
else if (storage->dim_2_choice == 2)
- p2 = position->z - storage->position.z;
- // p2 = position->z;
+ p2 = transformed_ray_position.z;
int i, j, k;
@@ -458,12 +463,20 @@ SHARE
allocate3Ddouble_2DS_t (int count_x, int count_y, int count_z, double* storage) {
// double *storage = malloc(count_x * count_y * count_z * sizeof(double));
storage = malloc (count_x * count_y * count_z * sizeof (double));
+ if (!storage)
+ exit (fprintf (stderr, "Union_logger_2D_space_time: ERROR allocating memory (allocate3Ddouble_2DS_t)\n"));
double* alloc = storage;
double*** x;
int i, j;
x = malloc (count_x * sizeof (*x));
+ if (!x)
+ exit (fprintf (stderr, "Union_logger_2D_space_time: ERROR allocating memory (allocate3Ddouble_2DS_t)\n"));
+
for (i = 0; i < count_x; i++) {
x[i] = malloc (count_y * sizeof (**x));
+ if (!x[i])
+ exit (fprintf (stderr, "Union_logger_2D_space_time: ERROR allocating memory (allocate3Ddouble_2DS_t)\n"));
+
for (j = 0; j < count_y; j++) {
x[i][j] = alloc;
alloc += count_z;
@@ -655,6 +668,8 @@ INITIALIZE
this_storage.temp_2DS_t_data.num_elements = 0;
this_storage.temp_2DS_t_data.allocated_elements = 10;
this_storage.temp_2DS_t_data.elements = malloc (this_storage.temp_2DS_t_data.allocated_elements * sizeof (struct temp_2DS_t_data_element_struct));
+ if (!this_storage.temp_2DS_t_data.elements)
+ exit (fprintf (stderr, "Union_logger_2D_space_time: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
if (_getcomp_index (init) < 0) {
fprintf (stderr, "Union_logger_2D_space_time:%s: Error identifying Union_init component, %s is not a known component name.\n", NAME_CURRENT_COMP, init);
@@ -669,9 +684,6 @@ INITIALIZE
rot_copy (this_storage.rotation, ROT_A_CURRENT_COMP);
add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_storage.rotation);
- rot_transpose (ROT_A_CURRENT_COMP, this_storage.t_rotation);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_storage.t_rotation);
-
// printf("past direction choices sanitation \n");
// Book keeping
diff --git a/mcstas-comps/union/Union_logger_3D_space.comp b/mcstas-comps/union/Union_logger_3D_space.comp
index e71df0acec..cc6980e428 100644
--- a/mcstas-comps/union/Union_logger_3D_space.comp
+++ b/mcstas-comps/union/Union_logger_3D_space.comp
@@ -115,7 +115,6 @@ SHARE
Coords position;
Rotation rotation;
- Rotation t_rotation;
};
// record_to_temp
@@ -156,27 +155,31 @@ SHARE
double p1, p2, p3;
p1 = p2 = p3 = 0;
- // dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input. "x" "y" "z".
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+
+ // dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input "x" "y" "z".
if (storage->dim_1_choice == 0)
- p1 = position->x - storage->position.x;
+ p1 = transformed_ray_position.x;
else if (storage->dim_1_choice == 1)
- p1 = position->y - storage->position.y;
+ p1 = transformed_ray_position.y;
else if (storage->dim_1_choice == 2)
- p1 = position->z - storage->position.z;
+ p1 = transformed_ray_position.z;
if (storage->dim_2_choice == 0)
- p2 = position->x - storage->position.x;
+ p2 = transformed_ray_position.x;
else if (storage->dim_2_choice == 1)
- p2 = position->y - storage->position.y;
+ p2 = transformed_ray_position.y;
else if (storage->dim_2_choice == 2)
- p2 = position->z - storage->position.z;
+ p2 = transformed_ray_position.z;
if (storage->dim_3_choice == 0)
- p2 = position->x - storage->position.x;
+ p3 = transformed_ray_position.x;
else if (storage->dim_3_choice == 1)
- p2 = position->y - storage->position.y;
+ p3 = transformed_ray_position.y;
else if (storage->dim_3_choice == 2)
- p2 = position->z - storage->position.z;
+ p3 = transformed_ray_position.z;
int i, j, k;
@@ -204,6 +207,8 @@ SHARE
struct temp_3DS_data_struct temporary_storage;
temporary_storage.num_elements = storage->temp_3DS_data.num_elements;
temporary_storage.elements = malloc (temporary_storage.num_elements * sizeof (struct temp_3DS_data_element_struct));
+ if (!temporary_storage.elements)
+ exit (fprintf (stderr, "Union_logger_3D_space: %s: ERROR allocating memory (record_to_temp_3DS)\n", logger->name));
for (index = 0; index < storage->temp_3DS_data.num_elements; index++) {
temporary_storage.elements[index].index_1 = storage->temp_3DS_data.elements[index].index_1;
@@ -218,6 +223,8 @@ SHARE
// allocate larger array (10 larger)
storage->temp_3DS_data.allocated_elements = 10 + storage->temp_3DS_data.num_elements;
storage->temp_3DS_data.elements = malloc (storage->temp_3DS_data.allocated_elements * sizeof (struct temp_3DS_data_element_struct));
+ if (!storage->temp_3DS_data.elements)
+ exit (fprintf (stderr, "Union_logger_3D_space: %s: ERROR allocating memory (record_to_temp_3DS)\n", logger->name));
// copy back from temp
for (index = 0; index < storage->temp_3DS_data.num_elements; index++) {
@@ -288,27 +295,31 @@ SHARE
double p1, p2, p3;
p1 = p2 = p3 = 0;
- // dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input. "x" "y" "z".
+ Coords transformed_ray_position;
+ transformed_ray_position = coords_sub (*position, storage->position);
+ transformed_ray_position = rot_apply (storage->rotation, transformed_ray_position);
+
+ // dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input "x" "y" "z".
if (storage->dim_1_choice == 0)
- p1 = position->x - storage->position.x;
+ p1 = transformed_ray_position.x;
else if (storage->dim_1_choice == 1)
- p1 = position->y - storage->position.y;
+ p1 = transformed_ray_position.y;
else if (storage->dim_1_choice == 2)
- p1 = position->z - storage->position.z;
+ p1 = transformed_ray_position.z;
if (storage->dim_2_choice == 0)
- p2 = position->x - storage->position.x;
+ p2 = transformed_ray_position.x;
else if (storage->dim_2_choice == 1)
- p2 = position->y - storage->position.y;
+ p2 = transformed_ray_position.y;
else if (storage->dim_2_choice == 2)
- p2 = position->z - storage->position.z;
+ p2 = transformed_ray_position.z;
if (storage->dim_3_choice == 0)
- p3 = position->x - storage->position.x;
+ p3 = transformed_ray_position.x;
else if (storage->dim_3_choice == 1)
- p3 = position->y - storage->position.y;
+ p3 = transformed_ray_position.y;
else if (storage->dim_3_choice == 2)
- p3 = position->z - storage->position.z;
+ p3 = transformed_ray_position.z;
int i, j, k;
@@ -480,6 +491,8 @@ SHARE
allocate3Ddouble_3DS (int count_x, int count_y, int count_z, double* storage) {
// double *storage = malloc(count_x * count_y * count_z * sizeof(double));
storage = malloc (count_x * count_y * count_z * sizeof (double));
+ if (!storage)
+ exit (fprintf (stderr, "Union_logger_3D_space: ERROR allocating memory (allocate3Ddouble_3DS)\n"));
if (storage == NULL) {
free (storage);
printf ("\nERROR: storage array not allocated in Union_logger_3D_space\n");
@@ -488,6 +501,8 @@ SHARE
double*** x;
int i, j;
x = malloc (count_x * sizeof (*x));
+ if (!x)
+ exit (fprintf (stderr, "Union_logger_3D_space: ERROR allocating memory (allocate3Ddouble_3DS)\n"));
if (x == NULL) {
free (x);
printf ("\nERROR: x array not allocated in Union_logger_3D_space\n");
@@ -495,6 +510,8 @@ SHARE
}
for (i = 0; i < count_x; i++) {
x[i] = malloc (count_y * sizeof (**x));
+ if (!x[i])
+ exit (fprintf (stderr, "Union_logger_3D_space: ERROR allocating memory (allocate3Ddouble_3DS)\n"));
if (x[i] == NULL) {
free (x[i]);
printf ("\nERROR: x[i] array not allocated in Union_logger_3D_space\n");
@@ -708,6 +725,8 @@ INITIALIZE
this_storage.temp_3DS_data.num_elements = 0;
this_storage.temp_3DS_data.allocated_elements = 10;
this_storage.temp_3DS_data.elements = malloc (this_storage.temp_3DS_data.allocated_elements * sizeof (struct temp_3DS_data_element_struct));
+ if (!this_storage.temp_3DS_data.elements)
+ exit (fprintf (stderr, "Union_logger_3D_space: %s: ERROR allocating memory (init)\n", NAME_CURRENT_COMP));
if (_getcomp_index (init) < 0) {
fprintf (stderr, "Union_logger_3D:%s: Error identifying Union_init component, %s is not a known component name.\n", NAME_CURRENT_COMP, init);
@@ -724,9 +743,6 @@ INITIALIZE
rot_copy (this_storage.rotation, ROT_A_CURRENT_COMP);
add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_storage.rotation);
- rot_transpose (ROT_A_CURRENT_COMP, this_storage.t_rotation);
- add_rotation_pointer_to_list (global_rotations_to_transform_list, &this_storage.t_rotation);
-
// printf("past direction choices sanitation \n");
// Book keeping
diff --git a/mcstas-comps/union/Union_master.comp b/mcstas-comps/union/Union_master.comp
index ae0f313459..bb1b007b1a 100755
--- a/mcstas-comps/union/Union_master.comp
+++ b/mcstas-comps/union/Union_master.comp
@@ -1948,13 +1948,10 @@ TRACE
// Logging for detector components assosiated with this volume
for (log_index = 0; log_index < Volumes[current_volume]->abs_loggers.num_elements; log_index++) {
- // Make transformation according to the individual position of the abs_logger? This would require position / rotation for all abs_loggers
- transformed_abs_position = coords_sub (abs_position, Volumes[current_volume]->abs_loggers.p_abs_logger[log_index]->position);
- transformed_abs_position = rot_apply (Volumes[current_volume]->abs_loggers.p_abs_logger[log_index]->rotation, transformed_abs_position);
-
// This function calls a logger function which in turn stores some data among the passed, and possibly performs some basic data analysis
+ // Position and k_new given in master coordinates, the abs_logger must transform to its coordnate system if required
Volumes[current_volume]->abs_loggers.p_abs_logger[log_index]->function_pointers.active_record_function (
- &transformed_abs_position, k_new, initial_weight * (1.0 - abs_weight_factor), t + t_abs_propagation, scattered_flag[current_volume],
+ &abs_position, k_new, initial_weight * (1.0 - abs_weight_factor), t + t_abs_propagation, scattered_flag[current_volume],
number_of_scattering_events, Volumes[current_volume]->abs_loggers.p_abs_logger[log_index], &abs_loggers_with_data_array);
// If the logging component have a conditional attatched, the collected data will be written to a temporary place
// At the end of the rays life, it will be checked if the condition is met
@@ -1972,13 +1969,9 @@ TRACE
// general. Could be interesting to have a monitor that just globally measurres the second scattering event in any volume (must be two in the same).
// Weird but not meaningless.
- // Make transformation according to the individual position of the abs_logger? This would require position / rotation for all abs_loggers
- transformed_abs_position = coords_sub (abs_position, global_all_volume_abs_logger_list_master->elements[log_index].abs_logger->position);
- transformed_abs_position = rot_apply (global_all_volume_abs_logger_list_master->elements[log_index].abs_logger->rotation, transformed_abs_position);
-
// Above version includes scattered_flag_VP, but selected_process may be undefined at this point.
global_all_volume_abs_logger_list_master->elements[log_index].abs_logger->function_pointers.active_record_function (
- &transformed_abs_position, k_new, initial_weight * (1.0 - abs_weight_factor), t + t_abs_propagation, scattered_flag[current_volume],
+ &abs_position, k_new, initial_weight * (1.0 - abs_weight_factor), t + t_abs_propagation, scattered_flag[current_volume],
number_of_scattering_events, global_all_volume_abs_logger_list_master->elements[log_index].abs_logger, &abs_loggers_with_data_array);
}
}