Skip to content

Commit

Permalink
Add mapping of macro time to micro time
Browse files Browse the repository at this point in the history
TO handle ALEX experiments map
macro time modulo period to micro times.
  • Loading branch information
tpeulen committed Dec 17, 2024
1 parent b88690e commit a0e5e55
Showing 2 changed files with 23 additions and 0 deletions.
16 changes: 16 additions & 0 deletions include/TTTR.h
Original file line number Diff line number Diff line change
@@ -501,6 +501,22 @@ class TTTR : public std::enable_shared_from_this<TTTR>{
long long macro_time_offset = 0
);

/**
* @brief Assigns a microtime based on the alternating-laser excitation (ALEX) period.
*
* This method computes a microtime for each macrotime value by taking the modulo
* operation of the macrotime with respect to the specified ALEX period. Optionally,
* a period shift can be applied to adjust the macrotime before the computation.
*
* microtime = (macrotime - period_shift) modulo alex_period
*
* @param alex_period The ALEX period in units of macrotime.
* @param period_shift An optional shift applied to the macrotime before computing
* the microtime. Default is 0.
*
*/
void alex_to_microtime(unsigned long alex_period, int period_shift=0);

/*!
* \brief Appends a single event to the TTTR object.
*
7 changes: 7 additions & 0 deletions src/TTTR.cpp
Original file line number Diff line number Diff line change
@@ -375,6 +375,13 @@ int TTTR::read_sm_file(const char *filename){

}

void TTTR::alex_to_microtime(unsigned long alex_period, int period_shift) {
for (size_t i = 0; i < n_valid_events; ++i) {
int64_t m = macro_times[i] - period_shift;
micro_times[i] = static_cast<unsigned short>(m % alex_period);
}
}

int TTTR::read_file(const char *fn, int container_type) {
#ifdef VERBOSE_TTTRLIB
std::clog << "READING TTTR FILE" << std::endl;

0 comments on commit a0e5e55

Please sign in to comment.