1#ifndef TTTRLIB_CORRELATOR_H
2#define TTTRLIB_CORRELATOR_H
28 std::string correlation_method =
"wahl";
32 bool is_valid =
false;
51 const unsigned long long *t1,
52 const unsigned long long *t2,
53 const double *weights1,
54 const double *weights2,
59 const unsigned long long *xdat,
double *corrl
76 std::vector<unsigned long long> &x_axis,
77 std::vector<double> &corr,
78 std::vector<unsigned long long> &x_axis_normalized,
79 std::vector<double> &corr_normalized,
80 double cr1,
double cr2,
83 unsigned long long maximum_macro_time
107 size_t n_casc,
size_t n_bins,
108 std::vector<unsigned long long> &taus,
109 std::vector<double> &corr,
137 double np1, uint64_t dt1,
138 double np2, uint64_t dt2,
139 std::vector<unsigned long long> &x_axis,
140 std::vector<double> &corr,
157 std::vector<unsigned long long> &taus,
158 std::vector<double> &corr,
176 std::vector<unsigned long long> &x_axis,
177 std::vector<double> &corr,
178 std::vector<double> &corr_normalized
222 std::shared_ptr<TTTR> tttr =
nullptr,
223 std::string method =
"wahl",
226 bool make_fine =
false
254 if (!is_valid)
run();
312 correlation_method = cm;
324 return correlation_method;
339 unsigned short *tac_1,
int n_tac_1,
340 unsigned short *tac_2,
int n_tac_2,
341 unsigned int number_of_microtime_channels
355 unsigned long long *t1,
int n_t1,
356 unsigned long long *t2,
int n_t2
366 std::pair<std::vector<unsigned long long>, std::vector<unsigned long long>>
get_macrotimes() {
386 unsigned long long *t1,
int n_t1,
387 double *weight_ch1,
int n_weights_ch1,
388 unsigned long long *t2,
int n_t2,
389 double *weight_ch2,
int n_weights_ch2
404 double *weight_ch1,
int n_weights_ch1,
405 double *weight_ch2,
int n_weights_ch2
415 std::pair<std::vector<double>, std::vector<double>>
get_weights(){
470 std::shared_ptr<TTTR> tttr_1,
471 std::shared_ptr<TTTR> tttr_2 =
nullptr ,
472 bool make_fine =
false
475 std::pair<std::shared_ptr<TTTR>, std::shared_ptr<TTTR>>
get_tttr();
491 const std::map<
short, std::vector<double>> &filter,
492 const std::vector<unsigned int> µ_times_1,
493 const std::vector<signed char> &routing_channels_1,
494 const std::vector<unsigned int> µ_times_2,
495 const std::vector<signed char> &routing_channels_2
Definition CLSMImage.h:161
Definition CorrelatorCurve.h:33
unsigned int get_n_casc() const
Get the number of cascades (blocks) in the correlation curve.
Definition CorrelatorCurve.h:178
CorrelationCurveSettings settings
Stores the settings of the correlation curve, i.e., the number of correlation bins.
Definition CorrelatorCurve.h:93
void set_n_casc(int v)
Set the number of cascades (blocks) in the correlation curve and update the correlation axis.
Definition CorrelatorCurve.h:166
void set_n_bins(int v)
Set the number of equally spaced correlation channels per block.
Definition CorrelatorCurve.h:142
Definition Correlator.h:21
std::pair< std::vector< unsigned long long >, std::vector< unsigned long long > > get_macrotimes()
Get event times of the first and second correlation channel.
Definition Correlator.h:366
static void normalize_ccf_wahl(double np1, uint64_t dt1, double np2, uint64_t dt2, std::vector< unsigned long long > &x_axis, std::vector< double > &corr, size_t n_bins)
Normalize computed correlation.
static void normalize_ccf_laurence(CorrelatorPhotonStream &p1, CorrelatorPhotonStream &p2, std::vector< unsigned long long > &x_axis, std::vector< double > &corr, std::vector< double > &corr_normalized)
Normalize the correlation.
CorrelatorPhotonStream p1
Definition Correlator.h:195
uint64_t dt()
Compute the time difference in macro time units between the first and the last event.
std::pair< std::vector< double >, std::vector< double > > get_weights()
Get weights used for correlation.
Definition Correlator.h:415
std::string get_correlation_method()
Get the name of the used correlation method.
Definition Correlator.h:323
static void ccf_laurence(std::vector< unsigned long long > &taus, std::vector< double > &corr, CorrelatorPhotonStream &p1, CorrelatorPhotonStream &p2)
Compute correlation on arbitray correlation axis.
void set_events(unsigned long long *t1, int n_t1, double *weight_ch1, int n_weights_ch1, unsigned long long *t2, int n_t2, double *weight_ch2, int n_weights_ch2)
Set time events and weights for the first and second correlation channels.
Correlator(std::shared_ptr< TTTR > tttr=nullptr, std::string method="wahl", int n_bins=17, int n_casc=25, bool make_fine=false)
Correlator Constructor.
void set_n_bins(int v)
Set the number of equally spaced correlation channels per block.
Definition Correlator.h:278
void run()
compute the correlation
void set_microtimes(unsigned short *tac_1, int n_tac_1, unsigned short *tac_2, int n_tac_2, unsigned int number_of_microtime_channels)
Add microtime information to the event stream.
void set_tttr(std::shared_ptr< TTTR > tttr_1, std::shared_ptr< TTTR > tttr_2=nullptr, bool make_fine=false)
Sets the time and the weights using TTTR objects.
void set_macrotimes(unsigned long long *t1, int n_t1, unsigned long long *t2, int n_t2)
Add macrotimes information to the event stream.
void set_weights(double *weight_ch1, int n_weights_ch1, double *weight_ch2, int n_weights_ch2)
Set weights used for correlation.
unsigned int get_n_bins() const
Get the number of equally spaced correlation channels per block.
Definition Correlator.h:290
static void normalize(Correlator *correlator, CorrelatorCurve &curve)
Normalize the correlation curve.
void set_n_casc(int n_casc)
Set the number of cascades (blocks) of the correlation curve.
Definition Correlator.h:240
void get_x_axis(double **output, int *n_output)
Get correlation bins (axis)
void get_corr(double **output, int *n_output)
Get the (unnormalized) correlation.
CorrelatorCurve curve
Definition Correlator.h:197
CorrelatorPhotonStream p2
Definition Correlator.h:196
static void normalize_ccf_felekyan(std::vector< unsigned long long > &x_axis, std::vector< double > &corr, std::vector< unsigned long long > &x_axis_normalized, std::vector< double > &corr_normalized, double cr1, double cr2, unsigned int n_bins, unsigned int n_casc, unsigned long long maximum_macro_time)
void get_corr_normalized(double **output, int *n_output)
Get the normalized correlation.
CorrelatorCurve * get_curve()
Get the correlation curve.
Definition Correlator.h:253
void set_correlation_method(std::string cm)
Set the correlation method.
Definition Correlator.h:310
static void ccf_wahl(size_t n_casc, size_t n_bins, std::vector< unsigned long long > &taus, std::vector< double > &corr, CorrelatorPhotonStream &p1, CorrelatorPhotonStream &p2)
Calculates the cross-correlation between two event streams.
unsigned int get_n_casc()
Get the number of correlation blocks.
Definition Correlator.h:266
std::pair< std::shared_ptr< TTTR >, std::shared_ptr< TTTR > > get_tttr()
static void ccf_felekyan(const unsigned long long *t1, const unsigned long long *t2, const double *weights1, const double *weights2, unsigned int nc, unsigned int nb, unsigned int np1, unsigned int np2, const unsigned long long *xdat, double *corrl)
void set_filter(const std::map< short, std::vector< double > > &filter, const std::vector< unsigned int > µ_times_1, const std::vector< signed char > &routing_channels_1, const std::vector< unsigned int > µ_times_2, const std::vector< signed char > &routing_channels_2)
Update weights based on a filter map and event information.
CorrelatorPhotonStream class gathers event times and weights.
Definition CorrelatorPhotonStream.h:14
std::vector< unsigned long long > times
The array containing the time points of the first correlation channel.
Definition CorrelatorPhotonStream.h:50
std::vector< double > weights
The array containing the weights of the first correlation channel.
Definition CorrelatorPhotonStream.h:55
unsigned int n_bins
The number of bins (correlation channels) per cascade.
Definition CorrelatorCurve.h:21