Compare commits

..

5 Commits

Author SHA1 Message Date
d5a712ab42 WIP 2021-11-11 16:03:39 +01:00
fa931b8fca WIP 2021-11-11 16:00:45 +01:00
37bf3600ad only static 2021-11-11 15:58:41 +01:00
96f6561080 only static 2021-11-11 15:57:22 +01:00
9ca831d954 cmake 3.9 and removed zmq 2021-11-11 15:41:50 +01:00
289 changed files with 23915 additions and 30811 deletions

View File

@ -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

View File

@ -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,32 +81,10 @@ 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()
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 two fake libraries to manage options
add_library(slsProjectOptions INTERFACE)
target_compile_features(slsProjectOptions INTERFACE cxx_std_11)
endif()
if (NOT TARGET slsProjectWarnings)
add_library(slsProjectWarnings INTERFACE)
target_compile_features(slsProjectOptions INTERFACE cxx_std_11)
target_compile_options(slsProjectWarnings INTERFACE
-Wall
-Wextra
@ -141,22 +100,7 @@ if (NOT TARGET slsProjectWarnings)
-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)
endif()
endif()
if (NOT TARGET slsProjectCSettings)
#Settings for C code
add_library(slsProjectCSettings INTERFACE)
target_compile_options(slsProjectCSettings INTERFACE
@ -170,8 +114,30 @@ if (NOT TARGET slsProjectCSettings)
-Wdouble-promotion
-Werror=return-type
)
sls_disable_c_warning("-Wstringop-truncation")
#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()
# 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)
# Common functionallity to detector and receiver
add_subdirectory(slsSupportLib)
endif()
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)

View File

@ -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

View File

@ -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()

View File

@ -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()

View File

@ -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 )

View File

@ -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
View File

@ -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=""

View File

@ -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

View 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

View File

@ -0,0 +1,8 @@
python:
- 3.6
- 3.7
- 3.8
- 3.9
numpy:
- 1.17

View 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/.

View 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
View 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

View 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
View 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
View File

@ -0,0 +1,3 @@
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
ctest -j2

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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', '') }}

View File

@ -1,2 +0,0 @@
python:
- 3.9

View File

@ -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', '') }}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}
)

View File

@ -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

View File

@ -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++) {

View File

@ -34,12 +34,6 @@ Python bindings
* pybind11 (packaged in libs/)
-----------------------
Moench executables
-----------------------
* libtiff
-----------------------
Documentation
-----------------------

View File

@ -305,18 +305,8 @@ 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

View File

@ -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());

View File

@ -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.

View File

@ -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.

View File

@ -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
----------

View File

@ -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

File diff suppressed because it is too large Load Diff

View 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})

View File

@ -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)

View File

@ -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')
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"))
print("Changes since last commit:")
subprocess.run(['git', 'diff', '../src/detector.cpp'])

View File

@ -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):

View File

@ -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):

View File

@ -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,9 +59,6 @@ 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:

View File

@ -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,7 +3422,7 @@ class Detector(CppDetectorApi):
[Gotthard2][Mythen3] Frequency of clock in Hz.
Note
----
-----
:setter: Not implemented. Use clkdiv to set frequency
@ -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>>>---------------------------

View File

@ -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) &
.def(
"getNumMissingPackets",
(Result<std::vector<uint64_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("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{});
}

View File

@ -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();
}

View File

@ -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

View File

@ -0,0 +1 @@
../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv6.0.0

View File

@ -1 +0,0 @@
../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv6.1.0

View File

@ -0,0 +1 @@
../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv6.0.0

View File

@ -1 +0,0 @@
../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv6.1.0

View File

@ -0,0 +1 @@
../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv6.0.0

View File

@ -1 +0,0 @@
../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv6.1.0

View File

@ -0,0 +1 @@
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv6.0.0

View File

@ -1 +0,0 @@
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv6.1.0

View File

@ -0,0 +1 @@
../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv6.0.0

View File

@ -1 +0,0 @@
../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv6.1.0

View File

@ -0,0 +1 @@
../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv6.0.0

View File

@ -1 +0,0 @@
../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv6.1.0

View File

@ -0,0 +1 @@
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv6.0.0

View File

@ -1 +0,0 @@
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv6.1.0

View File

@ -5,44 +5,44 @@
#include <math.h>
class MovingStat {
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
clears the moving average number of samples parameter, mean and standard deviation
*/
void Clear() {
void Clear()
{
m_n = 0;
m_newM=0;
m_newM2=0;
}
/**
clears the moving average number of samples parameter, mean and standard
deviation
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;
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;
// cout << "set " << val << " " << m << " " << m_n << " " << m_newM << endl;
}
/**
clears the moving average number of samples parameter, mean and standard
deviation
clears the moving average number of samples parameter, mean and standard deviation
*/
void SetRMS(double rms) {
void SetRMS(double rms)
{
if (rms<=0) {
if (m_n>0)
m_newM2=m_newM*m_newM/m_n;
@ -63,11 +63,7 @@ class MovingStat {
\param i number of samples parameter to be set
*/
int SetN(int i) {
if (i >= 1)
n = i;
return n;
};
int SetN(int i) {if (i>=1) n=i; return n;};
/**
gets number of samples parameter
@ -75,15 +71,12 @@ class MovingStat {
*/
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
/** 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);
if (m_n<n) Add(x);
else Push(x);
}
/** adds the element to the accumulated average and standard deviation
\param x value to add
@ -91,40 +84,51 @@ class MovingStat {
inline void Add(double x) {
m_n++;
if (m_n == 1) {
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
}
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) {
if (m_n == 0)
{
m_newM = x;
m_newM2 = x*x;
m_n++;
} else {
}
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; }
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;
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;
}
@ -132,19 +136,24 @@ class MovingStat {
/** 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); }
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 {
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 {
inline double StandardDeviation() const
{
return sqrt(Variance());//
}

View File

@ -1,19 +1,27 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
class RunningStat {
class RunningStat
{
public:
RunningStat() : m_n(0) {}
void Clear() { m_n = 0; }
void Clear()
{
m_n = 0;
}
void Push(double x) {
void Push(double x)
{
m_n++;
// See Knuth TAOCP vol 2, 3rd edition, page 232
if (m_n == 1) {
if (m_n == 1)
{
m_oldM = m_newM = x;
m_oldS = 0.0;
} else {
}
else
{
m_newM = m_oldM + (x - m_oldM)/m_n;
m_newS = m_oldS + (x - m_oldM)*(x - m_newM);
@ -23,13 +31,25 @@ class RunningStat {
}
}
int NumDataValues() const { return m_n; }
int NumDataValues() const
{
return m_n;
}
double Mean() const { return (m_n > 0) ? m_newM : 0.0; }
double Mean() const
{
return (m_n > 0) ? m_newM : 0.0;
}
double Variance() const { return ((m_n > 1) ? m_newS / (m_n - 1) : 0.0); }
double Variance() const
{
return ( (m_n > 1) ? m_newS/(m_n - 1) : 0.0 );
}
double StandardDeviation() const { return sqrt(Variance()); }
double StandardDeviation() const
{
return sqrt( Variance() );
}
private:
int m_n;

View File

@ -1,31 +1,45 @@
// 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() {
void Clear()
{
n = 0;
m=0;
m2=0;
}
void Push(double x) {
void Push(double x)
{
m+=x;
m2+=x*x;
n++;
}
int NumDataValues() const { return n; }
int NumDataValues() const
{
return n;
}
double Mean() const { return (n > 0) ? m / n : 0.0; }
double Mean() const
{
return (n > 0) ? m/n : 0.0;
}
double Variance() const {
double Variance() const
{
return ( (n >0 ) ? (m2/n-m*m/(n*n)) : 0.0 );
}
double StandardDeviation() const { return sqrt(Variance()); }
double StandardDeviation() const
{
return sqrt( Variance() );
}
private:
int n;

File diff suppressed because it is too large Load Diff

View File

@ -10,18 +10,22 @@
* */
//#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;
/** Circular Fifo (a.k.a. Circular Buffer)
* Thread safe for one reader, and one writer */
template <typename Element> class CircularFifo {
template<typename Element>
class CircularFifo {
public:
CircularFifo(unsigned int Size) : tail(0), head(0){
Capacity = Size + 1;
array.resize(Capacity);
@ -52,18 +56,23 @@ template <typename Element> class CircularFifo {
unsigned int increment(unsigned int idx_) const;
};
template <typename Element> int CircularFifo<Element>::getDataValue() const {
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
@ -72,7 +81,8 @@ template <typename Element> int CircularFifo<Element>::getFreeValue() const {
* \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) {
bool CircularFifo<Element>::push(Element*& item_, bool no_block)
{
// check for fifo full
if (no_block && isFull())
return false;
@ -92,7 +102,8 @@ bool CircularFifo<Element>::push(Element *&item_, bool no_block) {
* \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) {
bool CircularFifo<Element>::pop(Element*& item_, bool no_block)
{
// check for fifo empty
if (no_block && isEmpty())
return false;
@ -109,7 +120,9 @@ bool CircularFifo<Element>::pop(Element *&item_, bool no_block) {
* as the Procuder adds more items.
*
* \return true if circular buffer is empty */
template <typename Element> bool CircularFifo<Element>::isEmpty() const {
template<typename Element>
bool CircularFifo<Element>::isEmpty() const
{
return (getDataValue() == 0);
}
@ -118,7 +131,9 @@ template <typename Element> bool CircularFifo<Element>::isEmpty() const {
* as the Consumer catches up.
*
* \return true if circular buffer is full. */
template <typename Element> bool CircularFifo<Element>::isFull() const {
template<typename Element>
bool CircularFifo<Element>::isFull() const
{
return (getFreeValue() == 0);
}
@ -128,7 +143,8 @@ template <typename Element> bool CircularFifo<Element>::isFull() const {
* \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 {
unsigned int CircularFifo<Element>::increment(unsigned int idx_) const
{
// increment or wrap
// =================
// index++;
@ -139,3 +155,4 @@ unsigned int CircularFifo<Element>::increment(unsigned int idx_) const {
idx_ = (idx_+1) % Capacity;
return idx_;
}

View File

@ -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
\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];
};
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;
};
/** 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*/
/** 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*/
/** 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]);
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
/** 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) {
(void)ix;
(void)iy;
(void) ix; (void) iy;
//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
/** 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
\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;
};
(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 */
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

View File

@ -7,14 +7,13 @@
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
\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) {
@ -23,13 +22,8 @@ class commonModeSubtraction {
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;
};
/** 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); */
@ -39,18 +33,15 @@ class commonModeSubtraction {
return new commonModeSubtraction(this->nROI, this->nsigma);
}
/** clears the moving average and the sum of pedestals calculation - virtual
* func*/
/** 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*/
/** 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++) {
@ -58,11 +49,10 @@ class commonModeSubtraction {
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
/** 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
*/
@ -82,11 +72,10 @@ class commonModeSubtraction {
}
};
/** 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
/** 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
\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);
@ -94,9 +83,8 @@ class commonModeSubtraction {
/* 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;
// 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];
@ -104,19 +92,16 @@ class commonModeSubtraction {
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
/** 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
\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 sqrt(mean2[iroi]/nCm[iroi]-(mean[iroi]/nCm[iroi])*(mean[iroi]/nCm[iroi]));
}
return 0;
};
@ -124,25 +109,21 @@ class commonModeSubtraction {
/**
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;
};
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 */
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

View File

@ -3,26 +3,19 @@
#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 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];
short unsigned int *val=mythen03_frame(data,dynamicRange,numberOfCounters,serialOffset);
if (ix>=0 && ix<numberOfCounters) ret=val[ix];
delete [] val;
return ret;
};
@ -48,10 +41,11 @@ class mythen3_01_jctbData : public slsDetectorData<short unsigned int> {
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) {
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;
@ -72,8 +66,7 @@ class mythen3_01_jctbData : public slsDetectorData<short unsigned int> {
wp=(int64_t*)ptr;
for (iw=0; iw<nch/nb; iw) {
word = *wp;
;
word=*wp;;
if (ioff<off) {
ioff++;
cout <<"*";
@ -92,10 +85,10 @@ class mythen3_01_jctbData : public slsDetectorData<short unsigned int> {
idr++;
if (idr==dr) {
idr=0;
// cout << dec << " " << iw << " " << val[iw] << " " <<
// val[iw+nch/2] << endl;
// cout << dec << " " << iw << " " << val[iw] << " " << val[iw+nch/2] << endl;
cout <<dec << iw<<endl;
iw++;
}//end if()
@ -111,32 +104,22 @@ class mythen3_01_jctbData : public slsDetectorData<short unsigned int> {
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 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

View File

@ -3,24 +3,22 @@
#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 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)
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;}; */
/* 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); */
/* short unsigned int *val=mythen03_frame(data,dynamicRange,numberOfCounters,serialOffset); */
/* if (ix>=0 && ix<numberOfCounters) ret=val[ix]; */
/* delete [] val; */
/* return ret; */
@ -50,8 +48,8 @@ class mythen3_02_jctbData : public mythen3_01_jctbData {
/* } */
virtual short unsigned int *mythen03_frame(char *ptr, int dr = 24,
int nch = 64 * 3, int off = 5) {
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;
@ -94,10 +92,10 @@ class mythen3_02_jctbData : public mythen3_01_jctbData {
idr++;
if (idr==dr) {
idr=0;
// cout << dec << " " << iw << " " << val[iw] << " " <<
// val[iw+nch/2] << endl;
// cout << dec << " " << iw << " " << val[iw] << " " << val[iw+nch/2] << endl;
cout <<dec << iw<<endl;
iw++;
}//end if()
@ -113,14 +111,11 @@ class mythen3_02_jctbData : public mythen3_01_jctbData {
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 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: */
@ -128,6 +123,10 @@ class mythen3_02_jctbData : public mythen3_01_jctbData {
/* int serialOffset; */
/* int frameNumber; */
/* int numberOfCounters; */
};
#endif

View File

@ -3,17 +3,14 @@
#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 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;
@ -52,14 +49,17 @@ class adcSar2_jctbData : public slsDetectorData<short unsigned int> {
/* } */
virtual int setFrameNumber(int f = 0) {
if (f >= 0)
frameNumber = f;
return frameNumber;
};
virtual int setFrameNumber(int f=0) {if (f>=0) frameNumber=f; return frameNumber; };
private:
int frameNumber;
};
#endif

View File

@ -7,66 +7,53 @@
class chiptestBoardData : public slsDetectorData<uint16_t> {
public:
/**
chiptestBoard data structure. Works for data acquired using the
chiptestBoard. Inherits and implements slsDetectorData.
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.
\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.
*/
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)
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)
/**
Returns the frame number for the given dataset. Virtual func: works for
slsDetectorReceiver data (also for each packet), but can be overloaded.
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
*/
virtual int getFrameNumber(char *buff) {
(void)buff;
return iframe;
};
virtual int getFrameNumber(char *buff){(void)buff; return iframe;};
/**
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
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 *findNextFrame(char *data, int &ndata, int dsize) {
ndata = dsize;
setDataSize(dsize);
return data;
};
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 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 *readNextFrame(ifstream &filebin) {
@ -78,8 +65,7 @@ class chiptestBoardData : public slsDetectorData<uint16_t> {
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)) {
if (filebin.read((char*)afifo_cont,afifo_length*sizeof(uint16_t)*nAdc)) {
iframe++;
return (char*)afifo_cont;
} else {
@ -95,9 +81,11 @@ class chiptestBoardData : public slsDetectorData<uint16_t> {
private:
const int nAdc; /**<number of ADC read out */
const int offSize; /**< offset at the beginning of the frame (depends on the
pattern) */
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

View File

@ -2,34 +2,25 @@
// 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){};
virtual void getPixel(int ip, int &x, int &y) {
x = -1;
y = -1;
};
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) {};
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);
int *val=deserializeAll(data,dbitlist,dynamicRange,numberOfCounters,serialOffset);
ret=val[ix];
delete [] val;
}
@ -57,13 +48,15 @@ class deserializer : public slsDetectorData<int> {
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) {
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;
@ -98,8 +91,7 @@ class deserializer : public slsDetectorData<int> {
}
for (iw=0; iw<nw; iw) {
word = *wp;
;
word=*wp;;
if (ioff<off) {
ioff++;
// cout <<"*";
@ -111,8 +103,7 @@ class deserializer : public slsDetectorData<int> {
// for (const auto &bit : dbl) {
ich=iw+nch*ib/nb;
/* if (ich>1060) */
/* cout << iw << " " << idr << " " << ib << " " << bit << "
* " << ich << " " << val[ich] << " ** " ; */
/* cout << iw << " " << idr << " " << ib << " " << bit << " " << ich << " " << val[ich] << " ** " ; */
bit=dbl[ib];
ww=one<<bit;
if (word&(ww) && ich<nch) {
@ -120,8 +111,7 @@ class deserializer : public slsDetectorData<int> {
val[ich]|=(1<<idr);
}
/* if (ich>1060) */
/* cout << val[ich] << " " << hex << word << " " << ww <<
* " " << (word&(ww)) << dec <<endl; */
/* cout << val[ich] << " " << hex << word << " " << ww << " " << (word&(ww)) << dec <<endl; */
/* //else { */
//cout << "-" ;
//}
@ -133,8 +123,7 @@ class deserializer : public slsDetectorData<int> {
if (idr==dr) {
idr=0;
// cout << dec << " " << iw << " " << val[iw] << " " <<
// val[iw+nch/2] << endl;
// cout << dec << " " << iw << " " << val[iw] << " " << val[iw+nch/2] << endl;
// cout <<dec << iw<<endl;
iw++;
}//end if()
@ -144,11 +133,11 @@ class deserializer : public slsDetectorData<int> {
// ii++;
}//end for
return val;
}
static int *deserializeList(char *ptr, std::vector<int> dbl, int dr = 24,
int nch = 64 * 3, int off = 5) {
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;
@ -175,8 +164,7 @@ class deserializer : public slsDetectorData<int> {
// for (const auto &bit : dbl) {
/* if (ich>1060) */
/* cout << iw << " " << idr << " " << ib << " " << bit << " " << ich
* << " " << val[ich] << " ** " ; */
/* cout << iw << " " << idr << " " << ib << " " << bit << " " << ich << " " << val[ich] << " ** " ; */
bit=dbl[ib];
//ioff=off;
idr=0;
@ -193,41 +181,28 @@ class deserializer : public slsDetectorData<int> {
// 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 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

View File

@ -4,6 +4,13 @@
#define GOTTHARD2MODULEDATANEW_H
#include "gotthardModuleDataNew.h"
class gotthardDoubleModuleDataNew : public slsDetectorData<uint16_t> {
private:
@ -11,22 +18,29 @@ class gotthardDoubleModuleDataNew : public slsDetectorData<uint16_t> {
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
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) {
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;
#endif
uint16_t **dMask;
int **dMap;
int ix, iy;
@ -47,23 +61,22 @@ class gotthardDoubleModuleDataNew : public slsDetectorData<uint16_t> {
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] = 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)))
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);
};
/**
Returns the frame number for the given dataset.
@ -72,41 +85,37 @@ class gotthardDoubleModuleDataNew : public slsDetectorData<uint16_t> {
*/
int getFrameNumber(char *buff) {
if (offset >= sizeof(sls_detector_header))
return ((sls_detector_header *)buff)->frameNumber;
return iframe;
}; //*((int*)(buff+5))&0xffffff;};
int getFrameNumber(char *buff){if (offset>=sizeof(sls_detector_header)) return ((sls_detector_header*)buff)->frameNumber; return iframe;};//*((int*)(buff+5))&0xffffff;};
/**
gets the packets number (last packet is labelled with 0 and is replaced with
40) \param buff pointer to the memory \returns packet 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 getPacketNumber(char *buff){if (offset>=sizeof(sls_detector_header))return ((sls_detector_header*)buff)->packetNumber;};
/**
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
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;
if (dsize<dataSize) ndata=dsize;
else ndata=dataSize;
return data;
}
virtual char *readNextFrame(ifstream &filebin) {
@ -122,15 +131,14 @@ class gotthardDoubleModuleDataNew : public slsDetectorData<uint16_t> {
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;
}
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
char *data) {
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
@ -149,7 +157,18 @@ class gotthardDoubleModuleDataNew : public slsDetectorData<uint16_t> {
}
}
return NULL;
};
};
};
#endif

View File

@ -4,18 +4,26 @@
#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.)
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
*/
gotthardShortModuleData(double c = 0)
: slsReceiverData<uint16_t>(xpixels, ypixels, npackets, buffersize),
xtalk(c) {
gotthardShortModuleData(double c=0): slsReceiverData<uint16_t>(xpixels, ypixels, npackets, buffersize), xtalk(c){
uint16_t **dMask;
int **dMap;
@ -43,6 +51,7 @@ class gotthardShortModuleData : public slsReceiverData<uint16_t> {
setDataMask(dMask);
};
/**
Returns the frame number for the given dataset.
@ -51,15 +60,23 @@ class gotthardShortModuleData : public slsReceiverData<uint16_t> {
*/
int getFrameNumber(char *buff) { return (*(int *)buff); };
int getFrameNumber(char *buff){
return (*(int*)buff);
};
/**
gets the packets number (last packet is labelled with 0 and is replaced with
40) \param buff pointer to the memory \returns packet 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) { return 1; };
int getPacketNumber(char *buff){
return 1;
};
/**
returns the pixel value as double correcting for the output buffer crosstalk
@ -74,27 +91,32 @@ returns the pixel value as double correcting for the output buffer crosstalk
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);
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;
}
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;
@ -102,4 +124,6 @@ returns the pixel value as double correcting for the output buffer crosstalk
const static int buffersize = 518;
};
#endif

View File

@ -4,21 +4,25 @@
#define IMAGEZMQ16BIT_H
#include "slsDetectorData.h"
class imageZmq16bit : 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
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) {
// 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++){
@ -27,23 +31,22 @@ class imageZmq16bit : public slsDetectorData<uint16_t> {
is++;
}
}
};
virtual double getValue(char *data, int ix, int iy=0) {
cout << ix << " " << ix << dataMap[iy][ix] << 2 * nx * ny << " "
<< endl;
cout << ix << " " << ix << dataMap[iy][ix] << 2*nx*ny << " "<< endl;
uint16_t val=getChannel(data, ix, iy)&0x3fff;
return val;
};
int getFrameNumber(char *buff) {
return *((int *)buff);
}; //*((int*)(buff+5))&0xffffff;};
int getPacketNumber(char *buff) {
return 0;
} //((*(((int*)(buff+4))))&0xff)+1;};
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;
@ -58,21 +61,21 @@ class imageZmq16bit : public slsDetectorData<uint16_t> {
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;
}
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
char *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;
@ -84,19 +87,41 @@ class imageZmq16bit : public slsDetectorData<uint16_t> {
}
}
return NULL;
};
virtual char *findNextFrame(char *data, int &ndata, int dsize){
if (dsize < 2 * nx * ny)
ndata = dsize;
else
ndata = 2 * nx * ny;
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;};
};
#endif

View File

@ -4,21 +4,25 @@
#define IMAGEZMQ32BIT_H
#include "slsDetectorData.h"
class imageZmq32bit : 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
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) {
// 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++){
@ -27,23 +31,22 @@ class imageZmq32bit : public slsDetectorData<uint16_t> {
is++;
}
}
};
/* virtual double getValue(char *data, int ix, int iy=0) { */
/* //cout << ix << " " << ix << dataMap[iy][ix] << 2*nx*ny << " "<< endl;
*/
/* //cout << ix << " " << ix << dataMap[iy][ix] << 2*nx*ny << " "<< endl; */
/* uint16_t val=getChannel(data, ix, iy); */
/* return val; */
/* }; */
int getFrameNumber(char *buff) {
return *((int *)buff);
}; //*((int*)(buff+5))&0xffffff;};
int getPacketNumber(char *buff) {
return 0;
} //((*(((int*)(buff+4))))&0xff)+1;};
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;
@ -58,21 +61,21 @@ class imageZmq32bit : public slsDetectorData<uint16_t> {
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;
}
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
char *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;
@ -84,19 +87,41 @@ class imageZmq32bit : public slsDetectorData<uint16_t> {
}
}
return NULL;
};
virtual char *findNextFrame(char *data, int &ndata, int dsize){
if (dsize < 2 * nx * ny)
ndata = dsize;
else
ndata = 2 * nx * ny;
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;};
};
#endif

View File

@ -8,8 +8,7 @@
/**
@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 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
@ -28,21 +27,23 @@ typedef struct {
} jf_header;
class jungfrauHighZSingleChipData : public slsDetectorData<uint16_t> {
private:
int iframe;
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
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)) {
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++) {
@ -57,12 +58,14 @@ class jungfrauHighZSingleChipData : public slsDetectorData<uint16_t> {
// 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) {
@ -71,12 +74,16 @@ class jungfrauHighZSingleChipData : public slsDetectorData<uint16_t> {
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++) { */
@ -86,6 +93,7 @@ class jungfrauHighZSingleChipData : public slsDetectorData<uint16_t> {
/* // cout << "*" << endl; */
/* } */
/* double getGhost(int ix, int iy) { */
/* return 0; */
/* }; */
@ -106,9 +114,9 @@ class jungfrauHighZSingleChipData : public slsDetectorData<uint16_t> {
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff) {
return ((jf_header *)buff)->bunchNumber;
}; //*((int*)(buff+5))&0xffffff;};
int getFrameNumber(char *buff){return ((jf_header*)buff)->bunchNumber;};//*((int*)(buff+5))&0xffffff;};
/**
@ -119,34 +127,25 @@ class jungfrauHighZSingleChipData : public slsDetectorData<uint16_t> {
*/
int getPacketNumber(char *buff) {
return 0;
} //((*(((int*)(buff+4))))&0xff)+1;};
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 */
/* 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 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 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;}; */
/* 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! */
/* 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 */
/* \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){ */
@ -171,6 +170,7 @@ class jungfrauHighZSingleChipData : public slsDetectorData<uint16_t> {
/* return NULL; */
/* }; */
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
@ -184,15 +184,14 @@ class jungfrauHighZSingleChipData : public slsDetectorData<uint16_t> {
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;
}
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
char *data) {
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
@ -213,27 +212,29 @@ class jungfrauHighZSingleChipData : public slsDetectorData<uint16_t> {
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
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;
if (dsize<dataSize) ndata=dsize;
else ndata=dataSize;
return data;
}
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
};
#endif

View File

@ -4,9 +4,12 @@
#define MOENCH02CTBDATA_H
#include "slsDetectorData.h"
class moench02CtbData : public slsDetectorData<uint16_t> {
private:
int iframe;
// int *xmap, *ymap;
int nadc;
@ -15,17 +18,23 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
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
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) {
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};
@ -47,9 +56,9 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
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;
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
@ -59,8 +68,7 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
iiadc=i%32;
iadc=-1;
for (int iii=0; iii<4; iii++) {
if (iiadc == adc_nr[iii])
iadc = iii;
if (iiadc==adc_nr[iii]) iadc=iii;
}
ix=isample%sc_width;
iy=isample/sc_width;
@ -84,8 +92,10 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
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.
@ -94,10 +104,8 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
*/
virtual int getFrameNumber(char *buff) {
(void)buff;
return iframe;
};
virtual int getFrameNumber(char *buff){(void)buff; return iframe;};
/**
@ -112,28 +120,21 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
/**
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
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;
};
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
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){
@ -144,8 +145,7 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
afifo_cont=new uint16_t[dataSize/2];
while (filebin.read(((char*)afifo_cont)+ib,2)) {
ib+=2;
if (ib == dataSize)
break;
if (ib==dataSize) break;
}
if (ib>0) {
iframe++;
@ -160,6 +160,12 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
}
return NULL;
};
};
#endif

View File

@ -4,25 +4,31 @@
#define MOENCH03CTBDATA_H
#include "slsDetectorData.h"
class moench03CtbData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
int sc_height;
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
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) {
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;
@ -30,15 +36,17 @@ class moench03CtbData : public slsDetectorData<uint16_t> {
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};
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);
@ -49,8 +57,8 @@ class moench03CtbData : public slsDetectorData<uint16_t> {
}
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;
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
for (int i=0; i<nx*ny; i++) {
@ -65,12 +73,19 @@ class moench03CtbData : public slsDetectorData<uint16_t> {
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.
@ -79,10 +94,8 @@ class moench03CtbData : public slsDetectorData<uint16_t> {
*/
virtual int getFrameNumber(char *buff) {
(void)buff;
return iframe;
};
virtual int getFrameNumber(char *buff){(void)buff; return iframe;};
/**
@ -97,28 +110,21 @@ class moench03CtbData : public slsDetectorData<uint16_t> {
/**
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
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;
};
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
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){
@ -129,8 +135,7 @@ class moench03CtbData : public slsDetectorData<uint16_t> {
afifo_cont=new uint16_t[dataSize/2];
while (filebin.read(((char*)afifo_cont)+ib,2)) {
ib+=2;
if (ib == dataSize)
break;
if (ib==dataSize) break;
}
if (ib>0) {
iframe++;
@ -143,6 +148,12 @@ class moench03CtbData : public slsDetectorData<uint16_t> {
}
return NULL;
};
};
#endif

View File

@ -4,29 +4,36 @@
#define MOENCH03T1CTBDATA_H
#include "slsDetectorData.h"
class moench03T1CtbData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
int sc_height;
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
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};
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};
int row, col;
@ -34,6 +41,10 @@ class moench03T1CtbData : public slsDetectorData<uint16_t> {
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);
@ -44,8 +55,8 @@ class moench03T1CtbData : public slsDetectorData<uint16_t> {
}
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;
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
int adc4;
@ -63,12 +74,19 @@ class moench03T1CtbData : public slsDetectorData<uint16_t> {
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.
@ -77,10 +95,8 @@ class moench03T1CtbData : public slsDetectorData<uint16_t> {
*/
virtual int getFrameNumber(char *buff) {
(void)buff;
return iframe;
};
virtual int getFrameNumber(char *buff){(void)buff; return iframe;};
/**
@ -95,28 +111,21 @@ class moench03T1CtbData : public slsDetectorData<uint16_t> {
/**
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
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;
};
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
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){
@ -127,8 +136,7 @@ class moench03T1CtbData : public slsDetectorData<uint16_t> {
afifo_cont=new uint16_t[dataSize/2];
while (filebin.read(((char*)afifo_cont)+ib,2)) {
ib+=2;
if (ib == dataSize)
break;
if (ib==dataSize) break;
}
if (ib>0) {
iframe++;
@ -141,6 +149,12 @@ class moench03T1CtbData : public slsDetectorData<uint16_t> {
}
return NULL;
};
};
#endif

View File

@ -2,12 +2,52 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package
#ifndef MOENCH03T1RECDATANEW_H
#define MOENCH03T1RECDATANEW_H
#include "sls/sls_detector_defs.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 */
#ifndef VERSION_V1
uint64_t packetCaught[8]; /**< is the version number of this structure format */
#endif
} sls_detector_header;
class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
@ -16,27 +56,27 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
double ghost[200][25];
// Single point of definition if we need to customize
using header = sls::defs::sls_receiver_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
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(header)),
nSamples(ns) {
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 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;
@ -62,15 +102,12 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
} else {
row=200+i/sc_width;
}
dataMap[row][col] = sizeof(header) +
(nadc * i + iadc) * 2; //+16*(ip+1);
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)
std::cout << "Error: pointer " << dataMap[row][col]
<< " out of range " << std::endl;
if (dataMap[row][col]<0 || dataMap[row][col]>=nSamples*2*32)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
@ -82,13 +119,13 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
ghost[iy][ix]=0.;
int ipacket;
uint ibyte;
int ibyte;
int ii=0;
for (ibyte = 0; ibyte < sizeof(header) / 2; ibyte++) {
for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){
xmap[ibyte]=-1;
ymap[ibyte]=-1;
}
int off = sizeof(header) / 2;
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;
@ -115,19 +152,35 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
// 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
*/
double getValue(char *data, int ix, int iy = 0) override {
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++){ */
@ -147,8 +200,11 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
/* } */
/* } */
// cout << "*" << endl;
}
virtual void calcGhost(char *data) {
for (int ix=0; ix<25; ix++){
for (int iy=0; iy<200; iy++) {
@ -158,11 +214,10 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
// 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];
if (iy<200) return ghost[iy][ix%25];
if (iy<400) return ghost[399-iy][ix%25];
return 0;
};
@ -174,9 +229,17 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
*/
int getFrameNumber(char *buff) {
return ((header *)buff)->detHeader.frameNumber;
}
/* 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;};
/**
@ -187,36 +250,81 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
*/
int getPacketNumber(char *buff) {
return ((header *)buff)->detHeader.packetNumber;
}
int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
char *readNextFrame(std::ifstream &filebin) override {
/* /\** */
/* 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);
}
};
// not present in base class
virtual char *readNextFrame(std::ifstream &filebin, int &ff) {
virtual char *readNextFrame(ifstream &filebin, int &ff) {
int np=-1;
return readNextFrame(filebin, ff, np);
};
// not present in base class
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &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;
}
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) {
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);
@ -224,30 +332,35 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
return data;
}
}
return nullptr;
}
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
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
*/
char *findNextFrame(char *data, int &ndata, int dsize) override {
if (dsize < dataSize)
ndata = dsize;
else
ndata = dataSize;
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

View File

@ -9,8 +9,7 @@
/**
@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 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
@ -25,13 +24,11 @@
*/
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 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 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 */
@ -41,41 +38,44 @@ typedef struct {
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;
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
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 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,
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;
@ -89,6 +89,7 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
int adc4(0);
int pix;
int off=0;
#ifdef OFF_1
off=1;
@ -109,13 +110,9 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
} 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;
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
@ -177,6 +174,8 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
// cout << "data struct created" << endl;
};
/**
Returns the frame number for the given dataset. Purely virtual func.
@ -193,9 +192,9 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff) {
return ((sls_detector_header *)buff)->frameNumber;
}; //*((int*)(buff+5))&0xffffff;};
int getFrameNumber(char *buff){return ((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
/**
@ -206,35 +205,25 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
*/
int getPacketNumber(char *buff) {
return ((sls_detector_header *)buff)->packetNumber;
} //((*(((int*)(buff+4))))&0xff)+1;};
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 */
/* 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 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 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;}; */
/* 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! */
/* 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 */
/* \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){ */
@ -259,6 +248,7 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
/* return NULL; */
/* }; */
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
@ -272,15 +262,14 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
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;
}
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream & filebin, int &ff, int &np,
char *data) {
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
@ -299,29 +288,36 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
}
}
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
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;
if (dsize<dataSize) ndata=dsize;
else ndata=dataSize;
return data;
}
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
};
#endif

View File

@ -4,21 +4,26 @@
#define MOENCH03T1REORDERED_H
#include "slsDetectorData.h"
class moench03T1ReorderedData : public slsDetectorData<uint16_t> {
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
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) {
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);
@ -36,6 +41,8 @@ class moench03T1ReorderedData : public slsDetectorData<uint16_t> {
// cout << "data struct created" << endl;
};
/**
Returns the frame number for the given dataset. Purely virtual func.
@ -52,32 +59,27 @@ class moench03T1ReorderedData : public slsDetectorData<uint16_t> {
/* 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 */
/* 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 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 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;}; */
/* 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! */
/* 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 */
/* \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){ */
@ -102,6 +104,7 @@ class moench03T1ReorderedData : public slsDetectorData<uint16_t> {
/* return NULL; */
/* }; */
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
@ -115,15 +118,14 @@ class moench03T1ReorderedData : public slsDetectorData<uint16_t> {
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;
}
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
char *data) {
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
@ -141,29 +143,36 @@ class moench03T1ReorderedData : public slsDetectorData<uint16_t> {
}
}
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
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;
if (dsize<dataSize) ndata=dsize;
else ndata=dataSize;
return data;
}
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
};
#endif

View File

@ -4,9 +4,12 @@
#define MOENCH03T1ZMQDATA_H
#include "slsDetectorData.h"
class moench03T1ZmqData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
@ -14,24 +17,28 @@ class moench03T1ZmqData : public slsDetectorData<uint16_t> {
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
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) {
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 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;
@ -58,10 +65,8 @@ class moench03T1ZmqData : public slsDetectorData<uint16_t> {
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;
if (dataMap[row][col]<0 || dataMap[row][col]>=8192*40)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
@ -97,10 +102,15 @@ class moench03T1ZmqData : public slsDetectorData<uint16_t> {
}
}
iframe=0;
// cout << "data struct created" << endl;
};
/**
Returns the frame number for the given dataset. Purely virtual func.
@ -117,9 +127,9 @@ class moench03T1ZmqData : public slsDetectorData<uint16_t> {
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff) {
return iframe;
}; //*((int*)(buff+5))&0xffffff;};
int getFrameNumber(char *buff){return iframe;};//*((int*)(buff+5))&0xffffff;};
/**
@ -130,34 +140,25 @@ class moench03T1ZmqData : public slsDetectorData<uint16_t> {
*/
int getPacketNumber(char *buff) {
return 0;
} //((*(((int*)(buff+4))))&0xff)+1;};
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 */
/* 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 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 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;}; */
/* 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! */
/* 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 */
/* \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){ */
@ -182,6 +183,7 @@ class moench03T1ZmqData : public slsDetectorData<uint16_t> {
/* return NULL; */
/* }; */
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
@ -195,21 +197,21 @@ class moench03T1ZmqData : public slsDetectorData<uint16_t> {
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;
}
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
char *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;
@ -221,29 +223,48 @@ class moench03T1ZmqData : public slsDetectorData<uint16_t> {
}
}
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
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;
if (dsize<packetSize*nPackets) ndata=dsize;
else ndata=packetSize*nPackets;
return data;
}
int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
};
#endif

View File

@ -4,9 +4,11 @@
#define MOENCH03T1ZMQDATANEW_H
#include "slsDetectorData.h"
class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
private:
// int iframe;
int nadc;
int sc_width;
@ -14,29 +16,33 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
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
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;
// 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]={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,\
@ -49,7 +55,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
int iadc;
int ix, iy;
// int npackets=40;
int npackets=40;
int i;
int adc4(0);
@ -67,16 +73,15 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
} else {
row=200+i/sc_width;
}
dataMap[row][col] =
(nadc * i + iadc) * 2 + offset; //+16*(ip+1);
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;
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
// }
int ii=0;
for (i=0; i< dataSize; i++) {
@ -103,30 +108,34 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
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
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;*/
/* 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++) { */
@ -142,6 +151,8 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
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++){ */
@ -160,8 +171,11 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
/* } */
/* } */
// cout << "*" << endl;
}
virtual void calcGhost(char *data) {
for (int ix=0; ix<25; ix++){
for (int iy=0; iy<200; iy++) {
@ -171,14 +185,14 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
// 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];
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.
@ -195,9 +209,9 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff) {
return *((int *)buff);
}; //*((int*)(buff+5))&0xffffff;};
int getFrameNumber(char *buff){return *((int*)buff);};//*((int*)(buff+5))&0xffffff;};
/**
@ -208,34 +222,25 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
*/
int getPacketNumber(char *buff) {
return 0;
} //((*(((int*)(buff+4))))&0xff)+1;};
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 */
/* 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 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 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;}; */
/* 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! */
/* 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 */
/* \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){ */
@ -260,34 +265,35 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
/* return NULL; */
/* }; */
virtual char *readNextFrame(std::ifstream &filebin) {
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(std::ifstream &filebin, int &ff) {
virtual char *readNextFrame(ifstream &filebin, int &ff) {
int np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &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;
}
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np,
char *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;
@ -299,31 +305,50 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
}
}
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
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;
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

View File

@ -4,25 +4,31 @@
#define MOENCH03TCTBDATA_H
#include "slsDetectorData.h"
class moench03TCtbData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
int sc_height;
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
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) {
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;
@ -30,15 +36,21 @@ class moench03TCtbData : public slsDetectorData<uint16_t> {
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};
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]={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);
@ -49,8 +61,8 @@ class moench03TCtbData : public slsDetectorData<uint16_t> {
}
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;
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
int adc4;
@ -68,6 +80,8 @@ class moench03TCtbData : public slsDetectorData<uint16_t> {
xmap[i]=adc_nr[iadc]+ix;
ymap[i]=ny/2+iy;
}
}
/* for (int i=0; i<nx*ny; i++) { */
@ -83,12 +97,18 @@ class moench03TCtbData : public slsDetectorData<uint16_t> {
/* ymap[i]=ny/2+iy; */
/* } */
/* } */
iframe=0;
// cout << "data struct created" << endl;
};
/**
Returns the frame number for the given dataset. Purely virtual func.
@ -97,10 +117,8 @@ class moench03TCtbData : public slsDetectorData<uint16_t> {
*/
virtual int getFrameNumber(char *buff) {
(void)buff;
return iframe;
};
virtual int getFrameNumber(char *buff){(void)buff; return iframe;};
/**
@ -115,28 +133,21 @@ class moench03TCtbData : public slsDetectorData<uint16_t> {
/**
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
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;
};
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
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){
@ -147,8 +158,7 @@ class moench03TCtbData : public slsDetectorData<uint16_t> {
afifo_cont=new uint16_t[dataSize/2];
while (filebin.read(((char*)afifo_cont)+ib,2)) {
ib+=2;
if (ib == dataSize)
break;
if (ib==dataSize) break;
}
if (ib>0) {
iframe++;
@ -161,6 +171,12 @@ class moench03TCtbData : public slsDetectorData<uint16_t> {
}
return NULL;
};
};
#endif

View File

@ -8,8 +8,7 @@
/**
@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 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
@ -24,13 +23,11 @@
*/
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 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 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 */
@ -38,14 +35,17 @@ typedef struct {
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 */
uint64_t packetCaught[8]; /**< is the version number of this structure format */
} sls_detector_header;
class moench04CtbReceiver10GbData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
@ -53,25 +53,25 @@ class moench04CtbReceiver10GbData : public slsDetectorData<uint16_t> {
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
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) {
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 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;
@ -99,17 +99,11 @@ class moench04CtbReceiver10GbData : public slsDetectorData<uint16_t> {
row=200+i/sc_width;
}
if (nds>0)
dataMap[row][col] =
sizeof(sls_detector_header) +
((nadc + 4) * i + iadc) * 2; //+16*(ip+1);
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;
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;
}
}
}
@ -126,6 +120,7 @@ class moench04CtbReceiver10GbData : public slsDetectorData<uint16_t> {
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
/* i=ipacket*8208/2+ibyte; */
@ -152,6 +147,8 @@ class moench04CtbReceiver10GbData : public slsDetectorData<uint16_t> {
// cout << "data struct created" << endl;
};
/**
Returns the frame number for the given dataset. Purely virtual func.
@ -168,9 +165,9 @@ class moench04CtbReceiver10GbData : public slsDetectorData<uint16_t> {
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff) {
return ((sls_detector_header *)buff)->frameNumber;
}; //*((int*)(buff+5))&0xffffff;};
int getFrameNumber(char *buff){return ((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
/**
@ -181,34 +178,25 @@ class moench04CtbReceiver10GbData : public slsDetectorData<uint16_t> {
*/
int getPacketNumber(char *buff) {
return ((sls_detector_header *)buff)->packetNumber;
} //((*(((int*)(buff+4))))&0xff)+1;};
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 */
/* 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 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 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;}; */
/* 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! */
/* 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 */
/* \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){ */
@ -233,6 +221,7 @@ class moench04CtbReceiver10GbData : public slsDetectorData<uint16_t> {
/* return NULL; */
/* }; */
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
@ -246,15 +235,14 @@ class moench04CtbReceiver10GbData : public slsDetectorData<uint16_t> {
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;
}
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
char *data) {
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
@ -273,29 +261,36 @@ class moench04CtbReceiver10GbData : public slsDetectorData<uint16_t> {
}
}
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
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;
if (dsize<dataSize) ndata=dsize;
else ndata=dataSize;
return data;
}
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
};
#endif

View File

@ -8,8 +8,7 @@
/**
@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 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
@ -24,13 +23,11 @@
*/
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 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 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 */
@ -38,14 +35,17 @@ typedef struct {
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 */
uint64_t packetCaught[8]; /**< is the version number of this structure format */
} sls_detector_header;
class moench04CtbReceiverData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
@ -53,25 +53,25 @@ class moench04CtbReceiverData : public slsDetectorData<uint16_t> {
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
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) {
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 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;
@ -98,13 +98,9 @@ class moench04CtbReceiverData : public slsDetectorData<uint16_t> {
} 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;
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;
}
}
}
@ -121,6 +117,7 @@ class moench04CtbReceiverData : public slsDetectorData<uint16_t> {
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
/* i=ipacket*8208/2+ibyte; */
@ -147,6 +144,8 @@ class moench04CtbReceiverData : public slsDetectorData<uint16_t> {
// cout << "data struct created" << endl;
};
/**
Returns the frame number for the given dataset. Purely virtual func.
@ -163,9 +162,9 @@ class moench04CtbReceiverData : public slsDetectorData<uint16_t> {
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff) {
return ((sls_detector_header *)buff)->frameNumber;
}; //*((int*)(buff+5))&0xffffff;};
int getFrameNumber(char *buff){return ((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
/**
@ -176,34 +175,25 @@ class moench04CtbReceiverData : public slsDetectorData<uint16_t> {
*/
int getPacketNumber(char *buff) {
return ((sls_detector_header *)buff)->packetNumber;
} //((*(((int*)(buff+4))))&0xff)+1;};
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 */
/* 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 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 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;}; */
/* 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! */
/* 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 */
/* \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){ */
@ -228,6 +218,7 @@ class moench04CtbReceiverData : public slsDetectorData<uint16_t> {
/* return NULL; */
/* }; */
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
@ -241,15 +232,14 @@ class moench04CtbReceiverData : public slsDetectorData<uint16_t> {
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;
}
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
char *data) {
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
@ -268,29 +258,36 @@ class moench04CtbReceiverData : public slsDetectorData<uint16_t> {
}
}
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
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;
if (dsize<dataSize) ndata=dsize;
else ndata=dataSize;
return data;
}
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
};
#endif

View File

@ -3,64 +3,70 @@
#ifndef 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
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*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) {
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
/* 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; */
cout << "off is " << off << endl;
/* new slsDetectorData<uint16_t>(400, 400, ds); */
if (off>0)
cout << "M04 RAW 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 };
/*
iadc=ptr%32
isample=ptr/32
col=(adc_nr[iadc]%16)*25+isample%25
if (adc_nr[iadc]<16)
row=199-isample/25;
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};
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)
*/
int row, col;
@ -87,52 +93,72 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
row=200+i/sc_width;
}
if (nds>0)
dataMap[row][col] =
((nadc + 4) * i + iadc) * 2 + off; //+16*(ip+1);
dataMap[row][col]=((nadc+4)*i+iadc)*2;//+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;
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 (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;
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 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 (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;
// cout << isc << " " << ibit[isc] << " " << isample << hex << sample << dec << endl;
if (sample & (1<<ibit[isc]))
return 1;
else
@ -157,12 +183,9 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff) {
#ifdef RAWDATA
return ((slsDetectorDefs::sls_receiver_header *)buff)->detHeader.frameNumber;
#endif
return (int)(*buff);
};
int getFrameNumber(char *buff){return iframe;};//((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
/**
@ -173,14 +196,48 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
*/
int getPacketNumber(char *buff) {
#ifdef RAWDATA
return ((slsDetectorDefs::sls_receiver_header *)buff)->detHeader.packetNumber;
#endif
return 0;
//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) {
@ -196,19 +253,15 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
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;
}
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream & filebin, int &ff, int &np,
char *data) {
// char *retval=0;
#ifndef RAWDATA
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
// char *retval=0;
// int nd;
// int fnum = -1;
np=0;
@ -226,51 +279,36 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
}
}
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
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;
if (dsize<dataSize) ndata=dsize;
else ndata=dataSize;
return data;
}
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
};
#endif
#endif

View File

@ -4,9 +4,13 @@
#define MOENCH04ZMQDATA_H
#include "slsDetectorData.h"
class moench04CtbZmqData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
@ -14,20 +18,22 @@ class moench04CtbZmqData : public slsDetectorData<uint16_t> {
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
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
*/
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) {
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 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;
@ -54,14 +60,13 @@ class moench04CtbZmqData : public slsDetectorData<uint16_t> {
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;
if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
/* for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){ */
/* xmap[ibyte]=-1; */
/* ymap[ibyte]=-1; */
@ -70,6 +75,7 @@ class moench04CtbZmqData : public slsDetectorData<uint16_t> {
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
/* i=ipacket*8208/2+ibyte; */
@ -101,28 +107,22 @@ class moench04CtbZmqData : public slsDetectorData<uint16_t> {
int irow;
int isc=x/sc_width;
int icol=x%sc_width;
if (y < 200)
irow = sc_height - 1 - y;
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 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 (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;
// cout << isc << " " << ibit[isc] << " " << isample << hex << sample << dec << endl;
if (sample & (1<<ibit[isc]))
return 1;
else
@ -147,9 +147,9 @@ class moench04CtbZmqData : public slsDetectorData<uint16_t> {
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff) {
return iframe;
}; //((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
int getFrameNumber(char *buff){return iframe;};//((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
/**
@ -160,33 +160,25 @@ class moench04CtbZmqData : public slsDetectorData<uint16_t> {
*/
// int getPacketNumber(char *buff){return
// ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
//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 */
/* 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 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 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;}; */
/* 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! */
/* 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 */
/* \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){ */
@ -211,6 +203,7 @@ class moench04CtbZmqData : public slsDetectorData<uint16_t> {
/* return NULL; */
/* }; */
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
@ -224,15 +217,14 @@ class moench04CtbZmqData : public slsDetectorData<uint16_t> {
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;
}
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np,
char *data) {
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
// char *retval=0;
//int nd;
//int fnum = -1;
@ -251,29 +243,36 @@ class moench04CtbZmqData : public slsDetectorData<uint16_t> {
}
}
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
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;
if (dsize<dataSize) ndata=dsize;
else ndata=dataSize;
return data;
}
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
};
#endif

View File

@ -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

View File

@ -3,158 +3,52 @@
#ifndef SLSDETECTORDATA_H
#define SLSDETECTORDATA_H
#include <fstream>
#include <inttypes.h>
#include <iostream>
#include <fstream>
template <class dataType> class slsDetectorData {
using namespace std;
template <class dataType>
class slsDetectorData {
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 **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).
General slsDetectors data structure. Works for data acquired using the slsDetectorReceiver. Can be generalized to other detectors (many virtual funcs).
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);
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;
/**
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
\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.
*/
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) {
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];
orderedData=new dataType*[ny];
dataMap=new int*[ny];
dataMask=new dataType*[ny];
@ -166,6 +60,7 @@ slsDetectorData<dataType>::slsDetectorData(int npx, int npy, int dsize,
dataROIMask[i] = new int[nx];
for (int j=0; j<nx; j++)
dataROIMask[i][j]=1;
}
for (int ip=0; ip<el; ip++){
@ -176,9 +71,10 @@ slsDetectorData<dataType>::slsDetectorData(int npx, int npy, int dsize,
setDataMap(dMap);
setDataMask(dMask);
setDataROIMask(dROI);
}
template <typename dataType> slsDetectorData<dataType>::~slsDetectorData() {
virtual ~slsDetectorData() {
for(int i = 0; i < ny; i++) {
delete [] dataMap[i];
delete [] dataMask[i];
@ -191,10 +87,14 @@ template <typename dataType> slsDetectorData<dataType>::~slsDetectorData() {
delete [] orderedData;
delete [] xmap;
delete [] ymap;
}
};
template <typename dataType>
void slsDetectorData<dataType>::setDataMap(int **dMap) {
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;
@ -226,10 +126,16 @@ void slsDetectorData<dataType>::setDataMap(int **dMap) {
}
// cout << "nx:" <<nx << " ny:" << ny << endl;
}
template <typename dataType>
void slsDetectorData<dataType>::setDataMask(dataType **dMask) {
};
/**
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){
if (dMask!=NULL) {
@ -241,10 +147,14 @@ void slsDetectorData<dataType>::setDataMask(dataType **dMask) {
for (int ix=0; ix<nx; ix++)
dataMask[iy][ix]=0;
}
}
};
/**
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){
template <typename dataType>
void slsDetectorData<dataType>::setDataROIMask(int **dROI) {
if (dROI!=NULL) {
for (int iy=0; iy<ny; iy++)
@ -255,39 +165,46 @@ void slsDetectorData<dataType>::setDataROIMask(int **dROI) {
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++)
dataROIMask[iy][ix]=1;
}
}
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);
}
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;
}
/**
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;};
template <typename dataType>
void slsDetectorData<dataType>::getPixel(int ip, int &x, int &y) {
x = xmap[ip];
y = ymap[ip];
}
/**
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;};
template <typename dataType>
dataType **slsDetectorData<dataType>::getData(char *ptr, int dsize) {
/** 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;};
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;
@ -296,8 +213,7 @@ dataType **slsDetectorData<dataType>::getData(char *ptr, int dsize) {
// data[i]=new dataType[nx];
//}
isOrdered=0;
if (dsize <= 0 || dsize > dataSize)
dsize = dataSize;
if (dsize<=0 || dsize>dataSize) dsize=dataSize;
for (int ip=0; ip<(el); ip++) {
getPixel(ip,ix,iy);
@ -310,8 +226,9 @@ dataType **slsDetectorData<dataType>::getData(char *ptr, int dsize) {
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;
@ -320,8 +237,7 @@ double **slsDetectorData<dataType>::getImage(char *ptr, int dsize) {
data[i]=new double[nx];
}
int el=dsize/sizeof(dataType);
if (dsize <= 0 || dsize > dataSize)
dsize = dataSize;
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) {
@ -329,12 +245,21 @@ double **slsDetectorData<dataType>::getImage(char *ptr, int dsize) {
}
}
return data;
}
template <typename dataType>
dataType slsDetectorData<dataType>::getChannel(char *data, int ix, int iy) {
};
/**
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) {
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)));
@ -344,4 +269,80 @@ dataType slsDetectorData<dataType>::getChannel(char *data, int ix, int iy) {
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

View File

@ -9,10 +9,11 @@
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.
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!)
@ -20,48 +21,43 @@ Constructor (no error checking if datasize and offsets are compatible!)
\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.
\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.
*/
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){};
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) {};
/**
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 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
*/
virtual int getFrameNumber(char *buff) {
return ((*(int *)buff) & (0xffffff00)) >> 8;
};
virtual int getFrameNumber(char *buff){return ((*(int*)buff)&(0xffffff00))>>8;};
/**
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
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 getPacketNumber(char *buff){return (*(int*)buff)&0xff;};
/**
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 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
*/
@ -75,8 +71,7 @@ good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
//cout <<"fnum:"<<fn<<" pnum:"<<pnum<<" np:"<< np << "\t";
if (pnum<1 || pnum>nPackets) {
// cout << "Bad packet number " << pnum << " frame "<< fn <<
// endl;
//cout << "Bad packet number " << pnum << " frame "<< fn << endl;
retval=NULL;
np=0;
} else if (pnum==1) {
@ -87,8 +82,7 @@ good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
fnum=fn;
} else if (fn!=fnum) {
if (fnum!=-1) {
/* cout << " **Incomplete frame number " << fnum << " pnum "
* << pnum << " " << getFrameNumber(p) << endl;*/
/* cout << " **Incomplete frame number " << fnum << " pnum " << pnum << " " << getFrameNumber(p) << endl;*/
retval=NULL;
}
np=0;
@ -97,30 +91,24 @@ good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
dd+=packetSize;
np++;
//cout <<"fnum:"<<fn<<" pnum:"<<pnum<<" np:"<< np << "\t";
// cout << pnum << " " << fn << " " << np << " " << dd << " " <<
// dsize << endl;
// 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);
//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);
//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);
}
}
@ -131,11 +119,9 @@ good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
/**
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 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
*/
@ -153,6 +139,7 @@ good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
np=nd/packetSize;
// cout << np << endl;
if (retval==data && np==nPackets) {
// cout << "-" << endl;
return data;
@ -164,8 +151,7 @@ good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
} else if (retval!=NULL) {
// cout << "+" << endl;;
for (int ip=0; ip<np; ip++)
memcpy(data + ip * packetSize,
retval + ip * packetSize, packetSize);
memcpy(data+ip*packetSize,retval+ip*packetSize,packetSize);
}
} else if (np>nPackets) {
@ -182,14 +168,13 @@ good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
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)
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
\returns pointer to the first packet of the last good frame, NULL if no frame is found or last frame is incomplete
*/
@ -209,6 +194,7 @@ good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
np=nd/packetSize;
// cout << np << endl;
if (retval==data && np==nPackets) {
// cout << "-" << endl;
return data;
@ -220,8 +206,7 @@ good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
} else if (retval!=NULL) {
// cout << "+" << endl;;
for (int ip=0; ip<np; ip++)
memcpy(data + ip * packetSize,
retval + ip * packetSize, packetSize);
memcpy(data+ip*packetSize,retval+ip*packetSize,packetSize);
}
} else if (np>nPackets) {
@ -239,13 +224,9 @@ good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
return NULL;
};
virtual int *readNextFramewithMissingPackets(ifstream &filebin, int &fnum) {
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* readNextFrameOnlyData(ifstream &filebin, int& fnum) {return NULL;};
virtual int* decodeData(int* datain) {return NULL;};
virtual int getPacketNumber(int x, int y) {return 0;};
@ -254,4 +235,6 @@ good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
const int packetSize; /**< size of a udp packet */
};
#endif

View File

@ -6,23 +6,20 @@
#define MYROOT
#endif
#ifdef MYROOT
#include <TGraphErrors.h>
#include <TMath.h>
#include <TH1F.h>
#include <TH2F.h>
#include <TMath.h>
#include <TGraphErrors.h>
#endif
#include <iostream>
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))
#define ELEM_SWAP(a, b) \
{ \
register int t = (a); \
(a) = (b); \
(b) = t; \
}
#define ELEM_SWAP(a,b) { register int t=(a);(a)=(b);(b)=t; }
using namespace std;
@ -32,8 +29,8 @@ Double_t energyCalibrationFunctions::pedestal(Double_t *x, Double_t *par) {
return par[0]-par[1]*sign*x[0];
}
Double_t energyCalibrationFunctions::gaussChargeSharing(Double_t *x,
Double_t *par) {
Double_t energyCalibrationFunctions::gaussChargeSharing(Double_t *x, Double_t *par) {
Double_t f, arg=0;
// Gaussian exponent
if (par[3]!=0) {
@ -47,15 +44,12 @@ Double_t energyCalibrationFunctions::gaussChargeSharing(Double_t *x,
return par[4]*f+pedestal(x,par);
}
Double_t energyCalibrationFunctions::gaussChargeSharingKb(Double_t *x,
Double_t *par) {
Double_t energyCalibrationFunctions::gaussChargeSharingKb(Double_t *x, Double_t *par) {
Double_t f, arg=0,argb=0;
// Gaussian exponent
if (par[3]!=0) {
arg=sign*(x[0]-par[2])/par[3];
argb = sign * (x[0] - (par[6] * par[2])) /
par[3]; // using absolute kb mean might seem better but like this
// the ratio can be fixed
argb=sign*(x[0]-(par[6]*par[2]))/par[3]; // using absolute kb mean might seem better but like this the ratio can be fixed
}
// the Gaussian
f=TMath::Exp(-1*arg*arg/2.);
@ -67,9 +61,7 @@ Double_t energyCalibrationFunctions::gaussChargeSharingKb(Double_t *x,
return par[4]*f+pedestal(x,par);
}
Double_t
energyCalibrationFunctions::gaussChargeSharingKaDoublet(Double_t *x,
Double_t *par) {
Double_t energyCalibrationFunctions::gaussChargeSharingKaDoublet(Double_t *x, Double_t *par) {
Double_t f, f2, arg=0, arg2=0;
// Gaussian exponent
if (par[3]!=0) {
@ -81,18 +73,14 @@ energyCalibrationFunctions::gaussChargeSharingKaDoublet(Double_t *x,
f2=TMath::Exp(-1*arg2*arg2/2.);
// Gaussian + error function
f=f+par[5]/2.*(TMath::Erfc(arg/(TMath::Sqrt(2.))));
f2 = f2 +
par[5] / 2. *
(TMath::Erfc(arg / (TMath::Sqrt(2.)))); // shouldn't this be arg2?
f2=f2+par[5]/2.*(TMath::Erfc(arg/(TMath::Sqrt(2.)))); // shouldn't this be arg2?
// Gaussian + error function + pedestal
return par[4]*f+par[7]*f2+pedestal(x,par);
}
Double_t energyCalibrationFunctions::gaussChargeSharingPixel(Double_t *x,
Double_t *par) {
Double_t energyCalibrationFunctions::gaussChargeSharingPixel(Double_t *x, Double_t *par) {
Double_t f;
if (par[3] <= 0 || par[2] * (*x) <= 0 || par[5] < 0 || par[4] <= 0)
return 0;
if (par[3]<=0 || par[2]*(*x)<=0 || par[5]<0 || par[4]<=0) return 0;
Double_t pp[3];
@ -100,6 +88,7 @@ Double_t energyCalibrationFunctions::gaussChargeSharingPixel(Double_t *x,
pp[1]=par[2];
pp[2]=par[3];
f=(par[5]-par[6]*(TMath::Log(*x/par[2])))*erfBox(x,pp);
f+=par[4]*TMath::Gaus(*x, par[2], par[3], kTRUE);
return f+pedestal(x,par);
@ -107,6 +96,8 @@ Double_t energyCalibrationFunctions::gaussChargeSharingPixel(Double_t *x,
Double_t energyCalibrationFunctions::erfBox(Double_t *z, Double_t *par) {
Double_t m=par[0];
Double_t M=par[1];
@ -118,39 +109,39 @@ Double_t energyCalibrationFunctions::erfBox(Double_t *z, Double_t *par) {
if (m==M)
return 0;
if (par[2]<=0) {
if (*z>=m && *z<=M)
return 1./(M-m);
else
return 0;
}
return (TMath::Erfc((z[0] - M) / par[2]) -
TMath::Erfc((z[0] - m) / par[2])) *
0.5 / (M - m);
return (TMath::Erfc((z[0]-M)/par[2])-TMath::Erfc((z[0]-m)/par[2]))*0.5/(M-m);
}
// basic erf function
Double_t energyCalibrationFunctions::erfFunction(Double_t *x, Double_t *par) {
double arg=0;
if (par[1] != 0)
arg = (par[0] - x[0]) / par[1];
if (par[1]!=0) arg=(par[0]-x[0])/par[1];
return ((par[2]/2.*(1+TMath::Erf(sign*arg/(TMath::Sqrt(2))))));
};
Double_t energyCalibrationFunctions::erfFunctionChargeSharing(Double_t *x,
Double_t *par) {
Double_t energyCalibrationFunctions::erfFunctionChargeSharing(Double_t *x, Double_t *par) {
Double_t f;
f = erfFunction(x, par + 2) * (1 + par[5] * (par[2] - x[0])) + par[0] -
par[1] * x[0] * sign;
f=erfFunction(x, par+2)*(1+par[5]*(par[2]-x[0]))+par[0]-par[1]*x[0]*sign;
return f;
};
Double_t energyCalibrationFunctions::erfFuncFluo(Double_t *x, Double_t *par) {
Double_t f;
f = erfFunctionChargeSharing(x, par) +
erfFunction(x, par + 6) * (1 + par[9] * (par[6] - x[0]));
f=erfFunctionChargeSharing(x, par)+erfFunction(x, par+6)*(1+par[9]*(par[6]-x[0]));
return f;
};
#endif
@ -177,14 +168,13 @@ double energyCalibrationFunctions::median(double *x, int n) {
return xmed[k];
}
int energyCalibrationFunctions::quick_select(int arr[], int n){
int low, high ;
int median;
int middle, ll, hh;
low = 0;
high = n - 1;
median = (low + high) / 2;
low = 0 ; high = n-1 ; median = (low + high) / 2;
for (;;) {
if (high <= low) /* One element only */
return arr[median] ;
@ -197,12 +187,9 @@ int energyCalibrationFunctions::quick_select(int arr[], int n) {
/* Find median of low, middle and high items; swap into position low */
middle = (low + high) / 2;
if (arr[middle] > arr[high])
ELEM_SWAP(arr[middle], arr[high]);
if (arr[low] > arr[high])
ELEM_SWAP(arr[low], arr[high]);
if (arr[middle] > arr[low])
ELEM_SWAP(arr[middle], arr[low]);
if (arr[middle] > arr[high]) ELEM_SWAP(arr[middle], arr[high]) ;
if (arr[low] > arr[high]) ELEM_SWAP(arr[low], arr[high]) ;
if (arr[middle] > arr[low]) ELEM_SWAP(arr[middle], arr[low]) ;
/* Swap low item (now in position middle) into position (low+1) */
ELEM_SWAP(arr[middle], arr[low+1]) ;
@ -211,12 +198,8 @@ int energyCalibrationFunctions::quick_select(int arr[], int n) {
ll = low + 1;
hh = high;
for (;;) {
do
ll++;
while (arr[low] > arr[ll]);
do
hh--;
while (arr[hh] > arr[low]);
do ll++; while (arr[low] > arr[ll]) ;
do hh--; while (arr[hh] > arr[low]) ;
if (hh < ll)
break;
@ -239,31 +222,27 @@ int energyCalibrationFunctions::kth_smallest(int *a, int n, int k) {
register int i,j,l,m ;
register double x ;
l = 0;
m = n - 1;
l=0 ; m=n-1 ;
while (l<m) {
x=a[k] ;
i=l ;
j=m ;
do {
while (a[i] < x)
i++;
while (x < a[j])
j--;
while (a[i]<x) i++ ;
while (x<a[j]) j-- ;
if (i<=j) {
ELEM_SWAP(a[i],a[j]) ;
i++;
j--;
i++ ; j-- ;
}
} while (i<=j) ;
if (j < k)
l = i;
if (k < i)
m = j;
if (j<k) l=i ;
if (k<i) m=j ;
}
return a[k] ;
}
#ifdef MYROOT
Double_t energyCalibrationFunctions::spectrum(Double_t *x, Double_t *par) {
return gaussChargeSharing(x,par);
@ -273,8 +252,7 @@ Double_t energyCalibrationFunctions::spectrumkb(Double_t *x, Double_t *par) {
return gaussChargeSharingKb(x,par);
}
Double_t energyCalibrationFunctions::spectrumkadoublet(Double_t *x,
Double_t *par) {
Double_t energyCalibrationFunctions::spectrumkadoublet(Double_t *x, Double_t *par) {
return gaussChargeSharingKaDoublet(x,par);
}
@ -282,66 +260,65 @@ Double_t energyCalibrationFunctions::spectrumPixel(Double_t *x, Double_t *par) {
return gaussChargeSharingPixel(x,par);
}
Double_t energyCalibrationFunctions::scurve(Double_t *x, Double_t *par) {
return erfFunctionChargeSharing(x,par);
}
Double_t energyCalibrationFunctions::scurveFluo(Double_t *x, Double_t *par) {
return erfFuncFluo(x,par);
}
#endif
energyCalibration::energyCalibration()
:
energyCalibration::energyCalibration() :
#ifdef MYROOT
fit_min(-1), fit_max(-1), bg_offset(-1), bg_slope(-1), flex(-1),
noise(-1), ampl(-1), cs_slope(-1), kb_mean(-1), kb_frac(-1), mean2(-1),
ampl2(-1), fscurve(NULL), fspectrum(NULL), fspectrumkb(NULL),
fit_min(-1),
fit_max(-1),
bg_offset(-1),
bg_slope(-1),
flex(-1),
noise(-1),
ampl(-1),
cs_slope(-1),
kb_mean(-1),
kb_frac(-1),
mean2(-1),
ampl2(-1),
fscurve(NULL),
fspectrum(NULL),
fspectrumkb(NULL),
fspectrumkadoublet(NULL),
#endif
funcs(NULL), plot_flag(1), // fit parameters output to screen
cs_flag(1) {
funcs(NULL),
plot_flag(1), // fit parameters output to screen
cs_flag(1)
{
#ifdef MYROOT
funcs=new energyCalibrationFunctions();
fscurve = new TF1("fscurve", funcs, &energyCalibrationFunctions::scurve, 0,
1000, 6, "energyCalibrationFunctions", "scurve");
fscurve->SetParNames("Background Offset", "Background Slope",
"Inflection Point", "Noise RMS", "Number of Photons",
"Charge Sharing Slope");
fscurve=new TF1("fscurve",funcs,&energyCalibrationFunctions::scurve,0,1000,6,"energyCalibrationFunctions","scurve");
fscurve->SetParNames("Background Offset","Background Slope","Inflection Point","Noise RMS", "Number of Photons","Charge Sharing Slope");
fspectrum =
new TF1("fspectrum", funcs, &energyCalibrationFunctions::spectrum, 0,
1000, 6, "energyCalibrationFunctions", "spectrum");
fspectrum->SetParNames("Background Pedestal", "Background slope",
"Peak position", "Noise RMS", "Number of Photons",
"Charge Sharing Pedestal");
fspectrumkb =
new TF1("fspectrumkb", funcs, &energyCalibrationFunctions::spectrumkb,
0, 1000, 8, "energyCalibrationFunctions", "spectrumkb");
fspectrumkb->SetParNames("Background Pedestal", "Background slope",
"Peak position", "Noise RMS", "Number of Photons",
"Charge Sharing Pedestal", "kb mean", "kb frac");
fspectrum=new TF1("fspectrum",funcs,&energyCalibrationFunctions::spectrum,0,1000,6,"energyCalibrationFunctions","spectrum");
fspectrum->SetParNames("Background Pedestal","Background slope", "Peak position","Noise RMS", "Number of Photons","Charge Sharing Pedestal");
fspectrumkb=new TF1("fspectrumkb",funcs,&energyCalibrationFunctions::spectrumkb,0,1000,8,"energyCalibrationFunctions","spectrumkb");
fspectrumkb->SetParNames("Background Pedestal","Background slope", "Peak position","Noise RMS", "Number of Photons","Charge Sharing Pedestal","kb mean","kb frac");
fspectrumkadoublet =
new TF1("fspectrumkadoublet", funcs,
&energyCalibrationFunctions::spectrumkadoublet, 0, 1000, 8,
"energyCalibrationFunctions", "spectrumkadoublet");
fspectrumkadoublet->SetParNames(
"Background Pedestal", "Background slope", "Peak position", "Noise RMS",
"Number of Photons", "Charge Sharing Pedestal", "ka2 mean", "n2");
fspectrumkadoublet=new TF1("fspectrumkadoublet",funcs,&energyCalibrationFunctions::spectrumkadoublet,0,1000,8,"energyCalibrationFunctions","spectrumkadoublet");
fspectrumkadoublet->SetParNames("Background Pedestal","Background slope", "Peak position","Noise RMS", "Number of Photons","Charge Sharing Pedestal","ka2 mean","n2");
fspixel =
new TF1("fspixel", funcs, &energyCalibrationFunctions::spectrumPixel, 0,
1000, 7, "energyCalibrationFunctions", "spectrumPixel");
fspixel->SetParNames("Background Pedestal", "Background slope",
"Peak position", "Noise RMS", "Number of Photons",
"Charge Sharing Pedestal", "Corner");
fspixel=new TF1("fspixel",funcs,&energyCalibrationFunctions::spectrumPixel,0,1000,7,"energyCalibrationFunctions","spectrumPixel");
fspixel->SetParNames("Background Pedestal","Background slope", "Peak position","Noise RMS", "Number of Photons","Charge Sharing Pedestal","Corner");
#endif
}
void energyCalibration::fixParameter(int ip, Double_t val){
fscurve->FixParameter(ip, val);
@ -350,6 +327,7 @@ void energyCalibration::fixParameter(int ip, Double_t val) {
fspectrumkadoublet->FixParameter(ip, val);
}
void energyCalibration::releaseParameter(int ip){
fscurve->ReleaseParameter(ip);
@ -358,6 +336,12 @@ void energyCalibration::releaseParameter(int ip) {
fspectrumkadoublet->ReleaseParameter(ip);
}
energyCalibration::~energyCalibration(){
#ifdef MYROOT
delete fscurve;
@ -365,12 +349,16 @@ energyCalibration::~energyCalibration() {
delete fspectrumkb;
delete fspectrumkadoublet;
#endif
}
#ifdef MYROOT
TH1F *energyCalibration::createMedianHistogram(TH2F *h2, int ch0, int nch,
int direction) {
TH1F* energyCalibration::createMedianHistogram(TH2F* h2, int ch0, int nch, int direction) {
if (h2==NULL || nch==0)
return NULL;
@ -381,8 +369,7 @@ TH1F *energyCalibration::createMedianHistogram(TH2F *h2, int ch0, int nch,
double val=-1;
if (direction==0) {
h1 = new TH1F("median", "Median", h2->GetYaxis()->GetNbins(),
h2->GetYaxis()->GetXmin(), h2->GetYaxis()->GetXmax());
h1=new TH1F("median","Median",h2->GetYaxis()->GetNbins(),h2->GetYaxis()->GetXmin(),h2->GetYaxis()->GetXmax());
for (int ib=0; ib<h1->GetXaxis()->GetNbins(); ib++) {
for (int ich=0; ich<nch; ich++) {
x[ich]=h2->GetBinContent(ch0+ich+1,ib+1);
@ -391,8 +378,7 @@ TH1F *energyCalibration::createMedianHistogram(TH2F *h2, int ch0, int nch,
h1->SetBinContent(ib+1,val);
}
} else if (direction==1) {
h1 = new TH1F("median", "Median", h2->GetXaxis()->GetNbins(),
h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax());
h1=new TH1F("median","Median",h2->GetXaxis()->GetNbins(),h2->GetXaxis()->GetXmin(),h2->GetXaxis()->GetXmax());
for (int ib=0; ib<h1->GetYaxis()->GetNbins(); ib++) {
for (int ich=0; ich<nch; ich++) {
x[ich]=h2->GetBinContent(ib+1,ch0+ich+1);
@ -404,8 +390,22 @@ TH1F *energyCalibration::createMedianHistogram(TH2F *h2, int ch0, int nch,
delete [] x;
return h1;
}
void energyCalibration::setStartParameters(Double_t *par){
bg_offset=par[0];
bg_slope=par[1];
@ -441,6 +441,7 @@ void energyCalibration::setStartParametersKaDoublet(Double_t *par) {
//fit_max = 800;
}
void energyCalibration::getStartParameters(Double_t *par){
par[0]=bg_offset;
par[1]=bg_slope;
@ -472,6 +473,7 @@ int energyCalibration::setChargeSharing(int p) {
return cs_flag;
}
#ifdef MYROOT
void energyCalibration::initFitFunction(TF1 *fun, TH1 *h1) {
@ -485,29 +487,32 @@ void energyCalibration::initFitFunction(TF1 *fun, TH1 *h1) {
if (min==-1)
min=h1->GetXaxis()->GetXmin();
if (bg_offset==-1)
mypar[0]=0;
else
mypar[0]=bg_offset;
if (bg_slope==-1)
mypar[1]=0;
else
mypar[1]=bg_slope;
if (flex==-1)
mypar[2]=(min+max)/2.;
else
mypar[2]=flex;
if (noise==-1)
mypar[3]=0.1;
else
mypar[3]=noise;
if (ampl==-1)
mypar[4] =
h1->GetBinContent(h1->GetXaxis()->FindBin(0.5 * (max + min)));
mypar[4]=h1->GetBinContent(h1->GetXaxis()->FindBin(0.5*(max+min)));
else
mypar[4]=ampl;
@ -519,6 +524,7 @@ void energyCalibration::initFitFunction(TF1 *fun, TH1 *h1) {
fun->SetParameters(mypar);
fun->SetRange(min,max);
}
void energyCalibration::initFitFunctionKb(TF1 *fun, TH1 *h1) {
@ -533,29 +539,32 @@ void energyCalibration::initFitFunctionKb(TF1 *fun, TH1 *h1) {
if (min==-1)
min=h1->GetXaxis()->GetXmin();
if (bg_offset==-1)
mypar[0]=0;
else
mypar[0]=bg_offset;
if (bg_slope==-1)
mypar[1]=0;
else
mypar[1]=bg_slope;
if (flex==-1)
mypar[2]=(min+max)/2.;
else
mypar[2]=flex;
if (noise==-1)
mypar[3]=0.1;
else
mypar[3]=noise;
if (ampl==-1)
mypar[4] =
h1->GetBinContent(h1->GetXaxis()->FindBin(0.5 * (max + min)));
mypar[4]=h1->GetBinContent(h1->GetXaxis()->FindBin(0.5*(max+min)));
else
mypar[4]=ampl;
@ -577,6 +586,7 @@ void energyCalibration::initFitFunctionKb(TF1 *fun, TH1 *h1) {
fun->SetParameters(mypar);
fun->SetRange(min,max);
}
void energyCalibration::initFitFunctionKaDoublet(TF1 *fun, TH1 *h1) {
@ -591,29 +601,32 @@ void energyCalibration::initFitFunctionKaDoublet(TF1 *fun, TH1 *h1) {
if (min==-1)
min=h1->GetXaxis()->GetXmin();
if (bg_offset==-1)
mypar[0]=0;
else
mypar[0]=bg_offset;
if (bg_slope==-1)
mypar[1]=0;
else
mypar[1]=bg_slope;
if (flex==-1)
mypar[2]=(min+max)/2.;
else
mypar[2]=flex;
if (noise==-1)
mypar[3]=0.1;
else
mypar[3]=noise;
if (ampl==-1)
mypar[4] =
h1->GetBinContent(h1->GetXaxis()->FindBin(0.5 * (max + min)));
mypar[4]=h1->GetBinContent(h1->GetXaxis()->FindBin(0.5*(max+min)));
else
mypar[4]=ampl;
@ -635,10 +648,11 @@ void energyCalibration::initFitFunctionKaDoublet(TF1 *fun, TH1 *h1) {
fun->SetParameters(mypar);
fun->SetRange(min,max);
}
TF1 *energyCalibration::fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar,
Double_t *emypar) {
TF1* energyCalibration::fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar) {
TF1* fitfun;
@ -659,8 +673,8 @@ TF1 *energyCalibration::fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar,
return fitfun;
}
TF1 *energyCalibration::fitFunctionKb(TF1 *fun, TH1 *h1, Double_t *mypar,
Double_t *emypar) {
TF1* energyCalibration::fitFunctionKb(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar) {
TF1* fitfun;
@ -681,8 +695,8 @@ TF1 *energyCalibration::fitFunctionKb(TF1 *fun, TH1 *h1, Double_t *mypar,
return fitfun;
}
TF1 *energyCalibration::fitFunctionKaDoublet(TF1 *fun, TH1 *h1, Double_t *mypar,
Double_t *emypar) {
TF1* energyCalibration::fitFunctionKaDoublet(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar) {
TF1* fitfun;
@ -695,6 +709,7 @@ TF1 *energyCalibration::fitFunctionKaDoublet(TF1 *fun, TH1 *h1, Double_t *mypar,
} else
h1->Fit(fname,"R0Q");
fitfun= h1->GetFunction(fname);
fitfun->GetParameters(mypar);
for (int ip=0; ip<8; ip++) {
@ -708,27 +723,27 @@ TF1 *energyCalibration::fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar) {
return fitFunction(fscurve, h1, mypar, emypar);
}
TF1 *energyCalibration::fitSpectrum(TH1 *h1, Double_t *mypar,
Double_t *emypar) {
TF1* energyCalibration::fitSpectrum(TH1 *h1, Double_t *mypar, Double_t *emypar) {
initFitFunction(fspectrum,h1);
return fitFunction(fspectrum, h1, mypar, emypar);
}
TF1 *energyCalibration::fitSpectrumKb(TH1 *h1, Double_t *mypar,
Double_t *emypar) {
TF1* energyCalibration::fitSpectrumKb(TH1 *h1, Double_t *mypar, Double_t *emypar) {
initFitFunctionKb(fspectrumkb,h1);
return fitFunctionKb(fspectrumkb, h1, mypar, emypar);
}
TF1 *energyCalibration::fitSpectrumKaDoublet(TH1 *h1, Double_t *mypar,
Double_t *emypar) {
TF1* energyCalibration::fitSpectrumKaDoublet(TH1 *h1, Double_t *mypar, Double_t *emypar) {
initFitFunctionKaDoublet(fspectrumkadoublet,h1);
return fitFunctionKaDoublet(fspectrumkadoublet, h1, mypar, emypar);
}
TGraphErrors *energyCalibration::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) {
TGraphErrors* energyCalibration::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) {
TGraphErrors *gr;
@ -755,17 +770,15 @@ TGraphErrors *energyCalibration::linearCalibration(
return gr;
}
TGraphErrors *energyCalibration::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) {
TGraphErrors* energyCalibration::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) {
TH1F *h;
Double_t mypar[6], emypar[6];
Double_t fl[nscan], efl[nscan];
for (int ien=0; ien<nscan; ien++) {
h=h1[ien];
if (integral)
@ -777,6 +790,11 @@ TGraphErrors *energyCalibration::calibrate(int nscan, Double_t *en,
efl[ien]=emypar[2];
}
return linearCalibration(nscan,en,een,fl,efl,gain,off, egain, eoff);
}
#endif

View File

@ -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 */
/**
\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
@ -60,28 +66,21 @@ 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);};
/** 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
/**
@ -98,8 +97,7 @@ class energyCalibrationFunctions {
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])
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);
@ -111,8 +109,7 @@ class energyCalibrationFunctions {
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])
par[5] is the fractional height of the charge sharing pedestal (scales with par[3])
*/
Double_t gaussChargeSharingPixel(Double_t *x, Double_t *par);
@ -130,8 +127,7 @@ class energyCalibrationFunctions {
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])
par[5] is the angual coefficient of the charge sharing slope (scales with par[3])
*/
Double_t erfFunctionChargeSharing(Double_t *x, Double_t *par);
@ -141,59 +137,64 @@ class energyCalibrationFunctions {
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])
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);
/**
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]
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]
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])
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])
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);
@ -208,6 +209,8 @@ class energyCalibrationFunctions {
private:
int sign;
};
/**
@ -217,16 +220,15 @@ class energyCalibrationFunctions {
class energyCalibration {
public:
/**
default constructor - creates the function with which the s-curves
will be fitted
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
default destructor - deletes the function with which the s-curves will be fitted
*/
~energyCalibration();
@ -234,17 +236,11 @@ class energyCalibration {
\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);};
@ -254,6 +250,7 @@ class energyCalibration {
*/
int setChargeSharing(int p=-1);
void fixParameter(int ip, Double_t val);
void releaseParameter(int ip);
@ -261,35 +258,28 @@ class energyCalibration {
#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
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);
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;
};
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;
};
void getFitRange(Double_t &mi, Double_t &ma){mi=fit_min; ma=fit_max;};
/** set start parameters for the s-curve function
\param par parameters, -1 sets to auto-calculation
@ -298,8 +288,7 @@ class energyCalibration {
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
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);
@ -312,8 +301,7 @@ class energyCalibration {
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
par[5] is the angual coefficient of the charge sharing slope (scales with par[3]) -- always positive
*/
void getStartParameters(Double_t *par);
@ -322,23 +310,23 @@ class energyCalibration {
\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
\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);
/**
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
\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
@ -352,10 +340,7 @@ class energyCalibration {
\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);
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
@ -369,11 +354,7 @@ class energyCalibration {
\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);
};
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
@ -387,14 +368,12 @@ class energyCalibration {
\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);
};
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:
#ifdef MYROOT
/**
calculates gain and offset for the set of energies
@ -409,16 +388,13 @@ class energyCalibration {
\param integral 1 is an s-curve set (default), 0 spectra
\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
*/
@ -426,25 +402,24 @@ class energyCalibration {
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
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 *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 */
@ -461,8 +436,7 @@ class energyCalibration {
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 *fspectrumkadoublet; /**< function with which the spectrum will be fitted */
TF1 *fspixel; /**< function with which the spectrum will be fitted */
@ -471,8 +445,27 @@ class energyCalibration {
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

View File

@ -3,19 +3,19 @@
#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*/
public:
/** constructor
\param xt crosstalk
*/
ghostSummation(slsDetectorData<dataType> *d, double xt)
: xtalk(xt), det(d), nx(1), ny(1) {
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];
@ -28,18 +28,18 @@ template <class dataType> class ghostSummation {
ny=1;
det->getDetectorSize(nx,ny);
ghost=new double[nx*ny];
}
virtual ~ghostSummation() { delete[] ghost; };
virtual ghostSummation *Clone() { return new ghostSummation(this); }
}
~ghostSummation() {delete [] ghost;};
virtual ghostSummation *Clone() {
return new ghostSummation(this);
}
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++)
@ -48,8 +48,7 @@ template <class dataType> class ghostSummation {
}
virtual double getGhost(int ix, int iy) {
if (ix < 0 || ix >= nx || iy < 0 || iy >= ny)
return 0;
if (ix<0 || ix>=nx || iy<0 || iy>=ny) return 0;
return ghost[iy*nx+ix];
}
@ -58,6 +57,11 @@ template <class dataType> class ghostSummation {
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