Skip to content

Commit ee2b734

Browse files
committed
Added brick output for testing, debug etc uses. Option in CMake.
1 parent f311787 commit ee2b734

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ if(JABS_PLUGINS)
4545
endif()
4646
endif()
4747

48+
option(BRICK_OUTPUT "Always output debug brick data (will be very verbose)" OFF)
49+
if(BRICK_OUTPUT)
50+
add_compile_options(-DDEBUG_BRICK_OUTPUT)
51+
endif()
52+
4853
add_subdirectory(gitwatcher)
4954

5055
add_subdirectory(src)

src/brick.c

+13-2
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,24 @@ void bricks_convolute(gsl_histogram *h, const brick *bricks, size_t last_brick,
5151
hi = mi;
5252
}
5353
}
54-
for(size_t j = lo; j < h->n; j++) {
54+
#ifdef DEBUG_BRICK_OUTPUT
55+
double norm = 0.0;
56+
#endif
57+
for(size_t j = lo; j < h->n - 1; j++) {
5558
if(h->range[j] > E_cutoff_high) /* Low energy edge of histogram is above cutoff */
5659
break; /* Assumes histograms have increasing energy */
5760
const double E = (h->range[j] + h->range[j + 1]) / 2.0; /* Approximate gaussian at center bin */
5861
const double w = h->range[j + 1] - h->range[j];
5962
const double y = (erf_Q((b_low->E - E) / b_low->S_sum) - erf_Q((b_high->E - E) / b_high->S_sum));
60-
h->bin[j] += scale * y * w * b_w_inv * b_low->Q;
63+
double out = scale * y * w * b_w_inv * b_low->Q;
64+
h->bin[j] += out;
65+
#ifdef DEBUG_BRICK_OUTPUT
66+
fprintf(stdout, "BRICK %3zu %4zu %9.3lf %9.3lf %12e %12e %12e %12e %12e %12e\n", i, j, h->range[j] / C_KEV, h->range[j + 1] / C_KEV, out, h->bin[j], scale, y, w * b_w_inv, b_low->Q);
67+
norm += y * w * b_w_inv;
68+
#endif
6169
}
70+
#ifdef DEBUG_BRICK_OUTPUT
71+
fprintf(stdout, "BRICK #normalization calculated factor %.12lf relative error %.3e\nBRICK\nBRICK\n", norm, (norm-1.0));
72+
#endif
6273
}
6374
}

src/defaults.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#define DES_TABLE_MAX_SIZE (256 * DES_TABLE_INITIAL_ALLOC)
4242
#define ENERGY_DERIVATIVE_MIN (0.1) /* dE(detected)/dE(incident) is forced to be higher or equal to this. */
4343
#define ENERGY_DERIVATIVE_MAX (10.0)
44-
#define BRICK_WIDTH_SIGMAS_DEFAULT (2.0) /* Attempt to make bricks width energy difference equal to this many times the detector resolution and straggling sigmas combined (in quadrature (variances)) */
44+
#define BRICK_WIDTH_SIGMAS_DEFAULT (C_FWHM) /* Attempt to make bricks width energy difference equal to this many times the detector resolution and straggling sigmas combined (in quadrature (variances)) */
4545
#define INCIDENT_STOP_STEP_DEFAULT (0.0*C_KEV) /* Zero is automatic */
4646
#define INCIDENT_STOP_STEP_SIGMAS_DEFAULT (1.0)
4747
#define INCIDENT_STOP_STEP_MIN_DEFAULT (0.5 * C_KEV) /* Default minimum stopping step. */

src/script_command.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2065,7 +2065,7 @@ script_command_status script_test_reference(struct script_session *s, int argc,
20652065
jabs_message(MSG_ERROR, stderr, "Test failed.\n");
20662066
return_value = SCRIPT_COMMAND_FAILURE;
20672067
} else {
2068-
jabs_message(MSG_ERROR, stderr, "Test passed.\n");
2068+
jabs_message(MSG_INFO, stderr, "Test passed.\n");
20692069
}
20702070
}
20712071
return return_value;

0 commit comments

Comments
 (0)