mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 23:37:14 +02:00
Compare commits
17 Commits
2023.03.13
...
actions
Author | SHA1 | Date | |
---|---|---|---|
a475f14c68 | |||
805fa12705 | |||
17ec888ff4 | |||
acb2df8dc7 | |||
0c474ac140 | |||
9de917e5f2 | |||
a5fdd3ef46 | |||
e8a7f65ad8 | |||
b67c6dea08 | |||
c9215a6d9b | |||
1bdf83e101 | |||
1bd813d620 | |||
943a85cbd5 | |||
fc24558314 | |||
d23722a4b7 | |||
bc46d0f6ab | |||
532f76ed4f |
38
.github/workflows/cmake.yml
vendored
Normal file
38
.github/workflows/cmake.yml
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
name: CMake
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||
BUILD_TYPE: Debug
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
|
||||
# You can convert this to a matrix build if you need cross-platform coverage.
|
||||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
|
||||
runs-on: ubuntu-latest
|
||||
name: Configure and build using cmake
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: libzmq3-dev libhdf5-dev qtbase5-dev qt5-qmake libqt5svg5-dev
|
||||
version: 1.0
|
||||
|
||||
- name: Configure CMake
|
||||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DSLS_USE_TESTS=ON -DSLS_USE_HDF5=ON -DSLS_USE_GUI=ON
|
||||
|
||||
- name: Build
|
||||
# Build your program with the given configuration
|
||||
run: cmake --build ${{github.workspace}}/build -j2 --config ${{env.BUILD_TYPE}}
|
||||
|
||||
- name: Test
|
||||
working-directory: ${{github.workspace}}/build
|
||||
# Execute tests defined by the CMake configuration.
|
||||
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
||||
run: ctest -C ${{env.BUILD_TYPE}} -j1
|
||||
|
||||
|
@ -29,7 +29,13 @@ This document describes the differences between v7.x.x and v7.0.0
|
||||
|
||||
|
||||
- moench being made compatible with jungfrau 2.0 boards (jungfrau structure, away from ctb)
|
||||
- eiger febl and feb in versions
|
||||
- rx_hostname and port can be combo to one or to all, or vector or hostnames and ports. ignoring none or empty, then verifying no duplicates for the host port combo including from shared memory
|
||||
- same for hostname and port combo (for virtual servers)
|
||||
- eiger febl and febr in versions, ensure its the same as beb fw version
|
||||
- eiger hardware version fx30 and fx70 (versions command)
|
||||
- fixed rx_arping error
|
||||
- fix hdf5 compilation (detspec fields)
|
||||
- print server version atleast in exception msg when connecting to an older server, also able to add hostname to shm
|
||||
|
||||
|
||||
|
||||
|
@ -230,7 +230,8 @@ class Detector(CppDetectorApi):
|
||||
@element
|
||||
def hardwareversion(self):
|
||||
"""
|
||||
[Jungfrau][Moench][Gotthard2][Myhten3][Gotthard][Ctb] Hardware version of detector.
|
||||
[Jungfrau][Moench][Gotthard2][Myhten3][Gotthard][Ctb] Hardware version of detector. \n
|
||||
[Eiger] Hardware version of front FPGA on detector.
|
||||
"""
|
||||
return self.getHardwareVersion()
|
||||
|
||||
@ -1890,17 +1891,18 @@ class Detector(CppDetectorApi):
|
||||
def versions(self):
|
||||
version_list = {'type': self.type,
|
||||
'package': self.packageversion,
|
||||
'client': self.clientversion,
|
||||
'detectorserver': self.detectorserverversion,
|
||||
'kernel': self.kernelversion}
|
||||
|
||||
'client': self.clientversion}
|
||||
|
||||
if self.type == detectorType.EIGER:
|
||||
version_list ['firmware (Beb)'] = self.firmwareversion
|
||||
version_list ['firmware(Febl)'] = self.getFrontEndFirmwareVersion(slsDetectorDefs.fpgaPosition.FRONT_LEFT)
|
||||
version_list ['firmware (Febr)'] = self.getFrontEndFirmwareVersion(slsDetectorDefs.fpgaPosition.FRONT_RIGHT)
|
||||
else:
|
||||
version_list ['firmware'] = self.firmwareversion
|
||||
version_list ['hardware'] = self.hardwareversion
|
||||
|
||||
version_list ['detectorserver'] = self.detectorserverversion
|
||||
version_list ['kernel'] = self.kernelversion
|
||||
version_list ['hardware'] = self.hardwareversion
|
||||
|
||||
if self.use_receiver:
|
||||
version_list ['receiver'] = self.rx_version
|
||||
|
@ -1097,6 +1097,9 @@ template <class dataType> class analogDetector {
|
||||
return thr;
|
||||
};
|
||||
|
||||
virtual int setClusterSize(int n = -1) {
|
||||
};
|
||||
|
||||
/**
|
||||
gets threshold value for conversion into number of photons
|
||||
\returns threshold value
|
||||
|
@ -2,7 +2,11 @@
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef JUNGFRAULGADSTRIXELDATA_H
|
||||
#define JUNGFRAULGADSTRIXELDATA_H
|
||||
#ifdef CINT
|
||||
#include "sls/sls_detector_defs_CINT.h"
|
||||
#else
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#endif
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
/*
|
||||
@ -32,7 +36,7 @@ typedef struct {
|
||||
uint64_t bunchNumber; /**< is the frame number */
|
||||
uint64_t pre; /**< something */
|
||||
|
||||
} jf_header;
|
||||
} jf_header; //Aldo's header
|
||||
|
||||
|
||||
using namespace std;
|
||||
@ -41,7 +45,11 @@ class jungfrauLGADStrixelsData : public slsDetectorData<uint16_t> {
|
||||
private:
|
||||
int iframe;
|
||||
|
||||
#ifdef ALDO //VH
|
||||
using header = jf_header; //VH
|
||||
#else //VH
|
||||
using header = sls::defs::sls_receiver_header;
|
||||
#endif //VH
|
||||
public:
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read
|
||||
@ -53,6 +61,9 @@ class jungfrauLGADStrixelsData : public slsDetectorData<uint16_t> {
|
||||
: slsDetectorData<uint16_t>(1024/5, 512*5,
|
||||
512 * 1024 * 2 + sizeof(header)) {
|
||||
cout << "aaa" << endl;
|
||||
#ifdef ALDO //VH
|
||||
cout<< "using reduced jf_header" << endl; //VH
|
||||
#endif //VH
|
||||
for (int ix = 0; ix < 1024/5; ix++) {
|
||||
for (int iy = 0; iy < 512*5; iy++) {
|
||||
dataMap[iy][ix] = sizeof(header);//+ ( 1024 * 5 + 300) * 2; //somewhere on the guardring of the LGAD
|
||||
@ -61,44 +72,51 @@ class jungfrauLGADStrixelsData : public slsDetectorData<uint16_t> {
|
||||
#endif
|
||||
}
|
||||
}
|
||||
int x0=256+10, x1=256+246;
|
||||
int y0=10, y1=256-10;
|
||||
|
||||
//chip1
|
||||
/*
|
||||
* TL;DR comments: y0 is too high by 1, group 1 and group 2 are by one row too short
|
||||
* group34 by 2 rows, x is by one column too short
|
||||
* NOTE: If x0, x1, y0 are changed, likely also ox (and oy and ooy) will be affected!
|
||||
*/
|
||||
|
||||
cout << "G0" << endl; //chip coordinates of chip1 group1: x=255+10 to x=255+246, y=10 to y=64
|
||||
//9 pixels guard ring, bonding shift by one pixel in y, one square pixel in x on the left
|
||||
|
||||
int x0=256+10, x1=256+246; //excludes first column (in chip coordinates)
|
||||
int y0=10, y1=256-10; //y1 does nothing
|
||||
int ix,iy;
|
||||
int ox=0, oy=0, ooy=0;
|
||||
ox=0;
|
||||
cout << "G0" << endl;
|
||||
|
||||
//chip1
|
||||
|
||||
for (int ipx=x0; ipx<x1; ipx++) {
|
||||
for (int ipy=y0; ipy<y0+54; ipy++) {
|
||||
for (int ipy=y0; ipy<y0+54; ipy++) { //y0+54 excludes the last row (in chip coordinates), should be y0+55 to include all rows
|
||||
ix=(ipx-x0+ox)/3;
|
||||
iy=(ipx-x0+ox)%3+(ipy-y0+oy)*3+ooy;
|
||||
dataMap[iy][ix] = sizeof(header) + (1024 * ipy + ipx) * 2;
|
||||
|
||||
// cout << ipx << " " << ipy << " " << ix << " " << iy << endl;
|
||||
|
||||
|
||||
// cout << ipx << " " << ipy << " " << ix << " " << iy << endl;
|
||||
}
|
||||
}
|
||||
cout << "G1" << endl;
|
||||
|
||||
cout << "G1" << endl; //chip coordinates of chip1 group2: x=255+12 to x=255+246, y=65 to y=128
|
||||
//3 square pixels in x on the left
|
||||
oy=-54;
|
||||
ooy=54*3;
|
||||
ox=3;
|
||||
for (int ipx=x0; ipx<x1; ipx++) {
|
||||
for (int ipy=y0+54; ipy<y0+64+54; ipy++) {
|
||||
for (int ipy=y0+54; ipy<y0+64+54; ipy++) { //I think y0+54 catches the last row of group1! Should be y0+55 if we want to include all rows? And y0+55+64
|
||||
ix=(ipx-x0+ox)/5;
|
||||
iy=(ipx-x0+ox)%5+(ipy-y0+oy)*5+ooy;
|
||||
dataMap[iy][ix] = sizeof(header) + (1024 * ipy + ipx) * 2;
|
||||
}
|
||||
}
|
||||
|
||||
cout << "G2" << endl;
|
||||
cout << "G2" << endl; //chip coordinates of chip1 group34: x=255+11 to x=255+246, y=129 to y=247
|
||||
//2 square pixels on the left
|
||||
oy=-54-64;
|
||||
ooy=54*3+64*5;
|
||||
ox=3;
|
||||
for (int ipx=x0; ipx<x1; ipx++) {
|
||||
for (int ipy=y0+64+54; ipy<y0+64*2+54*2; ipy++) {
|
||||
for (int ipy=y0+64+54; ipy<y0+64*2+54*2; ipy++) { //Same as above, I think it should be y0+55+64 and y0+55*2+64*2 to include all rows
|
||||
ix=(ipx-x0+ox)/4;
|
||||
iy=(ipx-x0+ox)%4+(ipy-y0+oy)*4+ooy;
|
||||
dataMap[iy][ix] = sizeof(header) + (1024 * ipy + ipx) * 2;
|
||||
@ -106,43 +124,50 @@ class jungfrauLGADStrixelsData : public slsDetectorData<uint16_t> {
|
||||
}
|
||||
|
||||
//chip 6
|
||||
/*
|
||||
* TL;DR comments: y0 is too high by 3, group34 and group 1 are by one row too short
|
||||
* x is by two columns too short
|
||||
* NOTE: If x0, x1, y0 are changed, likely also ox (and oy and ooy) will be affected!
|
||||
*/
|
||||
|
||||
cout << "G0" << endl; //chip coordinates of chip6 group34: x=255+256+9 to x=255+256+244, y=255+8 to y=255+126
|
||||
//9 pixels guard ring, bonding shift by one pixel in -y, 2 square pixels in x on the right
|
||||
x0=256*2+10;
|
||||
y0=256+10;
|
||||
x1=256*2+246;
|
||||
ooy=256*5;
|
||||
oy=0;
|
||||
ox=1;
|
||||
cout << "G0" << endl;
|
||||
for (int ipx=x0; ipx<x1; ipx++) {
|
||||
for (int ipy=y0; ipy<y0+54+64; ipy++) {
|
||||
for (int ipy=y0; ipy<y0+54+64; ipy++) { //shifted by 3 rows because of y0, if y0 is corrected it should be y0+55+64 to include all rows
|
||||
ix=(ipx-x0+ox)/4;
|
||||
iy=(ipx-x0+ox)%4+(ipy-y0+oy)*4+ooy;
|
||||
dataMap[iy][ix] = sizeof(header) + (1024 * ipy + ipx) * 2;
|
||||
if (ipx==x0)
|
||||
cout << ipx << " " << ipy << " " << ix << " " << iy << endl;
|
||||
|
||||
|
||||
//if (ipx==x0)
|
||||
// cout << ipx << " " << ipy << " " << ix << " " << iy << endl;
|
||||
}
|
||||
}
|
||||
cout << "G1" << endl;
|
||||
|
||||
cout << "G1" << endl; //chip coordinates of chip6 group2: x=255+256+9 to x=255+256+243, y=255+127 to y=255+190
|
||||
//3 square pixels in x on the right
|
||||
oy=-54-64;
|
||||
ooy+=(54+64)*4;
|
||||
ox=1;
|
||||
for (int ipx=x0; ipx<x1; ipx++) {
|
||||
for (int ipy=y0+54+64; ipy<y0+64*2+54; ipy++) {
|
||||
for (int ipy=y0+54+64; ipy<y0+64*2+54; ipy++) { //shifted by 3 rows because of y0, if y0 is corrected it should be y0+55+64 and y0+55+64*2 to include all rows
|
||||
ix=(ipx-x0+ox)/5;
|
||||
iy=(ipx-x0+ox)%5+(ipy-y0+oy)*5+ooy;
|
||||
dataMap[iy][ix] = sizeof(header) + (1024 * ipy + ipx) * 2;
|
||||
}
|
||||
}
|
||||
|
||||
cout << "G2" << endl;
|
||||
cout << "G2" << endl; //chip coordinates of chip6 group1: x=255+256+9 to x=255+256+245, y=255+191 to y=255+245
|
||||
//one square pixel in x on the right
|
||||
oy=-54-64*2;
|
||||
ooy+=64*5;
|
||||
ox=1;
|
||||
for (int ipx=x0; ipx<x1; ipx++) {
|
||||
for (int ipy=y0+64*2+54; ipy<y0+64*2+54*2; ipy++) {
|
||||
for (int ipy=y0+64*2+54; ipy<y0+64*2+54*2; ipy++) { //shifted by 3 rows because of y0, if y0 is corrected it should be y0+55+64*2 and y0+55*2+64*2
|
||||
ix=(ipx-x0+ox)/3;
|
||||
iy=(ipx-x0+ox)%3+(ipy-y0+oy)*3+ooy;
|
||||
dataMap[iy][ix] = sizeof(header) + (1024 * ipy + ipx) * 2;
|
||||
@ -206,7 +231,11 @@ class jungfrauLGADStrixelsData : public slsDetectorData<uint16_t> {
|
||||
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
return ((header *)buff)->detHeader.frameNumber;
|
||||
#ifdef ALDO //VH
|
||||
return ((header *)buff)->bunchNumber; //VH
|
||||
#else //VH
|
||||
return ((header *)buff)->detHeader.frameNumber;
|
||||
#endif //VH
|
||||
};
|
||||
|
||||
/**
|
||||
@ -219,7 +248,11 @@ class jungfrauLGADStrixelsData : public slsDetectorData<uint16_t> {
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff) {
|
||||
return ((header *)buff)->detHeader.packetNumber;
|
||||
#ifdef ALDO //VH
|
||||
return -1; //VH //TODO: Keep in mind in case of bugs!
|
||||
#else //VH
|
||||
return ((header *)buff)->detHeader.packetNumber;
|
||||
#endif //VH
|
||||
};
|
||||
|
||||
|
||||
@ -265,8 +298,6 @@ class jungfrauLGADStrixelsData : 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 */
|
||||
|
@ -0,0 +1,305 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef JUNGFRAULGADSTRIXELSDATASINGLECHIP_H
|
||||
#define JUNGFRAULGADSTRIXELSDATASINGLECHIP_H
|
||||
#ifdef CINT
|
||||
#include "sls/sls_detector_defs_CINT.h"
|
||||
#else
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#endif
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
/*
|
||||
/afs/psi.ch/project/mythen/Anna/slsDetectorPackageDeveloperMpc2011/slsDetectorCalibration/jungfrauExecutables
|
||||
make -f Makefile.rawdataprocess jungfrauRawDataProcessStrx
|
||||
../dataStructures/jungfrauLGADStrixelsData.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
|
||||
*/
|
||||
|
||||
namespace strixelSingleChip {
|
||||
constexpr int nc_chip = 256;
|
||||
constexpr int nr_chip = 256;
|
||||
constexpr int gr = 9;
|
||||
|
||||
//Group 1: 25um pitch, groups of 3, 1 column of square pixels
|
||||
constexpr int g1_ncols{ (nc_chip-(2*gr)-1)/3 }; //79
|
||||
constexpr int g1_nrows{ ( (nr_chip/4)-gr )*3 }; //165
|
||||
|
||||
//Group 2: 15um pitch, groups of 5, 3 columns of square pixels
|
||||
constexpr int g2_ncols{ (nc_chip-(2*gr)-3)/5 }; //47
|
||||
constexpr int g2_nrows{ (nr_chip/4)*5 }; //320
|
||||
|
||||
//Group 3: 18.75um pitch, groups of 4, 2 columns of square pixels (double the size of the other groups)
|
||||
constexpr int g3_ncols{ (nc_chip-(2*gr)-2)/4 }; //59
|
||||
constexpr int g3_nrows{ ( ((nr_chip/4)*2)-gr )*4 }; //476
|
||||
|
||||
constexpr int nc_strixel = 2*gr + 1 + g1_ncols; //group 1 is the "longest" group in x and has one extra square pixel
|
||||
constexpr int nr_strixel = 2*gr + g1_nrows + g2_nrows + g3_nrows;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
uint64_t bunchNumber; /**< is the frame number */
|
||||
uint64_t pre; /**< something */
|
||||
|
||||
} jf_header; //Aldo's header
|
||||
|
||||
|
||||
using namespace strixelSingleChip;
|
||||
class jungfrauLGADStrixelsDataSingleChip : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
int mchip;
|
||||
|
||||
void remapGroup( const int group ) {
|
||||
int ix, iy;
|
||||
int x0, y0, x1, y1, shifty;
|
||||
int multiplicator;
|
||||
|
||||
switch (group) {
|
||||
default:
|
||||
case 1:
|
||||
multiplicator = 3;
|
||||
break;
|
||||
case 2:
|
||||
multiplicator = 5;
|
||||
break;
|
||||
case 3:
|
||||
multiplicator = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( mchip == 1 ) {
|
||||
switch (group) {
|
||||
default:
|
||||
case 1:
|
||||
x0 = 10;
|
||||
x1 = 247;
|
||||
y0 = 10;
|
||||
y1 = 65;
|
||||
shifty = 0;
|
||||
break;
|
||||
case 2:
|
||||
x0 = 12;
|
||||
x1 = 247;
|
||||
y0 = 65;
|
||||
y1 = 129;
|
||||
shifty = ( (nr_chip/4)-gr )*3;
|
||||
break;
|
||||
case 3:
|
||||
x0 = 11;
|
||||
x1 = 247;
|
||||
y0 = 129;
|
||||
y1 = 248;
|
||||
shifty = ( (nr_chip/4)-gr )*3 + (nr_chip/4)*5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( mchip == 6 ) {
|
||||
switch (group) {
|
||||
default:
|
||||
case 1:
|
||||
x0 = 9;
|
||||
x1 = 246;
|
||||
y0 = 191;
|
||||
y1 = 246;
|
||||
shifty = ( (nr_chip/4)-gr+(nr_chip/4) )*4 + (nr_chip/4)*5;
|
||||
break;
|
||||
case 2:
|
||||
x0 = 9;
|
||||
x1 = 244;
|
||||
y0 = 127;
|
||||
y1 = 191;
|
||||
shifty = ( (nr_chip/4)-gr+(nr_chip/4) )*4;
|
||||
break;
|
||||
case 3:
|
||||
x0 = 9;
|
||||
x1 = 245;
|
||||
y0 = 8;
|
||||
y1 = 127;
|
||||
shifty = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//remapping loop
|
||||
for ( int ipx=x0; ipx!=x1; ++ipx ) {
|
||||
for ( int ipy=y0; ipy!=y1; ++ipy) {
|
||||
ix = (ipx-x0)/multiplicator;
|
||||
for ( int m=0; m!=multiplicator; ++m ) {
|
||||
if ( (ipx-x0)%multiplicator==m ) iy=(ipy-y0)*multiplicator + m + shifty;
|
||||
}
|
||||
dataMap[iy][ix] = sizeof(header) + (nc_chip * ipy + ipx) * 2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
#ifdef ALDO //VH
|
||||
using header = jf_header; //VH
|
||||
#else //VH
|
||||
using header = sls::defs::sls_receiver_header;
|
||||
#endif //VH
|
||||
|
||||
jungfrauLGADStrixelsDataSingleChip( const int chip )
|
||||
: slsDetectorData<uint16_t>( /*nc_strixel*/nc_chip/3, /*nr_strixel*/ nr_chip*5,
|
||||
nc_chip * nr_chip * 2 + sizeof(header) ) {
|
||||
std::cout << "Jungfrau strixels single chip" << std::endl;
|
||||
#ifdef ALDO //VH
|
||||
std::cout<< "using reduced jf_header" << std::endl; //VH
|
||||
#endif //VH
|
||||
|
||||
mchip = chip;
|
||||
//Fill all strixels with dummy values
|
||||
for (int ix = 0; ix != nc_strixel; ++ix) {
|
||||
for (int iy = 0; iy != nr_strixel; ++iy) {
|
||||
dataMap[iy][ix] = sizeof(header);
|
||||
#ifdef HIGHZ
|
||||
dataMask[iy][ix] = 0x3fff;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
remapGroup(1);
|
||||
remapGroup(2);
|
||||
remapGroup(3);
|
||||
|
||||
iframe = 0;
|
||||
std::cout << "data struct created" << std::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
|
||||
|
||||
*/
|
||||
virtual double getValue(char *data, int ix, int iy = 0) {
|
||||
|
||||
uint16_t val = getChannel(data, ix, iy) & 0x3fff;
|
||||
return val;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
#ifdef ALDO //VH
|
||||
return ((header *)buff)->bunchNumber; //VH
|
||||
#else //VH
|
||||
return ((header *)buff)->detHeader.frameNumber;
|
||||
#endif //VH
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
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) {
|
||||
#ifdef ALDO //VH
|
||||
//uint32_t fakePacketNumber = 1000;
|
||||
//return fakePacketNumber; //VH //TODO: Keep in mind in case of bugs! //This is definitely bad!
|
||||
return 1000;
|
||||
#else //VH
|
||||
return ((header *)buff)->detHeader.packetNumber;
|
||||
#endif //VH
|
||||
};
|
||||
|
||||
|
||||
|
||||
char *readNextFrame(std::ifstream &filebin) {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
char *readNextFrame(std::ifstream &filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
char *readNextFrame(std::ifstream &filebin, int &ff, int &np) {
|
||||
char *data = new char[dataSize];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
char *readNextFrame(std::ifstream &filebin, int &ff, int &np,char *data) {
|
||||
char *retval = 0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np = 0;
|
||||
int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff >= 0)
|
||||
fnum = ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
np = getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all */
|
||||
/* packets 0 to nPackets, same frame number). purely virtual func \param */
|
||||
/* data pointer to the memory to be analyzed \param ndata reference to the */
|
||||
/* amount of data found for the frame, in case the frame is incomplete at */
|
||||
/* the end of the memory slot \param dsize size of the memory slot to be */
|
||||
/* analyzed \returns pointer to the beginning of the last good frame (might */
|
||||
/* be incomplete if ndata smaller than dataSize), or NULL if no frame is */
|
||||
/* found */
|
||||
|
||||
/* *\/ */
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
if (dsize < dataSize)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = dataSize;
|
||||
return data;
|
||||
};
|
||||
|
||||
// int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,271 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#ifndef JUNGFRAUSTRIXELSHALFMODULEOLD_H
|
||||
#define JUNGFRAUSTRIXELSHALFMODULEOLD_H
|
||||
#ifdef CINT
|
||||
#include "sls/sls_detector_defs_CINT.h"
|
||||
#else
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#endif
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
/*
|
||||
/afs/psi.ch/project/mythen/Anna/slsDetectorPackageDeveloperMpc2011/slsDetectorCalibration/jungfrauExecutables
|
||||
make -f Makefile.rawdataprocess jungfrauRawDataProcessStrx
|
||||
../dataStructures/jungfrauLGADStrixelsData.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
|
||||
*/
|
||||
|
||||
namespace strixelsOldDesign {
|
||||
constexpr int NC_STRIXEL = (1024*3);
|
||||
constexpr int NR_TOTAL = (512/3);
|
||||
constexpr int NR_STRIXEL = ( (256-4)/3 );
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
uint64_t bunchNumber; /**< is the frame number */
|
||||
uint64_t pre; /**< something */
|
||||
|
||||
} jf_header; //Aldo's header
|
||||
|
||||
|
||||
using namespace strixelsOldDesign;
|
||||
class jungfrauStrixelsHalfModuleOldDesign : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
int iframe;
|
||||
|
||||
#ifdef ALDO //VH
|
||||
using header = jf_header; //VH
|
||||
#else //VH
|
||||
using header = sls::defs::sls_receiver_header;
|
||||
#endif //VH
|
||||
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
|
||||
|
||||
*/
|
||||
jungfrauStrixelsHalfModuleOldDesign()
|
||||
: slsDetectorData<uint16_t>( 1024*3, 512/3,
|
||||
512 * 1024 * 2 + sizeof(header) ) {
|
||||
std::cout << "Jungfrau strixels old design" << std::endl;
|
||||
#ifdef ALDO //VH
|
||||
std::cout<< "using reduced jf_header" << std::endl; //VH
|
||||
#endif //VH
|
||||
for (int ix = 0; ix != 1024*3; ++ix) {
|
||||
for (int iy = 0; iy != 512/3; ++iy) {
|
||||
dataMap[iy][ix] = sizeof(header);//+ ( 1024 * 5 + 300) * 2; //somewhere on the guardring of the LGAD
|
||||
#ifdef HIGHZ
|
||||
dataMask[iy][ix] = 0x3fff;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//remap
|
||||
int ix, iy;
|
||||
for (int ipx=0; ipx!=1024; ++ipx) {
|
||||
for (int ipy=0; ipy!=256-4; ++ipy) {
|
||||
iy=ipy/3;
|
||||
/* //1
|
||||
if (ipy%3==0) ix=ipx*3+2;
|
||||
if (ipy%3==1) ix=ipx*3+1;
|
||||
if (ipy%3==2) ix=ipx*3;
|
||||
*/
|
||||
/* //2
|
||||
if (ipy%3==2) ix=ipx*3+2;
|
||||
if (ipy%3==0) ix=ipx*3+1;
|
||||
if (ipy%3==1) ix=ipx*3;
|
||||
*/
|
||||
/* //3
|
||||
if (ipy%3==1) ix=ipx*3+2;
|
||||
if (ipy%3==2) ix=ipx*3+1;
|
||||
if (ipy%3==0) ix=ipx*3;
|
||||
*/
|
||||
//4 //This seems to be correct //corresponds to looking from the backside of the sensor
|
||||
if (ipy%3==0) ix=ipx*3;
|
||||
if (ipy%3==1) ix=ipx*3+1;
|
||||
if (ipy%3==2) ix=ipx*3+2;
|
||||
|
||||
/* //5
|
||||
if (ipy%3==2) ix=ipx*3;
|
||||
if (ipy%3==0) ix=ipx*3+1;
|
||||
if (ipy%3==1) ix=ipx*3+2;
|
||||
*/
|
||||
/* //6
|
||||
if (ipy%3==1) ix=ipx*3;
|
||||
if (ipy%3==2) ix=ipx*3+1;
|
||||
if (ipy%3==0) ix=ipx*3+2;
|
||||
*/
|
||||
|
||||
if ( ipx!=255 && ipx!=256 && ipx!=511 && ipx!=512 && ipx!=767 && ipx!=768 ) //avoid double pixels
|
||||
// ( !( ipx%256==0 || ipx%256==255 ) || ipx==0 || ipx==1023 )
|
||||
dataMap[iy][ix] = sizeof(header) + (1024 * ipy + ipx) * 2;
|
||||
// cout << ipx << " " << ipy << " " << ix << " " << iy << endl;
|
||||
}
|
||||
}
|
||||
|
||||
iframe = 0;
|
||||
std::cout << "data struct created" << std::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
|
||||
|
||||
*/
|
||||
virtual double getValue(char *data, int ix, int iy = 0) {
|
||||
|
||||
uint16_t val = getChannel(data, ix, iy) & 0x3fff;
|
||||
return val;
|
||||
};
|
||||
|
||||
/* virtual void calcGhost(char *data, int ix, int iy) { */
|
||||
/* double val=0; */
|
||||
/* ghost[iy][ix]=0; */
|
||||
|
||||
/* } */
|
||||
|
||||
/* virtual void calcGhost(char *data) { */
|
||||
/* for (int ix=0; ix<25; ix++){ */
|
||||
/* for (int iy=0; iy<200; iy++) { */
|
||||
/* calcGhost(data, ix,iy); */
|
||||
/* } */
|
||||
/* } */
|
||||
/* // cout << "*" << endl; */
|
||||
/* } */
|
||||
|
||||
/* double getGhost(int ix, int iy) { */
|
||||
/* return 0; */
|
||||
/* }; */
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
|
||||
int getFrameNumber(char *buff) {
|
||||
#ifdef ALDO //VH
|
||||
return ((header *)buff)->bunchNumber; //VH
|
||||
#else //VH
|
||||
return ((header *)buff)->detHeader.frameNumber;
|
||||
#endif //VH
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
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) {
|
||||
#ifdef ALDO //VH
|
||||
//uint32_t fakePacketNumber = 1000;
|
||||
//return fakePacketNumber; //VH //TODO: Keep in mind in case of bugs! //This is definitely bad!
|
||||
return 1000;
|
||||
#else //VH
|
||||
return ((header *)buff)->detHeader.packetNumber;
|
||||
#endif //VH
|
||||
};
|
||||
|
||||
|
||||
|
||||
char *readNextFrame(std::ifstream &filebin) {
|
||||
int ff = -1, np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
char *readNextFrame(std::ifstream &filebin, int &ff) {
|
||||
int np = -1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
char *readNextFrame(std::ifstream &filebin, int &ff, int &np) {
|
||||
char *data = new char[dataSize];
|
||||
char *d = readNextFrame(filebin, ff, np, data);
|
||||
if (d == NULL) {
|
||||
delete[] data;
|
||||
data = NULL;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
char *readNextFrame(std::ifstream &filebin, int &ff, int &np,char *data) {
|
||||
char *retval = 0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np = 0;
|
||||
int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff >= 0)
|
||||
fnum = ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize)) {
|
||||
ff = getFrameNumber(data);
|
||||
np = getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all */
|
||||
/* packets 0 to nPackets, same frame number). purely virtual func \param */
|
||||
/* data pointer to the memory to be analyzed \param ndata reference to the */
|
||||
/* amount of data found for the frame, in case the frame is incomplete at */
|
||||
/* the end of the memory slot \param dsize size of the memory slot to be */
|
||||
/* analyzed \returns pointer to the beginning of the last good frame (might */
|
||||
/* be incomplete if ndata smaller than dataSize), or NULL if no frame is */
|
||||
/* found */
|
||||
|
||||
/* *\/ */
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||
if (dsize < dataSize)
|
||||
ndata = dsize;
|
||||
else
|
||||
ndata = dataSize;
|
||||
return data;
|
||||
};
|
||||
|
||||
// int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
};
|
||||
|
||||
#endif
|
@ -217,6 +217,7 @@ void slsDetectorData<dataType>::setDataMap(int **dMap) {
|
||||
}
|
||||
}
|
||||
}
|
||||
/* //commented this part because it causes out-of-bound issues if nx or ny are larger than dataMap bounds (single-chip readout of strixel with groups of different pitches) VH 2023-02-24
|
||||
for (iy = 0; iy < ny; iy++) {
|
||||
for (ix = 0; ix < nx; ix++) {
|
||||
ip = dataMap[iy][ix] / sizeof(dataType);
|
||||
@ -224,7 +225,7 @@ void slsDetectorData<dataType>::setDataMap(int **dMap) {
|
||||
ymap[ip] = iy;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
// cout << "nx:" <<nx << " ny:" << ny << endl;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ enum quadrant {
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
using namespace std;
|
||||
//using namespace std;
|
||||
|
||||
//#ifdef MYROOT1
|
||||
//: public TObject
|
||||
@ -128,7 +128,7 @@ class slsInterpolation {
|
||||
nSubPixelsY * nPixelsY);
|
||||
delete[] gm;
|
||||
} else
|
||||
cout << "Could not allocate float image " << endl;
|
||||
std::cout << "Could not allocate float image " << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ class slsInterpolation {
|
||||
if (ix > 1)
|
||||
sumR += cl[ix + iy * 3];
|
||||
if (iy < 1)
|
||||
sumB = cl[ix + iy * 3];
|
||||
sumB = cl[ix + iy * 3]; //???? not "+="? VH
|
||||
if (iy > 1)
|
||||
sumT += cl[ix + iy * 3];
|
||||
}
|
||||
@ -472,13 +472,13 @@ class slsInterpolation {
|
||||
val = cl[ix + 3 * iy];
|
||||
sum += val;
|
||||
if (iy == 0)
|
||||
l += val;
|
||||
if (iy == 2)
|
||||
r += val;
|
||||
if (ix == 0)
|
||||
b += val;
|
||||
if (ix == 2)
|
||||
if (iy == 2)
|
||||
t += val;
|
||||
if (ix == 0)
|
||||
l += val;
|
||||
if (ix == 2)
|
||||
r += val;
|
||||
}
|
||||
}
|
||||
if (sum > 0) {
|
||||
@ -526,6 +526,185 @@ class slsInterpolation {
|
||||
return calcEta3X(cli, etax, etay, sum);
|
||||
}
|
||||
|
||||
/************************************************/
|
||||
/* Additional strixel eta functions by Viktoria */
|
||||
/************************************************/
|
||||
//Etax: only central row, etay: only central column
|
||||
static int calcEta1x3( double* cl, double& etax, double& etay, double& toth, double& totv ) {
|
||||
double l, r, t, b;
|
||||
//sum = cl[0] + cl[1] + cl[2] + cl[3] + cl[4] + cl[5] + cl[6] + cl[7] + cl[8];
|
||||
toth = cl[3] + cl[4] + cl[5];
|
||||
if (toth > 0) {
|
||||
l = cl[3];
|
||||
r = cl[5];
|
||||
}
|
||||
etax = (-l + r) / toth;
|
||||
totv = cl[1] + cl[4] + cl[7];
|
||||
if (toth > 0) {
|
||||
b = cl[1];
|
||||
t = cl[7];
|
||||
}
|
||||
etay = (-b + t) / totv;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int calcEta1x3( int* cl, double& etax, double& etay, double& toth, double& totv ) {
|
||||
double cli[9];
|
||||
for ( int ix = 0; ix != 9; ++ix )
|
||||
cli[ix] = cl[ix];
|
||||
return calcEta1x3( cli, etax, etay, toth , totv );
|
||||
}
|
||||
|
||||
//Eta 1x2 essentially the same as etaL, but we also return toth and totv
|
||||
static int calcEta1x2(double totquad, int corner, double sDum[2][2],
|
||||
double &etax, double &etay, double& toth, double& totv) {
|
||||
double t, r;
|
||||
if (totquad > 0) {
|
||||
switch (corner) {
|
||||
case TOP_LEFT:
|
||||
t = sDum[1][1];
|
||||
r = sDum[0][1];
|
||||
toth = sDum[0][1] + sDum[0][0];
|
||||
totv = sDum[0][1] + sDum[1][1];
|
||||
break;
|
||||
case TOP_RIGHT:
|
||||
t = sDum[1][0];
|
||||
r = sDum[0][1];
|
||||
toth = sDum[0][1] + sDum[0][0];
|
||||
totv = sDum[1][0] + sDum[0][0];
|
||||
break;
|
||||
case BOTTOM_LEFT:
|
||||
r = sDum[1][1];
|
||||
t = sDum[1][1];
|
||||
toth = sDum[1][0] + sDum[1][1];
|
||||
totv = sDum[0][1] + sDum[1][1];
|
||||
break;
|
||||
case BOTTOM_RIGHT:
|
||||
t = sDum[1][0];
|
||||
r = sDum[1][1];
|
||||
toth = sDum[1][0] + sDum[1][1];
|
||||
totv = sDum[1][0] + sDum[0][0];
|
||||
break;
|
||||
default:
|
||||
etax = -1000;
|
||||
etay = -1000;
|
||||
return 0;
|
||||
}
|
||||
// etax=r/totquad;
|
||||
// etay=t/totquad;
|
||||
etax = r / toth;
|
||||
etay = t / totv;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int calcEta1x2( double *cl, double &etax, double &etay, double &sum,
|
||||
double &totquad, double sDum[2][2], double& toth, double& totv ) {
|
||||
int corner = calcQuad( cl, sum, totquad, sDum );
|
||||
calcEta1x2( totquad, corner, sDum, etax, etay, toth, totv );
|
||||
return corner;
|
||||
}
|
||||
|
||||
static int calcEta1x2( int *cl, double &etax, double &etay, double &sum,
|
||||
double &totquad, double sDum[2][2], double& toth, double& totv ) {
|
||||
int corner = calcQuad( cl, sum, totquad, sDum );
|
||||
calcEta1x2( totquad, corner, sDum, etax, etay, toth , totv );
|
||||
return corner;
|
||||
}
|
||||
|
||||
//Two functions to calculate 2x3 or 3x2 eta
|
||||
static int calcEta2x3( double* cl, double totquad, int corner, double& etax, double& etay, double& tot6 ) {
|
||||
double t, b, r;
|
||||
if (totquad > 0) {
|
||||
switch (corner) {
|
||||
case TOP_LEFT:
|
||||
case BOTTOM_LEFT:
|
||||
t = cl[6] + cl[7];
|
||||
b = cl[0] + cl[1];
|
||||
r = cl[1] + cl[4] + cl[7];
|
||||
tot6 = cl[0] + cl[1] + cl[3] + cl[4] + cl[6] + cl[7];
|
||||
break;
|
||||
case TOP_RIGHT:
|
||||
case BOTTOM_RIGHT:
|
||||
t = cl[7] + cl[8];
|
||||
b = cl[1] + cl[2];
|
||||
r = cl[2] + cl[5] + cl[8];
|
||||
tot6 = cl[1] + cl[2] + cl[4] + cl[5] + cl[7] + cl[8];
|
||||
break;
|
||||
default:
|
||||
etax = -1000;
|
||||
etay = -1000;
|
||||
return -1;
|
||||
}
|
||||
etax = r / tot6;
|
||||
etay = (-b + t) / tot6;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int calcEta3x2( double* cl, double totquad, int corner, double& etax, double& etay, double& tot6 ) {
|
||||
double t, l, r;
|
||||
if (totquad > 0) {
|
||||
switch (corner) {
|
||||
case TOP_LEFT:
|
||||
case TOP_RIGHT:
|
||||
l = cl[3] + cl[6];
|
||||
r = cl[5] + cl[8];
|
||||
t = cl[6] + cl[7] + cl[8];
|
||||
tot6 = cl[3] + cl[4] + cl[5] + cl[6] + cl[7] + cl[8];
|
||||
break;
|
||||
case BOTTOM_LEFT:
|
||||
case BOTTOM_RIGHT:
|
||||
l = cl[0] + cl[3];
|
||||
r = cl[2] + cl[5];
|
||||
t = cl[3] + cl[4] + cl[5];
|
||||
tot6 = cl[0] + cl[1] + cl[2] + cl[3] + cl[4] + cl[5];
|
||||
break;
|
||||
default:
|
||||
etax = -1000;
|
||||
etay = -1000;
|
||||
return -1;
|
||||
}
|
||||
etax = (-l + r) / tot6;
|
||||
etay = t / tot6;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//overload including both eta2x3 and eta3x2
|
||||
//ornt (orientation of long side (3) of eta) decides which eta is chosen
|
||||
enum orientation {
|
||||
HORIZONTAL_ORIENTATION = 0,
|
||||
VERTICAL_ORIENTATION = 1,
|
||||
UNDEFINED_ORIENTATION = -1
|
||||
};
|
||||
static int calcEta2x3( int ornt, double* cl, double& etax, double& etay, double& tot6 ) {
|
||||
double sum{};
|
||||
double totquad{};
|
||||
double sDum[2][2]{};
|
||||
int corner = calcQuad( cl, sum, totquad, sDum );
|
||||
switch (ornt) {
|
||||
case HORIZONTAL_ORIENTATION:
|
||||
calcEta3x2( cl, totquad, corner, etax, etay, tot6 );
|
||||
break;
|
||||
case VERTICAL_ORIENTATION:
|
||||
calcEta2x3( cl, totquad, corner, etax, etay, tot6 );
|
||||
break;
|
||||
default:
|
||||
etax = -1000;
|
||||
etay = -1000;
|
||||
return -1;
|
||||
}
|
||||
return corner;
|
||||
}
|
||||
|
||||
static int calcEta2x3( int strxo, int* cl, double& etax, double& etay, double& tot6 ) {
|
||||
double cli[9]{};
|
||||
for ( int ix = 0; ix != 9; ++ix )
|
||||
cli[ix] = cl[ix];
|
||||
return calcEta2x3( strxo, cli, etax, etay, tot6 );
|
||||
}
|
||||
|
||||
/* static int calcMyEta(double totquad, int quad, double *cl, double &etax,
|
||||
* double &etay) { */
|
||||
/* double l,r,t,b, sum; */
|
||||
|
@ -14,7 +14,19 @@ jungfrauRawDataProcess: jungfrauRawDataProcess.cpp $(INCS) clean
|
||||
g++ -o jungfrauRawDataProcess jungfrauRawDataProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DMODULE
|
||||
|
||||
jungfrauRawDataProcessStrx: jungfrauRawDataProcess.cpp $(INCS) clean
|
||||
g++ -o jungfrauRawDataProcessStrx jungfrauRawDataProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DJFSTRX
|
||||
g++ -o jungfrauRawDataProcessStrx jungfrauRawDataProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DJFSTRX
|
||||
|
||||
jungfrauRawDataProcessStrxChip1: jungfrauRawDataProcess.cpp $(INCS) clean
|
||||
g++ -o jungfrauRawDataProcessStrxChip1 jungfrauRawDataProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DJFSTRXCHIP1
|
||||
|
||||
jungfrauRawDataProcessStrxChip6: jungfrauRawDataProcess.cpp $(INCS) clean
|
||||
g++ -o jungfrauRawDataProcessStrxChip6 jungfrauRawDataProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DJFSTRXCHIP6
|
||||
|
||||
jungfrauRawDataProcessStrxChip1Aldo: jungfrauRawDataProcess.cpp $(INCS) clean
|
||||
g++ -o jungfrauRawDataProcessStrxChip1Aldo jungfrauRawDataProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DJFSTRXCHIP1 -DALDO
|
||||
|
||||
jungfrauRawDataProcessStrxChip6Aldo: jungfrauRawDataProcess.cpp $(INCS) clean
|
||||
g++ -o jungfrauRawDataProcessStrxChip6Aldo jungfrauRawDataProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DJFSTRXCHIP6 -DALDO
|
||||
|
||||
jungfrauRawDataProcessStrxAldo: jungfrauRawDataProcess.cpp $(INCS) clean
|
||||
g++ -o jungfrauRawDataProcessStrxAldo jungfrauRawDataProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DJFSTRX -DALDO
|
||||
|
@ -10,8 +10,7 @@
|
||||
|
||||
#define RAWDATA
|
||||
|
||||
#ifndef JFSTRX
|
||||
#ifndef JFSTRXOLD
|
||||
#if !defined JFSTRX && !defined JFSTRXOLD && !defined JFSTRXCHIP1 && !defined JFSTRXCHIP6
|
||||
#ifndef MODULE
|
||||
#include "jungfrauHighZSingleChipData.h"
|
||||
#endif
|
||||
@ -19,10 +18,13 @@
|
||||
#include "jungfrauModuleData.h"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef JFSTRX
|
||||
#include "jungfrauLGADStrixelsData.h"
|
||||
#endif
|
||||
#if defined JFSTRXCHIP1 || defined JFSTRXCHIP6
|
||||
#include "jungfrauLGADStrixelsDataSingleChip.h"
|
||||
#endif
|
||||
#ifdef JFSTRXOLD
|
||||
#include "jungfrauStrixelsHalfModuleOldDesign.h"
|
||||
#endif
|
||||
@ -56,15 +58,14 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
int fifosize = 1000;
|
||||
int nthreads = 10;
|
||||
int csize = 3;
|
||||
int csize = 3; //3
|
||||
int nsigma = 5;
|
||||
int nped = 10000;
|
||||
|
||||
int cf = 0;
|
||||
|
||||
|
||||
#ifndef JFSTRX
|
||||
#ifndef JFSTRXOLD
|
||||
#if !defined JFSTRX && !defined JFSTRXOLD && !defined JFSTRXCHIP1 && !defined JFSTRXCHIP6
|
||||
#ifndef MODULE
|
||||
jungfrauHighZSingleChipData *decoder = new jungfrauHighZSingleChipData();
|
||||
int nx = 256, ny = 256;
|
||||
@ -72,17 +73,26 @@ int main(int argc, char *argv[]) {
|
||||
#ifdef MODULE
|
||||
jungfrauModuleData *decoder = new jungfrauModuleData();
|
||||
int nx = 1024, ny = 512;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifdef JFSTRX
|
||||
cout << "bbb" << endl;
|
||||
cout << "Jungfrau strixel full module readout" << endl;
|
||||
jungfrauLGADStrixelsData *decoder = new jungfrauLGADStrixelsData();
|
||||
int nx = 1024/5, ny = 512*5;
|
||||
#endif
|
||||
#ifdef JFSTRXCHIP1
|
||||
std::cout << "Jungfrau strixel LGAD single chip 1" << std::endl;
|
||||
jungfrauLGADStrixelsDataSingleChip *decoder = new jungfrauLGADStrixelsDataSingleChip(1);
|
||||
int nx = 256/3, ny = 256*5;
|
||||
#endif
|
||||
#ifdef JFSTRXCHIP6
|
||||
std::cout << "Jungfrau strixel LGAD single chip 6" << std::endl;
|
||||
jungfrauLGADStrixelsDataSingleChip *decoder = new jungfrauLGADStrixelsDataSingleChip(6);
|
||||
int nx = 256/3, ny = 256*5;
|
||||
#endif
|
||||
#ifdef JFSTRXOLD
|
||||
cout << "ccc" << endl;
|
||||
std::cout << "Jungfrau strixels old design" << std::endl;
|
||||
jungfrauStrixelsHalfModuleOldDesign *decoder = new jungfrauStrixelsHalfModuleOldDesign();
|
||||
int nx = 1024*3, ny = 512/3;
|
||||
#endif
|
||||
@ -180,7 +190,7 @@ int main(int argc, char *argv[]) {
|
||||
uint32_t nnx, nny;
|
||||
|
||||
singlePhotonDetector *filter = new singlePhotonDetector(
|
||||
decoder, csize, nsigma, 1, NULL, nped, 200, -1, -1, gainmap, NULL);
|
||||
decoder, 3, nsigma, 1, NULL, nped, 200, -1, -1, gainmap, NULL);
|
||||
|
||||
if (gainfname) {
|
||||
|
||||
@ -211,6 +221,8 @@ int main(int argc, char *argv[]) {
|
||||
// multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
multiThreadedCountingDetector *mt =
|
||||
new multiThreadedCountingDetector(filter, nthreads, fifosize);
|
||||
mt->setClusterSize(csize,csize);
|
||||
|
||||
#ifndef ANALOG
|
||||
mt->setDetectorMode(ePhotonCounting);
|
||||
cout << "Counting!" << endl;
|
||||
|
@ -69,6 +69,11 @@ class threadedAnalogDetector {
|
||||
};
|
||||
virtual double setThreshold(double th) { return det->setThreshold(th); };
|
||||
|
||||
virtual double setClusterSize(int csx, int csy) {
|
||||
//cout << "44" << endl;
|
||||
return det->setClusterSize(csx);
|
||||
};
|
||||
|
||||
virtual void setROI(int xmin, int xmax, int ymin, int ymax) {
|
||||
det->setROI(xmin, xmax, ymin, ymax);
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ using namespace std;
|
||||
|
||||
class multiThreadedCountingDetector : public multiThreadedAnalogDetector {
|
||||
public:
|
||||
multiThreadedCountingDetector(singlePhotonDetector *d, int n, int fs = 1000)
|
||||
multiThreadedCountingDetector(singlePhotonDetector *d, int n, int fs = 1000)
|
||||
: multiThreadedAnalogDetector(d, n, fs){};
|
||||
// virtual
|
||||
// ~multiThreadedCountingDetector{multiThreadedAnalogDetector::~multiThreadedAnalogDetector();};
|
||||
@ -33,6 +33,11 @@ class multiThreadedCountingDetector : public multiThreadedAnalogDetector {
|
||||
for (int i = 0; i < nThreads; i++)
|
||||
(dets[i])->setEnergyRange(emi, ema);
|
||||
};
|
||||
virtual void setClusterSize(int sizex, int sizey) {
|
||||
for (int i = 0; i < nThreads; i++)
|
||||
((dets[i]))->setClusterSize(sizex, sizey);
|
||||
//std::cout << "+++++++++++++ sizex " << sizex << std::endl;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -174,8 +174,9 @@ class singlePhotonDetector : public analogDetector<uint16_t> {
|
||||
clusterSizeY = clusterSize;
|
||||
else
|
||||
clusterSizeY = 1;
|
||||
for (int ip = 0; ip < nx * ny; ip++)
|
||||
for (int ip = 0; ip < nx * ny; ip++) {
|
||||
(clusters + ip)->set_cluster_size(clusterSize, clusterSizeY);
|
||||
}
|
||||
// cluster=new single_photon_hit(clusterSize,clusterSizeY);
|
||||
}
|
||||
return clusterSize;
|
||||
@ -533,6 +534,7 @@ class singlePhotonDetector : public analogDetector<uint16_t> {
|
||||
(clusters + nph)->print();
|
||||
cout << max << " " << val[iy * nx + ix] << endl;
|
||||
}
|
||||
//else (clusters + nph)->print();
|
||||
good = 1;
|
||||
if (eMin > 0 && tot < eMin)
|
||||
good = 0;
|
||||
|
@ -44,14 +44,12 @@ class single_photon_hit {
|
||||
// fwrite((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad),
|
||||
// myFile); // if (fwrite((void*)this, 1,
|
||||
// sizeof(int)+2*sizeof(int16_t), myFile))
|
||||
#ifdef OLDFORMAT
|
||||
if (fwrite((void *)&iframe, 1, sizeof(int), myFile)) {
|
||||
};
|
||||
#endif
|
||||
#ifndef WRITE_QUAD
|
||||
// printf("no quad ");
|
||||
if (fwrite((void *)&x, sizeof(int16_t), 2, myFile))
|
||||
if ( fwrite( (void*)&x, sizeof(int16_t), 1, myFile ) ) {
|
||||
if ( fwrite( (void*)&y, sizeof(int16_t), 1, myFile ) )
|
||||
return fwrite((void *)data, sizeof(int), dx * dy, myFile);
|
||||
}
|
||||
#endif
|
||||
#ifdef WRITE_QUAD
|
||||
// printf("quad ");
|
||||
@ -109,14 +107,27 @@ class single_photon_hit {
|
||||
// fread((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad),
|
||||
// myFile);
|
||||
|
||||
#ifdef OLDFORMAT
|
||||
if (fread((void *)&iframe, 1, sizeof(int), myFile)) {
|
||||
}
|
||||
#endif
|
||||
#ifndef WRITE_QUAD
|
||||
// printf( "no quad \n");
|
||||
//printf( "no quad \n");
|
||||
//This reads two values of size int16_t into x
|
||||
//If x is located next to y (int16_t distance), this reads the values into x and y
|
||||
//How can I be sure, this is always the case?
|
||||
//If, e.g., the memory is padded after int16_t x, do we read the padding instead of y?
|
||||
//How can I be sure the memory is packed and y follows right after x with no padding?
|
||||
//Anyway, this is dangerous if anyone, at any point, changes the order of variable declaration,
|
||||
//or uses another architecture (64 bit vs 32 bit for instance).
|
||||
/*
|
||||
if (fread((void *)&x, sizeof(int16_t), 2, myFile))
|
||||
return fread((void *)data, sizeof(int), dx * dy, myFile);
|
||||
*/
|
||||
|
||||
//Suggestion
|
||||
if ( fread( (void*)&x, sizeof(int16_t), 1, myFile) ) { //reads x
|
||||
if ( fread( (void*)&y, sizeof(int16_t), 1, myFile ) ) //reads y
|
||||
return fread( (void*)data, sizeof(int), dx*dy, myFile ); //reads and returns data
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#ifdef WRITE_QUAD
|
||||
int qq[4];
|
||||
@ -217,7 +228,7 @@ class single_photon_hit {
|
||||
// int ix, iy;
|
||||
|
||||
printf("***************\n");
|
||||
printf("** %d %d **\n",x,y);
|
||||
printf("** %d %d ** %d %d **\n", x, y, dx, dy);
|
||||
for (int iy = 0; iy < dy; iy++) {
|
||||
for (int ix = 0; ix < dx; ix++) {
|
||||
printf("%d \t", data[ix + iy * dx]);
|
||||
@ -261,10 +272,11 @@ class single_photon_hit {
|
||||
x within the cluster (center is (0,0)) \param iy coordinate y within the
|
||||
cluster (center is (0,0)) \returns value of the cluster element
|
||||
*/
|
||||
double get_data(int ix, int iy = 0) {
|
||||
return data[(iy + dy / 2) * dx + ix + dx / 2];
|
||||
//Why not make these const? VH
|
||||
double get_data(int ix, int iy = 0) const {
|
||||
return data[(iy + dy / 2) * dx + ix + dx / 2]; //NOTE: those are int divisions
|
||||
};
|
||||
int *get_cluster() { return data; };
|
||||
int *get_cluster() const { return data; };
|
||||
|
||||
int iframe; /**< frame number */
|
||||
double
|
||||
|
@ -1742,6 +1742,7 @@ int Feb_Control_WriteRegister_BitMask(uint32_t offset, uint32_t data,
|
||||
|
||||
int Feb_Control_ReadRegister_BitMask(uint32_t offset, uint32_t *retval,
|
||||
uint32_t bitmask) {
|
||||
|
||||
uint32_t actualOffset = offset;
|
||||
char side[2][10] = {"right", "left"};
|
||||
unsigned int addr[2] = {Feb_Control_rightAddress, Feb_Control_leftAddress};
|
||||
@ -2206,6 +2207,21 @@ int Feb_Control_GetRightFPGATemp() {
|
||||
return (int)temperature;
|
||||
}
|
||||
|
||||
int Feb_Control_GetFPGAHardwareVersion(int *retval) {
|
||||
if (!Feb_Control_activated) {
|
||||
return 0;
|
||||
}
|
||||
unsigned int value = 0;
|
||||
if (!Feb_Control_ReadRegister_BitMask(FEB_REG_STATUS, &value,
|
||||
FEB_REG_STATUS_FX30_MSK)) {
|
||||
LOG(logERROR,
|
||||
("Trouble reading FEB_REG_STATUS reg to feb hardware version\n"));
|
||||
return 0;
|
||||
}
|
||||
*retval = (value >> FEB_REG_STATUS_FX30_OFST);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int64_t Feb_Control_GetFrontLeftFirmwareVersion() {
|
||||
if (!Feb_Control_activated) {
|
||||
return 0;
|
||||
|
@ -46,6 +46,8 @@
|
||||
#define FEB_REG_STATUS_WAIT_FOR_TRGGR_MSK (0x00000001 << FEB_REG_STATUS_WAIT_FOR_TRGGR_OFST)
|
||||
#define FEB_REG_STATUS_ACQ_DONE_OFST (6)
|
||||
#define FEB_REG_STATUS_ACQ_DONE_MSK (0x00000001 << FEB_REG_STATUS_ACQ_DONE_OFST)
|
||||
#define FEB_REG_STATUS_FX30_OFST (7)
|
||||
#define FEB_REG_STATUS_FX30_MSK (0x00000001 << FEB_REG_STATUS_FX30_OFST)
|
||||
#define FEB_REG_STATUS_FW_VERSION_OFST (8)
|
||||
#define FEB_REG_STATUS_FW_VERSION_MSK (0x000000FF << FEB_REG_STATUS_FW_VERSION_OFST)
|
||||
#define FEB_REG_STATUS_TEMP_OFST (16)
|
||||
|
Binary file not shown.
@ -123,18 +123,18 @@ void basictests() {
|
||||
int64_t sw_fw_apiversion = getFirmwareAPIVersion();
|
||||
|
||||
LOG(logINFOBLUE,
|
||||
("**************************************************\n"
|
||||
"Detector IP Addr:\t\t 0x%x\n"
|
||||
"Detector MAC Addr:\t\t 0x%llx\n"
|
||||
("\n********************************************************\n"
|
||||
"Detector IP Addr : 0x%x\n"
|
||||
"Detector MAC Addr : 0x%llx\n"
|
||||
|
||||
"Firmware Version:\t\t %lld\n"
|
||||
"Software Version:\t\t %s\n"
|
||||
"F/w-S/w API Version:\t\t %lld\n"
|
||||
"Required Firmware Version:\t %d\n"
|
||||
"Firmware (Beb) Version : %lld\n"
|
||||
"F/w-S/w API Version : %lld\n"
|
||||
"Required Firmware Version: %d\n"
|
||||
"Software Version : %s\n"
|
||||
"********************************************************\n",
|
||||
(unsigned int)ipadd, (long long unsigned int)macadd,
|
||||
(long long int)fwversion, swversion, (long long int)sw_fw_apiversion,
|
||||
REQUIRED_FIRMWARE_VERSION));
|
||||
(long long int)fwversion, (long long int)sw_fw_apiversion,
|
||||
REQUIRED_FIRMWARE_VERSION, swversion));
|
||||
|
||||
// update default udpdstip and udpdstmac (1g is hardware ip and hardware
|
||||
// mac)
|
||||
@ -161,9 +161,9 @@ void basictests() {
|
||||
// check for API compatibility - old server
|
||||
if (sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION) {
|
||||
sprintf(initErrorMessage,
|
||||
"This firmware-software api version (0x%llx) is incompatible "
|
||||
"This firmware-software api version (0x%lld) is incompatible "
|
||||
"with the software's minimum required firmware version "
|
||||
"(0x%llx).\nPlease update detector software to be compatible "
|
||||
"(0x%lld).\nPlease update detector software to be compatible "
|
||||
"with this firmware.\n",
|
||||
(long long int)sw_fw_apiversion,
|
||||
(long long int)REQUIRED_FIRMWARE_VERSION);
|
||||
@ -210,7 +210,7 @@ void getServerVersion(char *version) { strcpy(version, APIEIGER); }
|
||||
|
||||
u_int64_t getFirmwareVersion() {
|
||||
#ifdef VIRTUAL
|
||||
return 0;
|
||||
return REQUIRED_FIRMWARE_VERSION;
|
||||
#else
|
||||
return Beb_GetFirmwareRevision();
|
||||
#endif
|
||||
@ -218,7 +218,9 @@ u_int64_t getFirmwareVersion() {
|
||||
|
||||
uint64_t getFrontEndFirmwareVersion(enum fpgaPosition fpgaPosition) {
|
||||
uint64_t retval = 0;
|
||||
#ifndef VIRTUAL
|
||||
#ifdef VIRTUAL
|
||||
return REQUIRED_FIRMWARE_VERSION;
|
||||
#else
|
||||
sharedMemory_lockLocalLink();
|
||||
switch (fpgaPosition) {
|
||||
case FRONT_LEFT:
|
||||
@ -230,7 +232,7 @@ uint64_t getFrontEndFirmwareVersion(enum fpgaPosition fpgaPosition) {
|
||||
default:
|
||||
LOG(logERROR,
|
||||
("unknown index for fpga position to read firmware version\n"));
|
||||
retval = -1;
|
||||
retval = 0;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
@ -239,12 +241,39 @@ uint64_t getFrontEndFirmwareVersion(enum fpgaPosition fpgaPosition) {
|
||||
|
||||
u_int64_t getFirmwareAPIVersion() {
|
||||
#ifdef VIRTUAL
|
||||
return 0;
|
||||
return REQUIRED_FIRMWARE_VERSION;
|
||||
#else
|
||||
return (u_int64_t)Beb_GetFirmwareSoftwareAPIVersion();
|
||||
return Beb_GetFirmwareSoftwareAPIVersion();
|
||||
#endif
|
||||
}
|
||||
|
||||
void getHardwareVersion(char *version) {
|
||||
strcpy(version, "unknown");
|
||||
int hwversion = getHardwareVersionNumber();
|
||||
const int hwNumberList[] = HARDWARE_VERSION_NUMBERS;
|
||||
const char *hwNamesList[] = HARDWARE_VERSION_NAMES;
|
||||
for (int i = 0; i != NUM_HARDWARE_VERSIONS; ++i) {
|
||||
LOG(logDEBUG, ("0x%x %d 0x%x %s\n", hwversion, i, hwNumberList[i],
|
||||
hwNamesList[i]));
|
||||
if (hwNumberList[i] == hwversion) {
|
||||
strcpy(version, hwNamesList[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int getHardwareVersionNumber() {
|
||||
int retval = 0;
|
||||
#ifndef VIRTUAL
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_GetFPGAHardwareVersion(&retval)) {
|
||||
retval = -1;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
int getModuleId(int *ret, char *mess) {
|
||||
return getModuleIdInFile(ret, mess, ID_FILE);
|
||||
}
|
||||
@ -376,6 +405,37 @@ void initControlServer() {
|
||||
Beb_SetTopVariable(top);
|
||||
Beb_Beb();
|
||||
LOG(logDEBUG1, ("Control server: BEB Initialization done\n"));
|
||||
|
||||
// Getting the feb versions after initialization
|
||||
char hversion[MAX_STR_LENGTH] = {0};
|
||||
memset(hversion, 0, MAX_STR_LENGTH);
|
||||
getHardwareVersion(hversion);
|
||||
int64_t fwversion = getFirmwareVersion();
|
||||
int64_t feblfwversion = getFrontEndFirmwareVersion(FRONT_LEFT);
|
||||
int64_t febrfwversion = getFrontEndFirmwareVersion(FRONT_RIGHT);
|
||||
LOG(logINFOBLUE,
|
||||
("\n********************************************************\n"
|
||||
"Feb Versions\n"
|
||||
"Hardware Version : %s\n"
|
||||
"Firmware (Febl) Version : %lld\n"
|
||||
"Firmware (Febr) Version : %lld\n"
|
||||
"********************************************************\n",
|
||||
hversion, (long long int)feblfwversion,
|
||||
(long long int)febrfwversion));
|
||||
|
||||
// ensure febl, febr and beb fw versions are the same
|
||||
if (fwversion != feblfwversion || fwversion != febrfwversion) {
|
||||
sprintf(
|
||||
initErrorMessage,
|
||||
"Inconsistent firmware versions in feb and beb. [Beb: %lld, "
|
||||
"Febl: %lld Febr: %lld]\n",
|
||||
(long long int)fwversion, (long long int)feblfwversion,
|
||||
(long long int)febrfwversion);
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initError = FAIL;
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
// also reads config file and deactivates
|
||||
setupDetector();
|
||||
|
@ -5,6 +5,11 @@
|
||||
|
||||
#define LINKED_SERVER_NAME "eigerDetectorServer"
|
||||
|
||||
#define NUM_HARDWARE_VERSIONS (2)
|
||||
#define HARDWARE_VERSION_NUMBERS {0x0, 0x1};
|
||||
#define HARDWARE_VERSION_NAMES \
|
||||
{ "FX70T", "FX30T" }
|
||||
|
||||
#define REQUIRED_FIRMWARE_VERSION (31)
|
||||
// virtual ones renamed for consistency
|
||||
// real ones keep previous name for compatibility (already in production)
|
||||
|
@ -82,8 +82,10 @@ u_int64_t getFirmwareVersion();
|
||||
uint64_t getFrontEndFirmwareVersion(enum fpgaPosition fpgaPosition);
|
||||
#endif
|
||||
u_int64_t getFirmwareAPIVersion();
|
||||
#ifndef EIGERD
|
||||
void getHardwareVersion(char *version);
|
||||
#ifdef EIGERD
|
||||
int getHardwareVersionNumber();
|
||||
#else
|
||||
u_int16_t getHardwareVersionNumber();
|
||||
#endif
|
||||
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD)
|
||||
|
@ -732,8 +732,14 @@ int get_firmware_version(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int64_t retval = -1;
|
||||
retval = getFirmwareVersion();
|
||||
LOG(logDEBUG1,
|
||||
("firmware version retval: 0x%llx\n", (long long int)retval));
|
||||
if (retval == 0) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not get firmware version\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
LOG(logDEBUG1,
|
||||
("firmware version retval: 0x%llx\n", (long long int)retval));
|
||||
}
|
||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
@ -10138,12 +10144,8 @@ int get_hardware_version(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
char retvals[MAX_STR_LENGTH];
|
||||
memset(retvals, 0, MAX_STR_LENGTH);
|
||||
#ifdef EIGERD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
getHardwareVersion(retvals);
|
||||
LOG(logDEBUG1, ("hardware version retval: %s\n", retvals));
|
||||
#endif
|
||||
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
|
||||
}
|
||||
|
||||
@ -10171,9 +10173,15 @@ int get_frontend_firmware_version(int file_des) {
|
||||
}
|
||||
if (ret == OK) {
|
||||
retval = getFrontEndFirmwareVersion(arg);
|
||||
LOG(logDEBUG1,
|
||||
("Front %s version retval: 0x%llx\n",
|
||||
(arg == FRONT_LEFT ? "left" : "right"), (long long int)retval));
|
||||
if (retval == 0) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Could not get febl/r firmware version\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
LOG(logDEBUG1, ("Front %s version retval: 0x%llx\n",
|
||||
(arg == FRONT_LEFT ? "left" : "right"),
|
||||
(long long int)retval));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||
|
@ -85,7 +85,6 @@ class Detector {
|
||||
|
||||
Result<std::string> getDetectorServerVersion(Positions pos = {}) const;
|
||||
|
||||
/** [Jungfrau][Moench][Gotthard2][Myhten3][Gotthard][Ctb] */
|
||||
Result<std::string> getHardwareVersion(Positions pos = {}) const;
|
||||
|
||||
Result<std::string> getKernelVersion(Positions pos = {}) const;
|
||||
|
@ -279,11 +279,7 @@ std::string CmdProxy::Versions(int action) {
|
||||
auto t = det->getFirmwareVersion(std::vector<int>{det_id});
|
||||
os << "\nType : " << OutString(det->getDetectorType())
|
||||
<< "\nRelease : " << det->getPackageVersion() << std::hex
|
||||
<< "\nClient : " << det->getClientVersion()
|
||||
<< "\nServer : "
|
||||
<< OutString(det->getDetectorServerVersion(std::vector<int>{det_id}))
|
||||
<< "\nKernel : "
|
||||
<< OutString(det->getKernelVersion({std::vector<int>{det_id}}));
|
||||
<< "\nClient : " << det->getClientVersion();
|
||||
|
||||
if (eiger) {
|
||||
os << "\nFirmware (Beb) : "
|
||||
@ -297,11 +293,16 @@ std::string CmdProxy::Versions(int action) {
|
||||
} else {
|
||||
os << "\nFirmware : "
|
||||
<< OutStringHex(
|
||||
det->getFirmwareVersion(std::vector<int>{det_id}))
|
||||
<< "\nHardware : "
|
||||
<< OutString(det->getHardwareVersion(std::vector<int>{det_id}));
|
||||
det->getFirmwareVersion(std::vector<int>{det_id}));
|
||||
}
|
||||
|
||||
os << "\nServer : "
|
||||
<< OutString(det->getDetectorServerVersion(std::vector<int>{det_id}))
|
||||
<< "\nKernel : "
|
||||
<< OutString(det->getKernelVersion({std::vector<int>{det_id}}))
|
||||
<< "\nHardware : "
|
||||
<< OutString(det->getHardwareVersion(std::vector<int>{det_id}));
|
||||
|
||||
if (det->getUseReceiverFlag().squash(true)) {
|
||||
os << "\nReceiver : "
|
||||
<< OutString(det->getReceiverVersion(std::vector<int>{det_id}));
|
||||
|
@ -1244,7 +1244,8 @@ class CmdProxy {
|
||||
|
||||
GET_COMMAND(hardwareversion, getHardwareVersion,
|
||||
"\n\t[Jungfrau][Gotthard2][Myhten3][Gotthard][Ctb][Moench] "
|
||||
"Hardware version of detector.");
|
||||
"Hardware version of detector. \n\t[Eiger] Hardware version of "
|
||||
"front FPGA on detector.");
|
||||
|
||||
GET_COMMAND(
|
||||
kernelversion, getKernelVersion,
|
||||
|
@ -1182,7 +1182,8 @@ Result<std::string> Detector::getRxHostname(Positions pos) const {
|
||||
}
|
||||
|
||||
void Detector::setRxHostname(const std::string &receiver, Positions pos) {
|
||||
pimpl->Parallel(&Module::setReceiverHostname, pos, receiver,
|
||||
auto host = pimpl->verifyUniqueRxHost(receiver, pos);
|
||||
pimpl->Parallel(&Module::setReceiverHostname, pos, host.first, host.second,
|
||||
pimpl->getInitialChecks());
|
||||
updateRxRateCorrections();
|
||||
}
|
||||
@ -1190,17 +1191,15 @@ void Detector::setRxHostname(const std::string &receiver, Positions pos) {
|
||||
void Detector::setRxHostname(const std::vector<std::string> &name) {
|
||||
// set all to same rx_hostname
|
||||
if (name.size() == 1) {
|
||||
pimpl->Parallel(&Module::setReceiverHostname, {}, name[0],
|
||||
pimpl->getInitialChecks());
|
||||
auto host = pimpl->verifyUniqueRxHost(name[0], {});
|
||||
pimpl->Parallel(&Module::setReceiverHostname, {}, host.first,
|
||||
host.second, pimpl->getInitialChecks());
|
||||
} else {
|
||||
if ((int)name.size() != size()) {
|
||||
throw RuntimeError(
|
||||
"Receiver hostnames size " + std::to_string(name.size()) +
|
||||
" does not match detector size " + std::to_string(size()));
|
||||
}
|
||||
auto hosts = pimpl->verifyUniqueRxHost(name);
|
||||
// set each rx_hostname
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
pimpl->Parallel(&Module::setReceiverHostname, {idet}, name[idet],
|
||||
pimpl->Parallel(&Module::setReceiverHostname, {idet},
|
||||
hosts[idet].first, hosts[idet].second,
|
||||
pimpl->getInitialChecks());
|
||||
}
|
||||
}
|
||||
@ -1217,10 +1216,12 @@ void Detector::setRxPort(int port, int module_id) {
|
||||
for (auto &it : port_list) {
|
||||
it = port++;
|
||||
}
|
||||
// no need to verify hostname-port combo as unique port(incremented)
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
pimpl->Parallel(&Module::setReceiverPort, {idet}, port_list[idet]);
|
||||
}
|
||||
} else {
|
||||
pimpl->verifyUniqueRxHost(port, module_id);
|
||||
pimpl->Parallel(&Module::setReceiverPort, {module_id}, port);
|
||||
}
|
||||
}
|
||||
@ -2460,10 +2461,12 @@ Result<int> Detector::getControlPort(Positions pos) const {
|
||||
}
|
||||
|
||||
void Detector::setControlPort(int value, Positions pos) {
|
||||
pimpl->verifyUniqueDetHost(value, pos);
|
||||
pimpl->Parallel(&Module::setControlPort, pos, value);
|
||||
}
|
||||
|
||||
Result<int> Detector::getStopPort(Positions pos) const {
|
||||
// not verifying unique stop port (control port is sufficient)
|
||||
return pimpl->Parallel(&Module::getStopPort, pos);
|
||||
}
|
||||
|
||||
|
@ -279,31 +279,14 @@ void DetectorImpl::setHostname(const std::vector<std::string> &name) {
|
||||
}
|
||||
}
|
||||
|
||||
void DetectorImpl::addModule(const std::string &hostname) {
|
||||
LOG(logINFO) << "Adding module " << hostname;
|
||||
|
||||
int port = DEFAULT_TCP_CNTRL_PORTNO;
|
||||
std::string host = hostname;
|
||||
auto res = split(hostname, ':');
|
||||
if (res.size() > 1) {
|
||||
host = res[0];
|
||||
port = StringTo<int>(res[1]);
|
||||
}
|
||||
|
||||
if (host != "localhost") {
|
||||
for (auto &module : modules) {
|
||||
if (module->getHostname() == host) {
|
||||
LOG(logWARNING)
|
||||
<< "Module " << host << "already part of the Detector!"
|
||||
<< std::endl
|
||||
<< "Remove it before adding it back in a new position!";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void DetectorImpl::addModule(const std::string &name) {
|
||||
LOG(logINFO) << "Adding module " << name;
|
||||
auto host = verifyUniqueDetHost(name);
|
||||
std::string hostname = host.first;
|
||||
int port = host.second;
|
||||
|
||||
// get type by connecting
|
||||
detectorType type = Module::getTypeFromDetector(host, port);
|
||||
detectorType type = Module::getTypeFromDetector(hostname, port);
|
||||
|
||||
// gotthard cannot have more than 2 modules (50um=1, 25um=2
|
||||
if ((type == GOTTHARD || type == GOTTHARD2) && modules.size() > 2) {
|
||||
@ -316,7 +299,7 @@ void DetectorImpl::addModule(const std::string &hostname) {
|
||||
shm()->totalNumberOfModules = modules.size();
|
||||
modules[pos]->setControlPort(port);
|
||||
modules[pos]->setStopPort(port + 1);
|
||||
modules[pos]->setHostname(host, shm()->initialChecks);
|
||||
modules[pos]->setHostname(hostname, shm()->initialChecks);
|
||||
|
||||
// module type updated by now
|
||||
shm()->detType = Parallel(&Module::getDetectorType, {})
|
||||
@ -1538,6 +1521,129 @@ defs::xy DetectorImpl::calculatePosition(int moduleIndex,
|
||||
return pos;
|
||||
}
|
||||
|
||||
void DetectorImpl::verifyUniqueDetHost(const int port,
|
||||
std::vector<int> positions) const {
|
||||
// port for given positions
|
||||
if (positions.empty() || (positions.size() == 1 && positions[0] == -1)) {
|
||||
positions.resize(modules.size());
|
||||
std::iota(begin(positions), end(positions), 0);
|
||||
}
|
||||
std::vector<std::pair<std::string, int>> hosts(size());
|
||||
for (auto it : positions) {
|
||||
hosts[it].second = port;
|
||||
}
|
||||
verifyUniqueHost(true, hosts);
|
||||
}
|
||||
|
||||
void DetectorImpl::verifyUniqueRxHost(const int port,
|
||||
const int moduleId) const {
|
||||
std::vector<std::pair<std::string, int>> hosts(size());
|
||||
hosts[moduleId].second = port;
|
||||
verifyUniqueHost(false, hosts);
|
||||
}
|
||||
|
||||
std::pair<std::string, int>
|
||||
DetectorImpl::verifyUniqueDetHost(const std::string &name) {
|
||||
// extract port
|
||||
// C++17 could be auto [hostname, port] = ParseHostPort(name);
|
||||
auto res = ParseHostPort(name);
|
||||
std::string hostname = res.first;
|
||||
int port = res.second;
|
||||
if (port == 0) {
|
||||
port = DEFAULT_TCP_CNTRL_PORTNO;
|
||||
}
|
||||
|
||||
int detSize = size();
|
||||
// mod not yet added
|
||||
std::vector<std::pair<std::string, int>> hosts(detSize + 1);
|
||||
hosts[detSize].first = hostname;
|
||||
hosts[detSize].second = port;
|
||||
|
||||
verifyUniqueHost(true, hosts);
|
||||
return std::make_pair(hostname, port);
|
||||
}
|
||||
|
||||
std::pair<std::string, int>
|
||||
DetectorImpl::verifyUniqueRxHost(const std::string &name,
|
||||
std::vector<int> positions) const {
|
||||
// no checks if setting to none
|
||||
if (name == "none" || name.empty()) {
|
||||
return make_pair(name, 0);
|
||||
}
|
||||
// extract port
|
||||
// C++17 could be auto [hostname, port] = ParseHostPort(name);
|
||||
auto res = ParseHostPort(name);
|
||||
std::string hostname = res.first;
|
||||
int port = res.second;
|
||||
|
||||
// hostname and port for given positions
|
||||
if (positions.empty() || (positions.size() == 1 && positions[0] == -1)) {
|
||||
positions.resize(modules.size());
|
||||
std::iota(begin(positions), end(positions), 0);
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, int>> hosts(size());
|
||||
for (auto it : positions) {
|
||||
hosts[it].first = hostname;
|
||||
hosts[it].second = port;
|
||||
}
|
||||
|
||||
verifyUniqueHost(false, hosts);
|
||||
return std::make_pair(hostname, port);
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, int>>
|
||||
DetectorImpl::verifyUniqueRxHost(const std::vector<std::string> &names) const {
|
||||
if ((int)names.size() != size()) {
|
||||
throw RuntimeError(
|
||||
"Receiver hostnames size " + std::to_string(names.size()) +
|
||||
" does not match detector size " + std::to_string(size()));
|
||||
}
|
||||
|
||||
// extract ports
|
||||
std::vector<std::pair<std::string, int>> hosts;
|
||||
for (const auto &name : names) {
|
||||
hosts.push_back(ParseHostPort(name));
|
||||
}
|
||||
|
||||
verifyUniqueHost(false, hosts);
|
||||
return hosts;
|
||||
}
|
||||
|
||||
void DetectorImpl::verifyUniqueHost(
|
||||
bool isDet, std::vector<std::pair<std::string, int>> &hosts) const {
|
||||
|
||||
// fill from shm if not provided
|
||||
for (int i = 0; i != size(); ++i) {
|
||||
if (hosts[i].first.empty()) {
|
||||
hosts[i].first = (isDet ? modules[i]->getHostname()
|
||||
: modules[i]->getReceiverHostname());
|
||||
}
|
||||
if (hosts[i].second == 0) {
|
||||
hosts[i].second = (isDet ? modules[i]->getControlPort()
|
||||
: modules[i]->getReceiverPort());
|
||||
}
|
||||
}
|
||||
|
||||
// remove the ones without a hostname
|
||||
hosts.erase(std::remove_if(hosts.begin(), hosts.end(),
|
||||
[](const std::pair<std::string, int> &x) {
|
||||
return (x.first == "none" ||
|
||||
x.first.empty());
|
||||
}),
|
||||
hosts.end());
|
||||
|
||||
// must be unique
|
||||
if (hasDuplicates(hosts)) {
|
||||
throw RuntimeError(
|
||||
"Cannot set due to duplicate hostname-port number pairs.");
|
||||
}
|
||||
|
||||
for (auto it : hosts) {
|
||||
LOG(logDEBUG) << it.first << " " << it.second << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
defs::ROI DetectorImpl::getRxROI() const {
|
||||
if (shm()->detType == CHIPTESTBOARD) {
|
||||
throw RuntimeError("RxRoi not implemented for this Detector");
|
||||
|
@ -300,6 +300,17 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
Positions pos = {});
|
||||
void setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||
defs::detectorSettings sett, Positions pos);
|
||||
|
||||
void verifyUniqueDetHost(const int port, std::vector<int> positions) const;
|
||||
void verifyUniqueRxHost(const int port, const int moduleId) const;
|
||||
|
||||
std::pair<std::string, int> verifyUniqueDetHost(const std::string &name);
|
||||
std::pair<std::string, int>
|
||||
verifyUniqueRxHost(const std::string &name,
|
||||
std::vector<int> positions) const;
|
||||
std::vector<std::pair<std::string, int>>
|
||||
verifyUniqueRxHost(const std::vector<std::string> &names) const;
|
||||
|
||||
defs::ROI getRxROI() const;
|
||||
void setRxROI(const defs::ROI arg);
|
||||
void clearRxROI();
|
||||
@ -396,6 +407,10 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
defs::xy getPortGeometry() const;
|
||||
defs::xy calculatePosition(int moduleIndex, defs::xy geometry) const;
|
||||
|
||||
void
|
||||
verifyUniqueHost(bool isDet,
|
||||
std::vector<std::pair<std::string, int>> &hosts) const;
|
||||
|
||||
const int detectorIndex{0};
|
||||
SharedMemory<sharedDetector> shm{0, -1};
|
||||
SharedMemory<CtbConfig> ctb_shm{0, -1, CtbConfig::shm_tag()};
|
||||
|
@ -73,8 +73,8 @@ void Module::setHostname(const std::string &hostname,
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
client.close();
|
||||
try {
|
||||
initialDetectorServerChecks();
|
||||
checkDetectorVersionCompatibility();
|
||||
initialDetectorServerChecks();
|
||||
LOG(logINFO) << "Module Version Compatibility - Success";
|
||||
} catch (const RuntimeError &e) {
|
||||
if (!initialChecks) {
|
||||
@ -99,9 +99,28 @@ Module::getFrontEndFirmwareVersion(const fpgaPosition fpgaPosition) const {
|
||||
}
|
||||
|
||||
std::string Module::getControlServerLongVersion() const {
|
||||
char retval[MAX_STR_LENGTH]{};
|
||||
sendToDetector(F_GET_SERVER_VERSION, nullptr, retval);
|
||||
return retval;
|
||||
try {
|
||||
char retval[MAX_STR_LENGTH]{};
|
||||
sendToDetector(F_GET_SERVER_VERSION, nullptr, retval);
|
||||
return retval;
|
||||
}
|
||||
// throw with old server version (sends 8 bytes)
|
||||
catch (RuntimeError &e) {
|
||||
std::string emsg = std::string(e.what());
|
||||
if (emsg.find(F_GET_SERVER_VERSION) && emsg.find("8 bytes")) {
|
||||
throwDeprecatedServerVersion();
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void Module::throwDeprecatedServerVersion() const {
|
||||
uint64_t res = sendToDetectorStop<int64_t>(F_GET_SERVER_VERSION);
|
||||
std::cout << std::endl;
|
||||
std::ostringstream os;
|
||||
os << "Detector Server (Control) version (0x" << std::hex << res
|
||||
<< ") is incompatible with this client. Please update detector server!";
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
|
||||
std::string Module::getStopServerLongVersion() const {
|
||||
@ -1310,30 +1329,33 @@ std::string Module::getReceiverHostname() const {
|
||||
return std::string(shm()->rxHostname);
|
||||
}
|
||||
|
||||
void Module::setReceiverHostname(const std::string &receiverIP,
|
||||
void Module::setReceiverHostname(const std::string &hostname, const int port,
|
||||
const bool initialChecks) {
|
||||
LOG(logDEBUG1) << "Setting up Receiver hostname with " << receiverIP;
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Setting up Receiver hostname with " << hostname;
|
||||
if (port != 0) {
|
||||
oss << " at port " << port;
|
||||
}
|
||||
LOG(logDEBUG1) << oss.str();
|
||||
}
|
||||
|
||||
if (getRunStatus() == RUNNING) {
|
||||
throw RuntimeError("Cannot set receiver hostname. Acquisition already "
|
||||
"running. Stop it first.");
|
||||
}
|
||||
|
||||
if (receiverIP == "none") {
|
||||
if (hostname == "none") {
|
||||
memset(shm()->rxHostname, 0, MAX_STR_LENGTH);
|
||||
strcpy_safe(shm()->rxHostname, "none");
|
||||
shm()->useReceiverFlag = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// start updating
|
||||
std::string host = receiverIP;
|
||||
auto res = split(host, ':');
|
||||
if (res.size() > 1) {
|
||||
host = res[0];
|
||||
shm()->rxTCPPort = std::stoi(res[1]);
|
||||
strcpy_safe(shm()->rxHostname, hostname.c_str());
|
||||
if (port != 0) {
|
||||
shm()->rxTCPPort = port;
|
||||
}
|
||||
strcpy_safe(shm()->rxHostname, host.c_str());
|
||||
shm()->useReceiverFlag = true;
|
||||
|
||||
try {
|
||||
|
@ -93,6 +93,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
int64_t getFrontEndFirmwareVersion(const fpgaPosition fpgaPosition) const;
|
||||
std::string getControlServerLongVersion() const;
|
||||
std::string getStopServerLongVersion() const;
|
||||
void throwDeprecatedServerVersion() const;
|
||||
std::string getDetectorServerVersion() const;
|
||||
std::string getHardwareVersion() const;
|
||||
std::string getKernelVersion() const;
|
||||
@ -280,7 +281,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
* ************************************************/
|
||||
bool getUseReceiverFlag() const;
|
||||
std::string getReceiverHostname() const;
|
||||
void setReceiverHostname(const std::string &receiver,
|
||||
void setReceiverHostname(const std::string &hostname, const int port,
|
||||
const bool initialChecks);
|
||||
int getReceiverPort() const;
|
||||
int setReceiverPort(int port_number);
|
||||
|
@ -116,14 +116,8 @@ TEST_CASE("detectorserverversion", "[.cmd]") {
|
||||
TEST_CASE("hardwareversion", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type != defs::EIGER) {
|
||||
REQUIRE_NOTHROW(proxy.Call("hardwareversion", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("hardwareversion", {"0"}, -1, PUT));
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("hardwareversion", {"0"}, -1, PUT));
|
||||
REQUIRE_THROWS(proxy.Call("hardwareversion", {}, -1, GET));
|
||||
}
|
||||
REQUIRE_NOTHROW(proxy.Call("hardwareversion", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("hardwareversion", {"0"}, -1, PUT));
|
||||
}
|
||||
|
||||
TEST_CASE("kernelversion", "[.cmd]") {
|
||||
@ -519,7 +513,7 @@ TEST_CASE("gappixels", "[.cmd]") {
|
||||
|
||||
// test eiger(quad or full module only)
|
||||
bool gapPixelTest = false;
|
||||
if (det_type == defs:: || det_type == defs::MOENCH)
|
||||
if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH)
|
||||
gapPixelTest = true;
|
||||
else if (det_type == defs::EIGER) {
|
||||
bool quad = det.getQuad().squash(false);
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -16,6 +17,8 @@ namespace sls {
|
||||
#define gettid() syscall(SYS_gettid)
|
||||
#endif
|
||||
|
||||
void func(int signum) { wait(NULL); }
|
||||
|
||||
Arping::Arping() {}
|
||||
|
||||
Arping::~Arping() {
|
||||
@ -44,10 +47,11 @@ pid_t Arping::GetProcessId() const { return childPid; }
|
||||
bool Arping::IsRunning() const { return runningFlag; }
|
||||
|
||||
void Arping::StartProcess() {
|
||||
TestCommands();
|
||||
|
||||
// to prevent zombies from child processes being killed
|
||||
signal(SIGCHLD, SIG_IGN);
|
||||
signal(SIGCHLD, func);
|
||||
|
||||
// test once to throw exception if arping failed
|
||||
TestForErrors();
|
||||
|
||||
// Needs to be a fork and udp socket deleted after Listening threads
|
||||
// done running to prevent udp socket cannot bind because of popen
|
||||
@ -90,7 +94,7 @@ void Arping::ProcessExecution() {
|
||||
}
|
||||
}
|
||||
|
||||
void Arping::TestCommands() {
|
||||
void Arping::TestForErrors() {
|
||||
// atleast one interface must be set up
|
||||
if (commands[0].empty()) {
|
||||
throw RuntimeError(
|
||||
@ -116,7 +120,8 @@ std::string Arping::ExecuteCommands() {
|
||||
FILE *sysFile = popen(cmd.c_str(), "r");
|
||||
if (sysFile == NULL) {
|
||||
std::ostringstream os;
|
||||
os << "Could not Arping [" << cmd << " ] : Popen fail";
|
||||
os << "Could not Arping (" << cmd << " ) : Popen fail ("
|
||||
<< strerror(errno) << ')';
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@ -128,7 +133,7 @@ std::string Arping::ExecuteCommands() {
|
||||
// check exit status of command
|
||||
if (pclose(sysFile)) {
|
||||
std::ostringstream os;
|
||||
os << "Could not arping[" << cmd << "] : " << output;
|
||||
os << "Could not arping (" << cmd << ") : " << strerror(errno);
|
||||
return os.str();
|
||||
} else {
|
||||
LOG(logDEBUG) << output;
|
||||
|
@ -28,7 +28,7 @@ class Arping {
|
||||
void StopProcess();
|
||||
|
||||
private:
|
||||
void TestCommands();
|
||||
void TestForErrors();
|
||||
std::string ExecuteCommands();
|
||||
void ProcessExecution();
|
||||
|
||||
|
@ -402,7 +402,8 @@ int ClientInterface::setup_receiver(Interface &socket) {
|
||||
impl()->setDynamicRange(arg.dynamicRange);
|
||||
}
|
||||
impl()->setTimingMode(arg.timMode);
|
||||
if (detType == EIGER || detType == CHIPTESTBOARD || detType == MYTHEN3) {
|
||||
if (detType == EIGER || detType == CHIPTESTBOARD ||
|
||||
detType == MYTHEN3) {
|
||||
impl()->setTenGigaEnable(arg.tenGiga);
|
||||
}
|
||||
if (detType == CHIPTESTBOARD) {
|
||||
|
@ -14,14 +14,14 @@ HDF5DataFile::HDF5DataFile(int index, std::mutex *hdf5Lib)
|
||||
"frame number",
|
||||
"exp length or sub exposure time",
|
||||
"packets caught",
|
||||
"bunch id",
|
||||
"detector specific 1",
|
||||
"timestamp",
|
||||
"mod id",
|
||||
"row",
|
||||
"column",
|
||||
"reserved",
|
||||
"debug",
|
||||
"round robin number",
|
||||
"detector specific 2",
|
||||
"detector specific 3",
|
||||
"detector specific 4",
|
||||
"detector type",
|
||||
"detector header version",
|
||||
"packets caught bit mask",
|
||||
@ -317,7 +317,7 @@ void HDF5DataFile::WriteParameterDatasets(const uint64_t currentFrameNumber,
|
||||
dataSetPara[2]->write(&header.packetNumber, parameterDataTypes[2],
|
||||
memspace, *dataSpacePara);
|
||||
i = 3;
|
||||
dataSetPara[3]->write(&header.bunchId, parameterDataTypes[3], memspace,
|
||||
dataSetPara[3]->write(&header.detSpec1, parameterDataTypes[3], memspace,
|
||||
*dataSpacePara);
|
||||
i = 4;
|
||||
dataSetPara[4]->write(&header.timestamp, parameterDataTypes[4],
|
||||
@ -332,13 +332,13 @@ void HDF5DataFile::WriteParameterDatasets(const uint64_t currentFrameNumber,
|
||||
dataSetPara[7]->write(&header.column, parameterDataTypes[7], memspace,
|
||||
*dataSpacePara);
|
||||
i = 8;
|
||||
dataSetPara[8]->write(&header.reserved, parameterDataTypes[8], memspace,
|
||||
dataSetPara[8]->write(&header.detSpec2, parameterDataTypes[8], memspace,
|
||||
*dataSpacePara);
|
||||
i = 9;
|
||||
dataSetPara[9]->write(&header.debug, parameterDataTypes[9], memspace,
|
||||
dataSetPara[9]->write(&header.detSpec3, parameterDataTypes[9], memspace,
|
||||
*dataSpacePara);
|
||||
i = 10;
|
||||
dataSetPara[10]->write(&header.roundRNumber, parameterDataTypes[10],
|
||||
dataSetPara[10]->write(&header.detSpec4, parameterDataTypes[10],
|
||||
memspace, *dataSpacePara);
|
||||
i = 11;
|
||||
dataSetPara[11]->write(&header.detType, parameterDataTypes[11],
|
||||
|
@ -1132,7 +1132,7 @@ int Implementation::getUDPSocketBufferSize() const {
|
||||
|
||||
void Implementation::setUDPSocketBufferSize(const int s) {
|
||||
size_t listSize = listener.size();
|
||||
if ((generalData->detType == JUNGFRAU || generalData->detType == MOENCH ||
|
||||
if ((generalData->detType == JUNGFRAU || generalData->detType == MOENCH ||
|
||||
generalData->detType == GOTTHARD2) &&
|
||||
(int)listSize != generalData->numUDPInterfaces) {
|
||||
throw RuntimeError("Number of Interfaces " +
|
||||
|
@ -635,8 +635,8 @@ void MasterAttributes::GetMoenchBinaryAttributes(
|
||||
}
|
||||
|
||||
#ifdef HDF5C
|
||||
void MasterAttributes::WriteMoenchuHDF5Attributes(H5::H5File *fd,
|
||||
H5::Group *group) {
|
||||
void MasterAttributes::WriteMoenchHDF5Attributes(H5::H5File *fd,
|
||||
H5::Group *group) {
|
||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
MasterAttributes::WriteHDF5NumUDPInterfaces(fd, group);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
// #include <utility> //support pair in vectors
|
||||
|
||||
#include "sls/TypeTraits.h"
|
||||
|
||||
@ -148,6 +149,12 @@ Squash(const Container &c, typename Container::value_type default_value = {}) {
|
||||
return default_value;
|
||||
}
|
||||
|
||||
template <typename Container> bool hasDuplicates(Container c) {
|
||||
std::sort(c.begin(), c.end());
|
||||
auto pos = std::adjacent_find(c.begin(), c.end());
|
||||
return pos != c.end(); // if we found something there are duplicates
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<is_container<T>::value, bool>::type
|
||||
removeDuplicates(T &c) {
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace sls {
|
||||
@ -59,4 +60,6 @@ bool is_int(const std::string &s);
|
||||
bool replace_first(std::string *s, const std::string &substr,
|
||||
const std::string &repl);
|
||||
|
||||
std::pair<std::string, int> ParseHostPort(const std::string &s);
|
||||
|
||||
} // namespace sls
|
||||
|
@ -1,13 +1,13 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
/** API versions */
|
||||
#define RELEASE "developer"
|
||||
#define APICTB "developer 0x230224"
|
||||
#define APIGOTTHARD "developer 0x230224"
|
||||
#define RELEASE "developer"
|
||||
#define APICTB "developer 0x230224"
|
||||
#define APIGOTTHARD "developer 0x230224"
|
||||
#define APIGOTTHARD2 "developer 0x230224"
|
||||
#define APIJUNGFRAU "developer 0x230224"
|
||||
#define APIMYTHEN3 "developer 0x230224"
|
||||
#define APIMOENCH "developer 0x230224"
|
||||
#define APIEIGER "developer 0x230224"
|
||||
#define APILIB "developer 0x230224"
|
||||
#define APIRECEIVER "developer 0x230224"
|
||||
#define APIJUNGFRAU "developer 0x230224"
|
||||
#define APIMYTHEN3 "developer 0x230224"
|
||||
#define APIMOENCH "developer 0x230224"
|
||||
#define APILIB "developer 0x230224"
|
||||
#define APIRECEIVER "developer 0x230224"
|
||||
#define APIEIGER "developer 0x230224"
|
||||
|
@ -50,4 +50,17 @@ bool replace_first(std::string *s, const std::string &substr,
|
||||
return false;
|
||||
}
|
||||
|
||||
std::pair<std::string, int> ParseHostPort(const std::string &s) {
|
||||
// TODO deal with to many :, port not there?
|
||||
// no port return hostname as is and port as 0
|
||||
std::string host;
|
||||
int port{0};
|
||||
auto res = split(s, ':');
|
||||
host = res[0];
|
||||
if (res.size() > 1) {
|
||||
port = std::stoi(res[1]);
|
||||
}
|
||||
return std::make_pair(host, port);
|
||||
}
|
||||
|
||||
}; // namespace sls
|
@ -136,6 +136,23 @@ TEST_CASE("compare a vector of arrays", "[support]") {
|
||||
CHECK(minusOneIfDifferent(vec1) == arr);
|
||||
}
|
||||
|
||||
TEST_CASE("check if vector has duplicates") {
|
||||
std::vector<int> vec{1, 0, 2, 5, 3, 1, 8, 6};
|
||||
REQUIRE(hasDuplicates(vec) == true);
|
||||
}
|
||||
|
||||
TEST_CASE("check for duplicates in vector of pairs") {
|
||||
std::vector<std::pair<std::string, int>> vec;
|
||||
vec.emplace_back("localhost", 1954);
|
||||
REQUIRE(hasDuplicates(vec) == false);
|
||||
|
||||
vec.emplace_back("localhost", 1800);
|
||||
REQUIRE(hasDuplicates(vec) == false);
|
||||
|
||||
vec.emplace_back("localhost", 1954);
|
||||
REQUIRE(hasDuplicates(vec) == true);
|
||||
}
|
||||
|
||||
TEST_CASE("remove duplicates from vector") {
|
||||
std::vector<int> v{5, 6, 5, 3};
|
||||
auto r = removeDuplicates(v);
|
||||
|
@ -108,6 +108,21 @@ TEST_CASE("replace --help") {
|
||||
REQUIRE(s == "list");
|
||||
}
|
||||
|
||||
TEST_CASE("port host") {
|
||||
std::string hostport = "localhost:1954";
|
||||
auto res = ParseHostPort(hostport);
|
||||
REQUIRE(res.first == "localhost");
|
||||
REQUIRE(res.second == 1954);
|
||||
}
|
||||
|
||||
TEST_CASE("port missing") {
|
||||
// TODO! is this the intended result?
|
||||
std::string host = "localhost";
|
||||
auto res = ParseHostPort(host);
|
||||
REQUIRE(res.first == "localhost");
|
||||
REQUIRE(res.second == 0);
|
||||
}
|
||||
|
||||
// TEST_CASE("concat things not being strings")
|
||||
|
||||
} // namespace sls
|
||||
|
Reference in New Issue
Block a user