mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-04-24 15:50:01 +02:00
clear pedestal
This commit is contained in:
parent
7550a2cb97
commit
7ce02006f2
@ -33,6 +33,12 @@ typedef enum {
|
|||||||
pTopRight = 8
|
pTopRight = 8
|
||||||
} pixel;
|
} pixel;
|
||||||
|
|
||||||
|
struct Eta2 {
|
||||||
|
double x;
|
||||||
|
double y;
|
||||||
|
corner c;
|
||||||
|
};
|
||||||
|
|
||||||
struct ClusterAnalysis {
|
struct ClusterAnalysis {
|
||||||
uint32_t c;
|
uint32_t c;
|
||||||
int32_t tot;
|
int32_t tot;
|
||||||
@ -74,7 +80,8 @@ int analyze_data(int32_t *data, int32_t *t2, int32_t *t3, char *quad,
|
|||||||
int analyze_cluster(Cluster3x3& cl, int32_t *t2, int32_t *t3, char *quad,
|
int analyze_cluster(Cluster3x3& cl, int32_t *t2, int32_t *t3, char *quad,
|
||||||
double *eta2x, double *eta2y, double *eta3x, double *eta3y);
|
double *eta2x, double *eta2y, double *eta3x, double *eta3y);
|
||||||
|
|
||||||
|
|
||||||
NDArray<double, 2> calculate_eta2( ClusterVector<int>& clusters);
|
NDArray<double, 2> calculate_eta2( ClusterVector<int>& clusters);
|
||||||
std::array<double,2> calculate_eta2( Cluster3x3& cl);
|
Eta2 calculate_eta2( Cluster3x3& cl);
|
||||||
|
|
||||||
} // namespace aare
|
} // namespace aare
|
||||||
|
@ -47,6 +47,7 @@ class ClusterFinder {
|
|||||||
|
|
||||||
NDArray<PEDESTAL_TYPE, 2> pedestal() { return m_pedestal.mean(); }
|
NDArray<PEDESTAL_TYPE, 2> pedestal() { return m_pedestal.mean(); }
|
||||||
NDArray<PEDESTAL_TYPE, 2> noise() { return m_pedestal.std(); }
|
NDArray<PEDESTAL_TYPE, 2> noise() { return m_pedestal.std(); }
|
||||||
|
void clear_pedestal() { m_pedestal.clear(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Move the clusters from the ClusterVector in the ClusterFinder to a
|
* @brief Move the clusters from the ClusterVector in the ClusterFinder to a
|
||||||
|
@ -215,6 +215,15 @@ class ClusterFinderMT {
|
|||||||
m_current_thread++;
|
m_current_thread++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clear_pedestal() {
|
||||||
|
if (!m_processing_threads_stopped) {
|
||||||
|
throw std::runtime_error("ClusterFinderMT is still running");
|
||||||
|
}
|
||||||
|
for (auto &cf : m_cluster_finders) {
|
||||||
|
cf->clear_pedestal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Return the pedestal currently used by the cluster finder
|
* @brief Return the pedestal currently used by the cluster finder
|
||||||
* @param thread_index index of the thread
|
* @param thread_index index of the thread
|
||||||
|
@ -89,6 +89,7 @@ template <typename SUM_TYPE = double> class Pedestal {
|
|||||||
m_sum = 0;
|
m_sum = 0;
|
||||||
m_sum2 = 0;
|
m_sum2 = 0;
|
||||||
m_cur_samples = 0;
|
m_cur_samples = 0;
|
||||||
|
m_mean = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,6 +98,7 @@ template <typename SUM_TYPE = double> class Pedestal {
|
|||||||
m_sum(row, col) = 0;
|
m_sum(row, col) = 0;
|
||||||
m_sum2(row, col) = 0;
|
m_sum2(row, col) = 0;
|
||||||
m_cur_samples(row, col) = 0;
|
m_cur_samples(row, col) = 0;
|
||||||
|
m_mean(row, col) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -119,7 +121,7 @@ template <typename SUM_TYPE = double> class Pedestal {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Push but don't update the cached mean. Speeds up the process
|
* Push but don't update the cached mean. Speeds up the process
|
||||||
* when intitializing the pedestal.
|
* when initializing the pedestal.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
template <typename T> void push_no_update(NDView<T, 2> frame) {
|
template <typename T> void push_no_update(NDView<T, 2> frame) {
|
||||||
|
@ -72,6 +72,7 @@ void define_cluster_finder_mt_bindings(py::module &m) {
|
|||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
py::arg(), py::arg("frame_number") = 0)
|
py::arg(), py::arg("frame_number") = 0)
|
||||||
|
.def("clear_pedestal", &ClusterFinderMT<uint16_t, pd_type>::clear_pedestal)
|
||||||
.def("sync", &ClusterFinderMT<uint16_t, pd_type>::sync)
|
.def("sync", &ClusterFinderMT<uint16_t, pd_type>::sync)
|
||||||
.def("stop", &ClusterFinderMT<uint16_t, pd_type>::stop)
|
.def("stop", &ClusterFinderMT<uint16_t, pd_type>::stop)
|
||||||
.def("start", &ClusterFinderMT<uint16_t, pd_type>::start)
|
.def("start", &ClusterFinderMT<uint16_t, pd_type>::start)
|
||||||
@ -121,6 +122,7 @@ void define_cluster_finder_bindings(py::module &m) {
|
|||||||
auto view = make_view_2d(frame);
|
auto view = make_view_2d(frame);
|
||||||
self.push_pedestal_frame(view);
|
self.push_pedestal_frame(view);
|
||||||
})
|
})
|
||||||
|
.def("clear_pedestal", &ClusterFinder<uint16_t, pd_type>::clear_pedestal)
|
||||||
.def_property_readonly("pedestal",
|
.def_property_readonly("pedestal",
|
||||||
[](ClusterFinder<uint16_t, pd_type> &self) {
|
[](ClusterFinder<uint16_t, pd_type> &self) {
|
||||||
auto pd = new NDArray<pd_type, 2>{};
|
auto pd = new NDArray<pd_type, 2>{};
|
||||||
|
@ -262,19 +262,19 @@ std::vector<Cluster3x3> ClusterFile::read_cluster_with_cut(size_t n_clusters,
|
|||||||
NDArray<double, 2> calculate_eta2(ClusterVector<int> &clusters) {
|
NDArray<double, 2> calculate_eta2(ClusterVector<int> &clusters) {
|
||||||
NDArray<double, 2> eta2({static_cast<int64_t>(clusters.size()), 2});
|
NDArray<double, 2> eta2({static_cast<int64_t>(clusters.size()), 2});
|
||||||
for (size_t i = 0; i < clusters.size(); i++) {
|
for (size_t i = 0; i < clusters.size(); i++) {
|
||||||
// int32_t t2;
|
auto e = calculate_eta2(clusters.at<Cluster3x3>(i));
|
||||||
// auto* ptr = reinterpret_cast<int32_t*> (clusters.element_ptr(i) + 2 *
|
eta2(i, 0) = e.x;
|
||||||
// sizeof(int16_t)); analyze_cluster(clusters.at<Cluster3x3>(i), &t2,
|
eta2(i, 1) = e.y;
|
||||||
// nullptr, nullptr, &eta2(i,0), &eta2(i,1) , nullptr, nullptr);
|
|
||||||
auto [x, y] = calculate_eta2(clusters.at<Cluster3x3>(i));
|
|
||||||
eta2(i, 0) = x;
|
|
||||||
eta2(i, 1) = y;
|
|
||||||
}
|
}
|
||||||
return eta2;
|
return eta2;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<double, 2> calculate_eta2(Cluster3x3 &cl) {
|
/**
|
||||||
std::array<double, 2> eta2{};
|
* @brief Calculate the eta2 values for a 3x3 cluster and return them in a Eta2 struct
|
||||||
|
* containing etay, etax and the corner of the cluster.
|
||||||
|
*/
|
||||||
|
Eta2 calculate_eta2(Cluster3x3 &cl) {
|
||||||
|
Eta2 eta{};
|
||||||
|
|
||||||
std::array<int32_t, 4> tot2;
|
std::array<int32_t, 4> tot2;
|
||||||
tot2[0] = cl.data[0] + cl.data[1] + cl.data[3] + cl.data[4];
|
tot2[0] = cl.data[0] + cl.data[1] + cl.data[3] + cl.data[4];
|
||||||
@ -287,39 +287,43 @@ std::array<double, 2> calculate_eta2(Cluster3x3 &cl) {
|
|||||||
switch (c) {
|
switch (c) {
|
||||||
case cBottomLeft:
|
case cBottomLeft:
|
||||||
if ((cl.data[3] + cl.data[4]) != 0)
|
if ((cl.data[3] + cl.data[4]) != 0)
|
||||||
eta2[0] =
|
eta.x =
|
||||||
static_cast<double>(cl.data[4]) / (cl.data[3] + cl.data[4]);
|
static_cast<double>(cl.data[4]) / (cl.data[3] + cl.data[4]);
|
||||||
if ((cl.data[1] + cl.data[4]) != 0)
|
if ((cl.data[1] + cl.data[4]) != 0)
|
||||||
eta2[1] =
|
eta.y =
|
||||||
static_cast<double>(cl.data[4]) / (cl.data[1] + cl.data[4]);
|
static_cast<double>(cl.data[4]) / (cl.data[1] + cl.data[4]);
|
||||||
|
eta.c = cBottomLeft;
|
||||||
break;
|
break;
|
||||||
case cBottomRight:
|
case cBottomRight:
|
||||||
if ((cl.data[2] + cl.data[5]) != 0)
|
if ((cl.data[2] + cl.data[5]) != 0)
|
||||||
eta2[0] =
|
eta.x =
|
||||||
static_cast<double>(cl.data[5]) / (cl.data[4] + cl.data[5]);
|
static_cast<double>(cl.data[5]) / (cl.data[4] + cl.data[5]);
|
||||||
if ((cl.data[1] + cl.data[4]) != 0)
|
if ((cl.data[1] + cl.data[4]) != 0)
|
||||||
eta2[1] =
|
eta.y =
|
||||||
static_cast<double>(cl.data[4]) / (cl.data[1] + cl.data[4]);
|
static_cast<double>(cl.data[4]) / (cl.data[1] + cl.data[4]);
|
||||||
|
eta.c = cBottomRight;
|
||||||
break;
|
break;
|
||||||
case cTopLeft:
|
case cTopLeft:
|
||||||
if ((cl.data[7] + cl.data[4]) != 0)
|
if ((cl.data[7] + cl.data[4]) != 0)
|
||||||
eta2[0] =
|
eta.x =
|
||||||
static_cast<double>(cl.data[4]) / (cl.data[3] + cl.data[4]);
|
static_cast<double>(cl.data[4]) / (cl.data[3] + cl.data[4]);
|
||||||
if ((cl.data[7] + cl.data[4]) != 0)
|
if ((cl.data[7] + cl.data[4]) != 0)
|
||||||
eta2[1] =
|
eta.y =
|
||||||
static_cast<double>(cl.data[7]) / (cl.data[7] + cl.data[4]);
|
static_cast<double>(cl.data[7]) / (cl.data[7] + cl.data[4]);
|
||||||
|
eta.c = cTopLeft;
|
||||||
break;
|
break;
|
||||||
case cTopRight:
|
case cTopRight:
|
||||||
if ((cl.data[5] + cl.data[4]) != 0)
|
if ((cl.data[5] + cl.data[4]) != 0)
|
||||||
eta2[0] =
|
eta.x =
|
||||||
static_cast<double>(cl.data[5]) / (cl.data[5] + cl.data[4]);
|
static_cast<double>(cl.data[5]) / (cl.data[5] + cl.data[4]);
|
||||||
if ((cl.data[7] + cl.data[4]) != 0)
|
if ((cl.data[7] + cl.data[4]) != 0)
|
||||||
eta2[1] =
|
eta.y =
|
||||||
static_cast<double>(cl.data[7]) / (cl.data[7] + cl.data[4]);
|
static_cast<double>(cl.data[7]) / (cl.data[7] + cl.data[4]);
|
||||||
|
eta.c = cTopRight;
|
||||||
break;
|
break;
|
||||||
// default:;
|
// no default to allow compiler to warn about missing cases
|
||||||
}
|
}
|
||||||
return eta2;
|
return eta;
|
||||||
}
|
}
|
||||||
|
|
||||||
int analyze_cluster(Cluster3x3 &cl, int32_t *t2, int32_t *t3, char *quad,
|
int analyze_cluster(Cluster3x3 &cl, int32_t *t2, int32_t *t3, char *quad,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user