mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
d5a712ab42 | |||
fa931b8fca | |||
37bf3600ad | |||
96f6561080 | |||
9ca831d954 |
@ -19,7 +19,6 @@ Checks: '*,
|
||||
-google-readability-braces-around-statements,
|
||||
-modernize-use-trailing-return-type,
|
||||
-readability-isolate-declaration,
|
||||
-readability-implicit-bool-conversion,
|
||||
-llvmlibc-*'
|
||||
|
||||
HeaderFilterRegex: \.h
|
||||
|
215
CMakeLists.txt
215
CMakeLists.txt
@ -1,15 +1,18 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.9)
|
||||
project(slsDetectorPackage)
|
||||
set(PROJECT_VERSION 6.1.1)
|
||||
set(PROJECT_VERSION 6.0.0)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||
|
||||
cmake_policy(SET CMP0074 NEW)
|
||||
# cmake_policy(SET CMP0074 NEW)
|
||||
include(cmake/project_version.cmake)
|
||||
|
||||
#functions to add compiler flags
|
||||
include(cmake/SlsAddFlag.cmake)
|
||||
include(cmake/SlsFindZeroMQ.cmake)
|
||||
|
||||
# Include additional modules that are used unconditionally
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# If conda build, always set lib dir to 'lib'
|
||||
@ -23,7 +26,7 @@ string(TOLOWER "${PROJECT_NAME}" PROJECT_NAME_LOWER)
|
||||
|
||||
# Set targets export name (used by slsDetectorPackage and dependencies)
|
||||
set(TARGETS_EXPORT_NAME "${PROJECT_NAME_LOWER}-targets")
|
||||
set(namespace "sls::")
|
||||
#set(namespace "${PROJECT_NAME}::")
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||
|
||||
@ -34,8 +37,6 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
set(SLS_MASTER_PROJECT ON)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
option(SLS_USE_HDF5 "HDF5 File format" OFF)
|
||||
option(SLS_BUILD_SHARED_LIBRARIES "Build shared libaries" ON)
|
||||
option(SLS_USE_TEXTCLIENT "Text Client" ON)
|
||||
@ -55,32 +56,6 @@ option(SLS_TUNE_LOCAL "tune to local machine" OFF)
|
||||
option(SLS_DEVEL_HEADERS "install headers for devel" OFF)
|
||||
option(SLS_USE_MOENCH "compile zmq and post processing for Moench" OFF)
|
||||
|
||||
#Convenience option to switch off defaults when building Moench binaries only
|
||||
option(SLS_BUILD_ONLY_MOENCH "compile only Moench" OFF)
|
||||
if(SLS_BUILD_ONLY_MOENCH)
|
||||
message(STATUS "Build MOENCH binaries only!")
|
||||
set(SLS_BUILD_SHARED_LIBRARIES OFF CACHE BOOL "Disabled for MOENCH_ONLY" FORCE)
|
||||
set(SLS_USE_TEXTCLIENT OFF CACHE BOOL "Disabled for MOENCH_ONLY" FORCE)
|
||||
set(SLS_USE_DETECTOR OFF CACHE BOOL "Disabled for MOENCH_ONLY" FORCE)
|
||||
set(SLS_USE_RECEIVER OFF CACHE BOOL "Disabled for MOENCH_ONLY" FORCE)
|
||||
set(SLS_USE_RECEIVER_BINARIES OFF CACHE BOOL "Disabled for MOENCH_ONLY" FORCE)
|
||||
set(SLS_USE_MOENCH ON CACHE BOOL "Enable" FORCE)
|
||||
endif()
|
||||
|
||||
|
||||
option(SLS_EXT_BUILD "external build of part of the project" OFF)
|
||||
if(SLS_EXT_BUILD)
|
||||
message(STATUS "External build using already installed libraries")
|
||||
set(SLS_BUILD_SHARED_LIBRARIES OFF CACHE BOOL "Should already exist" FORCE)
|
||||
set(SLS_USE_TEXTCLIENT OFF CACHE BOOL "Should already exist" FORCE)
|
||||
set(SLS_USE_DETECTOR OFF CACHE BOOL "Should already exist" FORCE)
|
||||
set(SLS_USE_RECEIVER OFF CACHE BOOL "Should already exist" FORCE)
|
||||
set(SLS_USE_RECEIVER_BINARIES OFF CACHE BOOL "Should already exist" FORCE)
|
||||
set(SLS_MASTER_PROJECT OFF CACHE BOOL "No master proj in case of extbuild" FORCE)
|
||||
endif()
|
||||
|
||||
#Maybe have an option guarding this?
|
||||
set(SLS_INTERNAL_RAPIDJSON_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/rapidjson)
|
||||
|
||||
set(ClangFormat_EXCLUDE_PATTERNS "build/"
|
||||
"libs/"
|
||||
@ -92,6 +67,12 @@ set(ClangFormat_EXCLUDE_PATTERNS "build/"
|
||||
${CMAKE_BINARY_DIR})
|
||||
find_package(ClangFormat)
|
||||
|
||||
#Enable LTO if available
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(RESULT SLS_LTO_AVAILABLE)
|
||||
message(STATUS "SLS_LTO_AVAILABLE:" ${SLS_LTO_AVAILABLE})
|
||||
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
@ -100,78 +81,63 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
endif()
|
||||
|
||||
|
||||
#Enable LTO if available
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(RESULT SLS_LTO_AVAILABLE)
|
||||
if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE)
|
||||
message(STATUS "Building with link time optimization")
|
||||
else()
|
||||
message(STATUS "Building without link time optimization")
|
||||
endif()
|
||||
#Add two fake libraries to manage options
|
||||
add_library(slsProjectOptions INTERFACE)
|
||||
add_library(slsProjectWarnings INTERFACE)
|
||||
target_compile_features(slsProjectOptions INTERFACE cxx_std_11)
|
||||
target_compile_options(slsProjectWarnings INTERFACE
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wno-unused-parameter
|
||||
# -Wold-style-cast
|
||||
-Wnon-virtual-dtor
|
||||
-Woverloaded-virtual
|
||||
-Wdouble-promotion
|
||||
-Wformat=2
|
||||
-Wredundant-decls
|
||||
# -Wconversion
|
||||
-Wvla
|
||||
-Wdouble-promotion
|
||||
-Werror=return-type
|
||||
)
|
||||
|
||||
#Settings for C code
|
||||
add_library(slsProjectCSettings INTERFACE)
|
||||
target_compile_options(slsProjectCSettings INTERFACE
|
||||
-std=gnu99 #fixed
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wno-unused-parameter
|
||||
-Wdouble-promotion
|
||||
-Wformat=2
|
||||
-Wredundant-decls
|
||||
-Wdouble-promotion
|
||||
-Werror=return-type
|
||||
)
|
||||
|
||||
|
||||
if(SLS_EXT_BUILD)
|
||||
# Find ourself in case of external build
|
||||
find_package(slsDetectorPackage ${PROJECT_VERSION} REQUIRED)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
# slsProjectOptions and slsProjectWarnings are used
|
||||
# to control options for the libraries
|
||||
if(NOT TARGET slsProjectOptions)
|
||||
add_library(slsProjectOptions INTERFACE)
|
||||
target_compile_features(slsProjectOptions INTERFACE cxx_std_11)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET slsProjectWarnings)
|
||||
add_library(slsProjectWarnings INTERFACE)
|
||||
target_compile_options(slsProjectWarnings INTERFACE
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wno-unused-parameter
|
||||
# -Wold-style-cast
|
||||
-Wnon-virtual-dtor
|
||||
-Woverloaded-virtual
|
||||
-Wdouble-promotion
|
||||
-Wformat=2
|
||||
-Wredundant-decls
|
||||
# -Wconversion
|
||||
-Wvla
|
||||
-Wdouble-promotion
|
||||
-Werror=return-type
|
||||
)
|
||||
# Add or disable warnings depending on if the compiler supports them
|
||||
# The function checks internally and sets HAS_warning-name
|
||||
sls_enable_cxx_warning("-Wnull-dereference")
|
||||
sls_enable_cxx_warning("-Wduplicated-cond")
|
||||
sls_disable_cxx_warning("-Wclass-memaccess")
|
||||
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
target_compile_options(slsProjectWarnings INTERFACE
|
||||
-Wno-missing-field-initializers)
|
||||
#Testing for minimum version for compilers
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.2)
|
||||
message(FATAL_ERROR "Clang version must be at least 3.2!")
|
||||
endif()
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
|
||||
message(FATAL_ERROR "GCC version must be at least 4.8!")
|
||||
endif()
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5)
|
||||
target_compile_options(slsProjectWarnings INTERFACE
|
||||
-Wno-missing-field-initializers)
|
||||
endif()
|
||||
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
if (NOT TARGET slsProjectCSettings)
|
||||
#Settings for C code
|
||||
add_library(slsProjectCSettings INTERFACE)
|
||||
target_compile_options(slsProjectCSettings INTERFACE
|
||||
-std=gnu99 #fixed
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wno-unused-parameter
|
||||
-Wdouble-promotion
|
||||
-Wformat=2
|
||||
-Wredundant-decls
|
||||
-Wdouble-promotion
|
||||
-Werror=return-type
|
||||
)
|
||||
sls_disable_c_warning("-Wstringop-truncation")
|
||||
endif()
|
||||
# Add or disable warnings depending on if the compiler supports them
|
||||
# The function checks internally and sets HAS_warning-name
|
||||
# sls_enable_cxx_warning("-Wnull-dereference")
|
||||
# sls_enable_cxx_warning("-Wduplicated-cond")
|
||||
# sls_disable_cxx_warning("-Wclass-memaccess")
|
||||
# sls_disable_c_warning("-Wstringop-truncation")
|
||||
# sls_disable_c_warning("-Wformat-nonliteral")
|
||||
|
||||
|
||||
if(SLS_USE_SANITIZER)
|
||||
@ -186,22 +152,55 @@ if(SLS_TUNE_LOCAL)
|
||||
endif()
|
||||
|
||||
|
||||
if(SLS_MASTER_PROJECT)
|
||||
install(TARGETS slsProjectOptions slsProjectWarnings
|
||||
#rapidjson
|
||||
add_library(rapidjson INTERFACE)
|
||||
target_include_directories(rapidjson INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/libs/rapidjson>
|
||||
)
|
||||
|
||||
# Install fake the libraries
|
||||
install(TARGETS slsProjectOptions slsProjectWarnings rapidjson
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
set(CMAKE_INSTALL_RPATH $ORIGIN)
|
||||
# set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||
|
||||
|
||||
custom_find_zmq()
|
||||
# set(ZeroMQ_HINT "" CACHE STRING "Hint where ZeroMQ could be found")
|
||||
# #Adapted from: https://github.com/zeromq/cppzmq/
|
||||
# if (NOT TARGET libzmq)
|
||||
# if(ZeroMQ_HINT)
|
||||
# message(STATUS "Looking for ZeroMQ in: ${ZeroMQ_HINT}")
|
||||
# find_package(ZeroMQ 4
|
||||
# NO_DEFAULT_PATH
|
||||
# HINTS ${ZeroMQ_DIR}
|
||||
# )
|
||||
# else()
|
||||
# find_package(ZeroMQ 4 QUIET)
|
||||
# endif()
|
||||
|
||||
# # libzmq autotools install: fallback to pkg-config
|
||||
# if(NOT ZeroMQ_FOUND)
|
||||
# message(STATUS "CMake libzmq package not found, trying again with pkg-config (normal install of zeromq)")
|
||||
# list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/libzmq-pkg-config)
|
||||
# find_package(ZeroMQ 4 REQUIRED)
|
||||
# endif()
|
||||
|
||||
# # TODO "REQUIRED" above should already cause a fatal failure if not found, but this doesn't seem to work
|
||||
# if(NOT ZeroMQ_FOUND)
|
||||
# message(FATAL_ERROR "ZeroMQ was not found, neither as a CMake package nor via pkg-config")
|
||||
# endif()
|
||||
|
||||
# if (ZeroMQ_FOUND AND NOT TARGET libzmq)
|
||||
# message(FATAL_ERROR "ZeroMQ version not supported!")
|
||||
# endif()
|
||||
# endif()
|
||||
|
||||
if (SLS_USE_TESTS)
|
||||
enable_testing()
|
||||
@ -209,9 +208,8 @@ if (SLS_USE_TESTS)
|
||||
endif(SLS_USE_TESTS)
|
||||
|
||||
|
||||
if(NOT SLS_EXT_BUILD)
|
||||
add_subdirectory(slsSupportLib)
|
||||
endif()
|
||||
# Common functionallity to detector and receiver
|
||||
add_subdirectory(slsSupportLib)
|
||||
|
||||
if (SLS_USE_DETECTOR OR SLS_USE_TEXTCLIENT)
|
||||
add_subdirectory(slsDetectorSoftware)
|
||||
@ -235,7 +233,7 @@ endif (SLS_USE_INTEGRATION_TESTS)
|
||||
|
||||
if (SLS_USE_PYTHON)
|
||||
find_package (Python 3.6 COMPONENTS Interpreter Development)
|
||||
add_subdirectory(libs/pybind11 ${CMAKE_BINARY_DIR}/bin/)
|
||||
add_subdirectory(libs/pybind11)
|
||||
add_subdirectory(python)
|
||||
endif(SLS_USE_PYTHON)
|
||||
|
||||
@ -256,7 +254,6 @@ if(SLS_BUILD_DOCS)
|
||||
endif(SLS_BUILD_DOCS)
|
||||
|
||||
if(SLS_USE_MOENCH)
|
||||
add_subdirectory(slsDetectorCalibration/tiffio)
|
||||
add_subdirectory(slsDetectorCalibration/moenchExecutables)
|
||||
endif(SLS_USE_MOENCH)
|
||||
|
||||
|
359
RELEASE.txt
359
RELEASE.txt
@ -1,7 +1,7 @@
|
||||
SLS Detector Package Minor Release 7.0.0 released on 25.11.2021
|
||||
===============================================================
|
||||
SLS Detector Package 6.0.0 released on 21.10.2021
|
||||
==================================================
|
||||
|
||||
This document describes the differences between v7.0.0 and v6.x.x
|
||||
This document describes the differences between v6.0.0 and v5.1.0.
|
||||
|
||||
|
||||
|
||||
@ -9,9 +9,10 @@ This document describes the differences between v7.0.0 and v6.x.x
|
||||
--------
|
||||
1. New or Changed Features
|
||||
2. Resolved Issues
|
||||
3. Firmware Requirements
|
||||
4. Kernel Requirements
|
||||
5. Download, Documentation & Support
|
||||
3. Known Issues
|
||||
4. Changes in Next Major Release
|
||||
5. Firmware Requirements
|
||||
6. Download, Documentation & Support
|
||||
|
||||
|
||||
|
||||
@ -19,62 +20,277 @@ This document describes the differences between v7.0.0 and v6.x.x
|
||||
1. New or Changed Features
|
||||
==========================
|
||||
|
||||
- Fixed minor warnings (will fix commandline print of excess packets for missing packets)
|
||||
- ctb slow adcs and any other adcs (other than temp) goes to the control Server
|
||||
- number of udp interfaces is 2 for Eiger (CHANGE IN API??)
|
||||
- added module id for virtual servers into the udp header
|
||||
- refactoring (rxr)
|
||||
- fixed patsetbit and patsetmask for moench
|
||||
- changed default vref of adc9257 to 2V for moench (from 1.33V)
|
||||
- moench and ctb - can set the starting frame number of next acquisition
|
||||
- mythen server kernel check incompatible (cet timezone)
|
||||
- rx_arping
|
||||
- rx_threadsids max is now 9 (breaking api)
|
||||
- fixed datastream disabling for eiger. Its only available in 10g mode.
|
||||
- m3 server crash (vthrehsold dac names were not provided)
|
||||
- allow vtrim to be interpolated for Eiger settings
|
||||
- m3 setThresholdEnergy and setAllThresholdEnergy was overwriting gaincaps with settings enum
|
||||
- can set localhost with virtual server with minimum configuration: (hostname localhost, rx_hostname localhost, udp_dstip auto)
|
||||
- increases the progress according to listened index. (not processed index)
|
||||
- current frame index points to listened frame index (not processed index)
|
||||
- when in discard partial frames or empty mode, the frame number doesnt increase by 1, it increases to that number (so its faster)
|
||||
- file write disabled by default
|
||||
- eiger 12 bit mode
|
||||
- start non blocking acquisition at modular level
|
||||
- connect master commands to api (allow set master for eiger)
|
||||
--ignore-config command line
|
||||
- command line argument 'master' mainly for virtual servers (also master/top for real eiger), only one virtual server for eiger, use command lines for master/top
|
||||
- stop servers also check for errors at startup( in case it was running with an older version)
|
||||
- hostname cmd failed when connecting to servers in update mode (ctb, moench, jungfrau, eiger)
|
||||
- missingpackets signed (negative => extra packets)
|
||||
- framescaught and frameindex now returns a vector for each port
|
||||
- progress looks at activated or enabled ports, so progress does not stagnate
|
||||
- (eiger) disable datastreaming also for virtual servers only for 10g
|
||||
- missing packets also takes care of disabled ports
|
||||
- added geometry to metadata
|
||||
- 10g eiger nextframenumber get fixed.
|
||||
- stop, able to set nextframenumber to a consistent (max + 1) for all modules if different (eiger/ctb/jungfrau/moench)
|
||||
- ctb: can set names for all the dacs
|
||||
- fpga/kernel programming, checks if drive is a special file and not a normal file
|
||||
- gotthard 25 um image reconstructed in gui and virtual hdf5 (firmware updated for slave to reverse channels)
|
||||
- master binary file in json format now
|
||||
- fixed bug introduced in 6.0.0: hdf5 files created 1 file per frame after the initial file which had maxframesperfile
|
||||
- m3 polarity, interpolation (enables all counters when enabled), pump probe, analog pulsing, digital pulsing
|
||||
- updatedetectorserver - removes old server current binary pointing to for blackfin
|
||||
- removing copydetectorserver using tftp
|
||||
>>>>>>> developer
|
||||
- registerCallBackRawDataReady and registerCallBackRawDataModifyReady now gives a sls_receiver_header* instead of a char*, and uint32_t to size_t
|
||||
- registerCallBackStartAcquisition gave incorrect imagesize (+120 bytes). corrected.
|
||||
- registerCallBackStartAcquisition parameter is a const string reference
|
||||
- m3 (runnig config second time with tengiga 0, dr !=32, counters !=0x7) calculated incorrect image size expected
|
||||
- fixed row column indexing (mainly for multi module Jungfrau 2 interfaces )
|
||||
- eiger gui row indices not flipped anymore (fix in config)
|
||||
Added License. Read COPYING for more details.
|
||||
|
||||
Client
|
||||
------
|
||||
1. Shared libraries
|
||||
They are versioned from this release on (6.0.0).
|
||||
|
||||
2. [Jungfrau] Chip version
|
||||
Features for chipv1.1 incorporated
|
||||
Command line: chipversion, API: getchipVersion
|
||||
gets chip version (1.0 or 1.1)
|
||||
chipv1.1 requires config_jungfrau.txt on detector server and HW 2.0.
|
||||
|
||||
3. [Jungfrau] Chip configuration (only chipv1.1)
|
||||
powering on the chip and changing settings will configure the chip.
|
||||
Hence, required before acquisition.
|
||||
|
||||
4. [Jungfrau] Settings and Gain mode
|
||||
Settings can be gain0 and highgain0. Gain mode can be dynamicgain,
|
||||
forceswitchg1, forceswitchg2, fixg1, fixg2, fixg0. fixg0 must be
|
||||
used with EXTRA caution as you can damage the detector.
|
||||
Changing settings also changes dac values of 3 dacs
|
||||
(vref_prech, vref_ds and vref_comp) and reconfigures chip (only v1.1)
|
||||
|
||||
5. [Jungfrau] Storage cells (only chipv1.1)
|
||||
Additional number of storage cells not applicable for chipv1.1.
|
||||
Storage cell start is only allowed from 0 - 3 for chipv1.1
|
||||
(0 - 15 for chipv1.0).
|
||||
Command line: extrastoragecells, Previous Command line: storagecells
|
||||
API: remains the same.
|
||||
|
||||
6. [Gotthard2][Jungfrau] Filter Resistor
|
||||
Command line: filterresistor, API: getFilterResistor/ setFilterResistor
|
||||
Previous Command: filter, setFilter/ getFilter
|
||||
Set Filter resistor. Increasing values for increasing resistance.
|
||||
[Jungfrau] only for chipv1.1. Options: [0|1]. Default is 1.
|
||||
[Gotthard2] Options: [0|1|2|3]. Default is 0.
|
||||
|
||||
7. [Jungfrau] Filter cell (only chipv1.1)
|
||||
Command line: filtercells, API: getNumberOfFilterCells/ setNumberOfFilterCells
|
||||
Set filter cell. Options: [0-12]. Advanced user command.
|
||||
|
||||
8. [Jungfrau] Comparator disable time (only chipv1.1)
|
||||
Command line: compdisabletime, API: getComparatorDisableTime/
|
||||
setComparatorDisableTime
|
||||
One can customize the period to disable comparator.
|
||||
|
||||
9. [Eiger][Jungfrau] Read n rows
|
||||
Command line: readnrows, API: getReadNRows/ setReadNRows
|
||||
Previous Command: readnlines, getPartialReadout/ setPartialReadout
|
||||
[Eiger] same as before
|
||||
[Jungfrau] Options: 8 - 512, multiples of 8. Default is 512.
|
||||
|
||||
10. [Gotthard2][Jungfrau] Current source
|
||||
Command line: currentsource, API: getCurrentSource, setCurrentSource
|
||||
Enable or disable current source. Default is disabled.
|
||||
[Gotthard2] Can only enable or disable.
|
||||
[Jungfrau] Can choose to fix, select source and choose normal or low
|
||||
current. Normal/ low only for chipv1.1.
|
||||
Select source is 0-63 for chipv1.0 and a 64 bit mask for chipv1.1.
|
||||
|
||||
11. Default dac
|
||||
Command line: defaultdac, API: getDefaultDac/ setDefaultDac
|
||||
change default value of a dac
|
||||
[Jungfrau][Mythen3] Also change default value of dac for particular
|
||||
setting.
|
||||
|
||||
12. Reset dacs
|
||||
Command line: resetdacs, API: resetToDefaultDacs
|
||||
Previous command: defaultdacs
|
||||
Resets dacs to their default values or hard coded values.
|
||||
|
||||
13. [Mythen3] Gain Capacitance
|
||||
Command line: gaincaps, API: getGainCaps/ setGainCaps
|
||||
Set various gain capacitances.
|
||||
|
||||
14. [Gotthard2] Veto Streaming from chip
|
||||
Command line: veto, API: getVeto/ setVeto
|
||||
This command used to mean veto streaming from detector. Now, it means
|
||||
veto streaming from chip (New feature). Default is disabled.
|
||||
|
||||
15. [Gotthard2] Veto streaming from detector
|
||||
Command line: vetostream, API: getVetoStream, setVetoStream
|
||||
Options: None, local link interface, 10 10GbE, Both
|
||||
Default: None
|
||||
10GbE (as before) will enable 2 udp interfaces in receiver.
|
||||
|
||||
16. [Gotthard2] Veto algorithm
|
||||
Command line: vetoalg, API: getVetoAlgorithm/ setVetoAlgorithm
|
||||
Set veto algorithm for each interface.
|
||||
Options: hits, raw
|
||||
|
||||
17. [Eiger][Gotthard2][Mythen3] Module ID
|
||||
Command line: moduleid, API: getModuleId
|
||||
Previous command (Eiger only): serialnumber, getSerialNumber
|
||||
Unique id read from txt file on detector and streamed out in udp header.
|
||||
|
||||
18. [Gotthard2]
|
||||
Command line: dbitpipeline, API: getDBITPipeline/ setDBITPipeline
|
||||
Set pipeline to latch digital bits. Options: 0-7
|
||||
|
||||
19. [Eiger][Jungfrau] Round Robin commands
|
||||
Command line, udp_dstlist, API: getDestinationUDPList/
|
||||
setDestinationUDPList
|
||||
Round robin commands at the moment does not configure the receiver.
|
||||
Set multiple udp destinations in the detector to stream udp data packets
|
||||
to. Upto 32 destinations. Refer documentation for details.
|
||||
|
||||
Command line, udp_numdst, API: getNumberofUDPDestinations
|
||||
|
||||
[Jungfrau] Command line, udp_firstdst, API: getFirstUDPDestination/
|
||||
setFirstUDPDestination
|
||||
|
||||
20. Command Line Parsing
|
||||
Parsing of detector index and module index has been modified to
|
||||
integrate round robin index.
|
||||
[detector index]-[module index]:[round robin index] [command]
|
||||
|
||||
It is backwards compatible.
|
||||
For ease, one can also execute
|
||||
sls_detector_put [module index] [command]
|
||||
|
||||
21. Clear Udp Destination
|
||||
Command line, udp_cleardst, API: clearUDPDestinations
|
||||
This is useful when changing receivers for a detector or for round robin
|
||||
system.
|
||||
|
||||
22. Shared Memory Naming
|
||||
Shared memory name has been changed to reflect a more appropriate naming
|
||||
scheme.
|
||||
|
||||
23. [Eiger][Mythen3] Blocking trigger
|
||||
Command line: blockingtrigger, API: sendSoftwareTrigger
|
||||
Sends software trigger signal to detector and blocks till frames are
|
||||
sent out for that trigger.
|
||||
|
||||
24. [Eiger] Data stream enable for ports
|
||||
Command line: datastream, API: getDataStream/ setDataStream
|
||||
Enable or disable each port. Default: enabled
|
||||
|
||||
25. Changing TCP ports
|
||||
This will only affect shared memory and will not try to change the
|
||||
current tcp port of the control/stop server in detector.
|
||||
|
||||
26. [Eiger][Jungfrau][Gotthard2] Speed
|
||||
Command line: readoutspeed, readoutspeedlist API: getReadoutSpeed/ setReadoutSpeed /
|
||||
getReadoutSpeedList
|
||||
Previous command: speed, setSpeed/ getSpeed
|
||||
[Eiger][Jungfrau] same as before.
|
||||
[Gotthard2] New command to set readout speed. Options: 108, 144 (in MHz)
|
||||
|
||||
27. [Eiger][Jungfrau] Flip rows
|
||||
Command line: fliprows, API: getFlipRows/ setFlipRows
|
||||
Previous command: flippeddatax, setBottom/ getBottom
|
||||
[Jungfrau] Flips rows in detector only for HW v2.0.
|
||||
slsReceiver and slsDetectorGui will not flip them again.
|
||||
[Eiger] same as before.
|
||||
|
||||
28. [Jungfrau]
|
||||
Command line changes: autocompdisable, Previous command line: auto_comp_disable
|
||||
|
||||
|
||||
Detector servers
|
||||
----------------
|
||||
|
||||
1. [Gotthard2] Bad Channels moved to a new register, default settings
|
||||
including clock frequency changed
|
||||
|
||||
2. [Gotthard2] Updated config file in detector server
|
||||
|
||||
|
||||
Virtual servers
|
||||
----------------
|
||||
|
||||
1. Artifical pixel values increasing by every packet, instead of every pixel.
|
||||
|
||||
2. All possible features updated.
|
||||
|
||||
|
||||
Receiver
|
||||
--------
|
||||
|
||||
1. Frames caught in metadata
|
||||
Frames caught by the master receiver is added to master file metadata.
|
||||
Hdf5 and Binary version numbers changed to 6.3
|
||||
|
||||
2. Removed Padding option for Deactivated half modules.
|
||||
|
||||
3. Changing Receiver TCP ports
|
||||
This will only affect shared memory and will not try to change the
|
||||
current tcp port of the receiver.
|
||||
|
||||
Gui
|
||||
----
|
||||
|
||||
1. [Mythen3] counters added in settings tab
|
||||
|
||||
|
||||
|
||||
|
||||
2. Resolved Issues
|
||||
==================
|
||||
|
||||
Detector Servers
|
||||
----------------
|
||||
|
||||
3. Firmware Requirements
|
||||
1. [Gotthard2] Tolerance in time parameters.
|
||||
Eg. 220 ns was being set to 215 ns, instead of 222ns.
|
||||
|
||||
2. [Jungfrau] Stopping in trigger mode and then switching to auto timing mode
|
||||
blocks data streaming from detector. Workaround fix made in
|
||||
detector server to reset core until next firmware release.
|
||||
|
||||
3. [Jungfrau][CTB][Moench][Gotthard][Gotthard2][Mythen3] Firmware Programming
|
||||
Firmware programming incorporates more validations such as checksum of
|
||||
program. Always ensure client and server are of same release before
|
||||
programming firmware.
|
||||
|
||||
4. [Eiger] Stop sends last frame
|
||||
Stop acquisition will now also send out all complete frames in fifo.
|
||||
|
||||
5. [Eiger] Bottom not rotated in quad mode. Fixed.
|
||||
|
||||
6. [Mythen3] counter mask effect on vthreshold
|
||||
Setting counter mask changes vth daac values (ie. disabling sets to 2800),
|
||||
vthreshold only changes for enabled counters, setting vth overwrites
|
||||
dac even if counter disabled and when counters enabled, remembers set
|
||||
values.
|
||||
|
||||
7. [Eiger] fast quad fix for loading trimbits
|
||||
|
||||
8. [Eiger] Can also use copydetectorserver command.
|
||||
[All] copydetectorserver command also creates a link to the binary copied
|
||||
with a shorter name ([detector]DetectorServer only)
|
||||
|
||||
Receiver
|
||||
--------
|
||||
|
||||
1. Disabled port or deactivated (half) modules will not create files.
|
||||
|
||||
|
||||
|
||||
|
||||
3. Known Issues
|
||||
===============
|
||||
|
||||
Receiver
|
||||
--------
|
||||
1. It does not handle readnrows or partial readout. Only the summary
|
||||
is adjusted to print in red. However, it will still write complete
|
||||
images with missing data padded. Roi will be implemented in future
|
||||
that can be complemented with this feature to remove the additional
|
||||
data in files.
|
||||
|
||||
2. Round robin is not implemented in receiver side, ie. one cannot configure
|
||||
more than 1 receiver at a time. This will/might be done in the future.
|
||||
|
||||
|
||||
|
||||
|
||||
4. Changes in Next Major Release
|
||||
================================
|
||||
|
||||
1. Naming of Package
|
||||
The package might be renamed and so might the binaries, libraries,
|
||||
namespace,include paths in the next major release (which is breaking API).
|
||||
|
||||
|
||||
|
||||
|
||||
5. Firmware Requirements
|
||||
========================
|
||||
|
||||
Eiger
|
||||
@ -109,6 +325,7 @@ This document describes the differences between v7.0.0 and v6.x.x
|
||||
|
||||
Detector Upgrade
|
||||
================
|
||||
|
||||
The following can be upgraded remotely:
|
||||
Eiger via bit files
|
||||
Jungfrau via command <.pof>
|
||||
@ -127,34 +344,8 @@ This document describes the differences between v7.0.0 and v6.x.x
|
||||
|
||||
|
||||
|
||||
4. Kernel Requirements
|
||||
======================
|
||||
|
||||
Blackfin
|
||||
========
|
||||
Latest version: Fri Oct 29 00:00:00 2021
|
||||
|
||||
Older ones will work, but might have issues with programming firmware via
|
||||
the package.
|
||||
|
||||
Nios
|
||||
====
|
||||
Compatible version: Mon May 10 18:00:21 CEST 2021
|
||||
|
||||
Kernel Upgrade
|
||||
==============
|
||||
Eiger via bit files
|
||||
Others via command
|
||||
|
||||
Commands: udpatekernel, kernelversion
|
||||
Instructions available at
|
||||
https://slsdetectorgroup.github.io/devdoc/commandline.html
|
||||
https://slsdetectorgroup.github.io/devdoc/detector.html
|
||||
https://slsdetectorgroup.github.io/devdoc/pydetector.html
|
||||
|
||||
|
||||
|
||||
5. Download, Documentation & Support
|
||||
6. Download, Documentation & Support
|
||||
====================================
|
||||
|
||||
Download
|
||||
|
@ -7,9 +7,9 @@ function(enable_cxx_warning flag target)
|
||||
check_cxx_compiler_flag(${flag} ${flag_name})
|
||||
if(${flag_name})
|
||||
target_compile_options(${target} INTERFACE ${flag})
|
||||
message(STATUS "Adding: ${flag} to ${target}")
|
||||
message("Adding: ${flag} to ${target}")
|
||||
else()
|
||||
message(STATUS "Flag: ${flag} not supported")
|
||||
message("Flag: ${flag} not supported")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@ -18,9 +18,9 @@ function(enable_c_warning flag target)
|
||||
check_c_compiler_flag(${flag} ${flag_name})
|
||||
if(${flag_name})
|
||||
target_compile_options(${target} INTERFACE ${flag})
|
||||
message(STATUS "Adding: ${flag} to ${target}")
|
||||
message("Adding: ${flag} to ${target}")
|
||||
else()
|
||||
message(STATUS "Flag: ${flag} not supported")
|
||||
message("Flag: ${flag} not supported")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@ -31,10 +31,10 @@ function(disable_cxx_warning flag target)
|
||||
|
||||
if(${flag_name})
|
||||
string(REPLACE "-W" "-Wno-" neg_flag ${flag})
|
||||
message(STATUS "Adding: ${neg_flag} to ${target}")
|
||||
message("Adding: ${neg_flag} to ${target}")
|
||||
target_compile_options(${target} INTERFACE ${neg_flag})
|
||||
else()
|
||||
message(STATUS "Warning: ${flag} not supported no need to disable")
|
||||
message("Warning: ${flag} not supported no need to disable")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@ -43,10 +43,10 @@ function(disable_c_warning flag target)
|
||||
check_c_compiler_flag(${flag} ${flag_name})
|
||||
if(${flag_name})
|
||||
string(REPLACE "-W" "-Wno-" neg_flag ${flag})
|
||||
message(STATUS "Adding: ${neg_flag} to ${target}")
|
||||
message("Adding: ${neg_flag} to ${target}")
|
||||
target_compile_options(${target} INTERFACE ${neg_flag})
|
||||
else()
|
||||
message(STATUS "Warning: ${flag} not supported no need to disable")
|
||||
message("Warning: ${flag} not supported no need to disable")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
@ -1,38 +0,0 @@
|
||||
function(custom_find_zmq)
|
||||
set(ZeroMQ_HINT "" CACHE STRING "Hint where ZeroMQ could be found")
|
||||
#Adapted from: https://github.com/zeromq/cppzmq/
|
||||
if (NOT TARGET libzmq)
|
||||
if(ZeroMQ_HINT)
|
||||
message(STATUS "Looking for ZeroMQ in: ${ZeroMQ_HINT}")
|
||||
find_package(ZeroMQ 4
|
||||
NO_DEFAULT_PATH
|
||||
HINTS ${ZeroMQ_HINT}
|
||||
)
|
||||
else()
|
||||
find_package(ZeroMQ 4 QUIET)
|
||||
endif()
|
||||
|
||||
# libzmq autotools install: fallback to pkg-config
|
||||
if(ZeroMQ_FOUND)
|
||||
message(STATUS "Found libzmq using find_package")
|
||||
else()
|
||||
message(STATUS "CMake libzmq package not found, trying again with pkg-config (normal install of zeromq)")
|
||||
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake/libzmq-pkg-config)
|
||||
find_package(ZeroMQ 4 REQUIRED)
|
||||
endif()
|
||||
|
||||
# TODO "REQUIRED" above should already cause a fatal failure if not found, but this doesn't seem to work
|
||||
if(NOT ZeroMQ_FOUND)
|
||||
message(FATAL_ERROR "ZeroMQ was not found, neither as a CMake package nor via pkg-config")
|
||||
endif()
|
||||
|
||||
if (ZeroMQ_FOUND AND NOT TARGET libzmq)
|
||||
message(FATAL_ERROR "ZeroMQ version not supported!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
get_target_property(VAR libzmq IMPORTED_LOCATION)
|
||||
message(STATUS "Using libzmq: ${VAR}")
|
||||
|
||||
|
||||
endfunction()
|
@ -1,36 +0,0 @@
|
||||
#From: https://github.com/zeromq/cppzmq/
|
||||
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(PC_LIBZMQ QUIET libzmq)
|
||||
|
||||
set(ZeroMQ_VERSION ${PC_LIBZMQ_VERSION})
|
||||
|
||||
find_path(ZeroMQ_INCLUDE_DIR zmq.h
|
||||
PATHS ${ZeroMQ_DIR}/include
|
||||
${PC_LIBZMQ_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
find_library(ZeroMQ_LIBRARY
|
||||
NAMES zmq
|
||||
PATHS ${ZeroMQ_DIR}/lib
|
||||
${PC_LIBZMQ_LIBDIR}
|
||||
${PC_LIBZMQ_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
if(ZeroMQ_LIBRARY OR ZeroMQ_STATIC_LIBRARY)
|
||||
set(ZeroMQ_FOUND ON)
|
||||
message(STATUS "Found libzmq using PkgConfig")
|
||||
endif()
|
||||
|
||||
set ( ZeroMQ_LIBRARIES ${ZeroMQ_LIBRARY} )
|
||||
set ( ZeroMQ_INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIR} )
|
||||
|
||||
if (NOT TARGET libzmq)
|
||||
add_library(libzmq UNKNOWN IMPORTED)
|
||||
set_target_properties(libzmq PROPERTIES
|
||||
IMPORTED_LOCATION ${ZeroMQ_LIBRARIES}
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${ZeroMQ_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
include ( FindPackageHandleStandardArgs )
|
||||
find_package_handle_standard_args ( ZeroMQ DEFAULT_MSG ZeroMQ_LIBRARIES ZeroMQ_INCLUDE_DIRS )
|
@ -26,7 +26,7 @@ install(FILES
|
||||
)
|
||||
|
||||
install(FILES
|
||||
"${CMAKE_SOURCE_DIR}/cmake/libzmq-pkg-config/FindZeroMQ.cmake"
|
||||
"${CMAKE_SOURCE_DIR}/libzmq-pkg-config/FindZeroMQ.cmake"
|
||||
COMPONENT devel
|
||||
DESTINATION ${CMAKE_INSTALL_DIR}/libzmq-pkg-config
|
||||
)
|
||||
|
2
cmk.sh
2
cmk.sh
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#!/bin/bash
|
||||
CMAKE="cmake3"
|
||||
BUILDDIR="build"
|
||||
INSTALLDIR=""
|
||||
|
@ -2,18 +2,17 @@
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
mkdir build
|
||||
|
||||
mkdir install
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
|
||||
-DCMAKE_INSTALL_PREFIX=$PREFIX \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
-DSLS_USE_TEXTCLIENT=ON \
|
||||
-DSLS_USE_RECEIVER=ON \
|
||||
-DSLS_USE_GUI=OFF \
|
||||
-DSLS_USE_MOENCH=OFF\
|
||||
-DSLS_USE_GUI=ON \
|
||||
-DSLS_USE_MOENCH=ON\
|
||||
-DSLS_USE_TESTS=ON \
|
||||
-DSLS_USE_PYTHON=OFF \
|
||||
-DSLS_DEVEL_HEADERS=ON \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DSLS_USE_HDF5=OFF\
|
||||
|
||||
@ -23,7 +22,3 @@ cmake --build . -- -j${NCORES}
|
||||
cmake --build . --target install
|
||||
|
||||
CTEST_OUTPUT_ON_FAILURE=1 ctest -j 2
|
||||
|
||||
#Clean up for the next build
|
||||
# cd ..
|
||||
# rm -rf build
|
4
conda-recipes/slsdet/build.sh → conda-recepie/build_pylib.sh
Normal file → Executable file
4
conda-recipes/slsdet/build.sh → conda-recepie/build_pylib.sh
Normal file → Executable file
@ -2,7 +2,5 @@
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
echo "|<-------- starting python build"
|
||||
echo $PWD
|
||||
cd python
|
||||
echo "folder: $PWD"
|
||||
${PYTHON} setup.py install
|
||||
${PYTHON} setup.py install
|
8
conda-recepie/conda_build_config.yaml
Normal file
8
conda-recepie/conda_build_config.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
python:
|
||||
- 3.6
|
||||
- 3.7
|
||||
- 3.8
|
||||
- 3.9
|
||||
|
||||
numpy:
|
||||
- 1.17
|
11
conda-recepie/copy_ctbgui.sh
Normal file
11
conda-recepie/copy_ctbgui.sh
Normal file
@ -0,0 +1,11 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
mkdir $PREFIX/lib
|
||||
mkdir $PREFIX/bin
|
||||
mkdir $PREFIX/include
|
||||
|
||||
|
||||
|
||||
cp build/bin/ctbGui $PREFIX/bin/.
|
||||
cp build/bin/libctbRootLib.so $PREFIX/lib/.
|
||||
|
6
slsDetectorCalibration/tiffio/tests/CMakeLists.txt → conda-recepie/copy_gui.sh
Normal file → Executable file
6
slsDetectorCalibration/tiffio/tests/CMakeLists.txt → conda-recepie/copy_gui.sh
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
target_sources(tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-tiffio.cpp
|
||||
)
|
||||
#Copy the GUI
|
||||
mkdir -p $PREFIX/bin
|
||||
cp build/install/bin/slsDetectorGui $PREFIX/bin/.
|
22
conda-recepie/copy_lib.sh
Executable file
22
conda-recepie/copy_lib.sh
Executable file
@ -0,0 +1,22 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
mkdir -p $PREFIX/lib
|
||||
mkdir -p $PREFIX/bin
|
||||
mkdir -p $PREFIX/include/sls
|
||||
# mkdir $PREFIX/include/slsDetectorPackage
|
||||
|
||||
#Shared and static libraries
|
||||
cp build/install/lib/* $PREFIX/lib/
|
||||
|
||||
#Binaries
|
||||
cp build/install/bin/sls_detector_acquire $PREFIX/bin/.
|
||||
cp build/install/bin/sls_detector_get $PREFIX/bin/.
|
||||
cp build/install/bin/sls_detector_put $PREFIX/bin/.
|
||||
cp build/install/bin/sls_detector_help $PREFIX/bin/.
|
||||
cp build/install/bin/slsReceiver $PREFIX/bin/.
|
||||
cp build/install/bin/slsMultiReceiver $PREFIX/bin/.
|
||||
|
||||
|
||||
cp build/install/include/sls/* $PREFIX/include/sls
|
||||
cp -r build/install/share/ $PREFIX/share
|
6
conda-recepie/copy_moench.sh
Normal file
6
conda-recepie/copy_moench.sh
Normal file
@ -0,0 +1,6 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#Copy the Moench executables
|
||||
mkdir -p $PREFIX/bin
|
||||
cp build/install/bin/moench04ZmqProcess $PREFIX/bin/.
|
||||
cp build/install/bin/moenchZmqProcess $PREFIX/bin/.
|
134
conda-recepie/meta.yaml
Executable file
134
conda-recepie/meta.yaml
Executable file
@ -0,0 +1,134 @@
|
||||
|
||||
package:
|
||||
name: sls_detector_software
|
||||
version: {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
|
||||
source:
|
||||
- path: ..
|
||||
|
||||
build:
|
||||
number: 0
|
||||
binary_relocation: True
|
||||
rpaths:
|
||||
- lib/
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- cmake
|
||||
- qwt 6.*
|
||||
- qt 4.8.*
|
||||
- zeromq
|
||||
- xorg-libx11
|
||||
- xorg-libice
|
||||
- xorg-libxext
|
||||
- xorg-libsm
|
||||
- xorg-libxau
|
||||
- xorg-libxrender
|
||||
- xorg-libxfixes
|
||||
- {{ cdt('mesa-libgl-devel') }} # [linux]
|
||||
- {{ cdt('mesa-libegl-devel') }} # [linux]
|
||||
- {{ cdt('mesa-dri-drivers') }} # [linux]
|
||||
- {{ cdt('libselinux') }} # [linux]
|
||||
- {{ cdt('libxdamage') }} # [linux]
|
||||
- {{ cdt('libxxf86vm') }} # [linux]
|
||||
- expat
|
||||
|
||||
host:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- zeromq
|
||||
- xorg-libx11
|
||||
- xorg-libice
|
||||
- xorg-libxext
|
||||
- xorg-libsm
|
||||
- xorg-libxau
|
||||
- xorg-libxrender
|
||||
- xorg-libxfixes
|
||||
- expat
|
||||
|
||||
run:
|
||||
- zeromq
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
|
||||
|
||||
outputs:
|
||||
- name: slsdetlib
|
||||
script: copy_lib.sh
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- zeromq
|
||||
|
||||
host:
|
||||
- zeromq
|
||||
|
||||
run:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- zeromq
|
||||
|
||||
- name: slsdet
|
||||
|
||||
script: build_pylib.sh
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- python
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
- setuptools
|
||||
|
||||
host:
|
||||
- python
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
|
||||
|
||||
run:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- python
|
||||
- numpy
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
|
||||
|
||||
test:
|
||||
imports:
|
||||
- slsdet
|
||||
|
||||
- name: slsdetgui
|
||||
script: copy_gui.sh
|
||||
requirements:
|
||||
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
- qwt 6.*
|
||||
|
||||
run:
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
- qwt 6.*
|
||||
- qt 4.8.*
|
||||
- expat
|
||||
|
||||
- name: moenchzmq
|
||||
script: copy_moench.sh
|
||||
requirements:
|
||||
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
|
||||
|
||||
run:
|
||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
- expat
|
3
conda-recepie/run_test.sh
Executable file
3
conda-recepie/run_test.sh
Executable file
@ -0,0 +1,3 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
ctest -j2
|
@ -1,24 +0,0 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
mkdir build
|
||||
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
|
||||
-DCMAKE_INSTALL_PREFIX=$PREFIX \
|
||||
-DSLS_USE_CTBGUI=ON \
|
||||
-DSLS_EXT_BUILD=ON\
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DSLS_USE_HDF5=OFF\
|
||||
|
||||
NCORES=$(getconf _NPROCESSORS_ONLN)
|
||||
echo "Building using: ${NCORES} cores"
|
||||
cmake --build . -- -j${NCORES}
|
||||
cmake --build . --target install
|
||||
|
||||
CTEST_OUTPUT_ON_FAILURE=1 ctest -j 2
|
||||
|
||||
#Clean up for the next build
|
||||
# cd ..
|
||||
# rm -rf build
|
@ -1,94 +0,0 @@
|
||||
package:
|
||||
name: ctbgui
|
||||
version: {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
|
||||
source:
|
||||
- path: ../..
|
||||
|
||||
build:
|
||||
number: 0
|
||||
binary_relocation: True
|
||||
rpaths:
|
||||
- lib/
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- slsdetlib {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
- cmake
|
||||
- root
|
||||
# - qwt 6.*
|
||||
# - qt 4.8.*
|
||||
# - zeromq
|
||||
# - xorg-libx11
|
||||
# - xorg-libice
|
||||
# - xorg-libxext
|
||||
# - xorg-libsm
|
||||
# - xorg-libxau
|
||||
# - xorg-libxrender
|
||||
# - xorg-libxfixes
|
||||
# - {{ cdt('mesa-libgl-devel') }} # [linux]
|
||||
# - {{ cdt('mesa-libegl-devel') }} # [linux]
|
||||
# - {{ cdt('mesa-dri-drivers') }} # [linux]
|
||||
# - {{ cdt('libselinux') }} # [linux]
|
||||
# - {{ cdt('libxdamage') }} # [linux]
|
||||
# - {{ cdt('libxxf86vm') }} # [linux]
|
||||
# - expat
|
||||
|
||||
host:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- root
|
||||
- slsdetlib {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
# - zeromq
|
||||
# - xorg-libx11
|
||||
# - xorg-libice
|
||||
# - xorg-libxext
|
||||
# - xorg-libsm
|
||||
# - xorg-libxau
|
||||
# - xorg-libxrender
|
||||
# - xorg-libxfixes
|
||||
# - expat
|
||||
|
||||
run:
|
||||
# - zeromq
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- root
|
||||
# - slsdetlib {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
# - qwt 6.*
|
||||
# - qt 4.8.*
|
||||
# - expat
|
||||
|
||||
|
||||
|
||||
# - name: slsdetgui
|
||||
# script: copy_gui.sh
|
||||
# requirements:
|
||||
|
||||
# build:
|
||||
# - {{ compiler('c') }}
|
||||
# - {{compiler('cxx')}}
|
||||
# - {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
# - qwt 6.*
|
||||
|
||||
# run:
|
||||
# - {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
# - qwt 6.*
|
||||
# - qt 4.8.*
|
||||
# - expat
|
||||
|
||||
# - name: moenchzmq
|
||||
# script: copy_moench.sh
|
||||
# requirements:
|
||||
|
||||
# build:
|
||||
# - {{ compiler('c') }}
|
||||
# - {{compiler('cxx')}}
|
||||
# - {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
|
||||
|
||||
# run:
|
||||
# - {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
# - expat
|
@ -1,25 +0,0 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
mkdir build
|
||||
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
|
||||
-DCMAKE_INSTALL_PREFIX=$PREFIX \
|
||||
-DSLS_USE_MOENCH=ON\
|
||||
-DSLS_USE_TESTS=ON \
|
||||
-DSLS_EXT_BUILD=ON \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DSLS_USE_HDF5=OFF\
|
||||
|
||||
NCORES=$(getconf _NPROCESSORS_ONLN)
|
||||
echo "Building using: ${NCORES} cores"
|
||||
cmake --build . -- -j${NCORES}
|
||||
cmake --build . --target install
|
||||
|
||||
CTEST_OUTPUT_ON_FAILURE=1 ctest -j 2
|
||||
|
||||
#Clean up for the next build
|
||||
# cd ..
|
||||
# rm -rf build
|
@ -1,36 +0,0 @@
|
||||
|
||||
package:
|
||||
name: moenchzmq
|
||||
version: {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
|
||||
source:
|
||||
- path: ../..
|
||||
|
||||
build:
|
||||
number: 0
|
||||
binary_relocation: True
|
||||
rpaths:
|
||||
- lib/
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- cmake
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- zeromq
|
||||
- libtiff
|
||||
- slsdetlib {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
|
||||
host:
|
||||
- zeromq
|
||||
- libtiff
|
||||
- slsdetlib {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
|
||||
run:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- zeromq
|
||||
- libtiff
|
||||
- slsdetlib {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
@ -1,2 +0,0 @@
|
||||
python:
|
||||
- 3.9
|
@ -1,34 +0,0 @@
|
||||
|
||||
package:
|
||||
name: slsdet
|
||||
version: {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
|
||||
source:
|
||||
- path: ../..
|
||||
|
||||
build:
|
||||
number: 0
|
||||
binary_relocation: True
|
||||
rpaths:
|
||||
- lib/
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- python
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- cmake
|
||||
- slsdetlib {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
- setuptools
|
||||
|
||||
host:
|
||||
- python
|
||||
- slsdetlib {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
|
||||
|
||||
run:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- python
|
||||
- numpy
|
||||
- slsdetlib {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
@ -1,24 +0,0 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
mkdir build
|
||||
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
|
||||
-DCMAKE_INSTALL_PREFIX=$PREFIX \
|
||||
-DSLS_USE_GUI=ON \
|
||||
-DSLS_EXT_BUILD=ON\
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DSLS_USE_HDF5=OFF\
|
||||
|
||||
NCORES=$(getconf _NPROCESSORS_ONLN)
|
||||
echo "Building using: ${NCORES} cores"
|
||||
cmake --build . -- -j${NCORES}
|
||||
cmake --build . --target install
|
||||
|
||||
CTEST_OUTPUT_ON_FAILURE=1 ctest -j 2
|
||||
|
||||
#Clean up for the next build
|
||||
# cd ..
|
||||
# rm -rf build
|
@ -1,91 +0,0 @@
|
||||
package:
|
||||
name: slsdetgui
|
||||
version: {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
|
||||
source:
|
||||
- path: ../..
|
||||
|
||||
build:
|
||||
number: 0
|
||||
binary_relocation: True
|
||||
rpaths:
|
||||
- lib/
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- slsdetlib {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
- cmake
|
||||
- qwt 6.*
|
||||
- qt 4.8.*
|
||||
- zeromq
|
||||
- xorg-libx11
|
||||
- xorg-libice
|
||||
- xorg-libxext
|
||||
- xorg-libsm
|
||||
- xorg-libxau
|
||||
- xorg-libxrender
|
||||
- xorg-libxfixes
|
||||
- {{ cdt('mesa-libgl-devel') }} # [linux]
|
||||
- {{ cdt('mesa-libegl-devel') }} # [linux]
|
||||
- {{ cdt('mesa-dri-drivers') }} # [linux]
|
||||
- {{ cdt('libselinux') }} # [linux]
|
||||
- {{ cdt('libxdamage') }} # [linux]
|
||||
- {{ cdt('libxxf86vm') }} # [linux]
|
||||
- expat
|
||||
|
||||
host:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- slsdetlib {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
- zeromq
|
||||
- xorg-libx11
|
||||
- xorg-libice
|
||||
- xorg-libxext
|
||||
- xorg-libsm
|
||||
- xorg-libxau
|
||||
- xorg-libxrender
|
||||
- xorg-libxfixes
|
||||
- expat
|
||||
|
||||
run:
|
||||
- zeromq
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- slsdetlib {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
- qwt 6.*
|
||||
- qt 4.8.*
|
||||
- expat
|
||||
|
||||
|
||||
|
||||
# - name: slsdetgui
|
||||
# script: copy_gui.sh
|
||||
# requirements:
|
||||
|
||||
# build:
|
||||
# - {{ compiler('c') }}
|
||||
# - {{compiler('cxx')}}
|
||||
# - {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
# - qwt 6.*
|
||||
|
||||
# run:
|
||||
# - {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
# - qwt 6.*
|
||||
# - qt 4.8.*
|
||||
# - expat
|
||||
|
||||
# - name: moenchzmq
|
||||
# script: copy_moench.sh
|
||||
# requirements:
|
||||
|
||||
# build:
|
||||
# - {{ compiler('c') }}
|
||||
# - {{compiler('cxx')}}
|
||||
# - {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
|
||||
|
||||
# run:
|
||||
# - {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
# - expat
|
@ -1,90 +0,0 @@
|
||||
|
||||
package:
|
||||
name: slsdetlib
|
||||
version: {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
||||
|
||||
source:
|
||||
- path: ../..
|
||||
|
||||
build:
|
||||
number: 0
|
||||
binary_relocation: True
|
||||
rpaths:
|
||||
- lib/
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- cmake
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- zeromq
|
||||
|
||||
host:
|
||||
- zeromq
|
||||
|
||||
run:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- zeromq
|
||||
|
||||
|
||||
# outputs:
|
||||
# - name: slsdetlib
|
||||
# script: build_lib.sh
|
||||
|
||||
# requirements:
|
||||
# build:
|
||||
# - {{ compiler('c') }}
|
||||
# - {{compiler('cxx')}}
|
||||
# - libstdcxx-ng
|
||||
# - libgcc-ng
|
||||
# - zeromq
|
||||
|
||||
# host:
|
||||
# - zeromq
|
||||
|
||||
# run:
|
||||
# - libstdcxx-ng
|
||||
# - libgcc-ng
|
||||
# - zeromq
|
||||
|
||||
# - name: slsdet
|
||||
# script: build_py.sh
|
||||
|
||||
# requirements:
|
||||
# build:
|
||||
# - python
|
||||
# - {{ compiler('c') }}
|
||||
# - {{compiler('cxx')}}
|
||||
# - {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
# - setuptools
|
||||
|
||||
# host:
|
||||
# - python
|
||||
# - {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
|
||||
|
||||
# run:
|
||||
# - libstdcxx-ng
|
||||
# - libgcc-ng
|
||||
# - python
|
||||
# - numpy
|
||||
# - {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
|
||||
# - name: slsdetgui
|
||||
# script: build_gui.sh
|
||||
# requirements:
|
||||
|
||||
# build:
|
||||
# - {{ compiler('c') }}
|
||||
# - {{compiler('cxx')}}
|
||||
# - {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
# - qwt 6.*
|
||||
|
||||
# run:
|
||||
# - {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||
# - qwt 6.*
|
||||
# - qt 4.8.*
|
||||
# - expat
|
@ -34,7 +34,7 @@ add_executable(ctbGui
|
||||
ctbAdcs.cpp
|
||||
ctbPattern.cpp
|
||||
ctbAcquisition.cpp
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/tiffio/src/tiffIO.cpp
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/tiffIO.cpp
|
||||
)
|
||||
|
||||
|
||||
@ -43,7 +43,6 @@ target_include_directories(ctbGui PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/dataStructures
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/interpolations
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/
|
||||
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/tiffio/include/
|
||||
)
|
||||
|
||||
# Headders needed for ROOT dictionary generation
|
||||
@ -62,6 +61,7 @@ set( HEADERS
|
||||
#set(ROOT_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# ROOT dictionary generation
|
||||
include("${ROOT_DIR}/RootMacros.cmake")
|
||||
root_generate_dictionary(ctbDict ${HEADERS} LINKDEF ctbLinkDef.h)
|
||||
add_library(ctbRootLib SHARED ctbDict.cxx)
|
||||
target_include_directories(ctbRootLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
@ -83,12 +83,7 @@ target_link_libraries(ctbGui PUBLIC
|
||||
${TIFF_LIBRARIES}
|
||||
)
|
||||
|
||||
#set_target_properties(ctbGui PROPERTIES
|
||||
# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
#
|
||||
#)
|
||||
set_target_properties(ctbGui PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
|
||||
install(TARGETS ctbGui ctbRootLib
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
@ -21,10 +21,9 @@ fi
|
||||
|
||||
if [ -f "$infile" ]
|
||||
then
|
||||
dir=$(dirname $infile)
|
||||
gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c -I$dir;
|
||||
gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c ;
|
||||
echo compiling
|
||||
echo gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c -I$dir;
|
||||
echo gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c ;
|
||||
$exe ;
|
||||
echo cleaning
|
||||
rm $exe
|
||||
|
@ -69,14 +69,14 @@ void setoutput(int bit) {
|
||||
mask=mask<<bit;
|
||||
iopat |= mask;
|
||||
}
|
||||
/*
|
||||
|
||||
void setclk(int bit) {
|
||||
uint64_t mask=1;
|
||||
mask=mask<<bit;
|
||||
iopat |= mask;
|
||||
clkpat |= mask;
|
||||
}
|
||||
*/
|
||||
|
||||
void clearbit(int bit){
|
||||
uint64_t mask=1;
|
||||
mask=mask<<bit;
|
||||
@ -157,7 +157,7 @@ main(void) {
|
||||
#include INFILE
|
||||
|
||||
fprintf(fd,"patioctrl 0x%016llx\n",iopat);
|
||||
//fprintf(fd,"patclkctrl 0x%016llx\n",clkpat);
|
||||
fprintf(fd,"patclkctrl 0x%016llx\n",clkpat);
|
||||
fprintf(fd,"patlimits 0x%04x 0x%04x\n",start, stop);
|
||||
|
||||
for (iloop=0; iloop<MAXLOOPS; iloop++) {
|
||||
|
@ -34,12 +34,6 @@ Python bindings
|
||||
* pybind11 (packaged in libs/)
|
||||
|
||||
|
||||
-----------------------
|
||||
Moench executables
|
||||
-----------------------
|
||||
|
||||
* libtiff
|
||||
|
||||
-----------------------
|
||||
Documentation
|
||||
-----------------------
|
||||
|
@ -305,53 +305,43 @@ Firmware Troubleshooting with blackfin
|
||||
|
||||
5. If one can't list it, read the next section to try to get the blackfin to list it.
|
||||
|
||||
How to get back mtd3 drive remotely (udpating kernel)
|
||||
How to get back mtd3 drive remotely (copying new kernel)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
You have 2 alternatives to update the kernel.
|
||||
|
||||
1. Commands via software (>= v6.0.0)
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sls_detector_put updatekernel /home/...path-to-kernel-image
|
||||
|
||||
|
||||
2. or command line
|
||||
.. code-block:: bash
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# step 1: get the kernel image (uImage.lzma) from slsdetectorgroup
|
||||
# and copy it to pc's tftp folder
|
||||
# step 1: get the kernel image (uImage.lzma) from slsdetectorgroup
|
||||
# and copy it to pc's tftp folder
|
||||
|
||||
# step 2: connect to the board
|
||||
telnet bchipxxx
|
||||
# step 2: connect to the board
|
||||
telnet bchipxxx
|
||||
|
||||
#step 3: go to directory for space
|
||||
cd /var/tmp/
|
||||
#step 3: go to directory for space
|
||||
cd /var/tmp/
|
||||
|
||||
# step 3: copy kernel to board
|
||||
tftp pcxxx -r uImage.lzma -g
|
||||
# step 3: copy kernel to board
|
||||
tftp pcxxx -r uImage.lzma -g
|
||||
|
||||
# step 4: verify kernel copied properly
|
||||
ls -lrt
|
||||
|
||||
# step 5: erase flash
|
||||
flash_eraseall /dev/mtd1
|
||||
|
||||
# step 6: copy new image to kernel drive
|
||||
cat uImage.lzma > /dev/mtd1
|
||||
|
||||
# step 7:
|
||||
sync
|
||||
|
||||
# step 8:
|
||||
reboot
|
||||
|
||||
# step 9: verification
|
||||
telnet bchipxxx
|
||||
uname -a # verify kernel date
|
||||
more /proc/mtd # verify mtd3 is listed
|
||||
|
||||
# step 4: verify kernel copied properly
|
||||
ls -lrt
|
||||
|
||||
# step 5: erase flash
|
||||
flash_eraseall /dev/mtd1
|
||||
|
||||
# step 6: copy new image to kernel drive
|
||||
cat uImage.lzma > /dev/mtd1
|
||||
|
||||
# step 7:
|
||||
sync
|
||||
|
||||
# step 8:
|
||||
reboot
|
||||
|
||||
# step 9: verification
|
||||
telnet bchipxxx
|
||||
uname -a # verify kernel date
|
||||
more /proc/mtd # verify mtd3 is listed
|
||||
|
||||
|
||||
Last Resort using USB Blaster
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -45,7 +45,6 @@ int main() {
|
||||
|
||||
for (const auto &cmd : commands) {
|
||||
std::ostringstream os;
|
||||
std::cout << cmd << '\n';
|
||||
proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os);
|
||||
|
||||
auto tmp = os.str().erase(0, cmd.size());
|
||||
|
@ -136,7 +136,7 @@ can use dir()
|
||||
'__str__', '__subclasshook__', '_adc_register', '_frozen',
|
||||
'_register', 'acquire', 'adcclk', 'adcphase', 'adcpipeline',
|
||||
'adcreg', 'asamples', 'auto_comp_disable', 'clearAcquiringFlag',
|
||||
'clearBit', 'clearROI', 'client_version', 'config',
|
||||
'clearBit', 'clearROI', 'client_version', 'config', 'copyDetectorServer',
|
||||
'counters', 'daclist', 'dacvalues', 'dbitclk', 'dbitphase' ...
|
||||
|
||||
Since the list for Detector is rather long it's an good idea to filter it.
|
||||
|
@ -5,42 +5,17 @@ Detector Server Upgrade
|
||||
|
||||
**Location:** slsDetectorPackage/serverBin/ folder for every release.
|
||||
|
||||
.. note ::
|
||||
|
||||
For Mythen3, Gotthard2 and Eiger, you need to add scripts to automatically start detector server upon power on. See :ref:`Automatic start<Automatic start servers>` for more details.
|
||||
|
||||
.. note ::
|
||||
|
||||
Eiger requires a manual reboot. Or killall the servers and restart the new linked one. If you are in the process of updating firmware, then don't reboot yet.
|
||||
|
||||
|
||||
From 6.1.1 and above (no tftp required)
|
||||
---------------------------------------
|
||||
|
||||
#. Program from console
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# the following command copies new server, creates a soft link to xxxDetectorServerxxx
|
||||
# [Jungfrau][CTB][Moench] also deletes the old server binary and edits initttab to respawn server on reboot
|
||||
# Then, the detector controller will reboot (except Eiger)
|
||||
sls_detector_put updatedetectorserver /complete-path-to-binary/xxxDetectorServerxxx
|
||||
|
||||
#. Copy the detector server specific config files or any others required to the detector:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sls_detector_put execcommand "tftp pcxxx -r configxxx -g"
|
||||
|
||||
5.0.0 - 6.1.1
|
||||
--------------
|
||||
|
||||
#. Install tftp and copy detector server binary to tftp folder
|
||||
#. Program from console
|
||||
|
||||
.. note ::
|
||||
|
||||
These instructions are for upgrades from v5.0.0. For earlier versions, contact us.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# the following command copies new server from pc tftp folder, creates a soft link to xxxDetectorServerxxx
|
||||
# copies new server from pc tftp folder, creates a soft link to xxxDetectorServerxxx
|
||||
# [Jungfrau][CTB][Moench] also edits initttab to respawn server on reboot
|
||||
# Then, the detector controller will reboot (except Eiger)
|
||||
sls_detector_put copydetectorserver xxxDetectorServerxxx pcxxx
|
||||
@ -52,15 +27,18 @@ From 6.1.1 and above (no tftp required)
|
||||
sls_detector_put execcommand "tftp pcxxx -r configxxx -g"
|
||||
|
||||
|
||||
Troubleshooting with tftp
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
.. note ::
|
||||
|
||||
For Mythen3, Gotthard2 and Eiger, you need to add scripts to automatically start detector server upon power on. See :ref:`Automatic start<Automatic start servers>` for more details.
|
||||
|
||||
.. note ::
|
||||
|
||||
Eiger requires a manual reboot. Or killall the servers and restart the new linked one. If you are in the process of updating firmware, then don't reboot yet.
|
||||
|
||||
|
||||
Errors
|
||||
------
|
||||
|
||||
#. tftp write error: There is no space left. Please delete some old binaries and try again.
|
||||
|
||||
#. text file busy: You are trying to copy the same server.
|
||||
|
||||
|
||||
Older than 5.0.0
|
||||
-----------------
|
||||
|
||||
Please contact us.
|
||||
#. text file busy: You are trying to copy the same server.
|
@ -247,19 +247,6 @@ Possible causes could be the following:
|
||||
* For Jungfrau, refer to :ref:`Jungfrau Power Supply Troubleshooting<Jungfrau Troubleshooting Power Supply>`.
|
||||
|
||||
|
||||
Cannot ping module (Nios)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
If you executed "reboot" command on the board, you cannot ping it anymore unless you power cycle. To reboot the controller, please use the software command ("rebootcontroller"), which talks to the microcontroller.
|
||||
|
||||
Gotthard2
|
||||
---------
|
||||
|
||||
Cannot get data without a module attached
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
You cannot get data without a module attached as a specific pin is floating. Attach module to get data.
|
||||
|
||||
|
||||
Gotthard
|
||||
----------
|
||||
|
@ -3,33 +3,33 @@
|
||||
### edit with hostname or IP address of your detector
|
||||
############################################
|
||||
#hostname bchip181+
|
||||
hostname bchip119.psi.ch
|
||||
hostname bchip181+
|
||||
|
||||
#############################################
|
||||
### edit with hostname or 1Gbs IP address of your server
|
||||
############################################
|
||||
rx_hostname mpc2011:1777
|
||||
rx_hostname mpc2011
|
||||
|
||||
#############################################
|
||||
### edit with 10 Gbs IP of your server
|
||||
############################################
|
||||
udp_dstip 10.1.2.102
|
||||
udp_dstip 10.1.1.102
|
||||
#############################################
|
||||
### edit with any number in the subnet of your server (first 3 numbers as above)
|
||||
############################################
|
||||
udp_srcip 10.1.2.19
|
||||
udp_dstport 32000
|
||||
udp_srcip 10.1.1.19
|
||||
udp_dstport 32411
|
||||
|
||||
#############################################
|
||||
### edit with 10 Gbs IP of your server
|
||||
############################################
|
||||
rx_zmqip 10.1.2.102
|
||||
rx_zmqport 77000
|
||||
rx_zmqip 10.1.1.102
|
||||
rx_zmqport 50003
|
||||
#############################################
|
||||
### edit with 1 Gbs IP of PC where you will run the GUI
|
||||
############################################
|
||||
zmqip 129.129.202.132
|
||||
zmqport 77001
|
||||
zmqip 129.129.202.98
|
||||
zmqport 50001
|
||||
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ rx_zmqstream 1
|
||||
|
||||
|
||||
|
||||
frames 1000
|
||||
frames 100000
|
||||
period 0.0006
|
||||
exptime 0.00035
|
||||
|
||||
@ -62,9 +62,3 @@ highvoltage 90
|
||||
#adcreg 0x14 0x40
|
||||
|
||||
|
||||
|
||||
frames 10
|
||||
period 0.1
|
||||
rx_jsonpara subframes 1
|
||||
rx_jsonpara frameMode raw
|
||||
rx_jsonpara detectorMode analog
|
||||
|
5868
libs/catch/catch.hpp
5868
libs/catch/catch.hpp
File diff suppressed because it is too large
Load Diff
Submodule libs/pybind11 updated: 914c06fb25...8de7772cc7
27
libzmq-pkg-config/FindZeroMQ.cmake
Executable file
27
libzmq-pkg-config/FindZeroMQ.cmake
Executable file
@ -0,0 +1,27 @@
|
||||
#From: https://github.com/zeromq/cppzmq/
|
||||
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(PC_LIBZMQ QUIET libzmq)
|
||||
|
||||
set(ZeroMQ_VERSION ${PC_LIBZMQ_VERSION})
|
||||
find_library(ZeroMQ_LIBRARY NAMES libzmq.so libzmq.dylib libzmq.dll
|
||||
PATHS ${PC_LIBZMQ_LIBDIR} ${PC_LIBZMQ_LIBRARY_DIRS})
|
||||
find_library(ZeroMQ_STATIC_LIBRARY NAMES libzmq-static.a libzmq.a libzmq.dll.a
|
||||
PATHS ${PC_LIBZMQ_LIBDIR} ${PC_LIBZMQ_LIBRARY_DIRS})
|
||||
|
||||
if(ZeroMQ_LIBRARY OR ZeroMQ_STATIC_LIBRARY)
|
||||
set(ZeroMQ_FOUND ON)
|
||||
endif()
|
||||
|
||||
if (TARGET libzmq)
|
||||
# avoid errors defining targets twice
|
||||
return()
|
||||
endif()
|
||||
|
||||
add_library(libzmq SHARED IMPORTED)
|
||||
set_property(TARGET libzmq PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PC_LIBZMQ_INCLUDE_DIRS})
|
||||
set_property(TARGET libzmq PROPERTY IMPORTED_LOCATION ${ZeroMQ_LIBRARY})
|
||||
|
||||
add_library(libzmq-static STATIC IMPORTED ${PC_LIBZMQ_INCLUDE_DIRS})
|
||||
set_property(TARGET libzmq-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PC_LIBZMQ_INCLUDE_DIRS})
|
||||
set_property(TARGET libzmq-static PROPERTY IMPORTED_LOCATION ${ZeroMQ_STATIC_LIBRARY})
|
@ -13,11 +13,11 @@ import subprocess
|
||||
|
||||
from parse import remove_comments
|
||||
|
||||
allow_bitwise_op = ["M3_GainCaps"]
|
||||
allow_bitwise_op = ["streamingInterface"]
|
||||
|
||||
allow_bitwise_op = ["streamingInterface", "M3_GainCaps"]
|
||||
|
||||
op_key = {"operator|": "|",
|
||||
"operator&" : "&"}
|
||||
op_key = {"operator|": "__or__",
|
||||
"operator&" : "__and__"}
|
||||
|
||||
def single_line_enum(line):
|
||||
sub = line[line.find('{')+1:line.find('}')]
|
||||
@ -92,7 +92,8 @@ def generate_enum_string(enums):
|
||||
|
||||
#Here add the operators
|
||||
for op in operators:
|
||||
data.append(f"\n\t.def(py::self {op_key[op]} slsDetectorDefs::{key}())")
|
||||
data.append(f"\n\t.def(\"{op_key[op]}\", py::overload_cast< const slsDetectorDefs::streamingInterface&, const slsDetectorDefs::streamingInterface&>(&{op}))")
|
||||
|
||||
|
||||
data.append(';\n\n')
|
||||
return ''.join(data)
|
||||
|
@ -6,57 +6,49 @@ sls::Detector class. The tool needs the libclang bindings
|
||||
to be installed.
|
||||
|
||||
When the Detector API is updated this file should be run
|
||||
manually.
|
||||
manually
|
||||
"""
|
||||
from clang import cindex
|
||||
import subprocess
|
||||
import argparse
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
from parse import system_include_paths, clang_format_version
|
||||
|
||||
REDC = '\033[91m'
|
||||
GREENC = '\033[92m'
|
||||
ENDC = '\033[0m'
|
||||
def red(msg):
|
||||
return f'{REDC}{msg}{ENDC}'
|
||||
|
||||
def green(msg):
|
||||
return f'{GREENC}{msg}{ENDC}'
|
||||
|
||||
def check_clang_format_version(required_version):
|
||||
if (ver := clang_format_version()) != required_version:
|
||||
msg = red(f'Clang format version {required_version} required, detected: {ver}. Bye!')
|
||||
print(msg)
|
||||
sys.exit(1)
|
||||
else:
|
||||
msg = green(f'Found clang-format version {ver}')
|
||||
print(msg)
|
||||
|
||||
def check_for_compile_commands_json(path):
|
||||
# print(f"Looking for compile data base in: {path}")
|
||||
compile_data_base_file = path/'compile_commands.json'
|
||||
if not compile_data_base_file.exists():
|
||||
msg = red(f"No compile_commands.json file found in {path}. Bye!")
|
||||
print(msg)
|
||||
sys.exit(1)
|
||||
else:
|
||||
msg = green(f'Found: {compile_data_base_file}')
|
||||
print(msg)
|
||||
|
||||
from parse import system_include_paths
|
||||
|
||||
default_build_path = "/home/l_frojdh/sls/build/"
|
||||
fpath = "../../slsDetectorSoftware/src/Detector.cpp"
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"-p",
|
||||
"--build_path",
|
||||
help="Path to the build database",
|
||||
type=str,
|
||||
default=default_build_path,
|
||||
)
|
||||
cargs = parser.parse_args()
|
||||
|
||||
db = cindex.CompilationDatabase.fromDirectory(cargs.build_path)
|
||||
index = cindex.Index.create()
|
||||
args = db.getCompileCommands(fpath)
|
||||
args = list(iter(args).__next__().arguments)[0:-1]
|
||||
args = args + "-x c++ --std=c++11".split()
|
||||
syspath = system_include_paths("clang++")
|
||||
incargs = ["-I" + inc for inc in syspath]
|
||||
args = args + incargs
|
||||
|
||||
|
||||
tu = index.parse(fpath, args=args)
|
||||
|
||||
|
||||
m = []
|
||||
ag = []
|
||||
|
||||
lines = []
|
||||
|
||||
ag2 = []
|
||||
|
||||
cn = []
|
||||
|
||||
def get_arguments(node):
|
||||
@ -74,7 +66,7 @@ def get_arguments_with_default(node):
|
||||
args = []
|
||||
for arg in node.get_arguments():
|
||||
tokens = [t.spelling for t in arg.get_tokens()]
|
||||
# print(tokens)
|
||||
print(tokens)
|
||||
if '=' in tokens:
|
||||
if arg.type.spelling == "sls::Positions": #TODO! automate
|
||||
args.append("py::arg() = Positions{}")
|
||||
@ -119,67 +111,33 @@ def visit(node):
|
||||
lines.append(
|
||||
f'.def("{child.spelling}",{fs} &Detector::{child.spelling}{args})'
|
||||
)
|
||||
if cargs.verbose:
|
||||
print(f'&Detector::{child.spelling}{args})')
|
||||
cn.append(child)
|
||||
for child in node.get_children():
|
||||
visit(child)
|
||||
|
||||
# .def("setRxHostname",
|
||||
# (void (Detector::*)(const std::string &, Positions)) &
|
||||
# Detector::setRxHostname,
|
||||
# py::arg(), py::arg() = Positions{})
|
||||
# .def("setRxHostname",
|
||||
# (void (Detector::*)(const std::vector<std::string> &)) &
|
||||
# Detector::setRxHostname,
|
||||
# py::arg())
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"-p",
|
||||
"--build_path",
|
||||
help="Path to the build database",
|
||||
type=Path,
|
||||
default=default_build_path,
|
||||
)
|
||||
parser.add_argument(
|
||||
"-v",
|
||||
"--verbose",
|
||||
help="more output",
|
||||
action='store_true',
|
||||
)
|
||||
cargs = parser.parse_args()
|
||||
|
||||
check_clang_format_version(12)
|
||||
check_for_compile_commands_json(cargs.build_path)
|
||||
|
||||
print("Parsing functions in Detector.h - ", end = "", flush = True)
|
||||
t0 = time.perf_counter()
|
||||
#parse functions
|
||||
db = cindex.CompilationDatabase.fromDirectory(cargs.build_path)
|
||||
index = cindex.Index.create()
|
||||
args = db.getCompileCommands(fpath)
|
||||
args = list(iter(args).__next__().arguments)[0:-1]
|
||||
args = args + "-x c++ --std=c++11".split()
|
||||
syspath = system_include_paths("clang++")
|
||||
incargs = ["-I" + inc for inc in syspath]
|
||||
args = args + incargs
|
||||
tu = index.parse(fpath, args=args)
|
||||
visit(tu.cursor)
|
||||
print(green('OK'))
|
||||
print(f'Parsing took {time.perf_counter()-t0:.3f}s')
|
||||
visit(tu.cursor)
|
||||
|
||||
print("Read detector_in.cpp - ", end = "")
|
||||
with open("../src/detector_in.cpp") as f:
|
||||
data = f.read()
|
||||
s = "".join(lines)
|
||||
s += ";"
|
||||
text = data.replace("[[FUNCTIONS]]", s)
|
||||
warning = "/* WARINING This file is auto generated any edits might be overwritten without warning */\n\n"
|
||||
print(green("OK"))
|
||||
print("Writing to detector.cpp - ", end = "")
|
||||
with open("../src/detector.cpp", "w") as f:
|
||||
f.write(warning)
|
||||
f.write(text)
|
||||
print(green('OK'))
|
||||
|
||||
# run clang format on the output
|
||||
print('Running clang format on generated source -', end = "")
|
||||
subprocess.run(["clang-format", "../src/detector.cpp", "-i"])
|
||||
print(green(" OK"))
|
||||
with open("../src/detector_in.cpp") as f:
|
||||
data = f.read()
|
||||
s = "".join(lines)
|
||||
s += ";"
|
||||
text = data.replace("[[FUNCTIONS]]", s)
|
||||
warning = "/* WARINING This file is auto generated any edits might be overwritten without warning */\n\n"
|
||||
with open("../src/detector.cpp", "w") as f:
|
||||
f.write(warning)
|
||||
f.write(text)
|
||||
|
||||
# run clang format on the output
|
||||
subprocess.run(["clang-format", "../src/detector.cpp", "-i"])
|
||||
|
||||
print("Changes since last commit:")
|
||||
subprocess.run(['git', 'diff', '../src/detector.cpp'])
|
||||
|
@ -5,12 +5,6 @@ import subprocess
|
||||
from subprocess import PIPE
|
||||
import os
|
||||
|
||||
def clang_format_version():
|
||||
p = subprocess.run(['clang-format', '--version'], capture_output = True)
|
||||
ver = p.stdout.decode().split()[2]
|
||||
major = int(ver.split('.')[0])
|
||||
return major
|
||||
|
||||
|
||||
def remove_comments(text):
|
||||
def replacer(match):
|
||||
|
@ -1,45 +1,43 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
from .detector import Detector, freeze
|
||||
from .detector import Detector
|
||||
from .utils import element_if_equal
|
||||
from .dacs import DetectorDacs, NamedDacs
|
||||
from .dacs import DetectorDacs
|
||||
import _slsdet
|
||||
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
||||
from .detector_property import DetectorProperty
|
||||
|
||||
# class CtbDacs(DetectorDacs):
|
||||
# """
|
||||
# Ctb dacs
|
||||
# """
|
||||
# _dacs = [('dac0', dacIndex(0), 0, 4000, 1400),
|
||||
# ('dac1', dacIndex(1), 0, 4000, 1200),
|
||||
# ('dac2', dacIndex(2), 0, 4000, 900),
|
||||
# ('dac3', dacIndex(3), 0, 4000, 1050),
|
||||
# ('dac4', dacIndex(4), 0, 4000, 1400),
|
||||
# ('dac5', dacIndex(5), 0, 4000, 655),
|
||||
# ('dac6', dacIndex(6), 0, 4000, 2000),
|
||||
# ('dac7', dacIndex(7), 0, 4000, 1400),
|
||||
# ('dac8', dacIndex(8), 0, 4000, 850),
|
||||
# ('dac9', dacIndex(9), 0, 4000, 2000),
|
||||
# ('dac10', dacIndex(10), 0, 4000, 2294),
|
||||
# ('dac11', dacIndex(11), 0, 4000, 983),
|
||||
# ('dac12', dacIndex(12), 0, 4000, 1475),
|
||||
# ('dac13', dacIndex(13), 0, 4000, 1200),
|
||||
# ('dac14', dacIndex(14), 0, 4000, 1600),
|
||||
# ('dac15', dacIndex(15), 0, 4000, 1455),
|
||||
# ('dac16', dacIndex(16), 0, 4000, 0),
|
||||
# ('dac17', dacIndex(17), 0, 4000, 1000),
|
||||
# ]
|
||||
# _dacnames = [_d[0] for _d in _dacs]
|
||||
class CtbDacs(DetectorDacs):
|
||||
"""
|
||||
Ctb dacs
|
||||
"""
|
||||
_dacs = [('dac0', dacIndex(0), 0, 4000, 1400),
|
||||
('dac1', dacIndex(1), 0, 4000, 1200),
|
||||
('dac2', dacIndex(2), 0, 4000, 900),
|
||||
('dac3', dacIndex(3), 0, 4000, 1050),
|
||||
('dac4', dacIndex(4), 0, 4000, 1400),
|
||||
('dac5', dacIndex(5), 0, 4000, 655),
|
||||
('dac6', dacIndex(6), 0, 4000, 2000),
|
||||
('dac7', dacIndex(7), 0, 4000, 1400),
|
||||
('dac8', dacIndex(8), 0, 4000, 850),
|
||||
('dac9', dacIndex(9), 0, 4000, 2000),
|
||||
('dac10', dacIndex(10), 0, 4000, 2294),
|
||||
('dac11', dacIndex(11), 0, 4000, 983),
|
||||
('dac12', dacIndex(12), 0, 4000, 1475),
|
||||
('dac13', dacIndex(13), 0, 4000, 1200),
|
||||
('dac14', dacIndex(14), 0, 4000, 1600),
|
||||
('dac15', dacIndex(15), 0, 4000, 1455),
|
||||
('dac16', dacIndex(16), 0, 4000, 0),
|
||||
('dac17', dacIndex(17), 0, 4000, 1000),
|
||||
]
|
||||
_dacnames = [_d[0] for _d in _dacs]
|
||||
|
||||
from .utils import element
|
||||
@freeze
|
||||
class Ctb(Detector):
|
||||
def __init__(self, id = 0):
|
||||
super().__init__(id)
|
||||
self._frozen = False
|
||||
# self._dacs = CtbDacs(self)
|
||||
self._dacs = NamedDacs(self)
|
||||
self._dacs = CtbDacs(self)
|
||||
|
||||
@property
|
||||
def dacs(self):
|
||||
|
@ -36,79 +36,6 @@ class Dac(DetectorProperty):
|
||||
dacstr = ''.join([f'{item:5d}' for item in self.get()])
|
||||
return f'{self.__name__:15s}:{dacstr}'
|
||||
|
||||
class NamedDacs:
|
||||
"""
|
||||
New implementation of the detector dacs. Used at the momen for
|
||||
Ctb but should replace the old one for all detectors
|
||||
"""
|
||||
_frozen = False
|
||||
_direct_access = ['_detector', '_current', '_dacnames']
|
||||
def __init__(self, detector):
|
||||
self._detector = detector
|
||||
self._current = 0
|
||||
|
||||
self._dacnames = [n.replace(" ", "") for n in detector.getDacNames()]
|
||||
# # Populate the dacs
|
||||
for i,name in enumerate(self._dacnames):
|
||||
#name, enum, low, high, default, detector
|
||||
setattr(self, name, Dac(name, dacIndex(i), 0, 4000, 1000, detector))
|
||||
|
||||
self._frozen = True
|
||||
|
||||
# def __getattr__(self, name):
|
||||
# return self.__getattribute__('_' + name)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if not self._frozen:
|
||||
#durining init we need to be able to set up the class
|
||||
super().__setattr__(name, value)
|
||||
else:
|
||||
#Later we restrict us to manipulate dacs and a few fields
|
||||
if name in self._direct_access:
|
||||
super().__setattr__(name, value)
|
||||
elif name in self._dacnames:
|
||||
return self.__getattribute__(name).__setitem__(slice(None, None, None), value)
|
||||
else:
|
||||
raise AttributeError(f'Dac not found: {name}')
|
||||
|
||||
def __next__(self):
|
||||
if self._current >= len(self._dacnames):
|
||||
self._current = 0
|
||||
raise StopIteration
|
||||
else:
|
||||
self._current += 1
|
||||
return self.__getattribute__(self._dacnames[self._current-1])
|
||||
# return self.__getattr__(self._dacnames[self._current-1])
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def __repr__(self):
|
||||
r_str = ['========== DACS =========']
|
||||
r_str += [repr(dac) for dac in self]
|
||||
return '\n'.join(r_str)
|
||||
def get_asarray(self):
|
||||
"""
|
||||
Read the dacs into a numpy array with dimensions [ndacs, nmodules]
|
||||
"""
|
||||
dac_array = np.zeros((len(self._dacnames), len(self._detector)))
|
||||
for i, _d in enumerate(self):
|
||||
dac_array[i,:] = _d[:]
|
||||
return dac_array
|
||||
|
||||
def to_array(self):
|
||||
return self.get_asarray()
|
||||
|
||||
def set_from_array(self, dac_array):
|
||||
"""
|
||||
Set the dacs from an numpy array with dac values. [ndacs, nmodules]
|
||||
"""
|
||||
dac_array = dac_array.astype(np.int)
|
||||
for i, _d in enumerate(self):
|
||||
_d[:] = dac_array[i]
|
||||
|
||||
def from_array(self, dac_array):
|
||||
self.set_from_array(dac_array)
|
||||
|
||||
class DetectorDacs:
|
||||
_dacs = []
|
||||
@ -123,7 +50,7 @@ class DetectorDacs:
|
||||
# Index to support iteration
|
||||
self._current = 0
|
||||
|
||||
# Name the attributes?
|
||||
# Populate the dacs
|
||||
for _d in self._dacs:
|
||||
setattr(self, '_'+_d[0], Dac(*_d, detector))
|
||||
|
||||
@ -132,10 +59,7 @@ class DetectorDacs:
|
||||
def __getattr__(self, name):
|
||||
return self.__getattribute__('_' + name)
|
||||
|
||||
@property
|
||||
def dacnames(self):
|
||||
return [_d[0] for _d in _dacs]
|
||||
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if name in self._dacnames:
|
||||
return self.__getattribute__('_' + name).__setitem__(slice(None, None, None), value)
|
||||
|
@ -224,19 +224,6 @@ class Detector(CppDetectorApi):
|
||||
"""
|
||||
return ut.lhex(self.getDetectorServerVersion())
|
||||
|
||||
@property
|
||||
@element
|
||||
def kernelversion(self):
|
||||
"""
|
||||
Kernel version on the detector including time and date
|
||||
|
||||
Example
|
||||
-------
|
||||
>>> d.kernelversion
|
||||
'#37 PREEMPT Thu Oct 13 14:51:04 CEST 2016'
|
||||
"""
|
||||
return self.getKernelVersion()
|
||||
|
||||
@property
|
||||
def clientversion(self):
|
||||
"""Client software version in format [YYMMDD]
|
||||
@ -258,7 +245,7 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def rx_threads(self):
|
||||
"""
|
||||
Get thread ids from the receiver in order of [parent, tcp, listener 0, processor 0, streamer 0, listener 1, processor 1, streamer 1, arping].
|
||||
Get thread ids from the receiver in order of [parent, tcp, listener 0, processor 0, streamer 0, listener 1, processor 1, streamer 1].
|
||||
|
||||
Note
|
||||
-----
|
||||
@ -268,17 +255,6 @@ class Detector(CppDetectorApi):
|
||||
"""
|
||||
return self.getRxThreadIds()
|
||||
|
||||
@property
|
||||
@element
|
||||
def rx_arping(self):
|
||||
"""Starts a thread in slsReceiver to arping the interface it is listening every minute. Useful in 10G mode. """
|
||||
return self.getRxArping()
|
||||
|
||||
@rx_arping.setter
|
||||
def rx_arping(self, value):
|
||||
ut.set_using_dict(self.setRxArping, value)
|
||||
|
||||
|
||||
@property
|
||||
@element
|
||||
def dr(self):
|
||||
@ -287,7 +263,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
Note
|
||||
-----
|
||||
[Eiger] Options: 4, 8, 12, 16, 32. If set to 32, also sets clkdivider to 2 (quarter speed), else to 0 (full speed)\n
|
||||
[Eiger] Options: 4, 8, 16, 32. If set to 32, also sets clkdivider to 2 (quarter speed), else to 0 (full speed)\n
|
||||
[Mythen3] Options: 8, 16, 32 \n
|
||||
[Jungfrau][Gotthard][Ctb][Moench][Mythen3][Gotthard2] 16
|
||||
"""
|
||||
@ -599,13 +575,13 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def rx_framescaught(self):
|
||||
"""Number of frames caught by each port in receiver."""
|
||||
"""Number of frames caught by receiver."""
|
||||
return self.getFramesCaught()
|
||||
|
||||
@property
|
||||
@element
|
||||
def nextframenumber(self):
|
||||
"""[Eiger][Jungfrau][Moench][CTB] Next frame number. Stopping acquisition might result in different frame numbers for different modules. """
|
||||
"""[Eiger][Jungfrau] Next frame number. Stopping acquisition might result in different frame numbers for different modules. """
|
||||
return self.getNextFrameNumber()
|
||||
|
||||
@nextframenumber.setter
|
||||
@ -1474,19 +1450,6 @@ class Detector(CppDetectorApi):
|
||||
def trimval(self, value):
|
||||
ut.set_using_dict(self.setAllTrimbits, value)
|
||||
|
||||
@property
|
||||
@element
|
||||
def master(self):
|
||||
"""
|
||||
[Eiger] Sets half module to master and others to slaves.\n
|
||||
[Gotthard][Gotthard2][Mythen3][Eiger] Gets if the current module/ half module is master.
|
||||
"""
|
||||
return self.getMaster()
|
||||
|
||||
@master.setter
|
||||
def master(self, value):
|
||||
ut.set_using_dict(self.setMaster, value)
|
||||
|
||||
@property
|
||||
@element
|
||||
def lock(self):
|
||||
@ -1571,16 +1534,8 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@property
|
||||
def daclist(self):
|
||||
"""
|
||||
List of enums for every dac for this detector.
|
||||
:setter: Only implemented for Chiptestboard
|
||||
|
||||
"""
|
||||
return self.getDacNames()
|
||||
|
||||
@daclist.setter
|
||||
def daclist(self, value):
|
||||
self.setDacNames(value)
|
||||
"""Gets the list of enums for every dac for this detector."""
|
||||
return self.getDacList()
|
||||
|
||||
@property
|
||||
def dacvalues(self):
|
||||
@ -1701,7 +1656,6 @@ class Detector(CppDetectorApi):
|
||||
'client': self.clientversion,
|
||||
'firmware': self.firmwareversion,
|
||||
'detectorserver': self.detectorserverversion,
|
||||
'kernel': self.kernelversion,
|
||||
'receiver': self.rx_version}
|
||||
|
||||
@property
|
||||
@ -1926,13 +1880,13 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def rx_frameindex(self):
|
||||
"""Current frame index received for each port in receiver during acquisition."""
|
||||
"""Current frame index received in receiver during acquisition."""
|
||||
return self.getRxCurrentFrameIndex()
|
||||
|
||||
@property
|
||||
@element
|
||||
def rx_missingpackets(self):
|
||||
"""Gets the number of missing packets for each port in receiver. Negative number denotes extra packets. """
|
||||
"""Gets the number of missing packets for each port in receiver."""
|
||||
return self.getNumMissingPackets()
|
||||
|
||||
"""
|
||||
@ -1945,7 +1899,7 @@ class Detector(CppDetectorApi):
|
||||
def datastream(self):
|
||||
"""
|
||||
datastream [left|right] [0, 1]
|
||||
[Eiger] Enables or disables data streaming from left or/and right side of detector for 10GbE mode. 1 (enabled) by default.
|
||||
[Eiger] Enables or disables data streaming from left or/and right side of detector. 1 (enabled) by default.
|
||||
"""
|
||||
result = {}
|
||||
for port in [defs.LEFT, defs.RIGHT]:
|
||||
@ -2147,21 +2101,6 @@ class Detector(CppDetectorApi):
|
||||
"""
|
||||
return ut.reduce_time(self.getMeasuredSubFramePeriod())
|
||||
|
||||
@property
|
||||
@element
|
||||
def top(self):
|
||||
"""[Eiger] Sets half module to top (1), else bottom.
|
||||
|
||||
Note
|
||||
-----
|
||||
Advanced Function!
|
||||
"""
|
||||
return self.getTop()
|
||||
|
||||
@top.setter
|
||||
def top(self, value):
|
||||
ut.set_using_dict(self.setTop, value)
|
||||
|
||||
"""
|
||||
------------------<<<Jungfrau specific>>>-------------------------
|
||||
"""
|
||||
@ -2562,7 +2501,6 @@ class Detector(CppDetectorApi):
|
||||
-----
|
||||
|
||||
:getter: always returns in seconds. To get in datetime.delta, use getBurstPeriod
|
||||
:setter: Not Implemented
|
||||
|
||||
Example
|
||||
-----------
|
||||
@ -3066,7 +3004,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patsetbit(self):
|
||||
"""[Ctb][Moench][Mythen3] Sets the mask applied to every pattern to the selected bits.
|
||||
"""[Ctb][Moench][Mythen3] Selects the bits that will have a pattern mask applied to the selected patmask for every pattern.
|
||||
|
||||
Example
|
||||
--------
|
||||
@ -3083,7 +3021,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def patmask(self):
|
||||
"""[Ctb][Moench][Mythen3] Selects the bits that will have a pattern mask applied to the selected patmask for every pattern.
|
||||
"""[Ctb][Moench][Mythen3] Sets the mask applied to every pattern to the selected bits.
|
||||
|
||||
Example
|
||||
--------
|
||||
@ -3484,10 +3422,10 @@ class Detector(CppDetectorApi):
|
||||
[Gotthard2][Mythen3] Frequency of clock in Hz.
|
||||
|
||||
Note
|
||||
----
|
||||
-----
|
||||
|
||||
:setter: Not implemented. Use clkdiv to set frequency
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
>>> d.clkfreq[0]
|
||||
@ -3498,60 +3436,10 @@ class Detector(CppDetectorApi):
|
||||
|
||||
def readout(self):
|
||||
"""
|
||||
[Mythen3] Starts detector readout. Status changes to TRANSMITTING and automatically returns to idle at the end of readout.
|
||||
Mythen3] Starts detector readout. Status changes to TRANSMITTING and automatically returns to idle at the end of readout.
|
||||
"""
|
||||
self.startDetectorReadout()
|
||||
|
||||
@property
|
||||
@element
|
||||
def polarity(self):
|
||||
"""[Mythen3] Set positive or negative polarity. Enum: polarity"""
|
||||
return self.getPolarity()
|
||||
|
||||
@polarity.setter
|
||||
def polarity(self, value):
|
||||
ut.set_using_dict(self.setPolarity, value)
|
||||
|
||||
@property
|
||||
@element
|
||||
def interpolation(self):
|
||||
"""[Mythen3] Enable or disable interpolation. Enabling also enables all counters """
|
||||
return self.getInterpolation()
|
||||
|
||||
@interpolation.setter
|
||||
def interpolation(self, value):
|
||||
ut.set_using_dict(self.setInterpolation, value)
|
||||
|
||||
@property
|
||||
@element
|
||||
def pumpprobe(self):
|
||||
"""[Mythen3] Enable or disable pump probe mode. """
|
||||
return self.getPumpProbe()
|
||||
|
||||
@pumpprobe.setter
|
||||
def pumpprobe(self, value):
|
||||
ut.set_using_dict(self.setPumpProbe, value)
|
||||
|
||||
@property
|
||||
@element
|
||||
def apulse(self):
|
||||
"""[Mythen3] Enable or disable analog pulsing. """
|
||||
return self.getAnalogPulsing()
|
||||
|
||||
@apulse.setter
|
||||
def apulse(self, value):
|
||||
ut.set_using_dict(self.setAnalogPulsing, value)
|
||||
|
||||
@property
|
||||
@element
|
||||
def dpulse(self):
|
||||
"""[Mythen3] Enable or disable digital pulsing. """
|
||||
return self.getDigitalPulsing()
|
||||
|
||||
@dpulse.setter
|
||||
def dpulse(self, value):
|
||||
ut.set_using_dict(self.setDigitalPulsing, value)
|
||||
|
||||
|
||||
"""
|
||||
---------------------------<<<Debug>>>---------------------------
|
||||
|
@ -1,8 +1,8 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
/* WARINING This file is auto generated any edits might be overwritten without
|
||||
* warning */
|
||||
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include <pybind11/chrono.h>
|
||||
#include <pybind11/operators.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
@ -67,10 +67,6 @@ void init_det(py::module &m) {
|
||||
(Result<int64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getDetectorServerVersion,
|
||||
py::arg() = Positions{})
|
||||
.def("getKernelVersion",
|
||||
(Result<std::string>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getKernelVersion,
|
||||
py::arg() = Positions{})
|
||||
.def("getSerialNumber",
|
||||
(Result<int64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getSerialNumber,
|
||||
@ -173,12 +169,6 @@ void init_det(py::module &m) {
|
||||
.def("setFlipRows",
|
||||
(void (Detector::*)(bool, sls::Positions)) & Detector::setFlipRows,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getMaster",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getMaster,
|
||||
py::arg() = Positions{})
|
||||
.def("setMaster", (void (Detector::*)(bool, int)) & Detector::setMaster,
|
||||
py::arg(), py::arg())
|
||||
.def("isVirtualDetectorServer",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::isVirtualDetectorServer,
|
||||
@ -476,9 +466,7 @@ void init_det(py::module &m) {
|
||||
(void (Detector::*)()) & Detector::clearAcquiringFlag)
|
||||
.def("startReceiver", (void (Detector::*)()) & Detector::startReceiver)
|
||||
.def("stopReceiver", (void (Detector::*)()) & Detector::stopReceiver)
|
||||
.def("startDetector",
|
||||
(void (Detector::*)(sls::Positions)) & Detector::startDetector,
|
||||
py::arg() = Positions{})
|
||||
.def("startDetector", (void (Detector::*)()) & Detector::startDetector)
|
||||
.def("startDetectorReadout",
|
||||
(void (Detector::*)()) & Detector::startDetectorReadout)
|
||||
.def("stopDetector",
|
||||
@ -493,17 +481,14 @@ void init_det(py::module &m) {
|
||||
Detector::getReceiverStatus,
|
||||
py::arg() = Positions{})
|
||||
.def("getFramesCaught",
|
||||
(Result<std::vector<int64_t>>(Detector::*)(sls::Positions) const) &
|
||||
(Result<int64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getFramesCaught,
|
||||
py::arg() = Positions{})
|
||||
.def("getNumMissingPackets",
|
||||
(Result<std::vector<int64_t>>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getNumMissingPackets,
|
||||
py::arg() = Positions{})
|
||||
.def("getRxCurrentFrameIndex",
|
||||
(Result<std::vector<int64_t>>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getRxCurrentFrameIndex,
|
||||
py::arg() = Positions{})
|
||||
.def(
|
||||
"getNumMissingPackets",
|
||||
(Result<std::vector<uint64_t>>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getNumMissingPackets,
|
||||
py::arg() = Positions{})
|
||||
.def("getNextFrameNumber",
|
||||
(Result<uint64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getNextFrameNumber,
|
||||
@ -776,16 +761,9 @@ void init_det(py::module &m) {
|
||||
Detector::getRxLastClientIP,
|
||||
py::arg() = Positions{})
|
||||
.def("getRxThreadIds",
|
||||
(Result<std::array<pid_t, 9>>(Detector::*)(sls::Positions) const) &
|
||||
(Result<std::array<pid_t, 8>>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getRxThreadIds,
|
||||
py::arg() = Positions{})
|
||||
.def("getRxArping",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getRxArping,
|
||||
py::arg() = Positions{})
|
||||
.def("setRxArping",
|
||||
(void (Detector::*)(bool, sls::Positions)) & Detector::setRxArping,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getFileFormat",
|
||||
(Result<defs::fileFormat>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getFileFormat,
|
||||
@ -1015,13 +993,6 @@ void init_det(py::module &m) {
|
||||
sls::Positions)) &
|
||||
Detector::setDataStream,
|
||||
py::arg(), py::arg(), py::arg() = Positions{})
|
||||
.def("getTop",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getTop,
|
||||
py::arg() = Positions{})
|
||||
.def("setTop",
|
||||
(void (Detector::*)(bool, sls::Positions)) & Detector::setTop,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getChipVersion",
|
||||
(Result<double>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getChipVersion,
|
||||
@ -1280,6 +1251,10 @@ void init_det(py::module &m) {
|
||||
(Result<std::array<ns, 3>>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getGateDelayForAllGates,
|
||||
py::arg() = Positions{})
|
||||
.def("getMaster",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getMaster,
|
||||
py::arg() = Positions{})
|
||||
.def("getChipStatusRegister",
|
||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getChipStatusRegister,
|
||||
@ -1290,46 +1265,6 @@ void init_det(py::module &m) {
|
||||
.def("getGainCaps",
|
||||
(Result<int>(Detector::*)(sls::Positions)) & Detector::getGainCaps,
|
||||
py::arg() = Positions{})
|
||||
.def("getPolarity",
|
||||
(Result<defs::polarity>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getPolarity,
|
||||
py::arg() = Positions{})
|
||||
.def("setPolarity",
|
||||
(void (Detector::*)(defs::polarity, sls::Positions)) &
|
||||
Detector::setPolarity,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getInterpolation",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getInterpolation,
|
||||
py::arg() = Positions{})
|
||||
.def("setInterpolation",
|
||||
(void (Detector::*)(bool, sls::Positions)) &
|
||||
Detector::setInterpolation,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getPumpProbe",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getPumpProbe,
|
||||
py::arg() = Positions{})
|
||||
.def("setPumpProbe",
|
||||
(void (Detector::*)(bool, sls::Positions)) &
|
||||
Detector::setPumpProbe,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getAnalogPulsing",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getAnalogPulsing,
|
||||
py::arg() = Positions{})
|
||||
.def("setAnalogPulsing",
|
||||
(void (Detector::*)(bool, sls::Positions)) &
|
||||
Detector::setAnalogPulsing,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getDigitalPulsing",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getDigitalPulsing,
|
||||
py::arg() = Positions{})
|
||||
.def("setDigitalPulsing",
|
||||
(void (Detector::*)(bool, sls::Positions)) &
|
||||
Detector::setDigitalPulsing,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getNumberOfAnalogSamples",
|
||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getNumberOfAnalogSamples,
|
||||
@ -1467,19 +1402,6 @@ void init_det(py::module &m) {
|
||||
(void (Detector::*)(bool, sls::Positions)) &
|
||||
Detector::setLEDEnable,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("setDacNames",
|
||||
(void (Detector::*)(const std::vector<std::string>)) &
|
||||
Detector::setDacNames,
|
||||
py::arg())
|
||||
.def("getDacNames", (std::vector<std::string>(Detector::*)() const) &
|
||||
Detector::getDacNames)
|
||||
.def("getDacIndex",
|
||||
(defs::dacIndex(Detector::*)(const std::string &)) &
|
||||
Detector::getDacIndex,
|
||||
py::arg())
|
||||
.def("getDacName",
|
||||
(std::string(Detector::*)(defs::dacIndex)) & Detector::getDacName,
|
||||
py::arg())
|
||||
.def("setPattern",
|
||||
(void (Detector::*)(const std::string &, sls::Positions)) &
|
||||
Detector::setPattern,
|
||||
@ -1584,21 +1506,17 @@ void init_det(py::module &m) {
|
||||
Detector::setAdditionalJsonParameter,
|
||||
py::arg(), py::arg(), py::arg() = Positions{})
|
||||
.def("programFPGA",
|
||||
(void (Detector::*)(const std::string &, const bool,
|
||||
sls::Positions)) &
|
||||
(void (Detector::*)(const std::string &, sls::Positions)) &
|
||||
Detector::programFPGA,
|
||||
py::arg(), py::arg(), py::arg() = Positions{})
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("resetFPGA",
|
||||
(void (Detector::*)(sls::Positions)) & Detector::resetFPGA,
|
||||
py::arg() = Positions{})
|
||||
.def("updateDetectorServer",
|
||||
(void (Detector::*)(const std::string &, sls::Positions)) &
|
||||
Detector::updateDetectorServer,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("updateKernel",
|
||||
(void (Detector::*)(const std::string &, sls::Positions)) &
|
||||
Detector::updateKernel,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("copyDetectorServer",
|
||||
(void (Detector::*)(const std::string &, const std::string &,
|
||||
sls::Positions)) &
|
||||
Detector::copyDetectorServer,
|
||||
py::arg(), py::arg(), py::arg() = Positions{})
|
||||
.def("rebootController",
|
||||
(void (Detector::*)(sls::Positions)) & Detector::rebootController,
|
||||
py::arg() = Positions{})
|
||||
@ -1607,19 +1525,6 @@ void init_det(py::module &m) {
|
||||
const std::string &, sls::Positions)) &
|
||||
Detector::updateFirmwareAndServer,
|
||||
py::arg(), py::arg(), py::arg(), py::arg() = Positions{})
|
||||
.def("updateFirmwareAndServer",
|
||||
(void (Detector::*)(const std::string &, const std::string &,
|
||||
sls::Positions)) &
|
||||
Detector::updateFirmwareAndServer,
|
||||
py::arg(), py::arg(), py::arg() = Positions{})
|
||||
.def("getUpdateMode",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getUpdateMode,
|
||||
py::arg() = Positions{})
|
||||
.def("setUpdateMode",
|
||||
(void (Detector::*)(const bool, sls::Positions)) &
|
||||
Detector::setUpdateMode,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("readRegister",
|
||||
(Result<uint32_t>(Detector::*)(uint32_t, sls::Positions) const) &
|
||||
Detector::readRegister,
|
||||
@ -1709,5 +1614,9 @@ void init_det(py::module &m) {
|
||||
Detector::getMeasurementTime,
|
||||
py::arg() = Positions{})
|
||||
.def("getUserDetails",
|
||||
(std::string(Detector::*)() const) & Detector::getUserDetails);
|
||||
(std::string(Detector::*)() const) & Detector::getUserDetails)
|
||||
.def("getRxCurrentFrameIndex",
|
||||
(Result<uint64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getRxCurrentFrameIndex,
|
||||
py::arg() = Positions{});
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* WARINING This file is auto generated any edits might be overwritten without
|
||||
* warning */
|
||||
/* WARINING This file is auto generated any edits might be overwritten without warning */
|
||||
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
@ -43,19 +42,15 @@ void init_enums(py::module &m) {
|
||||
|
||||
py::enum_<slsDetectorDefs::frameDiscardPolicy>(Defs, "frameDiscardPolicy")
|
||||
.value("NO_DISCARD", slsDetectorDefs::frameDiscardPolicy::NO_DISCARD)
|
||||
.value("DISCARD_EMPTY_FRAMES",
|
||||
slsDetectorDefs::frameDiscardPolicy::DISCARD_EMPTY_FRAMES)
|
||||
.value("DISCARD_PARTIAL_FRAMES",
|
||||
slsDetectorDefs::frameDiscardPolicy::DISCARD_PARTIAL_FRAMES)
|
||||
.value("NUM_DISCARD_POLICIES",
|
||||
slsDetectorDefs::frameDiscardPolicy::NUM_DISCARD_POLICIES)
|
||||
.value("DISCARD_EMPTY_FRAMES", slsDetectorDefs::frameDiscardPolicy::DISCARD_EMPTY_FRAMES)
|
||||
.value("DISCARD_PARTIAL_FRAMES", slsDetectorDefs::frameDiscardPolicy::DISCARD_PARTIAL_FRAMES)
|
||||
.value("NUM_DISCARD_POLICIES", slsDetectorDefs::frameDiscardPolicy::NUM_DISCARD_POLICIES)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::fileFormat>(Defs, "fileFormat")
|
||||
.value("BINARY", slsDetectorDefs::fileFormat::BINARY)
|
||||
.value("HDF5", slsDetectorDefs::fileFormat::HDF5)
|
||||
.value("NUM_FILE_FORMATS",
|
||||
slsDetectorDefs::fileFormat::NUM_FILE_FORMATS)
|
||||
.value("NUM_FILE_FORMATS", slsDetectorDefs::fileFormat::NUM_FILE_FORMATS)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::dimension>(Defs, "dimension")
|
||||
@ -64,25 +59,19 @@ void init_enums(py::module &m) {
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::externalSignalFlag>(Defs, "externalSignalFlag")
|
||||
.value("TRIGGER_IN_RISING_EDGE",
|
||||
slsDetectorDefs::externalSignalFlag::TRIGGER_IN_RISING_EDGE)
|
||||
.value("TRIGGER_IN_FALLING_EDGE",
|
||||
slsDetectorDefs::externalSignalFlag::TRIGGER_IN_FALLING_EDGE)
|
||||
.value("INVERSION_ON",
|
||||
slsDetectorDefs::externalSignalFlag::INVERSION_ON)
|
||||
.value("INVERSION_OFF",
|
||||
slsDetectorDefs::externalSignalFlag::INVERSION_OFF)
|
||||
.value("TRIGGER_IN_RISING_EDGE", slsDetectorDefs::externalSignalFlag::TRIGGER_IN_RISING_EDGE)
|
||||
.value("TRIGGER_IN_FALLING_EDGE", slsDetectorDefs::externalSignalFlag::TRIGGER_IN_FALLING_EDGE)
|
||||
.value("INVERSION_ON", slsDetectorDefs::externalSignalFlag::INVERSION_ON)
|
||||
.value("INVERSION_OFF", slsDetectorDefs::externalSignalFlag::INVERSION_OFF)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::timingMode>(Defs, "timingMode")
|
||||
.value("AUTO_TIMING", slsDetectorDefs::timingMode::AUTO_TIMING)
|
||||
.value("TRIGGER_EXPOSURE",
|
||||
slsDetectorDefs::timingMode::TRIGGER_EXPOSURE)
|
||||
.value("TRIGGER_EXPOSURE", slsDetectorDefs::timingMode::TRIGGER_EXPOSURE)
|
||||
.value("GATED", slsDetectorDefs::timingMode::GATED)
|
||||
.value("BURST_TRIGGER", slsDetectorDefs::timingMode::BURST_TRIGGER)
|
||||
.value("TRIGGER_GATED", slsDetectorDefs::timingMode::TRIGGER_GATED)
|
||||
.value("NUM_TIMING_MODES",
|
||||
slsDetectorDefs::timingMode::NUM_TIMING_MODES)
|
||||
.value("NUM_TIMING_MODES", slsDetectorDefs::timingMode::NUM_TIMING_MODES)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::dacIndex>(Defs, "dacIndex")
|
||||
@ -170,16 +159,13 @@ void init_enums(py::module &m) {
|
||||
.value("HIGH_VOLTAGE", slsDetectorDefs::dacIndex::HIGH_VOLTAGE)
|
||||
.value("TEMPERATURE_ADC", slsDetectorDefs::dacIndex::TEMPERATURE_ADC)
|
||||
.value("TEMPERATURE_FPGA", slsDetectorDefs::dacIndex::TEMPERATURE_FPGA)
|
||||
.value("TEMPERATURE_FPGAEXT",
|
||||
slsDetectorDefs::dacIndex::TEMPERATURE_FPGAEXT)
|
||||
.value("TEMPERATURE_FPGAEXT", slsDetectorDefs::dacIndex::TEMPERATURE_FPGAEXT)
|
||||
.value("TEMPERATURE_10GE", slsDetectorDefs::dacIndex::TEMPERATURE_10GE)
|
||||
.value("TEMPERATURE_DCDC", slsDetectorDefs::dacIndex::TEMPERATURE_DCDC)
|
||||
.value("TEMPERATURE_SODL", slsDetectorDefs::dacIndex::TEMPERATURE_SODL)
|
||||
.value("TEMPERATURE_SODR", slsDetectorDefs::dacIndex::TEMPERATURE_SODR)
|
||||
.value("TEMPERATURE_FPGA2",
|
||||
slsDetectorDefs::dacIndex::TEMPERATURE_FPGA2)
|
||||
.value("TEMPERATURE_FPGA3",
|
||||
slsDetectorDefs::dacIndex::TEMPERATURE_FPGA3)
|
||||
.value("TEMPERATURE_FPGA2", slsDetectorDefs::dacIndex::TEMPERATURE_FPGA2)
|
||||
.value("TEMPERATURE_FPGA3", slsDetectorDefs::dacIndex::TEMPERATURE_FPGA3)
|
||||
.value("TRIMBIT_SCAN", slsDetectorDefs::dacIndex::TRIMBIT_SCAN)
|
||||
.value("V_POWER_A", slsDetectorDefs::dacIndex::V_POWER_A)
|
||||
.value("V_POWER_B", slsDetectorDefs::dacIndex::V_POWER_B)
|
||||
@ -218,20 +204,15 @@ void init_enums(py::module &m) {
|
||||
.value("VERYLOWGAIN", slsDetectorDefs::detectorSettings::VERYLOWGAIN)
|
||||
.value("G1_HIGHGAIN", slsDetectorDefs::detectorSettings::G1_HIGHGAIN)
|
||||
.value("G1_LOWGAIN", slsDetectorDefs::detectorSettings::G1_LOWGAIN)
|
||||
.value("G2_HIGHCAP_HIGHGAIN",
|
||||
slsDetectorDefs::detectorSettings::G2_HIGHCAP_HIGHGAIN)
|
||||
.value("G2_HIGHCAP_LOWGAIN",
|
||||
slsDetectorDefs::detectorSettings::G2_HIGHCAP_LOWGAIN)
|
||||
.value("G2_LOWCAP_HIGHGAIN",
|
||||
slsDetectorDefs::detectorSettings::G2_LOWCAP_HIGHGAIN)
|
||||
.value("G2_LOWCAP_LOWGAIN",
|
||||
slsDetectorDefs::detectorSettings::G2_LOWCAP_LOWGAIN)
|
||||
.value("G2_HIGHCAP_HIGHGAIN", slsDetectorDefs::detectorSettings::G2_HIGHCAP_HIGHGAIN)
|
||||
.value("G2_HIGHCAP_LOWGAIN", slsDetectorDefs::detectorSettings::G2_HIGHCAP_LOWGAIN)
|
||||
.value("G2_LOWCAP_HIGHGAIN", slsDetectorDefs::detectorSettings::G2_LOWCAP_HIGHGAIN)
|
||||
.value("G2_LOWCAP_LOWGAIN", slsDetectorDefs::detectorSettings::G2_LOWCAP_LOWGAIN)
|
||||
.value("G4_HIGHGAIN", slsDetectorDefs::detectorSettings::G4_HIGHGAIN)
|
||||
.value("G4_LOWGAIN", slsDetectorDefs::detectorSettings::G4_LOWGAIN)
|
||||
.value("GAIN0", slsDetectorDefs::detectorSettings::GAIN0)
|
||||
.value("UNDEFINED", slsDetectorDefs::detectorSettings::UNDEFINED)
|
||||
.value("UNINITIALIZED",
|
||||
slsDetectorDefs::detectorSettings::UNINITIALIZED)
|
||||
.value("UNINITIALIZED", slsDetectorDefs::detectorSettings::UNINITIALIZED)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::clockIndex>(Defs, "clockIndex")
|
||||
@ -244,8 +225,7 @@ void init_enums(py::module &m) {
|
||||
py::enum_<slsDetectorDefs::readoutMode>(Defs, "readoutMode")
|
||||
.value("ANALOG_ONLY", slsDetectorDefs::readoutMode::ANALOG_ONLY)
|
||||
.value("DIGITAL_ONLY", slsDetectorDefs::readoutMode::DIGITAL_ONLY)
|
||||
.value("ANALOG_AND_DIGITAL",
|
||||
slsDetectorDefs::readoutMode::ANALOG_AND_DIGITAL)
|
||||
.value("ANALOG_AND_DIGITAL", slsDetectorDefs::readoutMode::ANALOG_AND_DIGITAL)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::speedLevel>(Defs, "speedLevel")
|
||||
@ -259,22 +239,17 @@ void init_enums(py::module &m) {
|
||||
py::enum_<slsDetectorDefs::burstMode>(Defs, "burstMode")
|
||||
.value("BURST_INTERNAL", slsDetectorDefs::burstMode::BURST_INTERNAL)
|
||||
.value("BURST_EXTERNAL", slsDetectorDefs::burstMode::BURST_EXTERNAL)
|
||||
.value("CONTINUOUS_INTERNAL",
|
||||
slsDetectorDefs::burstMode::CONTINUOUS_INTERNAL)
|
||||
.value("CONTINUOUS_EXTERNAL",
|
||||
slsDetectorDefs::burstMode::CONTINUOUS_EXTERNAL)
|
||||
.value("CONTINUOUS_INTERNAL", slsDetectorDefs::burstMode::CONTINUOUS_INTERNAL)
|
||||
.value("CONTINUOUS_EXTERNAL", slsDetectorDefs::burstMode::CONTINUOUS_EXTERNAL)
|
||||
.value("NUM_BURST_MODES", slsDetectorDefs::burstMode::NUM_BURST_MODES)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::timingSourceType>(Defs, "timingSourceType")
|
||||
.value("TIMING_INTERNAL",
|
||||
slsDetectorDefs::timingSourceType::TIMING_INTERNAL)
|
||||
.value("TIMING_EXTERNAL",
|
||||
slsDetectorDefs::timingSourceType::TIMING_EXTERNAL)
|
||||
.value("TIMING_INTERNAL", slsDetectorDefs::timingSourceType::TIMING_INTERNAL)
|
||||
.value("TIMING_EXTERNAL", slsDetectorDefs::timingSourceType::TIMING_EXTERNAL)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::M3_GainCaps>(Defs, "M3_GainCaps",
|
||||
py::arithmetic())
|
||||
py::enum_<slsDetectorDefs::M3_GainCaps>(Defs, "M3_GainCaps")
|
||||
.value("M3_C10pre", slsDetectorDefs::M3_GainCaps::M3_C10pre)
|
||||
.value("M3_C15sh", slsDetectorDefs::M3_GainCaps::M3_C15sh)
|
||||
.value("M3_C30sh", slsDetectorDefs::M3_GainCaps::M3_C30sh)
|
||||
@ -290,17 +265,14 @@ void init_enums(py::module &m) {
|
||||
.value("BOTTOM", slsDetectorDefs::portPosition::BOTTOM)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::streamingInterface>(Defs, "streamingInterface",
|
||||
py::arithmetic())
|
||||
py::enum_<slsDetectorDefs::streamingInterface>(Defs, "streamingInterface", py::arithmetic())
|
||||
.value("NONE", slsDetectorDefs::streamingInterface::NONE)
|
||||
.value("LOW_LATENCY_LINK",
|
||||
slsDetectorDefs::streamingInterface::LOW_LATENCY_LINK)
|
||||
.value("ETHERNET_10GB",
|
||||
slsDetectorDefs::streamingInterface::ETHERNET_10GB)
|
||||
.value("LOW_LATENCY_LINK", slsDetectorDefs::streamingInterface::LOW_LATENCY_LINK)
|
||||
.value("ETHERNET_10GB", slsDetectorDefs::streamingInterface::ETHERNET_10GB)
|
||||
.value("ALL", slsDetectorDefs::streamingInterface::ALL)
|
||||
.export_values()
|
||||
.def(py::self | slsDetectorDefs::streamingInterface())
|
||||
.def(py::self & slsDetectorDefs::streamingInterface());
|
||||
.def("__or__", py::overload_cast<const slsDetectorDefs::streamingInterface &, const slsDetectorDefs::streamingInterface &>(&operator|))
|
||||
.def("__and__", py::overload_cast<const slsDetectorDefs::streamingInterface &, const slsDetectorDefs::streamingInterface &>(&operator&));
|
||||
|
||||
py::enum_<slsDetectorDefs::vetoAlgorithm>(Defs, "vetoAlgorithm")
|
||||
.value("ALG_HITS", slsDetectorDefs::vetoAlgorithm::ALG_HITS)
|
||||
@ -315,9 +287,4 @@ void init_enums(py::module &m) {
|
||||
.value("FIX_G2", slsDetectorDefs::gainMode::FIX_G2)
|
||||
.value("FIX_G0", slsDetectorDefs::gainMode::FIX_G0)
|
||||
.export_values();
|
||||
|
||||
py::enum_<slsDetectorDefs::polarity>(Defs, "polarity")
|
||||
.value("POSITIVE", slsDetectorDefs::polarity::POSITIVE)
|
||||
.value("NEGATIVE", slsDetectorDefs::polarity::NEGATIVE)
|
||||
.export_values();
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
from slsdet.enums import streamingInterface
|
||||
import pytest
|
||||
def test_streamingInterface_bitwise():
|
||||
"""Bitwise operations on streaming interfaces are allowed"""
|
||||
|
||||
sif_none = streamingInterface.NONE
|
||||
sif_low = streamingInterface.LOW_LATENCY_LINK
|
||||
sif_10g = streamingInterface.ETHERNET_10GB
|
||||
sif_all = streamingInterface.ALL
|
||||
|
||||
assert sif_low | sif_none == sif_low
|
||||
assert sif_10g | sif_none == sif_10g
|
||||
assert sif_low | sif_10g == sif_all
|
||||
assert sif_10g | sif_all == sif_all
|
||||
|
||||
assert sif_10g & sif_low == sif_none
|
||||
assert sif_low & sif_low == sif_low
|
||||
assert sif_all & sif_all == sif_all
|
||||
|
||||
def test_streamingInterface_bitwise_only_allowed_on_same_type():
|
||||
with pytest.raises(Exception):
|
||||
assert streamingInterface.LOW_LATENCY_LINK & 5 == 7
|
||||
|
1
serverBin/ctbDetectorServerv6.0.0
Symbolic link
1
serverBin/ctbDetectorServerv6.0.0
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv6.0.0
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv6.1.0
|
1
serverBin/eigerDetectorServerv6.0.0
Symbolic link
1
serverBin/eigerDetectorServerv6.0.0
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv6.0.0
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv6.1.0
|
1
serverBin/gotthard2DetectorServerv6.0.0
Symbolic link
1
serverBin/gotthard2DetectorServerv6.0.0
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv6.0.0
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv6.1.0
|
1
serverBin/gotthardDetectorServerv6.0.0
Symbolic link
1
serverBin/gotthardDetectorServerv6.0.0
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv6.0.0
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv6.1.0
|
1
serverBin/jungfrauDetectorServerv6.0.0
Symbolic link
1
serverBin/jungfrauDetectorServerv6.0.0
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv6.0.0
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv6.1.0
|
1
serverBin/moenchDetectorServerv6.0.0
Symbolic link
1
serverBin/moenchDetectorServerv6.0.0
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv6.0.0
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv6.1.0
|
1
serverBin/mythen3DetectorServerv6.0.0
Symbolic link
1
serverBin/mythen3DetectorServerv6.0.0
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv6.0.0
|
@ -1 +0,0 @@
|
||||
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv6.1.0
|
Binary file not shown.
Binary file not shown.
@ -1,158 +1,167 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOVINGSTAT_H
|
||||
#define MOVINGSTAT_H
|
||||
#define MOVINGSTAT_H
|
||||
|
||||
#include <math.h>
|
||||
|
||||
class MovingStat {
|
||||
|
||||
/** @short approximated moving average structure */
|
||||
public:
|
||||
/** constructor
|
||||
\param nn number of samples parameter to be used
|
||||
*/
|
||||
MovingStat(int nn) : n(nn), m_n(0), m_newM(0), m_newM2(0) {}
|
||||
// void setPointers(double *me, double *va) {mean=me; var=va;}
|
||||
/**
|
||||
clears the moving average number of samples parameter, mean and standard
|
||||
deviation
|
||||
*/
|
||||
void Clear() {
|
||||
m_n = 0;
|
||||
m_newM = 0;
|
||||
m_newM2 = 0;
|
||||
}
|
||||
class MovingStat
|
||||
{
|
||||
|
||||
/**
|
||||
clears the moving average number of samples parameter, mean and standard
|
||||
deviation
|
||||
*/
|
||||
void Set(double val, double rms = 0, int m = -1) {
|
||||
if (m >= 0)
|
||||
m_n = m;
|
||||
else
|
||||
m_n = n;
|
||||
m_newM = val * m_n;
|
||||
SetRMS(rms);
|
||||
// cout << "set " << val << " " << m << " " << m_n << " " << m_newM <<
|
||||
// endl;
|
||||
}
|
||||
/**
|
||||
clears the moving average number of samples parameter, mean and standard
|
||||
deviation
|
||||
*/
|
||||
void SetRMS(double rms) {
|
||||
if (rms <= 0) {
|
||||
if (m_n > 0)
|
||||
m_newM2 = m_newM * m_newM / m_n;
|
||||
else
|
||||
m_newM2 = 0;
|
||||
// m_n=0;
|
||||
} else {
|
||||
if (m_n > 0) {
|
||||
m_newM2 = (m_n * rms * rms + m_newM * m_newM / m_n);
|
||||
} else {
|
||||
m_newM2 = (m_n * rms * rms + m_newM * m_newM / n);
|
||||
m_n = 0;
|
||||
/** @short approximated moving average structure */
|
||||
public:
|
||||
|
||||
|
||||
/** constructor
|
||||
\param nn number of samples parameter to be used
|
||||
*/
|
||||
MovingStat(int nn) : n(nn), m_n(0), m_newM(0),m_newM2(0) {}
|
||||
// void setPointers(double *me, double *va) {mean=me; var=va;}
|
||||
/**
|
||||
clears the moving average number of samples parameter, mean and standard deviation
|
||||
*/
|
||||
void Clear()
|
||||
{
|
||||
m_n = 0;
|
||||
m_newM=0;
|
||||
m_newM2=0;
|
||||
}
|
||||
|
||||
/**
|
||||
clears the moving average number of samples parameter, mean and standard deviation
|
||||
*/
|
||||
void Set(double val, double rms=0, int m=-1)
|
||||
{
|
||||
if (m>=0) m_n = m; else m_n = n;
|
||||
m_newM=val*m_n;
|
||||
SetRMS(rms);
|
||||
// cout << "set " << val << " " << m << " " << m_n << " " << m_newM << endl;
|
||||
}
|
||||
/**
|
||||
clears the moving average number of samples parameter, mean and standard deviation
|
||||
*/
|
||||
void SetRMS(double rms)
|
||||
{
|
||||
if (rms<=0) {
|
||||
if (m_n>0)
|
||||
m_newM2=m_newM*m_newM/m_n;
|
||||
else
|
||||
m_newM2=0;
|
||||
//m_n=0;
|
||||
} else {
|
||||
if (m_n>0) {
|
||||
m_newM2=(m_n*rms*rms+m_newM*m_newM/m_n);
|
||||
} else {
|
||||
m_newM2=(m_n*rms*rms+m_newM*m_newM/n);
|
||||
m_n=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** sets number of samples parameter
|
||||
\param i number of samples parameter to be set
|
||||
*/
|
||||
|
||||
int SetN(int i) {if (i>=1) n=i; return n;};
|
||||
|
||||
/**
|
||||
gets number of samples parameter
|
||||
\returns actual number of samples parameter
|
||||
*/
|
||||
int GetN() {return m_n;};
|
||||
|
||||
/** calculates the moving average i.e. adds if number of elements is lower than number of samples parameter, pushes otherwise
|
||||
\param x value to calculate the moving average
|
||||
*/
|
||||
inline void Calc(double x) {
|
||||
if (m_n<n) Add(x);
|
||||
else Push(x);
|
||||
}
|
||||
/** adds the element to the accumulated average and standard deviation
|
||||
\param x value to add
|
||||
*/
|
||||
inline void Add(double x) {
|
||||
m_n++;
|
||||
|
||||
if (m_n == 1)
|
||||
{
|
||||
m_newM = x;
|
||||
m_newM2 = x*x;
|
||||
} else {
|
||||
m_newM = m_newM + x;
|
||||
m_newM2 = m_newM2 + x*x;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline void Push(double x)
|
||||
{
|
||||
/** adds the element to the accumulated average and squared mean, while subtracting the current value of the average and squared average
|
||||
\param x value to push
|
||||
*/
|
||||
if (m_n == 0)
|
||||
{
|
||||
m_newM = x;
|
||||
m_newM2 = x*x;
|
||||
m_n++;
|
||||
}
|
||||
else {
|
||||
m_newM = m_newM + x - m_newM/m_n;
|
||||
m_newM2 = m_newM2 + x*x - m_newM2/m_n;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** returns the current number of elements of the moving average
|
||||
\returns returns the current number of elements of the moving average
|
||||
*/
|
||||
int NumDataValues() const
|
||||
{
|
||||
return m_n;
|
||||
}
|
||||
/** returns the mean, 0 if no elements are inside
|
||||
\returns returns the mean
|
||||
*/
|
||||
inline double Mean() const
|
||||
{
|
||||
// cout << "get " << m_n << " " << m_newM << " " << m_newM/m_n << endl;
|
||||
|
||||
|
||||
return (m_n > 0) ? m_newM/m_n : 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
/** sets number of samples parameter
|
||||
\param i number of samples parameter to be set
|
||||
*/
|
||||
/** returns the squared mean, 0 if no elements are inside
|
||||
\returns returns the squared average
|
||||
*/
|
||||
double M2() const
|
||||
{
|
||||
return ( (m_n > 1) ? m_newM2/m_n : 0.0 );
|
||||
}
|
||||
|
||||
int SetN(int i) {
|
||||
if (i >= 1)
|
||||
n = i;
|
||||
return n;
|
||||
/** returns the variance, 0 if no elements are inside
|
||||
\returns returns the variance
|
||||
*/
|
||||
inline double Variance() const
|
||||
{
|
||||
return (m_n > 0) ? m_newM2/m_n-m_newM/m_n*m_newM/m_n : 0.0;
|
||||
}
|
||||
|
||||
/** returns the standard deviation, 0 if no elements are inside
|
||||
\returns returns the standard deviation
|
||||
*/
|
||||
inline double StandardDeviation() const
|
||||
{
|
||||
|
||||
return sqrt(Variance());//
|
||||
}
|
||||
|
||||
private:
|
||||
int n; /**< number of samples parameter */
|
||||
int m_n; /**< current number of elements */
|
||||
double m_newM; /**< accumulated average */
|
||||
double m_newM2; /**< accumulated squared average */
|
||||
};
|
||||
|
||||
/**
|
||||
gets number of samples parameter
|
||||
\returns actual number of samples parameter
|
||||
*/
|
||||
int GetN() { return m_n; };
|
||||
|
||||
/** calculates the moving average i.e. adds if number of elements is lower
|
||||
than number of samples parameter, pushes otherwise \param x value to
|
||||
calculate the moving average
|
||||
*/
|
||||
inline void Calc(double x) {
|
||||
if (m_n < n)
|
||||
Add(x);
|
||||
else
|
||||
Push(x);
|
||||
}
|
||||
/** adds the element to the accumulated average and standard deviation
|
||||
\param x value to add
|
||||
*/
|
||||
inline void Add(double x) {
|
||||
m_n++;
|
||||
|
||||
if (m_n == 1) {
|
||||
m_newM = x;
|
||||
m_newM2 = x * x;
|
||||
} else {
|
||||
m_newM = m_newM + x;
|
||||
m_newM2 = m_newM2 + x * x;
|
||||
}
|
||||
}
|
||||
|
||||
inline void Push(double x) {
|
||||
/** adds the element to the accumulated average and squared mean, while
|
||||
subtracting the current value of the average and squared average
|
||||
\param x value to push
|
||||
*/
|
||||
if (m_n == 0) {
|
||||
m_newM = x;
|
||||
m_newM2 = x * x;
|
||||
m_n++;
|
||||
} else {
|
||||
m_newM = m_newM + x - m_newM / m_n;
|
||||
m_newM2 = m_newM2 + x * x - m_newM2 / m_n;
|
||||
}
|
||||
}
|
||||
|
||||
/** returns the current number of elements of the moving average
|
||||
\returns returns the current number of elements of the moving average
|
||||
*/
|
||||
int NumDataValues() const { return m_n; }
|
||||
/** returns the mean, 0 if no elements are inside
|
||||
\returns returns the mean
|
||||
*/
|
||||
inline double Mean() const {
|
||||
// cout << "get " << m_n << " " << m_newM << " " << m_newM/m_n <<
|
||||
// endl;
|
||||
|
||||
return (m_n > 0) ? m_newM / m_n : 0.0;
|
||||
}
|
||||
|
||||
/** returns the squared mean, 0 if no elements are inside
|
||||
\returns returns the squared average
|
||||
*/
|
||||
double M2() const { return ((m_n > 1) ? m_newM2 / m_n : 0.0); }
|
||||
|
||||
/** returns the variance, 0 if no elements are inside
|
||||
\returns returns the variance
|
||||
*/
|
||||
inline double Variance() const {
|
||||
return (m_n > 0) ? m_newM2 / m_n - m_newM / m_n * m_newM / m_n : 0.0;
|
||||
}
|
||||
|
||||
/** returns the standard deviation, 0 if no elements are inside
|
||||
\returns returns the standard deviation
|
||||
*/
|
||||
inline double StandardDeviation() const {
|
||||
|
||||
return sqrt(Variance()); //
|
||||
}
|
||||
|
||||
private:
|
||||
int n; /**< number of samples parameter */
|
||||
int m_n; /**< current number of elements */
|
||||
double m_newM; /**< accumulated average */
|
||||
double m_newM2; /**< accumulated squared average */
|
||||
};
|
||||
#endif
|
||||
|
@ -1,37 +1,57 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
class RunningStat {
|
||||
public:
|
||||
RunningStat() : m_n(0) {}
|
||||
class RunningStat
|
||||
{
|
||||
public:
|
||||
RunningStat() : m_n(0) {}
|
||||
|
||||
void Clear() { m_n = 0; }
|
||||
|
||||
void Push(double x) {
|
||||
m_n++;
|
||||
|
||||
// See Knuth TAOCP vol 2, 3rd edition, page 232
|
||||
if (m_n == 1) {
|
||||
m_oldM = m_newM = x;
|
||||
m_oldS = 0.0;
|
||||
} else {
|
||||
m_newM = m_oldM + (x - m_oldM) / m_n;
|
||||
m_newS = m_oldS + (x - m_oldM) * (x - m_newM);
|
||||
|
||||
// set up for next iteration
|
||||
m_oldM = m_newM;
|
||||
m_oldS = m_newS;
|
||||
void Clear()
|
||||
{
|
||||
m_n = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int NumDataValues() const { return m_n; }
|
||||
void Push(double x)
|
||||
{
|
||||
m_n++;
|
||||
|
||||
double Mean() const { return (m_n > 0) ? m_newM : 0.0; }
|
||||
// See Knuth TAOCP vol 2, 3rd edition, page 232
|
||||
if (m_n == 1)
|
||||
{
|
||||
m_oldM = m_newM = x;
|
||||
m_oldS = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_newM = m_oldM + (x - m_oldM)/m_n;
|
||||
m_newS = m_oldS + (x - m_oldM)*(x - m_newM);
|
||||
|
||||
// set up for next iteration
|
||||
m_oldM = m_newM;
|
||||
m_oldS = m_newS;
|
||||
}
|
||||
}
|
||||
|
||||
double Variance() const { return ((m_n > 1) ? m_newS / (m_n - 1) : 0.0); }
|
||||
int NumDataValues() const
|
||||
{
|
||||
return m_n;
|
||||
}
|
||||
|
||||
double StandardDeviation() const { return sqrt(Variance()); }
|
||||
double Mean() const
|
||||
{
|
||||
return (m_n > 0) ? m_newM : 0.0;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_n;
|
||||
double m_oldM, m_newM, m_oldS, m_newS;
|
||||
};
|
||||
double Variance() const
|
||||
{
|
||||
return ( (m_n > 1) ? m_newS/(m_n - 1) : 0.0 );
|
||||
}
|
||||
|
||||
double StandardDeviation() const
|
||||
{
|
||||
return sqrt( Variance() );
|
||||
}
|
||||
|
||||
private:
|
||||
int m_n;
|
||||
double m_oldM, m_newM, m_oldS, m_newS;
|
||||
};
|
||||
|
@ -1,33 +1,47 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
class Stat {
|
||||
class Stat
|
||||
{
|
||||
public:
|
||||
Stat() : n(0), m(0.), m2(0.) {}
|
||||
|
||||
void Clear() {
|
||||
n = 0;
|
||||
m = 0;
|
||||
m2 = 0;
|
||||
|
||||
Stat() : n(0), m(0.), m2(0.) {}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
n = 0;
|
||||
m=0;
|
||||
m2=0;
|
||||
}
|
||||
|
||||
void Push(double x)
|
||||
{
|
||||
|
||||
m+=x;
|
||||
m2+=x*x;
|
||||
n++;
|
||||
}
|
||||
|
||||
void Push(double x) {
|
||||
int NumDataValues() const
|
||||
{
|
||||
return n;
|
||||
}
|
||||
|
||||
m += x;
|
||||
m2 += x * x;
|
||||
n++;
|
||||
}
|
||||
double Mean() const
|
||||
{
|
||||
return (n > 0) ? m/n : 0.0;
|
||||
}
|
||||
|
||||
int NumDataValues() const { return n; }
|
||||
double Variance() const
|
||||
{
|
||||
return ( (n >0 ) ? (m2/n-m*m/(n*n)) : 0.0 );
|
||||
}
|
||||
|
||||
double Mean() const { return (n > 0) ? m / n : 0.0; }
|
||||
double StandardDeviation() const
|
||||
{
|
||||
return sqrt( Variance() );
|
||||
}
|
||||
|
||||
double Variance() const {
|
||||
return ((n > 0) ? (m2 / n - m * m / (n * n)) : 0.0);
|
||||
}
|
||||
|
||||
double StandardDeviation() const { return sqrt(Variance()); }
|
||||
|
||||
private:
|
||||
int n;
|
||||
double m, m2;
|
||||
};
|
||||
private:
|
||||
int n;
|
||||
double m, m2;
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,78 +1,88 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
/* CircularFifo.h
|
||||
* Code & platform dependent issues with it was originally
|
||||
* published at http://www.kjellkod.cc/threadsafecircularqueue
|
||||
* 2009-11-02
|
||||
* @author Kjell Hedstr<74>m, hedstrom@kjellkod.cc
|
||||
* modified by the sls detetor group
|
||||
* */
|
||||
/* CircularFifo.h
|
||||
* Code & platform dependent issues with it was originally
|
||||
* published at http://www.kjellkod.cc/threadsafecircularqueue
|
||||
* 2009-11-02
|
||||
* @author Kjell Hedstr<74>m, hedstrom@kjellkod.cc
|
||||
* modified by the sls detetor group
|
||||
* */
|
||||
|
||||
//#include "sls_receiver_defs.h"
|
||||
#include <iostream>
|
||||
#include <semaphore.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
typedef int int32_t;
|
||||
|
||||
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
typedef int int32_t;
|
||||
|
||||
/** Circular Fifo (a.k.a. Circular Buffer)
|
||||
* Thread safe for one reader, and one writer */
|
||||
template <typename Element> class CircularFifo {
|
||||
public:
|
||||
CircularFifo(unsigned int Size) : tail(0), head(0) {
|
||||
Capacity = Size + 1;
|
||||
array.resize(Capacity);
|
||||
sem_init(&data_mutex, 0, 0);
|
||||
sem_init(&free_mutex, 0, Size);
|
||||
}
|
||||
virtual ~CircularFifo() {
|
||||
sem_destroy(&data_mutex);
|
||||
sem_destroy(&free_mutex);
|
||||
}
|
||||
* Thread safe for one reader, and one writer */
|
||||
template<typename Element>
|
||||
class CircularFifo {
|
||||
public:
|
||||
|
||||
bool push(Element *&item_, bool no_block = false);
|
||||
bool pop(Element *&item_, bool no_block = false);
|
||||
CircularFifo(unsigned int Size) : tail(0), head(0){
|
||||
Capacity = Size + 1;
|
||||
array.resize(Capacity);
|
||||
sem_init(&data_mutex,0,0);
|
||||
sem_init(&free_mutex,0,Size);
|
||||
}
|
||||
virtual ~CircularFifo() {
|
||||
sem_destroy(&data_mutex);
|
||||
sem_destroy(&free_mutex);
|
||||
}
|
||||
|
||||
bool isEmpty() const;
|
||||
bool isFull() const;
|
||||
bool push(Element*& item_, bool no_block=false);
|
||||
bool pop(Element*& item_, bool no_block=false);
|
||||
|
||||
int getDataValue() const;
|
||||
int getFreeValue() const;
|
||||
bool isEmpty() const;
|
||||
bool isFull() const;
|
||||
|
||||
private:
|
||||
std::vector<Element *> array;
|
||||
unsigned int tail; // input index
|
||||
unsigned int head; // output index
|
||||
unsigned int Capacity;
|
||||
mutable sem_t data_mutex;
|
||||
mutable sem_t free_mutex;
|
||||
unsigned int increment(unsigned int idx_) const;
|
||||
int getDataValue() const;
|
||||
int getFreeValue() const;
|
||||
|
||||
private:
|
||||
std::vector <Element*> array;
|
||||
unsigned int tail; // input index
|
||||
unsigned int head; // output index
|
||||
unsigned int Capacity;
|
||||
mutable sem_t data_mutex;
|
||||
mutable sem_t free_mutex;
|
||||
unsigned int increment(unsigned int idx_) const;
|
||||
};
|
||||
|
||||
template <typename Element> int CircularFifo<Element>::getDataValue() const {
|
||||
int value;
|
||||
sem_getvalue(&data_mutex, &value);
|
||||
return value;
|
||||
template<typename Element>
|
||||
int CircularFifo<Element>::getDataValue() const
|
||||
{
|
||||
int value;
|
||||
sem_getvalue(&data_mutex, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
template <typename Element> int CircularFifo<Element>::getFreeValue() const {
|
||||
template<typename Element>
|
||||
int CircularFifo<Element>::getFreeValue() const
|
||||
{
|
||||
int value;
|
||||
sem_getvalue(&free_mutex, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/** Producer only: Adds item to the circular queue.
|
||||
* If queue is full at 'push' operation no update/overwrite
|
||||
* will happen, it is up to the caller to handle this case
|
||||
*
|
||||
* \param item_ copy by reference the input item
|
||||
* \param no_block if true, return immediately if fifo is full
|
||||
* \return whether operation was successful or not */
|
||||
template <typename Element>
|
||||
bool CircularFifo<Element>::push(Element *&item_, bool no_block) {
|
||||
* If queue is full at 'push' operation no update/overwrite
|
||||
* will happen, it is up to the caller to handle this case
|
||||
*
|
||||
* \param item_ copy by reference the input item
|
||||
* \param no_block if true, return immediately if fifo is full
|
||||
* \return whether operation was successful or not */
|
||||
template<typename Element>
|
||||
bool CircularFifo<Element>::push(Element*& item_, bool no_block)
|
||||
{
|
||||
// check for fifo full
|
||||
if (no_block && isFull())
|
||||
return false;
|
||||
@ -85,57 +95,64 @@ bool CircularFifo<Element>::push(Element *&item_, bool no_block) {
|
||||
}
|
||||
|
||||
/** Consumer only: Removes and returns item from the queue
|
||||
* If queue is empty at 'pop' operation no retrieve will happen
|
||||
* It is up to the caller to handle this case
|
||||
*
|
||||
* \param item_ return by reference the wanted item
|
||||
* \param no_block if true, return immediately if fifo is full
|
||||
* \return whether operation was successful or not */
|
||||
template <typename Element>
|
||||
bool CircularFifo<Element>::pop(Element *&item_, bool no_block) {
|
||||
* If queue is empty at 'pop' operation no retrieve will happen
|
||||
* It is up to the caller to handle this case
|
||||
*
|
||||
* \param item_ return by reference the wanted item
|
||||
* \param no_block if true, return immediately if fifo is full
|
||||
* \return whether operation was successful or not */
|
||||
template<typename Element>
|
||||
bool CircularFifo<Element>::pop(Element*& item_, bool no_block)
|
||||
{
|
||||
// check for fifo empty
|
||||
if (no_block && isEmpty())
|
||||
return false;
|
||||
|
||||
sem_wait(&data_mutex);
|
||||
item_ = array[head];
|
||||
head = increment(head);
|
||||
sem_post(&free_mutex);
|
||||
return true;
|
||||
sem_wait(&data_mutex);
|
||||
item_ = array[head];
|
||||
head = increment(head);
|
||||
sem_post(&free_mutex);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Useful for testinng and Consumer check of status
|
||||
* Remember that the 'empty' status can change quickly
|
||||
* as the Procuder adds more items.
|
||||
*
|
||||
* \return true if circular buffer is empty */
|
||||
template <typename Element> bool CircularFifo<Element>::isEmpty() const {
|
||||
* Remember that the 'empty' status can change quickly
|
||||
* as the Procuder adds more items.
|
||||
*
|
||||
* \return true if circular buffer is empty */
|
||||
template<typename Element>
|
||||
bool CircularFifo<Element>::isEmpty() const
|
||||
{
|
||||
return (getDataValue() == 0);
|
||||
}
|
||||
|
||||
/** Useful for testing and Producer check of status
|
||||
* Remember that the 'full' status can change quickly
|
||||
* as the Consumer catches up.
|
||||
*
|
||||
* \return true if circular buffer is full. */
|
||||
template <typename Element> bool CircularFifo<Element>::isFull() const {
|
||||
* Remember that the 'full' status can change quickly
|
||||
* as the Consumer catches up.
|
||||
*
|
||||
* \return true if circular buffer is full. */
|
||||
template<typename Element>
|
||||
bool CircularFifo<Element>::isFull() const
|
||||
{
|
||||
return (getFreeValue() == 0);
|
||||
}
|
||||
|
||||
/** Increment helper function for index of the circular queue
|
||||
* index is inremented or wrapped
|
||||
*
|
||||
* \param idx_ the index to the incremented/wrapped
|
||||
* \return new value for the index */
|
||||
template <typename Element>
|
||||
unsigned int CircularFifo<Element>::increment(unsigned int idx_) const {
|
||||
// increment or wrap
|
||||
// =================
|
||||
// index++;
|
||||
// if(index == array.lenght) -> index = 0;
|
||||
//
|
||||
// or as written below:
|
||||
// index = (index+1) % array.length
|
||||
idx_ = (idx_ + 1) % Capacity;
|
||||
return idx_;
|
||||
* index is inremented or wrapped
|
||||
*
|
||||
* \param idx_ the index to the incremented/wrapped
|
||||
* \return new value for the index */
|
||||
template<typename Element>
|
||||
unsigned int CircularFifo<Element>::increment(unsigned int idx_) const
|
||||
{
|
||||
// increment or wrap
|
||||
// =================
|
||||
// index++;
|
||||
// if(index == array.lenght) -> index = 0;
|
||||
//
|
||||
//or as written below:
|
||||
// index = (index+1) % array.length
|
||||
idx_ = (idx_+1) % Capacity;
|
||||
return idx_;
|
||||
}
|
||||
|
||||
|
@ -5,95 +5,80 @@
|
||||
|
||||
#include "MovingStat.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class commonModeSubtraction {
|
||||
|
||||
/** @short class to calculate the common mode of the pedestals based on an
|
||||
* approximated moving average*/
|
||||
/** @short class to calculate the common mode of the pedestals based on an approximated moving average*/
|
||||
|
||||
public:
|
||||
/** constructor
|
||||
\param nn number of samples for the moving average to calculate the
|
||||
average common mode \param iroi number of regions on which one can
|
||||
calculate the common mode separately. Defaults to 1 i.e. whole detector
|
||||
public:
|
||||
|
||||
/** constructor
|
||||
\param nn number of samples for the moving average to calculate the average common mode
|
||||
\param iroi number of regions on which one can calculate the common mode separately. Defaults to 1 i.e. whole detector
|
||||
|
||||
*/
|
||||
commonModeSubtraction(int nn=1000, int iroi=1) : cmStat(NULL), cmPed(NULL), nCm(NULL), nROI(iroi) {cmStat=new MovingStat[nROI]; for (int i=0; i<nROI; i++) cmStat[i].SetN(nn); cmPed=new double[nROI]; nCm=new double[nROI];};
|
||||
|
||||
/** destructor - deletes the moving average(s) and the sum of pedestals calculator(s) */
|
||||
virtual ~commonModeSubtraction() {delete [] cmStat; delete [] cmPed; delete [] nCm;};
|
||||
|
||||
|
||||
/** clears the moving average and the sum of pedestals calculation - virtual func*/
|
||||
virtual void Clear(){
|
||||
for (int i=0; i<nROI; i++) {
|
||||
cmStat[i].Clear();
|
||||
nCm[i]=0;
|
||||
cmPed[i]=0;
|
||||
}};
|
||||
|
||||
/** adds the average of pedestals to the moving average and reinitializes the calculation of the sum of pedestals for all ROIs. - virtual func*/
|
||||
virtual void newFrame(){
|
||||
for (int i=0; i<nROI; i++) {
|
||||
if (nCm[i]>0) cmStat[i].Calc(cmPed[i]/nCm[i]);
|
||||
nCm[i]=0;
|
||||
cmPed[i]=0;
|
||||
}};
|
||||
|
||||
/** adds the pixel to the sum of pedestals -- virtual func must be overloaded to define the regions of interest
|
||||
\param val value to add
|
||||
\param ix pixel x coordinate
|
||||
\param iy pixel y coordinate
|
||||
*/
|
||||
commonModeSubtraction(int nn = 1000, int iroi = 1)
|
||||
: cmStat(NULL), cmPed(NULL), nCm(NULL), nROI(iroi) {
|
||||
cmStat = new MovingStat[nROI];
|
||||
for (int i = 0; i < nROI; i++)
|
||||
cmStat[i].SetN(nn);
|
||||
cmPed = new double[nROI];
|
||||
nCm = new double[nROI];
|
||||
virtual void addToCommonMode(double val, int ix=0, int iy=0) {
|
||||
(void) ix; (void) iy;
|
||||
|
||||
//if (isc>=0 && isc<nROI) {
|
||||
cmPed[0]+=val;
|
||||
nCm[0]++;//}
|
||||
};
|
||||
|
||||
/** destructor - deletes the moving average(s) and the sum of pedestals
|
||||
* calculator(s) */
|
||||
virtual ~commonModeSubtraction() {
|
||||
delete[] cmStat;
|
||||
delete[] cmPed;
|
||||
delete[] nCm;
|
||||
};
|
||||
|
||||
/** clears the moving average and the sum of pedestals calculation - virtual
|
||||
* func*/
|
||||
virtual void Clear() {
|
||||
for (int i = 0; i < nROI; i++) {
|
||||
cmStat[i].Clear();
|
||||
nCm[i] = 0;
|
||||
cmPed[i] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/** adds the average of pedestals to the moving average and reinitializes
|
||||
* the calculation of the sum of pedestals for all ROIs. - virtual func*/
|
||||
virtual void newFrame() {
|
||||
for (int i = 0; i < nROI; i++) {
|
||||
if (nCm[i] > 0)
|
||||
cmStat[i].Calc(cmPed[i] / nCm[i]);
|
||||
nCm[i] = 0;
|
||||
cmPed[i] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/** adds the pixel to the sum of pedestals -- virtual func must be
|
||||
overloaded to define the regions of interest \param val value to add
|
||||
\param ix pixel x coordinate
|
||||
\param iy pixel y coordinate
|
||||
/** gets the common mode i.e. the difference between the current average sum of pedestals mode and the average pedestal -- virtual func must be overloaded to define the regions of interest
|
||||
\param ix pixel x coordinate
|
||||
\param iy pixel y coordinate
|
||||
\return the difference between the current average sum of pedestals and the average pedestal
|
||||
*/
|
||||
virtual void addToCommonMode(double val, int ix = 0, int iy = 0) {
|
||||
(void)ix;
|
||||
(void)iy;
|
||||
virtual double getCommonMode(int ix=0, int iy=0) {
|
||||
(void) ix; (void) iy;
|
||||
if (nCm[0]>0) return cmPed[0]/nCm[0]-cmStat[0].Mean();
|
||||
return 0;};
|
||||
|
||||
|
||||
// if (isc>=0 && isc<nROI) {
|
||||
cmPed[0] += val;
|
||||
nCm[0]++; //}
|
||||
};
|
||||
|
||||
/** gets the common mode i.e. the difference between the current average sum
|
||||
of pedestals mode and the average pedestal -- virtual func must be
|
||||
overloaded to define the regions of interest \param ix pixel x coordinate
|
||||
\param iy pixel y coordinate
|
||||
\return the difference between the current average sum of pedestals and
|
||||
the average pedestal
|
||||
*/
|
||||
virtual double getCommonMode(int ix = 0, int iy = 0) {
|
||||
(void)ix;
|
||||
(void)iy;
|
||||
if (nCm[0] > 0)
|
||||
return cmPed[0] / nCm[0] - cmStat[0].Mean();
|
||||
return 0;
|
||||
};
|
||||
|
||||
protected:
|
||||
MovingStat *cmStat; /**<array of moving average of the pedestal average per
|
||||
region of interest */
|
||||
double *
|
||||
cmPed; /**< array storing the sum of pedestals per region of interest */
|
||||
double *nCm; /**< array storing the number of pixels currently contributing
|
||||
to the pedestals */
|
||||
const int
|
||||
nROI; /**< constant parameter for number of regions on which the common
|
||||
mode should be calculated separately e.g. supercolumns */
|
||||
|
||||
protected:
|
||||
MovingStat *cmStat; /**<array of moving average of the pedestal average per region of interest */
|
||||
double *cmPed; /**< array storing the sum of pedestals per region of interest */
|
||||
double *nCm; /**< array storing the number of pixels currently contributing to the pedestals */
|
||||
const int nROI; /**< constant parameter for number of regions on which the common mode should be calculated separately e.g. supercolumns */
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -7,142 +7,123 @@
|
||||
|
||||
class commonModeSubtraction {
|
||||
|
||||
/** @short class to calculate the common mode of the pedestals based on an
|
||||
* approximated moving average*/
|
||||
/** @short class to calculate the common mode of the pedestals based on an approximated moving average*/
|
||||
|
||||
public:
|
||||
/** constructor
|
||||
\param nn number of samples for the moving average to calculate the
|
||||
average common mode \param iroi number of regions on which one can
|
||||
calculate the common mode separately. Defaults to 1 i.e. whole detector
|
||||
public:
|
||||
|
||||
/** constructor
|
||||
\param nn number of samples for the moving average to calculate the average common mode
|
||||
\param iroi number of regions on which one can calculate the common mode separately. Defaults to 1 i.e. whole detector
|
||||
|
||||
*/
|
||||
commonModeSubtraction(int iroi = 1, int ns = 3) : nsigma(ns), nROI(iroi) {
|
||||
mean = new double[nROI];
|
||||
mean2 = new double[nROI];
|
||||
nCm = new double[nROI];
|
||||
};
|
||||
|
||||
/** destructor - deletes the moving average(s) and the sum of pedestals
|
||||
* calculator(s) */
|
||||
virtual ~commonModeSubtraction() {
|
||||
delete[] mean;
|
||||
delete[] mean2;
|
||||
delete[] nCm;
|
||||
};
|
||||
*/
|
||||
commonModeSubtraction(int iroi=1, int ns=3) : nsigma(ns), nROI(iroi) {
|
||||
mean=new double[nROI];
|
||||
mean2=new double[nROI];
|
||||
nCm=new double[nROI];
|
||||
};
|
||||
|
||||
/** destructor - deletes the moving average(s) and the sum of pedestals calculator(s) */
|
||||
virtual ~commonModeSubtraction() {delete [] mean; delete [] mean2; delete [] nCm;};
|
||||
|
||||
/* commonModeSubtraction(commonModeSubtraction *cs) { */
|
||||
/* if (cs) new commonModeSubtraction(cs->getNRoi(), cs->nsigma); */
|
||||
/* } */
|
||||
|
||||
|
||||
virtual commonModeSubtraction *Clone() {
|
||||
return new commonModeSubtraction(this->nROI, this->nsigma);
|
||||
return new commonModeSubtraction(this->nROI, this->nsigma);
|
||||
}
|
||||
|
||||
/** clears the moving average and the sum of pedestals calculation - virtual
|
||||
* func*/
|
||||
virtual void Clear() {
|
||||
for (int i = 0; i < nROI; i++) {
|
||||
mean[i] = 0;
|
||||
nCm[i] = 0;
|
||||
mean2[i] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/** adds the average of pedestals to the moving average and reinitializes
|
||||
* the calculation of the sum of pedestals for all ROIs. - virtual func*/
|
||||
virtual void newFrame() {
|
||||
// cout << "Reset CM" << endl;
|
||||
for (int i = 0; i < nROI; i++) {
|
||||
// if (nCm[i]>0) cmStat[i].Calc(cmPed[i]/nCm[i]);
|
||||
nCm[i] = 0;
|
||||
mean[i] = 0;
|
||||
mean2[i] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/** adds the pixel to the sum of pedestals -- virtual func must be
|
||||
overloaded to define the regions of interest \param val value to add
|
||||
\param ix pixel x coordinate
|
||||
\param iy pixel y coordinate
|
||||
/** clears the moving average and the sum of pedestals calculation - virtual func*/
|
||||
virtual void Clear(){
|
||||
for (int i=0; i<nROI; i++) {
|
||||
mean[i]=0;
|
||||
nCm[i]=0;
|
||||
mean2[i]=0;
|
||||
}};
|
||||
|
||||
/** adds the average of pedestals to the moving average and reinitializes the calculation of the sum of pedestals for all ROIs. - virtual func*/
|
||||
virtual void newFrame(){
|
||||
//cout << "Reset CM" << endl;
|
||||
for (int i=0; i<nROI; i++) {
|
||||
// if (nCm[i]>0) cmStat[i].Calc(cmPed[i]/nCm[i]);
|
||||
nCm[i]=0;
|
||||
mean[i]=0;
|
||||
mean2[i]=0;
|
||||
}};
|
||||
|
||||
/** adds the pixel to the sum of pedestals -- virtual func must be overloaded to define the regions of interest
|
||||
\param val value to add
|
||||
\param ix pixel x coordinate
|
||||
\param iy pixel y coordinate
|
||||
*/
|
||||
virtual void addToCommonMode(double val, int ix = 0, int iy = 0) {
|
||||
|
||||
int iroi = getROI(ix, iy);
|
||||
// if (iroi==0) val=100;
|
||||
// else val=-100;
|
||||
// if (isc>=0 && isc<nROI) {
|
||||
// cout << ix << " " << iy << " " << iroi << endl;
|
||||
// if (ix==15 && iy==15) cout << "=" << val << endl;
|
||||
if (iroi >= 0 && iroi < nROI) {
|
||||
// cout << ix << " " << iy << " " << iroi << endl;
|
||||
mean[iroi] += val;
|
||||
mean2[iroi] += val * val;
|
||||
nCm[iroi]++;
|
||||
}
|
||||
virtual void addToCommonMode(double val, int ix=0, int iy=0) {
|
||||
|
||||
int iroi=getROI(ix,iy);
|
||||
// if (iroi==0) val=100;
|
||||
// else val=-100;
|
||||
// if (isc>=0 && isc<nROI) {
|
||||
// cout << ix << " " << iy << " " << iroi << endl;
|
||||
//if (ix==15 && iy==15) cout << "=" << val << endl;
|
||||
if (iroi>=0 && iroi<nROI) {
|
||||
// cout << ix << " " << iy << " " << iroi << endl;
|
||||
mean[iroi]+=val;
|
||||
mean2[iroi]+=val*val;
|
||||
nCm[iroi]++;
|
||||
}
|
||||
};
|
||||
|
||||
/** gets the common mode i.e. the difference between the current average sum
|
||||
of pedestals mode and the average pedestal \param ix pixel x coordinate
|
||||
\param iy pixel y coordinate
|
||||
\return the difference between the current average sum of pedestals and
|
||||
the average pedestal
|
||||
/** gets the common mode i.e. the difference between the current average sum of pedestals mode and the average pedestal
|
||||
\param ix pixel x coordinate
|
||||
\param iy pixel y coordinate
|
||||
\return the difference between the current average sum of pedestals and the average pedestal
|
||||
*/
|
||||
virtual double getCommonMode(int ix = 0, int iy = 0) {
|
||||
int iroi = getROI(ix, iy);
|
||||
/* if (iroi==0) */
|
||||
/* return 100; */
|
||||
/* else */
|
||||
/* return -100; */
|
||||
// cout << "*" << ix << " " << iy << " " << iroi << " " << mean[iroi] <<
|
||||
// " " << nCm[iroi]<< endl; if (ix==15 && iy==15) cout << "-" <<
|
||||
// mean[iroi]/nCm[iroi] << endl;
|
||||
if (iroi >= 0 && iroi < nROI) {
|
||||
if (nCm[iroi] > 0)
|
||||
return mean[iroi] / nCm[iroi];
|
||||
}
|
||||
return 0;
|
||||
virtual double getCommonMode(int ix=0, int iy=0) {
|
||||
int iroi=getROI(ix,iy);
|
||||
/* if (iroi==0) */
|
||||
/* return 100; */
|
||||
/* else */
|
||||
/* return -100; */
|
||||
// cout << "*" << ix << " " << iy << " " << iroi << " " << mean[iroi] << " " << nCm[iroi]<< endl;
|
||||
// if (ix==15 && iy==15) cout << "-" << mean[iroi]/nCm[iroi] << endl;
|
||||
if (iroi>=0 && iroi<nROI) {
|
||||
if (nCm[iroi]>0)
|
||||
return mean[iroi]/nCm[iroi];
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
/** gets the common mode i.e. the difference between the current average sum
|
||||
of pedestals mode and the average pedestal \param ix pixel x coordinate
|
||||
\param iy pixel y coordinate
|
||||
\return the difference between the current average sum of pedestals and
|
||||
the average pedestal
|
||||
|
||||
/** gets the common mode i.e. the difference between the current average sum of pedestals mode and the average pedestal
|
||||
\param ix pixel x coordinate
|
||||
\param iy pixel y coordinate
|
||||
\return the difference between the current average sum of pedestals and the average pedestal
|
||||
*/
|
||||
virtual double getCommonModeRMS(int ix = 0, int iy = 0) {
|
||||
int iroi = getROI(ix, iy);
|
||||
if (iroi >= 0 && iroi < nROI) {
|
||||
if (nCm[iroi] > 0)
|
||||
return sqrt(mean2[iroi] / nCm[iroi] -
|
||||
(mean[iroi] / nCm[iroi]) *
|
||||
(mean[iroi] / nCm[iroi]));
|
||||
}
|
||||
return 0;
|
||||
virtual double getCommonModeRMS(int ix=0, int iy=0) {
|
||||
int iroi=getROI(ix,iy);
|
||||
if (iroi>=0 && iroi<nROI) {
|
||||
if (nCm[iroi]>0)
|
||||
return sqrt(mean2[iroi]/nCm[iroi]-(mean[iroi]/nCm[iroi])*(mean[iroi]/nCm[iroi]));
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
gets the common mode ROI for pixel ix, iy -should be overloaded!
|
||||
/**
|
||||
gets the common mode ROI for pixel ix, iy -should be overloaded!
|
||||
*/
|
||||
virtual int getROI(int ix, int iy) {
|
||||
(void)ix;
|
||||
(void)iy;
|
||||
return 0;
|
||||
};
|
||||
int getNRoi() { return nROI; };
|
||||
virtual int getROI(int ix, int iy){ (void) ix; (void) iy; return 0;};
|
||||
int getNRoi(){return nROI;};
|
||||
|
||||
protected:
|
||||
double *mean; /**<array of moving average of the pedestal average per region of interest */
|
||||
double *mean2; /**< array storing the sum of pedestals per region of interest */
|
||||
double *nCm; /**< array storing the number of pixels currently contributing to the pedestals */
|
||||
int nsigma; /** number of rms above which the pedestal should be considered as a photon */
|
||||
const int nROI; /**< constant parameter for number of regions on which the common mode should be calculated separately e.g. supercolumns */
|
||||
|
||||
|
||||
protected:
|
||||
double *mean; /**<array of moving average of the pedestal average per region
|
||||
of interest */
|
||||
double *
|
||||
mean2; /**< array storing the sum of pedestals per region of interest */
|
||||
double *nCm; /**< array storing the number of pixels currently contributing
|
||||
to the pedestals */
|
||||
int nsigma; /** number of rms above which the pedestal should be considered
|
||||
as a photon */
|
||||
const int
|
||||
nROI; /**< constant parameter for number of regions on which the common
|
||||
mode should be calculated separately e.g. supercolumns */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -3,140 +3,123 @@
|
||||
#ifndef MYTHEN301JCTBDATA_H
|
||||
#define MYTHEN301JCTBDATA_H
|
||||
|
||||
|
||||
class mythen3_01_jctbData : public slsDetectorData<short unsigned int> {
|
||||
|
||||
public:
|
||||
mythen3_01_jctbData(int nch = 64 * 3, int dr = 24, int off = 5)
|
||||
: slsDetectorData<short unsigned int>(64 * 3, 1, dr * 8 * nch, NULL,
|
||||
NULL, NULL),
|
||||
dynamicRange(dr), serialOffset(off), frameNumber(0),
|
||||
numberOfCounters(nch){};
|
||||
|
||||
virtual void getPixel(int ip, int &x, int &y) {
|
||||
x = -1;
|
||||
y = -1;
|
||||
};
|
||||
public:
|
||||
mythen3_01_jctbData( int nch=64*3,int dr=24, int off=5): slsDetectorData<short unsigned int>(64*3,1,dr*8*nch,NULL,NULL,NULL), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch) {};
|
||||
|
||||
virtual short unsigned int getChannel(char *data, int ix, int iy = 0) {
|
||||
int ret = -1;
|
||||
short unsigned int *val =
|
||||
mythen03_frame(data, dynamicRange, numberOfCounters, serialOffset);
|
||||
if (ix >= 0 && ix < numberOfCounters)
|
||||
ret = val[ix];
|
||||
delete[] val;
|
||||
return ret;
|
||||
};
|
||||
|
||||
virtual int getFrameNumber(char *buff) { return frameNumber; };
|
||||
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
ndata = dsize;
|
||||
return data;
|
||||
virtual void getPixel(int ip, int &x, int &y) {x=-1; y=-1;};
|
||||
|
||||
virtual short unsigned int getChannel(char *data, int ix, int iy=0) {
|
||||
int ret=-1;
|
||||
short unsigned int *val=mythen03_frame(data,dynamicRange,numberOfCounters,serialOffset);
|
||||
if (ix>=0 && ix<numberOfCounters) ret=val[ix];
|
||||
delete [] val;
|
||||
return ret;
|
||||
};
|
||||
|
||||
virtual int getFrameNumber(char *buff) {return frameNumber;};
|
||||
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
ndata=dsize;
|
||||
return data;
|
||||
}
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
char *data=NULL;
|
||||
if (filebin.is_open()) {
|
||||
data=new char[dataSize];
|
||||
filebin.read(data,dataSize);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
virtual short unsigned int **getData(char *ptr, int dsize=-1) {
|
||||
short unsigned int **val;
|
||||
val=new short unsigned int*[1];
|
||||
val[0]=mythen03_frame(ptr,dynamicRange,nx,serialOffset);
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
char *data = NULL;
|
||||
if (filebin.is_open()) {
|
||||
data = new char[dataSize];
|
||||
filebin.read(data, dataSize);
|
||||
}
|
||||
return data;
|
||||
virtual short unsigned int* mythen03_frame(char *ptr, int dr=24, int nch=64*3, int off=5) {
|
||||
// off=0;
|
||||
//int iarg;
|
||||
int64_t word, *wp;
|
||||
short unsigned int* val=new short unsigned int[nch];
|
||||
int bit[64];
|
||||
int nb=2;
|
||||
int ioff=0;
|
||||
int idr=0;
|
||||
int ib=0;
|
||||
int iw=0;
|
||||
int ii=0;
|
||||
bit[0]=19;
|
||||
bit[1]=8;
|
||||
idr=0;
|
||||
for (ib=0; ib<nch; ib++) {
|
||||
val[ib]=0;
|
||||
}
|
||||
wp=(int64_t*)ptr;
|
||||
|
||||
for (iw=0; iw<nch/nb; iw) {
|
||||
word=*wp;;
|
||||
if (ioff<off) {
|
||||
ioff++;
|
||||
cout <<"*";
|
||||
} else {
|
||||
|
||||
if (idr<16) {
|
||||
for (ib=0; ib<nb; ib++) {
|
||||
if (word&(1<<bit[ib])) {
|
||||
cout << "+" ;
|
||||
val[iw+nch/nb*(ib)]|=(1<<idr);
|
||||
} else {
|
||||
cout << "-" ;
|
||||
}
|
||||
}//end for()
|
||||
}
|
||||
|
||||
idr++;
|
||||
|
||||
|
||||
if (idr==dr) {
|
||||
idr=0;
|
||||
// cout << dec << " " << iw << " " << val[iw] << " " << val[iw+nch/2] << endl;
|
||||
cout <<dec << iw<<endl;
|
||||
iw++;
|
||||
}//end if()
|
||||
|
||||
virtual short unsigned int **getData(char *ptr, int dsize = -1) {
|
||||
short unsigned int **val;
|
||||
val = new short unsigned int *[1];
|
||||
val[0] = mythen03_frame(ptr, dynamicRange, nx, serialOffset);
|
||||
return val;
|
||||
}
|
||||
}//end else()
|
||||
wp+=1;
|
||||
ii++;
|
||||
}//end for
|
||||
|
||||
cout << "M3.01 Decoded "<<ii << " samples"<< endl;
|
||||
cout << "M3.01 Should be "<< nch/nb*dr+off << " samples"<< endl;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
virtual short unsigned int *mythen03_frame(char *ptr, int dr = 24,
|
||||
int nch = 64 * 3, int off = 5) {
|
||||
// off=0;
|
||||
// int iarg;
|
||||
int64_t word, *wp;
|
||||
short unsigned int *val = new short unsigned int[nch];
|
||||
int bit[64];
|
||||
int nb = 2;
|
||||
int ioff = 0;
|
||||
int idr = 0;
|
||||
int ib = 0;
|
||||
int iw = 0;
|
||||
int ii = 0;
|
||||
bit[0] = 19;
|
||||
bit[1] = 8;
|
||||
idr = 0;
|
||||
for (ib = 0; ib < nch; ib++) {
|
||||
val[ib] = 0;
|
||||
}
|
||||
wp = (int64_t *)ptr;
|
||||
virtual int setFrameNumber(int f=0) {if (f>=0) frameNumber=f; return frameNumber; };
|
||||
virtual int setDynamicRange(int d=-1) {if (d>0 && d<=24) dynamicRange=d; return dynamicRange;};
|
||||
virtual int setSerialOffset(int d=-1) {if (d>=0) serialOffset=d; return serialOffset;};
|
||||
virtual int setNumberOfCounters(int d=-1) {if (d>=0) numberOfCounters=d; return numberOfCounters;};
|
||||
|
||||
|
||||
for (iw = 0; iw < nch / nb; iw) {
|
||||
word = *wp;
|
||||
;
|
||||
if (ioff < off) {
|
||||
ioff++;
|
||||
cout << "*";
|
||||
} else {
|
||||
private:
|
||||
|
||||
int dynamicRange;
|
||||
int serialOffset;
|
||||
int frameNumber;
|
||||
int numberOfCounters;
|
||||
|
||||
|
||||
|
||||
if (idr < 16) {
|
||||
for (ib = 0; ib < nb; ib++) {
|
||||
if (word & (1 << bit[ib])) {
|
||||
cout << "+";
|
||||
val[iw + nch / nb * (ib)] |= (1 << idr);
|
||||
} else {
|
||||
cout << "-";
|
||||
}
|
||||
} // end for()
|
||||
}
|
||||
|
||||
idr++;
|
||||
|
||||
if (idr == dr) {
|
||||
idr = 0;
|
||||
// cout << dec << " " << iw << " " << val[iw] << " " <<
|
||||
// val[iw+nch/2] << endl;
|
||||
cout << dec << iw << endl;
|
||||
iw++;
|
||||
} // end if()
|
||||
|
||||
} // end else()
|
||||
wp += 1;
|
||||
ii++;
|
||||
} // end for
|
||||
|
||||
cout << "M3.01 Decoded " << ii << " samples" << endl;
|
||||
cout << "M3.01 Should be " << nch / nb * dr + off << " samples" << endl;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
virtual int setFrameNumber(int f = 0) {
|
||||
if (f >= 0)
|
||||
frameNumber = f;
|
||||
return frameNumber;
|
||||
};
|
||||
virtual int setDynamicRange(int d = -1) {
|
||||
if (d > 0 && d <= 24)
|
||||
dynamicRange = d;
|
||||
return dynamicRange;
|
||||
};
|
||||
virtual int setSerialOffset(int d = -1) {
|
||||
if (d >= 0)
|
||||
serialOffset = d;
|
||||
return serialOffset;
|
||||
};
|
||||
virtual int setNumberOfCounters(int d = -1) {
|
||||
if (d >= 0)
|
||||
numberOfCounters = d;
|
||||
return numberOfCounters;
|
||||
};
|
||||
|
||||
private:
|
||||
int dynamicRange;
|
||||
int serialOffset;
|
||||
int frameNumber;
|
||||
int numberOfCounters;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -3,131 +3,130 @@
|
||||
#ifndef MYTHEN302JCTBDATA_H
|
||||
#define MYTHEN302JCTBDATA_H
|
||||
|
||||
|
||||
#include "Mythen3_01_jctbData.h"
|
||||
// class mythen3_02_jctbData : public slsDetectorData<short unsigned int> {
|
||||
//class mythen3_02_jctbData : public slsDetectorData<short unsigned int> {
|
||||
class mythen3_02_jctbData : public mythen3_01_jctbData {
|
||||
|
||||
public:
|
||||
mythen3_02_jctbData(int nch = 64 * 3, int dr = 24, int off = 5)
|
||||
: mythen3_01_jctbData(nch, dr, off)
|
||||
// slsDetectorData<short unsigned
|
||||
// int>(64*3,1,dr*8*nch,NULL,NULL,NULL), dynamicRange(dr),
|
||||
// serialOffset(off), frameNumber(0), numberOfCounters(nch)
|
||||
{};
|
||||
|
||||
/* virtual void getPixel(int ip, int &x, int &y) {x=-1; y=-1;}; */
|
||||
public:
|
||||
mythen3_02_jctbData( int nch=64*3,int dr=24, int off=5): mythen3_01_jctbData( nch,dr, off)
|
||||
//slsDetectorData<short unsigned int>(64*3,1,dr*8*nch,NULL,NULL,NULL), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch)
|
||||
{};
|
||||
|
||||
/* virtual short unsigned int getChannel(char *data, int ix, int iy=0) { */
|
||||
/* int ret=-1; */
|
||||
/* short unsigned int
|
||||
* *val=mythen03_frame(data,dynamicRange,numberOfCounters,serialOffset); */
|
||||
/* if (ix>=0 && ix<numberOfCounters) ret=val[ix]; */
|
||||
/* delete [] val; */
|
||||
/* return ret; */
|
||||
/* }; */
|
||||
/* virtual void getPixel(int ip, int &x, int &y) {x=-1; y=-1;}; */
|
||||
|
||||
/* virtual short unsigned int getChannel(char *data, int ix, int iy=0) { */
|
||||
/* int ret=-1; */
|
||||
/* short unsigned int *val=mythen03_frame(data,dynamicRange,numberOfCounters,serialOffset); */
|
||||
/* if (ix>=0 && ix<numberOfCounters) ret=val[ix]; */
|
||||
/* delete [] val; */
|
||||
/* return ret; */
|
||||
/* }; */
|
||||
|
||||
/* virtual int getFrameNumber(char *buff) {return frameNumber;}; */
|
||||
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize) { */
|
||||
/* ndata=dsize; */
|
||||
/* return data; */
|
||||
/* } */
|
||||
|
||||
/* virtual char *readNextFrame(ifstream &filebin) { */
|
||||
/* char *data=NULL; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* data=new char[dataSize]; */
|
||||
/* filebin.read(data,dataSize); */
|
||||
/* } */
|
||||
/* return data; */
|
||||
/* } */
|
||||
|
||||
/* virtual short unsigned int **getData(char *ptr, int dsize=-1) { */
|
||||
/* short unsigned int **val; */
|
||||
/* val=new short unsigned int*[1]; */
|
||||
/* val[0]=mythen03_frame(ptr,dynamicRange,nx,serialOffset); */
|
||||
/* return val; */
|
||||
|
||||
/* } */
|
||||
|
||||
|
||||
/* virtual int getFrameNumber(char *buff) {return frameNumber;}; */
|
||||
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize) { */
|
||||
/* ndata=dsize; */
|
||||
/* return data; */
|
||||
/* } */
|
||||
|
||||
/* virtual char *readNextFrame(ifstream &filebin) { */
|
||||
/* char *data=NULL; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* data=new char[dataSize]; */
|
||||
/* filebin.read(data,dataSize); */
|
||||
/* } */
|
||||
/* return data; */
|
||||
/* } */
|
||||
|
||||
/* virtual short unsigned int **getData(char *ptr, int dsize=-1) { */
|
||||
/* short unsigned int **val; */
|
||||
/* val=new short unsigned int*[1]; */
|
||||
/* val[0]=mythen03_frame(ptr,dynamicRange,nx,serialOffset); */
|
||||
/* return val; */
|
||||
|
||||
/* } */
|
||||
|
||||
virtual short unsigned int *mythen03_frame(char *ptr, int dr = 24,
|
||||
int nch = 64 * 3, int off = 5) {
|
||||
// off=0;
|
||||
// int iarg;
|
||||
int64_t word, *wp;
|
||||
short unsigned int *val = new short unsigned int[nch];
|
||||
int bit[64];
|
||||
int nb = 2;
|
||||
int ioff = 0;
|
||||
int idr = 0;
|
||||
int ib = 0;
|
||||
// int ich=0;
|
||||
int ii = 0;
|
||||
int iw = 0;
|
||||
bit[0] = 17; // 19;
|
||||
bit[1] = 6; // 8;
|
||||
idr = 0;
|
||||
for (ib = 0; ib < nch; ib++) {
|
||||
val[ib] = 0;
|
||||
}
|
||||
wp = (int64_t *)ptr;
|
||||
|
||||
for (iw = 0; iw < nch / nb; iw) {
|
||||
word = *wp;
|
||||
|
||||
if (ioff < off) {
|
||||
ioff++;
|
||||
cout << "*";
|
||||
} else {
|
||||
|
||||
if (idr < 16) {
|
||||
for (ib = 0; ib < nb; ib++) {
|
||||
if (word & (1 << bit[ib])) {
|
||||
cout << "+";
|
||||
val[iw + nch / nb * (ib)] |= (1 << idr);
|
||||
} else {
|
||||
cout << "-";
|
||||
}
|
||||
// cout << iw+nch/nb*(ib)<< " " ;
|
||||
} // end for()
|
||||
}
|
||||
|
||||
idr++;
|
||||
|
||||
if (idr == dr) {
|
||||
idr = 0;
|
||||
// cout << dec << " " << iw << " " << val[iw] << " " <<
|
||||
// val[iw+nch/2] << endl;
|
||||
cout << dec << iw << endl;
|
||||
iw++;
|
||||
} // end if()
|
||||
|
||||
} // end else()
|
||||
wp += 1;
|
||||
ii++;
|
||||
} // end for
|
||||
|
||||
cout << "M3.02 Decoded " << ii << " samples" << endl;
|
||||
cout << "M3.02 Should be " << nch / nb * dr + off << " samples" << endl;
|
||||
|
||||
return val;
|
||||
virtual short unsigned int* mythen03_frame(char *ptr, int dr=24, int nch=64*3, int off=5) {
|
||||
// off=0;
|
||||
//int iarg;
|
||||
int64_t word, *wp;
|
||||
short unsigned int* val=new short unsigned int[nch];
|
||||
int bit[64];
|
||||
int nb=2;
|
||||
int ioff=0;
|
||||
int idr=0;
|
||||
int ib=0;
|
||||
//int ich=0;
|
||||
int ii=0;
|
||||
int iw=0;
|
||||
bit[0]=17;//19;
|
||||
bit[1]=6;//8;
|
||||
idr=0;
|
||||
for (ib=0; ib<nch; ib++) {
|
||||
val[ib]=0;
|
||||
}
|
||||
wp=(int64_t*)ptr;
|
||||
|
||||
for (iw=0; iw<nch/nb; iw) {
|
||||
word=*wp;
|
||||
|
||||
/* virtual int setFrameNumber(int f=0) {if (f>=0) frameNumber=f; return
|
||||
* frameNumber; }; */
|
||||
/* virtual int setDynamicRange(int d=-1) {if (d>0 && d<=24) dynamicRange=d;
|
||||
* return dynamicRange;}; */
|
||||
/* virtual int setSerialOffset(int d=-1) {if (d>=0) serialOffset=d; return
|
||||
* serialOffset;}; */
|
||||
/* virtual int setNumberOfCounters(int d=-1) {if (d>=0) numberOfCounters=d;
|
||||
* return numberOfCounters;}; */
|
||||
if (ioff<off) {
|
||||
ioff++;
|
||||
cout <<"*";
|
||||
} else {
|
||||
|
||||
if (idr<16) {
|
||||
for (ib=0; ib<nb; ib++) {
|
||||
if (word&(1<<bit[ib])) {
|
||||
cout << "+" ;
|
||||
val[iw+nch/nb*(ib)]|=(1<<idr);
|
||||
} else {
|
||||
cout << "-" ;
|
||||
}
|
||||
// cout << iw+nch/nb*(ib)<< " " ;
|
||||
}//end for()
|
||||
}
|
||||
|
||||
idr++;
|
||||
|
||||
|
||||
if (idr==dr) {
|
||||
idr=0;
|
||||
// cout << dec << " " << iw << " " << val[iw] << " " << val[iw+nch/2] << endl;
|
||||
cout <<dec << iw<<endl;
|
||||
iw++;
|
||||
}//end if()
|
||||
|
||||
}//end else()
|
||||
wp+=1;
|
||||
ii++;
|
||||
}//end for
|
||||
|
||||
cout << "M3.02 Decoded "<<ii << " samples"<< endl;
|
||||
cout << "M3.02 Should be "<< nch/nb*dr+off << " samples"<< endl;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/* virtual int setFrameNumber(int f=0) {if (f>=0) frameNumber=f; return frameNumber; }; */
|
||||
/* virtual int setDynamicRange(int d=-1) {if (d>0 && d<=24) dynamicRange=d; return dynamicRange;}; */
|
||||
/* virtual int setSerialOffset(int d=-1) {if (d>=0) serialOffset=d; return serialOffset;}; */
|
||||
/* virtual int setNumberOfCounters(int d=-1) {if (d>=0) numberOfCounters=d; return numberOfCounters;}; */
|
||||
|
||||
|
||||
/* private: */
|
||||
|
||||
/* int dynamicRange; */
|
||||
/* int serialOffset; */
|
||||
/* int frameNumber; */
|
||||
/* int numberOfCounters; */
|
||||
|
||||
|
||||
|
||||
/* private: */
|
||||
|
||||
/* int dynamicRange; */
|
||||
/* int serialOffset; */
|
||||
/* int frameNumber; */
|
||||
/* int numberOfCounters; */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -3,63 +3,63 @@
|
||||
#ifndef ADCSAR2_JCTBDATA_H
|
||||
#define ADCSAR2_JCTBDATA_H
|
||||
|
||||
|
||||
class adcSar2_jctbData : public slsDetectorData<short unsigned int> {
|
||||
|
||||
public:
|
||||
adcSar2_jctbData(int nsamples = 1000)
|
||||
: slsDetectorData<short unsigned int>(nsamples, 1, nsamples * 8, NULL,
|
||||
NULL, NULL){};
|
||||
|
||||
virtual void getPixel(int ip, int &x, int &y) {
|
||||
x = ip / 8;
|
||||
y = 1;
|
||||
};
|
||||
public:
|
||||
adcSar2_jctbData(int nsamples=1000): slsDetectorData<short unsigned int>(nsamples,1,nsamples*8,NULL,NULL,NULL){};
|
||||
|
||||
virtual short unsigned int getChannel(char *data, int ix, int iy = 0) {
|
||||
int adcvalue = 0;
|
||||
int vv1 = *((int16_t *)(data + 8 * ix));
|
||||
int vv2 = *((int16_t *)(data + 8 * ix + 2));
|
||||
for (int jj = 0; jj < 8; jj++) {
|
||||
adcvalue = adcvalue + (((vv1 >> (jj * 2)) & 0x1) << (jj));
|
||||
}
|
||||
for (int jj = 0; jj < 4; jj++) {
|
||||
adcvalue = adcvalue + (((vv2 >> (jj * 2)) & 0x1) << (jj + 8));
|
||||
}
|
||||
return adcvalue;
|
||||
};
|
||||
|
||||
virtual int getFrameNumber(char *buff) { return frameNumber; };
|
||||
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
ndata = dsize;
|
||||
return data;
|
||||
virtual void getPixel(int ip, int &x, int &y) {x=ip/8; y=1;};
|
||||
|
||||
virtual short unsigned int getChannel(char *data, int ix, int iy=0) {
|
||||
int adcvalue=0;
|
||||
int vv1= *((int16_t*) (data+8*ix));
|
||||
int vv2= *((int16_t*) (data+8*ix+2));
|
||||
for (int jj=0;jj<8;jj++){
|
||||
adcvalue=adcvalue+ (((vv1>>(jj*2)) & 0x1)<<(jj));
|
||||
}
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
char *data = NULL;
|
||||
if (filebin.is_open()) {
|
||||
data = new char[dataSize];
|
||||
filebin.read(data, dataSize);
|
||||
}
|
||||
return data;
|
||||
for (int jj=0;jj<4;jj++){
|
||||
adcvalue=adcvalue+ (((vv2>>(jj*2)) & 0x1)<<(jj+8));
|
||||
}
|
||||
return adcvalue;
|
||||
};
|
||||
|
||||
virtual int getFrameNumber(char *buff) {return frameNumber;};
|
||||
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
ndata=dsize;
|
||||
return data;
|
||||
}
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
char *data=NULL;
|
||||
if (filebin.is_open()) {
|
||||
data=new char[dataSize];
|
||||
filebin.read(data,dataSize);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/* virtual int **getData(char *ptr, int dsize=-1) { */
|
||||
/* int **val; */
|
||||
/* val=new int*[1]; */
|
||||
/* val[0]=mythen03_frame(ptr,dynamicRange,nx,serialOffset); */
|
||||
/* return val; */
|
||||
|
||||
/* } */
|
||||
|
||||
|
||||
/* virtual int **getData(char *ptr, int dsize=-1) { */
|
||||
/* int **val; */
|
||||
/* val=new int*[1]; */
|
||||
/* val[0]=mythen03_frame(ptr,dynamicRange,nx,serialOffset); */
|
||||
/* return val; */
|
||||
|
||||
/* } */
|
||||
virtual int setFrameNumber(int f=0) {if (f>=0) frameNumber=f; return frameNumber; };
|
||||
|
||||
private:
|
||||
|
||||
int frameNumber;
|
||||
|
||||
|
||||
|
||||
virtual int setFrameNumber(int f = 0) {
|
||||
if (f >= 0)
|
||||
frameNumber = f;
|
||||
return frameNumber;
|
||||
};
|
||||
|
||||
private:
|
||||
int frameNumber;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -7,97 +7,85 @@
|
||||
|
||||
class chiptestBoardData : public slsDetectorData<uint16_t> {
|
||||
|
||||
public:
|
||||
/**
|
||||
chiptestBoard data structure. Works for data acquired using the
|
||||
chiptestBoard. Inherits and implements slsDetectorData.
|
||||
|
||||
Constructor (no error checking if datasize and offsets are compatible!)
|
||||
\param npx number of pixels in the x direction
|
||||
\param npy number of pixels in the y direction (1 for strips)
|
||||
\param nadc number of adcs
|
||||
\param offset offset at the beginning of the pattern
|
||||
\param dMap array of size nx*ny storing the pointers to the data in the
|
||||
dataset (as offset) \param dMask Array of size nx*ny storing the polarity of
|
||||
the data in the dataset (should be 0 if no inversion is required, 0xffffffff
|
||||
is inversion is required) \param dROI Array of size nx*ny. The elements are
|
||||
1s if the channel is good or in the ROI, 0 is bad or out of the ROI. NULL
|
||||
(default) means all 1s.
|
||||
public:
|
||||
|
||||
*/
|
||||
chiptestBoardData(int npx, int npy, int nadc, int offset, int **dMap = NULL,
|
||||
uint16_t **dMask = NULL, int **dROI = NULL)
|
||||
: slsDetectorData<uint16_t>(npx, npy, nadc * (npx * npy) + offset, dMap,
|
||||
dMask, dROI),
|
||||
nAdc(nadc), offSize(offset),
|
||||
iframe(0){}; // should be? nadc*(npx*npy+offset)
|
||||
/**
|
||||
chiptestBoard data structure. Works for data acquired using the chiptestBoard.
|
||||
Inherits and implements slsDetectorData.
|
||||
|
||||
/**
|
||||
Constructor (no error checking if datasize and offsets are compatible!)
|
||||
\param npx number of pixels in the x direction
|
||||
\param npy number of pixels in the y direction (1 for strips)
|
||||
\param nadc number of adcs
|
||||
\param offset offset at the beginning of the pattern
|
||||
\param dMap array of size nx*ny storing the pointers to the data in the dataset (as offset)
|
||||
\param dMask Array of size nx*ny storing the polarity of the data in the dataset (should be 0 if no inversion is required, 0xffffffff is inversion is required)
|
||||
\param dROI Array of size nx*ny. The elements are 1s if the channel is good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
|
||||
|
||||
Returns the frame number for the given dataset. Virtual func: works for
|
||||
slsDetectorReceiver data (also for each packet), but can be overloaded.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
*/
|
||||
chiptestBoardData(int npx, int npy, int nadc, int offset, int **dMap=NULL, uint16_t **dMask=NULL, int **dROI=NULL): slsDetectorData<uint16_t>(npx, npy, nadc*(npx*npy)+offset, dMap, dMask, dROI), nAdc(nadc), offSize(offset), iframe(0) {}; // should be? nadc*(npx*npy+offset)
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
|
||||
virtual int getFrameNumber(char *buff) {
|
||||
(void)buff;
|
||||
return iframe;
|
||||
};
|
||||
Returns the frame number for the given dataset. Virtual func: works for slsDetectorReceiver data (also for each packet), but can be overloaded.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets
|
||||
0 to nPackets, same frame number). Can be overloaded for different kind of
|
||||
detectors! \param data pointer to the memory to be analyzed \param ndata
|
||||
size of frame returned \param dsize size of the memory slot to be analyzed
|
||||
\returns always return the pointer to data (no frame loss!)
|
||||
*/
|
||||
virtual int getFrameNumber(char *buff){(void)buff; return iframe;};
|
||||
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
ndata = dsize;
|
||||
setDataSize(dsize);
|
||||
return data;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets
|
||||
0 to nPackets, same frame number). Can be overloaded for different kind of
|
||||
detectors! \param filebin input file stream (binary) \returns pointer to
|
||||
the first packet of the last good frame, NULL if no frame is found or last
|
||||
frame is incomplete
|
||||
*/
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata size of frame returned
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns always return the pointer to data (no frame loss!)
|
||||
*/
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {ndata=dsize;setDataSize(dsize); return data;};
|
||||
|
||||
int afifo_length = 0;
|
||||
uint16_t *afifo_cont;
|
||||
/**
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
|
||||
\param filebin input file stream (binary)
|
||||
\returns pointer to the first packet of the last good frame, NULL if no frame is found or last frame is incomplete
|
||||
*/
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read((char *)&afifo_length, sizeof(uint32_t))) {
|
||||
setDataSize(afifo_length * nAdc * sizeof(uint16_t));
|
||||
afifo_cont = new uint16_t[afifo_length * nAdc];
|
||||
if (filebin.read((char *)afifo_cont,
|
||||
afifo_length * sizeof(uint16_t) * nAdc)) {
|
||||
iframe++;
|
||||
return (char *)afifo_cont;
|
||||
} else {
|
||||
delete[] afifo_cont;
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
|
||||
int afifo_length=0;
|
||||
uint16_t *afifo_cont;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read((char*)&afifo_length,sizeof(uint32_t))) {
|
||||
setDataSize(afifo_length*nAdc*sizeof(uint16_t));
|
||||
afifo_cont=new uint16_t[afifo_length*nAdc];
|
||||
if (filebin.read((char*)afifo_cont,afifo_length*sizeof(uint16_t)*nAdc)) {
|
||||
iframe++;
|
||||
return (char*)afifo_cont;
|
||||
} else {
|
||||
delete [] afifo_cont;
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
private:
|
||||
const int nAdc; /**<number of ADC read out */
|
||||
const int offSize; /**< offset at the beginning of the frame (depends on the pattern) */
|
||||
int iframe; /**< frame number (calculated in software! not in the data)*/
|
||||
|
||||
private:
|
||||
const int nAdc; /**<number of ADC read out */
|
||||
const int offSize; /**< offset at the beginning of the frame (depends on the
|
||||
pattern) */
|
||||
int iframe; /**< frame number (calculated in software! not in the data)*/
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -2,232 +2,207 @@
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef DESERIALIZER_H
|
||||
#define DESERIALIZER_H
|
||||
#include "slsDetectorData.h"
|
||||
#include <vector>
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
class deserializer : public slsDetectorData<int> {
|
||||
|
||||
public:
|
||||
deserializer(std::vector<int> dbl, int nch = 64 * 3, int dr = 24,
|
||||
int off = 2)
|
||||
: slsDetectorData<int>(nch, 1, nch * dr * 8 + off * 8, NULL, NULL,
|
||||
NULL),
|
||||
dynamicRange(dr), serialOffset(off), frameNumber(0),
|
||||
numberOfCounters(nch), dbitlist(dbl){};
|
||||
|
||||
deserializer(std::vector<int> dbl, int nch, int dr, int off, int ds)
|
||||
: slsDetectorData<int>(nch, 1, ds, NULL, NULL, NULL), dynamicRange(dr),
|
||||
serialOffset(off), frameNumber(0), numberOfCounters(nch),
|
||||
dbitlist(dbl){};
|
||||
public:
|
||||
|
||||
virtual void getPixel(int ip, int &x, int &y) {
|
||||
x = -1;
|
||||
y = -1;
|
||||
};
|
||||
|
||||
virtual int getChannel(char *data, int ix, int iy = 0) {
|
||||
int ret = -1;
|
||||
if (ix >= 0 && ix < numberOfCounters) {
|
||||
int *val = deserializeAll(data, dbitlist, dynamicRange,
|
||||
numberOfCounters, serialOffset);
|
||||
ret = val[ix];
|
||||
delete[] val;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
deserializer( std::vector <int> dbl, int nch=64*3,int dr=24, int off=2): slsDetectorData<int>(nch,1,nch*dr*8+off*8,NULL,NULL,NULL), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch), dbitlist(dbl) {};
|
||||
|
||||
virtual int getFrameNumber(char *buff) { return frameNumber; };
|
||||
deserializer( std::vector <int> dbl, int nch,int dr, int off, int ds): slsDetectorData<int>(nch,1,ds,NULL,NULL,NULL), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch), dbitlist(dbl) {};
|
||||
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
ndata = dsize;
|
||||
return data;
|
||||
virtual void getPixel(int ip, int &x, int &y) {x=-1; y=-1;};
|
||||
|
||||
virtual int getChannel(char *data, int ix, int iy=0) {
|
||||
int ret=-1;
|
||||
if (ix>=0 && ix<numberOfCounters) {
|
||||
int *val=deserializeAll(data,dbitlist,dynamicRange,numberOfCounters,serialOffset);
|
||||
ret=val[ix];
|
||||
delete [] val;
|
||||
}
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
char *data = NULL;
|
||||
if (filebin.is_open()) {
|
||||
data = new char[dataSize];
|
||||
filebin.read(data, dataSize);
|
||||
}
|
||||
return data;
|
||||
return ret;
|
||||
};
|
||||
|
||||
virtual int getFrameNumber(char *buff) {return frameNumber;};
|
||||
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
ndata=dsize;
|
||||
return data;
|
||||
}
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
char *data=NULL;
|
||||
if (filebin.is_open()) {
|
||||
data=new char[dataSize];
|
||||
filebin.read(data,dataSize);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
virtual int **getData(char *ptr, int dsize=-1) {
|
||||
int **val;
|
||||
val=new int*[1];
|
||||
val[0]=deserializeAll(ptr,dbitlist,dynamicRange,nx,serialOffset);
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual int **getData(char *ptr, int dsize = -1) {
|
||||
int **val;
|
||||
val = new int *[1];
|
||||
val[0] = deserializeAll(ptr, dbitlist, dynamicRange, nx, serialOffset);
|
||||
return val;
|
||||
}
|
||||
static int* deserializeAll(char *ptr, std::vector <int> dbl, int dr=24, int nch=64*3, int off=5) {
|
||||
// off=0;
|
||||
//int iarg;
|
||||
|
||||
static int *deserializeAll(char *ptr, std::vector<int> dbl, int dr = 24,
|
||||
int nch = 64 * 3, int off = 5) {
|
||||
// off=0;
|
||||
// int iarg;
|
||||
|
||||
cout << "** deserializer: " << endl;
|
||||
cout << "** Number of chans:\t" << nch << endl;
|
||||
cout << "** Serial Offset:\t" << off << endl;
|
||||
cout << "** Dynamic range:\t" << dr << endl;
|
||||
int64_t word, *wp, ww, one = 1, bit;
|
||||
int *val = new int[nch];
|
||||
int ioff = 0;
|
||||
int idr = 0;
|
||||
int ib = 0;
|
||||
int iw = 0;
|
||||
int ii = 0;
|
||||
int ich;
|
||||
int nb = dbl.size();
|
||||
idr = 0;
|
||||
for (ib = 0; ib < nch; ib++) {
|
||||
val[ib] = 0;
|
||||
}
|
||||
wp = (int64_t *)ptr;
|
||||
cout <<"** deserializer: " << endl;
|
||||
cout << "** Number of chans:\t" << nch << endl;
|
||||
cout << "** Serial Offset:\t" << off << endl;
|
||||
cout << "** Dynamic range:\t" << dr << endl;
|
||||
int64_t word, *wp, ww,one=1, bit ;
|
||||
int* val=new int[nch];
|
||||
int ioff=0;
|
||||
int idr=0;
|
||||
int ib=0;
|
||||
int iw=0;
|
||||
int ii=0;
|
||||
int ich;
|
||||
int nb=dbl.size();
|
||||
idr=0;
|
||||
for (ib=0; ib<nch; ib++) {
|
||||
val[ib]=0;
|
||||
}
|
||||
wp=(int64_t*)ptr;
|
||||
|
||||
int nw = nch / nb;
|
||||
int nw=nch/nb;
|
||||
|
||||
cout << "** Number of bits:\t" << nb << endl;
|
||||
cout << "** Samples:\t" << nw << endl;
|
||||
cout << "** Number of bits:\t" << nb << endl;
|
||||
cout << "** Samples:\t" << nw << endl;
|
||||
|
||||
for (ib=0; ib<nb; ib++) {
|
||||
cout << dbl[ib] << " " ;
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
for (ib=0; ib<nch; ib++) {
|
||||
val[ib]=0;
|
||||
}
|
||||
|
||||
for (iw=0; iw<nw; iw) {
|
||||
word=*wp;;
|
||||
if (ioff<off) {
|
||||
ioff++;
|
||||
// cout <<"*";
|
||||
} else {
|
||||
//if (idr<16) {
|
||||
//ib=0;
|
||||
// cout << hex << "*************" << word << endl;
|
||||
for (ib=0; ib<nb; ib++) {
|
||||
// for (const auto &bit : dbl) {
|
||||
ich=iw+nch*ib/nb;
|
||||
/* if (ich>1060) */
|
||||
/* cout << iw << " " << idr << " " << ib << " " << bit << " " << ich << " " << val[ich] << " ** " ; */
|
||||
bit=dbl[ib];
|
||||
ww=one<<bit;
|
||||
if (word&(ww) && ich<nch) {
|
||||
//cout << "+" ;
|
||||
val[ich]|=(1<<idr);
|
||||
}
|
||||
/* if (ich>1060) */
|
||||
/* cout << val[ich] << " " << hex << word << " " << ww << " " << (word&(ww)) << dec <<endl; */
|
||||
/* //else { */
|
||||
//cout << "-" ;
|
||||
//}
|
||||
//ib++;
|
||||
}
|
||||
|
||||
idr++;
|
||||
}
|
||||
|
||||
if (idr==dr) {
|
||||
idr=0;
|
||||
// cout << dec << " " << iw << " " << val[iw] << " " << val[iw+nch/2] << endl;
|
||||
// cout <<dec << iw<<endl;
|
||||
iw++;
|
||||
}//end if()
|
||||
|
||||
//end else()
|
||||
wp+=1;
|
||||
// ii++;
|
||||
}//end for
|
||||
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
for (ib = 0; ib < nb; ib++) {
|
||||
cout << dbl[ib] << " ";
|
||||
}
|
||||
cout << endl;
|
||||
static int* deserializeList(char *ptr, std::vector <int> dbl, int dr=24, int nch=64*3, int off=5) {
|
||||
// off=0;
|
||||
//int iarg;
|
||||
// int64_t word;
|
||||
int* val=new int[nch];
|
||||
//int ioff=0;
|
||||
int idr=0;
|
||||
int ib=0;
|
||||
int iw=0;
|
||||
int ii=0;
|
||||
int ich;
|
||||
int nb=dbl.size();
|
||||
int bit;
|
||||
char *dval;
|
||||
|
||||
for (ib = 0; ib < nch; ib++) {
|
||||
val[ib] = 0;
|
||||
}
|
||||
idr=0;
|
||||
for (ib=0; ib<nch; ib++) {
|
||||
val[ib]=0;
|
||||
}
|
||||
dval=ptr;
|
||||
|
||||
ib=0;
|
||||
ich=0;
|
||||
for (ib=0; ib<nb; ib++) {
|
||||
// for (const auto &bit : dbl) {
|
||||
|
||||
for (iw = 0; iw < nw; iw) {
|
||||
word = *wp;
|
||||
;
|
||||
if (ioff < off) {
|
||||
ioff++;
|
||||
// cout <<"*";
|
||||
} else {
|
||||
// if (idr<16) {
|
||||
// ib=0;
|
||||
// cout << hex << "*************" << word << endl;
|
||||
for (ib = 0; ib < nb; ib++) {
|
||||
// for (const auto &bit : dbl) {
|
||||
ich = iw + nch * ib / nb;
|
||||
/* if (ich>1060) */
|
||||
/* cout << iw << " " << idr << " " << ib << " " << bit << "
|
||||
* " << ich << " " << val[ich] << " ** " ; */
|
||||
bit = dbl[ib];
|
||||
ww = one << bit;
|
||||
if (word & (ww) && ich < nch) {
|
||||
// cout << "+" ;
|
||||
val[ich] |= (1 << idr);
|
||||
}
|
||||
/* if (ich>1060) */
|
||||
/* cout << val[ich] << " " << hex << word << " " << ww <<
|
||||
* " " << (word&(ww)) << dec <<endl; */
|
||||
/* //else { */
|
||||
// cout << "-" ;
|
||||
// }
|
||||
// ib++;
|
||||
}
|
||||
/* if (ich>1060) */
|
||||
/* cout << iw << " " << idr << " " << ib << " " << bit << " " << ich << " " << val[ich] << " ** " ; */
|
||||
bit=dbl[ib];
|
||||
//ioff=off;
|
||||
idr=0;
|
||||
for (iw=0; iw<(nch*dr/nb)/8; iw++) {
|
||||
val[ich]|=(*dval)<<idr;
|
||||
idr+=8;
|
||||
dval++;
|
||||
if (idr>=dr) {
|
||||
idr=0;
|
||||
ich++;
|
||||
}
|
||||
}
|
||||
ii++;
|
||||
// ib++;
|
||||
}//end for
|
||||
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
idr++;
|
||||
}
|
||||
virtual int setFrameNumber(int f=0) {if (f>=0) frameNumber=f; return frameNumber; };
|
||||
virtual int setDynamicRange(int d=-1) {if (d>0 && d<=24) dynamicRange=d; return dynamicRange;};
|
||||
virtual int setSerialOffset(int d=-1) {if (d>=0) serialOffset=d; return serialOffset;};
|
||||
virtual int setNumberOfCounters(int d=-1) {if (d>=0) numberOfCounters=d; return numberOfCounters;};
|
||||
virtual std::vector <int> setDBitList(std::vector <int> dbl) {dbitlist=dbl; return dbitlist;};
|
||||
virtual std::vector <int> getDBitList() {return dbitlist;};
|
||||
|
||||
|
||||
private:
|
||||
|
||||
int dynamicRange;
|
||||
int serialOffset;
|
||||
int frameNumber;
|
||||
int numberOfCounters;
|
||||
std::vector <int> dbitlist;
|
||||
|
||||
|
||||
if (idr == dr) {
|
||||
idr = 0;
|
||||
// cout << dec << " " << iw << " " << val[iw] << " " <<
|
||||
// val[iw+nch/2] << endl;
|
||||
// cout <<dec << iw<<endl;
|
||||
iw++;
|
||||
} // end if()
|
||||
|
||||
// end else()
|
||||
wp += 1;
|
||||
// ii++;
|
||||
} // end for
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static int *deserializeList(char *ptr, std::vector<int> dbl, int dr = 24,
|
||||
int nch = 64 * 3, int off = 5) {
|
||||
// off=0;
|
||||
// int iarg;
|
||||
// int64_t word;
|
||||
int *val = new int[nch];
|
||||
// int ioff=0;
|
||||
int idr = 0;
|
||||
int ib = 0;
|
||||
int iw = 0;
|
||||
int ii = 0;
|
||||
int ich;
|
||||
int nb = dbl.size();
|
||||
int bit;
|
||||
char *dval;
|
||||
|
||||
idr = 0;
|
||||
for (ib = 0; ib < nch; ib++) {
|
||||
val[ib] = 0;
|
||||
}
|
||||
dval = ptr;
|
||||
|
||||
ib = 0;
|
||||
ich = 0;
|
||||
for (ib = 0; ib < nb; ib++) {
|
||||
// for (const auto &bit : dbl) {
|
||||
|
||||
/* if (ich>1060) */
|
||||
/* cout << iw << " " << idr << " " << ib << " " << bit << " " << ich
|
||||
* << " " << val[ich] << " ** " ; */
|
||||
bit = dbl[ib];
|
||||
// ioff=off;
|
||||
idr = 0;
|
||||
for (iw = 0; iw < (nch * dr / nb) / 8; iw++) {
|
||||
val[ich] |= (*dval) << idr;
|
||||
idr += 8;
|
||||
dval++;
|
||||
if (idr >= dr) {
|
||||
idr = 0;
|
||||
ich++;
|
||||
}
|
||||
}
|
||||
ii++;
|
||||
// ib++;
|
||||
} // end for
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
virtual int setFrameNumber(int f = 0) {
|
||||
if (f >= 0)
|
||||
frameNumber = f;
|
||||
return frameNumber;
|
||||
};
|
||||
virtual int setDynamicRange(int d = -1) {
|
||||
if (d > 0 && d <= 24)
|
||||
dynamicRange = d;
|
||||
return dynamicRange;
|
||||
};
|
||||
virtual int setSerialOffset(int d = -1) {
|
||||
if (d >= 0)
|
||||
serialOffset = d;
|
||||
return serialOffset;
|
||||
};
|
||||
virtual int setNumberOfCounters(int d = -1) {
|
||||
if (d >= 0)
|
||||
numberOfCounters = d;
|
||||
return numberOfCounters;
|
||||
};
|
||||
virtual std::vector<int> setDBitList(std::vector<int> dbl) {
|
||||
dbitlist = dbl;
|
||||
return dbitlist;
|
||||
};
|
||||
virtual std::vector<int> getDBitList() { return dbitlist; };
|
||||
|
||||
private:
|
||||
int dynamicRange;
|
||||
int serialOffset;
|
||||
int frameNumber;
|
||||
int numberOfCounters;
|
||||
std::vector<int> dbitlist;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,155 +1,174 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef GOTTHARD2MODULEDATANEW_H
|
||||
#define GOTTHARD2MODULEDATANEW_H
|
||||
#define GOTTHARD2MODULEDATANEW_H
|
||||
#include "gotthardModuleDataNew.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class gotthardDoubleModuleDataNew : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
const int nModules;
|
||||
const int offset;
|
||||
int iframe;
|
||||
private:
|
||||
const int nModules;
|
||||
const int offset;
|
||||
int iframe;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the gotthard read out by a module
|
||||
i.e. using the slsReceiver (1x1280 pixels, 2 packets 1286 large etc.) \param c
|
||||
crosstalk parameter for the output buffer
|
||||
public:
|
||||
|
||||
*/
|
||||
|
||||
gotthardDoubleModuleDataNew(int off = 24 * 2, int nmod = 2)
|
||||
: slsDetectorData<uint16_t>(1280 * nmod, 1, nmod * (1280 * 2 + off)),
|
||||
nModules(nmod), offset(off), iframe(0) {
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the gotthard read out by a module i.e. using the slsReceiver
|
||||
(1x1280 pixels, 2 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
|
||||
|
||||
gotthardDoubleModuleDataNew(int off=24*2, int nmod=2): slsDetectorData<uint16_t>(1280*nmod, 1, nmod*(1280*2+off)), nModules(nmod), offset(off),iframe(0) {
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef BCHIP074_BCHIP075
|
||||
cout << "This is a bchip074-bchip075 system " << endl;
|
||||
cout << "This is a bchip074-bchip075 system " << endl;
|
||||
#endif
|
||||
|
||||
uint16_t **dMask;
|
||||
int **dMap;
|
||||
int ix, iy;
|
||||
int ypixels = 1;
|
||||
int xpixels = 1280 * nmod;
|
||||
int imod, ipix;
|
||||
dMask = new uint16_t *[1];
|
||||
dMap = new int *[1];
|
||||
dMap[0] = new int[1280 * nmod];
|
||||
dMask[0] = new uint16_t[1280 * nmod];
|
||||
|
||||
for (int ix = 0; ix < xpixels; ix++) {
|
||||
imod = ix % 2;
|
||||
if (imod == 0)
|
||||
ipix = ix / 2;
|
||||
else
|
||||
ipix = 1280 - 1 - ix / 2;
|
||||
if (imod == 0)
|
||||
dMap[0][ix] = ipix * 2 + offset;
|
||||
else
|
||||
dMap[0][ix] = 1280 * 2 + 2 * offset +
|
||||
ipix * 2; // dataSize-2-ix;//+2*offset;
|
||||
// dMap[0][ix] = 2*ipix+offset*(imod+1)+1280*2*imod;
|
||||
dMask[0][ix] = 0x0;
|
||||
uint16_t **dMask;
|
||||
int **dMap;
|
||||
int ix, iy;
|
||||
int ypixels=1;
|
||||
int xpixels=1280*nmod;
|
||||
int imod, ipix;
|
||||
dMask=new uint16_t*[1];
|
||||
dMap=new int*[1];
|
||||
dMap[0] = new int[1280*nmod];
|
||||
dMask[0] = new uint16_t[1280*nmod];
|
||||
|
||||
for(int ix=0; ix<xpixels; ix++) {
|
||||
imod=ix%2;
|
||||
if (imod==0)
|
||||
ipix=ix/2;
|
||||
else
|
||||
ipix=1280-1-ix/2;
|
||||
if (imod==0)
|
||||
dMap[0][ix] =ipix*2+offset;
|
||||
else
|
||||
dMap[0][ix] = 1280*2+2*offset+ipix*2;//dataSize-2-ix;//+2*offset;
|
||||
// dMap[0][ix] = 2*ipix+offset*(imod+1)+1280*2*imod;
|
||||
dMask[0][ix] = 0x0;
|
||||
#ifdef BCHIP074_BCHIP075
|
||||
int ibad = ix / 2 + 1280 * imod;
|
||||
if ((ibad >= 128 * 4 && ibad < 128 * 5) ||
|
||||
(ibad >= 9 * 128 && ibad < 10 * 128) ||
|
||||
(ibad >= (1280 + 128 * 4) && ibad < ibad >= (1280 + 128 * 6)))
|
||||
dataROIMask[0][ix] = 0;
|
||||
int ibad=ix/2+1280*imod;
|
||||
if ((ibad>=128*4 && ibad<128*5) || (ibad>=9*128 && ibad<10*128) || (ibad>=(1280+128*4) && ibad<ibad>=(1280+128*6)))
|
||||
dataROIMask[0][ix]=0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
setDataMap(dMap);
|
||||
setDataMask(dMask);
|
||||
};
|
||||
setDataMap(dMap);
|
||||
setDataMask(dMask);
|
||||
|
||||
/**
|
||||
};
|
||||
|
||||
Returns the frame number for the given dataset.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
/**
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
if (offset >= sizeof(sls_detector_header))
|
||||
return ((sls_detector_header *)buff)->frameNumber;
|
||||
return iframe;
|
||||
}; //*((int*)(buff+5))&0xffffff;};
|
||||
Returns the frame number for the given dataset.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
/**
|
||||
gets the packets number (last packet is labelled with 0 and is replaced with
|
||||
40) \param buff pointer to the memory \returns packet number
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
int getPacketNumber(char *buff) {
|
||||
if (offset >= sizeof(sls_detector_header))
|
||||
return ((sls_detector_header *)buff)->packetNumber;
|
||||
};
|
||||
int getFrameNumber(char *buff){if (offset>=sizeof(sls_detector_header)) return ((sls_detector_header*)buff)->frameNumber; return iframe;};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all
|
||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
||||
data pointer to the memory to be analyzed \param ndata reference to the
|
||||
amount of data found for the frame, in case the frame is incomplete at
|
||||
the end of the memory slot \param dsize size of the memory slot to be
|
||||
analyzed \returns pointer to the beginning of the last good frame (might
|
||||
be incomplete if ndata smaller than dataSize), or NULL if no frame is
|
||||
found
|
||||
/**
|
||||
gets the packets number (last packet is labelled with 0 and is replaced with 40)
|
||||
\param buff pointer to the memory
|
||||
\returns packet number
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
if (dsize < dataSize)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = dataSize;
|
||||
return data;
|
||||
}
|
||||
*/
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
int getPacketNumber(char *buff){if (offset>=sizeof(sls_detector_header))return ((sls_detector_header*)buff)->packetNumber;};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np) {
|
||||
char *data = new char[dataSize];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
char *retval = 0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np = 0;
|
||||
int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff >= 0)
|
||||
fnum = ff;
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<dataSize) ndata=dsize;
|
||||
else ndata=dataSize;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
char *retval=0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np=0;
|
||||
int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
ff=getFrameNumber(data);
|
||||
np=getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
np = getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,105 +1,129 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef GOTTHARDSHORTMODULEDATA_H
|
||||
#define GOTTHARDSHORTMODULEDATA_H
|
||||
#define GOTTHARDSHORTMODULEDATA_H
|
||||
#include "slsReceiverData.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class gotthardShortModuleData : public slsReceiverData<uint16_t> {
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the gotthard short read out by a
|
||||
module i.e. using the slsReceiver (1x256 pixels, 1 packet 256 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
public:
|
||||
|
||||
*/
|
||||
|
||||
gotthardShortModuleData(double c = 0)
|
||||
: slsReceiverData<uint16_t>(xpixels, ypixels, npackets, buffersize),
|
||||
xtalk(c) {
|
||||
|
||||
uint16_t **dMask;
|
||||
int **dMap;
|
||||
int ix, iy;
|
||||
int offset = 2;
|
||||
|
||||
dMask = new uint16_t *[ypixels];
|
||||
dMap = new int *[ypixels];
|
||||
for (int i = 0; i < ypixels; i++) {
|
||||
dMap[i] = new int[xpixels];
|
||||
dMask[i] = new uint16_t[xpixels];
|
||||
}
|
||||
/**
|
||||
Implements the slsReceiverData structure for the gotthard short read out by a module i.e. using the slsReceiver
|
||||
(1x256 pixels, 1 packet 256 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
for (ix = 0; ix < ypixels; ++ix)
|
||||
for (iy = 0; iy < xpixels; ++iy)
|
||||
dMask[ix][iy] = 0x0;
|
||||
*/
|
||||
|
||||
for (ix = 0; ix < ypixels; ++ix)
|
||||
for (iy = 0; iy < xpixels; ++iy) {
|
||||
dMap[ix][iy] = offset;
|
||||
offset++;
|
||||
}
|
||||
|
||||
setDataMap(dMap);
|
||||
setDataMask(dMask);
|
||||
};
|
||||
gotthardShortModuleData(double c=0): slsReceiverData<uint16_t>(xpixels, ypixels, npackets, buffersize), xtalk(c){
|
||||
|
||||
/**
|
||||
uint16_t **dMask;
|
||||
int **dMap;
|
||||
int ix, iy;
|
||||
int offset = 2;
|
||||
|
||||
Returns the frame number for the given dataset.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
dMask=new uint16_t*[ypixels];
|
||||
dMap=new int*[ypixels];
|
||||
for (int i = 0; i < ypixels; i++) {
|
||||
dMap[i] = new int[xpixels];
|
||||
dMask[i] = new uint16_t[xpixels];
|
||||
}
|
||||
|
||||
*/
|
||||
for(ix=0; ix<ypixels; ++ix)
|
||||
for(iy=0; iy<xpixels; ++iy)
|
||||
dMask[ix][iy] = 0x0;
|
||||
|
||||
int getFrameNumber(char *buff) { return (*(int *)buff); };
|
||||
for(ix=0; ix<ypixels; ++ix)
|
||||
for(iy=0; iy<xpixels; ++iy){
|
||||
dMap[ix][iy] = offset;
|
||||
offset++;
|
||||
}
|
||||
|
||||
/**
|
||||
gets the packets number (last packet is labelled with 0 and is replaced with
|
||||
40) \param buff pointer to the memory \returns packet number
|
||||
setDataMap(dMap);
|
||||
setDataMask(dMask);
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
int getPacketNumber(char *buff) { return 1; };
|
||||
/**
|
||||
|
||||
/**
|
||||
returns the pixel value as double correcting for the output buffer crosstalk
|
||||
\param data pointer to the memory
|
||||
\param ix coordinate in the x direction
|
||||
\param iy coordinate in the y direction
|
||||
\returns channel value as double
|
||||
Returns the frame number for the given dataset.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
double getValue(char *data, int ix, int iy = 0) {
|
||||
// check how it is for gotthard
|
||||
if (xtalk == 0)
|
||||
return slsDetectorData<uint16_t>::getValue(data, ix, iy);
|
||||
else
|
||||
return slsDetectorData<uint16_t>::getValue(data, ix, iy) -
|
||||
xtalk *
|
||||
slsDetectorData<uint16_t>::getValue(data, ix - 1, iy);
|
||||
};
|
||||
*/
|
||||
|
||||
/** sets the output buffer crosstalk correction parameter
|
||||
\param c output buffer crosstalk correction parameter to be set
|
||||
\returns current value for the output buffer crosstalk correction parameter
|
||||
int getFrameNumber(char *buff){
|
||||
return (*(int*)buff);
|
||||
};
|
||||
|
||||
*/
|
||||
double setXTalk(double c) {
|
||||
xtalk = c;
|
||||
return xtalk;
|
||||
}
|
||||
|
||||
/** gets the output buffer crosstalk parameter
|
||||
\returns current value for the output buffer crosstalk correction parameter
|
||||
*/
|
||||
double getXTalk() { return xtalk; }
|
||||
|
||||
private:
|
||||
double xtalk; /**<output buffer crosstalk correction parameter */
|
||||
const static int xpixels = 256;
|
||||
const static int ypixels = 1;
|
||||
const static int npackets = 1;
|
||||
const static int buffersize = 518;
|
||||
/**
|
||||
gets the packets number (last packet is labelled with 0 and is replaced with 40)
|
||||
\param buff pointer to the memory
|
||||
\returns packet number
|
||||
|
||||
*/
|
||||
|
||||
int getPacketNumber(char *buff){
|
||||
return 1;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
returns the pixel value as double correcting for the output buffer crosstalk
|
||||
\param data pointer to the memory
|
||||
\param ix coordinate in the x direction
|
||||
\param iy coordinate in the y direction
|
||||
\returns channel value as double
|
||||
|
||||
*/
|
||||
double getValue(char *data, int ix, int iy=0) {
|
||||
//check how it is for gotthard
|
||||
if (xtalk==0)
|
||||
return slsDetectorData<uint16_t>::getValue(data, ix, iy);
|
||||
else
|
||||
return slsDetectorData<uint16_t>::getValue(data, ix, iy)-xtalk*slsDetectorData<uint16_t>::getValue(data, ix-1, iy);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** sets the output buffer crosstalk correction parameter
|
||||
\param c output buffer crosstalk correction parameter to be set
|
||||
\returns current value for the output buffer crosstalk correction parameter
|
||||
|
||||
*/
|
||||
double setXTalk(double c) {xtalk=c; return xtalk;}
|
||||
|
||||
|
||||
/** gets the output buffer crosstalk parameter
|
||||
\returns current value for the output buffer crosstalk correction parameter
|
||||
*/
|
||||
double getXTalk() {return xtalk;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
double xtalk; /**<output buffer crosstalk correction parameter */
|
||||
const static int xpixels = 256;
|
||||
const static int ypixels = 1;
|
||||
const static int npackets = 1;
|
||||
const static int buffersize = 518;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,102 +1,127 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef IMAGEZMQ16BIT_H
|
||||
#define IMAGEZMQ16BIT_H
|
||||
#define IMAGEZMQ16BIT_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
class imageZmq16bit : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
// int iframe;
|
||||
public:
|
||||
|
||||
private:
|
||||
// int iframe;
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
// moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400,
|
||||
// ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) {
|
||||
imageZmq16bit(int nnx = 400, int nny = 400)
|
||||
: slsDetectorData<uint16_t>(nnx, nny, 2 * nnx * nny) {
|
||||
cout << "* " << nx << " " << ny << endl;
|
||||
int is = 0;
|
||||
for (int row = 0; row < ny; row++) {
|
||||
for (int col = 0; col < nx; col++) {
|
||||
dataMap[row][col] = is * 2;
|
||||
is++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
virtual double getValue(char *data, int ix, int iy = 0) {
|
||||
|
||||
cout << ix << " " << ix << dataMap[iy][ix] << 2 * nx * ny << " "
|
||||
<< endl;
|
||||
uint16_t val = getChannel(data, ix, iy) & 0x3fff;
|
||||
return val;
|
||||
};
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
return *((int *)buff);
|
||||
}; //*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
int getPacketNumber(char *buff) {
|
||||
return 0;
|
||||
} //((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np) {
|
||||
char *data = new char[2 * nx * ny];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
*/
|
||||
// moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) {
|
||||
imageZmq16bit(int nnx=400, int nny=400): slsDetectorData<uint16_t>(nnx, nny, 2*nnx*nny) {
|
||||
cout << "* " << nx << " " << ny << endl;
|
||||
int is=0;
|
||||
for (int row=0; row<ny; row++){
|
||||
for(int col=0;col<nx;col++){
|
||||
dataMap[row][col]=is*2;
|
||||
is++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
// char *retval=0;
|
||||
// int nd;
|
||||
// int fnum = -1;
|
||||
np = 0;
|
||||
// int pn;
|
||||
};
|
||||
|
||||
// if (ff>=0)
|
||||
// fnum=ff;
|
||||
virtual double getValue(char *data, int ix, int iy=0) {
|
||||
|
||||
cout << ix << " " << ix << dataMap[iy][ix] << 2*nx*ny << " "<< endl;
|
||||
uint16_t val=getChannel(data, ix, iy)&0x3fff;
|
||||
return val;
|
||||
};
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, 2 * nx * ny)) {
|
||||
// iframe++;
|
||||
// ff=iframe;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
if (dsize < 2 * nx * ny)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = 2 * nx * ny;
|
||||
return data;
|
||||
}
|
||||
int getFrameNumber(char *buff){return *((int*)buff);};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
// virtual int setFrameNumber(int ff){iframe=ff};
|
||||
|
||||
int getPacketNumber(char *buff){return 0;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[2*nx*ny];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
//char *retval=0;
|
||||
// int nd;
|
||||
//int fnum = -1;
|
||||
np=0;
|
||||
// int pn;
|
||||
|
||||
|
||||
// if (ff>=0)
|
||||
// fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, 2*nx*ny) ){
|
||||
// iframe++;
|
||||
//ff=iframe;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<2*nx*ny) ndata=dsize;
|
||||
else ndata=2*nx*ny;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// virtual int setFrameNumber(int ff){iframe=ff};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int getPacketNumber(int x, int y) {return 0;};
|
||||
|
||||
int getPacketNumber(int x, int y) { return 0; };
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,102 +1,127 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef IMAGEZMQ32BIT_H
|
||||
#define IMAGEZMQ32BIT_H
|
||||
#define IMAGEZMQ32BIT_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
class imageZmq32bit : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
// int iframe;
|
||||
public:
|
||||
|
||||
private:
|
||||
// int iframe;
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
// moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400,
|
||||
// ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) {
|
||||
imageZmq32bit(int nnx = 400, int nny = 400)
|
||||
: slsDetectorData<uint16_t>(nnx, nny, sizeof(uint32_t) * nnx * nny) {
|
||||
cout << "* " << nx << " " << ny << endl;
|
||||
int is = 0;
|
||||
for (int row = 0; row < ny; row++) {
|
||||
for (int col = 0; col < nx; col++) {
|
||||
dataMap[row][col] = is * sizeof(uint32_t);
|
||||
is++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* virtual double getValue(char *data, int ix, int iy=0) { */
|
||||
|
||||
/* //cout << ix << " " << ix << dataMap[iy][ix] << 2*nx*ny << " "<< endl;
|
||||
*/
|
||||
/* uint16_t val=getChannel(data, ix, iy); */
|
||||
/* return val; */
|
||||
/* }; */
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
return *((int *)buff);
|
||||
}; //*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
int getPacketNumber(char *buff) {
|
||||
return 0;
|
||||
} //((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np) {
|
||||
char *data = new char[2 * nx * ny];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
*/
|
||||
// moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) {
|
||||
imageZmq32bit(int nnx=400, int nny=400): slsDetectorData<uint16_t>(nnx, nny, sizeof(uint32_t)*nnx*nny) {
|
||||
cout << "* " << nx << " " << ny << endl;
|
||||
int is=0;
|
||||
for (int row=0; row<ny; row++){
|
||||
for(int col=0;col<nx;col++){
|
||||
dataMap[row][col]=is*sizeof(uint32_t);
|
||||
is++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
// char *retval=0;
|
||||
// int nd;
|
||||
// int fnum = -1;
|
||||
np = 0;
|
||||
// int pn;
|
||||
};
|
||||
|
||||
// if (ff>=0)
|
||||
// fnum=ff;
|
||||
/* virtual double getValue(char *data, int ix, int iy=0) { */
|
||||
|
||||
/* //cout << ix << " " << ix << dataMap[iy][ix] << 2*nx*ny << " "<< endl; */
|
||||
/* uint16_t val=getChannel(data, ix, iy); */
|
||||
/* return val; */
|
||||
/* }; */
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, 2 * nx * ny)) {
|
||||
// iframe++;
|
||||
// ff=iframe;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
if (dsize < 2 * nx * ny)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = 2 * nx * ny;
|
||||
return data;
|
||||
}
|
||||
int getFrameNumber(char *buff){return *((int*)buff);};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
// virtual int setFrameNumber(int ff){iframe=ff};
|
||||
|
||||
int getPacketNumber(char *buff){return 0;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[2*nx*ny];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
//char *retval=0;
|
||||
// int nd;
|
||||
//int fnum = -1;
|
||||
np=0;
|
||||
// int pn;
|
||||
|
||||
|
||||
// if (ff>=0)
|
||||
// fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, 2*nx*ny) ){
|
||||
// iframe++;
|
||||
//ff=iframe;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<2*nx*ny) ndata=dsize;
|
||||
else ndata=2*nx*ny;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// virtual int setFrameNumber(int ff){iframe=ff};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int getPacketNumber(int x, int y) {return 0;};
|
||||
|
||||
int getPacketNumber(int x, int y) { return 0; };
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,239 +1,240 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef JUNGFRAUHIGHZSINGLECHIPDATA_H
|
||||
#define JUNGFRAUHIGHZSINGLECHIPDATA_H
|
||||
#define JUNGFRAUHIGHZSINGLECHIPDATA_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
//#define VERSION_V2
|
||||
/**
|
||||
@short structure for a Detector Packet or Image Header
|
||||
@li frameNumber is the frame number
|
||||
@li expLength is the subframe number (32 bit eiger) or real time exposure
|
||||
time in 100ns (others)
|
||||
@li packetNumber is the packet number
|
||||
@li bunchId is the bunch id from beamline
|
||||
@li timestamp is the time stamp with 10 MHz clock
|
||||
@li modId is the unique module id (unique even for left, right, top, bottom)
|
||||
@li xCoord is the x coordinate in the complete detector system
|
||||
@li yCoord is the y coordinate in the complete detector system
|
||||
@li zCoord is the z coordinate in the complete detector system
|
||||
@li debug is for debugging purposes
|
||||
@li roundRNumber is the round robin set number
|
||||
@li detType is the detector type see :: detectorType
|
||||
@li version is the version number of this structure format
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t bunchNumber; /**< is the frame number */
|
||||
uint64_t pre; /**< something */
|
||||
/**
|
||||
@short structure for a Detector Packet or Image Header
|
||||
@li frameNumber is the frame number
|
||||
@li expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
@li packetNumber is the packet number
|
||||
@li bunchId is the bunch id from beamline
|
||||
@li timestamp is the time stamp with 10 MHz clock
|
||||
@li modId is the unique module id (unique even for left, right, top, bottom)
|
||||
@li xCoord is the x coordinate in the complete detector system
|
||||
@li yCoord is the y coordinate in the complete detector system
|
||||
@li zCoord is the z coordinate in the complete detector system
|
||||
@li debug is for debugging purposes
|
||||
@li roundRNumber is the round robin set number
|
||||
@li detType is the detector type see :: detectorType
|
||||
@li version is the version number of this structure format
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t bunchNumber; /**< is the frame number */
|
||||
uint64_t pre; /**< something */
|
||||
|
||||
} jf_header;
|
||||
|
||||
|
||||
|
||||
} jf_header;
|
||||
|
||||
class jungfrauHighZSingleChipData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
*/
|
||||
jungfrauHighZSingleChipData(): slsDetectorData<uint16_t>(256, 256, 256*256*2+sizeof(jf_header)) {
|
||||
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
jungfrauHighZSingleChipData()
|
||||
: slsDetectorData<uint16_t>(256, 256,
|
||||
256 * 256 * 2 + sizeof(jf_header)) {
|
||||
|
||||
for (int ix = 0; ix < 256; ix++) {
|
||||
for (int iy = 0; iy < 256; iy++) {
|
||||
dataMap[iy][ix] = sizeof(jf_header) + (256 * iy + ix) * 2;
|
||||
for (int ix=0; ix<256; ix++) {
|
||||
for (int iy=0; iy<256; iy++) {
|
||||
dataMap[iy][ix]=sizeof(jf_header)+(256*iy+ix)*2;
|
||||
#ifdef HIGHZ
|
||||
dataMask[iy][ix] = 0x3fff;
|
||||
dataMask[iy][ix]=0x3fff;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
iframe = 0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the value of the selected channel for the given dataset as double.
|
||||
\param data pointer to the dataset (including headers etc)
|
||||
\param ix pixel number in the x direction
|
||||
\param iy pixel number in the y direction
|
||||
\returns data for the selected channel, with inversion if required as double
|
||||
|
||||
/**
|
||||
Returns the value of the selected channel for the given dataset as
|
||||
double. \param data pointer to the dataset (including headers etc) \param
|
||||
ix pixel number in the x direction \param iy pixel number in the y
|
||||
direction \returns data for the selected channel, with inversion if
|
||||
required as double
|
||||
*/
|
||||
virtual double getValue(char *data, int ix, int iy=0) {
|
||||
|
||||
uint16_t val=getChannel(data, ix, iy)&0x3fff;
|
||||
return val;
|
||||
};
|
||||
|
||||
*/
|
||||
virtual double getValue(char *data, int ix, int iy = 0) {
|
||||
|
||||
|
||||
uint16_t val = getChannel(data, ix, iy) & 0x3fff;
|
||||
return val;
|
||||
};
|
||||
|
||||
/* virtual void calcGhost(char *data, int ix, int iy) { */
|
||||
/* double val=0; */
|
||||
/* ghost[iy][ix]=0; */
|
||||
|
||||
/* } */
|
||||
|
||||
/* virtual void calcGhost(char *data) { */
|
||||
/* for (int ix=0; ix<25; ix++){ */
|
||||
/* for (int iy=0; iy<200; iy++) { */
|
||||
/* calcGhost(data, ix,iy); */
|
||||
/* } */
|
||||
/* } */
|
||||
/* // cout << "*" << endl; */
|
||||
/* } */
|
||||
|
||||
/* double getGhost(int ix, int iy) { */
|
||||
/* return 0; */
|
||||
/* }; */
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
return ((jf_header *)buff)->bunchNumber;
|
||||
}; //*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
/* virtual void calcGhost(char *data, int ix, int iy) { */
|
||||
/* double val=0; */
|
||||
/* ghost[iy][ix]=0; */
|
||||
|
||||
/* } */
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff) {
|
||||
return 0;
|
||||
} //((*(((int*)(buff+4))))&0xff)+1;};
|
||||
/* virtual void calcGhost(char *data) { */
|
||||
/* for (int ix=0; ix<25; ix++){ */
|
||||
/* for (int iy=0; iy<200; iy++) { */
|
||||
/* calcGhost(data, ix,iy); */
|
||||
/* } */
|
||||
/* } */
|
||||
/* // cout << "*" << endl; */
|
||||
/* } */
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all
|
||||
* packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in
|
||||
* case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be
|
||||
* incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
*/
|
||||
/* double getGhost(int ix, int iy) { */
|
||||
/* return 0; */
|
||||
/* }; */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int
|
||||
* dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
/**
|
||||
|
||||
/* /\** */
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all
|
||||
* packets 0 to nPackets, same frame number). Can be overloaded for
|
||||
* different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no
|
||||
* frame is found or last frame is incomplete */
|
||||
*/
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np) {
|
||||
char *data = new char[dataSize];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
int getFrameNumber(char *buff){return ((jf_header*)buff)->bunchNumber;};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
char *retval = 0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np = 0;
|
||||
int pn;
|
||||
/**
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff >= 0)
|
||||
fnum = ff;
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
np = getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all
|
||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
||||
data pointer to the memory to be analyzed \param ndata reference to the
|
||||
amount of data found for the frame, in case the frame is incomplete at
|
||||
the end of the memory slot \param dsize size of the memory slot to be
|
||||
analyzed \returns pointer to the beginning of the last good frame (might
|
||||
be incomplete if ndata smaller than dataSize), or NULL if no frame is
|
||||
found
|
||||
*/
|
||||
int getPacketNumber(char *buff){return 0;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
if (dsize < dataSize)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = dataSize;
|
||||
return data;
|
||||
}
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
char *retval=0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np=0;
|
||||
int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
ff=getFrameNumber(data);
|
||||
np=getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<dataSize) ndata=dsize;
|
||||
else ndata=dataSize;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
|
||||
// int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,165 +1,171 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOENCH02CTBDATA_H
|
||||
#define MOENCH02CTBDATA_H
|
||||
#define MOENCH02CTBDATA_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
|
||||
class moench02CtbData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
// int *xmap, *ymap;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
// int *xmap, *ymap;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
|
||||
int maplength;
|
||||
int maplength;
|
||||
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
|
||||
moench02CtbData(int ns = 6400)
|
||||
: slsDetectorData<uint16_t>(160, 160, ns * 2 * 32, NULL, NULL),
|
||||
nadc(32), sc_width(40), sc_height(160) {
|
||||
public:
|
||||
|
||||
int adc_off[4] = {40, 0, 120, 80};
|
||||
int adc_nr[4] = {8, 10, 20, 22};
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc, iiadc;
|
||||
int ix, iy;
|
||||
maplength = this->getDataSize() / 2;
|
||||
// cout << maplength << endl;
|
||||
|
||||
for (iiadc = 0; iiadc < 4; iiadc++) {
|
||||
|
||||
iadc = adc_nr[iiadc];
|
||||
// cout << iiadc << endl;
|
||||
for (int i = 0; i < sc_width * sc_height; i++) {
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
col = adc_off[iiadc] + (i % sc_width);
|
||||
row = i / sc_width;
|
||||
dataMap[row][col] = (32 * i + iadc) * 2;
|
||||
if (dataMap[row][col] < 0 || dataMap[row][col] >= dataSize) {
|
||||
cout << "Error: pointer " << dataMap[row][col]
|
||||
<< " out of range " << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
for (int i = 0; i < maplength; i++) {
|
||||
// cout << i << endl;
|
||||
isample = i / 32;
|
||||
iiadc = i % 32;
|
||||
iadc = -1;
|
||||
for (int iii = 0; iii < 4; iii++) {
|
||||
if (iiadc == adc_nr[iii])
|
||||
iadc = iii;
|
||||
}
|
||||
ix = isample % sc_width;
|
||||
iy = isample / sc_width;
|
||||
if (iadc >= 0) {
|
||||
xmap[i] = adc_off[iadc] + ix;
|
||||
ymap[i] = iy;
|
||||
} else {
|
||||
xmap[i] = -1;
|
||||
ymap[i] = -1;
|
||||
}
|
||||
}
|
||||
iframe = 0;
|
||||
cout << "data struct created" << endl;
|
||||
moench02CtbData(int ns=6400): slsDetectorData<uint16_t>(160, 160, ns*2*32, NULL, NULL) , nadc(32), sc_width(40), sc_height(160) {
|
||||
|
||||
|
||||
int adc_off[4]={40,0,120,80};
|
||||
int adc_nr[4]={8,10,20,22};
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc, iiadc;
|
||||
int ix, iy;
|
||||
maplength=this->getDataSize()/2;
|
||||
//cout << maplength << endl;
|
||||
|
||||
for (iiadc=0; iiadc<4; iiadc++) {
|
||||
|
||||
iadc=adc_nr[iiadc];
|
||||
//cout << iiadc << endl;
|
||||
for (int i=0; i<sc_width*sc_height; i++) {
|
||||
|
||||
col=adc_off[iiadc]+(i%sc_width);
|
||||
row=i/sc_width;
|
||||
dataMap[row][col]=(32*i+iadc)*2;
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=dataSize) {
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<maplength; i++) {
|
||||
//cout << i << endl;
|
||||
isample=i/32;
|
||||
iiadc=i%32;
|
||||
iadc=-1;
|
||||
for (int iii=0; iii<4; iii++) {
|
||||
if (iiadc==adc_nr[iii]) iadc=iii;
|
||||
}
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
if(iadc>=0){
|
||||
xmap[i]=adc_off[iadc]+ix;
|
||||
ymap[i]=iy;
|
||||
}else{
|
||||
xmap[i]=-1;
|
||||
ymap[i]=-1;
|
||||
}
|
||||
}
|
||||
iframe=0;
|
||||
cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
void getPixel(int ip, int &x, int &y) {
|
||||
if(ip>=0 && ip<maplength){
|
||||
x=xmap[ip];
|
||||
y=ymap[ip];
|
||||
}/*else{
|
||||
cerr<<"WRONG ARRAY LENGTH"<<endl;
|
||||
cerr<<"Trying to access the "<<ip<<"-th element"<<endl;
|
||||
}*/
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
|
||||
virtual int getFrameNumber(char *buff){(void)buff; return iframe;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
virtual int getPacketNumber(char *buff)=0;
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
|
||||
\param filebin input file stream (binary)
|
||||
\returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete
|
||||
|
||||
*/
|
||||
virtual char *readNextFrame(ifstream &filebin){
|
||||
// int afifo_length=0;
|
||||
uint16_t *afifo_cont;
|
||||
int ib=0;
|
||||
if (filebin.is_open()) {
|
||||
afifo_cont=new uint16_t[dataSize/2];
|
||||
while (filebin.read(((char*)afifo_cont)+ib,2)) {
|
||||
ib+=2;
|
||||
if (ib==dataSize) break;
|
||||
}
|
||||
if (ib>0) {
|
||||
iframe++;
|
||||
//cout << ib/2 << "-" << endl;
|
||||
//for (int i=0; i<ib/2; i++)
|
||||
//cout << i << " " << afifo_cont[i] << endl;
|
||||
return (char*)afifo_cont;
|
||||
} else {
|
||||
delete [] afifo_cont;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
void getPixel(int ip, int &x, int &y) {
|
||||
if (ip >= 0 && ip < maplength) {
|
||||
x = xmap[ip];
|
||||
y = ymap[ip];
|
||||
} /*else{
|
||||
cerr<<"WRONG ARRAY LENGTH"<<endl;
|
||||
cerr<<"Trying to access the "<<ip<<"-th element"<<endl;
|
||||
}*/
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
virtual int getFrameNumber(char *buff) {
|
||||
(void)buff;
|
||||
return iframe;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
virtual int getPacketNumber(char *buff)=0;
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets
|
||||
0 to nPackets, same frame number). purely virtual func \param data pointer
|
||||
to the memory to be analyzed \param ndata reference to the amount of data
|
||||
found for the frame, in case the frame is incomplete at the end of the
|
||||
memory slot \param dsize size of the memory slot to be analyzed \returns
|
||||
pointer to the beginning of the last good frame (might be incomplete if
|
||||
ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
ndata = dsize;
|
||||
setDataSize(dsize);
|
||||
return data;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets
|
||||
0 to nPackets, same frame number). Can be overloaded for different kind of
|
||||
detectors! \param filebin input file stream (binary) \returns pointer to
|
||||
the begin of the last good frame, NULL if no frame is found or last frame
|
||||
is incomplete
|
||||
|
||||
*/
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
// int afifo_length=0;
|
||||
uint16_t *afifo_cont;
|
||||
int ib = 0;
|
||||
if (filebin.is_open()) {
|
||||
afifo_cont = new uint16_t[dataSize / 2];
|
||||
while (filebin.read(((char *)afifo_cont) + ib, 2)) {
|
||||
ib += 2;
|
||||
if (ib == dataSize)
|
||||
break;
|
||||
}
|
||||
if (ib > 0) {
|
||||
iframe++;
|
||||
// cout << ib/2 << "-" << endl;
|
||||
// for (int i=0; i<ib/2; i++)
|
||||
// cout << i << " " << afifo_cont[i] << endl;
|
||||
return (char *)afifo_cont;
|
||||
} else {
|
||||
delete[] afifo_cont;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,148 +1,159 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOENCH03CTBDATA_H
|
||||
#define MOENCH03CTBDATA_H
|
||||
#define MOENCH03CTBDATA_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
|
||||
class moench03CtbData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
public:
|
||||
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
|
||||
moench03CtbData(int ns = 5000)
|
||||
: slsDetectorData<uint16_t>(400, 400, ns * 2 * 32, NULL, NULL),
|
||||
nadc(32), sc_width(25), sc_height(200) {
|
||||
|
||||
int row, col;
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
*/
|
||||
|
||||
|
||||
int adc_nr[32] = {200, 225, 250, 275, 300, 325, 350, 375, 0, 25, 50,
|
||||
75, 100, 125, 150, 175, 175, 150, 125, 100, 75, 50,
|
||||
25, 0, 375, 350, 325, 300, 275, 250, 225, 200};
|
||||
moench03CtbData(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*2*32, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) {
|
||||
|
||||
/* int adc_nr[32]={300,325,350,375,300,325,350,375, \ */
|
||||
/* 200,225,250,275,200,225,250,275,\ */
|
||||
/* 100,125,150,175,100,125,150,175,\ */
|
||||
/* 0,25,50,75,0,25,50,75}; */
|
||||
|
||||
int row, col;
|
||||
|
||||
for (iadc = 0; iadc < nadc; iadc++) {
|
||||
for (int i = 0; i < sc_width * sc_height; i++) {
|
||||
col = adc_nr[iadc] + (i % sc_width);
|
||||
if (iadc < 16) {
|
||||
row = 199 - i / sc_width;
|
||||
} else {
|
||||
row = 200 + i / sc_width;
|
||||
}
|
||||
dataMap[row][col] = (nadc * i + iadc) * 2;
|
||||
if (dataMap[row][col] < 0 || dataMap[row][col] >= 2 * 400 * 400)
|
||||
cout << "Error: pointer " << dataMap[row][col]
|
||||
<< " out of range " << endl;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < nx * ny; i++) {
|
||||
isample = i / nadc;
|
||||
iadc = i % nadc;
|
||||
ix = isample % sc_width;
|
||||
iy = isample / sc_width;
|
||||
if (iadc < (nadc / 2)) {
|
||||
xmap[i] = adc_nr[iadc] + ix;
|
||||
ymap[i] = ny / 2 - 1 - iy;
|
||||
} else {
|
||||
xmap[i] = adc_nr[iadc] + ix;
|
||||
ymap[i] = ny / 2 + iy;
|
||||
}
|
||||
}
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
iframe = 0;
|
||||
// cout << "data struct created" << endl;
|
||||
int adc_nr[32]={200,225,250,275,300,325,350,375,\
|
||||
0,25,50,75,100,125,150,175,\
|
||||
175,150,125,100,75,50,25,0,\
|
||||
375,350,325,300,275,250,225,200};
|
||||
|
||||
/* int adc_nr[32]={300,325,350,375,300,325,350,375, \ */
|
||||
/* 200,225,250,275,200,225,250,275,\ */
|
||||
/* 100,125,150,175,100,125,150,175,\ */
|
||||
/* 0,25,50,75,0,25,50,75}; */
|
||||
|
||||
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=adc_nr[iadc]+(i%sc_width);
|
||||
if (iadc<16) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
dataMap[row][col]=(nadc*i+iadc)*2;
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=2*400*400)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
|
||||
}
|
||||
}
|
||||
for (int i=0; i<nx*ny; i++) {
|
||||
isample=i/nadc;
|
||||
iadc=i%nadc;
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
if (iadc<(nadc/2)) {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2-1-iy;
|
||||
} else {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2+iy;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
|
||||
virtual int getFrameNumber(char *buff){(void)buff; return iframe;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
virtual int getPacketNumber(char *buff)=0;
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
|
||||
\param filebin input file stream (binary)
|
||||
\returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete
|
||||
|
||||
*/
|
||||
virtual char *readNextFrame(ifstream &filebin){
|
||||
// int afifo_length=0;
|
||||
uint16_t *afifo_cont;
|
||||
int ib=0;
|
||||
if (filebin.is_open()) {
|
||||
afifo_cont=new uint16_t[dataSize/2];
|
||||
while (filebin.read(((char*)afifo_cont)+ib,2)) {
|
||||
ib+=2;
|
||||
if (ib==dataSize) break;
|
||||
}
|
||||
if (ib>0) {
|
||||
iframe++;
|
||||
// cout << ib << "-" << endl;
|
||||
return (char*)afifo_cont;
|
||||
} else {
|
||||
delete [] afifo_cont;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
|
||||
*/
|
||||
|
||||
virtual int getFrameNumber(char *buff) {
|
||||
(void)buff;
|
||||
return iframe;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
virtual int getPacketNumber(char *buff)=0;
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets
|
||||
0 to nPackets, same frame number). purely virtual func \param data pointer
|
||||
to the memory to be analyzed \param ndata reference to the amount of data
|
||||
found for the frame, in case the frame is incomplete at the end of the
|
||||
memory slot \param dsize size of the memory slot to be analyzed \returns
|
||||
pointer to the beginning of the last good frame (might be incomplete if
|
||||
ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
ndata = dsize;
|
||||
setDataSize(dsize);
|
||||
return data;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets
|
||||
0 to nPackets, same frame number). Can be overloaded for different kind of
|
||||
detectors! \param filebin input file stream (binary) \returns pointer to
|
||||
the begin of the last good frame, NULL if no frame is found or last frame
|
||||
is incomplete
|
||||
|
||||
*/
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
// int afifo_length=0;
|
||||
uint16_t *afifo_cont;
|
||||
int ib = 0;
|
||||
if (filebin.is_open()) {
|
||||
afifo_cont = new uint16_t[dataSize / 2];
|
||||
while (filebin.read(((char *)afifo_cont) + ib, 2)) {
|
||||
ib += 2;
|
||||
if (ib == dataSize)
|
||||
break;
|
||||
}
|
||||
if (ib > 0) {
|
||||
iframe++;
|
||||
// cout << ib << "-" << endl;
|
||||
return (char *)afifo_cont;
|
||||
} else {
|
||||
delete[] afifo_cont;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,146 +1,160 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOENCH03T1CTBDATA_H
|
||||
#define MOENCH03T1CTBDATA_H
|
||||
#define MOENCH03T1CTBDATA_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
|
||||
class moench03T1CtbData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
public:
|
||||
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
|
||||
moench03T1CtbData(int ns = 5000)
|
||||
: slsDetectorData<uint16_t>(400, 400, ns * 2 * 32, NULL, NULL),
|
||||
nadc(32), sc_width(25), sc_height(200) {
|
||||
|
||||
int adc_nr[32] = {300, 325, 350, 375, 300, 325, 350, 375, 200, 225, 250,
|
||||
275, 200, 225, 250, 275, 100, 125, 150, 175, 100, 125,
|
||||
150, 175, 0, 25, 50, 75, 0, 25, 50, 75};
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
int row, col;
|
||||
*/
|
||||
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
moench03T1CtbData(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*2*32, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) {
|
||||
|
||||
for (iadc = 0; iadc < nadc; iadc++) {
|
||||
for (int i = 0; i < sc_width * sc_height; i++) {
|
||||
col = adc_nr[iadc] + (i % sc_width);
|
||||
if (iadc < 16) {
|
||||
row = 199 - i / sc_width;
|
||||
} else {
|
||||
row = 200 + i / sc_width;
|
||||
}
|
||||
dataMap[row][col] = (nadc * i + iadc) * 2;
|
||||
if (dataMap[row][col] < 0 || dataMap[row][col] >= 2 * 400 * 400)
|
||||
cout << "Error: pointer " << dataMap[row][col]
|
||||
<< " out of range " << endl;
|
||||
}
|
||||
}
|
||||
int adc4;
|
||||
for (int i = 0; i < nx * ny; i++) {
|
||||
isample = i / nadc;
|
||||
iadc = i % nadc;
|
||||
ix = isample % sc_width;
|
||||
iy = isample / sc_width;
|
||||
adc4 = (int)iadc / 4;
|
||||
// if (iadc<(nadc/2)) {
|
||||
if (adc4 % 2 == 0) {
|
||||
xmap[i] = adc_nr[iadc] + ix;
|
||||
ymap[i] = ny / 2 - 1 - iy;
|
||||
} else {
|
||||
xmap[i] = adc_nr[iadc] + ix;
|
||||
ymap[i] = ny / 2 + iy;
|
||||
}
|
||||
}
|
||||
|
||||
iframe = 0;
|
||||
// cout << "data struct created" << endl;
|
||||
int adc_nr[32]={300,325,350,375,300,325,350,375, \
|
||||
200,225,250,275,200,225,250,275,\
|
||||
100,125,150,175,100,125,150,175,\
|
||||
0,25,50,75,0,25,50,75};
|
||||
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=adc_nr[iadc]+(i%sc_width);
|
||||
if (iadc<16) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
dataMap[row][col]=(nadc*i+iadc)*2;
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=2*400*400)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
|
||||
}
|
||||
}
|
||||
int adc4;
|
||||
for (int i=0; i<nx*ny; i++) {
|
||||
isample=i/nadc;
|
||||
iadc=i%nadc;
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
adc4 = (int)iadc/4;
|
||||
// if (iadc<(nadc/2)) {
|
||||
if (adc4%2==0) {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2-1-iy;
|
||||
} else {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2+iy;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
|
||||
virtual int getFrameNumber(char *buff){(void)buff; return iframe;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
virtual int getPacketNumber(char *buff)=0;
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
|
||||
\param filebin input file stream (binary)
|
||||
\returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete
|
||||
|
||||
*/
|
||||
virtual char *readNextFrame(ifstream &filebin){
|
||||
// int afifo_length=0;
|
||||
uint16_t *afifo_cont;
|
||||
int ib=0;
|
||||
if (filebin.is_open()) {
|
||||
afifo_cont=new uint16_t[dataSize/2];
|
||||
while (filebin.read(((char*)afifo_cont)+ib,2)) {
|
||||
ib+=2;
|
||||
if (ib==dataSize) break;
|
||||
}
|
||||
if (ib>0) {
|
||||
iframe++;
|
||||
// cout << ib << "-" << endl;
|
||||
return (char*)afifo_cont;
|
||||
} else {
|
||||
delete [] afifo_cont;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
|
||||
*/
|
||||
|
||||
virtual int getFrameNumber(char *buff) {
|
||||
(void)buff;
|
||||
return iframe;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
virtual int getPacketNumber(char *buff)=0;
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets
|
||||
0 to nPackets, same frame number). purely virtual func \param data pointer
|
||||
to the memory to be analyzed \param ndata reference to the amount of data
|
||||
found for the frame, in case the frame is incomplete at the end of the
|
||||
memory slot \param dsize size of the memory slot to be analyzed \returns
|
||||
pointer to the beginning of the last good frame (might be incomplete if
|
||||
ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
ndata = dsize;
|
||||
setDataSize(dsize);
|
||||
return data;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets
|
||||
0 to nPackets, same frame number). Can be overloaded for different kind of
|
||||
detectors! \param filebin input file stream (binary) \returns pointer to
|
||||
the begin of the last good frame, NULL if no frame is found or last frame
|
||||
is incomplete
|
||||
|
||||
*/
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
// int afifo_length=0;
|
||||
uint16_t *afifo_cont;
|
||||
int ib = 0;
|
||||
if (filebin.is_open()) {
|
||||
afifo_cont = new uint16_t[dataSize / 2];
|
||||
while (filebin.read(((char *)afifo_cont) + ib, 2)) {
|
||||
ib += 2;
|
||||
if (ib == dataSize)
|
||||
break;
|
||||
}
|
||||
if (ib > 0) {
|
||||
iframe++;
|
||||
// cout << ib << "-" << endl;
|
||||
return (char *)afifo_cont;
|
||||
} else {
|
||||
delete[] afifo_cont;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,253 +1,366 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOENCH03T1RECDATANEW_H
|
||||
#define MOENCH03T1RECDATANEW_H
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#define MOENCH03T1RECDATANEW_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int nSamples;
|
||||
|
||||
double ghost[200][25];
|
||||
|
||||
// Single point of definition if we need to customize
|
||||
using header = sls::defs::sls_receiver_header;
|
||||
|
||||
public:
|
||||
//#define VERSION_V2
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
@short structure for a Detector Packet or Image Header
|
||||
@li frameNumber is the frame number
|
||||
@li expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
@li packetNumber is the packet number
|
||||
@li bunchId is the bunch id from beamline
|
||||
@li timestamp is the time stamp with 10 MHz clock
|
||||
@li modId is the unique module id (unique even for left, right, top, bottom)
|
||||
@li xCoord is the x coordinate in the complete detector system
|
||||
@li yCoord is the y coordinate in the complete detector system
|
||||
@li zCoord is the z coordinate in the complete detector system
|
||||
@li debug is for debugging purposes
|
||||
@li roundRNumber is the round robin set number
|
||||
@li detType is the detector type see :: detectorType
|
||||
@li version is the version number of this structure format
|
||||
*/
|
||||
moench03T1ReceiverDataNew(int ns = 5000)
|
||||
: slsDetectorData<uint16_t>(400, 400, ns * 2 * 32 + sizeof(header)),
|
||||
nSamples(ns) {
|
||||
|
||||
int nadc = 32;
|
||||
int sc_width = 25;
|
||||
int sc_height = 200;
|
||||
|
||||
int adc_nr[32] = {300, 325, 350, 375, 300, 325, 350, 375, 200, 225, 250,
|
||||
275, 200, 225, 250, 275, 100, 125, 150, 175, 100, 125,
|
||||
150, 175, 0, 25, 50, 75, 0, 25, 50, 75};
|
||||
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
int npackets = 40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
|
||||
for (int ip = 0; ip < npackets; ip++) {
|
||||
for (int is = 0; is < 128; is++) {
|
||||
|
||||
for (iadc = 0; iadc < nadc; iadc++) {
|
||||
i = 128 * ip + is;
|
||||
adc4 = (int)iadc / 4;
|
||||
if (i < sc_width * sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col = adc_nr[iadc] + (i % sc_width);
|
||||
if (adc4 % 2 == 0) {
|
||||
row = 199 - i / sc_width;
|
||||
} else {
|
||||
row = 200 + i / sc_width;
|
||||
}
|
||||
dataMap[row][col] = sizeof(header) +
|
||||
(nadc * i + iadc) * 2; //+16*(ip+1);
|
||||
#ifdef HIGHZ
|
||||
dataMask[row][col] = 0x3fff; // invert data
|
||||
typedef struct {
|
||||
uint64_t frameNumber; /**< is the frame number */
|
||||
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
|
||||
uint32_t packetNumber; /**< is the packet number */
|
||||
uint64_t bunchId; /**< is the bunch id from beamline */
|
||||
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||
uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
|
||||
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||
uint32_t debug; /**< is for debugging purposes */
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
#ifndef VERSION_V1
|
||||
uint64_t packetCaught[8]; /**< is the version number of this structure format */
|
||||
#endif
|
||||
if (dataMap[row][col] < 0 ||
|
||||
dataMap[row][col] >= nSamples * 2 * 32)
|
||||
std::cout << "Error: pointer " << dataMap[row][col]
|
||||
<< " out of range " << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// double ghost[200][25];
|
||||
|
||||
for (int ix = 0; ix < 25; ix++)
|
||||
for (int iy = 0; iy < 200; iy++)
|
||||
ghost[iy][ix] = 0.;
|
||||
} sls_detector_header;
|
||||
|
||||
int ipacket;
|
||||
uint ibyte;
|
||||
int ii = 0;
|
||||
for (ibyte = 0; ibyte < sizeof(header) / 2; ibyte++) {
|
||||
xmap[ibyte] = -1;
|
||||
ymap[ibyte] = -1;
|
||||
}
|
||||
int off = sizeof(header) / 2;
|
||||
for (ipacket = 0; ipacket < npackets; ipacket++) {
|
||||
for (ibyte = 0; ibyte < 8192 / 2; ibyte++) {
|
||||
i = ipacket * 8208 / 2 + ibyte;
|
||||
isample = ii / nadc;
|
||||
if (isample < nSamples) {
|
||||
iadc = ii % nadc;
|
||||
adc4 = (int)iadc / 4;
|
||||
ix = isample % sc_width;
|
||||
iy = isample / sc_width;
|
||||
if (adc4 % 2 == 0) {
|
||||
xmap[i + off] = adc_nr[iadc] + ix;
|
||||
ymap[i + off] = ny / 2 - 1 - iy;
|
||||
} else {
|
||||
xmap[i + off] = adc_nr[iadc] + ix;
|
||||
ymap[i + off] = ny / 2 + iy;
|
||||
}
|
||||
}
|
||||
ii++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
iframe = 0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the value of the selected channel for the given dataset as
|
||||
double. \param data pointer to the dataset (including headers etc) \param
|
||||
ix pixel number in the x direction \param iy pixel number in the y
|
||||
direction \returns data for the selected channel, with inversion if
|
||||
required as double
|
||||
|
||||
*/
|
||||
double getValue(char *data, int ix, int iy = 0) override {
|
||||
uint16_t val = getChannel(data, ix, iy) & 0x3fff;
|
||||
return val;
|
||||
};
|
||||
class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int nSamples;
|
||||
|
||||
virtual void calcGhost(char *data, int ix, int iy) {
|
||||
double val = 0;
|
||||
/* for (int ix=0; ix<25; ix++){ */
|
||||
/* for (int iy=0; iy<200; iy++) { */
|
||||
val = 0;
|
||||
// cout << "** ";
|
||||
for (int isc = 0; isc < 16; isc++) {
|
||||
// for (int ii=0; ii<2; ii++) {
|
||||
val += getChannel(data, ix + 25 * isc, iy);
|
||||
// cout << "(" << isc << "," << val << " " ;
|
||||
val += getChannel(data, ix + 25 * isc, 399 - iy);
|
||||
// cout << val << " " ;
|
||||
// }
|
||||
}
|
||||
ghost[iy][ix] = val; //-6224;
|
||||
// cout << " --"<< endl;
|
||||
/* } */
|
||||
/* } */
|
||||
// cout << "*" << endl;
|
||||
double ghost[200][25];
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
moench03T1ReceiverDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*2*32+sizeof(sls_detector_header)), nSamples(ns) {
|
||||
|
||||
int nadc=32;
|
||||
int sc_width=25;
|
||||
int sc_height=200;
|
||||
|
||||
int adc_nr[32]={300,325,350,375,300,325,350,375, \
|
||||
200,225,250,275,200,225,250,275,\
|
||||
100,125,150,175,100,125,150,175,\
|
||||
0,25,50,75,0,25,50,75};
|
||||
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
int npackets=40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
|
||||
for (int ip=0; ip<npackets; ip++) {
|
||||
for (int is=0; is<128; is++) {
|
||||
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
i=128*ip+is;
|
||||
adc4=(int)iadc/4;
|
||||
if (i<sc_width*sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=adc_nr[iadc]+(i%sc_width);
|
||||
if (adc4%2==0) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
|
||||
#ifdef HIGHZ
|
||||
dataMask[row][col]=0x3fff; //invert data
|
||||
#endif
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=nSamples*2*32)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// double ghost[200][25];
|
||||
|
||||
virtual void calcGhost(char *data) {
|
||||
for (int ix = 0; ix < 25; ix++) {
|
||||
for (int iy = 0; iy < 200; iy++) {
|
||||
calcGhost(data, ix, iy);
|
||||
}
|
||||
}
|
||||
// cout << "*" << endl;
|
||||
for (int ix=0; ix<25; ix++)
|
||||
for (int iy=0; iy<200; iy++)
|
||||
ghost[iy][ix]=0.;
|
||||
|
||||
int ipacket;
|
||||
int ibyte;
|
||||
int ii=0;
|
||||
for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){
|
||||
xmap[ibyte]=-1;
|
||||
ymap[ibyte]=-1;
|
||||
}
|
||||
|
||||
double getGhost(int ix, int iy) {
|
||||
if (iy < 200)
|
||||
return ghost[iy][ix % 25];
|
||||
if (iy < 400)
|
||||
return ghost[399 - iy][ix % 25];
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
return ((header *)buff)->detHeader.frameNumber;
|
||||
int off=sizeof(sls_detector_header)/2;
|
||||
for (ipacket=0; ipacket<npackets; ipacket++) {
|
||||
for (ibyte=0; ibyte< 8192/2; ibyte++) {
|
||||
i=ipacket*8208/2+ibyte;
|
||||
isample=ii/nadc;
|
||||
if (isample<nSamples) {
|
||||
iadc=ii%nadc;
|
||||
adc4 = (int)iadc/4;
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
if (adc4%2==0) {
|
||||
xmap[i+off]=adc_nr[iadc]+ix;
|
||||
ymap[i+off]=ny/2-1-iy;
|
||||
} else {
|
||||
xmap[i+off]=adc_nr[iadc]+ix;
|
||||
ymap[i+off]=ny/2+iy;
|
||||
}
|
||||
}
|
||||
ii++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
Returns the value of the selected channel for the given dataset as double.
|
||||
\param data pointer to the dataset (including headers etc)
|
||||
\param ix pixel number in the x direction
|
||||
\param iy pixel number in the y direction
|
||||
\returns data for the selected channel, with inversion if required as double
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
*/
|
||||
virtual double getValue(char *data, int ix, int iy=0) {
|
||||
/* cout << " x "<< ix << " y"<< iy << " val " << getChannel(data, ix, iy)<< endl;*/
|
||||
/* double val=0, vout=getChannel(data, ix, iy); */
|
||||
/* int x1=ix%25; */
|
||||
/* for (int ix=0; ix<16; ix++) { */
|
||||
/* for (int ii=0; ii<2; ii++) { */
|
||||
/* val+=getChannel(data,x1+25*ix,iy); */
|
||||
/* val+=getChannel(data,x1+25*ix,399-iy); */
|
||||
/* } */
|
||||
/* } */
|
||||
/* vout+=0.0008*val-6224; */
|
||||
/* return vout; //(double)getChannel(data, ix, iy);
|
||||
*/
|
||||
uint16_t val=getChannel(data, ix, iy)&0x3fff;
|
||||
return val;
|
||||
};
|
||||
|
||||
|
||||
|
||||
virtual void calcGhost(char *data, int ix, int iy) {
|
||||
double val=0;
|
||||
/* for (int ix=0; ix<25; ix++){ */
|
||||
/* for (int iy=0; iy<200; iy++) { */
|
||||
val=0;
|
||||
// cout << "** ";
|
||||
for (int isc=0; isc<16; isc++) {
|
||||
// for (int ii=0; ii<2; ii++) {
|
||||
val+=getChannel(data,ix+25*isc,iy);
|
||||
// cout << "(" << isc << "," << val << " " ;
|
||||
val+=getChannel(data,ix+25*isc,399-iy);
|
||||
// cout << val << " " ;
|
||||
// }
|
||||
}
|
||||
ghost[iy][ix]=val;//-6224;
|
||||
// cout << " --"<< endl;
|
||||
/* } */
|
||||
/* } */
|
||||
// cout << "*" << endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff) {
|
||||
return ((header *)buff)->detHeader.packetNumber;
|
||||
virtual void calcGhost(char *data) {
|
||||
for (int ix=0; ix<25; ix++){
|
||||
for (int iy=0; iy<200; iy++) {
|
||||
calcGhost(data, ix,iy);
|
||||
}
|
||||
}
|
||||
// cout << "*" << endl;
|
||||
}
|
||||
|
||||
char *readNextFrame(std::ifstream &filebin) override {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
}
|
||||
|
||||
// not present in base class
|
||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
double getGhost(int ix, int iy) {
|
||||
if (iy<200) return ghost[iy][ix%25];
|
||||
if (iy<400) return ghost[399-iy][ix%25];
|
||||
return 0;
|
||||
};
|
||||
|
||||
// not present in base class
|
||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np) {
|
||||
char *data = new char[dataSize];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
|
||||
// not present in base class
|
||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
np = 0;
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
np = getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all
|
||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
||||
data pointer to the memory to be analyzed \param ndata reference to the
|
||||
amount of data found for the frame, in case the frame is incomplete at
|
||||
the end of the memory slot \param dsize size of the memory slot to be
|
||||
analyzed \returns pointer to the beginning of the last good frame (might
|
||||
be incomplete if ndata smaller than dataSize), or NULL if no frame is
|
||||
found
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
*/
|
||||
char *findNextFrame(char *data, int &ndata, int dsize) override {
|
||||
if (dsize < dataSize)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = dataSize;
|
||||
return data;
|
||||
}
|
||||
|
||||
// int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
|
||||
int getFrameNumber(char *buff){return ((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
char *retval=0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np=0;
|
||||
int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
ff=getFrameNumber(data);
|
||||
np=getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<dataSize) ndata=dsize;
|
||||
else ndata=dataSize;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,327 +1,323 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOENCH03T1RECDATANEWRECT_H
|
||||
#define MOENCH03T1RECDATANEWRECT_H
|
||||
#define MOENCH03T1RECDATANEWRECT_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
#define VERT 1
|
||||
|
||||
/**
|
||||
@short structure for a Detector Packet or Image Header
|
||||
@li frameNumber is the frame number
|
||||
@li expLength is the subframe number (32 bit eiger) or real time exposure
|
||||
time in 100ns (others)
|
||||
@li packetNumber is the packet number
|
||||
@li bunchId is the bunch id from beamline
|
||||
@li timestamp is the time stamp with 10 MHz clock
|
||||
@li modId is the unique module id (unique even for left, right, top, bottom)
|
||||
@li xCoord is the x coordinate in the complete detector system
|
||||
@li yCoord is the y coordinate in the complete detector system
|
||||
@li zCoord is the z coordinate in the complete detector system
|
||||
@li debug is for debugging purposes
|
||||
@li roundRNumber is the round robin set number
|
||||
@li detType is the detector type see :: detectorType
|
||||
@li version is the version number of this structure format
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t frameNumber; /**< is the frame number */
|
||||
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time
|
||||
exposure time in 100ns (others) */
|
||||
uint32_t packetNumber; /**< is the packet number */
|
||||
uint64_t bunchId; /**< is the bunch id from beamline */
|
||||
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||
uint16_t modId; /**< is the unique module id (unique even for left, right,
|
||||
top, bottom) */
|
||||
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||
uint32_t debug; /**< is for debugging purposes */
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
} sls_detector_header;
|
||||
/**
|
||||
@short structure for a Detector Packet or Image Header
|
||||
@li frameNumber is the frame number
|
||||
@li expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
@li packetNumber is the packet number
|
||||
@li bunchId is the bunch id from beamline
|
||||
@li timestamp is the time stamp with 10 MHz clock
|
||||
@li modId is the unique module id (unique even for left, right, top, bottom)
|
||||
@li xCoord is the x coordinate in the complete detector system
|
||||
@li yCoord is the y coordinate in the complete detector system
|
||||
@li zCoord is the z coordinate in the complete detector system
|
||||
@li debug is for debugging purposes
|
||||
@li roundRNumber is the round robin set number
|
||||
@li detType is the detector type see :: detectorType
|
||||
@li version is the version number of this structure format
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t frameNumber; /**< is the frame number */
|
||||
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
|
||||
uint32_t packetNumber; /**< is the packet number */
|
||||
uint64_t bunchId; /**< is the bunch id from beamline */
|
||||
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||
uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
|
||||
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||
uint32_t debug; /**< is for debugging purposes */
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
} sls_detector_header;
|
||||
|
||||
|
||||
|
||||
|
||||
class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int nSamples;
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int nSamples;
|
||||
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
public:
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
#ifdef HOR
|
||||
moench03T1ReceiverDataNew(int ns = 5000)
|
||||
: slsDetectorData<uint16_t>(800, 200,
|
||||
ns * 2 * 32 + sizeof(sls_detector_header)),
|
||||
nSamples(ns) {
|
||||
moench03T1ReceiverDataNew(int ns=5000): slsDetectorData<uint16_t>(800, 200, ns*2*32+sizeof(sls_detector_header)), nSamples(ns) {
|
||||
#endif
|
||||
#ifdef VERT
|
||||
moench03T1ReceiverDataNew(int ns = 5000)
|
||||
: slsDetectorData<uint16_t>(
|
||||
200, 800, ns * 2 * 32 + sizeof(sls_detector_header)),
|
||||
nSamples(ns) {
|
||||
moench03T1ReceiverDataNew(int ns=5000): slsDetectorData<uint16_t>(200, 800, ns*2*32+sizeof(sls_detector_header)), nSamples(ns) {
|
||||
#endif
|
||||
int nadc = 32;
|
||||
int sc_width = 25;
|
||||
int sc_height = 200;
|
||||
int nadc=32;
|
||||
int sc_width=25;
|
||||
int sc_height=200;
|
||||
|
||||
int adc_nr[32] = {300, 325, 350, 375, 300, 325, 350, 375,
|
||||
200, 225, 250, 275, 200, 225, 250, 275,
|
||||
100, 125, 150, 175, 100, 125, 150, 175,
|
||||
0, 25, 50, 75, 0, 25, 50, 75};
|
||||
int adc_nr[32]={300,325,350,375,300,325,350,375, \
|
||||
200,225,250,275,200,225,250,275,\
|
||||
100,125,150,175,100,125,150,175,\
|
||||
0,25,50,75,0,25,50,75};
|
||||
|
||||
int row, col;
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
int npackets=40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
int pix;
|
||||
|
||||
int npackets = 40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
int pix;
|
||||
|
||||
int off = 0;
|
||||
int off=0;
|
||||
#ifdef OFF_1
|
||||
off = 1;
|
||||
off=1;
|
||||
#endif
|
||||
cout << "This is a MOENCH with rectangular pixels!" << endl;
|
||||
cout << "This is a MOENCH with rectangular pixels!" << endl;
|
||||
|
||||
for (int ip = 0; ip < npackets; ip++) {
|
||||
for (int is = 0; is < 128; is++) {
|
||||
for (int ip=0; ip<npackets; ip++) {
|
||||
for (int is=0; is<128; is++) {
|
||||
|
||||
for (iadc = 0; iadc < nadc; iadc++) {
|
||||
i = 128 * ip + is;
|
||||
adc4 = (int)iadc / 4;
|
||||
if (i < sc_width * sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col = adc_nr[iadc] + (i % sc_width);
|
||||
if (adc4 % 2 == 0) {
|
||||
row = 199 - i / sc_width;
|
||||
} else {
|
||||
row = 200 + i / sc_width;
|
||||
}
|
||||
pix = sizeof(sls_detector_header) +
|
||||
(nadc * i + iadc) * 2; //+16*(ip+1);
|
||||
if (pix < 0 ||
|
||||
pix >= nSamples * 2 * 32 +
|
||||
sizeof(sls_detector_header))
|
||||
cout << "Error: pointer " << dataMap[row][col]
|
||||
<< " out of range " << endl;
|
||||
ix = col;
|
||||
iy = row;
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
i=128*ip+is;
|
||||
adc4=(int)iadc/4;
|
||||
if (i<sc_width*sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=adc_nr[iadc]+(i%sc_width);
|
||||
if (adc4%2==0) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
pix=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
|
||||
if (pix<0 || pix>=nSamples*2*32+sizeof(sls_detector_header))
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
ix=col;
|
||||
iy=row;
|
||||
#ifdef HOR
|
||||
if (row % 2 == off) {
|
||||
ix = 2 * col;
|
||||
iy = row / 2;
|
||||
} else {
|
||||
ix = 2 * col + 1;
|
||||
iy = row / 2;
|
||||
}
|
||||
if (row%2==off) {
|
||||
ix=2*col;
|
||||
iy=row/2;
|
||||
} else {
|
||||
ix=2*col+1;
|
||||
iy=row/2;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VERT
|
||||
if (col % 2 == off) {
|
||||
ix = col / 2;
|
||||
iy = row * 2 + 1;
|
||||
} else {
|
||||
ix = col / 2;
|
||||
iy = row * 2;
|
||||
}
|
||||
if (col%2==off) {
|
||||
ix=col/2;
|
||||
iy=row*2+1;
|
||||
} else {
|
||||
ix=col/2;
|
||||
iy=row*2;
|
||||
}
|
||||
#endif
|
||||
dataMap[iy][ix] = pix;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dataMap[iy][ix]=pix;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* int ipacket; */
|
||||
/* int ibyte; */
|
||||
/* int ii=0; */
|
||||
/* for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){ */
|
||||
/* xmap[ibyte]=-1; */
|
||||
/* ymap[ibyte]=-1; */
|
||||
/* } */
|
||||
/* int off=sizeof(sls_detector_header)/2; */
|
||||
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
|
||||
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
|
||||
/* i=ipacket*8208/2+ibyte; */
|
||||
/* isample=ii/nadc; */
|
||||
/* if (isample<nSamples) { */
|
||||
/* iadc=ii%nadc; */
|
||||
/* adc4 = (int)iadc/4; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (adc4%2==0) { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2+iy; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* ii++; */
|
||||
/* // } */
|
||||
/* } */
|
||||
/* } */
|
||||
/* int ipacket; */
|
||||
/* int ibyte; */
|
||||
/* int ii=0; */
|
||||
/* for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){ */
|
||||
/* xmap[ibyte]=-1; */
|
||||
/* ymap[ibyte]=-1; */
|
||||
/* } */
|
||||
/* int off=sizeof(sls_detector_header)/2; */
|
||||
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
|
||||
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
|
||||
/* i=ipacket*8208/2+ibyte; */
|
||||
/* isample=ii/nadc; */
|
||||
/* if (isample<nSamples) { */
|
||||
/* iadc=ii%nadc; */
|
||||
/* adc4 = (int)iadc/4; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (adc4%2==0) { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2+iy; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* ii++; */
|
||||
/* // } */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
iframe = 0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
return ((sls_detector_header *)buff)->frameNumber;
|
||||
}; //*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff) {
|
||||
return ((sls_detector_header *)buff)->packetNumber;
|
||||
} //((*(((int*)(buff+4))))&0xff)+1;};
|
||||
int getFrameNumber(char *buff){return ((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/* /\** */
|
||||
/**
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e.
|
||||
* all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the
|
||||
* frame, in case the frame is incomplete at the end of the memory slot
|
||||
*/
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might
|
||||
* be incomplete if ndata smaller than dataSize), or NULL if no frame is
|
||||
* found */
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int
|
||||
* dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e.
|
||||
* all packets 0 to nPackets, same frame number). Can be overloaded for
|
||||
* different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no
|
||||
* frame is found or last frame is incomplete */
|
||||
*/
|
||||
int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
/* /\** */
|
||||
|
||||
virtual char *readNextFrame(ifstream & filebin) {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||
|
||||
virtual char *readNextFrame(ifstream & filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
virtual char *readNextFrame(ifstream & filebin, int &ff, int &np) {
|
||||
char *data = new char[dataSize];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
virtual char *readNextFrame(ifstream & filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
char *retval = 0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np = 0;
|
||||
int pn;
|
||||
/* /\** */
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff >= 0)
|
||||
fnum = ff;
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
np = getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all
|
||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
||||
data pointer to the memory to be analyzed \param ndata reference to
|
||||
the amount of data found for the frame, in case the frame is
|
||||
incomplete at the end of the memory slot \param dsize size of the
|
||||
memory slot to be analyzed \returns pointer to the beginning of the
|
||||
last good frame (might be incomplete if ndata smaller than dataSize),
|
||||
or NULL if no frame is found
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
char *retval=0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np=0;
|
||||
int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
ff=getFrameNumber(data);
|
||||
np=getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<dataSize) ndata=dsize;
|
||||
else ndata=dataSize;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
|
||||
};
|
||||
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
if (dsize < dataSize)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = dataSize;
|
||||
return data;
|
||||
}
|
||||
|
||||
// int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,169 +1,178 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOENCH03T1REORDERED_H
|
||||
#define MOENCH03T1REORDERED_H
|
||||
#define MOENCH03T1REORDERED_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
class moench03T1ReorderedData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
|
||||
private:
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
fwrite(&ff, 8, 1,of);//write detector frame number
|
||||
fwrite(&ifr, 8, 1,of);//write datset frame number
|
||||
fwrite(data,2,NX*NY,of);//write reordered data
|
||||
*/
|
||||
moench03T1ReorderedData()
|
||||
: slsDetectorData<uint16_t>(400, 400, 2 * 400 * 400 + 2 * 8) {
|
||||
for (int iy = 0; iy < 400; iy++)
|
||||
for (int ix = 0; ix < 400; ix++)
|
||||
dataMap[iy][ix] = 2 * 8 + 2 * (iy * 400 + ix);
|
||||
|
||||
int ibyte;
|
||||
for (ibyte = 0; ibyte < 8; ibyte++) {
|
||||
xmap[ibyte] = -1;
|
||||
ymap[ibyte] = -1;
|
||||
}
|
||||
for (ibyte = 0; ibyte < 400 * 400; ibyte++) {
|
||||
xmap[ibyte + 8] = ibyte % 400;
|
||||
ymap[ibyte + 8] = ibyte / 400;
|
||||
}
|
||||
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
int getFrameNumber(char *buff) { return *((int *)buff); };
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all
|
||||
* packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in
|
||||
* case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be
|
||||
* incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
*/
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int
|
||||
* dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all
|
||||
* packets 0 to nPackets, same frame number). Can be overloaded for
|
||||
* different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no
|
||||
* frame is found or last frame is incomplete */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np) {
|
||||
char *data = new char[dataSize];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
fwrite(&ff, 8, 1,of);//write detector frame number
|
||||
fwrite(&ifr, 8, 1,of);//write datset frame number
|
||||
fwrite(data,2,NX*NY,of);//write reordered data
|
||||
*/
|
||||
moench03T1ReorderedData(): slsDetectorData<uint16_t>(400, 400, 2*400*400+2*8) {
|
||||
for (int iy=0; iy<400; iy++)
|
||||
for (int ix=0; ix<400; ix++)
|
||||
dataMap[iy][ix]=2*8+2*(iy*400+ix);
|
||||
|
||||
int ibyte;
|
||||
for (ibyte=0; ibyte<8; ibyte++){
|
||||
xmap[ibyte]=-1;
|
||||
ymap[ibyte]=-1;
|
||||
}
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
char *retval = 0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np = 0;
|
||||
int pn;
|
||||
|
||||
if (ff >= 0)
|
||||
fnum = ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
np = 40;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all
|
||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
||||
data pointer to the memory to be analyzed \param ndata reference to the
|
||||
amount of data found for the frame, in case the frame is incomplete at
|
||||
the end of the memory slot \param dsize size of the memory slot to be
|
||||
analyzed \returns pointer to the beginning of the last good frame (might
|
||||
be incomplete if ndata smaller than dataSize), or NULL if no frame is
|
||||
found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
if (dsize < dataSize)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = dataSize;
|
||||
return data;
|
||||
for (ibyte=0; ibyte<400*400; ibyte++){
|
||||
xmap[ibyte+8]=ibyte%400;
|
||||
ymap[ibyte+8]=ibyte/400;
|
||||
}
|
||||
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
|
||||
|
||||
int getFrameNumber(char *buff){return *((int*)buff);};
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
char *retval=0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np=0;
|
||||
int pn;
|
||||
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
ff=getFrameNumber(data);
|
||||
np=40;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<dataSize) ndata=dsize;
|
||||
else ndata=dataSize;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
|
||||
// int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,249 +1,270 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOENCH03T1ZMQDATA_H
|
||||
#define MOENCH03T1ZMQDATA_H
|
||||
#define MOENCH03T1ZMQDATA_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
|
||||
class moench03T1ZmqData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int nPackets; /**<number of UDP packets constituting one frame */
|
||||
const int packetSize; /**< size of a udp packet */
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int nPackets; /**<number of UDP packets constituting one frame */
|
||||
const int packetSize; /**< size of a udp packet */
|
||||
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
moench03T1ZmqData(int npackets = 40, int ps = 8192)
|
||||
: slsDetectorData<uint16_t>(400, 400, ps * npackets), packetSize(ps),
|
||||
nPackets(npackets) {
|
||||
|
||||
int nadc = 32;
|
||||
int sc_width = 25;
|
||||
int sc_height = 200;
|
||||
|
||||
int adc_nr[32] = {300, 325, 350, 375, 300, 325, 350, 375, 200, 225, 250,
|
||||
275, 200, 225, 250, 275, 100, 125, 150, 175, 100, 125,
|
||||
150, 175, 0, 25, 50, 75, 0, 25, 50, 75};
|
||||
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
// int npackets=40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
|
||||
for (int ip = 0; ip < npackets; ip++) {
|
||||
for (int is = 0; is < 128; is++) {
|
||||
|
||||
for (iadc = 0; iadc < nadc; iadc++) {
|
||||
i = 128 * ip + is;
|
||||
adc4 = (int)iadc / 4;
|
||||
if (i < sc_width * sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col = adc_nr[iadc] + (i % sc_width);
|
||||
if (adc4 % 2 == 0) {
|
||||
row = 199 - i / sc_width;
|
||||
} else {
|
||||
row = 200 + i / sc_width;
|
||||
}
|
||||
dataMap[row][col] = (nadc * i + iadc) * 2; //+16*(ip+1);
|
||||
if (dataMap[row][col] < 0 ||
|
||||
dataMap[row][col] >= 8192 * 40)
|
||||
cout << "Error: pointer " << dataMap[row][col]
|
||||
<< " out of range " << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ipacket;
|
||||
int ibyte;
|
||||
int ii = 0;
|
||||
for (int ipacket = 0; ipacket < npackets; ipacket++) {
|
||||
for (int ibyte = 0; ibyte < 8192 / 2; ibyte++) {
|
||||
i = ipacket * 8208 / 2 + ibyte;
|
||||
/* if (ibyte<8) { */
|
||||
/* //header! */
|
||||
/* xmap[i]=-1; */
|
||||
/* ymap[i]=-1; */
|
||||
/* } else { */
|
||||
// ii=ibyte+128*32*ipacket;
|
||||
isample = ii / nadc;
|
||||
iadc = ii % nadc;
|
||||
adc4 = (int)iadc / 4;
|
||||
ix = isample % sc_width;
|
||||
iy = isample / sc_width;
|
||||
if (adc4 % 2 == 0) {
|
||||
xmap[i] = adc_nr[iadc] + ix;
|
||||
ymap[i] = ny / 2 - 1 - iy;
|
||||
} else {
|
||||
xmap[i] = adc_nr[iadc] + ix;
|
||||
ymap[i] = ny / 2 + iy;
|
||||
}
|
||||
|
||||
ii++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
iframe = 0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
return iframe;
|
||||
}; //*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
public:
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff) {
|
||||
return 0;
|
||||
} //((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* /\** */
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all
|
||||
* packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in
|
||||
* case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be
|
||||
* incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
*/
|
||||
*/
|
||||
moench03T1ZmqData(int npackets=40, int ps=8192): slsDetectorData<uint16_t>(400, 400, ps*npackets), packetSize(ps), nPackets(npackets) {
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int
|
||||
* dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
int nadc=32;
|
||||
int sc_width=25;
|
||||
int sc_height=200;
|
||||
|
||||
/* /\** */
|
||||
int adc_nr[32]={300,325,350,375,300,325,350,375, \
|
||||
200,225,250,275,200,225,250,275,\
|
||||
100,125,150,175,100,125,150,175,\
|
||||
0,25,50,75,0,25,50,75};
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all
|
||||
* packets 0 to nPackets, same frame number). Can be overloaded for
|
||||
* different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no
|
||||
* frame is found or last frame is incomplete */
|
||||
int row, col;
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
// int npackets=40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
for (int ip=0; ip<npackets; ip++) {
|
||||
for (int is=0; is<128; is++) {
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np) {
|
||||
char *data = new char[packetSize * nPackets];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
i=128*ip+is;
|
||||
adc4=(int)iadc/4;
|
||||
if (i<sc_width*sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=adc_nr[iadc]+(i%sc_width);
|
||||
if (adc4%2==0) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
dataMap[row][col]=(nadc*i+iadc)*2;//+16*(ip+1);
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=8192*40)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
char *retval = 0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np = 0;
|
||||
int pn;
|
||||
|
||||
if (ff >= 0)
|
||||
fnum = ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, packetSize * nPackets)) {
|
||||
iframe++;
|
||||
ff = iframe;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all
|
||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
||||
data pointer to the memory to be analyzed \param ndata reference to the
|
||||
amount of data found for the frame, in case the frame is incomplete at
|
||||
the end of the memory slot \param dsize size of the memory slot to be
|
||||
analyzed \returns pointer to the beginning of the last good frame (might
|
||||
be incomplete if ndata smaller than dataSize), or NULL if no frame is
|
||||
found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
if (dsize < packetSize * nPackets)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = packetSize * nPackets;
|
||||
return data;
|
||||
int ipacket;
|
||||
int ibyte;
|
||||
int ii=0;
|
||||
for (int ipacket=0; ipacket<npackets; ipacket++) {
|
||||
for (int ibyte=0; ibyte< 8192/2; ibyte++) {
|
||||
i=ipacket*8208/2+ibyte;
|
||||
/* if (ibyte<8) { */
|
||||
/* //header! */
|
||||
/* xmap[i]=-1; */
|
||||
/* ymap[i]=-1; */
|
||||
/* } else { */
|
||||
// ii=ibyte+128*32*ipacket;
|
||||
isample=ii/nadc;
|
||||
iadc=ii%nadc;
|
||||
adc4 = (int)iadc/4;
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
if (adc4%2==0) {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2-1-iy;
|
||||
} else {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2+iy;
|
||||
}
|
||||
|
||||
ii++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
|
||||
|
||||
int getFrameNumber(char *buff){return iframe;};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff){return 0;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[packetSize*nPackets];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
char *retval=0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np=0;
|
||||
int pn;
|
||||
|
||||
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, packetSize*nPackets) ){
|
||||
iframe++;
|
||||
ff=iframe;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<packetSize*nPackets) ndata=dsize;
|
||||
else ndata=packetSize*nPackets;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
|
||||
int getPacketNumber(int x, int y) { return dataMap[y][x] / packetSize; };
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,329 +1,354 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOENCH03T1ZMQDATANEW_H
|
||||
#define MOENCH03T1ZMQDATANEW_H
|
||||
#define MOENCH03T1ZMQDATANEW_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
// int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int nSamples;
|
||||
const int offset;
|
||||
|
||||
double ghost[200][25];
|
||||
double xtalk;
|
||||
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
// moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400,
|
||||
// ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) {
|
||||
moench03T1ZmqDataNew(int ns = 5000, int oo = 2 * 2)
|
||||
: slsDetectorData<uint16_t>(400, 400, ns * 32 * 2 + oo), nSamples(ns),
|
||||
offset(oo), xtalk(0.00021) {
|
||||
std::cout << "M0.3" << std::endl;
|
||||
int nadc = 32;
|
||||
int sc_width = 25;
|
||||
int sc_height = 200;
|
||||
|
||||
int adc_nr[32] = {300, 325, 350, 375, 300, 325, 350, 375, 200, 225, 250,
|
||||
275, 200, 225, 250, 275, 100, 125, 150, 175, 100, 125,
|
||||
150, 175, 0, 25, 50, 75, 0, 25, 50, 75};
|
||||
|
||||
/* int adc_nr[32]={350,375,150,175,350,375,150,175, \
|
||||
300,325,100,125,300,325,100,125,\
|
||||
250,275,50,75,250,275,50,75,\
|
||||
200,225,0,25,200,225,0,25};
|
||||
*/
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
// int npackets=40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
|
||||
// for (int ip=0; ip<npackets; ip++) {
|
||||
// for (int is=0; is<128; is++) {
|
||||
for (i = 0; i < nSamples; i++) {
|
||||
for (iadc = 0; iadc < nadc; iadc++) {
|
||||
// i=128*ip+is;
|
||||
adc4 = (int)iadc / 4;
|
||||
if (i < sc_width * sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col = adc_nr[iadc] + (i % sc_width);
|
||||
if (adc4 % 2 == 0) {
|
||||
row = 199 - i / sc_width;
|
||||
} else {
|
||||
row = 200 + i / sc_width;
|
||||
}
|
||||
dataMap[row][col] =
|
||||
(nadc * i + iadc) * 2 + offset; //+16*(ip+1);
|
||||
if (dataMap[row][col] < 0 || dataMap[row][col] >= dataSize)
|
||||
std::cout << "Error: pointer " << dataMap[row][col]
|
||||
<< " out of range " << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
int ii = 0;
|
||||
|
||||
for (i = 0; i < dataSize; i++) {
|
||||
if (i < offset) {
|
||||
// header! */
|
||||
xmap[i] = -1;
|
||||
ymap[i] = -1;
|
||||
} else {
|
||||
// ii=ibyte+128*32*ipacket;
|
||||
isample = ii / nadc;
|
||||
if (isample < nSamples) {
|
||||
iadc = ii % nadc;
|
||||
adc4 = (int)iadc / 4;
|
||||
ix = isample % sc_width;
|
||||
iy = isample / sc_width;
|
||||
if (adc4 % 2 == 0) {
|
||||
xmap[i] = adc_nr[iadc] + ix;
|
||||
ymap[i] = ny / 2 - 1 - iy;
|
||||
} else {
|
||||
xmap[i] = adc_nr[iadc] + ix;
|
||||
ymap[i] = ny / 2 + iy;
|
||||
}
|
||||
}
|
||||
|
||||
ii++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int ix = 0; ix < 25; ix++)
|
||||
for (int iy = 0; iy < 200; iy++)
|
||||
ghost[iy][ix] = 0.;
|
||||
|
||||
// iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
double getXTalk() { return xtalk; };
|
||||
void setXTalk(double g) { xtalk = g; };
|
||||
|
||||
/**
|
||||
Returns the value of the selected channel for the given dataset as
|
||||
double. \param data pointer to the dataset (including headers etc) \param
|
||||
ix pixel number in the x direction \param iy pixel number in the y
|
||||
direction \returns data for the selected channel, with inversion if
|
||||
required as double
|
||||
|
||||
*/
|
||||
virtual double getValue(char *data, int ix, int iy = 0) {
|
||||
/* cout << " x "<< ix << " y"<< iy << " val " << getChannel(data, ix,
|
||||
* iy)<< endl;*/
|
||||
/* double val=0, vout=getChannel(data, ix, iy); */
|
||||
/* int x1=ix%25; */
|
||||
/* for (int ix=0; ix<16; ix++) { */
|
||||
/* for (int ii=0; ii<2; ii++) { */
|
||||
/* val+=getChannel(data,x1+25*ix,iy); */
|
||||
/* val+=getChannel(data,x1+25*ix,399-iy); */
|
||||
/* } */
|
||||
/* } */
|
||||
/* vout+=0.0008*val-6224; */
|
||||
/* return vout; //(double)getChannel(data, ix, iy);
|
||||
*/
|
||||
// cout << ix << " "<< iy << " " << dataMap[iy][ix] << endl;
|
||||
return ((double)getChannel(data, ix, iy)) + xtalk * getGhost(iy, iy);
|
||||
};
|
||||
|
||||
virtual void calcGhost(char *data, int ix, int iy) {
|
||||
double val = 0;
|
||||
/* for (int ix=0; ix<25; ix++){ */
|
||||
/* for (int iy=0; iy<200; iy++) { */
|
||||
val = 0;
|
||||
for (int isc = 0; isc < 16; isc++) {
|
||||
for (int ii = 0; ii < 2; ii++) {
|
||||
val += getChannel(data, ix + 25 * isc, iy);
|
||||
// cout << val << " " ;
|
||||
val += getChannel(data, ix + 25 * isc, 399 - iy);
|
||||
// cout << val << " " ;
|
||||
}
|
||||
}
|
||||
ghost[iy][ix] = val; //-6224;
|
||||
// cout << endl;
|
||||
/* } */
|
||||
/* } */
|
||||
// cout << "*" << endl;
|
||||
}
|
||||
|
||||
virtual void calcGhost(char *data) {
|
||||
for (int ix = 0; ix < 25; ix++) {
|
||||
for (int iy = 0; iy < 200; iy++) {
|
||||
calcGhost(data, ix, iy);
|
||||
}
|
||||
}
|
||||
// cout << "*" << endl;
|
||||
}
|
||||
|
||||
double getGhost(int ix, int iy) {
|
||||
if (iy < 200)
|
||||
return ghost[iy][ix % 25];
|
||||
if (iy < 400)
|
||||
return ghost[399 - iy][ix % 25];
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
return *((int *)buff);
|
||||
}; //*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
private:
|
||||
|
||||
// int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int nSamples;
|
||||
const int offset;
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff) {
|
||||
return 0;
|
||||
} //((*(((int*)(buff+4))))&0xff)+1;};
|
||||
double ghost[200][25];
|
||||
double xtalk;
|
||||
|
||||
/* /\** */
|
||||
public:
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all
|
||||
* packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in
|
||||
* case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be
|
||||
* incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
// moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) {
|
||||
moench03T1ZmqDataNew(int ns=5000, int oo=2*2): slsDetectorData<uint16_t>(400, 400, ns*32*2+oo), nSamples(ns), offset(oo), xtalk(0.00021) {
|
||||
cout << "M0.3" << endl;
|
||||
int nadc=32;
|
||||
int sc_width=25;
|
||||
int sc_height=200;
|
||||
|
||||
int adc_nr[32]={300,325,350,375,300,325,350,375, \
|
||||
200,225,250,275,200,225,250,275,\
|
||||
100,125,150,175,100,125,150,175,\
|
||||
0,25,50,75,0,25,50,75};
|
||||
|
||||
/* int adc_nr[32]={350,375,150,175,350,375,150,175, \
|
||||
300,325,100,125,300,325,100,125,\
|
||||
250,275,50,75,250,275,50,75,\
|
||||
200,225,0,25,200,225,0,25};
|
||||
*/
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
int npackets=40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
|
||||
//for (int ip=0; ip<npackets; ip++) {
|
||||
// for (int is=0; is<128; is++) {
|
||||
for (i=0; i<nSamples; i++) {
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
//i=128*ip+is;
|
||||
adc4=(int)iadc/4;
|
||||
if (i<sc_width*sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=adc_nr[iadc]+(i%sc_width);
|
||||
if (adc4%2==0) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
dataMap[row][col]=(nadc*i+iadc)*2+offset;//+16*(ip+1);
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=dataSize)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int
|
||||
* dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all
|
||||
* packets 0 to nPackets, same frame number). Can be overloaded for
|
||||
* different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no
|
||||
* frame is found or last frame is incomplete */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
virtual char *readNextFrame(std::ifstream &filebin) {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np) {
|
||||
char *data = new char[32 * 2 * nSamples];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
|
||||
int ii=0;
|
||||
|
||||
for (i=0; i< dataSize; i++) {
|
||||
if (i<offset) {
|
||||
//header! */
|
||||
xmap[i]=-1;
|
||||
ymap[i]=-1;
|
||||
} else {
|
||||
// ii=ibyte+128*32*ipacket;
|
||||
isample=ii/nadc;
|
||||
if (isample<nSamples) {
|
||||
iadc=ii%nadc;
|
||||
adc4 = (int)iadc/4;
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
if (adc4%2==0) {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2-1-iy;
|
||||
} else {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2+iy;
|
||||
}
|
||||
}
|
||||
|
||||
ii++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
// char *retval=0;
|
||||
// int nd;
|
||||
// int fnum = -1;
|
||||
np = 0;
|
||||
// int pn;
|
||||
|
||||
for (int ix=0; ix<25; ix++)
|
||||
for (int iy=0; iy<200; iy++)
|
||||
ghost[iy][ix]=0.;
|
||||
|
||||
|
||||
// iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
// if (ff>=0)
|
||||
// fnum=ff;
|
||||
double getXTalk(){return xtalk;};
|
||||
void setXTalk(double g) {xtalk=g;};
|
||||
|
||||
/**
|
||||
Returns the value of the selected channel for the given dataset as double.
|
||||
\param data pointer to the dataset (including headers etc)
|
||||
\param ix pixel number in the x direction
|
||||
\param iy pixel number in the y direction
|
||||
\returns data for the selected channel, with inversion if required as double
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, 32 * 2 * nSamples)) {
|
||||
// iframe++;
|
||||
// ff=iframe;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
*/
|
||||
virtual double getValue(char *data, int ix, int iy=0) {
|
||||
/* cout << " x "<< ix << " y"<< iy << " val " << getChannel(data, ix, iy)<< endl;*/
|
||||
/* double val=0, vout=getChannel(data, ix, iy); */
|
||||
/* int x1=ix%25; */
|
||||
/* for (int ix=0; ix<16; ix++) { */
|
||||
/* for (int ii=0; ii<2; ii++) { */
|
||||
/* val+=getChannel(data,x1+25*ix,iy); */
|
||||
/* val+=getChannel(data,x1+25*ix,399-iy); */
|
||||
/* } */
|
||||
/* } */
|
||||
/* vout+=0.0008*val-6224; */
|
||||
/* return vout; //(double)getChannel(data, ix, iy);
|
||||
*/
|
||||
// cout << ix << " "<< iy << " " << dataMap[iy][ix] << endl;
|
||||
return ((double)getChannel(data, ix, iy))+xtalk*getGhost(iy,iy);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all
|
||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
||||
data pointer to the memory to be analyzed \param ndata reference to the
|
||||
amount of data found for the frame, in case the frame is incomplete at
|
||||
the end of the memory slot \param dsize size of the memory slot to be
|
||||
analyzed \returns pointer to the beginning of the last good frame (might
|
||||
be incomplete if ndata smaller than dataSize), or NULL if no frame is
|
||||
found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
if (dsize < 32 * 2 * nSamples)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = 32 * 2 * nSamples;
|
||||
return data;
|
||||
virtual void calcGhost(char *data, int ix, int iy) {
|
||||
double val=0;
|
||||
/* for (int ix=0; ix<25; ix++){ */
|
||||
/* for (int iy=0; iy<200; iy++) { */
|
||||
val=0;
|
||||
for (int isc=0; isc<16; isc++) {
|
||||
for (int ii=0; ii<2; ii++) {
|
||||
val+=getChannel(data,ix+25*isc,iy);
|
||||
// cout << val << " " ;
|
||||
val+=getChannel(data,ix+25*isc,399-iy);
|
||||
// cout << val << " " ;
|
||||
}
|
||||
}
|
||||
ghost[iy][ix]=val;//-6224;
|
||||
// cout << endl;
|
||||
/* } */
|
||||
/* } */
|
||||
// cout << "*" << endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void calcGhost(char *data) {
|
||||
for (int ix=0; ix<25; ix++){
|
||||
for (int iy=0; iy<200; iy++) {
|
||||
calcGhost(data, ix,iy);
|
||||
}
|
||||
}
|
||||
// cout << "*" << endl;
|
||||
}
|
||||
|
||||
// virtual int setFrameNumber(int ff){iframe=ff};
|
||||
|
||||
int getPacketNumber(int x, int y) { return 0; };
|
||||
double getGhost(int ix, int iy) {
|
||||
if (iy<200) return ghost[iy][ix%25];
|
||||
if (iy<400) return ghost[399-iy][ix%25];
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
|
||||
|
||||
int getFrameNumber(char *buff){return *((int*)buff);};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff){return 0;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[32*2*nSamples];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
//char *retval=0;
|
||||
// int nd;
|
||||
//int fnum = -1;
|
||||
np=0;
|
||||
// int pn;
|
||||
|
||||
|
||||
// if (ff>=0)
|
||||
// fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, 32*2*nSamples) ){
|
||||
// iframe++;
|
||||
//ff=iframe;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<32*2*nSamples) ndata=dsize;
|
||||
else ndata=32*2*nSamples;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// virtual int setFrameNumber(int ff){iframe=ff};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int getPacketNumber(int x, int y) {return 0;};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,166 +1,182 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOENCH03TCTBDATA_H
|
||||
#define MOENCH03TCTBDATA_H
|
||||
#define MOENCH03TCTBDATA_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
|
||||
class moench03TCtbData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
public:
|
||||
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
|
||||
moench03TCtbData(int ns = 5000)
|
||||
: slsDetectorData<uint16_t>(400, 400, ns * 2 * 32, NULL, NULL),
|
||||
nadc(32), sc_width(25), sc_height(200) {
|
||||
|
||||
int row, col;
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
*/
|
||||
|
||||
|
||||
int adc_nr[32] = {300, 325, 350, 375, 300, 325, 350, 375, 200, 225, 250,
|
||||
275, 200, 225, 250, 275, 100, 125, 150, 175, 100, 125,
|
||||
150, 175, 0, 25, 50, 75, 0, 25, 50, 75};
|
||||
moench03TCtbData(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*2*32, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) {
|
||||
|
||||
/* int adc_nr[32]={200,225,250,275,300,325,350,375,\ */
|
||||
/* 0,25,50,75,100,125,150,175,\ */
|
||||
/* 175,150,125,100,75,50,25,0,\ */
|
||||
/* 375,350,325,300,275,250,225,200}; */
|
||||
|
||||
int row, col;
|
||||
|
||||
for (iadc = 0; iadc < nadc; iadc++) {
|
||||
for (int i = 0; i < sc_width * sc_height; i++) {
|
||||
col = adc_nr[iadc] + (i % sc_width);
|
||||
if (iadc < 16) {
|
||||
row = 199 - i / sc_width;
|
||||
} else {
|
||||
row = 200 + i / sc_width;
|
||||
}
|
||||
dataMap[row][col] = (nadc * i + iadc) * 2;
|
||||
if (dataMap[row][col] < 0 || dataMap[row][col] >= 2 * 400 * 400)
|
||||
cout << "Error: pointer " << dataMap[row][col]
|
||||
<< " out of range " << endl;
|
||||
}
|
||||
}
|
||||
int adc4;
|
||||
for (int i = 0; i < nx * ny; i++) {
|
||||
isample = i / nadc;
|
||||
iadc = i % nadc;
|
||||
ix = isample % sc_width;
|
||||
iy = isample / sc_width;
|
||||
adc4 = (int)iadc / 4;
|
||||
// if (iadc<(nadc/2)) {
|
||||
if (adc4 % 2 == 0) {
|
||||
xmap[i] = adc_nr[iadc] + ix;
|
||||
ymap[i] = ny / 2 - 1 - iy;
|
||||
} else {
|
||||
xmap[i] = adc_nr[iadc] + ix;
|
||||
ymap[i] = ny / 2 + iy;
|
||||
}
|
||||
}
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
/* for (int i=0; i<nx*ny; i++) { */
|
||||
/* isample=i/nadc; */
|
||||
/* iadc=i%nadc; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (iadc<(nadc/2)) { */
|
||||
/* xmap[i]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i]=ny/2+iy; */
|
||||
/* } */
|
||||
|
||||
|
||||
/* } */
|
||||
int adc_nr[32]={300,325,350,375,300,325,350,375, \
|
||||
200,225,250,275,200,225,250,275,\
|
||||
100,125,150,175,100,125,150,175,\
|
||||
0,25,50,75,0,25,50,75};
|
||||
|
||||
iframe = 0;
|
||||
// cout << "data struct created" << endl;
|
||||
|
||||
|
||||
/* int adc_nr[32]={200,225,250,275,300,325,350,375,\ */
|
||||
/* 0,25,50,75,100,125,150,175,\ */
|
||||
/* 175,150,125,100,75,50,25,0,\ */
|
||||
/* 375,350,325,300,275,250,225,200}; */
|
||||
|
||||
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=adc_nr[iadc]+(i%sc_width);
|
||||
if (iadc<16) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
dataMap[row][col]=(nadc*i+iadc)*2;
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=2*400*400)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
|
||||
}
|
||||
}
|
||||
int adc4;
|
||||
for (int i=0; i<nx*ny; i++) {
|
||||
isample=i/nadc;
|
||||
iadc=i%nadc;
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
adc4 = (int)iadc/4;
|
||||
// if (iadc<(nadc/2)) {
|
||||
if (adc4%2==0) {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2-1-iy;
|
||||
} else {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2+iy;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* for (int i=0; i<nx*ny; i++) { */
|
||||
/* isample=i/nadc; */
|
||||
/* iadc=i%nadc; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (iadc<(nadc/2)) { */
|
||||
/* xmap[i]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i]=ny/2+iy; */
|
||||
/* } */
|
||||
|
||||
|
||||
/* } */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
|
||||
virtual int getFrameNumber(char *buff){(void)buff; return iframe;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
virtual int getPacketNumber(char *buff)=0;
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
|
||||
\param filebin input file stream (binary)
|
||||
\returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete
|
||||
|
||||
*/
|
||||
virtual char *readNextFrame(ifstream &filebin){
|
||||
// int afifo_length=0;
|
||||
uint16_t *afifo_cont;
|
||||
int ib=0;
|
||||
if (filebin.is_open()) {
|
||||
afifo_cont=new uint16_t[dataSize/2];
|
||||
while (filebin.read(((char*)afifo_cont)+ib,2)) {
|
||||
ib+=2;
|
||||
if (ib==dataSize) break;
|
||||
}
|
||||
if (ib>0) {
|
||||
iframe++;
|
||||
// cout << ib << "-" << endl;
|
||||
return (char*)afifo_cont;
|
||||
} else {
|
||||
delete [] afifo_cont;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
|
||||
*/
|
||||
|
||||
virtual int getFrameNumber(char *buff) {
|
||||
(void)buff;
|
||||
return iframe;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
virtual int getPacketNumber(char *buff)=0;
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets
|
||||
0 to nPackets, same frame number). purely virtual func \param data pointer
|
||||
to the memory to be analyzed \param ndata reference to the amount of data
|
||||
found for the frame, in case the frame is incomplete at the end of the
|
||||
memory slot \param dsize size of the memory slot to be analyzed \returns
|
||||
pointer to the beginning of the last good frame (might be incomplete if
|
||||
ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
ndata = dsize;
|
||||
setDataSize(dsize);
|
||||
return data;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets
|
||||
0 to nPackets, same frame number). Can be overloaded for different kind of
|
||||
detectors! \param filebin input file stream (binary) \returns pointer to
|
||||
the begin of the last good frame, NULL if no frame is found or last frame
|
||||
is incomplete
|
||||
|
||||
*/
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
// int afifo_length=0;
|
||||
uint16_t *afifo_cont;
|
||||
int ib = 0;
|
||||
if (filebin.is_open()) {
|
||||
afifo_cont = new uint16_t[dataSize / 2];
|
||||
while (filebin.read(((char *)afifo_cont) + ib, 2)) {
|
||||
ib += 2;
|
||||
if (ib == dataSize)
|
||||
break;
|
||||
}
|
||||
if (ib > 0) {
|
||||
iframe++;
|
||||
// cout << ib << "-" << endl;
|
||||
return (char *)afifo_cont;
|
||||
} else {
|
||||
delete[] afifo_cont;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,301 +1,296 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOENCH04REC10GBDATA_H
|
||||
#define MOENCH04REC10GBDATA_H
|
||||
#define MOENCH04REC10GBDATA_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
//#define VERSION_V2
|
||||
/**
|
||||
@short structure for a Detector Packet or Image Header
|
||||
@li frameNumber is the frame number
|
||||
@li expLength is the subframe number (32 bit eiger) or real time exposure
|
||||
time in 100ns (others)
|
||||
@li packetNumber is the packet number
|
||||
@li bunchId is the bunch id from beamline
|
||||
@li timestamp is the time stamp with 10 MHz clock
|
||||
@li modId is the unique module id (unique even for left, right, top, bottom)
|
||||
@li xCoord is the x coordinate in the complete detector system
|
||||
@li yCoord is the y coordinate in the complete detector system
|
||||
@li zCoord is the z coordinate in the complete detector system
|
||||
@li debug is for debugging purposes
|
||||
@li roundRNumber is the round robin set number
|
||||
@li detType is the detector type see :: detectorType
|
||||
@li version is the version number of this structure format
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t frameNumber; /**< is the frame number */
|
||||
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time
|
||||
exposure time in 100ns (others) */
|
||||
uint32_t packetNumber; /**< is the packet number */
|
||||
uint64_t bunchId; /**< is the bunch id from beamline */
|
||||
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||
uint16_t modId; /**< is the unique module id (unique even for left, right,
|
||||
top, bottom) */
|
||||
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||
uint32_t debug; /**< is for debugging purposes */
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
uint64_t
|
||||
packetCaught[8]; /**< is the version number of this structure format */
|
||||
/**
|
||||
@short structure for a Detector Packet or Image Header
|
||||
@li frameNumber is the frame number
|
||||
@li expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
@li packetNumber is the packet number
|
||||
@li bunchId is the bunch id from beamline
|
||||
@li timestamp is the time stamp with 10 MHz clock
|
||||
@li modId is the unique module id (unique even for left, right, top, bottom)
|
||||
@li xCoord is the x coordinate in the complete detector system
|
||||
@li yCoord is the y coordinate in the complete detector system
|
||||
@li zCoord is the z coordinate in the complete detector system
|
||||
@li debug is for debugging purposes
|
||||
@li roundRNumber is the round robin set number
|
||||
@li detType is the detector type see :: detectorType
|
||||
@li version is the version number of this structure format
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t frameNumber; /**< is the frame number */
|
||||
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
|
||||
uint32_t packetNumber; /**< is the packet number */
|
||||
uint64_t bunchId; /**< is the bunch id from beamline */
|
||||
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||
uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
|
||||
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||
uint32_t debug; /**< is for debugging purposes */
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
uint64_t packetCaught[8]; /**< is the version number of this structure format */
|
||||
|
||||
} sls_detector_header;
|
||||
|
||||
|
||||
|
||||
} sls_detector_header;
|
||||
|
||||
class moench04CtbReceiver10GbData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int aSamples;
|
||||
const int dSamples;
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int aSamples;
|
||||
const int dSamples;
|
||||
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
moench04CtbReceiver10GbData(int nas = 5000, int nds = 0)
|
||||
: slsDetectorData<uint16_t>(
|
||||
400, 400, nas * 2 * 32 + sizeof(sls_detector_header) + nds * 8),
|
||||
aSamples(nas), dSamples(nds) {
|
||||
|
||||
int nadc = 32;
|
||||
int sc_width = 25;
|
||||
int sc_height = 200;
|
||||
|
||||
int adc_nr[32] = {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 row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
int npackets = 40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
|
||||
for (int ip = 0; ip < npackets; ip++) {
|
||||
for (int is = 0; is < 128; is++) {
|
||||
|
||||
for (iadc = 0; iadc < nadc; iadc++) {
|
||||
i = 128 * ip + is;
|
||||
adc4 = (int)iadc / 4;
|
||||
if (i < sc_width * sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col = (adc_nr[iadc] % 16) * sc_width + (i % sc_width);
|
||||
// if (adc4%2==0) {
|
||||
if (iadc / 16 > 0) {
|
||||
row = 199 - i / sc_width;
|
||||
} else {
|
||||
row = 200 + i / sc_width;
|
||||
}
|
||||
if (nds > 0)
|
||||
dataMap[row][col] =
|
||||
sizeof(sls_detector_header) +
|
||||
((nadc + 4) * i + iadc) * 2; //+16*(ip+1);
|
||||
else
|
||||
dataMap[row][col] =
|
||||
sizeof(sls_detector_header) +
|
||||
(nadc * i + iadc) * 2; //+16*(ip+1);
|
||||
if (dataMap[row][col] < 0 ||
|
||||
dataMap[row][col] >= aSamples * 2 * 32)
|
||||
cout << "Error: pointer " << dataMap[row][col]
|
||||
<< " out of range " << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ipacket;
|
||||
int ibyte;
|
||||
int ii = 0;
|
||||
for (ibyte = 0; ibyte < sizeof(sls_detector_header) / 2; ibyte++) {
|
||||
xmap[ibyte] = -1;
|
||||
ymap[ibyte] = -1;
|
||||
}
|
||||
/* int off=sizeof(sls_detector_header)/2; */
|
||||
|
||||
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
|
||||
|
||||
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
|
||||
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
|
||||
/* i=ipacket*8208/2+ibyte; */
|
||||
/* isample=ii/nadc; */
|
||||
/* if (isample<nSamples) { */
|
||||
/* iadc=ii%nadc; */
|
||||
/* adc4 = (int)iadc/4; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (adc4%2==0) { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2+iy; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* ii++; */
|
||||
/* // } */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
iframe = 0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
return ((sls_detector_header *)buff)->frameNumber;
|
||||
}; //*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
public:
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff) {
|
||||
return ((sls_detector_header *)buff)->packetNumber;
|
||||
} //((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* /\** */
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all
|
||||
* packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in
|
||||
* case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be
|
||||
* incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
*/
|
||||
*/
|
||||
moench04CtbReceiver10GbData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+sizeof(sls_detector_header)+nds*8), aSamples(nas), dSamples(nds) {
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int
|
||||
* dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
int nadc=32;
|
||||
int sc_width=25;
|
||||
int sc_height=200;
|
||||
|
||||
/* /\** */
|
||||
int adc_nr[32]={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 };
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all
|
||||
* packets 0 to nPackets, same frame number). Can be overloaded for
|
||||
* different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no
|
||||
* frame is found or last frame is incomplete */
|
||||
int row, col;
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
int npackets=40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
for (int ip=0; ip<npackets; ip++) {
|
||||
for (int is=0; is<128; is++) {
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np) {
|
||||
char *data = new char[dataSize];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
i=128*ip+is;
|
||||
adc4=(int)iadc/4;
|
||||
if (i<sc_width*sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=(adc_nr[iadc]%16)*sc_width+(i%sc_width);
|
||||
// if (adc4%2==0) {
|
||||
if (iadc/16>0) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
if (nds>0)
|
||||
dataMap[row][col]=sizeof(sls_detector_header)+((nadc+4)*i+iadc)*2;//+16*(ip+1);
|
||||
else
|
||||
dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
char *retval = 0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np = 0;
|
||||
int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff >= 0)
|
||||
fnum = ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
np = getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all
|
||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
||||
data pointer to the memory to be analyzed \param ndata reference to the
|
||||
amount of data found for the frame, in case the frame is incomplete at
|
||||
the end of the memory slot \param dsize size of the memory slot to be
|
||||
analyzed \returns pointer to the beginning of the last good frame (might
|
||||
be incomplete if ndata smaller than dataSize), or NULL if no frame is
|
||||
found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
if (dsize < dataSize)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = dataSize;
|
||||
return data;
|
||||
int ipacket;
|
||||
int ibyte;
|
||||
int ii=0;
|
||||
for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){
|
||||
xmap[ibyte]=-1;
|
||||
ymap[ibyte]=-1;
|
||||
}
|
||||
/* int off=sizeof(sls_detector_header)/2; */
|
||||
|
||||
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
|
||||
|
||||
|
||||
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
|
||||
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
|
||||
/* i=ipacket*8208/2+ibyte; */
|
||||
/* isample=ii/nadc; */
|
||||
/* if (isample<nSamples) { */
|
||||
/* iadc=ii%nadc; */
|
||||
/* adc4 = (int)iadc/4; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (adc4%2==0) { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2+iy; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* ii++; */
|
||||
/* // } */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
|
||||
|
||||
int getFrameNumber(char *buff){return ((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
char *retval=0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np=0;
|
||||
int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
ff=getFrameNumber(data);
|
||||
np=getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<dataSize) ndata=dsize;
|
||||
else ndata=dataSize;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
|
||||
// int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,296 +1,293 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOENCH04RECDATA_H
|
||||
#define MOENCH04RECDATA_H
|
||||
#define MOENCH04RECDATA_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
//#define VERSION_V2
|
||||
/**
|
||||
@short structure for a Detector Packet or Image Header
|
||||
@li frameNumber is the frame number
|
||||
@li expLength is the subframe number (32 bit eiger) or real time exposure
|
||||
time in 100ns (others)
|
||||
@li packetNumber is the packet number
|
||||
@li bunchId is the bunch id from beamline
|
||||
@li timestamp is the time stamp with 10 MHz clock
|
||||
@li modId is the unique module id (unique even for left, right, top, bottom)
|
||||
@li xCoord is the x coordinate in the complete detector system
|
||||
@li yCoord is the y coordinate in the complete detector system
|
||||
@li zCoord is the z coordinate in the complete detector system
|
||||
@li debug is for debugging purposes
|
||||
@li roundRNumber is the round robin set number
|
||||
@li detType is the detector type see :: detectorType
|
||||
@li version is the version number of this structure format
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t frameNumber; /**< is the frame number */
|
||||
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time
|
||||
exposure time in 100ns (others) */
|
||||
uint32_t packetNumber; /**< is the packet number */
|
||||
uint64_t bunchId; /**< is the bunch id from beamline */
|
||||
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||
uint16_t modId; /**< is the unique module id (unique even for left, right,
|
||||
top, bottom) */
|
||||
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||
uint32_t debug; /**< is for debugging purposes */
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
uint64_t
|
||||
packetCaught[8]; /**< is the version number of this structure format */
|
||||
/**
|
||||
@short structure for a Detector Packet or Image Header
|
||||
@li frameNumber is the frame number
|
||||
@li expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
@li packetNumber is the packet number
|
||||
@li bunchId is the bunch id from beamline
|
||||
@li timestamp is the time stamp with 10 MHz clock
|
||||
@li modId is the unique module id (unique even for left, right, top, bottom)
|
||||
@li xCoord is the x coordinate in the complete detector system
|
||||
@li yCoord is the y coordinate in the complete detector system
|
||||
@li zCoord is the z coordinate in the complete detector system
|
||||
@li debug is for debugging purposes
|
||||
@li roundRNumber is the round robin set number
|
||||
@li detType is the detector type see :: detectorType
|
||||
@li version is the version number of this structure format
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t frameNumber; /**< is the frame number */
|
||||
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
|
||||
uint32_t packetNumber; /**< is the packet number */
|
||||
uint64_t bunchId; /**< is the bunch id from beamline */
|
||||
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||
uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
|
||||
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||
uint32_t debug; /**< is for debugging purposes */
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
uint64_t packetCaught[8]; /**< is the version number of this structure format */
|
||||
|
||||
} sls_detector_header;
|
||||
|
||||
|
||||
|
||||
} sls_detector_header;
|
||||
|
||||
class moench04CtbReceiverData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int aSamples;
|
||||
const int dSamples;
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int aSamples;
|
||||
const int dSamples;
|
||||
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
moench04CtbReceiverData(int nas = 5000, int nds = 0)
|
||||
: slsDetectorData<uint16_t>(
|
||||
400, 400, nas * 2 * 32 + sizeof(sls_detector_header) + nds * 8),
|
||||
aSamples(nas), dSamples(nds) {
|
||||
|
||||
int nadc = 32;
|
||||
int sc_width = 25;
|
||||
int sc_height = 200;
|
||||
|
||||
int adc_nr[32] = {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 row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
int npackets = 40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
|
||||
for (int ip = 0; ip < npackets; ip++) {
|
||||
for (int is = 0; is < 128; is++) {
|
||||
|
||||
for (iadc = 0; iadc < nadc; iadc++) {
|
||||
i = 128 * ip + is;
|
||||
adc4 = (int)iadc / 4;
|
||||
if (i < sc_width * sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col = (adc_nr[iadc] % 16) * sc_width + (i % sc_width);
|
||||
// if (adc4%2==0) {
|
||||
if (iadc / 16 > 0) {
|
||||
row = 199 - i / sc_width;
|
||||
} else {
|
||||
row = 200 + i / sc_width;
|
||||
}
|
||||
dataMap[row][col] = sizeof(sls_detector_header) +
|
||||
(nadc * i + iadc) * 2; //+16*(ip+1);
|
||||
if (dataMap[row][col] < 0 ||
|
||||
dataMap[row][col] >=
|
||||
aSamples * 2 * 32 + sizeof(sls_detector_header))
|
||||
cout << "Error: pointer " << dataMap[row][col]
|
||||
<< " out of range " << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ipacket;
|
||||
int ibyte;
|
||||
int ii = 0;
|
||||
for (ibyte = 0; ibyte < sizeof(sls_detector_header) / 2; ibyte++) {
|
||||
xmap[ibyte] = -1;
|
||||
ymap[ibyte] = -1;
|
||||
}
|
||||
/* int off=sizeof(sls_detector_header)/2; */
|
||||
|
||||
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
|
||||
|
||||
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
|
||||
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
|
||||
/* i=ipacket*8208/2+ibyte; */
|
||||
/* isample=ii/nadc; */
|
||||
/* if (isample<nSamples) { */
|
||||
/* iadc=ii%nadc; */
|
||||
/* adc4 = (int)iadc/4; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (adc4%2==0) { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2+iy; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* ii++; */
|
||||
/* // } */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
iframe = 0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
return ((sls_detector_header *)buff)->frameNumber;
|
||||
}; //*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
public:
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff) {
|
||||
return ((sls_detector_header *)buff)->packetNumber;
|
||||
} //((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* /\** */
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all
|
||||
* packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in
|
||||
* case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be
|
||||
* incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
*/
|
||||
*/
|
||||
moench04CtbReceiverData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+sizeof(sls_detector_header)+nds*8), aSamples(nas), dSamples(nds) {
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int
|
||||
* dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
int nadc=32;
|
||||
int sc_width=25;
|
||||
int sc_height=200;
|
||||
|
||||
/* /\** */
|
||||
int adc_nr[32]={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 };
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all
|
||||
* packets 0 to nPackets, same frame number). Can be overloaded for
|
||||
* different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no
|
||||
* frame is found or last frame is incomplete */
|
||||
int row, col;
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
int npackets=40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
for (int ip=0; ip<npackets; ip++) {
|
||||
for (int is=0; is<128; is++) {
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np) {
|
||||
char *data = new char[dataSize];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
i=128*ip+is;
|
||||
adc4=(int)iadc/4;
|
||||
if (i<sc_width*sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=(adc_nr[iadc]%16)*sc_width+(i%sc_width);
|
||||
// if (adc4%2==0) {
|
||||
if (iadc/16>0) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
char *retval = 0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np = 0;
|
||||
int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff >= 0)
|
||||
fnum = ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
np = getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all
|
||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
||||
data pointer to the memory to be analyzed \param ndata reference to the
|
||||
amount of data found for the frame, in case the frame is incomplete at
|
||||
the end of the memory slot \param dsize size of the memory slot to be
|
||||
analyzed \returns pointer to the beginning of the last good frame (might
|
||||
be incomplete if ndata smaller than dataSize), or NULL if no frame is
|
||||
found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
if (dsize < dataSize)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = dataSize;
|
||||
return data;
|
||||
int ipacket;
|
||||
int ibyte;
|
||||
int ii=0;
|
||||
for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){
|
||||
xmap[ibyte]=-1;
|
||||
ymap[ibyte]=-1;
|
||||
}
|
||||
/* int off=sizeof(sls_detector_header)/2; */
|
||||
|
||||
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
|
||||
|
||||
|
||||
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
|
||||
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
|
||||
/* i=ipacket*8208/2+ibyte; */
|
||||
/* isample=ii/nadc; */
|
||||
/* if (isample<nSamples) { */
|
||||
/* iadc=ii%nadc; */
|
||||
/* adc4 = (int)iadc/4; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (adc4%2==0) { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2+iy; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* ii++; */
|
||||
/* // } */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
|
||||
|
||||
int getFrameNumber(char *buff){return ((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
char *retval=0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np=0;
|
||||
int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
ff=getFrameNumber(data);
|
||||
np=getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<dataSize) ndata=dsize;
|
||||
else ndata=dataSize;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
|
||||
// int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,276 +1,314 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOENCH04ZMQ10GBDATA_H
|
||||
#define MOENCH04ZMQ10GBDATA_H
|
||||
#define MOENCH04ZMQ10GBDATA_H
|
||||
#include "slsDetectorData.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int aSamples;
|
||||
const int dSamples;
|
||||
int off;
|
||||
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
// moench04CtbZmq10GbData(int nas=5000, int nds=0):
|
||||
// slsDetectorData<uint16_t>(400, 400, nas*2*32+nds*8), aSamples(nas),
|
||||
// dSamples(nds), nadc(32), sc_width(25), sc_height(200) {
|
||||
|
||||
moench04CtbZmq10GbData(int nas = 5000, int nds = 0)
|
||||
: slsDetectorData<uint16_t>(400, 400,
|
||||
#ifdef RAWDATA
|
||||
sizeof(slsDetectorDefs::sls_receiver_header) +
|
||||
#endif
|
||||
((nas > 0) && (nds > 0)
|
||||
? max(nas, nds) * (32 * 2 + 8)
|
||||
: nas * 32 * 2 + nds * 8)),
|
||||
nadc(32), sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) {
|
||||
#ifdef RAWDATA
|
||||
off=sizeof(slsDetectorDefs::sls_receiver_header);
|
||||
#endif
|
||||
#ifndef RAWDATA
|
||||
#ifndef CTB
|
||||
off=sizeof(int);
|
||||
#endif
|
||||
#ifdef CTB
|
||||
off=0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
cout << "off is " << off << endl;
|
||||
|
||||
if (off>0)
|
||||
cout << "M04 RAW DATA NEW " << endl;
|
||||
else
|
||||
cout << "M04 ZMQ DATA NEW " << endl;
|
||||
|
||||
int adc_nr[32] = {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 row, col;
|
||||
|
||||
// int isample;
|
||||
int iadc;
|
||||
// int ix, iy;
|
||||
|
||||
// int npackets=40;
|
||||
int i;
|
||||
// int adc4(0);
|
||||
|
||||
for (int is = 0; is < aSamples; is++) {
|
||||
|
||||
for (iadc = 0; iadc < nadc; iadc++) {
|
||||
i = is;
|
||||
// adc4=(int)iadc/4;
|
||||
if (i < sc_width * sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col = (adc_nr[iadc] % 16) * sc_width + (i % sc_width);
|
||||
// if (adc4%2==0) {
|
||||
if (iadc < 16) {
|
||||
row = 199 - i / sc_width;
|
||||
} else {
|
||||
row = 200 + i / sc_width;
|
||||
}
|
||||
if (nds > 0)
|
||||
dataMap[row][col] =
|
||||
((nadc + 4) * i + iadc) * 2 + off; //+16*(ip+1);
|
||||
else
|
||||
dataMap[row][col] =
|
||||
(nadc * i + iadc) * 2 + off; //+16*(ip+1);
|
||||
if (dataMap[row][col] < 0 ||
|
||||
dataMap[row][col] >= aSamples * 2 * 32 + off)
|
||||
cout << "Error: pointer " << dataMap[row][col]
|
||||
<< " out of range " << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int aSamples;
|
||||
const int dSamples;
|
||||
|
||||
|
||||
iframe = 0;
|
||||
// cout << "data struct created" << endl;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
int getGain(char *data, int x, int y) {
|
||||
// int aoff=aSamples*2*32;
|
||||
int irow;
|
||||
int isc = x / sc_width;
|
||||
int icol = x % sc_width;
|
||||
if (y < 200)
|
||||
irow = sc_height - 1 - y;
|
||||
else {
|
||||
irow = y - sc_height;
|
||||
isc++;
|
||||
}
|
||||
int ibit[32] = {-1, -1, -1, -1, -1, -1, 1, 3, 5, 7, -1,
|
||||
-1, -1, -1, -1, -1, 62, 60, 58, 56, 54, 52,
|
||||
50, 48, 63, 61, 59, 57, 55, 53, 51, 49};
|
||||
int isample = irow * sc_width + icol;
|
||||
|
||||
uint64_t sample;
|
||||
char *ptr;
|
||||
if (isc < 0 || isc >= 32)
|
||||
return 0;
|
||||
if (ibit[isc] < 0 || ibit[isc] >= 64)
|
||||
return 0;
|
||||
if (dSamples > isample) {
|
||||
ptr = data + 32 * (isample + 1) + 8 * isample;
|
||||
sample = *((uint64_t *)ptr);
|
||||
// cout << isc << " " << ibit[isc] << " " << isample << hex <<
|
||||
// sample << dec << endl;
|
||||
if (sample & (1 << ibit[isc]))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
//moench04CtbZmq10GbData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+nds*8), aSamples(nas), dSamples(nds), nadc(32), sc_width(25), sc_height(200) {
|
||||
moench04CtbZmq10GbData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, (nas > 0) && (nds>0) ? max(nas,nds)*(32*2+8) : nas*32*2+nds*8), nadc(32), sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) {
|
||||
|
||||
/* int ds; */
|
||||
/* if (nas && nds) */
|
||||
/* if (nds>nas) */
|
||||
/* ds=nds*(32*2+8); */
|
||||
/* else */
|
||||
/* ds=nas*(32*2+8); */
|
||||
/* else */
|
||||
/* ds=nas*32*2+nds*8; */
|
||||
|
||||
/* new slsDetectorData<uint16_t>(400, 400, ds); */
|
||||
|
||||
int adc_nr[32]={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 };
|
||||
|
||||
/*
|
||||
iadc=ptr%32
|
||||
isample=ptr/32
|
||||
|
||||
col=(adc_nr[iadc]%16)*25+isample%25
|
||||
if (adc_nr[iadc]<16)
|
||||
row=199-isample/25;
|
||||
else
|
||||
row=200+isample/25
|
||||
|
||||
|
||||
adc0 col(9*25..10*25-1) row(199..0)
|
||||
adc1 col(8*25..9*25-1) row(199..0)
|
||||
adc2 col(11*25..12*25-1) row(199..0)
|
||||
adc3 col(10*25..11*25-1) row(199..0)
|
||||
adc4 col(13*25..14*25-1) row(199..0)
|
||||
adc5 col(12*25..13*25-1) row(199..0)
|
||||
adc6 col(15*25..16*25-1) row(199..0)
|
||||
adc7 col(14*25..15*25-1) row(199..0)
|
||||
adc8 col(1*25..2*25-1) row(199..0)
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
int row, col;
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
#ifdef RAWDATA
|
||||
return ((slsDetectorDefs::sls_receiver_header *)buff)->detHeader.frameNumber;
|
||||
#endif
|
||||
return (int)(*buff);
|
||||
};
|
||||
//int isample;
|
||||
int iadc;
|
||||
// int ix, iy;
|
||||
|
||||
// int npackets=40;
|
||||
int i;
|
||||
//int adc4(0);
|
||||
|
||||
/**
|
||||
for (int is=0; is<aSamples; is++) {
|
||||
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
i=is;
|
||||
// adc4=(int)iadc/4;
|
||||
if (i<sc_width*sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=(adc_nr[iadc]%16)*sc_width+(i%sc_width);
|
||||
// if (adc4%2==0) {
|
||||
if (iadc<16) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
if (nds>0)
|
||||
dataMap[row][col]=((nadc+4)*i+iadc)*2;//+16*(ip+1);
|
||||
else
|
||||
dataMap[row][col]=(nadc*i+iadc)*2;//+16*(ip+1);
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
/* for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){ */
|
||||
/* xmap[ibyte]=-1; */
|
||||
/* ymap[ibyte]=-1; */
|
||||
/* } */
|
||||
/* int off=sizeof(sls_detector_header)/2; */
|
||||
|
||||
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
|
||||
|
||||
|
||||
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
|
||||
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
|
||||
/* i=ipacket*8208/2+ibyte; */
|
||||
/* isample=ii/nadc; */
|
||||
/* if (isample<nSamples) { */
|
||||
/* iadc=ii%nadc; */
|
||||
/* adc4 = (int)iadc/4; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (adc4%2==0) { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2+iy; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* ii++; */
|
||||
/* // } */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
}
|
||||
|
||||
int getGain(char *data, int x, int y) {
|
||||
// int aoff=aSamples*2*32;
|
||||
int irow;
|
||||
int isc=x/sc_width;
|
||||
int icol=x%sc_width;
|
||||
if (y<200) irow=sc_height-1-y;
|
||||
else {
|
||||
irow=y-sc_height;
|
||||
isc++;
|
||||
}
|
||||
int ibit[32]={-1,-1,-1,-1,-1,-1,1,3,5,7,-1,-1,-1,-1,-1,-1,62,60,58,56,54,52,50,48,63,61,59,57,55,53,51,49};
|
||||
int isample=irow*sc_width+icol;
|
||||
|
||||
uint64_t sample;
|
||||
char *ptr;
|
||||
if (isc<0 || isc>=32) return 0;
|
||||
if (ibit[isc]<0 || ibit[isc]>=64) return 0;
|
||||
if (dSamples>isample) {
|
||||
ptr=data+32*(isample+1)+8*isample;
|
||||
sample=*((uint64_t*)ptr);
|
||||
// cout << isc << " " << ibit[isc] << " " << isample << hex << sample << dec << endl;
|
||||
if (sample & (1<<ibit[isc]))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff) {
|
||||
#ifdef RAWDATA
|
||||
return ((slsDetectorDefs::sls_receiver_header *)buff)->detHeader.packetNumber;
|
||||
#endif
|
||||
return 0;
|
||||
int getFrameNumber(char *buff){return iframe;};//((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
|
||||
*/
|
||||
//int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
// char *retval=0;
|
||||
// int nd;
|
||||
// int fnum = -1;
|
||||
np=0;
|
||||
//int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff>=0)
|
||||
// fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
ff=getFrameNumber(data);
|
||||
// np=getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream & filebin) {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream & filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
/**
|
||||
|
||||
virtual char *readNextFrame(ifstream & filebin, int &ff, int &np) {
|
||||
char *data = new char[dataSize];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<dataSize) ndata=dsize;
|
||||
else ndata=dataSize;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream & filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
// char *retval=0;
|
||||
#ifndef RAWDATA
|
||||
|
||||
// int nd;
|
||||
// int fnum = -1;
|
||||
np = 0;
|
||||
// int pn;
|
||||
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff >= 0)
|
||||
// fnum=ff;
|
||||
};
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
// np=getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
#ifdef RAWDATA
|
||||
//int nd;
|
||||
int fnum = -1;
|
||||
np = 0;
|
||||
//int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff >= 0)
|
||||
fnum = ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
np = getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all
|
||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
||||
data pointer to the memory to be analyzed \param ndata reference to
|
||||
the amount of data found for the frame, in case the frame is
|
||||
incomplete at the end of the memory slot \param dsize size of the
|
||||
memory slot to be analyzed \returns pointer to the beginning of the
|
||||
last good frame (might be incomplete if ndata smaller than dataSize),
|
||||
or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
if (dsize < dataSize)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = dataSize;
|
||||
return data;
|
||||
}
|
||||
// int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,279 +1,278 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOENCH04ZMQDATA_H
|
||||
#define MOENCH04ZMQDATA_H
|
||||
#define MOENCH04ZMQDATA_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class moench04CtbZmqData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int aSamples;
|
||||
const int dSamples;
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int aSamples;
|
||||
const int dSamples;
|
||||
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
public:
|
||||
|
||||
*/
|
||||
moench04CtbZmqData(int nas = 5000, int nds = 0)
|
||||
: slsDetectorData<uint16_t>(400, 400, nas * 2 * 32 + nds * 8), nadc(32),
|
||||
sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) {
|
||||
|
||||
int adc_nr[32] = {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 row, col;
|
||||
|
||||
// int isample;
|
||||
int iadc;
|
||||
// int ix, iy;
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
// int npackets=40;
|
||||
int i;
|
||||
// int adc4(0);
|
||||
*/
|
||||
moench04CtbZmqData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+nds*8), nadc(32), sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) {
|
||||
|
||||
|
||||
for (int is = 0; is < aSamples; is++) {
|
||||
int adc_nr[32]={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 };
|
||||
|
||||
for (iadc = 0; iadc < nadc; iadc++) {
|
||||
i = is;
|
||||
// adc4=(int)iadc/4;
|
||||
if (i < sc_width * sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col = (adc_nr[iadc] % 16) * sc_width + (i % sc_width);
|
||||
// if (adc4%2==0) {
|
||||
if (iadc < 16) {
|
||||
row = 199 - i / sc_width;
|
||||
} else {
|
||||
row = 200 + i / sc_width;
|
||||
}
|
||||
dataMap[row][col] = (nadc * i + iadc) * 2; //+16*(ip+1);
|
||||
if (dataMap[row][col] < 0 ||
|
||||
dataMap[row][col] >= aSamples * 2 * 32)
|
||||
cout << "Error: pointer " << dataMap[row][col]
|
||||
<< " out of range " << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
int row, col;
|
||||
|
||||
/* for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){ */
|
||||
/* xmap[ibyte]=-1; */
|
||||
/* ymap[ibyte]=-1; */
|
||||
/* } */
|
||||
/* int off=sizeof(sls_detector_header)/2; */
|
||||
//int isample;
|
||||
int iadc;
|
||||
//int ix, iy;
|
||||
|
||||
// int npackets=40;
|
||||
int i;
|
||||
//int adc4(0);
|
||||
|
||||
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
|
||||
for (int is=0; is<aSamples; is++) {
|
||||
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
i=is;
|
||||
// adc4=(int)iadc/4;
|
||||
if (i<sc_width*sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=(adc_nr[iadc]%16)*sc_width+(i%sc_width);
|
||||
// if (adc4%2==0) {
|
||||
if (iadc<16) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
dataMap[row][col]=(nadc*i+iadc)*2;//+16*(ip+1);
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
|
||||
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
|
||||
/* i=ipacket*8208/2+ibyte; */
|
||||
/* isample=ii/nadc; */
|
||||
/* if (isample<nSamples) { */
|
||||
/* iadc=ii%nadc; */
|
||||
/* adc4 = (int)iadc/4; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (adc4%2==0) { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2+iy; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* ii++; */
|
||||
/* // } */
|
||||
/* } */
|
||||
/* } */
|
||||
/* for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){ */
|
||||
/* xmap[ibyte]=-1; */
|
||||
/* ymap[ibyte]=-1; */
|
||||
/* } */
|
||||
/* int off=sizeof(sls_detector_header)/2; */
|
||||
|
||||
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
|
||||
|
||||
iframe = 0;
|
||||
// cout << "data struct created" << endl;
|
||||
|
||||
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
|
||||
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
|
||||
/* i=ipacket*8208/2+ibyte; */
|
||||
/* isample=ii/nadc; */
|
||||
/* if (isample<nSamples) { */
|
||||
/* iadc=ii%nadc; */
|
||||
/* adc4 = (int)iadc/4; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (adc4%2==0) { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2+iy; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* ii++; */
|
||||
/* // } */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
}
|
||||
|
||||
int getGain(char *data, int x, int y) {
|
||||
int aoff=aSamples*2*32;
|
||||
int irow;
|
||||
int isc=x/sc_width;
|
||||
int icol=x%sc_width;
|
||||
if (y<200) irow=sc_height-1-y;
|
||||
else {
|
||||
irow=y-sc_height;
|
||||
isc++;
|
||||
}
|
||||
int ibit[32]={-1,-1,-1,-1,-1,-1,1,3,5,7,-1,-1,-1,-1,-1,-1,62,60,58,56,54,52,50,48,63,61,59,57,55,53,51,49};
|
||||
int isample=irow*sc_width+icol;
|
||||
|
||||
uint64_t sample;
|
||||
char *ptr;
|
||||
if (isc<0 || isc>=32) return 0;
|
||||
if (ibit[isc]<0 || ibit[isc]>=64) return 0;
|
||||
if (dSamples>isample) {
|
||||
ptr=data+aoff+8*isample;
|
||||
sample=*((uint64_t*)ptr);
|
||||
// cout << isc << " " << ibit[isc] << " " << isample << hex << sample << dec << endl;
|
||||
if (sample & (1<<ibit[isc]))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getGain(char *data, int x, int y) {
|
||||
int aoff = aSamples * 2 * 32;
|
||||
int irow;
|
||||
int isc = x / sc_width;
|
||||
int icol = x % sc_width;
|
||||
if (y < 200)
|
||||
irow = sc_height - 1 - y;
|
||||
else {
|
||||
irow = y - sc_height;
|
||||
isc++;
|
||||
}
|
||||
int ibit[32] = {-1, -1, -1, -1, -1, -1, 1, 3, 5, 7, -1,
|
||||
-1, -1, -1, -1, -1, 62, 60, 58, 56, 54, 52,
|
||||
50, 48, 63, 61, 59, 57, 55, 53, 51, 49};
|
||||
int isample = irow * sc_width + icol;
|
||||
/**
|
||||
|
||||
uint64_t sample;
|
||||
char *ptr;
|
||||
if (isc < 0 || isc >= 32)
|
||||
return 0;
|
||||
if (ibit[isc] < 0 || ibit[isc] >= 64)
|
||||
return 0;
|
||||
if (dSamples > isample) {
|
||||
ptr = data + aoff + 8 * isample;
|
||||
sample = *((uint64_t *)ptr);
|
||||
// cout << isc << " " << ibit[isc] << " " << isample << hex <<
|
||||
// sample << dec << endl;
|
||||
if (sample & (1 << ibit[isc]))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
return iframe;
|
||||
}; //((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
|
||||
|
||||
*/
|
||||
// int getPacketNumber(char *buff){return
|
||||
// ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
int getFrameNumber(char *buff){return iframe;};//((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/* /\** */
|
||||
/**
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all
|
||||
* packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in
|
||||
* case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be
|
||||
* incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
*/
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int
|
||||
* dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all
|
||||
* packets 0 to nPackets, same frame number). Can be overloaded for
|
||||
* different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no
|
||||
* frame is found or last frame is incomplete */
|
||||
*/
|
||||
//int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
/* /\** */
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np) {
|
||||
char *data = new char[dataSize];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
// char *retval=0;
|
||||
// int nd;
|
||||
// int fnum = -1;
|
||||
np = 0;
|
||||
// int pn;
|
||||
/* /\** */
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff >= 0)
|
||||
// fnum=ff;
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
// np=getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all
|
||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
||||
data pointer to the memory to be analyzed \param ndata reference to the
|
||||
amount of data found for the frame, in case the frame is incomplete at
|
||||
the end of the memory slot \param dsize size of the memory slot to be
|
||||
analyzed \returns pointer to the beginning of the last good frame (might
|
||||
be incomplete if ndata smaller than dataSize), or NULL if no frame is
|
||||
found
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
if (dsize < dataSize)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = dataSize;
|
||||
return data;
|
||||
}
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
// char *retval=0;
|
||||
//int nd;
|
||||
//int fnum = -1;
|
||||
np=0;
|
||||
//int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff>=0)
|
||||
// fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
ff=getFrameNumber(data);
|
||||
// np=getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<dataSize) ndata=dsize;
|
||||
else ndata=dataSize;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
|
||||
// int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,216 +0,0 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef MOENCHDATA_H
|
||||
#define MOENCHDATA_H
|
||||
#include "slsDetectorData.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
using namespace std;
|
||||
class moenchData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int aSamples;
|
||||
const int dSamples;
|
||||
int off;
|
||||
int *adc_nr;
|
||||
int *ibit;
|
||||
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
|
||||
|
||||
moenchData(int off, int nadc_i, int *adc_nr_in, int *ibit_in, int nas = 5000, int nds = 0, int nx_i=400, int ny_i=400)
|
||||
: nadc(nadc_i), slsDetectorData<uint16_t>(nx_i, ny_i,off+((nas > 0) && (nds > 0)
|
||||
? max(nas, nds) * (nadc_i * 2 + 8)
|
||||
: nas * nadc_i * 2 + nds * 8)),
|
||||
sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) {
|
||||
|
||||
|
||||
adc_nr=new int[nadc];
|
||||
if (ibit_in)
|
||||
ibit=new int[nadc];
|
||||
else
|
||||
ibit=NULL;
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
adc_nr[iadc]=adc_nr_in[iadc];
|
||||
if (ibit)
|
||||
ibit[iadc]=ibit_in[iadc];
|
||||
}
|
||||
|
||||
|
||||
|
||||
int row, col;
|
||||
int iadc;
|
||||
int i;
|
||||
|
||||
for (int is = 0; is < aSamples; is++) {
|
||||
|
||||
for (iadc = 0; iadc < nadc; iadc++) {
|
||||
i = is;
|
||||
// adc4=(int)iadc/4;
|
||||
if (i < sc_width * sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col = (adc_nr[iadc] % 16) * sc_width + (i % sc_width);
|
||||
// if (adc4%2==0) {
|
||||
if (iadc < 16) {
|
||||
row = 199 - i / sc_width;
|
||||
} else {
|
||||
row = 200 + i / sc_width;
|
||||
}
|
||||
if (nds > 0)
|
||||
dataMap[row][col] =
|
||||
((nadc + 4) * i + iadc) * 2 + off; //+16*(ip+1);
|
||||
else
|
||||
dataMap[row][col] =
|
||||
(nadc * i + iadc) * 2 + off; //+16*(ip+1);
|
||||
if (dataMap[row][col] < 0 ||
|
||||
dataMap[row][col] >= aSamples * 2 * 32 + off)
|
||||
cout << "Error: pointer " << dataMap[row][col]
|
||||
<< " out of range " << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
iframe = 0;
|
||||
}
|
||||
|
||||
|
||||
virtual int getGain(char *data, int x, int y) {
|
||||
// int aoff=aSamples*2*32;
|
||||
|
||||
if (ibit) {
|
||||
int irow;
|
||||
int isc = x / sc_width;
|
||||
int icol = x % sc_width;
|
||||
if (y < 200)
|
||||
irow = sc_height - 1 - y;
|
||||
else {
|
||||
irow = y - sc_height;
|
||||
isc++;
|
||||
}
|
||||
int isample = irow * sc_width + icol;
|
||||
|
||||
uint64_t sample;
|
||||
char *ptr;
|
||||
if (isc < 0 || isc >= 32)
|
||||
return 0;
|
||||
if (ibit[isc] < 0 || ibit[isc] >= 64)
|
||||
return 0;
|
||||
if (dSamples > isample) {
|
||||
ptr = data + 32 * (isample + 1) + 8 * isample;
|
||||
sample = *((uint64_t *)ptr);
|
||||
if (sample & (1 << ibit[isc]))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
return (int* buff)[0];
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff) {
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream & filebin) {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream & filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream & filebin, int &ff, int &np) {
|
||||
char *data = new char[dataSize];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream & filebin, int &ff, int &np,
|
||||
char *data) {
|
||||
|
||||
char *retval = 0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np = 0;
|
||||
int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
//if (ff >= 0)
|
||||
// fnum = ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
np = getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all
|
||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
||||
data pointer to the memory to be analyzed \param ndata reference to
|
||||
the amount of data found for the frame, in case the frame is
|
||||
incomplete at the end of the memory slot \param dsize size of the
|
||||
memory slot to be analyzed \returns pointer to the beginning of the
|
||||
last good frame (might be incomplete if ndata smaller than dataSize),
|
||||
or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
if (dsize < dataSize)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = dataSize;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -3,345 +3,346 @@
|
||||
#ifndef SLSDETECTORDATA_H
|
||||
#define SLSDETECTORDATA_H
|
||||
|
||||
#include <fstream>
|
||||
#include <inttypes.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
template <class dataType> class slsDetectorData {
|
||||
using namespace std;
|
||||
|
||||
protected:
|
||||
const int nx; /**< Number of pixels in the x direction */
|
||||
const int ny; /**< Number of pixels in the y direction */
|
||||
int dataSize; /**<size of the data constituting one frame */
|
||||
int **dataMap; /**< Array of size nx*ny storing the pointers to the data in
|
||||
the dataset (as offset)*/
|
||||
dataType **dataMask; /**< Array of size nx*ny storing the polarity of the
|
||||
data in the dataset (should be 0 if no inversion is
|
||||
required, 0xffffffff is inversion is required) */
|
||||
int **dataROIMask; /**< Array of size nx*ny 1 if channel is good (or in the
|
||||
ROI), 0 if bad channel (or out of ROI) */
|
||||
int *xmap;
|
||||
int *ymap;
|
||||
dataType **orderedData;
|
||||
int isOrdered;
|
||||
|
||||
public:
|
||||
/**
|
||||
General slsDetectors data structure. Works for data acquired using the
|
||||
slsDetectorReceiver. Can be generalized to other detectors (many virtual
|
||||
funcs).
|
||||
template <class dataType>
|
||||
class slsDetectorData {
|
||||
|
||||
Constructor (no error checking if datasize and offsets are compatible!)
|
||||
\param npx number of pixels in the x direction
|
||||
\param npy number of pixels in the y direction (1 for strips)
|
||||
\param dsize size of the data
|
||||
\param dMap array of size nx*ny storing the pointers to the data in the
|
||||
dataset (as offset) \param dMask Array of size nx*ny storing the polarity of
|
||||
the data in the dataset (should be 0 if no inversion is required, 0xffffffff
|
||||
is inversion is required) \param dROI Array of size nx*ny. The elements are
|
||||
1s if the channel is good or in the ROI, 0 is bad or out of the ROI. NULL
|
||||
(default) means all 1s.
|
||||
*/
|
||||
slsDetectorData(int npx, int npy, int dsize, int **dMap = NULL,
|
||||
dataType **dMask = NULL, int **dROI = NULL);
|
||||
protected:
|
||||
const int nx; /**< Number of pixels in the x direction */
|
||||
const int ny; /**< Number of pixels in the y direction */
|
||||
int dataSize; /**<size of the data constituting one frame */
|
||||
int **dataMap; /**< Array of size nx*ny storing the pointers to the data in the dataset (as offset)*/
|
||||
dataType **dataMask; /**< Array of size nx*ny storing the polarity of the data in the dataset (should be 0 if no inversion is required, 0xffffffff is inversion is required) */
|
||||
int **dataROIMask; /**< Array of size nx*ny 1 if channel is good (or in the ROI), 0 if bad channel (or out of ROI) */
|
||||
int *xmap;
|
||||
int *ymap;
|
||||
dataType **orderedData;
|
||||
int isOrdered;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
||||
|
||||
General slsDetectors data structure. Works for data acquired using the slsDetectorReceiver. Can be generalized to other detectors (many virtual funcs).
|
||||
|
||||
virtual ~slsDetectorData();
|
||||
|
||||
// Virtual functions
|
||||
virtual int getPointer(int ix, int iy) { return dataMap[iy][ix]; };
|
||||
virtual void getPixel(int ip, int &x, int &y);
|
||||
virtual dataType **getData(char *ptr, int dsize = -1);
|
||||
virtual double **getImage(char *ptr, int dsize = -1);
|
||||
virtual dataType getChannel(char *data, int ix, int iy = 0);
|
||||
virtual int getGain(char *data, int ix, int iy = 0) { return 0; };
|
||||
virtual double getValue(char *data, int ix, int iy = 0) {
|
||||
return (double)getChannel(data, ix, iy);
|
||||
};
|
||||
|
||||
virtual int getFrameNumber(char *buff) = 0;
|
||||
Constructor (no error checking if datasize and offsets are compatible!)
|
||||
\param npx number of pixels in the x direction
|
||||
\param npy number of pixels in the y direction (1 for strips)
|
||||
\param dsize size of the data
|
||||
\param dMap array of size nx*ny storing the pointers to the data in the dataset (as offset)
|
||||
\param dMask Array of size nx*ny storing the polarity of the data in the dataset (should be 0 if no inversion is required, 0xffffffff is inversion is required)
|
||||
\param dROI Array of size nx*ny. The elements are 1s if the channel is good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
|
||||
|
||||
*/
|
||||
slsDetectorData(int npx, int npy, int dsize, int **dMap=NULL, dataType **dMask=NULL, int **dROI=NULL): nx(npx), ny(npy), dataSize(dsize), orderedData(NULL), isOrdered(0) {
|
||||
|
||||
int el=dsize/sizeof(dataType);
|
||||
xmap=new int[el];
|
||||
ymap=new int[el];
|
||||
|
||||
/**
|
||||
Loops over a memory slot until a complete frame is found (i.e. all
|
||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
||||
data pointer to the memory to be analyzed \param ndata reference to the
|
||||
amount of data found for the frame, in case the frame is incomplete at
|
||||
the end of the memory slot \param dsize size of the memory slot to be
|
||||
analyzed \returns pointer to the beginning of the last good frame (might
|
||||
be incomplete if ndata smaller than dataSize), or NULL if no frame is
|
||||
found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) = 0;
|
||||
|
||||
//Returns a pointer to the next complete frame, if none found nullptr
|
||||
//data needs to be deallocated by caller
|
||||
virtual char *readNextFrame(std::ifstream &filebin) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//END Virtual functions
|
||||
|
||||
/**
|
||||
defines the data map (as offset) - no error checking if datasize and
|
||||
offsets are compatible! \param dMap array of size nx*ny storing the
|
||||
pointers to the data in the dataset (as offset). If NULL (default),the
|
||||
data are arranged as if read out row by row
|
||||
(dataMap[iy][ix]=(iy*nx+ix)*sizeof(dataType);)
|
||||
*/
|
||||
void setDataMap(int **dMap = NULL);
|
||||
|
||||
/**
|
||||
defines the data mask i.e. the polarity of the data
|
||||
\param dMask Array of size nx*ny storing the polarity of the data in the
|
||||
dataset (should be 0 if no inversion is required, 0xffffffff is inversion
|
||||
is required)
|
||||
|
||||
*/
|
||||
void setDataMask(dataType **dMask = NULL);
|
||||
/**
|
||||
defines the region of interest and/or the bad channels mask
|
||||
\param dROI Array of size nx*ny. The ements are 1s if the channel is
|
||||
good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all
|
||||
1s.
|
||||
|
||||
*/
|
||||
void setDataROIMask(int **dROI = NULL);
|
||||
|
||||
/**
|
||||
Define bad channel or roi mask for a single channel
|
||||
\param ix channel x coordinate
|
||||
\param iy channel y coordinate (1 for strips)
|
||||
\param i 1 if pixel is good (or in the roi), 0 if bad
|
||||
\returns 1 if pixel is good, 0 if it's bad, -1 if pixel is out of range
|
||||
*/
|
||||
int setGood(int ix, int iy, int i = 1);
|
||||
|
||||
// returns 1 if pixel is good, 0 if it's bad, -1 if pixel is out of range
|
||||
int isGood(int ix, int iy);
|
||||
|
||||
// returns total number of channels, outparam npx and npy x,y dimensions
|
||||
int getDetectorSize(int &npx, int &npy);
|
||||
|
||||
/** Returns the size of the data frame */
|
||||
int getDataSize() { return dataSize; };
|
||||
|
||||
/** changes the size of the data frame */
|
||||
int setDataSize(int d) {
|
||||
dataSize = d;
|
||||
return dataSize;
|
||||
};
|
||||
|
||||
void newFrame() { isOrdered = 0; };
|
||||
|
||||
/**
|
||||
Returns the value of the selected channel for the given dataset. Virtual
|
||||
function, can be overloaded. \param data pointer to the dataset
|
||||
(including headers etc) \param ix pixel number in the x direction \param
|
||||
iy pixel number in the y direction \returns data for the selected
|
||||
channel, with inversion if required
|
||||
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
template <typename dataType>
|
||||
slsDetectorData<dataType>::slsDetectorData(int npx, int npy, int dsize,
|
||||
int **dMap, dataType **dMask,
|
||||
int **dROI)
|
||||
: nx(npx), ny(npy), dataSize(dsize), orderedData(NULL), isOrdered(0) {
|
||||
|
||||
int el = dsize / sizeof(dataType);
|
||||
xmap = new int[el];
|
||||
ymap = new int[el];
|
||||
|
||||
orderedData = new dataType *[ny];
|
||||
dataMap = new int *[ny];
|
||||
dataMask = new dataType *[ny];
|
||||
dataROIMask = new int *[ny];
|
||||
for (int i = 0; i < ny; i++) {
|
||||
dataMap[i] = new int[nx];
|
||||
orderedData[i] = new dataType[nx];
|
||||
dataMask[i] = new dataType[nx];
|
||||
dataROIMask[i] = new int[nx];
|
||||
for (int j = 0; j < nx; j++)
|
||||
dataROIMask[i][j] = 1;
|
||||
}
|
||||
|
||||
for (int ip = 0; ip < el; ip++) {
|
||||
xmap[ip] = -1;
|
||||
ymap[ip] = -1;
|
||||
}
|
||||
|
||||
|
||||
orderedData=new dataType*[ny];
|
||||
dataMap=new int*[ny];
|
||||
dataMask=new dataType*[ny];
|
||||
dataROIMask=new int*[ny];
|
||||
for(int i = 0; i < ny; i++) {
|
||||
dataMap[i] = new int[nx];
|
||||
orderedData[i]=new dataType[nx];
|
||||
dataMask[i] = new dataType[nx];
|
||||
dataROIMask[i] = new int[nx];
|
||||
for (int j=0; j<nx; j++)
|
||||
dataROIMask[i][j]=1;
|
||||
|
||||
}
|
||||
|
||||
for (int ip=0; ip<el; ip++){
|
||||
xmap[ip]=-1;
|
||||
ymap[ip]=-1;
|
||||
}
|
||||
|
||||
setDataMap(dMap);
|
||||
setDataMask(dMask);
|
||||
setDataROIMask(dROI);
|
||||
}
|
||||
|
||||
template <typename dataType> slsDetectorData<dataType>::~slsDetectorData() {
|
||||
for (int i = 0; i < ny; i++) {
|
||||
delete[] dataMap[i];
|
||||
delete[] dataMask[i];
|
||||
delete[] dataROIMask[i];
|
||||
delete[] orderedData[i];
|
||||
|
||||
}
|
||||
|
||||
virtual ~slsDetectorData() {
|
||||
for(int i = 0; i < ny; i++) {
|
||||
delete [] dataMap[i];
|
||||
delete [] dataMask[i];
|
||||
delete [] dataROIMask[i];
|
||||
delete [] orderedData[i];
|
||||
}
|
||||
delete[] dataMap;
|
||||
delete[] dataMask;
|
||||
delete[] dataROIMask;
|
||||
delete[] orderedData;
|
||||
delete[] xmap;
|
||||
delete[] ymap;
|
||||
}
|
||||
|
||||
template <typename dataType>
|
||||
void slsDetectorData<dataType>::setDataMap(int **dMap) {
|
||||
|
||||
int ip = 0;
|
||||
delete [] dataMap;
|
||||
delete [] dataMask;
|
||||
delete [] dataROIMask;
|
||||
delete [] orderedData;
|
||||
delete [] xmap;
|
||||
delete [] ymap;
|
||||
};
|
||||
|
||||
virtual int getPointer(int ix,int iy) {return dataMap[iy][ix];};
|
||||
/**
|
||||
defines the data map (as offset) - no error checking if datasize and offsets are compatible!
|
||||
\param dMap array of size nx*ny storing the pointers to the data in the dataset (as offset). If NULL (default),the data are arranged as if read out row by row (dataMap[iy][ix]=(iy*nx+ix)*sizeof(dataType);)
|
||||
*/
|
||||
void setDataMap(int **dMap=NULL) {
|
||||
|
||||
int ip=0;
|
||||
int ix, iy;
|
||||
if (dMap == NULL) {
|
||||
for (iy = 0; iy < ny; iy++) {
|
||||
for (ix = 0; ix < nx; ix++) {
|
||||
dataMap[iy][ix] = (iy * nx + ix) * sizeof(dataType);
|
||||
}
|
||||
}
|
||||
if (dMap==NULL) {
|
||||
for (iy=0; iy<ny; iy++) {
|
||||
for (ix=0; ix<nx; ix++) {
|
||||
dataMap[iy][ix]=(iy*nx+ix)*sizeof(dataType);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// cout << "set dmap "<< dataMap << " " << dMap << endl;
|
||||
for (iy = 0; iy < ny; iy++) {
|
||||
// cout << iy << endl;
|
||||
for (ix = 0; ix < nx; ix++) {
|
||||
dataMap[iy][ix] = dMap[iy][ix];
|
||||
// cout << ix << " " << iy << endl;
|
||||
/*ip=dataMap[ix][iy]/sizeof(dataType);
|
||||
xmap[ip]=ix;
|
||||
ymap[ip]=iy;Annaa*/
|
||||
}
|
||||
}
|
||||
//cout << "set dmap "<< dataMap << " " << dMap << endl;
|
||||
for (iy=0; iy<ny; iy++){
|
||||
// cout << iy << endl;
|
||||
for (ix=0; ix<nx; ix++) {
|
||||
dataMap[iy][ix]=dMap[iy][ix];
|
||||
// cout << ix << " " << iy << endl;
|
||||
/*ip=dataMap[ix][iy]/sizeof(dataType);
|
||||
xmap[ip]=ix;
|
||||
ymap[ip]=iy;Annaa*/
|
||||
}
|
||||
}
|
||||
}
|
||||
for (iy = 0; iy < ny; iy++) {
|
||||
for (ix = 0; ix < nx; ix++) {
|
||||
ip = dataMap[iy][ix] / sizeof(dataType);
|
||||
xmap[ip] = ix;
|
||||
ymap[ip] = iy;
|
||||
}
|
||||
for (iy=0; iy<ny; iy++){
|
||||
for (ix=0; ix<nx; ix++) {
|
||||
ip=dataMap[iy][ix]/sizeof(dataType);
|
||||
xmap[ip]=ix;
|
||||
ymap[ip]=iy;
|
||||
}
|
||||
}
|
||||
|
||||
// cout << "nx:" <<nx << " ny:" << ny << endl;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// cout << "nx:" <<nx << " ny:" << ny << endl;
|
||||
}
|
||||
/**
|
||||
defines the data mask i.e. the polarity of the data
|
||||
\param dMask Array of size nx*ny storing the polarity of the data in the dataset (should be 0 if no inversion is required, 0xffffffff is inversion is required)
|
||||
|
||||
template <typename dataType>
|
||||
void slsDetectorData<dataType>::setDataMask(dataType **dMask) {
|
||||
|
||||
if (dMask != NULL) {
|
||||
|
||||
for (int iy = 0; iy < ny; iy++)
|
||||
for (int ix = 0; ix < nx; ix++)
|
||||
dataMask[iy][ix] = dMask[iy][ix];
|
||||
*/
|
||||
void setDataMask(dataType **dMask=NULL){
|
||||
|
||||
if (dMask!=NULL) {
|
||||
|
||||
for (int iy=0; iy<ny; iy++)
|
||||
for (int ix=0; ix<nx; ix++)
|
||||
dataMask[iy][ix]=dMask[iy][ix];
|
||||
} else {
|
||||
for (int iy = 0; iy < ny; iy++)
|
||||
for (int ix = 0; ix < nx; ix++)
|
||||
dataMask[iy][ix] = 0;
|
||||
for (int iy=0; iy<ny; iy++)
|
||||
for (int ix=0; ix<nx; ix++)
|
||||
dataMask[iy][ix]=0;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename dataType>
|
||||
void slsDetectorData<dataType>::setDataROIMask(int **dROI) {
|
||||
if (dROI != NULL) {
|
||||
|
||||
for (int iy = 0; iy < ny; iy++)
|
||||
for (int ix = 0; ix < nx; ix++)
|
||||
dataROIMask[iy][ix] = dROI[iy][ix];
|
||||
};
|
||||
/**
|
||||
defines the region of interest and/or the bad channels mask
|
||||
\param dROI Array of size nx*ny. The lements are 1s if the channel is good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
|
||||
|
||||
*/
|
||||
void setDataROIMask(int **dROI=NULL){
|
||||
|
||||
if (dROI!=NULL) {
|
||||
|
||||
for (int iy=0; iy<ny; iy++)
|
||||
for (int ix=0; ix<nx; ix++)
|
||||
dataROIMask[iy][ix]=dROI[iy][ix];
|
||||
} else {
|
||||
|
||||
for (int iy = 0; iy < ny; iy++)
|
||||
for (int ix = 0; ix < nx; ix++)
|
||||
dataROIMask[iy][ix] = 1;
|
||||
|
||||
for (int iy=0; iy<ny; iy++)
|
||||
for (int ix=0; ix<nx; ix++)
|
||||
dataROIMask[iy][ix]=1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
Define bad channel or roi mask for a single channel
|
||||
\param ix channel x coordinate
|
||||
\param iy channel y coordinate (1 for strips)
|
||||
\param i 1 if pixel is good (or in the roi), 0 if bad
|
||||
\returns 1 if pixel is good, 0 if it's bad, -1 if pixel is out of range
|
||||
*/
|
||||
int setGood(int ix, int iy, int i=1) { if (ix>=0 && ix<nx && iy>=0 && iy<ny) dataROIMask[iy][ix]=i; return isGood(ix,iy);};
|
||||
/**
|
||||
Define bad channel or roi mask for a single channel
|
||||
\param ix channel x coordinate
|
||||
\param iy channel y coordinate (1 for strips)
|
||||
\returns 1 if pixel is good, 0 if it's bad, -1 if pixel is out of range
|
||||
*/
|
||||
int isGood(int ix, int iy) { if (ix>=0 && ix<nx && iy>=0 && iy<ny) return dataROIMask[iy][ix]; else return -1;};
|
||||
|
||||
/**
|
||||
Returns detector size in x,y
|
||||
\param npx reference to number of channels in x
|
||||
\param npy reference to number of channels in y (will be 1 for strips)
|
||||
\returns total number of channels
|
||||
*/
|
||||
int getDetectorSize(int &npx, int &npy){npx=nx; npy=ny; return nx*ny;};
|
||||
|
||||
/** Returns the size of the data frame */
|
||||
int getDataSize() {return dataSize;};
|
||||
|
||||
/** changes the size of the data frame */
|
||||
int setDataSize(int d) {dataSize=d; return dataSize;};
|
||||
|
||||
template <typename dataType>
|
||||
int slsDetectorData<dataType>::setGood(int ix, int iy, int i) {
|
||||
if (ix >= 0 && ix < nx && iy >= 0 && iy < ny)
|
||||
dataROIMask[iy][ix] = i;
|
||||
return isGood(ix, iy);
|
||||
}
|
||||
|
||||
virtual void getPixel(int ip, int &x, int &y) {x=xmap[ip]; y=ymap[ip];};
|
||||
|
||||
virtual dataType **getData(char *ptr, int dsize=-1) {
|
||||
int el=dsize/sizeof(dataType);
|
||||
//dataType **data;
|
||||
int ix,iy;
|
||||
//data=new dataType*[ny];
|
||||
//for(int i = 0; i < ny; i++) {
|
||||
// data[i]=new dataType[nx];
|
||||
//}
|
||||
isOrdered=0;
|
||||
if (dsize<=0 || dsize>dataSize) dsize=dataSize;
|
||||
|
||||
template <typename dataType>
|
||||
int slsDetectorData<dataType>::isGood(int ix, int iy) {
|
||||
if (ix >= 0 && ix < nx && iy >= 0 && iy < ny)
|
||||
return dataROIMask[iy][ix];
|
||||
else
|
||||
return -1;
|
||||
};
|
||||
|
||||
template <typename dataType>
|
||||
int slsDetectorData<dataType>::getDetectorSize(int &npx, int &npy) {
|
||||
npx = nx;
|
||||
npy = ny;
|
||||
return nx * ny;
|
||||
}
|
||||
|
||||
template <typename dataType>
|
||||
void slsDetectorData<dataType>::getPixel(int ip, int &x, int &y) {
|
||||
x = xmap[ip];
|
||||
y = ymap[ip];
|
||||
}
|
||||
|
||||
template <typename dataType>
|
||||
dataType **slsDetectorData<dataType>::getData(char *ptr, int dsize) {
|
||||
int el = dsize / sizeof(dataType);
|
||||
// dataType **data;
|
||||
int ix, iy;
|
||||
// data=new dataType*[ny];
|
||||
// for(int i = 0; i < ny; i++) {
|
||||
// data[i]=new dataType[nx];
|
||||
// }
|
||||
isOrdered = 0;
|
||||
if (dsize <= 0 || dsize > dataSize)
|
||||
dsize = dataSize;
|
||||
|
||||
for (int ip = 0; ip < (el); ip++) {
|
||||
getPixel(ip, ix, iy);
|
||||
if (ix >= 0 && ix < nx && iy >= 0 && iy < ny) {
|
||||
// data[iy][ix]=getChannel(ptr,ix,iy);
|
||||
orderedData[iy][ix] = *(ptr + ip); // getChannel(ptr,ix,iy);
|
||||
}
|
||||
for (int ip=0; ip<(el); ip++) {
|
||||
getPixel(ip,ix,iy);
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
|
||||
//data[iy][ix]=getChannel(ptr,ix,iy);
|
||||
orderedData[iy][ix]=*(ptr+ip);//getChannel(ptr,ix,iy);
|
||||
}
|
||||
}
|
||||
isOrdered = 1;
|
||||
isOrdered=1;
|
||||
return orderedData;
|
||||
}
|
||||
|
||||
template <typename dataType>
|
||||
double **slsDetectorData<dataType>::getImage(char *ptr, int dsize) {
|
||||
void newFrame(){isOrdered=0;};
|
||||
|
||||
virtual double **getImage(char *ptr, int dsize=-1) {
|
||||
|
||||
double **data;
|
||||
int ix, iy;
|
||||
data = new double *[ny];
|
||||
for (int i = 0; i < ny; i++) {
|
||||
data[i] = new double[nx];
|
||||
int ix,iy;
|
||||
data=new double*[ny];
|
||||
for(int i = 0; i < ny; i++) {
|
||||
data[i]=new double[nx];
|
||||
}
|
||||
int el = dsize / sizeof(dataType);
|
||||
if (dsize <= 0 || dsize > dataSize)
|
||||
dsize = dataSize;
|
||||
for (int ip = 0; ip < el; ip++) {
|
||||
getPixel(ip, ix, iy);
|
||||
if (ix >= 0 && ix < nx && iy >= 0 && iy < ny) {
|
||||
data[iy][ix] = getValue(ptr, ix, iy);
|
||||
}
|
||||
int el=dsize/sizeof(dataType);
|
||||
if (dsize<=0 || dsize>dataSize) dsize=dataSize;
|
||||
for (int ip=0; ip<el; ip++) {
|
||||
getPixel(ip,ix,iy);
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
|
||||
data[iy][ix]=getValue(ptr,ix,iy);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
template <typename dataType>
|
||||
dataType slsDetectorData<dataType>::getChannel(char *data, int ix, int iy) {
|
||||
dataType m = 0, d = 0;
|
||||
if (ix >= 0 && ix < nx && iy >= 0 && iy < ny && dataMap[iy][ix] >= 0 &&
|
||||
dataMap[iy][ix] < dataSize) {
|
||||
m = dataMask[iy][ix];
|
||||
if (isOrdered == 0)
|
||||
d = *((dataType *)(data + getPointer(ix, iy)));
|
||||
else
|
||||
d = orderedData[iy][ix];
|
||||
}
|
||||
return d ^ m;
|
||||
return data;
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the value of the selected channel for the given dataset. Virtual function, can be overloaded.
|
||||
\param data pointer to the dataset (including headers etc)
|
||||
\param ix pixel number in the x direction
|
||||
\param iy pixel number in the y direction
|
||||
\returns data for the selected channel, with inversion if required
|
||||
|
||||
*/
|
||||
virtual dataType getChannel(char *data, int ix, int iy=0) {
|
||||
dataType m=0, d=0;
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny && dataMap[iy][ix]>=0 && dataMap[iy][ix]<dataSize) {
|
||||
// cout << ix << " " << iy << " " ;
|
||||
//cout << dataMap[ix][iy] << " " << (void*)data << " " << dataSize<< endl;
|
||||
m=dataMask[iy][ix];
|
||||
if (isOrdered==0)
|
||||
d=*((dataType*)(data+getPointer(ix,iy)));
|
||||
else
|
||||
d=orderedData[iy][ix];
|
||||
}
|
||||
return d^m;
|
||||
};
|
||||
|
||||
virtual int getGain(char *data, int ix, int iy=0){return 0;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the value of the selected channel for the given dataset. Virtual function, can be overloaded.
|
||||
\param data pointer to the dataset (including headers etc)
|
||||
\param ix pixel number in the x direction
|
||||
\param iy pixel number in the y direction
|
||||
\returns data for the selected channel, with inversion if required or -1 if its a missing packet
|
||||
|
||||
*/
|
||||
|
||||
virtual int getChannelwithMissingPackets(char *data, int ix, int iy) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Returns the value of the selected channel for the given dataset as double.
|
||||
\param data pointer to the dataset (including headers etc)
|
||||
\param ix pixel number in the x direction
|
||||
\param iy pixel number in the y direction
|
||||
\returns data for the selected channel, with inversion if required as double
|
||||
|
||||
*/
|
||||
virtual double getValue(char *data, int ix, int iy=0) {
|
||||
/* cout << " x "<< ix << " y"<< iy << " val " << getChannel(data, ix, iy)<< endl;*/
|
||||
return (double)getChannel(data, ix, iy);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
virtual int getFrameNumber(char *buff)=0;
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
virtual int getPacketNumber(char *buff)=0;
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize)=0;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
|
||||
\param filebin input file stream (binary)
|
||||
\returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete
|
||||
|
||||
*/
|
||||
virtual char *readNextFrame(ifstream &filebin)=0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,257 +1,240 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef SLSRECEIVERDATA_H
|
||||
#define SLSRECEIVERDATA_H
|
||||
#define SLSRECEIVERDATA_H
|
||||
|
||||
#include "slsDetectorData.h"
|
||||
#include <cstring>
|
||||
#include <stdlib.h> // exit()
|
||||
#include <stdlib.h> // exit()
|
||||
template <class dataType>
|
||||
class slsReceiverData : public slsDetectorData<dataType> {
|
||||
|
||||
public:
|
||||
/**
|
||||
slsReceiver data structure. Works for data acquired using the
|
||||
slsDetectorReceiver subdivided in different packets with headers and footers.
|
||||
Inherits and implements slsDetectorData.
|
||||
|
||||
Constructor (no error checking if datasize and offsets are compatible!)
|
||||
\param npx number of pixels in the x direction
|
||||
\param npy number of pixels in the y direction (1 for strips)
|
||||
\param np number of packets
|
||||
\param psize packets size
|
||||
\param dMap array of size nx*ny storing the pointers to the data in the dataset
|
||||
(as offset) \param dMask Array of size nx*ny storing the polarity of the data in
|
||||
the dataset (should be 0 if no inversion is required, 0xffffffff is inversion is
|
||||
required) \param dROI Array of size nx*ny. The elements are 1s if the channel is
|
||||
good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
|
||||
public:
|
||||
|
||||
*/
|
||||
slsReceiverData(int npx, int npy, int np, int psize, int **dMap = NULL,
|
||||
dataType **dMask = NULL, int **dROI = NULL)
|
||||
: slsDetectorData<dataType>(npx, npy, np * psize, dMap, dMask, dROI),
|
||||
nPackets(np), packetSize(psize){};
|
||||
/**
|
||||
slsReceiver data structure. Works for data acquired using the slsDetectorReceiver subdivided in different packets with headers and footers.
|
||||
Inherits and implements slsDetectorData.
|
||||
|
||||
/**
|
||||
Constructor (no error checking if datasize and offsets are compatible!)
|
||||
\param npx number of pixels in the x direction
|
||||
\param npy number of pixels in the y direction (1 for strips)
|
||||
\param np number of packets
|
||||
\param psize packets size
|
||||
\param dMap array of size nx*ny storing the pointers to the data in the dataset (as offset)
|
||||
\param dMask Array of size nx*ny storing the polarity of the data in the dataset (should be 0 if no inversion is required, 0xffffffff is inversion is required)
|
||||
\param dROI Array of size nx*ny. The elements are 1s if the channel is good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
|
||||
|
||||
Returns the frame number for the given dataset. Virtual func: works for
|
||||
slsDetectorReceiver data (also for each packet), but can be overloaded. \param
|
||||
buff pointer to the dataset \returns frame number
|
||||
*/
|
||||
slsReceiverData(int npx, int npy, int np, int psize, int **dMap=NULL, dataType **dMask=NULL, int **dROI=NULL): slsDetectorData<dataType>(npx, npy, np*psize, dMap, dMask, dROI), nPackets(np), packetSize(psize) {};
|
||||
|
||||
*/
|
||||
|
||||
virtual int getFrameNumber(char *buff) {
|
||||
return ((*(int *)buff) & (0xffffff00)) >> 8;
|
||||
};
|
||||
/**
|
||||
|
||||
/**
|
||||
Returns the frame number for the given dataset. Virtual func: works for slsDetectorReceiver data (also for each packet), but can be overloaded.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
Returns the packet number for the given dataset. Virtual func: works for
|
||||
slsDetectorReceiver packets, but can be overloaded. \param buff pointer to the
|
||||
dataset \returns packet number number
|
||||
*/
|
||||
|
||||
*/
|
||||
virtual int getFrameNumber(char *buff){return ((*(int*)buff)&(0xffffff00))>>8;};
|
||||
|
||||
virtual int getPacketNumber(char *buff) { return (*(int *)buff) & 0xff; };
|
||||
/**
|
||||
|
||||
/**
|
||||
Returns the packet number for the given dataset. Virtual func: works for slsDetectorReceiver packets, but can be overloaded.
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to
|
||||
nPackets, same frame number). Can be overloaded for different kind of
|
||||
detectors! \param data pointer to the memory to be analyzed \param ndata size
|
||||
of frame returned \param dsize size of the memory slot to be analyzed \returns
|
||||
pointer to the first packet of the last good frame (might be incomplete if
|
||||
npackets lower than the number of packets), or NULL if no frame is found
|
||||
*/
|
||||
|
||||
*/
|
||||
virtual int getPacketNumber(char *buff){return (*(int*)buff)&0xff;};
|
||||
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
char *retval = NULL, *p = data;
|
||||
int dd = 0;
|
||||
int fn, fnum = -1, np = 0, pnum = -1;
|
||||
while (dd <= (dsize - packetSize)) {
|
||||
pnum = getPacketNumber(p);
|
||||
fn = getFrameNumber(p);
|
||||
// cout <<"fnum:"<<fn<<" pnum:"<<pnum<<" np:"<< np << "\t";
|
||||
|
||||
if (pnum < 1 || pnum > nPackets) {
|
||||
// cout << "Bad packet number " << pnum << " frame "<< fn <<
|
||||
// endl;
|
||||
retval = NULL;
|
||||
np = 0;
|
||||
} else if (pnum == 1) {
|
||||
retval = p;
|
||||
if (np > 0)
|
||||
/*cout << "*Incomplete frame number " << fnum << endl;*/
|
||||
np = 0;
|
||||
fnum = fn;
|
||||
} else if (fn != fnum) {
|
||||
if (fnum != -1) {
|
||||
/* cout << " **Incomplete frame number " << fnum << " pnum "
|
||||
* << pnum << " " << getFrameNumber(p) << endl;*/
|
||||
retval = NULL;
|
||||
}
|
||||
np = 0;
|
||||
}
|
||||
p += packetSize;
|
||||
dd += packetSize;
|
||||
np++;
|
||||
// cout <<"fnum:"<<fn<<" pnum:"<<pnum<<" np:"<< np << "\t";
|
||||
// cout << pnum << " " << fn << " " << np << " " << dd << " " <<
|
||||
// dsize << endl;
|
||||
if (np == nPackets) {
|
||||
if (pnum == nPackets) {
|
||||
// cprintf(BG_GREEN, "Frame Found\n");
|
||||
// cout << "Frame found!" << endl;
|
||||
break;
|
||||
} else {
|
||||
// cprintf(BG_RED, "Too many packets for this frame!
|
||||
// fnum:%d, pnum:%d np:%d\n",fnum,pnum,np);
|
||||
cout << "Too many packets for this frame! " << fnum << " "
|
||||
<< pnum
|
||||
<< endl; // cprintf(BG_RED,"Exiting\n");exit(-1);
|
||||
retval = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (np < nPackets) {
|
||||
if (np > 0) {
|
||||
// cprintf(BG_RED, "Too few packets for this frame! fnum:%d,
|
||||
// pnum:%d np:%d\n",fnum,pnum,np);
|
||||
cout << "Too few packets for this frame! " << fnum << " "
|
||||
<< pnum << " " << np
|
||||
<< endl; // cprintf(BG_RED,"Exiting\n");exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
ndata = np * packetSize;
|
||||
// cout << "return " << ndata << endl;
|
||||
return retval;
|
||||
};
|
||||
/**
|
||||
|
||||
/**
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata size of frame returned
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the first packet of the last good frame (might be incomplete if npackets lower than the number of packets), or NULL if no frame is found
|
||||
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets 0 to
|
||||
nPackets, same frame number). Can be overloaded for different kind of
|
||||
detectors! \param filebin input file stream (binary) \returns pointer to the
|
||||
first packet of the last good frame, NULL if no frame is found or last frame is
|
||||
incomplete
|
||||
*/
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
char *retval=NULL, *p=data;
|
||||
int dd=0;
|
||||
int fn, fnum=-1, np=0, pnum=-1;
|
||||
while (dd<=(dsize-packetSize)) {
|
||||
pnum=getPacketNumber(p);
|
||||
fn=getFrameNumber(p);
|
||||
//cout <<"fnum:"<<fn<<" pnum:"<<pnum<<" np:"<< np << "\t";
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
char *data = new char[packetSize * nPackets];
|
||||
char *retval = 0;
|
||||
int np = 0, nd;
|
||||
if (pnum<1 || pnum>nPackets) {
|
||||
//cout << "Bad packet number " << pnum << " frame "<< fn << endl;
|
||||
retval=NULL;
|
||||
np=0;
|
||||
} else if (pnum==1) {
|
||||
retval=p;
|
||||
if (np>0)
|
||||
/*cout << "*Incomplete frame number " << fnum << endl;*/
|
||||
np=0;
|
||||
fnum=fn;
|
||||
} else if (fn!=fnum) {
|
||||
if (fnum!=-1) {
|
||||
/* cout << " **Incomplete frame number " << fnum << " pnum " << pnum << " " << getFrameNumber(p) << endl;*/
|
||||
retval=NULL;
|
||||
}
|
||||
np=0;
|
||||
}
|
||||
p+=packetSize;
|
||||
dd+=packetSize;
|
||||
np++;
|
||||
//cout <<"fnum:"<<fn<<" pnum:"<<pnum<<" np:"<< np << "\t";
|
||||
// cout << pnum << " " << fn << " " << np << " " << dd << " " << dsize << endl;
|
||||
if (np==nPackets){
|
||||
if (pnum==nPackets) {
|
||||
//cprintf(BG_GREEN, "Frame Found\n");
|
||||
// cout << "Frame found!" << endl;
|
||||
break;
|
||||
} else {
|
||||
//cprintf(BG_RED, "Too many packets for this frame! fnum:%d, pnum:%d np:%d\n",fnum,pnum,np);
|
||||
cout << "Too many packets for this frame! "<< fnum << " " << pnum << endl;//cprintf(BG_RED,"Exiting\n");exit(-1);
|
||||
retval=NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (np<nPackets) {
|
||||
if (np>0){
|
||||
//cprintf(BG_RED, "Too few packets for this frame! fnum:%d, pnum:%d np:%d\n",fnum,pnum,np);
|
||||
cout << "Too few packets for this frame! "<< fnum << " " << pnum << " " << np <<endl;//cprintf(BG_RED,"Exiting\n");exit(-1);
|
||||
|
||||
if (filebin.is_open()) {
|
||||
while (filebin.read(data + np * packetSize, packetSize)) {
|
||||
}
|
||||
}
|
||||
|
||||
if (np == (nPackets - 1)) {
|
||||
ndata=np*packetSize;
|
||||
// cout << "return " << ndata << endl;
|
||||
return retval;
|
||||
};
|
||||
|
||||
retval = findNextFrame(data, nd, packetSize * nPackets);
|
||||
np = nd / packetSize;
|
||||
// cout << np << endl;
|
||||
/**
|
||||
|
||||
if (retval == data && np == nPackets) {
|
||||
// cout << "-" << endl;
|
||||
return data;
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
|
||||
\param filebin input file stream (binary)
|
||||
\returns pointer to the first packet of the last good frame, NULL if no frame is found or last frame is incomplete
|
||||
|
||||
} else if (np > nPackets) {
|
||||
cout << "too many packets!!!!!!!!!!" << endl;
|
||||
delete[] data;
|
||||
return NULL;
|
||||
} else if (retval != NULL) {
|
||||
// cout << "+" << endl;;
|
||||
for (int ip = 0; ip < np; ip++)
|
||||
memcpy(data + ip * packetSize,
|
||||
retval + ip * packetSize, packetSize);
|
||||
}
|
||||
*/
|
||||
|
||||
} else if (np > nPackets) {
|
||||
cout << "*******too many packets!!!!!!!!!!" << endl;
|
||||
delete[] data;
|
||||
return NULL;
|
||||
} else {
|
||||
// cout << "." << endl;;
|
||||
np++;
|
||||
}
|
||||
}
|
||||
}
|
||||
delete[] data;
|
||||
return NULL;
|
||||
};
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
char *data=new char[packetSize*nPackets];
|
||||
char *retval=0;
|
||||
int np=0, nd;
|
||||
|
||||
/**
|
||||
if (filebin.is_open()) {
|
||||
while (filebin.read(data+np*packetSize,packetSize)) {
|
||||
|
||||
Loops over a file stream until a complete frame is found (i.e. all
|
||||
packets 0 to nPackets, same frame number). Can be overloaded for
|
||||
different kind of detectors! \param filebin input file stream (binary)
|
||||
\param fnum frame number of frame returned
|
||||
\returns pointer to the first packet of the last good frame, NULL if no
|
||||
frame is found or last frame is incomplete
|
||||
if (np==(nPackets-1)) {
|
||||
|
||||
*/
|
||||
retval=findNextFrame(data,nd,packetSize*nPackets);
|
||||
np=nd/packetSize;
|
||||
// cout << np << endl;
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &fnum) {
|
||||
char *data = new char[packetSize * nPackets];
|
||||
char *retval = 0;
|
||||
int np = 0, nd;
|
||||
fnum = -1;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
while (filebin.read(data + np * packetSize, packetSize)) {
|
||||
if (retval==data && np==nPackets) {
|
||||
// cout << "-" << endl;
|
||||
return data;
|
||||
|
||||
if (np == (nPackets - 1)) {
|
||||
} else if (np>nPackets) {
|
||||
cout << "too many packets!!!!!!!!!!" << endl;
|
||||
delete [] data;
|
||||
return NULL;
|
||||
} else if (retval!=NULL) {
|
||||
// cout << "+" << endl;;
|
||||
for (int ip=0; ip<np; ip++)
|
||||
memcpy(data+ip*packetSize,retval+ip*packetSize,packetSize);
|
||||
}
|
||||
|
||||
fnum = getFrameNumber(data); // cout << "fnum:"<<fnum<<endl;
|
||||
retval = findNextFrame(data, nd, packetSize * nPackets);
|
||||
np = nd / packetSize;
|
||||
// cout << np << endl;
|
||||
} else if (np>nPackets) {
|
||||
cout << "*******too many packets!!!!!!!!!!" << endl;
|
||||
delete [] data;
|
||||
return NULL;
|
||||
} else {
|
||||
// cout << "." << endl;;
|
||||
np++;
|
||||
}
|
||||
}
|
||||
}
|
||||
delete [] data;
|
||||
return NULL;
|
||||
};
|
||||
|
||||
if (retval == data && np == nPackets) {
|
||||
// cout << "-" << endl;
|
||||
return data;
|
||||
|
||||
} else if (np > nPackets) {
|
||||
cout << "too many packets!!!!!!!!!!" << endl;
|
||||
delete[] data;
|
||||
return NULL;
|
||||
} else if (retval != NULL) {
|
||||
// cout << "+" << endl;;
|
||||
for (int ip = 0; ip < np; ip++)
|
||||
memcpy(data + ip * packetSize,
|
||||
retval + ip * packetSize, packetSize);
|
||||
}
|
||||
/**
|
||||
|
||||
} else if (np > nPackets) {
|
||||
cout << "*******too many packets!!!!!!!!!!" << endl;
|
||||
delete[] data;
|
||||
return NULL;
|
||||
} else {
|
||||
// cout << "." << endl;;
|
||||
np++;
|
||||
// cout<<"np:"<<np<<endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
delete[] data;
|
||||
return NULL;
|
||||
};
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
|
||||
\param filebin input file stream (binary)
|
||||
\param fnum frame number of frame returned
|
||||
\returns pointer to the first packet of the last good frame, NULL if no frame is found or last frame is incomplete
|
||||
|
||||
virtual int *readNextFramewithMissingPackets(ifstream &filebin, int &fnum) {
|
||||
return NULL;
|
||||
}
|
||||
virtual void getChannelArray(double *data, char *buffer){};
|
||||
virtual int *readNextFrameOnlyData(ifstream &filebin, int &fnum) {
|
||||
return NULL;
|
||||
};
|
||||
virtual int *decodeData(int *datain) { return NULL; };
|
||||
virtual int getPacketNumber(int x, int y) { return 0; };
|
||||
*/
|
||||
|
||||
protected:
|
||||
const int nPackets; /**<number of UDP packets constituting one frame */
|
||||
const int packetSize; /**< size of a udp packet */
|
||||
virtual char *readNextFrame(ifstream &filebin, int& fnum) {
|
||||
char *data=new char[packetSize*nPackets];
|
||||
char *retval=0;
|
||||
int np=0, nd;
|
||||
fnum = -1;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
while (filebin.read(data+np*packetSize,packetSize)) {
|
||||
|
||||
if (np==(nPackets-1)) {
|
||||
|
||||
fnum=getFrameNumber(data); //cout << "fnum:"<<fnum<<endl;
|
||||
retval=findNextFrame(data,nd,packetSize*nPackets);
|
||||
np=nd/packetSize;
|
||||
// cout << np << endl;
|
||||
|
||||
|
||||
if (retval==data && np==nPackets) {
|
||||
// cout << "-" << endl;
|
||||
return data;
|
||||
|
||||
} else if (np>nPackets) {
|
||||
cout << "too many packets!!!!!!!!!!" << endl;
|
||||
delete [] data;
|
||||
return NULL;
|
||||
} else if (retval!=NULL) {
|
||||
// cout << "+" << endl;;
|
||||
for (int ip=0; ip<np; ip++)
|
||||
memcpy(data+ip*packetSize,retval+ip*packetSize,packetSize);
|
||||
}
|
||||
|
||||
} else if (np>nPackets) {
|
||||
cout << "*******too many packets!!!!!!!!!!" << endl;
|
||||
delete [] data;
|
||||
return NULL;
|
||||
} else {
|
||||
// cout << "." << endl;;
|
||||
np++;
|
||||
//cout<<"np:"<<np<<endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
delete [] data;
|
||||
return NULL;
|
||||
};
|
||||
|
||||
virtual int* readNextFramewithMissingPackets(ifstream &filebin, int& fnum) {return NULL;}
|
||||
virtual void getChannelArray(double* data, char* buffer){};
|
||||
virtual int* readNextFrameOnlyData(ifstream &filebin, int& fnum) {return NULL;};
|
||||
virtual int* decodeData(int* datain) {return NULL;};
|
||||
virtual int getPacketNumber(int x, int y) {return 0;};
|
||||
|
||||
protected:
|
||||
const int nPackets; /**<number of UDP packets constituting one frame */
|
||||
const int packetSize; /**< size of a udp packet */
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,7 @@
|
||||
#define MYROOT
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __MAKECINT__
|
||||
#define MYROOT
|
||||
#endif
|
||||
@ -22,35 +23,40 @@
|
||||
#define MYROOT
|
||||
|
||||
#ifdef MYROOT
|
||||
#include <TF1.h>
|
||||
#include <TROOT.h>
|
||||
#include <TF1.h>
|
||||
class TH1F;
|
||||
class TH2F;
|
||||
class TGraphErrors;
|
||||
#endif
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
const double conven = 1000. / 3.6; /**< electrons/keV */
|
||||
const double el = 1.67E-4; /**< electron charge in fC */
|
||||
|
||||
|
||||
|
||||
const double conven=1000./3.6; /**< electrons/keV */
|
||||
const double el=1.67E-4; /**< electron charge in fC */
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\mainpage Common Root library for SLS detectors data analysis
|
||||
*
|
||||
* \section intro_sec Introduction
|
||||
We know very well s-curves etc. but at the end everybody uses different
|
||||
functions ;-).
|
||||
We know very well s-curves etc. but at the end everybody uses different functions ;-).
|
||||
|
||||
* \subsection mot_sec Motivation
|
||||
It would be greate to use everybody the same functions...
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
@libdoc The energiCalibration class contains all the necessary functions for
|
||||
s-curve fitting and linear calibration of the threshold.
|
||||
@libdoc The energiCalibration class contains all the necessary functions for s-curve fitting and linear calibration of the threshold.
|
||||
*
|
||||
* @short Energy calibration functions
|
||||
* @author Anna Bergamaschi
|
||||
@ -59,155 +65,152 @@ s-curve fitting and linear calibration of the threshold.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
class containing all the possible energy calibration functions (scurves with
|
||||
and without charge sharing, gaussian spectrum with and without charge sharing,
|
||||
possibility of chosing the sign of the X-axis)
|
||||
/**
|
||||
class containing all the possible energy calibration functions (scurves with and without charge sharing, gaussian spectrum with and without charge sharing, possibility of chosing the sign of the X-axis)
|
||||
|
||||
*/
|
||||
class energyCalibrationFunctions {
|
||||
|
||||
public:
|
||||
energyCalibrationFunctions(int s = -1) { setScanSign(s); };
|
||||
|
||||
public:
|
||||
|
||||
energyCalibrationFunctions(int s=-1) {setScanSign(s);};
|
||||
|
||||
/** sets scan sign
|
||||
\param s can be 1 (energy and x-axis have the same direction) or -1
|
||||
(energy and x-axis have opposite directions) otherwise gets \returns
|
||||
current scan sign can be 1 (energy and x-axis have the same direction) or
|
||||
-1 (energy and x-axis have opposite directions)
|
||||
\param s can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) otherwise gets
|
||||
\returns current scan sign can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions)
|
||||
*/
|
||||
int setScanSign(int s = 0) {
|
||||
if (s == 1 || s == -1)
|
||||
sign = s;
|
||||
return sign;
|
||||
};
|
||||
;
|
||||
int setScanSign(int s=0) {if (s==1 || s==-1) sign=s; return sign;};;
|
||||
|
||||
|
||||
#ifdef MYROOT
|
||||
/**
|
||||
Gaussian Function with charge sharing pedestal
|
||||
par[0] is the absolute height of the background pedestal
|
||||
par[1] is the slope of the background pedestal
|
||||
*/
|
||||
Double_t pedestal(Double_t *x, Double_t *par);
|
||||
/**
|
||||
Gaussian Function with charge sharing pedestal
|
||||
par[0] is the absolute height of the background pedestal
|
||||
par[1] is the slope of the background pedestal
|
||||
*/
|
||||
Double_t pedestal(Double_t *x, Double_t *par);
|
||||
|
||||
/**
|
||||
Gaussian Function with charge sharing pedestal
|
||||
par[0] is the absolute height of the background pedestal
|
||||
par[1] is the slope of the background pedestal
|
||||
par[2] is the gaussian peak position
|
||||
par[3] is the RMS of the gaussian (and of the pedestal)
|
||||
par[4] is the height of the function
|
||||
par[5] is the fractional height of the charge sharing pedestal (scales
|
||||
with par[3])
|
||||
*/
|
||||
Double_t gaussChargeSharing(Double_t *x, Double_t *par);
|
||||
Double_t gaussChargeSharingKb(Double_t *x, Double_t *par);
|
||||
Double_t gaussChargeSharingKaDoublet(Double_t *x, Double_t *par);
|
||||
/**
|
||||
Gaussian Function with charge sharing pedestal
|
||||
par[0] is the absolute height of the background pedestal
|
||||
par[1] is the slope of the background pedestal
|
||||
par[2] is the gaussian peak position
|
||||
par[3] is the RMS of the gaussian (and of the pedestal)
|
||||
par[4] is the height of the function
|
||||
par[5] is the fractional height of the charge sharing pedestal (scales
|
||||
with par[3])
|
||||
*/
|
||||
Double_t gaussChargeSharingPixel(Double_t *x, Double_t *par);
|
||||
/**
|
||||
Gaussian Function with charge sharing pedestal
|
||||
par[0] is the absolute height of the background pedestal
|
||||
par[1] is the slope of the background pedestal
|
||||
par[2] is the gaussian peak position
|
||||
par[3] is the RMS of the gaussian (and of the pedestal)
|
||||
par[4] is the height of the function
|
||||
par[5] is the fractional height of the charge sharing pedestal (scales with par[3])
|
||||
*/
|
||||
Double_t gaussChargeSharing(Double_t *x, Double_t *par);
|
||||
Double_t gaussChargeSharingKb(Double_t *x, Double_t *par);
|
||||
Double_t gaussChargeSharingKaDoublet(Double_t *x, Double_t *par);
|
||||
/**
|
||||
Gaussian Function with charge sharing pedestal
|
||||
par[0] is the absolute height of the background pedestal
|
||||
par[1] is the slope of the background pedestal
|
||||
par[2] is the gaussian peak position
|
||||
par[3] is the RMS of the gaussian (and of the pedestal)
|
||||
par[4] is the height of the function
|
||||
par[5] is the fractional height of the charge sharing pedestal (scales with par[3])
|
||||
*/
|
||||
Double_t gaussChargeSharingPixel(Double_t *x, Double_t *par);
|
||||
|
||||
/**
|
||||
Basic erf function
|
||||
par[0] is the inflection point
|
||||
par[1] is the RMS
|
||||
par[2] is the amplitude
|
||||
*/
|
||||
Double_t erfFunction(Double_t *x, Double_t *par);
|
||||
Double_t erfBox(Double_t *z, Double_t *par);
|
||||
/** Erf function with charge sharing slope
|
||||
par[0] is the pedestal
|
||||
par[1] is the slope of the pedestal
|
||||
par[2] is the inflection point
|
||||
par[3] is the RMS
|
||||
par[4] is the amplitude
|
||||
par[5] is the angual coefficient of the charge sharing slope (scales
|
||||
with par[3])
|
||||
*/
|
||||
Double_t erfFunctionChargeSharing(Double_t *x, Double_t *par);
|
||||
/**
|
||||
Basic erf function
|
||||
par[0] is the inflection point
|
||||
par[1] is the RMS
|
||||
par[2] is the amplitude
|
||||
*/
|
||||
Double_t erfFunction(Double_t *x, Double_t *par) ;
|
||||
Double_t erfBox(Double_t *z, Double_t *par);
|
||||
/** Erf function with charge sharing slope
|
||||
par[0] is the pedestal
|
||||
par[1] is the slope of the pedestal
|
||||
par[2] is the inflection point
|
||||
par[3] is the RMS
|
||||
par[4] is the amplitude
|
||||
par[5] is the angual coefficient of the charge sharing slope (scales with par[3])
|
||||
*/
|
||||
Double_t erfFunctionChargeSharing(Double_t *x, Double_t *par);
|
||||
|
||||
/** Double Erf function with charge sharing slope
|
||||
par[0] is the pedestal
|
||||
par[1] is the slope of the pedestal
|
||||
par[2] is the inflection point of the first energy
|
||||
par[3] is the RMS of the first energy
|
||||
par[4] is the amplitude of the first energy
|
||||
par[5] is the angual coefficient of the charge sharing slope of the first energy (scales with par[3])
|
||||
par[6] is the inflection point of the second energy
|
||||
par[7] is the RMS of the second energy
|
||||
par[8] is the amplitude of the second energy
|
||||
par[9] is the angual coefficient of the charge sharing slope of the second energy (scales with par[8])
|
||||
*/
|
||||
|
||||
/** Double Erf function with charge sharing slope
|
||||
par[0] is the pedestal
|
||||
par[1] is the slope of the pedestal
|
||||
par[2] is the inflection point of the first energy
|
||||
par[3] is the RMS of the first energy
|
||||
par[4] is the amplitude of the first energy
|
||||
par[5] is the angual coefficient of the charge sharing slope of the
|
||||
first energy (scales with par[3]) par[6] is the inflection point of the
|
||||
second energy par[7] is the RMS of the second energy par[8] is the
|
||||
amplitude of the second energy par[9] is the angual coefficient of the
|
||||
charge sharing slope of the second energy (scales with par[8])
|
||||
*/
|
||||
Double_t erfFuncFluo(Double_t *x, Double_t *par);
|
||||
|
||||
Double_t erfFuncFluo(Double_t *x, Double_t *par);
|
||||
|
||||
/**
|
||||
static function Gaussian with charge sharing pedestal with the correct scan sign
|
||||
par[0] is the absolute height of the background pedestal
|
||||
par[1] is the slope of the pedestal
|
||||
par[2] is the gaussian peak position
|
||||
par[3] is the RMS of the gaussian (and of the pedestal)
|
||||
par[4] is the height of the function
|
||||
par[5] is the fractional height of the charge sharing pedestal (scales with par[4]
|
||||
*/
|
||||
Double_t spectrum(Double_t *x, Double_t *par);
|
||||
Double_t spectrumkb(Double_t *x, Double_t *par);
|
||||
Double_t spectrumkadoublet(Double_t *x, Double_t *par);
|
||||
|
||||
/**
|
||||
static function Gaussian with charge sharing pedestal with the correct
|
||||
scan sign par[0] is the absolute height of the background pedestal par[1]
|
||||
is the slope of the pedestal par[2] is the gaussian peak position par[3]
|
||||
is the RMS of the gaussian (and of the pedestal) par[4] is the height of
|
||||
the function par[5] is the fractional height of the charge sharing
|
||||
pedestal (scales with par[4]
|
||||
*/
|
||||
Double_t spectrum(Double_t *x, Double_t *par);
|
||||
Double_t spectrumkb(Double_t *x, Double_t *par);
|
||||
Double_t spectrumkadoublet(Double_t *x, Double_t *par);
|
||||
/**
|
||||
static function Gaussian with charge sharing pedestal with the correct scan sign
|
||||
par[0] is the absolute height of the background pedestal
|
||||
par[1] is the slope of the pedestal
|
||||
par[2] is the gaussian peak position
|
||||
par[3] is the RMS of the gaussian (and of the pedestal)
|
||||
par[4] is the height of the function
|
||||
par[5] is the fractional height of the charge sharing pedestal (scales with par[4]
|
||||
*/
|
||||
Double_t spectrumPixel(Double_t *x, Double_t *par);
|
||||
|
||||
/**
|
||||
static function Gaussian with charge sharing pedestal with the correct
|
||||
scan sign par[0] is the absolute height of the background pedestal par[1]
|
||||
is the slope of the pedestal par[2] is the gaussian peak position par[3]
|
||||
is the RMS of the gaussian (and of the pedestal) par[4] is the height of
|
||||
the function par[5] is the fractional height of the charge sharing
|
||||
pedestal (scales with par[4]
|
||||
*/
|
||||
Double_t spectrumPixel(Double_t *x, Double_t *par);
|
||||
|
||||
/** Erf function with charge sharing slope with the correct scan sign
|
||||
par[0] is the pedestal
|
||||
par[1] is the slope of the pedestal
|
||||
par[2] is the inflection point
|
||||
par[3] is the RMS
|
||||
par[4] is the amplitude
|
||||
par[5] is the angual coefficient of the charge sharing slope (scales
|
||||
with par[3])
|
||||
*/
|
||||
Double_t scurve(Double_t *x, Double_t *par);
|
||||
/** Erf function with charge sharing slope with the correct scan sign
|
||||
par[0] is the pedestal
|
||||
par[1] is the slope of the pedestal
|
||||
par[2] is the inflection point
|
||||
par[3] is the RMS
|
||||
par[4] is the amplitude
|
||||
par[5] is the angual coefficient of the charge sharing slope (scales with par[3])
|
||||
*/
|
||||
Double_t scurve(Double_t *x, Double_t *par);
|
||||
|
||||
/** Double Erf function with charge sharing slope
|
||||
par[0] is the pedestal
|
||||
par[1] is the slope of the pedestal
|
||||
par[2] is the inflection point of the first energy
|
||||
par[3] is the RMS of the first energy
|
||||
par[4] is the amplitude of the first energy
|
||||
par[5] is the angual coefficient of the charge sharing slope of the first
|
||||
energy (scales with par[3]) par[6] is the inflection point of the second
|
||||
energy par[7] is the RMS of the second energy par[8] is the amplitude of
|
||||
the second energy par[9] is the angual coefficient of the charge sharing
|
||||
slope of the second energy (scales with par[8])
|
||||
*/
|
||||
Double_t scurveFluo(Double_t *x, Double_t *par);
|
||||
|
||||
|
||||
/** Double Erf function with charge sharing slope
|
||||
par[0] is the pedestal
|
||||
par[1] is the slope of the pedestal
|
||||
par[2] is the inflection point of the first energy
|
||||
par[3] is the RMS of the first energy
|
||||
par[4] is the amplitude of the first energy
|
||||
par[5] is the angual coefficient of the charge sharing slope of the first energy (scales with par[3])
|
||||
par[6] is the inflection point of the second energy
|
||||
par[7] is the RMS of the second energy
|
||||
par[8] is the amplitude of the second energy
|
||||
par[9] is the angual coefficient of the charge sharing slope of the second energy (scales with par[8])
|
||||
*/
|
||||
Double_t scurveFluo(Double_t *x, Double_t *par);
|
||||
|
||||
#endif
|
||||
|
||||
/** Calculates the median of an array of n elements */
|
||||
static double median(double *x, int n);
|
||||
/** Calculates the median of an array of n elements (swaps the arrays!)*/
|
||||
static int quick_select(int arr[], int n);
|
||||
/** Calculates the median of an array of n elements (swaps the arrays!)*/
|
||||
static int kth_smallest(int *a, int n, int k);
|
||||
/** Calculates the median of an array of n elements */
|
||||
static double median(double *x, int n);
|
||||
/** Calculates the median of an array of n elements (swaps the arrays!)*/
|
||||
static int quick_select(int arr[], int n);
|
||||
/** Calculates the median of an array of n elements (swaps the arrays!)*/
|
||||
static int kth_smallest(int *a, int n, int k);
|
||||
|
||||
private:
|
||||
int sign;
|
||||
|
||||
|
||||
private:
|
||||
int sign;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -215,186 +218,162 @@ class energyCalibrationFunctions {
|
||||
|
||||
*/
|
||||
|
||||
class energyCalibration {
|
||||
class energyCalibration {
|
||||
|
||||
public:
|
||||
/**
|
||||
default constructor - creates the function with which the s-curves
|
||||
will be fitted
|
||||
*/
|
||||
energyCalibration();
|
||||
|
||||
/**
|
||||
default destructor - deletes the function with which the s-curves will
|
||||
be fitted
|
||||
*/
|
||||
~energyCalibration();
|
||||
|
||||
public:
|
||||
/**
|
||||
default constructor - creates the function with which the s-curves will be fitted
|
||||
*/
|
||||
energyCalibration();
|
||||
|
||||
/**
|
||||
default destructor - deletes the function with which the s-curves will be fitted
|
||||
*/
|
||||
~energyCalibration();
|
||||
|
||||
/** sets plot flag
|
||||
\param p plot flag (-1 gets, 0 unsets, >0 plot)
|
||||
\returns current plot flag
|
||||
\param p plot flag (-1 gets, 0 unsets, >0 plot)
|
||||
\returns current plot flag
|
||||
*/
|
||||
int setPlotFlag(int p = -1) {
|
||||
if (p >= 0)
|
||||
plot_flag = p;
|
||||
return plot_flag;
|
||||
};
|
||||
int setPlotFlag(int p=-1) {if (p>=0) plot_flag=p; return plot_flag;};
|
||||
|
||||
/** sets scan sign
|
||||
\param s can be 1 (energy and x-axis have the same direction) or -1
|
||||
(energy and x-axis have opposite directions) otherwise gets \returns
|
||||
current scan sign can be 1 (energy and x-axis have the same direction) or
|
||||
-1 (energy and x-axis have opposite directions)
|
||||
\param s can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions) otherwise gets
|
||||
\returns current scan sign can be 1 (energy and x-axis have the same direction) or -1 (energy and x-axis have opposite directions)
|
||||
*/
|
||||
int setScanSign(int s = 0) { return funcs->setScanSign(s); };
|
||||
|
||||
int setScanSign(int s=0) {return funcs->setScanSign(s);};
|
||||
|
||||
/** sets plot flag
|
||||
\param p plot flag (-1 gets, 0 unsets, >0 plot)
|
||||
\returns current plot flag
|
||||
\param p plot flag (-1 gets, 0 unsets, >0 plot)
|
||||
\returns current plot flag
|
||||
*/
|
||||
int setChargeSharing(int p = -1);
|
||||
int setChargeSharing(int p=-1);
|
||||
|
||||
void fixParameter(int ip, Double_t val);
|
||||
|
||||
void releaseParameter(int ip);
|
||||
void fixParameter(int ip, Double_t val);
|
||||
|
||||
void releaseParameter(int ip);
|
||||
|
||||
#ifdef MYROOT
|
||||
|
||||
/**
|
||||
Creates an histogram with the median of nchannels starting from a
|
||||
specified one. the direction on which it is mediated can be selected
|
||||
(defaults to x=0) \param h2 2D histogram on which the median will be
|
||||
calculated \param ch0 starting channel \param nch number of channels to
|
||||
be mediated \param direction can be either 0 (x, default) or 1 (y)
|
||||
\returns a TH1F histogram with the X-axis as a clone of the h2 Y (if
|
||||
direction=0) or X (if direction=0) axis, and on the Y axis the median of
|
||||
the counts of the mediated channels f h2
|
||||
*/
|
||||
static TH1F *createMedianHistogram(TH2F *h2, int ch0, int nch,
|
||||
int direction = 0);
|
||||
/**
|
||||
Creates an histogram with the median of nchannels starting from a specified one. the direction on which it is mediated can be selected (defaults to x=0)
|
||||
\param h2 2D histogram on which the median will be calculated
|
||||
\param ch0 starting channel
|
||||
\param nch number of channels to be mediated
|
||||
\param direction can be either 0 (x, default) or 1 (y)
|
||||
\returns a TH1F histogram with the X-axis as a clone of the h2 Y (if direction=0) or X (if direction=0) axis, and on the Y axis the median of the counts of the mediated channels f h2
|
||||
*/
|
||||
static TH1F* createMedianHistogram(TH2F* h2, int ch0, int nch, int direction=0);
|
||||
|
||||
/** sets the s-curve fit range
|
||||
\param mi minimum of the fit range (-1 is histogram x-min)
|
||||
\param ma maximum of the fit range (-1 is histogram x-max)
|
||||
*/
|
||||
void setFitRange(Double_t mi, Double_t ma) {
|
||||
fit_min = mi;
|
||||
fit_max = ma;
|
||||
};
|
||||
|
||||
/** gets the s-curve fit range
|
||||
\param mi reference for minimum of the fit range (-1 is histogram x-min)
|
||||
\param ma reference for maximum of the fit range (-1 is histogram x-max)
|
||||
*/
|
||||
void getFitRange(Double_t &mi, Double_t &ma) {
|
||||
mi = fit_min;
|
||||
ma = fit_max;
|
||||
};
|
||||
/** sets the s-curve fit range
|
||||
\param mi minimum of the fit range (-1 is histogram x-min)
|
||||
\param ma maximum of the fit range (-1 is histogram x-max)
|
||||
*/
|
||||
void setFitRange(Double_t mi, Double_t ma){fit_min=mi; fit_max=ma;};
|
||||
|
||||
/** set start parameters for the s-curve function
|
||||
\param par parameters, -1 sets to auto-calculation
|
||||
par[0] is the pedestal
|
||||
par[1] is the slope of the pedestal
|
||||
par[2] is the inflection point
|
||||
par[3] is the RMS
|
||||
par[4] is the amplitude
|
||||
par[5] is the angual coefficient of the charge sharing slope (scales
|
||||
with par[3]) -- always positive
|
||||
*/
|
||||
void setStartParameters(Double_t *par);
|
||||
void setStartParametersKb(Double_t *par);
|
||||
void setStartParametersKaDoublet(Double_t *par);
|
||||
/** gets the s-curve fit range
|
||||
\param mi reference for minimum of the fit range (-1 is histogram x-min)
|
||||
\param ma reference for maximum of the fit range (-1 is histogram x-max)
|
||||
*/
|
||||
void getFitRange(Double_t &mi, Double_t &ma){mi=fit_min; ma=fit_max;};
|
||||
|
||||
/** get start parameters for the s-curve function
|
||||
\param par parameters, -1 means auto-calculated
|
||||
par[0] is the pedestal
|
||||
par[1] is the slope of the pedestal
|
||||
par[2] is the inflection point
|
||||
par[3] is the RMS
|
||||
par[4] is the amplitude
|
||||
par[5] is the angual coefficient of the charge sharing slope (scales
|
||||
with par[3]) -- always positive
|
||||
*/
|
||||
void getStartParameters(Double_t *par);
|
||||
|
||||
/**
|
||||
fits histogram with the s-curve function
|
||||
\param h1 1d-histogram to be fitted
|
||||
\param mypar pointer to fit parameters array
|
||||
\param emypar pointer to fit parameter errors
|
||||
\returns the fitted function - can be used e.g. to get the Chi2 or
|
||||
similar
|
||||
*/
|
||||
TF1 *fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar);
|
||||
/** set start parameters for the s-curve function
|
||||
\param par parameters, -1 sets to auto-calculation
|
||||
par[0] is the pedestal
|
||||
par[1] is the slope of the pedestal
|
||||
par[2] is the inflection point
|
||||
par[3] is the RMS
|
||||
par[4] is the amplitude
|
||||
par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive
|
||||
*/
|
||||
void setStartParameters(Double_t *par);
|
||||
void setStartParametersKb(Double_t *par);
|
||||
void setStartParametersKaDoublet(Double_t *par);
|
||||
|
||||
/**
|
||||
fits histogram with the spectrum
|
||||
\param h1 1d-histogram to be fitted
|
||||
\param mypar pointer to fit parameters array
|
||||
\param emypar pointer to fit parameter errors
|
||||
\returns the fitted function - can be used e.g. to get the Chi2 or
|
||||
similar
|
||||
*/
|
||||
TF1 *fitSpectrum(TH1 *h1, Double_t *mypar, Double_t *emypar);
|
||||
TF1 *fitSpectrumKb(TH1 *h1, Double_t *mypar, Double_t *emypar);
|
||||
TF1 *fitSpectrumKaDoublet(TH1 *h1, Double_t *mypar, Double_t *emypar);
|
||||
/** get start parameters for the s-curve function
|
||||
\param par parameters, -1 means auto-calculated
|
||||
par[0] is the pedestal
|
||||
par[1] is the slope of the pedestal
|
||||
par[2] is the inflection point
|
||||
par[3] is the RMS
|
||||
par[4] is the amplitude
|
||||
par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive
|
||||
*/
|
||||
void getStartParameters(Double_t *par);
|
||||
|
||||
/**
|
||||
calculates gain and offset for the set of inflection points
|
||||
\param nscan number of energy scans
|
||||
\param en array of energies (nscan long)
|
||||
\param een array of errors on energies (nscan long) - can be NULL!
|
||||
\param fl array of inflection points (nscan long)
|
||||
\param efl array of errors on the inflection points (nscan long)
|
||||
\param gain reference to gain resulting from the fit
|
||||
\param off reference to offset resulting from the fit
|
||||
\param egain reference to error on the gain resulting from the fit
|
||||
\param eoff reference to the error on the offset resulting from the fit
|
||||
\returns graph energy vs inflection point
|
||||
*/
|
||||
TGraphErrors *linearCalibration(int nscan, Double_t *en, Double_t *een,
|
||||
Double_t *fl, Double_t *efl, Double_t &gain,
|
||||
Double_t &off, Double_t &egain,
|
||||
Double_t &eoff);
|
||||
/**
|
||||
fits histogram with the s-curve function
|
||||
\param h1 1d-histogram to be fitted
|
||||
\param mypar pointer to fit parameters array
|
||||
\param emypar pointer to fit parameter errors
|
||||
\returns the fitted function - can be used e.g. to get the Chi2 or similar
|
||||
*/
|
||||
TF1 *fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar);
|
||||
|
||||
/**
|
||||
calculates gain and offset for the set of energy scans
|
||||
\param nscan number of energy scans
|
||||
\param en array of energies (nscan long)
|
||||
\param een array of errors on energies (nscan long) - can be NULL!
|
||||
\param h1 array of TH1
|
||||
\param gain reference to gain resulting from the fit
|
||||
\param off reference to offset resulting from the fit
|
||||
\param egain reference to error on the gain resulting from the fit
|
||||
\param eoff reference to the error on the offset resulting from the fit
|
||||
\returns graph energy vs inflection point
|
||||
*/
|
||||
TGraphErrors *calibrateScurves(int nscan, Double_t *en, Double_t *een,
|
||||
TH1F **h1, Double_t &gain, Double_t &off,
|
||||
Double_t &egain, Double_t &eoff) {
|
||||
return calibrate(nscan, en, een, h1, gain, off, egain, eoff, 1);
|
||||
};
|
||||
|
||||
/**
|
||||
calculates gain and offset for the set of energy spectra
|
||||
\param nscan number of energy scans
|
||||
\param en array of energies (nscan long)
|
||||
\param een array of errors on energies (nscan long) - can be NULL!
|
||||
\param h1 array of TH1
|
||||
\param gain reference to gain resulting from the fit
|
||||
\param off reference to offset resulting from the fit
|
||||
\param egain reference to error on the gain resulting from the fit
|
||||
\param eoff reference to the error on the offset resulting from the fit
|
||||
\returns graph energy vs peak
|
||||
*/
|
||||
TGraphErrors *calibrateSpectra(int nscan, Double_t *en, Double_t *een,
|
||||
TH1F **h1, Double_t &gain, Double_t &off,
|
||||
Double_t &egain, Double_t &eoff) {
|
||||
return calibrate(nscan, en, een, h1, gain, off, egain, eoff, 0);
|
||||
};
|
||||
/**
|
||||
fits histogram with the spectrum
|
||||
\param h1 1d-histogram to be fitted
|
||||
\param mypar pointer to fit parameters array
|
||||
\param emypar pointer to fit parameter errors
|
||||
\returns the fitted function - can be used e.g. to get the Chi2 or similar
|
||||
*/
|
||||
TF1 *fitSpectrum(TH1 *h1, Double_t *mypar, Double_t *emypar);
|
||||
TF1 *fitSpectrumKb(TH1 *h1, Double_t *mypar, Double_t *emypar);
|
||||
TF1 *fitSpectrumKaDoublet(TH1 *h1, Double_t *mypar, Double_t *emypar);
|
||||
|
||||
|
||||
/**
|
||||
calculates gain and offset for the set of inflection points
|
||||
\param nscan number of energy scans
|
||||
\param en array of energies (nscan long)
|
||||
\param een array of errors on energies (nscan long) - can be NULL!
|
||||
\param fl array of inflection points (nscan long)
|
||||
\param efl array of errors on the inflection points (nscan long)
|
||||
\param gain reference to gain resulting from the fit
|
||||
\param off reference to offset resulting from the fit
|
||||
\param egain reference to error on the gain resulting from the fit
|
||||
\param eoff reference to the error on the offset resulting from the fit
|
||||
\returns graph energy vs inflection point
|
||||
*/
|
||||
TGraphErrors* linearCalibration(int nscan, Double_t *en, Double_t *een, Double_t *fl, Double_t *efl, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff);
|
||||
|
||||
/**
|
||||
calculates gain and offset for the set of energy scans
|
||||
\param nscan number of energy scans
|
||||
\param en array of energies (nscan long)
|
||||
\param een array of errors on energies (nscan long) - can be NULL!
|
||||
\param h1 array of TH1
|
||||
\param gain reference to gain resulting from the fit
|
||||
\param off reference to offset resulting from the fit
|
||||
\param egain reference to error on the gain resulting from the fit
|
||||
\param eoff reference to the error on the offset resulting from the fit
|
||||
\returns graph energy vs inflection point
|
||||
*/
|
||||
TGraphErrors* calibrateScurves(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff){return calibrate(nscan, en, een, h1, gain, off, egain, eoff, 1);};
|
||||
|
||||
/**
|
||||
calculates gain and offset for the set of energy spectra
|
||||
\param nscan number of energy scans
|
||||
\param en array of energies (nscan long)
|
||||
\param een array of errors on energies (nscan long) - can be NULL!
|
||||
\param h1 array of TH1
|
||||
\param gain reference to gain resulting from the fit
|
||||
\param off reference to offset resulting from the fit
|
||||
\param egain reference to error on the gain resulting from the fit
|
||||
\param eoff reference to the error on the offset resulting from the fit
|
||||
\returns graph energy vs peak
|
||||
*/
|
||||
TGraphErrors* calibrateSpectra(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff){return calibrate(nscan, en, een, h1, gain, off, egain, eoff, 0);};
|
||||
|
||||
|
||||
#endif
|
||||
private:
|
||||
private:
|
||||
|
||||
#ifdef MYROOT
|
||||
/**
|
||||
calculates gain and offset for the set of energies
|
||||
@ -407,72 +386,86 @@ class energyCalibration {
|
||||
\param egain reference to error on the gain resulting from the fit
|
||||
\param eoff reference to the error on the offset resulting from the fit
|
||||
\param integral 1 is an s-curve set (default), 0 spectra
|
||||
\returns graph energy vs peak/inflection point
|
||||
\returns graph energy vs peak/inflection point
|
||||
*/
|
||||
TGraphErrors *calibrate(int nscan, Double_t *en, Double_t *een, TH1F **h1,
|
||||
Double_t &gain, Double_t &off, Double_t &egain,
|
||||
Double_t &eoff, int integral = 1);
|
||||
TGraphErrors* calibrate(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff, int integral=1);
|
||||
|
||||
/**
|
||||
Initializes the start parameters and the range of the fit depending on
|
||||
the histogram characteristics and/or on the start parameters specified by
|
||||
the user \param fun pointer to function to be initialized \param h1
|
||||
histogram from which to extract the range and start parameters, if not
|
||||
already specified by the user
|
||||
|
||||
/**
|
||||
Initializes the start parameters and the range of the fit depending on the histogram characteristics and/or on the start parameters specified by the user
|
||||
\param fun pointer to function to be initialized
|
||||
\param h1 histogram from which to extract the range and start parameters, if not already specified by the user
|
||||
|
||||
*/
|
||||
|
||||
void initFitFunction(TF1 *fun, TH1 *h1);
|
||||
void initFitFunctionKb(TF1 *fun, TH1 *h1);
|
||||
void initFitFunctionKaDoublet(TF1 *fun, TH1 *h1);
|
||||
|
||||
|
||||
/**
|
||||
Performs the fit according to the flags specified and returns the fitted function
|
||||
\param fun function to fit
|
||||
\param h1 histogram to fit
|
||||
\param mypar pointer to fit parameters array
|
||||
\param emypar pointer to fit parameter errors
|
||||
\returns the fitted function - can be used e.g. to get the Chi2 or similar
|
||||
*/
|
||||
|
||||
void initFitFunction(TF1 *fun, TH1 *h1);
|
||||
void initFitFunctionKb(TF1 *fun, TH1 *h1);
|
||||
void initFitFunctionKaDoublet(TF1 *fun, TH1 *h1);
|
||||
|
||||
/**
|
||||
Performs the fit according to the flags specified and returns the fitted
|
||||
function \param fun function to fit \param h1 histogram to fit \param
|
||||
mypar pointer to fit parameters array \param emypar pointer to fit
|
||||
parameter errors \returns the fitted function - can be used e.g. to get
|
||||
the Chi2 or similar
|
||||
*/
|
||||
TF1 *fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar);
|
||||
TF1 *fitFunctionKb(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar);
|
||||
TF1 *fitFunctionKaDoublet(TF1 *fun, TH1 *h1, Double_t *mypar,
|
||||
Double_t *emypar);
|
||||
TF1 *fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar);
|
||||
TF1 *fitFunctionKb(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar);
|
||||
TF1 *fitFunctionKaDoublet(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef MYROOT
|
||||
Double_t fit_min; /**< minimum of the s-curve fitting range, -1 is histogram
|
||||
x-min */
|
||||
Double_t fit_max; /**< maximum of the s-curve fitting range, -1 is histogram
|
||||
x-max */
|
||||
Double_t fit_min; /**< minimum of the s-curve fitting range, -1 is histogram x-min */
|
||||
Double_t fit_max; /**< maximum of the s-curve fitting range, -1 is histogram x-max */
|
||||
|
||||
Double_t bg_offset; /**< start value for the background pedestal */
|
||||
Double_t bg_slope; /**< start value for the background slope */
|
||||
Double_t flex; /**< start value for the inflection point */
|
||||
Double_t noise; /**< start value for the noise */
|
||||
Double_t ampl; /**< start value for the number of photons */
|
||||
Double_t cs_slope; /**< start value for the charge sharing slope */
|
||||
Double_t kb_mean;
|
||||
Double_t kb_frac;
|
||||
Double_t mean2;
|
||||
Double_t ampl2;
|
||||
|
||||
Double_t bg_offset; /**< start value for the background pedestal */
|
||||
Double_t bg_slope; /**< start value for the background slope */
|
||||
Double_t flex; /**< start value for the inflection point */
|
||||
Double_t noise; /**< start value for the noise */
|
||||
Double_t ampl; /**< start value for the number of photons */
|
||||
Double_t cs_slope; /**< start value for the charge sharing slope */
|
||||
Double_t kb_mean;
|
||||
Double_t kb_frac;
|
||||
Double_t mean2;
|
||||
Double_t ampl2;
|
||||
TF1 *fscurve; /**< function with which the s-curve will be fitted */
|
||||
|
||||
TF1 *fscurve; /**< function with which the s-curve will be fitted */
|
||||
TF1 *fspectrum; /**< function with which the spectrum will be fitted */
|
||||
TF1 *fspectrumkb; /**< function with which the spectrum will be fitted */
|
||||
TF1 *fspectrumkadoublet; /**< function with which the spectrum will be fitted */
|
||||
|
||||
TF1 *fspectrum; /**< function with which the spectrum will be fitted */
|
||||
TF1 *fspectrumkb; /**< function with which the spectrum will be fitted */
|
||||
TF1 *fspectrumkadoublet; /**< function with which the spectrum will be
|
||||
fitted */
|
||||
|
||||
TF1 *fspixel; /**< function with which the spectrum will be fitted */
|
||||
TF1 *fspixel; /**< function with which the spectrum will be fitted */
|
||||
|
||||
#endif
|
||||
|
||||
energyCalibrationFunctions *funcs;
|
||||
int plot_flag; /**< 0 does not plot, >0 plots (flags?) */
|
||||
energyCalibrationFunctions *funcs;
|
||||
int plot_flag; /**< 0 does not plot, >0 plots (flags?) */
|
||||
|
||||
int cs_flag; /**< 0 functions without charge sharing contribution, >0 with charge sharing contribution */
|
||||
|
||||
int cs_flag; /**< 0 functions without charge sharing contribution, >0 with
|
||||
charge sharing contribution */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -3,61 +3,65 @@
|
||||
#ifndef GHOSTSUMMATION_H
|
||||
#define GHOSTSUMMATION_H
|
||||
|
||||
#include "slsDetectorData.h"
|
||||
#include <cmath>
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
template <class dataType> class ghostSummation {
|
||||
|
||||
/** @short virtual calss to handle ghosting*/
|
||||
/** @short virtual calss to handle ghosting*/
|
||||
|
||||
public:
|
||||
/** constructor
|
||||
\param xt crosstalk
|
||||
*/
|
||||
ghostSummation(slsDetectorData<dataType> *d, double xt)
|
||||
: xtalk(xt), det(d), nx(1), ny(1) {
|
||||
if (det)
|
||||
det->getDetectorSize(nx, ny);
|
||||
ghost = new double[nx * ny];
|
||||
};
|
||||
public:
|
||||
|
||||
/** constructor
|
||||
\param xt crosstalk
|
||||
*/
|
||||
ghostSummation(slsDetectorData<dataType> *d, double xt) : xtalk(xt),det(d), nx(1), ny(1) {
|
||||
if (det)
|
||||
det->getDetectorSize(nx,ny);
|
||||
ghost=new double[nx*ny];
|
||||
};
|
||||
|
||||
ghostSummation(ghostSummation *orig) {
|
||||
xtalk = orig->xtalk;
|
||||
det = orig->det;
|
||||
nx = 1;
|
||||
ny = 1;
|
||||
det->getDetectorSize(nx, ny);
|
||||
ghost = new double[nx * ny];
|
||||
}
|
||||
virtual ~ghostSummation() { delete[] ghost; };
|
||||
ghostSummation(ghostSummation *orig) {
|
||||
xtalk=orig->xtalk;
|
||||
det=orig->det;
|
||||
nx=1;
|
||||
ny=1;
|
||||
det->getDetectorSize(nx,ny);
|
||||
ghost=new double[nx*ny];
|
||||
|
||||
}
|
||||
~ghostSummation() {delete [] ghost;};
|
||||
|
||||
virtual ghostSummation *Clone() { return new ghostSummation(this); }
|
||||
virtual ghostSummation *Clone() {
|
||||
return new ghostSummation(this);
|
||||
}
|
||||
|
||||
double getXTalk() { return xtalk; };
|
||||
void setXTalk(double g) { xtalk = g; };
|
||||
double getXTalk(){return xtalk;};
|
||||
void setXTalk(double g) {xtalk=g;};
|
||||
|
||||
virtual double calcGhost(char *data, int ix, int iy = 1) {
|
||||
ghost[iy * nx + ix] = 0;
|
||||
return 0;
|
||||
};
|
||||
virtual double calcGhost(char *data, int ix, int iy=1){ghost[iy*nx+ix]=0; return 0;};
|
||||
|
||||
virtual void calcGhost(char *data) {
|
||||
for (int iy = 0; iy < ny; iy++)
|
||||
for (int ix = 0; ix < nx; ix++)
|
||||
ghost[iy * nx + ix] = calcGhost(data, ix, iy);
|
||||
}
|
||||
virtual void calcGhost(char *data){
|
||||
for (int iy=0; iy<ny; iy++)
|
||||
for (int ix=0; ix<nx; ix++)
|
||||
ghost[iy*nx+ix]=calcGhost(data, ix, iy);
|
||||
}
|
||||
|
||||
virtual double getGhost(int ix, int iy) {
|
||||
if (ix < 0 || ix >= nx || iy < 0 || iy >= ny)
|
||||
return 0;
|
||||
return ghost[iy * nx + ix];
|
||||
}
|
||||
virtual double getGhost(int ix, int iy) {
|
||||
if (ix<0 || ix>=nx || iy<0 || iy>=ny) return 0;
|
||||
return ghost[iy*nx+ix];
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
double xtalk;
|
||||
slsDetectorData<dataType> *det;
|
||||
double *ghost;
|
||||
int nx, ny;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user