tttrlib
A library for time-tagged time resolved data
Loading...
Searching...
No Matches
CorrelatorPhotonStream.h
Go to the documentation of this file.
1#ifndef TTTRLIB_CORRELATORPHOTONSTREAM_H
2#define TTTRLIB_CORRELATORPHOTONSTREAM_H
3
4#include <vector>
5#include <numeric> /* std::accumulate */
6
7#include "TTTR.h"
8
9
10
15
16 friend class Correlator;
17
18protected:
19
24
25 std::shared_ptr<TTTR> tttr = nullptr;
26
27public:
28
33
41
46
50 std::vector<unsigned long long> times;
51
55 std::vector<double> weights;
56
62 bool empty() const{
63 return times.empty() && weights.empty();
64 }
65
71 size_t size() const{
72 return times.size();
73 }
74
80 void clear(){
81 times.clear();
82 weights.clear();
83 }
84
94 void resize(size_t n, double x = 1.0){
95 times.resize(n);
96 weights.resize(n, x);
97 }
98
112 static void make_fine_times(
113 unsigned long long *t, unsigned int n_times,
114 unsigned short *tac,
115 unsigned int n_tac
116 );
117
131 unsigned short *tac, int n_tac,
132 unsigned int number_of_microtime_channels
133 );
134
147 const std::map<short, std::vector<double>>& filter,
148 std::vector<unsigned int> micro_times = std::vector<unsigned int>(),
149 std::vector<signed char> routing_channels = std::vector<signed char>()
150 );
151
163 unsigned long long *t, int n_t,
164 double* weight, int n_weight
165 ){
166 resize(std::min(n_t, n_weight));
167 for(size_t i = 0; i < size();i++){
168 times[i] = t[i];
169 weights[i] = weight[i];
170 }
171 }
172
180 void coarsen();
181
187 unsigned long long dt();
188
195
202
211
222 }
223
233 void set_tttr(std::shared_ptr<TTTR> tttr, bool make_fine = false);
234
240 std::shared_ptr<TTTR> get_tttr() const {
241 return tttr;
242 }
243
244};
245
246#endif //TTTRLIB_CORRELATORPHOTONSTREAM_H
Definition Correlator.h:21
CorrelatorPhotonStream class gathers event times and weights.
Definition CorrelatorPhotonStream.h:14
double sum_of_weights()
Compute the sum of weights in the correlation stream.
void set_events(unsigned long long *t, int n_t, double *weight, int n_weight)
Set time events and weights.
Definition CorrelatorPhotonStream.h:162
void set_time_axis_calibration(double v)
Set the time axis calibration.
bool empty() const
Check if the CorrelatorPhotonStream is empty.
Definition CorrelatorPhotonStream.h:62
std::shared_ptr< TTTR > tttr
Definition CorrelatorPhotonStream.h:25
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
std::shared_ptr< TTTR > get_tttr() const
Get the TTTR object associated with the CorrelatorPhotonStream.
Definition CorrelatorPhotonStream.h:240
size_t size() const
Get the size of the CorrelatorPhotonStream.
Definition CorrelatorPhotonStream.h:71
CorrelatorPhotonStream(const CorrelatorPhotonStream &a)
Copy constructor for CorrelatorPhotonStream.
Definition CorrelatorPhotonStream.h:39
void set_weights(const std::map< short, std::vector< double > > &filter, std::vector< unsigned int > micro_times=std::vector< unsigned int >(), std::vector< signed char > routing_channels=std::vector< signed char >())
Set weights using a filter for time events.
void clear()
Clear the CorrelatorPhotonStream.
Definition CorrelatorPhotonStream.h:80
double mean_count_rate()
Compute the mean count rate in the correlation stream.
void resize(size_t n, double x=1.0)
Resize the CorrelatorPhotonStream.
Definition CorrelatorPhotonStream.h:94
double get_time_axis_calibration() const
Get the calibration of the time axis.
Definition CorrelatorPhotonStream.h:220
void make_fine(unsigned short *tac, int n_tac, unsigned int number_of_microtime_channels)
Make time events fine by adding micro time to macro time.
void set_tttr(std::shared_ptr< TTTR > tttr, bool make_fine=false)
Set the TTTR object for the CorrelatorPhotonStream.
CorrelatorPhotonStream()=default
Default constructor for CorrelatorPhotonStream.
void coarsen()
Coarsen the time events.
static void make_fine_times(unsigned long long *t, unsigned int n_times, unsigned short *tac, unsigned int n_tac)
Make time events fine by adding micro time to macro time.
double time_axis_calibration
Definition CorrelatorPhotonStream.h:23
~CorrelatorPhotonStream()=default
Default destructor for CorrelatorPhotonStream.
unsigned long long dt()
Compute the time difference in macro time units between the first and last event.