diff --git a/proto/diagnostics/clock_regression.proto b/proto/diagnostics/clock_regression.proto index d734d4be..7188ebdf 100644 --- a/proto/diagnostics/clock_regression.proto +++ b/proto/diagnostics/clock_regression.proto @@ -27,6 +27,10 @@ import "calin.proto"; package calin.ix.diagnostics.clock_regression; +enum Regressor { + PRINCIPAL_CLOCK = 0; + EVENT_NUMBER = 1; +}; enum ClockPartitionMode { SINGLE_PARTITION = 0; @@ -41,16 +45,18 @@ message SingleClockRegressionConfig { int32 clock_id = 2 [ (CFO).desc = "ID of camera or module clock to calculate regression on. " "This is overridden by the clock_name parameter if it is present," ]; - ClockPartitionMode partition_mode = 3 [ + Regressor regressor = 3 [ + (CFO).desc = "Source of (independent) regressor." ]; + ClockPartitionMode partition_mode = 4 [ (CFO).desc = "How to partition the clock data into bins." ]; - int64 partition_bin_size = 4 [ + int64 partition_bin_size = 5 [ (CFO).desc = "Size of clock partition bins, either in events or ticks of " "principal clock." ]; - int64 principal_clock_divisor = 5 [ + int64 principal_clock_divisor = 6 [ (CFO).desc = "Divisor to apply to principal clock before regression. Should " "only be used if there is a risk of overflow of the 64-bit " "accumulators." ]; - bool include_possibly_suspect_time_values = 6 [ + bool include_possibly_suspect_time_values = 7 [ (CFO).desc = "Include values of the test clock that are flagged as " "possibly suspicious in the regression." ]; }; diff --git a/src/diagnostics/clock_regression.cpp b/src/diagnostics/clock_regression.cpp index 55be3373..8cf9f3c7 100644 --- a/src/diagnostics/clock_regression.cpp +++ b/src/diagnostics/clock_regression.cpp @@ -195,18 +195,20 @@ namespace { std::map& bins, bool do_rebalance) { + using namespace calin::ix::diagnostics::clock_regression; + int64_t regressor_value = config.regressor()==EVENT_NUMBER ? local_event_number : principal_time; int ibin; switch(config.partition_mode()) { - case calin::ix::diagnostics::clock_regression::PARTITION_BY_CLOCK_SEQUENCE_ID: + case PARTITION_BY_CLOCK_SEQUENCE_ID: ibin = clock.time_sequence_id(); break; - case calin::ix::diagnostics::clock_regression::PARTITION_BY_LOCAL_EVENT_NUMBER: + case PARTITION_BY_LOCAL_EVENT_NUMBER: ibin = local_event_number/config.partition_bin_size(); break; - case calin::ix::diagnostics::clock_regression::PARTITION_BY_MASTER_CLOCK: + case PARTITION_BY_MASTER_CLOCK: ibin = principal_time/config.partition_bin_size(); break; - case calin::ix::diagnostics::clock_regression::SINGLE_PARTITION: + case SINGLE_PARTITION: default: ibin = 0; break; @@ -216,7 +218,7 @@ namespace { bins[ibin] = accumulator = new calin::diagnostics::clock_regression::ClockRegressionParallelEventVisitor::RegressionAccumulator(); } - accumulator->accumulate(principal_time, clock.time_value()); + accumulator->accumulate(regressor_value, clock.time_value()); if(do_rebalance) { accumulator->rebalance(); } @@ -328,7 +330,9 @@ bool ClockRegressionParallelEventVisitor::merge_results() calin::ix::diagnostics::clock_regression::ClockRegressionConfig ClockRegressionParallelEventVisitor::default_config() { - calin::ix::diagnostics::clock_regression::ClockRegressionConfig config; + using namespace calin::ix::diagnostics::clock_regression; + + ClockRegressionConfig config; config.set_principal_clock_id(0); // UCTS timestamp config.set_rebalance_nevent(1000); @@ -336,29 +340,30 @@ ClockRegressionParallelEventVisitor::default_config() auto* clock = config.add_default_nectarcam_camera_clocks(); clock->set_clock_name("UCTS 10MHz counter"); // UCTS 10MHz - clock->set_partition_mode(calin::ix::diagnostics::clock_regression::PARTITION_BY_CLOCK_SEQUENCE_ID); + clock->set_partition_mode(PARTITION_BY_CLOCK_SEQUENCE_ID); clock = config.add_default_nectarcam_camera_clocks(); clock->set_clock_name("TIB 10MHz counter"); // TIB 10MHz - clock->set_partition_mode(calin::ix::diagnostics::clock_regression::PARTITION_BY_CLOCK_SEQUENCE_ID); + clock->set_partition_mode(PARTITION_BY_CLOCK_SEQUENCE_ID); clock = config.add_default_nectarcam_camera_clocks(); clock->set_clock_name("FEB local 2ns TDC counter sum"); // FEB local oscillator sum - clock->set_partition_mode(calin::ix::diagnostics::clock_regression::PARTITION_BY_CLOCK_SEQUENCE_ID); + clock->set_partition_mode(PARTITION_BY_CLOCK_SEQUENCE_ID); clock = config.add_default_nectarcam_camera_clocks(); clock->set_clock_name("FEB local 2ns TDC counter sum"); // FEB local oscillator sum - clock->set_partition_mode(calin::ix::diagnostics::clock_regression::PARTITION_BY_MASTER_CLOCK); + clock->set_partition_mode(PARTITION_BY_MASTER_CLOCK); clock->set_partition_bin_size(250000000); clock = config.add_default_nectarcam_camera_clocks(); clock->set_clock_name("UCTS timestamp"); // UCTS timestamp - clock->set_partition_mode(calin::ix::diagnostics::clock_regression::PARTITION_BY_LOCAL_EVENT_NUMBER); + clock->set_partition_mode(PARTITION_BY_LOCAL_EVENT_NUMBER); + clock->set_regressor(EVENT_NUMBER); clock->set_partition_bin_size(10000); clock = config.add_default_nectarcam_module_clocks(); clock->set_clock_name("local 2ns TDC time"); // local ~2ns TDC time - clock->set_partition_mode(calin::ix::diagnostics::clock_regression::PARTITION_BY_CLOCK_SEQUENCE_ID); + clock->set_partition_mode(PARTITION_BY_CLOCK_SEQUENCE_ID); // LSTCAM