Skip to content

Commit

Permalink
Allow regressor to be event number
Browse files Browse the repository at this point in the history
  • Loading branch information
sfegan committed Oct 6, 2024
1 parent d3907d0 commit 8b1afda
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
14 changes: 10 additions & 4 deletions proto/diagnostics/clock_regression.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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." ];
};
Expand Down
29 changes: 17 additions & 12 deletions src/diagnostics/clock_regression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,20 @@ namespace {
std::map<int, calin::diagnostics::clock_regression::ClockRegressionParallelEventVisitor::RegressionAccumulator*>& 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;
Expand All @@ -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();
}
Expand Down Expand Up @@ -328,37 +330,40 @@ 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);

// NectarCAM

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

Expand Down

0 comments on commit 8b1afda

Please sign in to comment.