mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-02-18 19:58:41 +01:00
added structs with chip defeinitions
This commit is contained in:
@@ -188,6 +188,37 @@ struct ROI {
|
||||
}
|
||||
};
|
||||
|
||||
/// @brief Chip specifications for Matterhorn1
|
||||
struct Matterhorn10 {
|
||||
constexpr static size_t nRows = 256;
|
||||
constexpr static size_t nCols = 256;
|
||||
};
|
||||
|
||||
/// @brief Chip specifications for Matterhorn2
|
||||
struct Matterhorn02 {
|
||||
constexpr static size_t nRows = 48;
|
||||
constexpr static size_t nCols = 48;
|
||||
constexpr static size_t nHalfCols = 24;
|
||||
};
|
||||
|
||||
/// @brief Chip specifications for Moench04
|
||||
struct Moench04 {
|
||||
constexpr static size_t nRows = 400;
|
||||
constexpr static size_t nCols = 400;
|
||||
constexpr static std::array<int, 32>
|
||||
adcNumbers =
|
||||
{
|
||||
9, 8, 11, 10, 13, 12, 15, 14, 1, 0, 3,
|
||||
2, 5, 4, 7, 6, 23, 22, 21, 20, 19, 18,
|
||||
17, 16, 31, 30, 29, 28, 27, 26, 25, 24}; // TODO : should we
|
||||
// only have chip
|
||||
// specifications or
|
||||
// also wiring in
|
||||
// chiptestboard?
|
||||
constexpr static size_t nPixelsPerSuperColumn = 5000;
|
||||
constexpr static size_t superColumnWidth = 25;
|
||||
};
|
||||
|
||||
enum ReadoutMode : uint8_t {
|
||||
ANALOG_ONLY = 0,
|
||||
DIGITAL_ONLY = 1,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import numpy as np
|
||||
from . import _aare
|
||||
from aare import ReadoutMode
|
||||
from aare._aare import Matterhorn10
|
||||
|
||||
class AdcSar04Transform64to16:
|
||||
def __call__(self, data):
|
||||
@@ -92,12 +93,8 @@ class Matterhorn10Transform:
|
||||
:type data: np.ndarray
|
||||
:raises ValueError: if not compatible
|
||||
"""
|
||||
expected_size = (Matterhorn10.nRows*Matterhorn10.nCols*self.num_counters*self.dynamic_range)//8 # read_frame returns data in uint8_t
|
||||
|
||||
# TODO maybe better to have definition in matterhorn10 struct
|
||||
rows = 256
|
||||
cols = 256
|
||||
expected_size = (rows*cols*self.num_counters*self.dynamic_range)//8 # read_frame returns data in uint8_t
|
||||
|
||||
if(data.size != expected_size):
|
||||
raise ValueError(f"Data size {data.size} does not match expected size {expected_size} for Matterhorn10 with dynamic range {self.dynamic_range} and num_counters {self.num_counters}.")
|
||||
|
||||
|
||||
25
python/src/bind_Defs.hpp
Normal file
25
python/src/bind_Defs.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "aare/defs.hpp"
|
||||
|
||||
namespace py = pybind11;
|
||||
using namespace aare;
|
||||
|
||||
void define_defs_bindings(py::module &m) {
|
||||
auto matterhorn10 = py::class_<Matterhorn10>(m, "Matterhorn10");
|
||||
matterhorn10.attr("nRows") = Matterhorn10::nRows;
|
||||
matterhorn10.attr("nCols") = Matterhorn10::nCols;
|
||||
|
||||
auto matterhorn02 = py::class_<Matterhorn02>(m, "Matterhorn02");
|
||||
matterhorn02.attr("nRows") = Matterhorn02::nRows;
|
||||
matterhorn02.attr("nCols") = Matterhorn02::nCols;
|
||||
matterhorn02.attr("nHalfCols") = Matterhorn02::nHalfCols;
|
||||
|
||||
auto moench04 = py::class_<Moench04>(m, "Moench04");
|
||||
moench04.attr("nRows") = Moench04::nRows;
|
||||
moench04.attr("nCols") = Moench04::nCols;
|
||||
moench04.attr("nPixelsPerSuperColumn") = Moench04::nPixelsPerSuperColumn;
|
||||
moench04.attr("superColumnWidth") = Moench04::superColumnWidth;
|
||||
moench04.attr("adcNumbers") = Moench04::adcNumbers;
|
||||
}
|
||||
@@ -9,12 +9,13 @@
|
||||
#include "bind_ClusterFinder.hpp"
|
||||
#include "bind_ClusterFinderMT.hpp"
|
||||
#include "bind_ClusterVector.hpp"
|
||||
#include "bind_Defs.hpp"
|
||||
#include "bind_Eta.hpp"
|
||||
#include "bind_Interpolator.hpp"
|
||||
#include "bind_PixelMap.hpp"
|
||||
#include "bind_calibration.hpp"
|
||||
|
||||
// TODO! migrate the other names
|
||||
#include "bind_PixelMap.hpp"
|
||||
#include "ctb_raw_file.hpp"
|
||||
#include "file.hpp"
|
||||
#include "fit.hpp"
|
||||
@@ -140,6 +141,8 @@ PYBIND11_MODULE(_aare, m) {
|
||||
register_calculate_3x3eta<float, 3, 3, uint16_t>(m);
|
||||
register_calculate_3x3eta<int16_t, 3, 3, uint16_t>(m);
|
||||
|
||||
define_defs_bindings(m);
|
||||
|
||||
using Sum_index_pair_d = Sum_index_pair<double, corner>;
|
||||
PYBIND11_NUMPY_DTYPE(Sum_index_pair_d, sum, index);
|
||||
using Sum_index_pair_f = Sum_index_pair<float, corner>;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
#include "aare/PixelMap.hpp"
|
||||
#include "aare/defs.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
@@ -32,23 +33,20 @@ NDArray<ssize_t, 2> GenerateMoench03PixelMap() {
|
||||
}
|
||||
|
||||
NDArray<ssize_t, 2> GenerateMoench04AnalogPixelMap() {
|
||||
std::array<int, 32> const adc_nr = {
|
||||
9, 8, 11, 10, 13, 12, 15, 14, 1, 0, 3, 2, 5, 4, 7, 6,
|
||||
23, 22, 21, 20, 19, 18, 17, 16, 31, 30, 29, 28, 27, 26, 25, 24};
|
||||
int const sc_width = 25;
|
||||
int const nadc = 32;
|
||||
int const pixels_per_sc = 5000;
|
||||
NDArray<ssize_t, 2> order_map({400, 400});
|
||||
std::array<int, 32> const adc_nr = Moench04::adcNumbers;
|
||||
int const nadc = adc_nr.size();
|
||||
NDArray<ssize_t, 2> order_map({Moench04::nRows, Moench04::nCols});
|
||||
|
||||
int pixel = 0;
|
||||
for (int i = 0; i != pixels_per_sc; ++i) {
|
||||
for (int i_adc = 0; i_adc != nadc; ++i_adc) {
|
||||
int const col = (adc_nr[i_adc] % 16) * 25 + (i % sc_width);
|
||||
for (size_t i = 0; i != Moench04::nPixelsPerSuperColumn; ++i) {
|
||||
for (size_t i_adc = 0; i_adc != nadc; ++i_adc) {
|
||||
int const col =
|
||||
(adc_nr[i_adc] % 16) * 25 + (i % Moench04::superColumnWidth);
|
||||
int row = 0;
|
||||
if (i_adc < 16)
|
||||
row = 199 - (i / sc_width);
|
||||
row = 199 - (i / Moench04::superColumnWidth);
|
||||
else
|
||||
row = 200 + (i / sc_width);
|
||||
row = 200 + (i / Moench04::superColumnWidth);
|
||||
|
||||
order_map(row, col) = pixel;
|
||||
pixel++;
|
||||
@@ -134,13 +132,14 @@ NDArray<ssize_t, 2> GenerateEigerFlipRowsPixelMap() {
|
||||
NDArray<ssize_t, 2> GenerateMH02SingleCounterPixelMap() {
|
||||
// This is the pixel map for a single counter Matterhorn02, i.e. 48x48
|
||||
// pixels. Data is read from two transceivers in blocks of 4 pixels.
|
||||
NDArray<ssize_t, 2> order_map({48, 48});
|
||||
NDArray<ssize_t, 2> order_map({Matterhorn02::nRows, Matterhorn02::nCols});
|
||||
size_t offset = 0;
|
||||
size_t nSamples = 4;
|
||||
for (int row = 0; row < 48; row++) {
|
||||
for (int col = 0; col < 24; col++) {
|
||||
for (int iTrans = 0; iTrans < 2; iTrans++) {
|
||||
order_map(row, iTrans * 24 + col) = offset + nSamples * iTrans;
|
||||
for (size_t row = 0; row < Matterhorn02::nRows; row++) {
|
||||
for (size_t col = 0; col < Matterhorn02::nHalfCols; col++) {
|
||||
for (size_t iTrans = 0; iTrans < 2; iTrans++) {
|
||||
order_map(row, iTrans * Matterhorn02::nHalfCols + col) =
|
||||
offset + nSamples * iTrans;
|
||||
}
|
||||
offset += 1;
|
||||
if ((col + 1) % nSamples == 0) {
|
||||
@@ -153,12 +152,14 @@ NDArray<ssize_t, 2> GenerateMH02SingleCounterPixelMap() {
|
||||
|
||||
NDArray<ssize_t, 3> GenerateMH02FourCounterPixelMap() {
|
||||
auto single_counter_map = GenerateMH02SingleCounterPixelMap();
|
||||
NDArray<ssize_t, 3> order_map({4, 48, 48});
|
||||
for (int counter = 0; counter < 4; counter++) {
|
||||
for (int row = 0; row < 48; row++) {
|
||||
for (int col = 0; col < 48; col++) {
|
||||
NDArray<ssize_t, 3> order_map(
|
||||
{4, Matterhorn02::nRows, Matterhorn02::nCols});
|
||||
for (size_t counter = 0; counter < 4; counter++) {
|
||||
for (size_t row = 0; row < Matterhorn02::nRows; row++) {
|
||||
for (size_t col = 0; col < Matterhorn02::nCols; col++) {
|
||||
order_map(counter, row, col) =
|
||||
single_counter_map(row, col) + counter * 48 * 48;
|
||||
single_counter_map(row, col) +
|
||||
counter * Matterhorn02::nRows * Matterhorn02::nCols;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,8 +168,8 @@ NDArray<ssize_t, 3> GenerateMH02FourCounterPixelMap() {
|
||||
|
||||
NDArray<ssize_t, 2> GenerateMatterhorn10PixelMap(const size_t dynamic_range,
|
||||
const size_t n_counters) {
|
||||
constexpr size_t n_cols = 256;
|
||||
constexpr size_t n_rows = 256;
|
||||
constexpr size_t n_cols = Matterhorn10::nCols;
|
||||
constexpr size_t n_rows = Matterhorn10::nRows;
|
||||
NDArray<ssize_t, 2> pixel_map(
|
||||
{static_cast<ssize_t>(n_rows * n_counters), n_cols});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user