379 double const expectedFrequency = timings.clockData().OpticalClock().Frequency();
381 auto const frequency = timings.OpticalClockFrequency();
384 if (frequency.value() == expectedFrequency) {
386 <<
"DetectorTimings::OpticalClockFrequency() => " << frequency;
391 <<
"Optical clock frequency expected to be " << expectedFrequency <<
" MHz, but got " 392 << frequency <<
" instead";
396 double const expectedPeriod = timings.clockData().OpticalClock().TickPeriod();
398 auto const period = timings.OpticalClockPeriod();
401 if (period.value() == expectedPeriod) {
403 <<
"DetectorTimings::OpticalClockPeriod() => " << period;
408 <<
"Optical clock period expected to be " << expectedPeriod <<
" us, but got " << period
412 if (
std::abs(period.quantity() * frequency - 1.0) > 1
e-4) {
415 <<
"Optical clock period (" << period <<
") and frequency (" << frequency
416 <<
" should have been one the inverse of the other! (their product is " 417 << (period.quantity() * frequency) <<
")";
427 auto const expectedStartTime = 0_us;
429 auto const startTime = timings.startTime<
optical_time>();
433 if (startTime == expectedStartTime) {
435 <<
"DetectorTimings::startTime<optical_time>() => " << startTime;
440 <<
"Start of optical time scale is expected to be " << expectedStartTime
441 <<
" in electronics time, but got " << startTime <<
" instead";
445 auto const expectedTrigStartTime = expectedStartTime - timings.detClocksUnits().TriggerTime();
451 if (trigStartTime == expectedTrigStartTime) {
453 <<
"DetectorTimings::startTime<optical_time, trigger_time>() => " << trigStartTime;
458 <<
"Start of optical time scale is expected to be " << expectedTrigStartTime
459 <<
" in trigger time, but got " << trigStartTime <<
" instead";
465 double const inputTick_count = 900.5;
470 double const expectedTime_us = inputTick_count * timings.clockData().OpticalClock().TickPeriod();
475 auto const time = timings.toElectronicsTime(inputTick_d);
478 if (
time.value() == expectedTime_us) {
480 <<
"DetectorTimings::toElectronicsTime<optical_tick_d>(" << inputTick_d <<
") => " <<
time;
485 <<
"Optical tick #" << inputTick_count <<
" is expected to be " << expectedTime_us
486 <<
" us in electronics time, but got " <<
time <<
" instead";
493 if (
tick == inputTick_d) {
495 <<
"DetectorTimings::toTick<optical_tick_d, " 503 <<
" is expected to be optical tick " << inputTick_d <<
", but got " <<
tick <<
" instead";
508 double const expectedTrigTime_us = expectedTime_us - timings.clockData().TriggerTime();
509 double const expectedTrigTime_truncated_us =
510 static_cast<int>(inputTick_count) * timings.clockData().OpticalClock().TickPeriod() -
511 timings.clockData().TriggerTime();
513 auto const inputTick = optical_tick::castFrom(inputTick_count);
516 auto const trigTime = timings.toTriggerTime(inputTick);
520 if (trigTime.value() == expectedTrigTime_truncated_us) {
522 <<
"DetectorTimings::toTriggerTime<optical_tick>(" << inputTick <<
") => " << trigTime;
527 <<
"Optical tick " << inputTick <<
" is expected to be " << expectedTrigTime_truncated_us
528 <<
" us in trigger time, but got " << trigTime <<
" instead";
537 if (trigTick == inputTick) {
539 <<
"DetectorTimings::toTick<optical_tick, trigger_time>(" << expectedTrigTime_us <<
") => " 545 <<
"Trigger time " << expectedTrigTime_us <<
" us is expected to be optical tick " 546 << inputTick <<
", but got " << trigTick <<
" instead";
559 if (elecTick == expectedElecTick) {
561 <<
"DetectorTimings::toTick<electronics_tick>(" << inputTick <<
") => " 567 <<
"Optical tick #" << inputTick_count <<
" is expected to be " 568 << expectedElecTick <<
" (electronics tick), but got " 569 << elecTick <<
" instead";
574 = timings.toTick<
optical_tick>(timings.toElectronicsTime(expectedElecTick));
576 auto const tickFromElecTick = timings.toTick<
optical_tick>(elecTick);
582 if (tickFromElecTick == expectedOptTick) {
584 <<
"DetectorTimings::toTick<optical_tick, " 586 <<
">(" << elecTick <<
") => " << tickFromElecTick;
593 <<
" is expected to be optical tick " << expectedOptTick
594 <<
", but got " << tickFromElecTick <<
" instead";
601 double const inputInterval_us = 200.008;
608 double const expectedTicksD = inputInterval_us / timings.clockData().OpticalClock().TickPeriod();
615 <<
"DetectorTimings::toTicks<optical_time_ticks_d>(" << inputInterval <<
") => " <<
ticks_d;
620 <<
"Time interval " << inputInterval <<
" is expected to last " << expectedTicksD
621 <<
" optical ticks, but got " <<
ticks_d <<
" instead";
625 int const expectedTicks =
static_cast<int>(expectedTicksD);
632 <<
"DetectorTimings::toTicks<optical_time_ticks>(" << inputInterval <<
") => " <<
ticks;
637 <<
"Time interval " << inputInterval <<
" is expected to last " << expectedTicks
638 <<
" optical integer ticks, but got " <<
ticks <<
" instead";
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
timescale_traits< ElectronicsTimeCategory >::tick_t electronics_tick
A point on the electronics time scale expressed in its ticks.
tick_d ticks_d
Alias for common language habits.
A collection of traits for a time scale.
constexpr value_t value() const
Returns the value of the quantity.
tick ticks
Alias for common language habits.
timescale_traits< OpticalTimeCategory >::tick_interval_d_t optical_time_ticks_d
timescale_traits< OpticalTimeCategory >::tick_interval_t optical_time_ticks
timescale_traits< TriggerTimeCategory >::time_point_t trigger_time
A point in time on the trigger time scale.
MaybeLogger_< ELseverityLevel::ELsev_error, true > LogProblem
A value measured in the specified unit.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
timescale_traits< OpticalTimeCategory >::time_point_t optical_time
A point in time on the optical detector electronics time scale.
An interval (duration, length, distance) between two quantity points.
Literal constants for time quantities.
timescale_traits< OpticalTimeCategory >::tick_t optical_tick
timescale_traits< OpticalTimeCategory >::tick_d_t optical_tick_d
Namespace including different time scales as defined in LArSoft.