mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 15:27:13 +02:00
Compare commits
130 Commits
sophieesrf
...
moenchv0.1
Author | SHA1 | Date | |
---|---|---|---|
52f74142b1 | |||
18ab437ae5 | |||
3b56091e2f | |||
dcad6c80ce | |||
6abfdcb2c8 | |||
9e5ec6a57b | |||
9d3134c3de | |||
563d644d2f | |||
e379b98631 | |||
f98259adc9 | |||
88e0914405 | |||
9d8aa5fe91 | |||
dceea92f1a | |||
2815458652 | |||
d8140d8db9 | |||
4d0090dfcc | |||
e98d60c26e | |||
cd3135c01d | |||
40dedb8b07 | |||
2e83db7d45 | |||
817736fcd5 | |||
660ed4c177 | |||
0d96272db5 | |||
38a6393dde | |||
4aa720eecb | |||
d68c3b73a8 | |||
def79807f6 | |||
eb89d12f41 | |||
c477970cf0 | |||
03ae32dcf3 | |||
5a394c080f | |||
e631414526 | |||
d2bce7e372 | |||
f9b95b63eb | |||
c2db073d5e | |||
970d448e73 | |||
b236c14a66 | |||
80c0d4e10e | |||
46db575cc4 | |||
6f0c505c01 | |||
06d698166f | |||
5a139d70b5 | |||
33d1b11279 | |||
b163180d6f | |||
cab9dff225 | |||
7d8188fc11 | |||
64229ca32b | |||
ae8678cdc2 | |||
4aa0d26f26 | |||
c52025dd7c | |||
9f84bf7175 | |||
235002cdd4 | |||
c784f0f539 | |||
961489edb1 | |||
255931bbde | |||
781152a772 | |||
7b4910ee87 | |||
021212372b | |||
59cb9c84c2 | |||
e8612a481c | |||
d67b4765ea | |||
8773de93e9 | |||
ef20fa6f3c | |||
19e7ced332 | |||
f288390255 | |||
30e060b3b1 | |||
29ba9ae6f7 | |||
2b2b53f598 | |||
1ebb07198a | |||
ed0b22b500 | |||
548036a602 | |||
1b55fdad86 | |||
14c899e7cf | |||
b3d4e90f7f | |||
cedd275892 | |||
588037fd18 | |||
1700d9884a | |||
e0b8fb3609 | |||
b7f62fcd47 | |||
5b6ec303d7 | |||
cea6c30ded | |||
0781344117 | |||
63c130a380 | |||
7945d15beb | |||
4e446f1f39 | |||
83600fcb15 | |||
2a28333a96 | |||
830f92dedc | |||
87e8333dfd | |||
b3ccd5e1a1 | |||
f0ac49190a | |||
921ae01bbe | |||
fa175ac934 | |||
0018fa46f8 | |||
c934e92a41 | |||
da4253fe13 | |||
3cab1bc0fe | |||
d74a8368b8 | |||
39ebd81230 | |||
823c855ef4 | |||
7fadf4feb4 | |||
f86578cfc3 | |||
a0512a01d5 | |||
bdd37fa7c2 | |||
a96a019435 | |||
dd3f4aa81d | |||
1102153d2b | |||
ab7e63c20f | |||
f1333c7a90 | |||
e77cdb35dd | |||
52b1e98726 | |||
df75fef6f6 | |||
44fdc46c11 | |||
147194e8af | |||
05055eb283 | |||
0dc1e10bd3 | |||
e38e500e16 | |||
134f13fc52 | |||
41fb6c26a2 | |||
73fcef5f6d | |||
e9cc91698e | |||
6213b5e07a | |||
08aacf76ac | |||
711e0d771e | |||
2fc98c7a54 | |||
3b6ead7783 | |||
40c96b5562 | |||
6bb7195a2c | |||
9ae1289616 | |||
3baa677a2e |
45
.travis.yml
Normal file
45
.travis.yml
Normal file
@ -0,0 +1,45 @@
|
||||
sudo: false
|
||||
|
||||
language: cpp
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
env: CONDA_PY=3.6
|
||||
|
||||
dist: trusty
|
||||
|
||||
install:
|
||||
- sudo apt-get update
|
||||
- ldd --version
|
||||
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
|
||||
- bash miniconda.sh -b -p $HOME/miniconda
|
||||
- export PATH="$HOME/miniconda/bin:$PATH"
|
||||
- rm -f miniconda.sh
|
||||
- hash -r
|
||||
- conda config --set always_yes yes --set changeps1 no
|
||||
- conda config --add channels conda-forge
|
||||
- conda config --add channels slsdetectorgroup
|
||||
- conda update conda
|
||||
- conda update --all
|
||||
- conda install conda-build anaconda-client
|
||||
|
||||
# Useful for debugging any issues with conda
|
||||
- conda info -a
|
||||
|
||||
|
||||
# Replace dep1 dep2 ... with your dependencies
|
||||
- conda create -q -n test-environment python=$CONDA_PY
|
||||
- source activate test-environment
|
||||
- conda-build .
|
||||
|
||||
script:
|
||||
- echo "No test scripts to be run!"
|
||||
|
||||
|
||||
deploy:
|
||||
provider: script
|
||||
script: find $HOME/miniconda/conda-bld/${TRAVIS_OS_NAME}-64 -name "*.tar.bz2" -exec anaconda -t $CONDA_TOKEN upload --force {} \;
|
||||
on:
|
||||
branch: developer
|
||||
|
@ -11,14 +11,14 @@ option (USE_GUI "GUI" OFF)
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++98 -Wno-misleading-indentation")
|
||||
else ()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++98")
|
||||
endif ()
|
||||
|
||||
find_package(Qt4)
|
||||
find_package(Qwt 6)
|
||||
find_package(CBF)
|
||||
find_package(Doxygen)
|
||||
find_package(PNG REQUIRED)
|
||||
# find_package(PNG REQUIRED)
|
||||
|
||||
if (USE_HDF5)
|
||||
find_package(HDF5 1.10 COMPONENTS CXX)
|
||||
|
3
Makefile
3
Makefile
@ -19,6 +19,7 @@ RECEIVERDIR = $(LIBRARYRXRDIR)
|
||||
CALWIZDIR = $(WD)/calibrationWizards
|
||||
MANDIR = $(WD)/manual
|
||||
CALIBDIR = $(WD)/slsDetectorCalibration
|
||||
MANAPIDIR = $(MANDIR)/manual-api
|
||||
|
||||
TABSPACE := "\t"
|
||||
|
||||
@ -79,6 +80,7 @@ slsReceiver_static: receiver
|
||||
receiver: #libreceiver
|
||||
# cd $(RECEIVERDIR) && $(MAKE) receiver FLAGS='$(FLAGS)' DESTDIR='$(BINDIR)' LIBS='$(LDFLAGRXR)' INCLUDES='$(INCLUDESRXR)' LIBDIR='$(LIBDIR)'
|
||||
cd $(RECEIVERDIR) && $(MAKE) FLAGS='$(FLAGS)' DESTDIR='$(BINDIR)' LIBS='$(LDFLAGRXR)' INCLUDES='$(INCLUDESRXR)' LIBDIR='$(LIBDIR)'
|
||||
cd $(MANAPIDIR) && $(MAKE) slsMultiReceiver
|
||||
@echo ""
|
||||
@echo "#######################################"
|
||||
@echo "# Back in slsDetectorPackage Makefile #"
|
||||
@ -151,6 +153,7 @@ clean:
|
||||
cd $(DOCDIR) && rm -rf *
|
||||
rm -rf slsDetectorPackageDocs;
|
||||
rm -rf $(DETAILDOC)
|
||||
rm -rf $(MANAPIDIR)/slsMultiReceiver
|
||||
|
||||
|
||||
#install_lib:
|
||||
|
@ -2,7 +2,7 @@
|
||||
Detailed documentation can be found on the [official site.](https://www.psi.ch/detectors/users-support)
|
||||
|
||||
### Binaries
|
||||
Documentation to obtain the binaries via the conda package is available [here.](https://github.com/slsdetectorgroup/sls_detector_software)
|
||||
Documentation to obtain the binaries via the conda package is available for [lib](https://github.com/slsdetectorgroup/sls_detector_lib) and [gui](https://github.com/slsdetectorgroup/sls_detector_gui)
|
||||
|
||||
### Source code
|
||||
One can also obtain the source code from this repository and compile while realizing the setup dependencies as required.
|
||||
@ -19,7 +19,7 @@ Requirements: Qt 4.8 and Qwt 6.0
|
||||
```
|
||||
If either of them does not exist, the GUI client will not be built.
|
||||
|
||||
* Calibration wizards<br>
|
||||
* Advanced user Calibration wizards<br>
|
||||
Requirements: ROOT
|
||||
```
|
||||
export ROOTSYS=/usr/local/root-5.34
|
||||
@ -43,6 +43,7 @@ Usage: [-c] [-b] [-h] [-d HDF5 directory] [-j]<br>
|
||||
* -r: Build/Rebuilds only receiver<br>
|
||||
* -g: Build/Rebuilds only gui<br>
|
||||
* -j: Number of threads to compile through<br>
|
||||
* -e: Debug mode
|
||||
|
||||
Basic Option:
|
||||
./cmk.sh -b
|
||||
@ -86,5 +87,5 @@ After compiling, the libraries and executables will be found at `bin` directory
|
||||
```
|
||||
$ ls bin/
|
||||
gui_client libSlsDetector.a libSlsDetector.so libSlsReceiver.a libSlsReceiver.so
|
||||
sls_detector_acquire sls_detector_get slsDetectorGui sls_detector_help sls_detector_put slsReceiver
|
||||
sls_detector_acquire sls_detector_get slsDetectorGui sls_detector_help sls_detector_put slsReceiver slsMultiReceiver
|
||||
```
|
||||
|
507
RELEASE.txt
507
RELEASE.txt
@ -1 +1,508 @@
|
||||
SLS Detector Package 4.0.0 released on 27.09.2018
|
||||
=================================================
|
||||
|
||||
|
||||
|
||||
INTRODUCTION
|
||||
|
||||
This document describes the differences between 4.0.0 and 3.1.4 releases.
|
||||
|
||||
Download
|
||||
--------
|
||||
|
||||
The Source Code (Default C++ API):
|
||||
https://github.com/slsdetectorgroup/slsDetectorPackage
|
||||
|
||||
The Conda Lib Package:
|
||||
https://github.com/slsdetectorgroup/sls_detector_lib
|
||||
|
||||
The Conda GUI Package:
|
||||
https://github.com/slsdetectorgroup/sls_detector_gui
|
||||
|
||||
The Python Interface (including the package):
|
||||
https://github.com/slsdetectorgroup/sls_detector
|
||||
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
Manual (HTML & PDF):
|
||||
https://www.psi.ch/detectors/documentation
|
||||
slsDetectorPackage/manual/docs/
|
||||
|
||||
Command Line Documentation:
|
||||
manual/docs/html/slsDetectorClientDocs/index.html
|
||||
manual/docs/pdf/slsDetectorClientDocs.pdf
|
||||
|
||||
C++ API Documentation:
|
||||
manual/docs/html/slsDetectorUsersDocs/index.html
|
||||
manual/docs/pdf/slsDetectorUsersDocs.pdf
|
||||
|
||||
C++ API Example:
|
||||
manual/manual-api/mainClient.cpp
|
||||
manual/manual-api/mainReceiver.cpp
|
||||
|
||||
Python API Documentation:
|
||||
https://slsdetectorgroup.github.io/sls_detector/
|
||||
|
||||
Further Documentation:
|
||||
https://www.psi.ch/detectors/users-support
|
||||
|
||||
|
||||
Support
|
||||
-------
|
||||
|
||||
General Software related:
|
||||
dhanya.thattil@psi.ch
|
||||
anna.bergamaschi@psi.ch
|
||||
|
||||
Python related:
|
||||
erik.frojdh@psi.ch
|
||||
|
||||
|
||||
|
||||
CONTENTS
|
||||
|
||||
1. Firmware Requirements
|
||||
2. Changes in User Interface
|
||||
3. New/Modified Commands
|
||||
4. Other New Features
|
||||
5. Resolved Issues
|
||||
6. Known Issues
|
||||
7. Next Major Release Plans
|
||||
|
||||
|
||||
|
||||
1. Firmware Requirements
|
||||
========================
|
||||
|
||||
Gotthard
|
||||
========
|
||||
Minimum compatible version : 11.01.2013
|
||||
Latest version : 08.02.2018 (50um and 25um Master)
|
||||
09.02.2018 (25 um Slave)
|
||||
Eiger
|
||||
=====
|
||||
Minimum compatible version : 22
|
||||
Latest version : 22
|
||||
|
||||
Jungfrau
|
||||
========
|
||||
Minimum compatible version : 15.06.2018
|
||||
Latest version : 15.06.2018
|
||||
|
||||
|
||||
Detector Upgrade
|
||||
================
|
||||
Gotthard Cannot be upgraded remotely. Requires programming via USB blaster
|
||||
Eiger Can be upgraded remotely via bit files
|
||||
Jungfrau Can be upgraded remotely using sls_detector_put programfpga <pof>
|
||||
|
||||
Instructions available at
|
||||
https://www.psi.ch/detectors/installation-instructions
|
||||
under Detector Upgrade -> [Detector Type] -> Firmware.
|
||||
|
||||
|
||||
Please refer to the link below for more details on the firmware versions.
|
||||
https://www.psi.ch/detectors/firmware.
|
||||
|
||||
|
||||
|
||||
2. Changes in User Interface
|
||||
============================
|
||||
|
||||
Client
|
||||
------
|
||||
|
||||
1. Shared Memory:
|
||||
|
||||
POSIX shared memory has been implemented and they are typically created in
|
||||
/dev/shm/ folder.
|
||||
|
||||
A multiSlsDetector object will create a shared memory segment with naming style:
|
||||
slsDetectorPackage_x_[_z]
|
||||
and an slsDetector object will create a shared memory segment with naming style:
|
||||
slsDetectorPackage_x_sls_y[_z]
|
||||
|
||||
where
|
||||
x is the multi detector id
|
||||
y is the sls detector id
|
||||
z is the environment variable SLSDETNAME, if set.
|
||||
They can be deleted directly.
|
||||
|
||||
Environment variable SLSDETNAME included for user-friendliness
|
||||
of using 2 different detectors from the same client pc. One needn't use
|
||||
different multi detector id if the SLSDETNAME is different for both consoles.
|
||||
|
||||
Constructor will fail if shared memory size is different (different package
|
||||
releases/detectors). Loading config file cleans shared memory.
|
||||
|
||||
|
||||
2. Exceptions in constructors:
|
||||
|
||||
All constructors that have an error throws an exception. For this release,
|
||||
this is caught within the package and interfaced as error codes or messages
|
||||
to the users using command line or API.
|
||||
|
||||
As a result:
|
||||
- slsDetectorsUsers constructor signature now includes a success flag.
|
||||
- If one uses multiSlsDetector, slsDetector, ZmqSocket classes directly,
|
||||
catch exceptions from constructors.
|
||||
- In future releases, the exception will be thrown
|
||||
outside the package for the users to handle it.
|
||||
|
||||
|
||||
3. API Compatibility:
|
||||
|
||||
Client now checks API version of Detector Server - Client and Receiver - Client
|
||||
when connecting for the first time to detector server or receiver server
|
||||
and the online flags have not been set in shm.
|
||||
|
||||
Upon failure, error messages will ensue and further commands will not
|
||||
be executed. Detector servers referred to are only for Eiger, Jungfrau and Gotthard.
|
||||
|
||||
Previously, the detector server would exit on mismatched Firmware-Detector
|
||||
server mismatch. They now wait for client to ask for compatibility check,
|
||||
which is done the first time client connects to the detector and the
|
||||
online flag in shm has not been set.
|
||||
|
||||
|
||||
4. Commands "type", "id" and "replace" are removed.
|
||||
|
||||
|
||||
Receiver
|
||||
--------
|
||||
|
||||
1. Reciever Header Structure in file writing and call back:
|
||||
|
||||
sls_receiver_header structure added to sls_receiver_defs.h for image headers
|
||||
in file writing.
|
||||
|
||||
#define MAX_NUM_PACKETS 512
|
||||
typedef std::bitset<MAX_NUM_PACKETS> sls_bitset;
|
||||
typedef struct {
|
||||
sls_detector_header detHeader; /**< is the detector header */
|
||||
sls_bitset packetsMask; /**< is the packets caught bit mask */
|
||||
} sls_receiver_header;
|
||||
|
||||
It includes the detector header structure + bitmask of 512 bits,
|
||||
where each bit represents a packet caught. This is useful in saving time
|
||||
in writing to file by not padding missing packets and still retaining useful data.
|
||||
|
||||
The binary and HDF5 writer version number changed from 1.0 to 2.0.
|
||||
The detector header version remains as 1.0.
|
||||
|
||||
registerCallBackRawDataReady modified to give this structure pointer,
|
||||
instead of individual structure member pointers.
|
||||
|
||||
|
||||
2. ZmqSocket class:
|
||||
|
||||
If one uses ZmqSocket.h, then the json header has to be parsed outside
|
||||
the class to allow the user to remove the restriction in extracting all data
|
||||
from the json header.
|
||||
|
||||
|
||||
3. Receiver Call back with modified size:
|
||||
|
||||
registerCallBackRawDataModifyReady call back that is similar to the receiver
|
||||
registerCallBackRawDataReady has been added to allow the call back to
|
||||
specify an updated size of image after call back. This is in view to process
|
||||
an image in call back (including extract only a region of the image) and
|
||||
provide this updated size in callback. This new resized/processed image
|
||||
will be written to file or streamed out via zmq. This is useful in ROI
|
||||
selection in the receiver.
|
||||
|
||||
This also means that the call back is now called before writing to file.
|
||||
|
||||
|
||||
|
||||
3. New/Modified Commands
|
||||
========================
|
||||
|
||||
Client
|
||||
------
|
||||
|
||||
1. add (modified):
|
||||
appends detector to end of multi detector list.
|
||||
|
||||
2. replace:
|
||||
sets hostname/ip address for a single detector.
|
||||
|
||||
3. user:
|
||||
get user details from shared memory.
|
||||
|
||||
4. checkdetversion:
|
||||
checks client version compatibility with detector server.
|
||||
|
||||
5. checkrecversion:
|
||||
checks client version compatibility with receiver server.
|
||||
|
||||
|
||||
Receiver
|
||||
--------
|
||||
|
||||
1. rx_zmqip:
|
||||
sets/gets the zmq (TCP) ip of the receiver from where data is streamed
|
||||
out from. (Eg. to the gui or intermediate process). By default, it is
|
||||
the same as the zmqip.
|
||||
|
||||
2. zmqip:
|
||||
sets/gets the zmq (TCP) ip, where client listens to, to reconstuct images.
|
||||
(Eg. from receiver or intermediate process). By default, it is the same
|
||||
as rx_zmqip.
|
||||
|
||||
3. rx_jsonaddheader:
|
||||
sets/gets additional json header to be streamed out with the zmq from
|
||||
receiver. Default is empty. Eg. p rx_jsonaddheader \"what\":\"nothing\"
|
||||
|
||||
4. r_discardpolicy:
|
||||
sets/gets the frame discard policy in the receiver.
|
||||
nodiscard - no discard (default),
|
||||
discardempty - discard only empty frames,
|
||||
discardpartial - discard any partial frame(fastest)
|
||||
|
||||
5. r_padding:
|
||||
sets/gets the frame padding in the receiver.
|
||||
0 does not pad partial frames(fastest),
|
||||
1 (default) pads partial frames.
|
||||
One can look at bitmask in the sls_receiver_header to process the unpadded
|
||||
partial frames later.
|
||||
|
||||
6. activate (modified):
|
||||
Extra option added to pad or unpad images in receivers when deactivated.
|
||||
activate i [padding option], where i is activate/deactivate and padding
|
||||
option is "padding" (default) or "nopadding".
|
||||
|
||||
7. rx_udpsocksize:
|
||||
sets/gets the UDP socket buffer size. Already attempts to set by default
|
||||
to 100mb, 2gb for Jungfrau. Does not remember custom values in client
|
||||
shared memory, so must be initialized each time after setting receiver
|
||||
hostname in config file.
|
||||
|
||||
8. rx_realudpsocksize:
|
||||
gets the actual UDP socket buffer size. Usually double the set udp socket
|
||||
buffer size due to kernel bookkeeping.
|
||||
|
||||
9. r_framesperfile:
|
||||
sets/gets the frames per file in receiver. 0 means infinite or all frames
|
||||
in a single file. Default of Eiger changed from 2k to 10k.
|
||||
|
||||
|
||||
Eiger Specific
|
||||
--------------
|
||||
|
||||
1. status trigger:
|
||||
To trigger internally via software, one can use "status trigger".
|
||||
|
||||
2. subdeadtime:
|
||||
sets/gets sub frame dead time in s in 32 bit mode. Subperiod is set in
|
||||
the detector by subexptime + subdeadtime. This value is normally a
|
||||
constant set by an expert catered to individual detector modules in the
|
||||
config file. Receiver files writes master file metadata subperiod
|
||||
instead of subdeadtime.
|
||||
|
||||
3. gappixels:
|
||||
enables/disables gap pixels in system (detector & receiver). 1 sets,
|
||||
0 unsets. In Receiver, 4 bit gap pixels mode is not implemented, but is
|
||||
implemented in client data call back. Gap pixels are at module level
|
||||
and not at multi module level.
|
||||
|
||||
4. measuredperiod:
|
||||
gets the measured frame period (time between last frame and the previous
|
||||
one) in s. Makes sense only for acquisitions of more than 1 frame.
|
||||
|
||||
5. measuredsubperiod:
|
||||
gets the measured subframe period (time between last subframe and the
|
||||
previous one) in s in 32 bit mode.
|
||||
|
||||
6. flags(modified):
|
||||
extra flags "nooverflow" (default) and "overflow" for sub images in 32
|
||||
bit mode. If set to overflow, it will set MSB of pixel data high if
|
||||
there was any saturation in any of the sub images 32 bit mode.
|
||||
|
||||
|
||||
Jungfrau Specific
|
||||
-----------------
|
||||
|
||||
1. storagecells:
|
||||
sets/gets number of additional storage cells per acquisition. For very
|
||||
advanced users only. Range: 0-15. Default: 0.
|
||||
The #images = #frames * #cycles * (#storagecells +1).
|
||||
|
||||
2. storage_start:
|
||||
sets/gets the storage cell that stores the first acquisition of the series.
|
||||
For very advanced users only. Range: 0-15. Default: 15(0xf).
|
||||
|
||||
|
||||
|
||||
4. Other New Features
|
||||
=====================
|
||||
|
||||
Client
|
||||
------
|
||||
|
||||
1. (Jungfrau & Gotthard) Settingsdir and caldir is removed from config file.
|
||||
Default dacs are stored in detector server. Hence, these folders
|
||||
are also removed from slsDetectorPackage/settingsdir. Eiger and Mythen
|
||||
continue to have them.
|
||||
|
||||
2. Depending on 1d position of detectors and detsizechan in config file,
|
||||
row and column (previously xcoord and ycoord) are given to detector
|
||||
servers (Eiger and Jungfrau) to encode into the udp header.
|
||||
|
||||
3. (Eiger) Setting threshold energy changes such as CAL dac is irrelevant
|
||||
when interpolating between two energies and VRS dac is interpolated, not copied.
|
||||
|
||||
4. Users API updated with the following functions:
|
||||
- setReceiverFramesDiscardPolicy
|
||||
- setReceiverPartialFramesPadding
|
||||
- setReceiverFramesPerFile
|
||||
- sendSoftwareTrigger
|
||||
- setSubFrameExposureDeadTime
|
||||
- setSubFrameExposureTime
|
||||
- enableGapPixels
|
||||
- getMeasuredPeriod
|
||||
- getMeasuredSubFramePeriod
|
||||
- setOverflowMode
|
||||
- setNumberOfStorageCells
|
||||
- setStoragecellStart
|
||||
- setThresholdEnergy (overloaded)
|
||||
- resetFramesCaughtInReceiver
|
||||
- setReceiverFifoDepth
|
||||
- setFlowControl10G
|
||||
- setTenGigabitEthernet
|
||||
- getNMods
|
||||
- setReceiverDataStreamingOutIP
|
||||
- setClientDataStreamingInIP
|
||||
|
||||
SlsReceiver
|
||||
-----------
|
||||
|
||||
1. slsMultiReceiver executable added that creates multiple receiver child processes.
|
||||
./slsMultiReceiver [start_tcp_port] [num_receivers] [1 for call back, 0 for none]
|
||||
|
||||
2. Default row and column (previously xcoord and ycoord) are hardcoded
|
||||
for missing packets. (Eiger and Jungfrau)
|
||||
|
||||
|
||||
Gui
|
||||
---
|
||||
|
||||
1. (Jungfrau) Gain plot included. Option under 2D options in Plot tab.
|
||||
|
||||
2. Option to maintain aspect ratio
|
||||
|
||||
3. Start and Stop separated to prevent multiple click syndrome.
|
||||
|
||||
|
||||
Detector Server
|
||||
---------------
|
||||
|
||||
1. (Jungfrau) To use programfpga command, one must start server with -update
|
||||
mode and then restart server without -update mode.
|
||||
|
||||
2. (Jungfrau) ASIC Timer configured at server start up and changed a few
|
||||
startup values for firmware v0.7 such as adc phase, ADC_PORT_INVERT_VAL
|
||||
and ADC offset half speed value.
|
||||
|
||||
3. (Jungfrau) Minimum exposure time of 50 us was implemented.
|
||||
|
||||
4. (Eiger and Jungfrau) They can be configured to have x and y coord values
|
||||
of the detector in their udp header.
|
||||
|
||||
|
||||
|
||||
|
||||
5. Resolved Issues
|
||||
==================
|
||||
|
||||
Client
|
||||
------
|
||||
memory leak for multi threading
|
||||
|
||||
1. Compiler flag -std=c++98 enforced. Debug flag removed.
|
||||
|
||||
2. If trimen gives different list from different detectors, it returns a -1.
|
||||
|
||||
3. Version format for each submodule of the package changed to just date YYMMDD.
|
||||
Users class fixed to give correct version, instead of -1.
|
||||
|
||||
4. Getting settings in users class gave -1. Fixed now.
|
||||
|
||||
5. (Jungfrau) Programming FPGA now creates the rawbin file from pof in tmp
|
||||
rather than source file location (for permission issues).
|
||||
|
||||
6. (Gotthard) ROI segmentation fault fixed.
|
||||
|
||||
Receiver
|
||||
--------
|
||||
|
||||
1. Silent feature of receiver fixed.
|
||||
|
||||
2. Socket descriptor misused earlier for success flag, instead exceptions
|
||||
used that are handled inside the package.
|
||||
|
||||
3. Global optind variable initialized to instantiate multiple receivers
|
||||
in same process. Also removed static members to enable this feature.
|
||||
|
||||
4. Socket buffer size attempts to set for each acquiistion and provide
|
||||
warning if no capabilities. Warnings can be removed using instruction with
|
||||
error provided. Default Jungfrau UDP socket buffer size if 2 GB, default is
|
||||
100 MB.
|
||||
|
||||
5. Refactored code a bit for performance and robustness, blocking push
|
||||
in buffer between listener and dataprocessor
|
||||
|
||||
|
||||
Detector Server
|
||||
---------------
|
||||
|
||||
1. (Jungfrau) Stop server also mapped during a reset. Reading power status
|
||||
instead of user input register for power.
|
||||
|
||||
2. (Eiger) Bug fix for saving trimbits to file (Advanced users).
|
||||
|
||||
3. (Gotthard 25um) config.txt is not read again after detector startup,
|
||||
no matter the number of times the detector server is restarted.
|
||||
|
||||
|
||||
6. Known Issues
|
||||
===============
|
||||
|
||||
Receiver
|
||||
--------
|
||||
|
||||
1. HDF5 compression and filters are not implemented yet.
|
||||
|
||||
|
||||
Detector Server
|
||||
---------------
|
||||
|
||||
1. (Eiger) Registers mapped differently between firmware v20 and v22.
|
||||
So, please ensure correct on-board server before switching between
|
||||
firmware versions. Else one cannot ping it anymore. Will need to flash firmware
|
||||
again to recover.
|
||||
|
||||
2. (Gotthard) To switch back to all ADC from single ADC ROI, one must take
|
||||
even number of images for the receiver to understand complete images.
|
||||
This will be fixed in the next firmware upgrade.
|
||||
|
||||
|
||||
|
||||
7. Next Major Release Plans
|
||||
===========================
|
||||
|
||||
Client
|
||||
------
|
||||
|
||||
1. Exceptions thrown to the user to be handled.
|
||||
|
||||
2. Compilation using c++11.
|
||||
|
||||
3. Support of Mythen II restricted to this major and its minor releases.
|
||||
|
||||
4. Restructuring and refactoring of client code.
|
||||
|
||||
|
||||
|
||||
|
15
cmk.sh
15
cmk.sh
@ -6,6 +6,7 @@ COMPILERTHREADS=0
|
||||
TEXTCLIENT=0
|
||||
RECEIVER=0
|
||||
GUI=0
|
||||
DEBUG=0
|
||||
|
||||
|
||||
CLEAN=0
|
||||
@ -24,6 +25,7 @@ Usage: $0 [-c] [-b] [-h] [-d <HDF5 directory>] [-j]
|
||||
-r: Build/Rebuilds only receiver
|
||||
-g: Build/Rebuilds only gui
|
||||
-j: Number of threads to compile through
|
||||
-e: Debug mode
|
||||
|
||||
For only make:
|
||||
./cmk.sh
|
||||
@ -53,7 +55,7 @@ For rebuilding only certain sections
|
||||
|
||||
" ; exit 1; }
|
||||
|
||||
while getopts ":bchd:j:trg" opt ; do
|
||||
while getopts ":bchd:j:trge" opt ; do
|
||||
case $opt in
|
||||
b)
|
||||
echo "Building of CMake files Required"
|
||||
@ -91,6 +93,10 @@ while getopts ":bchd:j:trg" opt ; do
|
||||
GUI=1
|
||||
REBUILD=1
|
||||
;;
|
||||
e)
|
||||
echo "Compiling Options: Debug"
|
||||
DEBUG=1
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG"
|
||||
usage
|
||||
@ -145,7 +151,12 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug "
|
||||
#Debug
|
||||
if [ $DEBUG -eq 1 ]; then
|
||||
CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug "
|
||||
echo "Debug Option enabled"
|
||||
fi
|
||||
|
||||
|
||||
#hdf5 rebuild
|
||||
if [ $HDF5 -eq 1 ]; then
|
||||
|
61
examples/bchip2modules.config
Normal file
61
examples/bchip2modules.config
Normal file
@ -0,0 +1,61 @@
|
||||
detsizechan 2560 1
|
||||
|
||||
hostname bchip074+bchip075+
|
||||
|
||||
#replace my_installation_path
|
||||
settingsdir /my_installation_path/slsDetectorPackage/settingsdir/gotthard
|
||||
caldir /my_installation_path/slsDetectorPackage/settingsdir/gotthard
|
||||
|
||||
0:extsig:0 trigger_in_rising_edge
|
||||
0:rx_tcpport 1954
|
||||
0:rx_udpport 50001
|
||||
0:vhighvoltage 0
|
||||
|
||||
1:extsig:0 trigger_in_rising_edge
|
||||
1:rx_tcpport 1955
|
||||
1:rx_udpport 50002
|
||||
#1:detectorip 10.1.1.52
|
||||
1:vhighvoltage 0
|
||||
|
||||
##############################################################################
|
||||
#########
|
||||
######### Uncomment this part to use the gotthard25umZmq process
|
||||
#########
|
||||
##############################################################################
|
||||
|
||||
# #replace my_receiver_hostname with the hostname of IP of the machine where the receiver runs
|
||||
#0:rx_zmqip my_receiver_hostname
|
||||
#0:rx_zmqport 30003
|
||||
# #replace my_client_hostname with the hostname of IP of the machine where the client/GUI or softIOC runs
|
||||
#0:zmqip my_client_hostname
|
||||
#0:zmqport 40003
|
||||
|
||||
# #replace my_receiver_hostname with the hostname of IP of the machine where the receiver runs
|
||||
#1:rx_zmqip my_receiver_hostname
|
||||
#1:rx_zmqport 30004
|
||||
# #replace my_client_hostname with the hostname of IP of the machine where the client/GUI or softIOC runs
|
||||
#1:zmqip my_client_hostname
|
||||
#1:zmqport 40004
|
||||
|
||||
##############################################################################
|
||||
#########
|
||||
######### until here
|
||||
#########
|
||||
##############################################################################
|
||||
|
||||
|
||||
r_readfreq 1
|
||||
rx_datastream 1
|
||||
|
||||
#replace my_receiver_hostname with the hostname of 1Gb IP of the machine where the receiver runs
|
||||
rx_hostname my_receiver_hostname
|
||||
rx_datastream 1
|
||||
outdir /tmp/
|
||||
angconv none
|
||||
threaded 1
|
||||
|
||||
settings veryhighgain
|
||||
exptime 0.000005
|
||||
period 0.0001
|
||||
|
||||
vhighvoltage 90
|
61
examples/bchip2modules_pc8829.config
Normal file
61
examples/bchip2modules_pc8829.config
Normal file
@ -0,0 +1,61 @@
|
||||
detsizechan 2560 1
|
||||
|
||||
hostname bchip074+bchip075+
|
||||
|
||||
#replace my_installation_path
|
||||
settingsdir /my_installation_path/slsDetectorPackage/settingsdir/gotthard
|
||||
caldir /my_installation_path/slsDetectorPackage/settingsdir/gotthard
|
||||
|
||||
0:extsig:0 trigger_in_rising_edge
|
||||
0:rx_tcpport 1954
|
||||
0:rx_udpport 50001
|
||||
0:vhighvoltage 0
|
||||
|
||||
1:extsig:0 trigger_in_rising_edge
|
||||
1:rx_tcpport 1955
|
||||
1:rx_udpport 50002
|
||||
#1:detectorip 10.1.1.52
|
||||
1:vhighvoltage 0
|
||||
|
||||
##############################################################################
|
||||
#########
|
||||
######### Uncomment this part to use the gotthard25umZmq process
|
||||
#########
|
||||
##############################################################################
|
||||
|
||||
# #replace my_receiver_hostname with the hostname of IP of the machine where the receiver runs
|
||||
#0:rx_zmqip my_receiver_hostname
|
||||
#0:rx_zmqport 30003
|
||||
# #replace my_client_hostname with the hostname of IP of the machine where the client/GUI or softIOC runs
|
||||
#0:zmqip my_client_hostname
|
||||
#0:zmqport 40003
|
||||
|
||||
# #replace my_receiver_hostname with the hostname of IP of the machine where the receiver runs
|
||||
#1:rx_zmqip my_receiver_hostname
|
||||
#1:rx_zmqport 30004
|
||||
# #replace my_client_hostname with the hostname of IP of the machine where the client/GUI or softIOC runs
|
||||
#1:zmqip my_client_hostname
|
||||
#1:zmqport 40004
|
||||
|
||||
##############################################################################
|
||||
#########
|
||||
######### until here
|
||||
#########
|
||||
##############################################################################
|
||||
|
||||
|
||||
r_readfreq 1
|
||||
rx_datastream 1
|
||||
|
||||
#replace my_receiver_hostname with the hostname of 1Gb IP of the machine where the receiver runs
|
||||
rx_hostname my_receiver_hostname
|
||||
rx_datastream 1
|
||||
outdir /tmp/
|
||||
angconv none
|
||||
threaded 1
|
||||
|
||||
settings veryhighgain
|
||||
exptime 0.000005
|
||||
period 0.0001
|
||||
|
||||
vhighvoltage 90
|
14
examples/howto_gotthatd_twomodules.txt
Normal file
14
examples/howto_gotthatd_twomodules.txt
Normal file
@ -0,0 +1,14 @@
|
||||
Turn on the two receivers:
|
||||
slsReceiver --rx_tcpport 1954 &
|
||||
slsReceiver --rx_tcpport 1955 &
|
||||
|
||||
Switch on the photon conversion on the receiver machine (replace my_receiver_hostname):
|
||||
gotthard25umZmq my_receiver_hostname 30003 my_receiver_hostname 40003 &
|
||||
|
||||
Run the configuration file:
|
||||
sls_detector_put config bchip2modules.config
|
||||
|
||||
|
||||
Start your measurements using the command line, the slsDetectorGui or the EPICS driver
|
||||
|
||||
|
492
examples/moench03_T1_lab.config
Normal file
492
examples/moench03_T1_lab.config
Normal file
@ -0,0 +1,492 @@
|
||||
hostname bchip011+
|
||||
|
||||
patword 0000 0000000000000000
|
||||
patword 0001 0000000000000000
|
||||
patword 0002 0008000900080000
|
||||
patword 0003 0008000900080000
|
||||
patword 0004 0008000900080000
|
||||
patword 0005 0008000900080000
|
||||
patword 0006 0008000900080000
|
||||
patword 0007 0008000900080000
|
||||
patword 0008 0008000900080000
|
||||
patword 0009 0008000900080000
|
||||
patword 000a 0008000900080000
|
||||
patword 000b 0008000900080000
|
||||
patword 000c 0008000900080000
|
||||
patword 000d 0008000900080000
|
||||
patword 000e 0008000900080000
|
||||
patword 000f 0008000900080000
|
||||
patword 0010 0008000900080000
|
||||
patword 0011 0008000900080000
|
||||
patword 0012 0008000900080000
|
||||
patword 0013 0008000900080000
|
||||
patword 0014 0008000900080000
|
||||
patword 0015 0008000900080000
|
||||
patword 0016 0008400900080020
|
||||
patword 0017 0008400900080020
|
||||
patword 0018 0008599f0418503a
|
||||
patword 0019 0008599f0418503a
|
||||
patword 001a 0108599f0418503a
|
||||
patword 001b 0108599f0418503a
|
||||
patword 001c 0108599f0418503a
|
||||
patword 001d 0108599f0418503a
|
||||
patword 001e 0108599f0418503a
|
||||
patword 001f 0108599f0418503a
|
||||
patword 0020 0108599f0418503a
|
||||
patword 0021 0108599f0418503a
|
||||
patword 0022 0108599f0418503a
|
||||
patword 0023 0108599f0418503a
|
||||
patword 0024 0108599f0418503a
|
||||
patword 0025 0108599f0418503a
|
||||
patword 0026 0108599f0418503a
|
||||
patword 0027 0108599f0418503a
|
||||
patword 0028 0108599f0418503a
|
||||
patword 0029 0108599f0418503a
|
||||
patword 002a 0108599f0418503a
|
||||
patword 002b 0108599f0418503a
|
||||
patword 002c 0108599f0418503a
|
||||
patword 002d 0108599f0418503a
|
||||
patword 002e 0108599f0418503a
|
||||
patword 002f 0108599f0418503a
|
||||
patword 0030 0108599f0418503a
|
||||
patword 0031 0108599f0418503a
|
||||
patword 0032 0108599f0418503a
|
||||
patword 0033 0108599f0418503a
|
||||
patword 0034 0108599f0418503a
|
||||
patword 0035 0108599f0418503a
|
||||
patword 0036 0108599f0418503a
|
||||
patword 0037 0108599f0418503a
|
||||
patword 0038 0108599f0418503a
|
||||
patword 0039 0108599f0418503a
|
||||
patword 003a 0108599f0418503a
|
||||
patword 003b 0108599f0418503a
|
||||
patword 003c 0108599f0418503a
|
||||
patword 003d 0108599f0418503a
|
||||
patword 003e 0108599f0418503a
|
||||
patword 003f 0108599f0418503a
|
||||
patword 0040 0108599f0418503a
|
||||
patword 0041 0108599f0418503a
|
||||
patword 0042 0108599f0418503a
|
||||
patword 0043 0108599f0418503a
|
||||
patword 0044 0108599f0418503a
|
||||
patword 0045 0108599f0418503a
|
||||
patword 0046 0108599f0418503a
|
||||
patword 0047 0108599f0418503a
|
||||
patword 0048 0108599f0418503a
|
||||
patword 0049 0108599f0418503a
|
||||
patword 004a 0108599f0418503a
|
||||
patword 004b 0108599f0418503a
|
||||
patword 004c 0108599f0418503a
|
||||
patword 004d 0108599f0418503a
|
||||
patword 004e 0108599f0418503a
|
||||
patword 004f 0108599f0418503a
|
||||
patword 0050 0108599f0418503a
|
||||
patword 0051 0108599f0418503a
|
||||
patword 0052 0108599f0418503a
|
||||
patword 0053 0108599f0418503a
|
||||
patword 0054 0108599f0418503a
|
||||
patword 0055 0108599f0418503a
|
||||
patword 0056 0108599f0418503a
|
||||
patword 0057 0108599f0418503a
|
||||
patword 0058 0108599f0418503a
|
||||
patword 0059 0108599f0418503a
|
||||
patword 005a 0108599f0418503a
|
||||
patword 005b 0108599f0418503a
|
||||
patword 005c 0108599f0418503a
|
||||
patword 005d 0108599f0418503a
|
||||
patword 005e 0108599f0418503a
|
||||
patword 005f 0108599f0418503a
|
||||
patword 0060 0108599f0418503a
|
||||
patword 0061 0108599f0418503a
|
||||
patword 0062 0108599f0418503a
|
||||
patword 0063 0108599f0418503a
|
||||
patword 0064 0108599f0418503a
|
||||
patword 0065 0108599f0418503a
|
||||
patword 0066 0108599f0418503a
|
||||
patword 0067 0108599f0418503a
|
||||
patword 0068 0108599f0418503a
|
||||
patword 0069 0108599f0418503a
|
||||
patword 006a 0108599f0418503a
|
||||
patword 006b 0108599f0418503a
|
||||
patword 006c 0108599f0418503a
|
||||
patword 006d 0108599f0418503a
|
||||
patword 006e 0108599f0418503a
|
||||
patword 006f 0108599f0418503a
|
||||
patword 0070 0108599f0418503a
|
||||
patword 0071 0108599f0418503a
|
||||
patword 0072 0108599f0418503a
|
||||
patword 0073 0108599f0418503a
|
||||
patword 0074 0108599f0418503a
|
||||
patword 0075 0108599f0418503a
|
||||
patword 0076 0108599f0418503a
|
||||
patword 0077 0108599f0418503a
|
||||
patword 0078 0108599f0418503a
|
||||
patword 0079 0108599f0418503a
|
||||
patword 007a 0108599f0418503a
|
||||
patword 007b 0108599f0418503a
|
||||
patword 007c 0108599f0418503a
|
||||
patword 007d 0108599f0418503a
|
||||
patword 007e 010859960418503a
|
||||
patword 007f 010859960418503a
|
||||
patword 0080 010859960418503a
|
||||
patword 0081 010859960418503a
|
||||
patword 0082 010859960418503a
|
||||
patword 0083 010859960418503a
|
||||
patword 0084 010859960418503a
|
||||
patword 0085 010859960418503a
|
||||
patword 0086 010859960418503a
|
||||
patword 0087 010859960418503a
|
||||
patword 0088 010859960418503a
|
||||
patword 0089 010859960418503a
|
||||
patword 008a 010859960418503a
|
||||
patword 008b 010859960418503a
|
||||
patword 008c 010859960418503a
|
||||
patword 008d 010859960418503a
|
||||
patword 008e 010859960418503a
|
||||
patword 008f 010859960418503a
|
||||
patword 0090 010859960418503a
|
||||
patword 0091 010859960418503a
|
||||
patword 0092 010819960418501a
|
||||
patword 0093 010819960418501a
|
||||
patword 0094 010819960418501a
|
||||
patword 0095 010819960418501a
|
||||
patword 0096 030819960418501a
|
||||
patword 0097 030819960418501a
|
||||
patword 0098 030819960418501a
|
||||
patword 0099 030819960418501a
|
||||
patword 009a 030819960418501a
|
||||
patword 009b 030819960418501a
|
||||
patword 009c 030819960418501a
|
||||
patword 009d 030819960418501a
|
||||
patword 009e 030819960418501a
|
||||
patword 009f 030819960418501a
|
||||
patword 00a0 030819960418501a
|
||||
patword 00a1 030819960418501a
|
||||
patword 00a2 030819960418501a
|
||||
patword 00a3 030819960418501a
|
||||
patword 00a4 030819960418501a
|
||||
patword 00a5 030819960418501a
|
||||
patword 00a6 030819960418501a
|
||||
patword 00a7 030819960418501a
|
||||
patword 00a8 030819960418501a
|
||||
patword 00a9 030819960418501a
|
||||
patword 00aa 030819960418501a
|
||||
patword 00ab 030819960418501a
|
||||
patword 00ac 030819960008501a
|
||||
patword 00ad 030819960008501a
|
||||
patword 00ae 030819960008501a
|
||||
patword 00af 030819960008501a
|
||||
patword 00b0 030819960008501a
|
||||
patword 00b1 030819960008501a
|
||||
patword 00b2 030819960008501a
|
||||
patword 00b3 030819960008501a
|
||||
patword 00b4 030819960008501a
|
||||
patword 00b5 030819960008501a
|
||||
patword 00b6 030819960008501a
|
||||
patword 00b7 030819960008501a
|
||||
patword 00b8 030819960008501a
|
||||
patword 00b9 030819960008501a
|
||||
patword 00ba 030819960008501a
|
||||
patword 00bb 030819960008501a
|
||||
patword 00bc 030819960008501a
|
||||
patword 00bd 030819960008501a
|
||||
patword 00be 030819960008501a
|
||||
patword 00bf 030819960008501a
|
||||
patword 00c0 0308199f0008501a
|
||||
patword 00c1 0308199f0008501a
|
||||
patword 00c2 0308199f0008501a
|
||||
patword 00c3 0308199f0008501a
|
||||
patword 00c4 0308199f0008501a
|
||||
patword 00c5 0308199f0008501a
|
||||
patword 00c6 0308199f0008501a
|
||||
patword 00c7 0308199f0008501a
|
||||
patword 00c8 0308199f0008501a
|
||||
patword 00c9 0308199f0008501a
|
||||
patword 00ca 0308199f0008501a
|
||||
patword 00cb 0308199f0008501a
|
||||
patword 00cc 0308199f0008501a
|
||||
patword 00cd 0308199f0008501a
|
||||
patword 00ce 0308199f0008501a
|
||||
patword 00cf 0308199f0008501a
|
||||
patword 00d0 0308199f0008501a
|
||||
patword 00d1 0308199f0008501a
|
||||
patword 00d2 0308199f0008501a
|
||||
patword 00d3 0308199f0008501a
|
||||
patword 00d4 0308599f0008503a
|
||||
patword 00d5 0308599f0008503a
|
||||
patword 00d6 030c599f000850ba
|
||||
patword 00d7 030c599f000850ba
|
||||
patword 00d8 030c599f000850ba
|
||||
patword 00d9 030c599f000850ba
|
||||
patword 00da 030c599f000850ba
|
||||
patword 00db 030c599f000850ba
|
||||
patword 00dc 030c599f000850ba
|
||||
patword 00dd 030c599f000850ba
|
||||
patword 00de 030c599f000850ba
|
||||
patword 00df 030c599f000850ba
|
||||
patword 00e0 030c599f000850ba
|
||||
patword 00e1 030c599f000850ba
|
||||
patword 00e2 030c599f000850ba
|
||||
patword 00e3 030c599f000850ba
|
||||
patword 00e4 030c599f000850ba
|
||||
patword 00e5 030c599f000850ba
|
||||
patword 00e6 030c599f000850ba
|
||||
patword 00e7 030c599f000850ba
|
||||
patword 00e8 030c599f000850ba
|
||||
patword 00e9 030c599f000850ba
|
||||
patword 00ea 030c799f010858ba
|
||||
patword 00eb 030c799f010858ba
|
||||
patword 00ec 030c599f000850ba
|
||||
patword 00ed 030c599f000850ba
|
||||
patword 00ee 030c599f000850ba
|
||||
patword 00ef 030c599f000850ba
|
||||
patword 00f0 030c599f000850ba
|
||||
patword 00f1 030c599f000850ba
|
||||
patword 00f2 030c599f000850ba
|
||||
patword 00f3 030c599f000850ba
|
||||
patword 00f4 030c599f000850ba
|
||||
patword 00f5 030c599f000850ba
|
||||
patword 00f6 030c599f000850ba
|
||||
patword 00f7 030c599f000850ba
|
||||
patword 00f8 030c599f000850ba
|
||||
patword 00f9 030c599f000850ba
|
||||
patword 00fa 030c599f000850ba
|
||||
patword 00fb 030c599f000850ba
|
||||
patword 00fc 030c599f000850ba
|
||||
patword 00fd 030c599f000850ba
|
||||
patword 00fe 030c599f000850ba
|
||||
patword 00ff 030c599f000850ba
|
||||
patword 0100 030c599f000850ba
|
||||
patword 0101 030c599f000850ba
|
||||
patword 0102 030c599f400850ba
|
||||
patword 0103 030c599f400850ba
|
||||
patword 0104 030c599f600850ba
|
||||
patword 0105 030c599f400850ba
|
||||
patword 0106 030c599f400850ba
|
||||
patword 0107 030c599f400850ba
|
||||
patword 0108 870c599f682e50ba
|
||||
patword 0109 870c599f482850ba
|
||||
patword 010a 870c599f000e50ba
|
||||
patword 010b 870c599f000850ba
|
||||
patword 010c 870c599f000e50ba
|
||||
patword 010d 870c599f000850ba
|
||||
patword 010e 870c599f000e50ba
|
||||
patword 010f 870c599f000850ba
|
||||
patword 0110 870c599f000e50ba
|
||||
patword 0111 870c599f000850ba
|
||||
patword 0112 870c599f000e50ba
|
||||
patword 0113 870c599f000850ba
|
||||
patword 0114 870c599f000e50ba
|
||||
patword 0115 870c599f000850ba
|
||||
patword 0116 870c599f000e50ba
|
||||
patword 0117 870c599f000850ba
|
||||
patword 0118 870c599f000e50ba
|
||||
patword 0119 870c599f000850ba
|
||||
patword 011a 870c599f000e50ba
|
||||
patword 011b 870c599f000850ba
|
||||
patword 011c 870c599f000e50ba
|
||||
patword 011d 870c599f000850ba
|
||||
patword 011e 870c599f000e50ba
|
||||
patword 011f 870c599f000850ba
|
||||
patword 0120 870c599f000e50ba
|
||||
patword 0121 870c599f000850ba
|
||||
patword 0122 870c599f200e50ba
|
||||
patword 0123 870c599f000850ba
|
||||
patword 0124 870c599f000e50ba
|
||||
patword 0125 870c599f000850ba
|
||||
patword 0126 870c599f000e50ba
|
||||
patword 0127 870c599f000850ba
|
||||
patword 0128 870c599f000e50ba
|
||||
patword 0129 870c599f000850ba
|
||||
patword 012a 870c599f000e50ba
|
||||
patword 012b 870c599f000850ba
|
||||
patword 012c 870c599f000e50ba
|
||||
patword 012d 870c599f000850ba
|
||||
patword 012e 870c599f000e50ba
|
||||
patword 012f 870c599f000850ba
|
||||
patword 0130 870c599f000e50ba
|
||||
patword 0131 870c599f000850ba
|
||||
patword 0132 870c599f000e50ba
|
||||
patword 0133 870c599f000850ba
|
||||
patword 0134 870c599f000e50ba
|
||||
patword 0135 870c599f000850ba
|
||||
patword 0136 870c599f000e50ba
|
||||
patword 0137 870c599f000850ba
|
||||
patword 0138 870c599f000e50ba
|
||||
patword 0139 870c599f000850ba
|
||||
patword 013a 870c599f282e50ba
|
||||
patword 013b 870c599f082850ba
|
||||
patword 013c 870c599f000e50ba
|
||||
patword 013d 870c599f000850ba
|
||||
patword 013e 870c599f000e50ba
|
||||
patword 013f 870c599f000850ba
|
||||
patword 0140 870c599f000e50ba
|
||||
patword 0141 870c599f000850ba
|
||||
patword 0142 870c599f000e50ba
|
||||
patword 0143 870c599f000850ba
|
||||
patword 0144 870c599f000e50ba
|
||||
patword 0145 870c599f000850ba
|
||||
patword 0146 870c599f000e50ba
|
||||
patword 0147 870c599f000850ba
|
||||
patword 0148 870c599f000e50ba
|
||||
patword 0149 870c599f000850ba
|
||||
patword 014a 870c599f000e50ba
|
||||
patword 014b 870c599f000850ba
|
||||
patword 014c 870c599f000e50ba
|
||||
patword 014d 870c599f000850ba
|
||||
patword 014e 870c599f000e50ba
|
||||
patword 014f 870c599f000850ba
|
||||
patword 0150 870c599f000e50ba
|
||||
patword 0151 870c599f000850ba
|
||||
patword 0152 870c599f000e50ba
|
||||
patword 0153 870c599f000850ba
|
||||
patword 0154 870c599f200e50ba
|
||||
patword 0155 870c599f000850ba
|
||||
patword 0156 870c599f000e50ba
|
||||
patword 0157 870c599f000850ba
|
||||
patword 0158 870c599f000e50ba
|
||||
patword 0159 870c599f000850ba
|
||||
patword 015a 870c599f000e50ba
|
||||
patword 015b 870c599f000850ba
|
||||
patword 015c 870c599f000e50ba
|
||||
patword 015d 870c599f000850ba
|
||||
patword 015e 870c599f000e50ba
|
||||
patword 015f 870c599f000850ba
|
||||
patword 0160 870c599f000e50ba
|
||||
patword 0161 870c599f000850ba
|
||||
patword 0162 870c599f000e50ba
|
||||
patword 0163 870c599f000850ba
|
||||
patword 0164 870c599f000e50ba
|
||||
patword 0165 870c599f000850ba
|
||||
patword 0166 870c599f000e50ba
|
||||
patword 0167 870c599f000850ba
|
||||
patword 0168 870c599f000e50ba
|
||||
patword 0169 870c599f000850ba
|
||||
patword 016a 870c599f000e50ba
|
||||
patword 016b 870c599f000850ba
|
||||
patword 016c 070c599f000850ba
|
||||
patword 016d 070c599f000850ba
|
||||
patword 016e 000c599f000850ba
|
||||
patword 016f 000c599f000850ba
|
||||
patword 0170 0008599f200e503a
|
||||
patword 0171 0008599f0008503a
|
||||
patword 0172 0008599f200e503a
|
||||
patword 0173 0008599f0008503a
|
||||
patword 0174 0008599f0008503a
|
||||
patword 0175 0008599f0008503a
|
||||
patword 0176 0008599f0008503a
|
||||
patword 0177 0008599f0008503a
|
||||
patword 0178 0008599f0008503a
|
||||
patword 0179 0008599f0008503a
|
||||
patword 017a 0008599f0008503a
|
||||
patword 017b 0008599f0008503a
|
||||
patword 017c 0008599f0008503a
|
||||
patword 017d 0008599f0008503a
|
||||
patword 017e 0008599f0008503a
|
||||
patword 017f 0008599f0008503a
|
||||
patword 0180 0008599f0008503a
|
||||
patword 0181 0008599f0008503a
|
||||
patword 0182 0008599f0008503a
|
||||
patword 0183 0008599f0008503a
|
||||
patword 0184 0008599f0008503a
|
||||
patword 0185 0008599f0008503a
|
||||
patword 0186 0008599f0008503a
|
||||
patword 0187 0008599f0008503a
|
||||
patword 0188 0008599f0008503a
|
||||
patword 0189 0008599f0008503a
|
||||
patword 018a 0008599f0008503a
|
||||
patword 018b 0008599f0008503a
|
||||
patword 018c 0008599f0008503a
|
||||
patword 018d 0008599f0008503a
|
||||
patioctrl 8f0effff6dbffdbf
|
||||
patclkctrl 0000000000000000
|
||||
patlimits 0000 018c
|
||||
patloop0 013a 016b
|
||||
patnloop0 199
|
||||
patloop1 0400 0400
|
||||
patnloop1 0
|
||||
patloop2 0400 0400
|
||||
patnloop2 0
|
||||
patwait0 00aa
|
||||
patwaittime0 40000
|
||||
patwait1 0400
|
||||
patwaittime1 0
|
||||
patwait2 0400
|
||||
patwaittime2 0
|
||||
|
||||
|
||||
####mcp2011
|
||||
#0:rx_tcpport 1955
|
||||
#0:rx_udpip 10.1.1.102
|
||||
#0:detectorip 10.1.1.19
|
||||
#0:rx_udpport 32411
|
||||
####gui listening to
|
||||
#zmqip 129.129.202.106
|
||||
#zmqport 50001
|
||||
####data streaming out of
|
||||
#rx_zmqip 10.1.2.103
|
||||
#rx_zmqport 50003
|
||||
|
||||
#0:rx_hostname mpc2011
|
||||
|
||||
####pcmoench01
|
||||
0:rx_tcpport 1977
|
||||
0:rx_udpip 10.1.1.100
|
||||
0:detectorip 10.1.1.19
|
||||
0:rx_udpport 32410
|
||||
####gui listening to (on receiver pc)
|
||||
zmqip 129.129.202.92
|
||||
zmqport 50001
|
||||
####data streaming out of
|
||||
rx_zmqip 10.1.1.100
|
||||
rx_zmqport 50003
|
||||
0:rx_hostname pcmoench01
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#turn on datastream from commandline
|
||||
rx_datastream 1
|
||||
|
||||
r_readfreq 1
|
||||
|
||||
#0:configuremac -1
|
||||
rx_datastream 1
|
||||
|
||||
r_readfreq 1
|
||||
|
||||
|
||||
dac:6 800
|
||||
dac:0 1300
|
||||
dac:4 1428
|
||||
dac:1 1000
|
||||
dac:7 900
|
||||
dac:3 680
|
||||
dac:2 1400
|
||||
dac:5 1200
|
||||
adcinvert 4a342593
|
||||
samples 5000
|
||||
adcphase 90
|
||||
adcpipeline 15
|
||||
adcreg 14 40
|
||||
powerchip 1
|
||||
vhighvoltage 90
|
||||
period 0.005
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
frames 100
|
||||
period 0.1
|
||||
outdir /scratch/
|
||||
enablefwrite 0
|
||||
|
@ -1,17 +1,35 @@
|
||||
|
||||
add_executable(slsMultiReceiver
|
||||
set(SOURCES
|
||||
mainReceiver.cpp
|
||||
)
|
||||
set_target_properties(slsMultiReceiver PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
|
||||
include_directories(
|
||||
../../slsReceiverSoftware/include
|
||||
../../slsDetectorSoftware/slsDetectorAnalysis
|
||||
../../build/bin
|
||||
../../slsdetectorSoftware/slsDetector
|
||||
)
|
||||
|
||||
add_executable(slsMultiReceiver
|
||||
${SOURCES}
|
||||
)
|
||||
|
||||
target_link_libraries(slsMultiReceiver
|
||||
slsReceiverShared
|
||||
pthread
|
||||
zmq
|
||||
rt
|
||||
${HDF5_LIBRARIES}
|
||||
)
|
||||
|
||||
install(TARGETS slsMultiReceiver
|
||||
RUNTIME DESTINATION bin)
|
||||
if (HDF5_FOUND)
|
||||
target_link_libraries(slsMultiReceiver
|
||||
${HDF5_LIBRARIES}
|
||||
)
|
||||
endif ()
|
||||
|
||||
|
||||
set_target_properties(slsMultiReceiver PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
install(TARGETS slsMultiReceiver DESTINATION bin)
|
||||
|
@ -1,18 +1,26 @@
|
||||
INCLUDES = -I .
|
||||
PKGDIR = ../..
|
||||
LIBDIR = $(PKGDIR)/build/bin
|
||||
INCLUDES = -I . -I$(PKGDIR)/slsReceiverSoftware/include -I$(PKGDIR)/slsDetectorSoftware/slsDetectorAnalysis -I$(LIBDIR) -I$(PKGDIR)/slsDetectorSoftware/slsDetector
|
||||
SRC_DET = mainClient.cpp
|
||||
SRC_REC = mainReceiver.cpp
|
||||
LIBDIR = .
|
||||
LDFLAG_DET = -I. -L$(LIBDIR) -lSlsDetector -L/usr/lib64/ -pthread -lrt -L. -lzmq
|
||||
LDFLAG_REC = -I. -L$(LIBDIR) -lSlsReceiver -L/usr/lib64/ -pthread -lrt -L. -lzmq
|
||||
ZMQLIBDIR = $(PKGDIR)/slsReceiverSoftware/include
|
||||
LDFLAG_DET = -I. -L$(LIBDIR) -Wl,-rpath=$(LIBDIR) -lSlsDetector -L/usr/lib64/ -pthread -lrt -L$(ZMQLIBDIR) -Wl,-rpath=$(ZMQLIBDIR) -lzmq
|
||||
LDFLAG_REC = -I. -L$(LIBDIR) -Wl,-rpath=$(LIBDIR) -lSlsReceiver -L/usr/lib64/ -pthread -lrt -L$(ZMQLIBDIR) -Wl,-rpath=$(ZMQLIBDIR) -lzmq
|
||||
DESTDIR ?= ../docs
|
||||
|
||||
HDF5 ?= no
|
||||
HDF5_DIR ?= /opt/hdf5v1.10.0
|
||||
|
||||
all: docs detUser detReceiver
|
||||
ifeq ($(HDF5),yes)
|
||||
LDFLAG_REC += -L$(HDF5_DIR)/lib -Wl,-rpath=$(HDF5_DIR)/lib -lhdf5 -lhdf5_cpp -lsz -lz -DHDF5C
|
||||
endif
|
||||
|
||||
all: docs detUser slsMultiReceiver
|
||||
#all: docs
|
||||
|
||||
docs: createdocs docspdf docshtml removedocs
|
||||
|
||||
createdocs: slsDetectorUsers.doxy slsDetectorUsers.h detectorData.h slsReceiverUsers.h mainClient.cpp mainReceiver.cpp
|
||||
createdocs: slsDetectorUsers.doxy mainClient.cpp mainReceiver.cpp
|
||||
doxygen slsDetectorUsers.doxy
|
||||
|
||||
docspdf:
|
||||
@ -35,18 +43,20 @@ detUser:$(SRC_DET)
|
||||
mkdir -p bin
|
||||
g++ -o bin/detUser $(SRC_DET) $(INCLUDES) $(LDFLAG_DET) -lm -lstdc++
|
||||
|
||||
detReceiver:$(SRC_REC)
|
||||
slsMultiReceiver:$(SRC_REC)
|
||||
echo "creating receiver"
|
||||
echo $LDFLAG_REC
|
||||
mkdir -p bin
|
||||
g++ -o bin/detReceiver $(SRC_REC) $(INCLUDES) $(LDFLAG_REC) -lm -lstdc++
|
||||
|
||||
g++ -o bin/slsMultiReceiver $(SRC_REC) $(INCLUDES) $(LDFLAG_REC) -lm -lstdc++
|
||||
cp bin/slsMultiReceiver $(LIBDIR)
|
||||
|
||||
clean:
|
||||
echo "cleaning for manual-api"
|
||||
rm -rf bin/detUser bin/detReceiver slsDetectorUsersDocs
|
||||
rm -rf bin/detUser bin/slsMultiReceiver bin/detReceiver slsDetectorUsersDocs
|
||||
rm -rf slsDetectorUsersDocs
|
||||
rm -rf $(DESTDIR)/html/slsDetectorUsersDocs
|
||||
rm -rf $(DESTDIR)/pdf/slsDetectorUsersDocs.pdf
|
||||
rm -rf $(LIBDIR)/slsMultiReceiver
|
||||
|
||||
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
../../slsReceiverSoftware/include/ansi.h
|
@ -1 +0,0 @@
|
||||
../../slsDetectorSoftware/slsDetectorAnalysis/detectorData.h
|
@ -1 +0,0 @@
|
||||
../../build/bin/libSlsDetector.so
|
@ -1 +0,0 @@
|
||||
../../build/bin/libSlsReceiver.so
|
@ -1 +0,0 @@
|
||||
../../slsReceiverSoftware/include/libzmq.a
|
@ -54,7 +54,12 @@ int main(int argc, char **argv) {
|
||||
|
||||
|
||||
/** - slsDetectorUsers Object is instantiated with appropriate ID */
|
||||
slsDetectorUsers *pDetector = new slsDetectorUsers (id);
|
||||
int ret = 1;
|
||||
slsDetectorUsers *pDetector = new slsDetectorUsers (ret, id);
|
||||
if (ret == 1) {
|
||||
std::cout << "Error: Could not instantiate slsDetectorUsers" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
/** - if specified, load configuration file (necessary at least the first time it is called to properly configure advanced settings in the shared memory) */
|
||||
@ -71,10 +76,6 @@ int main(int argc, char **argv) {
|
||||
|
||||
/** - registering data callback */
|
||||
pDetector->registerDataCallback(&dataCallback, NULL);
|
||||
/** - if receiver exists, enable data streaming from receiver to get the data */
|
||||
pDetector->enableDataStreamingFromReceiver(1);
|
||||
/** - create zmq sockets in client to enable data streaming in of data from receiver/different process */
|
||||
pDetector->enableDataStreamingToClient(1);
|
||||
|
||||
|
||||
/** - ensuring detector status is idle before starting acquisition. exiting if not idle */
|
||||
@ -93,7 +94,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
/** - start measurement */
|
||||
pDetector->startMeasurement();
|
||||
std::cout << "measurement finished" << std::endl; usleep(1*1000*1000);
|
||||
std::cout << "measurement finished" << std::endl;
|
||||
|
||||
/** - returning when acquisition is finished or data are avilable */
|
||||
|
||||
|
@ -71,7 +71,7 @@ void printHelp() {
|
||||
*/
|
||||
int StartAcq(char* filepath, char* filename, uint64_t fileindex, uint32_t datasize, void*p){
|
||||
cprintf(BLUE, "#### StartAcq: filepath:%s filename:%s fileindex:%llu datasize:%u ####\n",
|
||||
filepath, filename, fileindex, datasize);
|
||||
filepath, filename, (long long unsigned int)fileindex, datasize);
|
||||
|
||||
cprintf(BLUE, "--StartAcq: returning 0\n");
|
||||
return 0;
|
||||
@ -83,7 +83,7 @@ int StartAcq(char* filepath, char* filename, uint64_t fileindex, uint32_t datasi
|
||||
* @param p pointer to object
|
||||
*/
|
||||
void AcquisitionFinished(uint64_t frames, void*p){
|
||||
cprintf(BLUE, "#### AcquisitionFinished: frames:%llu ####\n",frames);
|
||||
cprintf(BLUE, "#### AcquisitionFinished: frames:%llu ####\n",(long long unsigned int)frames);
|
||||
}
|
||||
|
||||
|
||||
@ -99,18 +99,18 @@ void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){
|
||||
slsReceiverDefs::sls_receiver_header* header = (slsReceiverDefs::sls_receiver_header*)metadata;
|
||||
slsReceiverDefs::sls_detector_header detectorHeader = header->detHeader;
|
||||
|
||||
PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.xCoord,
|
||||
PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row,
|
||||
"#### %d GetData: ####\n"
|
||||
"frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu"
|
||||
"\t\ttimestamp: %llu\t\tmodId: %u\t\t"
|
||||
"xCoord: %u\t\tyCoord: %u\t\tzCoord: %u\t\tdebug: %u"
|
||||
"row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u"
|
||||
"\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u"
|
||||
//"\t\tpacketsMask:%s"
|
||||
"\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n",
|
||||
detectorHeader.xCoord, detectorHeader.frameNumber,
|
||||
detectorHeader.expLength, detectorHeader.packetNumber, detectorHeader.bunchId,
|
||||
detectorHeader.timestamp, detectorHeader.modId,
|
||||
detectorHeader.xCoord, detectorHeader.yCoord, detectorHeader.zCoord,
|
||||
detectorHeader.row, (long long unsigned int)detectorHeader.frameNumber,
|
||||
detectorHeader.expLength, detectorHeader.packetNumber, (long long unsigned int)detectorHeader.bunchId,
|
||||
(long long unsigned int)detectorHeader.timestamp, detectorHeader.modId,
|
||||
detectorHeader.row, detectorHeader.column, detectorHeader.reserved,
|
||||
detectorHeader.debug, detectorHeader.roundRNumber,
|
||||
detectorHeader.detType, detectorHeader.version,
|
||||
//header->packetsMask.to_string().c_str(),
|
||||
@ -133,18 +133,18 @@ void GetData(char* metadata, char* datapointer, uint32_t &revDatasize, void* p){
|
||||
slsReceiverDefs::sls_receiver_header* header = (slsReceiverDefs::sls_receiver_header*)metadata;
|
||||
slsReceiverDefs::sls_detector_header detectorHeader = header->detHeader;
|
||||
|
||||
PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.xCoord,
|
||||
PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row,
|
||||
"#### %d GetData: ####\n"
|
||||
"frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu"
|
||||
"\t\ttimestamp: %llu\t\tmodId: %u\t\t"
|
||||
"xCoord: %u\t\tyCoord: %u\t\tzCoord: %u\t\tdebug: %u"
|
||||
"row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u"
|
||||
"\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u"
|
||||
//"\t\tpacketsMask:%s"
|
||||
"\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n",
|
||||
detectorHeader.xCoord, detectorHeader.frameNumber,
|
||||
detectorHeader.expLength, detectorHeader.packetNumber, detectorHeader.bunchId,
|
||||
detectorHeader.timestamp, detectorHeader.modId,
|
||||
detectorHeader.xCoord, detectorHeader.yCoord, detectorHeader.zCoord,
|
||||
detectorHeader.row, (long long unsigned int)detectorHeader.frameNumber,
|
||||
detectorHeader.expLength, detectorHeader.packetNumber, (long long unsigned int)detectorHeader.bunchId,
|
||||
(long long unsigned int)detectorHeader.timestamp, detectorHeader.modId,
|
||||
detectorHeader.row, detectorHeader.column, detectorHeader.reserved,
|
||||
detectorHeader.debug, detectorHeader.roundRNumber,
|
||||
detectorHeader.detType, detectorHeader.version,
|
||||
//header->packetsMask.to_string().c_str(),
|
||||
|
@ -82,6 +82,10 @@ SOURCE_BROWSER = YES
|
||||
|
||||
PREDEFINED = __cplusplus
|
||||
|
||||
INPUT = slsDetectorUsers.h detectorData.h slsReceiverUsers.h mainClient.cpp mainReceiver.cpp
|
||||
INPUT = ../../slsDetectorSoftware/slsDetector/slsDetectorUsers.h \
|
||||
../../slDetectorSoftware/slsDetectorAnalysis/detectorData.h \
|
||||
../../slsReceiverSoftware/include/slsReceiverUsers.h \
|
||||
mainClient.cpp \
|
||||
mainReceiver.cpp
|
||||
|
||||
OUTPUT_DIRECTORY = slsDetectorUsersDocs
|
||||
|
@ -1 +0,0 @@
|
||||
../../slsDetectorSoftware/slsDetector/slsDetectorUsers.h
|
@ -1 +0,0 @@
|
||||
../../slsReceiverSoftware/include/slsReceiverUsers.h
|
@ -1 +0,0 @@
|
||||
../../slsReceiverSoftware/include/sls_receiver_defs.h
|
@ -1 +0,0 @@
|
||||
../../slsReceiverSoftware/include/sls_receiver_funcs.h
|
@ -1 +0,0 @@
|
||||
../../slsReceiverSoftware/include/zmq.h
|
Binary file not shown.
@ -28,8 +28,6 @@ Figure ~\ref{boards} show the readout board basic components on an Eiger half mo
|
||||
\label{boards}
|
||||
\end{figure}
|
||||
|
||||
|
||||
|
||||
\subsection{Mandatory setup - Hardware}
|
||||
An EIGER single module (500~kpixels) needs:
|
||||
\begin{itemize}
|
||||
@ -66,7 +64,8 @@ The directory contains some executables that are needed to make your detector to
|
||||
\begin{verbatim}
|
||||
./on #to switch modules on
|
||||
./off #to switch modules off
|
||||
./hvget #gets the current HV value
|
||||
./state #tells you if is ON or OFF
|
||||
cat /var/log/pcu.log #displays the log if there are problem
|
||||
./waterflow #returns the current waterflow returned by the flowmeter
|
||||
./temp #returns the water temperature returned by the flowmeter
|
||||
\end{verbatim}
|
||||
@ -93,10 +92,14 @@ The receiver is a process run on a PC closely connected to the detector. Open on
|
||||
where xxxx, yyyy are the tcp port numbers. Use 1955 and 1956 for example. The receiver for the bottom is open without arguments but still in the configuration file one needs to write {\tt{n:flippeddatax 1}}, where {\tt{2n+1}} indicated the half module number, 1 if it is a module.
|
||||
\\ Open as many receiver as half module boards. A single module has two half module boards.
|
||||
|
||||
From the software version 3.0.1, one can decide weather start a zmq callback from the receiver to the client (for example to visualize data in the slsDetectorGui or another gui). If the zmq steam is not required (cased of the command line for example, one can switch off the streaming with {\tt{./sls\_detector\_put rx\_datastream 0}}, enable it with {\tt{./sls\_detector\_put rx\_datastream 1}}. In the case of inizialising the stream to use the slsDetectorGui, nothing needs to be taken care of by the user. If instead you want to stream the streaming on different channels, the zmq port of the client can be set stealing from the slsDetectorGui stream having {\tt{./sls\_detector\_put zmqport 300y}}. Note that if this is done globally (not for every half module n independently, then the client automatically takes into account that for every half module, there are 2 zmq stream. The receiver stream {\tt{./sls\_detector\_put rx\_zmqport 300y}} has to match such that the GUI can work.
|
||||
From the software version 3.0.1, one can decide weather start a zmq callback from the receiver to the client (for example to visualize data in the slsDetectorGui or another gui). If the zmq steam is not required (cased of the command line for example, one can switch off the streaming with {\tt{./sls\_detector\_put rx\_datastream 0}}, enable it with {\tt{./sls\_detector\_put rx\_datastream 1}}. In the case of initializing the stream to use the slsDetectorGui, nothing needs to be taken care of by the user. If instead you want to stream the streaming on different channels, the zmq port of the client can be set stealing from the slsDetectorGui stream having {\tt{./sls\_detector\_put zmqport 300y}}. Note that if this is done globally (not for every half module n independently, then the client automatically takes into account that for every half module, there are 2 zmq stream. The receiver stream {\tt{./sls\_detector\_put rx\_zmqport 300y}} has to match such that the GUI can work.
|
||||
If one desires to set the zmqport manually, he offset has to be taken into account: {\tt{./sls\_detector\_put 0:rx\_zmqport 300y}}, {\tt{./sls\_detector\_put 1:rx\_zmqport 300y+2}} and so on..
|
||||
|
||||
There is an example code that can be compiled in {\tt{manual/manual-api/mainReceiver.cpp}} and gives the executable {\tt{./detReceiver}}, use it with two or more receivers to open all receivers in one single terminal: {\tt{./detReceiver startTCPPort numReceivers withCallback}}, where startTCPPort assumes the other ports are consecutively increased.
|
||||
|
||||
{\tt{slsMultiReceiver}} uses two or more receivers in one single terminal: {\tt{./slsMultiReceiver startTCPPort numReceivers withCallback}}, where startTCPPort assumes the other ports are consecutively increased.
|
||||
|
||||
The command {\tt{r\_framesperfile}} sets the number of frames written in the same file. By default now it is 10000. It can be changes. It needs to be lowered particularly if one wants to parallelize the following conversion of the files.
|
||||
|
||||
|
||||
\subsection{Mandatory setup - Client}
|
||||
|
||||
@ -282,6 +285,39 @@ The detector will not accept other commands while acquiring. If an acquisition w
|
||||
\end{itemize}
|
||||
this same command can be used after a non proper abortion of the acquisition to reset to normal status the detector.
|
||||
|
||||
\section{Gap pixels inside a module}
|
||||
A module is composed of 2$\times$4 chips. Each chip is of dimension 256$\times$256 pixels. There is no dead area in a module, as a single sensor covers the 8 chips. The physical pixels at the border of the chips in the sensor are double in size, to allow not to loose photons in the gaps between the chip alignment. They count double what the other normal pixels would count. In the corner between chips, the pixels are 4-times the normal size. See figure~\ref{fgappix} to check the geometry.
|
||||
|
||||
\begin{figure}[t]
|
||||
\begin{center}
|
||||
\includegraphics[width=0.9\textwidth]{GapPixels}
|
||||
\end{center}
|
||||
\caption{Geometry of gap pixels between a module.}
|
||||
\label{fgappix}
|
||||
\end{figure}
|
||||
|
||||
It is possible to interpolated the value on the larger pixels by splitting the events (or properly interpolating) introducing a virtual pixel for every double pixel, or 3 virtual pixels for every corner. In this way the counts of a single large pixel can be shared among the correct amount of pixels of the normal dimension.
|
||||
|
||||
The gap pixels can be added for the slsDetectorGui, from the datacall back or stealing the zmq port from the GUI (see later). The detector size can be added in the configuration file as first thing.
|
||||
|
||||
Putting the long side of the module first always as a convection for the code, WITHOUT GAP PIXELS an EIGER module is:
|
||||
\begin{verbatim}
|
||||
detsizechan 1024 512
|
||||
\end{verbatim}
|
||||
and the client needs to be set {\tt{sls\_detector\_put gappixels 0}}, which is the default behavior.\\
|
||||
If you want to have GAP PIXELS included:
|
||||
\begin{verbatim}
|
||||
detsizechan 1030 514
|
||||
\end{verbatim}
|
||||
and the client needs to be set {\tt{sls\_detector\_put gappixels 1}}.
|
||||
|
||||
The size of the gap pixels between modules to insert is
|
||||
\begin{verbatim}
|
||||
GapPixelsBetweenModules_x = 8
|
||||
GapPixelsBetweenModules_y = 36
|
||||
\end{verbatim}
|
||||
where the {\tt{GapPixelsBetweenModules\_x}} are the one on the short side of the module, while {\tt{GapPixelsBetweenModules\_y}} are the ones on the long side of the module (where the wirebonds take physical space).
|
||||
|
||||
\section{Readout timing- maximum frame rate}\label{timing}
|
||||
IMPORTANT: to have faster readout and smaller dead time, one can configure {\tt{clkdivider}}, i.e. the speed at which the data are read, i.e. 200/100/50~MHz for {\tt{clkdivider 0/1/2}} and the dead time between frames through {\tt{flags parallel}}, i.e. acquire and read at the same time or acquire and then read out.
|
||||
The configuration of this timing variables allows to achieve different frame rates. NOTE THAT IN EIGER, WHATEVER YOU DO, THE FRAME RATE LIMITATIONS COME FROM THE NETWORK BOTTLENECK AS THE HARDWARE GOES FASTER THAN THE DATA OUT.
|
||||
@ -369,48 +405,50 @@ where the 'minimum time between frames' and the minimum period will be discussed
|
||||
\begin{tiny}
|
||||
\begin{table}
|
||||
\begin{flushleft}
|
||||
\begin{tabular}{|c|c|c|c|c|c|c|}
|
||||
\begin{tabular}{|c|c|c|c|c|c|c|c|}
|
||||
\hline
|
||||
\tiny{dr} & \tiny{clkdivider} & \tiny{flags} & \tiny{t between frames($\mu$s) } & \tiny{max frame rate (kHz)} & \tiny{min period ($\mu$s)} & \tiny{max imgs (nominal/our network)}\\
|
||||
\tiny{dr} & \tiny{clkdivider} & \tiny{flags} & \tiny{$\Delta$t frames($\mu$s) } & \tiny{max FR (kHz)} & \tiny{min period ($\mu$s)} & \tiny{meas. period ($\mu$s)} & \tiny{max imgs (nominal/our network)}\\
|
||||
\hline
|
||||
4 & 0 & parallel & 3.4 & 22 & 44 & 30k/50k\\
|
||||
4 & 0 & \tiny {parallel} & 3.4 & 22 & 44 & 44.01 & 30k/50k\\
|
||||
\hline
|
||||
4 & 1 & parallel & 6 & 10.5 & 92 & 30k/100k\\
|
||||
4 & 1 & \tiny {parallel} & 6 & 10.5 & 92 & 92.02 & 30k/100k\\
|
||||
\hline
|
||||
4 & 2 & parallel & 11.2 & 5.4 & 197 & infinite\\
|
||||
4 & 2 & \tiny {parallel} & 11.2 & 5.4 & 197& 197.01 & infinite\\
|
||||
\hline
|
||||
\hline
|
||||
8 & 0 & parallel & 3.4 & 11.1 & 89 & 15k/24k\\
|
||||
8 & 0 & \tiny {parallel} & 3.4 & 11.1 & 89 & 89.01 & 15k/24k\\
|
||||
\hline
|
||||
8 & 1 & parallel & 6.1 & 5.7 & 181 & 15k/52k\\
|
||||
8 & 1 & \tiny {parallel} & 6.1 & 5.7 & 181 & 181.01 & 15k/52k\\
|
||||
\hline
|
||||
8 & 2 & parallel & 11.2 & 2.9 & 342 & infinite\\
|
||||
8 & 2 & \tiny {parallel} & 11.2 & 2.9 & 342 & 342.01 & infinite\\
|
||||
\hline
|
||||
\hline
|
||||
16 & 0 & parallel & 3.4 & 6.1 & (126+38)* =164 & 8k/12k\\
|
||||
16 & 0 & \tiny {parallel} & 3.4 & 6.1 & (126+38)* =164 & 164.02 & 8k/12k\\
|
||||
\hline
|
||||
16 & 0 & nonparallel & 126 & 5.6 & (126+52)*= 179 & 8k/23k\\
|
||||
16 & 0 & \tiny {nonparallel} & 127 & 5.6 & (126+52)*= 179 & 179.01& 8k/23k\\
|
||||
\hline
|
||||
16 & 1 & parallel & 6.1 & 3.9 & 257 & 8k/28k\\
|
||||
16 & 1 & \tiny {parallel} & 6.1 & 3.9 & 257 & 257.01 & 8k/28k\\
|
||||
\hline
|
||||
16 & 1 & nonparallel & 255 & 3.3 & 303 & infinite\\
|
||||
16 & 1 & \tiny {nonparallel} & 255 & 3.3 & 303 & 303.01 & infinite\\
|
||||
\hline
|
||||
16 & 2 & parallel & 11 & 1.9 & 526 & infinite \\
|
||||
16 & 2 & \tiny {parallel} & 11.2 & 1.9 & 526 & 526.2 & infinite \\
|
||||
\hline
|
||||
16 & 2 & nonparallel & 504 & 1.8 & 555 & infinite\\
|
||||
16 & 2 & \tiny {nonparallel} & 505 & 1.8 & 555 & 555.01& infinite\\
|
||||
\hline
|
||||
%32 & 2 & parallel & 11 & 2& & &\\
|
||||
%\hline
|
||||
%32 & 2 & nonparallel & 504 & $<2$& & &\\
|
||||
%\hline
|
||||
\end{tabular}
|
||||
\caption{Readout settings. The {\tiny{min exptime}} possible is 5$-$10~$\mu$s. This is due to the time to pass the pixel enable signal in the whole chip. The time between frames has been measured with the oscilloscope and the maximum frames rate has been tested with an external gating from a pulse generator at known frequence. The minimum period is obtained as 1/$\textrm{max frame rate}$.}
|
||||
\caption{Readout settings. The {\tiny{min exptime}} possible is 5$-$10~$\mu$s. This is due to the time to pass the pixel enable signal in the whole chip. The time between frames ($\Delta$t) has been measured with the oscilloscope and the maximum frames rate (max FR) has been tested with an external gating from a pulse generator at known frequency. The minimum period is obtained as 1/$\textrm{max frame rate}$.}
|
||||
\label{tframes}
|
||||
\end{flushleft}
|
||||
\end{table}
|
||||
\end{tiny}
|
||||
|
||||
\textbf{As if you run too fast, the detector could become noisier, it is important to match the detector settings to your frame rate. This can be done having more parameters files and load the one suitable with your experiment.} We experienced that with low energy settings could not reach 6~kHz and no noise.
|
||||
\textbf{From software version 4.0.0, there is a very useful function {\tt{sls\_detector\_get measuredperiod}} which return the measured period AFTER the acquisition. This is important to check that the settings to obtain the targeted frame rate was correct.}
|
||||
|
||||
\textbf{If you run too fast, the detector could become noisier (see problem shooting), it is important to match the detector settings to your frame rate. This can be done having more parameters files and load the one suitable with your experiment.} We experienced that with low energy settings could not reach 6~kHz and no noise.
|
||||
|
||||
In 16 bit mode, it could make sense, in case of noise and low threshold to either reduce the frame rate:
|
||||
\begin{equation}
|
||||
@ -482,6 +520,12 @@ The number of subframes composing a single 32bit acquisition can be calculated a
|
||||
\end{equation}
|
||||
This also means that {\tt{exptime}}$<${\tt{subexptime}} will be rounded to{\tt{subexptime}}. If you want shorter acquisitions, either reduce the {\tt{subexptime}} or switch two 16-bit mode (you can always sum offline if needed).
|
||||
|
||||
From release 4.0.0, an extra {\tt{flag overflow/nooverflow}} is added, with {\tt{nooverflow}} default:
|
||||
\begin{itemize}
|
||||
\item {\tt{nooverflow}}: the internal 12-bit result is summed, even if there was saturation of the 12-bit counter (4095) in any of the subframes. Note that if there is saturation for every subframe, you might get as a result a value of the counter equal to (4095$\times$~number~of~subframes), which you need to correctly identify. On the other hand if the saturation occurred only one time, you will get something "close'' to the real number.
|
||||
\item {\tt{overflow}}: In this case, even if a pixel saturate only 1 time in a subframe, you will be returned as a value of the counter for that pixel: $2^{32}-1$, i.e. 4294967295.
|
||||
\end{itemize}
|
||||
|
||||
The UDP header will contain, after you receive the data, the effective number of subframe per image (see section~\ref{UDP}) as "SubFrame Num or Exp Time", i.e. the number of subframes recorded (32 bit eiger).
|
||||
The effective time the detector has recorded data can be computed as:
|
||||
\begin{equation}
|
||||
@ -489,7 +533,9 @@ The effective time the detector has recorded data can be computed as:
|
||||
%\label{esubframes}
|
||||
\end{equation}
|
||||
|
||||
In the future release, a configurable extra time difference between subframes will be introduced for the parallel mode, so that some noise appearing in detectors at low threshold can be removed. This will enlarge the time difference between frames form the default 12~$\mu$s to something configurable, expected to be 15-40~$\mu$s (for the 9M it is currently 200~$\mu$s due to a noisier module).
|
||||
From release 4.0.0, a configurable extra time difference between subframes can be introduced for the parallel mode, so that some noise appearing in detectors at low threshold can be removed. This is obtained through the {\tt{subdeadtime}}. You need to add values specific for your detector (ask the detector group). Typically, values between 15-40~$\mu$s should be used (for the 9M it is currently 200~$\mu$s due to a noisier module).
|
||||
|
||||
|
||||
|
||||
\section{External triggering options}\label{triggering}
|
||||
The detector can be setup such to receive external triggers. Connect a LEMO signal to the TRIGGER IN connector in the Power Distribution Board (see Fig.). The logic 0 for the board is passed by low level 0$-$0.7~V, the logic 1 is passed to the board with a signal between 1.2$-$5~V. Eiger is 50~$\Omega$ terminated. By default the positive polarity is used (negative should not be passed to the board).
|
||||
@ -515,12 +561,23 @@ Here are the implemented options so far:
|
||||
\item {\tt{auto}} is the software controlled acquisition (does not use triggers), where {\tt{exptime}} and {\tt{period}} have to be set. Set number of cycles (i.e. triggers) to 1 using {\tt{cycles}}. Set number of frames using {\tt{frames}}.
|
||||
\item {\tt{trigger}} 1 frame taken for 1 trigger. Your {\tt{frames}} needs to be 1 always, {\tt{cycles}} can be changed and defines how many triggers are considered. {\tt{exptime}} needs to be set. In the GUI this is called trigger exposure series.
|
||||
\item {\tt{burst\_trigger}} gets only 1 trigger, but allows to take many frames. With {\tt{frames}} one can change the number of frames. {\tt{cycles}} needs to be 1. {\tt{exptime}} and {\tt{period}} have to be set. In the gui it is called trigger readout.
|
||||
\item{\tt{gating}} allows to get a frame only when the trigger pulse is gating. Note that in this case the exp time and period only depend on the gating signal. {\tt{cycles}} allows to select how many gates to consider. Set number of frames to 1 using {\tt{frames}}.
|
||||
\item{\tt{gating}} allows to get a frame only when the trigger pulse is gating. Note that in this case the exp time and period only depend on the gating signal. {\tt{cycles}} allows to select how many gates to consider. Set number of frames to 1 using {\tt{frames}}. ATTENTION: if you are in 16 bit mode and you are applying online rate corrections, as now the exptime is generated by the trigger, you might not have correct rate corrections. If you know what the exposure time is in the gating signal, then you can set the {\tt{exptime}} once and the rate corrections will be correct. If the exposure time is unknow, it is recommended that you switch off the rate corrections. In 32 bit mode, it does not matter as the rate corrections depends on the {\tt{subexptime}} which is software set independently from the gate exptime.
|
||||
|
||||
\end{itemize}
|
||||
|
||||
Hardware-wise, the ENABLE OUT signal outputs when the chips are really acquiring. This means that the single subframes will be output in 32 bit mode. The TRIGGER OUT outputs the sum-up-signal at the moment (which is useless). This will be changed in the future to output the envelop of the enable signal.
|
||||
|
||||
We are planning to change some functionality, i.e. unify the {\tt{trigger}} and {\tt{burst}} trigger modes and make both {\tt{frames}} and {\tt{cycles}} configurable at the same time.
|
||||
We are planning to change some functionality, i.e. unify the {\tt{trigger}} and {\tt{burst\_trigger}} trigger modes and make both {\tt{frames}} and {\tt{cycles}} configurable at the same time.
|
||||
|
||||
There is the possibility to use {\tt{timing trigger/burst\_trigger}} and send software single commands to fake the trigger. This is done with:
|
||||
\begin{verbatim}
|
||||
sls_detector_put 0-timing [trigger/burst_trigger]
|
||||
sls_detector_put 0-frames x
|
||||
sls_detector_put 0-cycles y
|
||||
sls_detector_status trigger
|
||||
\end{verbatim}
|
||||
Note that this functionality is very (!) useful if you need to do something between and acquisition and the next. This can be used to do a fast threshold scan for example. See section~\ref{Sec:fastthresholdscan}.
|
||||
|
||||
|
||||
\section{Autosumming and rate corrections} \label{advanced}
|
||||
|
||||
@ -718,44 +775,53 @@ white the option {\tt{n:flippeddatax 1}}, which flips in vertical the content of
|
||||
\subsection{``raw'' files}
|
||||
If you use the option of writing raw files, you will have a raw file for each UDP port (meaning most likely 2 chips), 4 files per module. In addition to the raw files, you will get also a ``master'' file, containing in ascii some detector general parameters and the explanation of how to interpret the data from the raw files.
|
||||
|
||||
The master file is named: {\tt{filename\_master\_0.raw}} and for version ``3.0'' of the slsDetectorSoftware looks like:
|
||||
The master file is named: {\tt{filename\_master\_0.raw}} and for version ``4.0.0'' of the slsDetectorSoftware looks like:
|
||||
|
||||
\begin{verbatim}
|
||||
Version : 1.0
|
||||
Dynamic Range : 16
|
||||
Ten Giga : 1
|
||||
Image Size : 262144 bytes
|
||||
x : 512 pixels
|
||||
y : 256 pixels
|
||||
Total Frames : 1
|
||||
Exptime (ns) : 1000000000
|
||||
SubExptime (ns) : 2621440
|
||||
Period (ns) : 1000000000
|
||||
Timestamp : Thu Aug 17 10:55:19 2017
|
||||
Version : 2.0
|
||||
Dynamic Range : 32
|
||||
Ten Giga : 1
|
||||
Image Size : 524288 bytes
|
||||
x : 512 pixels
|
||||
y : 256 pixels
|
||||
Max. Frames Per File : 10000
|
||||
Total Frames : 1
|
||||
Exptime (ns) : 1000000000
|
||||
SubExptime (ns) : 2621440
|
||||
SubPeriod(ns) : 2621440
|
||||
Period (ns) : 1000000000
|
||||
Timestamp : Mon Sep 3 09:07:05 2018
|
||||
|
||||
|
||||
#Frame Header
|
||||
Frame Number : 8 bytes
|
||||
SubFrame Number : 4 bytes
|
||||
Packet Number : 4 bytes
|
||||
Bunch ID : 8 bytes
|
||||
Timestamp : 8 bytes
|
||||
Module Id : 2 bytes
|
||||
X Coordinate : 2 bytes
|
||||
Y Coordinate : 2 bytes
|
||||
Z Coordinate : 2 bytes
|
||||
Debug : 4 bytes
|
||||
Round Robin Number : 2 bytes
|
||||
Detector Type : 1 byte
|
||||
Header Version : 1 byte
|
||||
Frame Number : 8 bytes
|
||||
SubFrame Number/ExpLength : 4 bytes
|
||||
Packet Number : 4 bytes
|
||||
Bunch ID : 8 bytes
|
||||
Timestamp : 8 bytes
|
||||
Module Id : 2 bytes
|
||||
X Coordinate : 2 bytes
|
||||
Y Coordinate : 2 bytes
|
||||
Z Coordinate : 2 bytes
|
||||
Debug : 4 bytes
|
||||
Round Robin Number : 2 bytes
|
||||
Detector Type : 1 byte
|
||||
Header Version : 1 byte
|
||||
Packets Caught Mask : 64 bytes
|
||||
\end{verbatim}
|
||||
|
||||
Note that if one wants to reconstruct the real time the detector was acquiring in 32 bit (autosumming mode), one would have to multiply the SubExptime (ns) for the SubFrame Number.
|
||||
|
||||
\subsection{Offline image reconstruction}
|
||||
The offline image reconstruction{\tt{slsImageReconstruction}} is not part of the package anymore.
|
||||
The offline image reconstruction{\tt{slsImageReconstruction}} is not part of the package anymore. The code is still available doing \\
|
||||
{\tt{git clone git@git.psi.ch:sls\_detectors\_software/sls\_image\_reconstruction.git slsImageReconstruction}}.
|
||||
Checkout the {\tt{developer}} branch if in a 3.1.X release or the {\tt{v4.0.0}} branch if in 4.0.X release of the {\tt{slsDetector}} code.
|
||||
|
||||
The detector writes 2 raw files per receiver. An offline image reconstruction executable has been written to collate the possible files together and produce cbf files. The executable uses the CBFlib-0.9.5 library (downloaded from the web as it download some architecture dependent packages at installation).\\
|
||||
Three possible conversions are possible: into \textbf{cbf}, \textbf{hdf5} and \textbf{root} format. The detector writes 4 raw files per receiver. An offline image reconstruction executable has been written to collate the possible files together and produce output files. By default an interpolation between the values of the large pixels is performed. Gap pixels between modules are also inserted.
|
||||
|
||||
|
||||
\subsubsection{cbf}
|
||||
The cbf executable executable uses the CBFlib-0.9.5 library (downloaded from the web as it download some architecture dependent packages at installation).Edit the Makefile to correclty point at it.\\
|
||||
\underline{At cSAXS, the CBFlib-0.9.5 has been compiled -such that the required packages are}\\\underline{ downloaded in /sls/X12SA/data/x12saop/EigerPackage/CBFlib-0.9.5.}\\
|
||||
|
||||
To use it for a single module:
|
||||
@ -765,29 +831,90 @@ cbfMaker [filename with dir]
|
||||
eg.
|
||||
{\tt{cbfMaker /scratch/run\_63\_d1\_f000000000000\_3.raw}}\\
|
||||
|
||||
To use it for a 1.5 multi modules:
|
||||
\begin{verbatim}
|
||||
cbfMaker [filename] [pixels x] [pixels y] ([singlemodulelongside_x] [start det])
|
||||
\end{verbatim}
|
||||
To use it any geometry:\\
|
||||
{\tt{cbfMaker [filename] [pixels x, def=1024] [pixels y, def=512] [singlemodulelongside\_x, def=1] [fillgaps, def=Interpolate Big Pixels] [hdf5datasetname, def="Eiger"] [start det,def=0]}}\\
|
||||
eg.
|
||||
{\tt cbfMaker /scratch/run\_63\_d0\_f000000000000\_3.raw 3072 512 1 0}.\\
|
||||
The {\tt{[singlemodulelongside\_x]}} {\tt{[option to interpolate gap pixels]}} param are optional. Defaults are ``1'', the detector long side is on the x coordinate and start to reconstruct from module 0.
|
||||
{\tt cbfMaker /scratch/run\_63\_d0\_f000000000000\_3.raw 3072 512 1 2 ``Eiger'' 0}.\\
|
||||
|
||||
The {\tt{[singlemodulelongside\_x]}} {\tt{[option to interpolate gap pixels]}} param are optional. Defaults are ``1'', the detector long side is on the x coordinate and to start to reconstruct from module 0.
|
||||
The interpolation scheme fro the gap pixels between chips is by default ``interpolate large big pixels'', =2;
|
||||
If you want to change interpolation scheme, use:\\
|
||||
\begin{tabular}{|c|c|}
|
||||
\hline
|
||||
interpolation scheme & argument\\
|
||||
\hline
|
||||
insert gap pixels and assign value only to the first one & 0\\
|
||||
\hline
|
||||
equally divide the value of the counter bettern the two pixels & 1\\
|
||||
\hline
|
||||
interpolate large pixel value & 2\\
|
||||
\hline
|
||||
mask the value of the two gap pixels & 3\\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\ \\
|
||||
\ \\
|
||||
The executables:
|
||||
\begin{verbatim}
|
||||
bcfMaker1.5M [file_name_with_dir]
|
||||
bcfMaker9M [file_name_with_dir]
|
||||
cbfMaker1.5M [file_name_with_dir]
|
||||
cbfMakerOMNY [file_name_with_dir]
|
||||
cbfMaker9M [file_name_with_dir]
|
||||
\end{verbatim}
|
||||
contain the hardcoded geometry for the 1.5M (3 modules horizontal on the long side) and for the 9M at cSAXS: 6(short side)$\times$3 (long side) modules.\\
|
||||
contain the hardcoded geometry for the 1.5M (3 modules horizontal on the long side), the 1.5M OMNY geometry (3 modules next to each other on the long side) and for the 9M at cSAXS: 6(short side)$\times$3 (long side) modules.\\
|
||||
Missing packets in a frame and border pixels ($\times 2$ and $\times 4$ are given with value $-1$ at the present time.
|
||||
|
||||
It is important to know, that the pixels at the edge between 2 chips count more as double size. We can virtually introduced 1 virtual pixel per double larger pixel, so to have an even number of counts everywhere. Virtual pixels (not filled ) between module gaps are also inserted.
|
||||
Make sure the following options are uncommented in the {\tt{slsImageReconstruction/src/main\_csaxs.cpp}} file.
|
||||
\begin{verbatim}
|
||||
#define MYCBF
|
||||
##following line only if you need to process with
|
||||
##BUBBLE (Material Science / uXAS beamlines).
|
||||
#define MSHeader
|
||||
\end{verbatim}
|
||||
Compile it with:
|
||||
\begin{verbatim}
|
||||
make cbfMaker; make cbfMakerOMNY;
|
||||
\end{verbatim}
|
||||
|
||||
\begin{verbatim}
|
||||
GapPixelsBetweenChips_x = 2;
|
||||
GapPixelsBetweenChips_y = 2;
|
||||
GapPixelsBetweenModules_x = 8;
|
||||
GapPixelsBetweenModules_y = 36;
|
||||
\end{verbatim}
|
||||
\subsubsection{hdf5}
|
||||
In case of HDF5 output file, we rely on having the HDF5 1.10.1 library installed. Edit the Makefile to correclty point at it. Different compression methods are being tried so different external filters might be to be installed. This work is not finished yet.
|
||||
|
||||
To choose HDF5, with ZLIB implementation, open {\tt{slsImageReconstruction/src/main\_csaxs.cpp}} and make sure that
|
||||
\begin{verbatim}
|
||||
#define HDF5f
|
||||
#define ZLIB
|
||||
\end{verbatim}
|
||||
are not commented out. All other options need to be commented out. Copile the code with
|
||||
\begin{verbatim}
|
||||
make hdf5Maker; make hdf5MakerOMNY;
|
||||
\end{verbatim}
|
||||
|
||||
If you are at cSAXS. all images collected will be written in a single file. If you are not at CSAXS, most likely you want to have all the images written in a single raw file into an HDF5 file. The multiple HDF5 files are then linked in a master file, with many subdatasets (can be read by albula) or by a virtual file with a single dataset. If you want a mster o virtual file, uncomment this option:
|
||||
\begin{verbatim}
|
||||
#define MASTERVIRTUAL
|
||||
\end{verbatim}
|
||||
and recompile.
|
||||
To use it for a single module:
|
||||
\begin{verbatim}
|
||||
hdf5Maker [filename with dir]
|
||||
\end{verbatim}
|
||||
eg.
|
||||
{\tt{hdf5Maker /scratch/run\_63\_d1\_f000000000000\_3.raw}}\\
|
||||
|
||||
To use it any geometry:\\
|
||||
{\tt{hdf5Maker [filename] [pixels x, def=1024] [pixels y, def=512] [singlemodulelongside\_x, def=1] [fillgaps, def=Interpolate Big Pixels] [hdf5datasetname, def="Eiger"] [start det,def=0]}}\\
|
||||
eg.
|
||||
{\tt hdf5Maker /scratch/run\_63\_d0\_f000000000000\_3.raw 3072 512 1 2 ``Eiger'' 0}.\\
|
||||
|
||||
\subsubsection{root}
|
||||
The data will be written as TH2D in root format. Edit the {\tt{Makefile}} to point to the correct ROOT library location. Compile the executable as:
|
||||
\begin{verbatim}
|
||||
make image
|
||||
\end{verbatim}
|
||||
There is no program other executable that alredy keeps into account the geometry for it.
|
||||
To use it any geometry:\\
|
||||
{\tt{image [filename] [pixels x, def=1024] [pixels y, def=512] [singlemodulelongside\_x, def=1] [fillgaps, def=Interpolate Big Pixels] [hdf5datasetname, def="Eiger"] [start det,def=0]}}\\
|
||||
eg.
|
||||
{\tt image /scratch/run\_63\_d0\_f000000000000\_3.raw 3072 512 1 2 ``Eiger'' 0}.\\
|
||||
|
||||
\subsection{Read temperatures/HV from boards}
|
||||
|
||||
@ -851,6 +978,16 @@ ssh root@$i sync; done
|
||||
|
||||
\section{Loading firmware bitfiles}
|
||||
|
||||
\textbf{As a new procedure, the first thing to do is to kill the server on the boards, copy the new one there without starting it.} Note taht failure to do this step before may cause the linux on the baords to crash and not being able to ping it (this if the registers between the old and new firmware change).
|
||||
|
||||
This is teh procedure from a terminal;
|
||||
\begin{verbatim}
|
||||
for i in beb111 beb070;
|
||||
do ssh root@$i killall eigerDetectorServer;
|
||||
scp eigerDetectorServer root@$i:~/executables/eigerDetectorServer ;
|
||||
ssh root@$i sync; done
|
||||
\end{verbatim}
|
||||
|
||||
A \textbf{bcp} executable (which needs \textbf{tftp} installed on the PC, is needed.
|
||||
\begin{enumerate}
|
||||
\item Manual way: you need to press something on the detector. To program bitfiles (firmware files), do a hard reset with a pin/thin stuff in the holes at the very back of the module. They are between the top 7 LED and the bottom 1 and opposite for the other side. Push hard till all LEDs are alternating green and red.
|
||||
@ -909,7 +1046,7 @@ for j in $(seq 0 255) ; do
|
||||
sls_detector_put pulsenmove N 0 1;
|
||||
done;
|
||||
done;
|
||||
sls_detector_p resmat 0
|
||||
sls_detector_put resmat 0
|
||||
sls_detector_acquire
|
||||
\end{verbatim}
|
||||
You read {\tt{N}} in every pixel if you are setup correctly.
|
||||
@ -921,6 +1058,12 @@ To load the special noise file look at {\tt{settingsdir/eiger/standard/eigernois
|
||||
\begin{verbatim}
|
||||
sls_detector_put trimbits ../settingsdir/eiger/standard/eigernoise
|
||||
\end{verbatim}
|
||||
To exit from this pattern noise, just set the theshold to something known.
|
||||
\begin{verbatim}
|
||||
\item sls_detector_put threshold 50000 standard
|
||||
\end{verbatim}
|
||||
where 5000 would be a value in eV and {/tt{standard}} is important in this case.
|
||||
|
||||
|
||||
\section{Troubleshooting}
|
||||
\subsection{Cannot successfully finish an acquisition}
|
||||
@ -1017,6 +1160,10 @@ Note that occasionally if there is a shared memory of a different size (from an
|
||||
\end{verbatim}
|
||||
This needs to be cleaned with {\tt{ipcs -m}} and then {\tt{ipcrm -M xxx}}, where xxx are the keys with nattch 0. Alternative in the main slsDetectorFolder there is a script that can be used as {\tt{sh cleansharedmemory.sh}}. Note that you need to run the script with the account of the client user, as the shared memory belongs to the client. It is good procedure to implement an automatic cleanup of the shared memory if the client user changes often.
|
||||
|
||||
\subsection{Client has shared memory iusses}
|
||||
The shared memory from software version 4.0.0 creates shared memory segments in /dev/shm/. You can look at them and cancel them directly. Note that this is still user dependent.
|
||||
Environment variable SLSDETNAME can be set for using 2 different detectors from the same client pc. One needs a different multi detector id if the SLSDETNAME is different for both consoles.
|
||||
|
||||
\subsection{Measure the HV}
|
||||
For every system:
|
||||
\begin{itemize}
|
||||
@ -1038,6 +1185,13 @@ If you see strange lines in vertical occurring at period patterns, it is a memor
|
||||
\subsection{ssh to the boards takes long}
|
||||
Depending on your network setup, to speed up the ssh to the boards from a pc with internal dhcp server running: \textbf{iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE; echo "1" > /proc/sys/net/ipv4/ip\_forward}, where eth1 has to be the 1Gb network device on the pc
|
||||
|
||||
\subsection{Generate keys on the boards not to have to type the password}
|
||||
\begin{verbatim}
|
||||
export AFSDIRS64=/afs/psi.ch/intranet/Controls/Software/Trolltech/SL6-x86_64
|
||||
ssh-copy-id -i /afs/psi.ch/user/t/tinti_g/.ssh/id_rsa.pub root@beb100
|
||||
ssh-keygen
|
||||
\end{verbatim}
|
||||
|
||||
\subsection{Check firmware version installed on BEB}
|
||||
You can either ask in the client as described in section~\ref{api}, or login to the boards directly. Follow some steps described in Section~\ref{server}.
|
||||
\begin{verbatim}
|
||||
@ -1061,6 +1215,13 @@ Scroll up in the terminal till you find:\\
|
||||
*************** MASTER/SLAVE ***************\\
|
||||
*************** NORMAL/SPECIAL ***************\\
|
||||
|
||||
There is also an easier way, that is that only the master module will reaturn the real value of the HV. If you have more than 1 detector system, then you will have more than 1 physical master, as the HV needs to be applied to all the systems.
|
||||
|
||||
\begin{verbatim}
|
||||
for i in $(seq 0 36); do sls_detector_put $i:vhighvoltage; done
|
||||
\end{verbatim}
|
||||
Only the master will return to you a sensible number (150 normally). the others will return -999.
|
||||
|
||||
\subsection{'Cannot connect to socket'}
|
||||
This error is typically due to the detector server not running. For why, see section~\ref{servernot}.
|
||||
|
||||
@ -1078,15 +1239,14 @@ If you see the client returning the following error message:\\
|
||||
\end{verbatim}
|
||||
|
||||
\subsection{There is noise running the detector in 32-bit}
|
||||
Short story (for now): You are running in {\tt{parallel}} mode, switch {\tt{flags}} to non {\tt{nonparallel}} mode.
|
||||
Long story: If you are running the detector in 32-bit (autosumming), there might be some noise, particularly at lower thereshold energies. This is due to the fact that the analog part of the chips require some latency time to settle which is larger than the redout time. At the present moment it is possible to run the detector only in {\tt{parallel}} or {\tt{nonparallel}} mode, respectively with readout times between frames of 12~$\mu$s and 504~$\mu$s. If you switch {\tt{flags}} to non {\tt{nonparallel}} mode you will giveenough time for teh signals to settle. For future realeas we are planning to introduce some configurable delay, such that you can remain with the {\tt{parallel}} flag, but can obtain a configurable dead time between frames in the range 12$-$504~$\mu$s.
|
||||
If you are running the detector in 32-bit (autosumming), there might be some noise, particularly at lower thereshold energies. This is due to the fact that the analog part of the chips require some latency time to settle which is larger than the readout time. It is possible to run the detector only in {\tt{parallel}} or {\tt{nonparallel}} mode, respectively with readout times between frames of 12~$\mu$s and 504~$\mu$s. If you switch {\tt{flags}} to non {\tt{nonparallel}} mode you will give enough time for the signals to settle. From release 4.0.0, there is a configurable delay that can be set through the {\tt{subdeadtime}} variable, such that you can remain with the {\tt{parallel}} flag, but can obtain a configurable dead time between frames. Ask the SLS detector group for an appropriate dead time for your detector, but typically a dead time of 20-50~$\mu$s should be enough. Note that this {\tt{subdeadtime}} need to include the 12~$\mu$s minimum readout time, so it has to be larger than 12~$\mu$s to do anything.
|
||||
|
||||
\subsection{There is noise running the detector at high frame rate(4,8,16 bit)}
|
||||
If are running in {\tt{parallel}} mode, in particular at low thereshold energies, you might encounter some noise. The reason is that the analog part of the chips require some latency time to settle which is larger than the redout time.
|
||||
If are running in {\tt{parallel}} mode, in particular at low thereshold energies, you might encounter some noise. The reason is that the analog part of the chips require some latency time to settle which is larger than the readout time.
|
||||
\begin{enumerate}
|
||||
\item You can lower the frame rate and relax requirements on period:
|
||||
At low frame rate, you normally leave enough time between the end of the acquisition and the starting of the next, so you should not see this effect. In any case setting a {\tt{period}}={\tt{exptime}}+readout time from Table~\ref{tchipro} +extra 20$\mu$s cures the problem. The 20$\mu$s could also be 10~$\mu$s, they are very hardware dependent.
|
||||
\item The frame rate requirement are stingent (as for time resolved measurements): the only option here is to reduce the {\tt{exptime}} to let the extra 20~$\mu$s (or 10)~$\mu$s. The {\tt{period}} remains the same.
|
||||
\item The frame rate requirement are stringent (as for time resolved measurements): the only option here is to reduce the {\tt{exptime}} to let the extra 20~$\mu$s (or 10)~$\mu$s. The {\tt{period}} remains the same.
|
||||
\end{enumerate}
|
||||
|
||||
\section{Client checks - command line}
|
||||
@ -1289,7 +1449,7 @@ In table~\ref{tframescomplete} is a list of all the readout times in the differe
|
||||
\end{table}
|
||||
\end{tiny}
|
||||
|
||||
Table~\ref{tx} shows the bandwidth of data trasnferring between the FEB and BEB and of the DDR2 memory access. the GTX lanes are only capable of 25.6~Gbit/s. This limits the 12/16 bit frame rate. The 2$\times$DDR2 memories have a bandwidth or 2$\cdot$25.6~Gb/s=51.2~Gb/s. Due to this memory access bandwidth, the 32 bit autosumming mode can only run in {\tt{clkdivider}} 2.
|
||||
Table~\ref{tx} shows the bandwidth of data transferring between the FEB and BEB and of the DDR2 memory access. the GTX lanes are only capable of 25.6~Gbit/s. This limits the 12/16 bit frame rate. The 2$\times$DDR2 memories have a bandwidth or 2$\cdot$25.6~Gb/s=51.2~Gb/s. Due to this memory access bandwidth, the 32 bit autosumming mode can only run in {\tt{clkdivider}} 2.
|
||||
\begin{figure}[t]
|
||||
\begin{center}
|
||||
\includegraphics[width=1.\textwidth]{TansmissionRates}
|
||||
|
BIN
manual/manual-client/GapPixels.png
Normal file
BIN
manual/manual-client/GapPixels.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
@ -61,6 +61,11 @@ The \textit{data receiver}, which can be run on a different machine than the
|
||||
client, receives the data from the detector and processes it. The receiver can
|
||||
be configured, controlled and monitored by the client.
|
||||
|
||||
\item \textcolor{blue}{slsMultiReceiver}: \\
|
||||
It is the same as the \textit{slsReceiver}, but that it is a single process
|
||||
for many multiple slsReceiver child processes. One can configure the start TCP port,
|
||||
number of slsReceiver processes and if call back should be enabled or not.
|
||||
|
||||
\item \textcolor{blue}{slsDetectorGUI}: \\
|
||||
The \textit{graphical user interface}, which provides a user friendly way
|
||||
of operating the detectors and data receivers with online data preview.
|
||||
@ -110,13 +115,13 @@ conda config --add channels conda-forge
|
||||
conda config --add channels slsdetectorgroup
|
||||
|
||||
#Install latest version
|
||||
conda install sls_detector_software
|
||||
conda install sls_detector_lib
|
||||
conda install sls_detector_gui
|
||||
|
||||
#Install specific release (GLIBC2.14)
|
||||
conda install sls_detector_software=3.1.0
|
||||
#Install specific release
|
||||
conda install sls_detector_lib=4.0.0
|
||||
conda install sls_detector_gui=4.0.0
|
||||
|
||||
#Scientific Linux 6 version (GLIBC2.12)
|
||||
conda install sls_detector_software=SL6_3.1.0
|
||||
\end{verbatim}
|
||||
\item The package including Python interface
|
||||
\begin{verbatim}
|
||||
@ -127,11 +132,9 @@ conda config --add channels sls_detector
|
||||
#Install latest version
|
||||
conda install sls_detector
|
||||
|
||||
#Install specific release (GLIBC2.14)
|
||||
conda install sls_detector=3.1.0
|
||||
#Install specific release
|
||||
conda install sls_detector=4.0.0
|
||||
|
||||
#Scientific Linux 6 version (GLIBC2.12)
|
||||
conda install sls_detector=SL6_3.1.0
|
||||
\end{verbatim}
|
||||
\end{itemize}
|
||||
|
||||
@ -148,13 +151,13 @@ acquisition system, or if one wants to download the source code and compile.
|
||||
\begin{verbatim}
|
||||
#Clone source code with specific release
|
||||
git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git --branch
|
||||
3.1.0
|
||||
4.0.0
|
||||
\end{verbatim}
|
||||
\item The package including Python interface
|
||||
\begin{verbatim}
|
||||
#Clone source code with specific release
|
||||
git clone https://github.com/slsdetectorgroup/sls_detector.git --branch
|
||||
3.1.0
|
||||
4.0.0
|
||||
\end{verbatim}
|
||||
\end{itemize}
|
||||
|
||||
@ -437,14 +440,11 @@ the SLS Detector Package or a different detector type.
|
||||
One can use the \verb=cleansharedmemory.sh= script available under the
|
||||
slsDetector Package.
|
||||
|
||||
One can also just use the following commands to clean the shared memory
|
||||
segments one by one.
|
||||
\begin{verbatim}
|
||||
#displays list of shared memeory segments
|
||||
ipcs -m
|
||||
#remove segments that have nattach equal to zero. They key is the first column
|
||||
ipcrm -M [key]
|
||||
\end{verbatim}
|
||||
One can also just delete the files that are typically located under /dev/shm/ folder
|
||||
and starts with slsDetectorPackage.
|
||||
|
||||
One no longer has to delete segments using ipcs.
|
||||
|
||||
|
||||
\section{Software Upgrade}
|
||||
|
||||
@ -544,14 +544,14 @@ detector board the programming files and/or software package provided by
|
||||
the SLS Detectors group.
|
||||
|
||||
\subsubsection{GOTTHARD Firmware}
|
||||
\textit{For SLS Detector Package v3.1.0} \\
|
||||
\textit{For SLS Detector Package v4.0.0} \\
|
||||
\indent Minimum compatible version: \\
|
||||
\indent \indent 11.01.2013 \\
|
||||
\indent Latest version: \\
|
||||
\indent \indent 08.02.2018 (50um and 25um Master) \\
|
||||
\indent \indent 08.02.2018 (50um) \\
|
||||
\indent \indent 08.02.2018 (25 um Master) \\
|
||||
\indent \indent 09.02.2018 (25 um Slave) \\
|
||||
|
||||
|
||||
Normally, the firmware will be upgraded by us as it requires programming the
|
||||
FPGA via the USB-Blaster.
|
||||
|
||||
@ -636,9 +636,9 @@ detector board the programming files and/or software package provided by
|
||||
the SLS Detectors group.
|
||||
|
||||
\subsubsection{EIGER Firmware}
|
||||
\textit{For SLS Detector Package v3.1.0} \\
|
||||
\indent Minimum compatible version: 16 \\
|
||||
\indent Latest version: 20 \\
|
||||
\textit{For SLS Detector Package v4.0.0} \\
|
||||
\indent Minimum compatible version: 22 \\
|
||||
\indent Latest version: 22 \\
|
||||
|
||||
|
||||
\begin{enumerate}
|
||||
@ -647,6 +647,20 @@ Detector Group.
|
||||
\item If one does not have the bcp script, that should also be obtained from
|
||||
the SLS Detector Group. It is required to program the bit files and requires
|
||||
that tftp be installed on the pc.
|
||||
\item Bring the detector into programmable mode by either of the following ways.
|
||||
Both ways end up in just the central LED blinking.
|
||||
\begin{enumerate}
|
||||
\item hard reset on the back panel boards resulting in blinking LEDS
|
||||
\item by having the following program running in the background.
|
||||
\begin{verbatim}
|
||||
boot_recovery
|
||||
\end{verbatim}
|
||||
\end{enumerate}
|
||||
\item Start a terminal for each half module and run the following to see
|
||||
progress.
|
||||
\begin{verbatim}
|
||||
nc -p 3000 -u bebxxx 3000
|
||||
\end{verbatim}
|
||||
\item Run the following to update firmware
|
||||
\begin{verbatim}
|
||||
#update back end fpga
|
||||
@ -715,9 +729,9 @@ detector board the programming files and/or software package provided by
|
||||
the SLS Detectors group.
|
||||
|
||||
\subsubsection{JUNGFRAU Firmware}
|
||||
\textit{For SLS Detector Package v3.1.0} \\
|
||||
\indent Minimum compatible version: 13.11.2017 \\
|
||||
\indent Latest version: 13.11.2017 \\
|
||||
\textit{For SLS Detector Package v4.0.0} \\
|
||||
\indent Minimum compatible version: 15.06.2018 \\
|
||||
\indent Latest version: 15.06.2018 \\
|
||||
|
||||
|
||||
At times, one has to update the firmware, which then also requires updating the
|
||||
@ -733,7 +747,7 @@ Detector Group.
|
||||
\item Update the latest SLS Detector package installed.
|
||||
\item Update the on-board software as per the instructions in the next
|
||||
section.
|
||||
\item Start the on-board server in debug mode:
|
||||
\item Start the on-board server in update mode:
|
||||
\begin{enumerate}
|
||||
\item Connect to the blackfin on the detector\\
|
||||
\verb=telnet bchipxxx=
|
||||
@ -743,10 +757,10 @@ section.
|
||||
\item Comment out the line
|
||||
\verb=#ttyS0::respawn:/jungfrauDetectorServervxxx=
|
||||
\item Reboot blackfin using \verb=reboot=
|
||||
\item Run \verb=ps= to ensure no gotthardDetectorServers are running
|
||||
\item Run \verb=ps= to ensure no jungfrauDetectorServers are running
|
||||
\end{enumerate}
|
||||
\item Start the server in debug mode using: \\
|
||||
\verb=./jungfrauDetectorServerxxx -debug= \\
|
||||
\item Start the server in update mode using: \\
|
||||
\verb=./jungfrauDetectorServerxxx -update= \\
|
||||
Leave this console on to come back to it later.
|
||||
\end{enumerate}
|
||||
\item From the command line of the pc, clear shared memory \\
|
||||
@ -759,7 +773,7 @@ script in \verb=slsDetectorPackage/cleansharedmemory.sh=
|
||||
\verb=./sls_detector_put programfpga xxx.pof=
|
||||
\item Once the programming is done:
|
||||
\begin{enumerate}
|
||||
\item Switch to the console that has the debug server running and kill it
|
||||
\item Switch to the console that has the update server running and kill it
|
||||
using Ctrl+C and ensure no jungfrauDetectorServers are
|
||||
running
|
||||
\item Restart the new server to see if it runs with the new firmware \\
|
||||
|
15
recipe/build.sh
Normal file
15
recipe/build.sh
Normal file
@ -0,0 +1,15 @@
|
||||
mkdir build
|
||||
mkdir install
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
-DUSE_TEXTCLIENT=ON \
|
||||
-DUSE_RECEIVER=ON \
|
||||
-DUSE_GUI=ON \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DUSE_HDF5=OFF\
|
||||
|
||||
|
||||
cmake --build . -- -j10
|
||||
cmake --build . --target install
|
15
recipe/copy_gui.sh
Normal file
15
recipe/copy_gui.sh
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
mkdir $PREFIX/lib
|
||||
mkdir $PREFIX/bin
|
||||
mkdir $PREFIX/include
|
||||
|
||||
#No libs for gui?
|
||||
|
||||
#Binaries
|
||||
cp build/bin/gui_client $PREFIX/bin/.
|
||||
cp build/bin/slsDetectorGui $PREFIX/bin/.
|
||||
|
||||
|
||||
#Which headers do we need for development??
|
||||
|
||||
# cp include/some_lib.h $PREFIX/include/.
|
23
recipe/copy_lib.sh
Normal file
23
recipe/copy_lib.sh
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
mkdir $PREFIX/lib
|
||||
mkdir $PREFIX/bin
|
||||
mkdir $PREFIX/include
|
||||
mkdir $PREFIX/include/slsDetectorPackage
|
||||
|
||||
#Shared and static libraries
|
||||
cp build/bin/libSlsDetector.so $PREFIX/lib/.
|
||||
cp build/bin/libSlsDetector.a $PREFIX/lib/.
|
||||
cp build/bin/libSlsReceiver.so $PREFIX/lib/.
|
||||
cp build/bin/libSlsReceiver.a $PREFIX/lib/.
|
||||
|
||||
#Binaries
|
||||
cp build/bin/sls_detector_acquire $PREFIX/bin/.
|
||||
cp build/bin/sls_detector_get $PREFIX/bin/.
|
||||
cp build/bin/sls_detector_put $PREFIX/bin/.
|
||||
cp build/bin/sls_detector_help $PREFIX/bin/.
|
||||
cp build/bin/slsReceiver $PREFIX/bin/.
|
||||
cp build/bin/slsMultiReceiver $PREFIX/bin/.
|
||||
|
||||
#Which headers do we need for development??
|
||||
cp build/install/include/* $PREFIX/include/slsDetectorPackage/
|
||||
# cp include/some_lib.h $PREFIX/include/.
|
89
recipe/meta.yaml
Normal file
89
recipe/meta.yaml
Normal file
@ -0,0 +1,89 @@
|
||||
|
||||
package:
|
||||
name: sls_detector_software
|
||||
version: "developer"
|
||||
|
||||
source:
|
||||
- path: ..
|
||||
|
||||
build:
|
||||
number: 0
|
||||
rpaths:
|
||||
- lib/
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- cmake
|
||||
- qwt 6.*
|
||||
- qt=4.8.7=7
|
||||
- zeromq=4.2.5=hfc679d8_5
|
||||
- pyzmq
|
||||
- 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]
|
||||
|
||||
host:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
- libpng >=1.6.32,<1.6.35
|
||||
- xorg-libx11
|
||||
- xorg-libice
|
||||
- xorg-libxext
|
||||
- xorg-libsm
|
||||
- xorg-libxau
|
||||
- xorg-libxrender
|
||||
- xorg-libxfixes
|
||||
|
||||
run:
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
|
||||
outputs:
|
||||
- name: sls_detector_lib
|
||||
version: "developer"
|
||||
script: copy_lib.sh
|
||||
requirements:
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- name: sls_detector_gui
|
||||
version: "developer"
|
||||
script: copy_gui.sh
|
||||
requirements:
|
||||
build:
|
||||
- {{ compiler('c') }}
|
||||
- {{compiler('cxx')}}
|
||||
- cmake
|
||||
- qwt 6.*
|
||||
- qt=4.8.7=7
|
||||
- zeromq=4.2.5=hfc679d8_5
|
||||
- pyzmq
|
||||
- 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]
|
||||
run:
|
||||
- sls_detector_lib=developer
|
||||
- qwt 6.*
|
||||
- qt=4.8.7=7
|
@ -1 +0,0 @@
|
||||
../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_developer
|
@ -1 +0,0 @@
|
||||
../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualMaster
|
@ -1 +0,0 @@
|
||||
../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualSlave
|
1
serverBin/eigerDetectorServerv4.0.0.22.0
Symbolic link
1
serverBin/eigerDetectorServerv4.0.0.22.0
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv4.0.0.22.0
|
@ -1 +0,0 @@
|
||||
../slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_developer
|
@ -1 +0,0 @@
|
||||
../slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_virtual
|
1
serverBin/gotthardDetectorServerv4.0.0.3
Symbolic link
1
serverBin/gotthardDetectorServerv4.0.0.3
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServerv4.0.0.3
|
@ -1 +0,0 @@
|
||||
../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer
|
@ -1 +0,0 @@
|
||||
../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_virtual
|
1
serverBin/jungfrauDetectorServerv4.0.0.0
Symbolic link
1
serverBin/jungfrauDetectorServerv4.0.0.0
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv4.0.0.0
|
45
slsDetectorCalibration/Stat.h
Normal file
45
slsDetectorCalibration/Stat.h
Normal file
@ -0,0 +1,45 @@
|
||||
class Stat
|
||||
{
|
||||
public:
|
||||
|
||||
Stat() : n(0), m(0.), m2(0.) {}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
n = 0;
|
||||
m=0;
|
||||
m2=0;
|
||||
}
|
||||
|
||||
void Push(double x)
|
||||
{
|
||||
|
||||
m+=x;
|
||||
m2+=x*x;
|
||||
n++;
|
||||
}
|
||||
|
||||
int NumDataValues() const
|
||||
{
|
||||
return n;
|
||||
}
|
||||
|
||||
double Mean() const
|
||||
{
|
||||
return (n > 0) ? m/n : 0.0;
|
||||
}
|
||||
|
||||
double Variance() const
|
||||
{
|
||||
return ( (n >0 ) ? (m2/n-m*m/(n*n)) : 0.0 );
|
||||
}
|
||||
|
||||
double StandardDeviation() const
|
||||
{
|
||||
return sqrt( Variance() );
|
||||
}
|
||||
|
||||
private:
|
||||
int n;
|
||||
double m, m2;
|
||||
};
|
@ -8,6 +8,7 @@
|
||||
#include "pedestalSubtraction.h"
|
||||
#include "commonModeSubtraction.h"
|
||||
#include "tiffIO.h"
|
||||
#include "slsInterpolation.h"
|
||||
|
||||
|
||||
#ifdef ROOTSPECTRUM
|
||||
@ -29,6 +30,10 @@ using namespace std;
|
||||
enum to define the flags of the data set, which are needed to seect the type of processing it should undergo: frame, pedestal, flat
|
||||
*/
|
||||
enum frameMode { eFrame, ePedestal, eFlat };
|
||||
/**
|
||||
enum to define the detector mode
|
||||
*/
|
||||
enum detectorMode { eAnalog, ePhotonCounting, eInterpolating };
|
||||
#endif
|
||||
|
||||
|
||||
@ -76,7 +81,6 @@ template <class dataType> class analogDetector {
|
||||
fMode=ePedestal;
|
||||
thr=0;
|
||||
myFile=NULL;
|
||||
fm=new pthread_mutex_t ;
|
||||
#ifdef ROOTSPECTRUM
|
||||
hs=new TH2F("hs","hs",2000,-100,10000,nx*ny,-0.5,nx*ny-0.5);
|
||||
#ifdef ROOTCLUST
|
||||
@ -124,7 +128,6 @@ template <class dataType> class analogDetector {
|
||||
// nSigma=orig->nSigma;
|
||||
fMode=orig->fMode;
|
||||
myFile=orig->myFile;
|
||||
fm=orig->fm;
|
||||
|
||||
|
||||
stat=new pedestalSubtraction*[ny];
|
||||
@ -218,8 +221,8 @@ template <class dataType> class analogDetector {
|
||||
if (gm) {
|
||||
if (gmap) delete [] gmap;
|
||||
gmap=new double[nnx*nny];
|
||||
for (int ix=0; ix<nnx; ix++) {
|
||||
for (int iy=0; iy<nny; iy++) {
|
||||
for (int ix=0; ix<nnx; ix++) {
|
||||
gmap[iy*nnx+ix]=gm[iy*nnx+ix];
|
||||
}
|
||||
}
|
||||
@ -237,8 +240,8 @@ template <class dataType> class analogDetector {
|
||||
void *ret;
|
||||
if (gmap) {
|
||||
gm=new float[nx*ny];
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
gm[iy*nx+ix]=gmap[iy*nx+ix];
|
||||
}
|
||||
}
|
||||
@ -322,10 +325,11 @@ template <class dataType> class analogDetector {
|
||||
|
||||
virtual void addToCommonMode(char *data){
|
||||
if (cmSub) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
// if (getNumpedestals(ix,iy)>0)
|
||||
addToCommonMode(data, ix, iy);
|
||||
if (det->isGood(ix,iy))
|
||||
addToCommonMode(data, ix, iy);
|
||||
}
|
||||
}
|
||||
//cout << "cm " << getCommonMode(0,0) << " " << getCommonMode(1,0) << endl;
|
||||
@ -383,9 +387,10 @@ template <class dataType> class analogDetector {
|
||||
virtual double* getPedestal(double *ped){
|
||||
if (ped==NULL)
|
||||
ped=new double[nx*ny];
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
ped[iy*nx+ix]=stat[iy][ix].getPedestal();
|
||||
//cout << ped[iy*nx+ix] << " " ;
|
||||
}
|
||||
}
|
||||
return ped;
|
||||
@ -400,8 +405,8 @@ template <class dataType> class analogDetector {
|
||||
virtual double* getPedestalRMS(double *ped=NULL){
|
||||
if (ped==NULL)
|
||||
ped=new double[nx*ny];
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
ped[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
|
||||
}
|
||||
}
|
||||
@ -440,8 +445,8 @@ template <class dataType> class analogDetector {
|
||||
*/
|
||||
virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){
|
||||
double rr=0;
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
if (rms) rr=rms[iy*nx+ix];
|
||||
stat[iy][ix].setPedestal(ped[iy*nx+ix],rr, m);
|
||||
};
|
||||
@ -469,8 +474,8 @@ template <class dataType> class analogDetector {
|
||||
\param rms pointer to array of pedestal rms
|
||||
*/
|
||||
virtual void setPedestalRMS(double *rms){
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
stat[iy][ix].setPedestalRMS(rms[iy*nx+ix]);
|
||||
};
|
||||
};
|
||||
@ -493,8 +498,8 @@ template <class dataType> class analogDetector {
|
||||
|
||||
#endif
|
||||
gm=new float[nx*ny];
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
gm[iy*nx+ix]=image[iy*nx+ix];
|
||||
#ifdef ROOTSPECTRUM
|
||||
hmap->SetBinContent(ix+1, iy+1,image[iy*nx+ix]);
|
||||
@ -541,8 +546,8 @@ template <class dataType> class analogDetector {
|
||||
TH2F *hmap=new TH2F("hmap","hmap",nx, -0.5,nx-0.5, ny, -0.5, ny-0.5);
|
||||
|
||||
#endif
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
/* if (cmSub) */
|
||||
/* gm[iy*nx+ix]=stat[iy][ix].getPedestal()-cmSub->getCommonMode(); */
|
||||
/* else */
|
||||
@ -588,8 +593,8 @@ template <class dataType> class analogDetector {
|
||||
|
||||
|
||||
if (gm) {
|
||||
for (int ix=0; ix<nnx; ix++) {
|
||||
for (int iy=0; iy<nny; iy++) {
|
||||
for (int ix=0; ix<nnx; ix++) {
|
||||
stat[iy][ix].setPedestal(gm[iy*nx+ix],-1,-1);
|
||||
}
|
||||
}
|
||||
@ -613,8 +618,8 @@ template <class dataType> class analogDetector {
|
||||
|
||||
|
||||
if (gm) {
|
||||
for (int ix=0; ix<nnx; ix++) {
|
||||
for (int iy=0; iy<nny; iy++) {
|
||||
for (int ix=0; ix<nnx; ix++) {
|
||||
image[iy*nx+ix]=gm[iy*nx+ix];
|
||||
}
|
||||
}
|
||||
@ -639,8 +644,8 @@ template <class dataType> class analogDetector {
|
||||
float *gm=NULL;
|
||||
void *ret;
|
||||
gm=new float[nx*ny];
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
gm[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
|
||||
}
|
||||
}
|
||||
@ -661,8 +666,8 @@ template <class dataType> class analogDetector {
|
||||
if (nnx>nx) nnx=nx;
|
||||
if (nny>ny) nny=ny;
|
||||
if (gm) {
|
||||
for (int ix=0; ix<nnx; ix++) {
|
||||
for (int iy=0; iy<nny; iy++) {
|
||||
for (int ix=0; ix<nnx; ix++) {
|
||||
stat[iy][ix].setPedestalRMS(gm[iy*nx+ix]);
|
||||
}
|
||||
}
|
||||
@ -682,24 +687,28 @@ template <class dataType> class analogDetector {
|
||||
\param data pointer to the data
|
||||
*/
|
||||
|
||||
|
||||
virtual void addToPedestal(char *data, int cm=0) {
|
||||
|
||||
|
||||
// cout << "add to pedestal " << endl;
|
||||
newFrame();
|
||||
|
||||
if (cmSub) {
|
||||
addToCommonMode(data);
|
||||
}
|
||||
|
||||
// cout << xmin << " " << xmax << endl;
|
||||
//cout << xmin << " " << xmax << endl;
|
||||
// cout << ymin << " " << ymax << endl;
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
addToPedestal(data,ix,iy,1);
|
||||
|
||||
#ifdef ROOTSPECTRUM
|
||||
subtractPedestal(data,ix,iy,cm);
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
if (det->isGood(ix,iy)) {
|
||||
addToPedestal(data,ix,iy,1);
|
||||
//if (ix==10 && iy==10)
|
||||
// cout <<ix << " " << iy << " " << getPedestal(ix,iy)<< endl;
|
||||
#ifdef ROOTSPECTRUM
|
||||
subtractPedestal(data,ix,iy,cm);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -709,6 +718,7 @@ template <class dataType> class analogDetector {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Sets region of interest in which data should be processed
|
||||
\param xmi minimum x. if -1 or out of range remains unchanged
|
||||
@ -783,12 +793,12 @@ template <class dataType> class analogDetector {
|
||||
else
|
||||
val=((double*)data)[iy*nx+ix];
|
||||
|
||||
/* if (ix==10 && iy==10) */
|
||||
/* cout << ix << " " << iy << " " << val ; */
|
||||
/* if (ix==10 && iy==10) */
|
||||
/* cout << ix << " " << iy << " " << val ; */
|
||||
/* if (ix==100 && iy==100) */
|
||||
/* cout << ix << " " << iy << " " << val; */
|
||||
addToPedestal(val,ix,iy);
|
||||
/* if (ix==10 && iy==10) */
|
||||
/* if (ix==10 && iy==10) */
|
||||
/* cout <<" " << getPedestal(ix,iy)<< endl; */
|
||||
/* if (ix==100 && iy==100) */
|
||||
/* cout << " " << getPedestal(ix,iy)<< endl; */
|
||||
@ -813,9 +823,10 @@ template <class dataType> class analogDetector {
|
||||
if (val==NULL)
|
||||
val=image;//new double[nx*ny];
|
||||
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
val[iy*nx+ix]+=subtractPedestal(data, ix, iy,cm);
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
if (det->isGood(ix,iy))
|
||||
val[iy*nx+ix]+=subtractPedestal(data, ix, iy,cm);
|
||||
}
|
||||
}
|
||||
return val;
|
||||
@ -843,9 +854,11 @@ template <class dataType> class analogDetector {
|
||||
if (g==0) g=-1.;
|
||||
}
|
||||
|
||||
if (det)
|
||||
if (det) {
|
||||
/* if (det->getChannel(data, ix, iy)>=0x3fff) */
|
||||
/* cout << ix << " " << iy << " " << det->getChannel(data, ix, iy) <<endl; */
|
||||
val= (dataSign*det->getValue(data, ix, iy)-getPedestal(ix,iy,cm))/g;
|
||||
else
|
||||
} else
|
||||
val= (((double*)data)[iy*nx+ix]-getPedestal(ix,iy))/g;
|
||||
|
||||
#ifdef ROOTSPECTRUM
|
||||
@ -940,9 +953,10 @@ template <class dataType> class analogDetector {
|
||||
|
||||
addToCommonMode(data);
|
||||
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
nph[iy*nx+ix]+=getNPhotons(data, ix, iy);
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
if (det->isGood(ix,iy))
|
||||
nph[iy*nx+ix]+=getNPhotons(data, ix, iy);
|
||||
}
|
||||
}
|
||||
return nph;
|
||||
@ -954,8 +968,8 @@ template <class dataType> class analogDetector {
|
||||
|
||||
*/
|
||||
virtual void clearImage(){
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
image[iy*nx+ix]=0;
|
||||
}
|
||||
}
|
||||
@ -985,8 +999,8 @@ template <class dataType> class analogDetector {
|
||||
int SetNPedestals(int i=-1) {
|
||||
int ix=0, iy=0;
|
||||
if (i>0)
|
||||
for (ix=0; ix<nx; ix++)
|
||||
for (iy=0; iy<ny; iy++)
|
||||
for (ix=0; ix<nx; ix++)
|
||||
stat[iy][ix].SetNPedestals(i);
|
||||
return stat[0][0].SetNPedestals();
|
||||
};
|
||||
@ -1018,10 +1032,13 @@ template <class dataType> class analogDetector {
|
||||
if (ymi<0) ymi=ymin;
|
||||
if (yma<0) yma=ymax;
|
||||
|
||||
for (int ix=xmi; ix<xma; ix++)
|
||||
for (int iy=ymi; iy<yma; iy++)
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
|
||||
val+=getNPhotons(data, ix, iy);
|
||||
for (int ix=xmi; ix<xma; ix++)
|
||||
if (det->isGood(ix,iy)) {
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
|
||||
val+=getNPhotons(data, ix, iy);
|
||||
}
|
||||
|
||||
return val;
|
||||
|
||||
};
|
||||
@ -1038,16 +1055,17 @@ template <class dataType> class analogDetector {
|
||||
virtual void processData(char *data,int *val=NULL) {
|
||||
switch(fMode) {
|
||||
case ePedestal:
|
||||
// cout << "ped " << endl;
|
||||
//cout << "analog ped " << endl;
|
||||
addToPedestal(data);
|
||||
break;
|
||||
default:
|
||||
// cout << "analog " << endl;
|
||||
//subtractPedestal(data);
|
||||
getNPhotons(data);
|
||||
}
|
||||
};
|
||||
|
||||
virtual char *getInterpolation(){return NULL;};
|
||||
// virtual char *getInterpolation(){return NULL;};
|
||||
|
||||
/** sets the current frame mode for the detector
|
||||
\param f frame mode to be set
|
||||
@ -1061,6 +1079,21 @@ template <class dataType> class analogDetector {
|
||||
*/
|
||||
frameMode getFrameMode() {return fMode;};
|
||||
|
||||
|
||||
|
||||
//enum detectorMode { eAnalog, ePhotonCounting, eInterpolating };
|
||||
/** sets the current detector mode for the detector
|
||||
\param f detector mode to be set
|
||||
\returns current detector mode
|
||||
*/
|
||||
detectorMode setDetectorMode(detectorMode f) {dMode=f; return dMode;};
|
||||
|
||||
/** gets the current detector mode for the detector
|
||||
\returns current detector mode
|
||||
*/
|
||||
detectorMode getDetectorMode() {return dMode;};
|
||||
|
||||
|
||||
/** sets file pointer where to write the clusters to
|
||||
\param f file pointer
|
||||
\returns current file pointer
|
||||
@ -1071,7 +1104,32 @@ FILE *setFilePointer(FILE *f){myFile=f; return myFile;};
|
||||
\returns current file pointer
|
||||
*/
|
||||
FILE *getFilePointer(){return myFile;};
|
||||
void setMutex(pthread_mutex_t *m){fm=m;};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
virtual slsInterpolation *getInterpolation(){
|
||||
return NULL;
|
||||
};
|
||||
|
||||
virtual slsInterpolation *setInterpolation(slsInterpolation *ii){return NULL;}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual double setNSigma(double n) {return 0;};
|
||||
virtual void setEnergyRange(double emi, double ema) {;};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
slsDetectorData<dataType> *det; /**< slsDetectorData to be used */
|
||||
@ -1092,6 +1150,7 @@ FILE *getFilePointer(){return myFile;};
|
||||
double thr; /**< threshold to be used for conversion into number of photons */
|
||||
// int nSigma; /**< number of sigma to be used for conversion into number of photons if threshold is undefined */
|
||||
frameMode fMode; /**< current detector frame mode */
|
||||
detectorMode dMode; /**< current detector frame mode */
|
||||
FILE *myFile; /**< file pointer to write to */
|
||||
#ifdef ROOTSPECTRUM
|
||||
TH2F *hs;
|
||||
@ -1102,7 +1161,6 @@ FILE *getFilePointer(){return myFile;};
|
||||
TH2F *hs9;
|
||||
#endif
|
||||
#endif
|
||||
pthread_mutex_t *fm;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
116
slsDetectorCalibration/commonModeSubtractionNew.h
Normal file
116
slsDetectorCalibration/commonModeSubtractionNew.h
Normal file
@ -0,0 +1,116 @@
|
||||
#ifndef COMMONMODESUBTRACTION_H
|
||||
#define COMMONMODESUBTRACTION_H
|
||||
|
||||
#include <cmath>
|
||||
|
||||
class commonModeSubtraction {
|
||||
|
||||
/** @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
|
||||
|
||||
*/
|
||||
commonModeSubtraction(int iroi=1, int ns=3) : nROI(iroi), nsigma(ns) {
|
||||
mean=new double[nROI];
|
||||
mean2=new double[nROI];
|
||||
nCm=new double[nROI];
|
||||
};
|
||||
|
||||
/** destructor - deletes the moving average(s) and the sum of pedestals calculator(s) */
|
||||
virtual ~commonModeSubtraction() {delete [] mean; delete [] mean2; delete [] nCm;};
|
||||
|
||||
|
||||
/** clears the moving average and the sum of pedestals calculation - virtual func*/
|
||||
virtual void Clear(){
|
||||
for (int i=0; i<nROI; i++) {
|
||||
mean[i]=0;
|
||||
nCm[i]=0;
|
||||
mean2[i]=0;
|
||||
}};
|
||||
|
||||
/** adds the average of pedestals to the moving average and reinitializes the calculation of the sum of pedestals for all ROIs. - virtual func*/
|
||||
virtual void newFrame(){
|
||||
for (int i=0; i<nROI; i++) {
|
||||
// if (nCm[i]>0) cmStat[i].Calc(cmPed[i]/nCm[i]);
|
||||
nCm[i]=0;
|
||||
mean[i]=0;
|
||||
mean2[i]=0;
|
||||
}};
|
||||
|
||||
/** adds the pixel to the sum of pedestals -- virtual func must be overloaded to define the regions of interest
|
||||
\param val value to add
|
||||
\param ix pixel x coordinate
|
||||
\param iy pixel y coordinate
|
||||
*/
|
||||
virtual void addToCommonMode(double val, int ix=0, int iy=0) {
|
||||
|
||||
int iroi=getROI(ix,iy);
|
||||
// if (iroi==0) val=100;
|
||||
// else val=-100;
|
||||
// if (isc>=0 && isc<nROI) {
|
||||
if (iroi>=0 && iroi<nROI) {
|
||||
mean[iroi]+=val;
|
||||
mean2[iroi]+=val*val;
|
||||
nCm[iroi]++;
|
||||
}
|
||||
};
|
||||
|
||||
/** gets the common mode i.e. the difference between the current average sum of pedestals mode and the average pedestal
|
||||
\param ix pixel x coordinate
|
||||
\param iy pixel y coordinate
|
||||
\return the difference between the current average sum of pedestals and the average pedestal
|
||||
*/
|
||||
virtual double getCommonMode(int ix=0, int iy=0) {
|
||||
int iroi=getROI(ix,iy);
|
||||
/* if (iroi==0) */
|
||||
/* return 100; */
|
||||
/* else */
|
||||
/* return -100; */
|
||||
|
||||
if (iroi>=0 && iroi<nROI) {
|
||||
if (nCm[iroi]>0)
|
||||
return mean[iroi]/nCm[iroi];
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
/** gets the common mode i.e. the difference between the current average sum of pedestals mode and the average pedestal
|
||||
\param ix pixel x coordinate
|
||||
\param iy pixel y coordinate
|
||||
\return the difference between the current average sum of pedestals and the average pedestal
|
||||
*/
|
||||
virtual double getCommonModeRMS(int ix=0, int iy=0) {
|
||||
int iroi=getROI(ix,iy);
|
||||
if (iroi>=0 && iroi<nROI) {
|
||||
if (nCm[iroi]>0)
|
||||
return sqrt(mean2[iroi]/nCm[iroi]-(mean[iroi]/nCm[iroi])*(mean[iroi]/nCm[iroi]));
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
gets the common mode ROI for pixel ix, iy -should be overloaded!
|
||||
*/
|
||||
virtual int getROI(int ix, int iy){ (void) ix; (void) iy; return 0;};
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
double *mean; /**<array of moving average of the pedestal average per region of interest */
|
||||
double *mean2; /**< array storing the sum of pedestals per region of interest */
|
||||
double *nCm; /**< array storing the number of pixels currently contributing to the pedestals */
|
||||
int nsigma; /** number of rms above which the pedestal should be considered as a photon */
|
||||
const int nROI; /**< constant parameter for number of regions on which the common mode should be calculated separately e.g. supercolumns */
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -43,7 +43,7 @@ class mythen3_01_jctbData : public slsDetectorData<short unsigned int> {
|
||||
}
|
||||
|
||||
|
||||
static 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;
|
||||
@ -74,7 +74,7 @@ class mythen3_01_jctbData : public slsDetectorData<short unsigned int> {
|
||||
for (ib=0; ib<nb; ib++) {
|
||||
if (word&(1<<bit[ib])) {
|
||||
cout << "+" ;
|
||||
val[iw+nch*(ib/nb)]|=(1<<idr);
|
||||
val[iw+nch/nb*(ib)]|=(1<<idr);
|
||||
} else {
|
||||
cout << "-" ;
|
||||
}
|
||||
@ -96,8 +96,8 @@ class mythen3_01_jctbData : public slsDetectorData<short unsigned int> {
|
||||
ii++;
|
||||
}//end for
|
||||
|
||||
cout << "Decoded "<<ii << " samples"<< endl;
|
||||
cout << "Should be "<< nch/nb*dr+off << " samples"<< endl;
|
||||
cout << "M3.01 Decoded "<<ii << " samples"<< endl;
|
||||
cout << "M3.01 Should be "<< nch/nb*dr+off << " samples"<< endl;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
130
slsDetectorCalibration/dataStructures/Mythen3_02_jctbData.h
Normal file
130
slsDetectorCalibration/dataStructures/Mythen3_02_jctbData.h
Normal file
@ -0,0 +1,130 @@
|
||||
#ifndef MYTHEN302JCTBDATA_H
|
||||
#define MYTHEN302JCTBDATA_H
|
||||
|
||||
|
||||
#include "Mythen3_01_jctbData.h"
|
||||
//class mythen3_02_jctbData : public slsDetectorData<short unsigned int> {
|
||||
class mythen3_02_jctbData : public mythen3_01_jctbData {
|
||||
|
||||
|
||||
public:
|
||||
mythen3_02_jctbData( int nch=64*3,int dr=24, int off=5): mythen3_01_jctbData( nch,dr, off)
|
||||
//slsDetectorData<short unsigned int>(64*3,1,dr*8*nch,NULL,NULL,NULL), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch)
|
||||
{};
|
||||
|
||||
/* virtual void getPixel(int ip, int &x, int &y) {x=-1; y=-1;}; */
|
||||
|
||||
/* virtual short unsigned int getChannel(char *data, int ix, int iy=0) { */
|
||||
/* int ret=-1; */
|
||||
/* short unsigned int *val=mythen03_frame(data,dynamicRange,numberOfCounters,serialOffset); */
|
||||
/* if (ix>=0 && ix<numberOfCounters) ret=val[ix]; */
|
||||
/* delete [] val; */
|
||||
/* return ret; */
|
||||
/* }; */
|
||||
|
||||
/* virtual int getFrameNumber(char *buff) {return frameNumber;}; */
|
||||
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize) { */
|
||||
/* ndata=dsize; */
|
||||
/* return data; */
|
||||
/* } */
|
||||
|
||||
/* virtual char *readNextFrame(ifstream &filebin) { */
|
||||
/* char *data=NULL; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* data=new char[dataSize]; */
|
||||
/* filebin.read(data,dataSize); */
|
||||
/* } */
|
||||
/* return data; */
|
||||
/* } */
|
||||
|
||||
/* virtual short unsigned int **getData(char *ptr, int dsize=-1) { */
|
||||
/* short unsigned int **val; */
|
||||
/* val=new short unsigned int*[1]; */
|
||||
/* val[0]=mythen03_frame(ptr,dynamicRange,nx,serialOffset); */
|
||||
/* return val; */
|
||||
|
||||
/* } */
|
||||
|
||||
|
||||
virtual short unsigned int* mythen03_frame(char *ptr, int dr=24, int nch=64*3, int off=5) {
|
||||
// off=0;
|
||||
int iarg;
|
||||
int64_t word, *wp;
|
||||
short unsigned int* val=new short unsigned int[nch];
|
||||
int bit[64];
|
||||
int nb=2;
|
||||
int ioff=0;
|
||||
int idr=0;
|
||||
int ib=0;
|
||||
int ich=0;
|
||||
int ii=0;
|
||||
int iw=0;
|
||||
bit[0]=17;//19;
|
||||
bit[1]=6;//8;
|
||||
idr=0;
|
||||
for (ib=0; ib<nch; ib++) {
|
||||
val[ib]=0;
|
||||
}
|
||||
wp=(int64_t*)ptr;
|
||||
|
||||
for (iw=0; iw<nch/nb; iw) {
|
||||
word=*wp;
|
||||
|
||||
if (ioff<off) {
|
||||
ioff++;
|
||||
cout <<"*";
|
||||
} else {
|
||||
|
||||
if (idr<16) {
|
||||
for (ib=0; ib<nb; ib++) {
|
||||
if (word&(1<<bit[ib])) {
|
||||
cout << "+" ;
|
||||
val[iw+nch/nb*(ib)]|=(1<<idr);
|
||||
} else {
|
||||
cout << "-" ;
|
||||
}
|
||||
// cout << iw+nch/nb*(ib)<< " " ;
|
||||
}//end for()
|
||||
}
|
||||
|
||||
idr++;
|
||||
|
||||
|
||||
if (idr==dr) {
|
||||
idr=0;
|
||||
// cout << dec << " " << iw << " " << val[iw] << " " << val[iw+nch/2] << endl;
|
||||
cout <<dec << iw<<endl;
|
||||
iw++;
|
||||
}//end if()
|
||||
|
||||
}//end else()
|
||||
wp+=1;
|
||||
ii++;
|
||||
}//end for
|
||||
|
||||
cout << "M3.02 Decoded "<<ii << " samples"<< endl;
|
||||
cout << "M3.02 Should be "<< nch/nb*dr+off << " samples"<< endl;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/* virtual 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
|
@ -8,6 +8,23 @@ class jungfrau10ModuleData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
typedef struct {
|
||||
uint64_t frameNumber; /**< is the frame number */
|
||||
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
|
||||
uint32_t packetNumber; /**< is the packet number */
|
||||
uint64_t bunchId; /**< is the bunch id from beamline */
|
||||
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||
uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
|
||||
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||
uint32_t debug; /**< is for debugging purposes */
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
} sls_detector_header;
|
||||
|
||||
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
@ -25,7 +42,7 @@ class jungfrau10ModuleData : public slsDetectorData<uint16_t> {
|
||||
*/
|
||||
|
||||
|
||||
jungfrau10ModuleData(int ns=16384): slsDetectorData<uint16_t>(256*4, 256*2, 256*256*8*2, NULL, NULL, NULL) , iframe(0), nadc(32), sc_width(64), sc_height(256) {
|
||||
jungfrau10ModuleData(int ns=16384): slsDetectorData<uint16_t>(256*4, 256*2, 256*256*8*2+48, NULL, NULL, NULL) , iframe(0) {
|
||||
|
||||
|
||||
|
||||
@ -38,45 +55,53 @@ class jungfrau10ModuleData : public slsDetectorData<uint16_t> {
|
||||
int ichip;
|
||||
|
||||
// cout << sizeof(uint16_t) << endl;
|
||||
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
ichip=iadc/4;
|
||||
|
||||
for (int i=0; i<sc_width*sc_height; i++) {
|
||||
|
||||
if (ichip%2==0) {
|
||||
row=sc_height+i/sc_width;
|
||||
col=(ichip/2)*256+iadc%4*sc_width+(i%sc_width);
|
||||
} else {
|
||||
row=sc_height-1-i/sc_width;
|
||||
col=((ichip/2)*256+iadc%4*sc_width)+sc_width-(i%sc_width)-1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* if (iadc<nadc/2) { */
|
||||
/* row=sc_height+i/sc_width; */
|
||||
/* col=iadc*sc_width+(i%sc_width); */
|
||||
/* } else { */
|
||||
/* row=sc_height-1-i/sc_width; */
|
||||
/* col=(nx-1)-((iadc-16)*sc_width)-(i%sc_width); */
|
||||
/* } */
|
||||
if (row<0 || row>=ny || col<0 || col>=nx) {
|
||||
cout << "Wrong row, column " << row << " " << col << " " << iadc << " " << i << endl;
|
||||
} else
|
||||
dataMap[row][col]=(nadc*i+iadc)*2;
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=dataSize)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range " << row << " " << col <<" " << iadc << " " << i << endl;
|
||||
else {
|
||||
xmap[nadc*i+iadc]=col;
|
||||
ymap[nadc*i+iadc]=row;
|
||||
|
||||
}
|
||||
int ip=0;
|
||||
for (int iy=0; iy<256*2; iy++) {
|
||||
for (int ix=0; ix<256*4; ix++){
|
||||
dataMap[iy][ix]=ip*2+48;
|
||||
ip++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* for (iadc=0; iadc<nadc; iadc++) { */
|
||||
/* ichip=iadc/4; */
|
||||
|
||||
/* for (int i=0; i<sc_width*sc_height; i++) { */
|
||||
|
||||
/* if (ichip%2==0) { */
|
||||
/* row=sc_height+i/sc_width; */
|
||||
/* col=(ichip/2)*256+iadc%4*sc_width+(i%sc_width); */
|
||||
/* } else { */
|
||||
/* row=sc_height-1-i/sc_width; */
|
||||
/* col=((ichip/2)*256+iadc%4*sc_width)+sc_width-(i%sc_width)-1; */
|
||||
/* } */
|
||||
|
||||
|
||||
|
||||
/* /\* if (iadc<nadc/2) { *\/ */
|
||||
/* /\* row=sc_height+i/sc_width; *\/ */
|
||||
/* /\* col=iadc*sc_width+(i%sc_width); *\/ */
|
||||
/* /\* } else { *\/ */
|
||||
/* /\* row=sc_height-1-i/sc_width; *\/ */
|
||||
/* /\* col=(nx-1)-((iadc-16)*sc_width)-(i%sc_width); *\/ */
|
||||
/* /\* } *\/ */
|
||||
/* if (row<0 || row>=ny || col<0 || col>=nx) { */
|
||||
/* cout << "Wrong row, column " << row << " " << col << " " << iadc << " " << i << endl; */
|
||||
/* } else */
|
||||
/* dataMap[row][col]=(nadc*i+iadc)*2; */
|
||||
/* if (dataMap[row][col]<0 || dataMap[row][col]>=dataSize) */
|
||||
/* cout << "Error: pointer " << dataMap[row][col] << " out of range " << row << " " << col <<" " << iadc << " " << i << endl; */
|
||||
/* else { */
|
||||
/* xmap[nadc*i+iadc]=col; */
|
||||
/* ymap[nadc*i+iadc]=row; */
|
||||
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -91,7 +116,7 @@ class jungfrau10ModuleData : public slsDetectorData<uint16_t> {
|
||||
*/
|
||||
|
||||
|
||||
int getFrameNumber(char *buff){(void)buff; return iframe;};
|
||||
int getFrameNumber(return (sls_detector_header*)buff)->frameNumber;};
|
||||
|
||||
/**
|
||||
|
||||
@ -123,28 +148,65 @@ class jungfrau10ModuleData : public slsDetectorData<uint16_t> {
|
||||
\returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete
|
||||
|
||||
*/
|
||||
char *readNextFrame(ifstream &filebin){
|
||||
// int afifo_length=0;
|
||||
uint16_t *afifo_cont;
|
||||
int ib=0;
|
||||
if (filebin.is_open()) {
|
||||
afifo_cont=new uint16_t[dataSize/2];
|
||||
while (filebin.read(((char*)afifo_cont)+ib,2)) {
|
||||
ib+=2;
|
||||
if (ib==dataSize) break;
|
||||
}
|
||||
if (ib>0) {
|
||||
iframe++;
|
||||
// cout << ib << "-" << endl;
|
||||
return (char*)afifo_cont;
|
||||
} else {
|
||||
delete [] afifo_cont;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
// char *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; */
|
||||
/* }; */
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
||||
|
@ -31,23 +31,28 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
|
||||
*/
|
||||
|
||||
|
||||
moench02CtbData(int ns=6400): slsDetectorData<uint16_t>(160, 160, ns*2*32, NULL, NULL) , nadc(4), 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_nr[4]={120,0,80,40};
|
||||
int adc_off[4]={40,0,120,80};
|
||||
int adc_nr[4]={8,10,20,22};
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int iadc, iiadc;
|
||||
int ix, iy;
|
||||
maplength=this->getDataSize()/2;
|
||||
//cout << maplength << endl;
|
||||
|
||||
for (iiadc=0; iiadc<4; iiadc++) {
|
||||
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
iadc=adc_nr[iiadc];
|
||||
//cout << iiadc << endl;
|
||||
for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=adc_nr[iadc]+(i%sc_width);
|
||||
|
||||
col=adc_off[iiadc]+(i%sc_width);
|
||||
row=i/sc_width;
|
||||
dataMap[row][col]=(32*i+iadc+2)*2;
|
||||
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;
|
||||
}
|
||||
@ -56,12 +61,17 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
|
||||
}
|
||||
|
||||
for (int i=0; i<maplength; i++) {
|
||||
//cout << i << endl;
|
||||
isample=i/32;
|
||||
iadc=i%32;
|
||||
iiadc=i%32;
|
||||
iadc=-1;
|
||||
for (int iii=0; iii<4; iii++) {
|
||||
if (iiadc==adc_nr[iii]) iadc=iii;
|
||||
}
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
if(iadc>1 && iadc<6){
|
||||
xmap[i]=adc_nr[iadc-2]+ix;
|
||||
if(iadc>=0){
|
||||
xmap[i]=adc_off[iadc]+ix;
|
||||
ymap[i]=iy;
|
||||
}else{
|
||||
xmap[i]=-1;
|
||||
@ -76,10 +86,10 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
|
||||
if(ip>=0 && ip<maplength){
|
||||
x=xmap[ip];
|
||||
y=ymap[ip];
|
||||
}else{
|
||||
}/*else{
|
||||
cerr<<"WRONG ARRAY LENGTH"<<endl;
|
||||
cerr<<"Trying to access the "<<ip<<"-th element"<<endl;
|
||||
}
|
||||
}*/
|
||||
|
||||
};
|
||||
|
||||
@ -137,7 +147,9 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
|
||||
}
|
||||
if (ib>0) {
|
||||
iframe++;
|
||||
//cout << ib << "-" << endl;
|
||||
//cout << ib/2 << "-" << endl;
|
||||
//for (int i=0; i<ib/2; i++)
|
||||
//cout << i << " " << afifo_cont[i] << endl;
|
||||
return (char*)afifo_cont;
|
||||
} else {
|
||||
delete [] afifo_cont;
|
||||
|
187
slsDetectorCalibration/dataStructures/moench02CtbDataDGS.h
Normal file
187
slsDetectorCalibration/dataStructures/moench02CtbDataDGS.h
Normal file
@ -0,0 +1,187 @@
|
||||
#ifndef MOENCH02CTBDATADGS_H
|
||||
#define MOENCH02CTBDATADGS_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
|
||||
class moench02CtbData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
// int *xmap, *ymap;
|
||||
//int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
|
||||
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
|
||||
|
||||
*/
|
||||
|
||||
|
||||
moench02CtbDataDGS(int ns=6400): slsDetectorData<uint16_t>(160, 160, ns*(2*32+8), NULL, NULL) , sc_width(40), sc_height(160) {
|
||||
|
||||
|
||||
int adc_off[4]={40,0,120,80};
|
||||
int adc_nr[4]={8,10,20,23};
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc, iiadc;
|
||||
int ix, iy;
|
||||
maplength=this->getDataSize()/2;
|
||||
//cout << maplength << endl;
|
||||
|
||||
for (iiadc=0; iiadc<4; iiadc++) {
|
||||
|
||||
iadc=adc_nr[iiadc];
|
||||
//cout << iiadc << endl;
|
||||
for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=adc_off[iiadc]+(i%sc_width);
|
||||
row=i/sc_width;
|
||||
dataMap[row][col]=(32*i+iadc)*2;
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=dataSize) {
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<maplength; i++) {
|
||||
//cout << i << endl;
|
||||
isample=i/32;
|
||||
iiadc=i%32;
|
||||
iadc=-1;
|
||||
for (int iii=0; iii<4; iii++) {
|
||||
if (iiadc==adc_nr[iii]) iadc=iii;
|
||||
}
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
if(iadc>=0){
|
||||
xmap[i]=adc_off[iadc]+ix;
|
||||
ymap[i]=iy;
|
||||
}else{
|
||||
xmap[i]=-1;
|
||||
ymap[i]=-1;
|
||||
}
|
||||
}
|
||||
iframe=0;
|
||||
cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
void getPixel(int ip, int &x, int &y) {
|
||||
if(ip>=0 && ip<maplength){
|
||||
x=xmap[ip];
|
||||
y=ymap[ip];
|
||||
}/*else{
|
||||
cerr<<"WRONG ARRAY LENGTH"<<endl;
|
||||
cerr<<"Trying to access the "<<ip<<"-th element"<<endl;
|
||||
}*/
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the gain for the selected pixel (at the moemnt only 3rd supercolumn)
|
||||
\param buff pointer to the dataset
|
||||
\param ix x coordinate
|
||||
\param iy y coordinate
|
||||
\returns gain value
|
||||
*/
|
||||
|
||||
int getGain(char *buff, int ix, int iy) {
|
||||
int isample=iy*sc_width+iy;
|
||||
if (ix<sc_width) return 0; //first supercolumn no gain switching - could return the static gain if wished
|
||||
if (ix<2*sc_width) return 0; //second supercolumn no gain switching - could return the static gain if wished
|
||||
if (ix<3*sc_width){
|
||||
if(*((long*)(buff+(32*2*isample+8*(isample-1)))&(1>>31)) return 1;
|
||||
return 0;
|
||||
}
|
||||
return 0; //not yet implemented for 4th supercolumn
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
|
||||
virtual int getFrameNumber(char *buff){(void)buff; return iframe;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
virtual int getPacketNumber(char *buff)=0;
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
|
||||
\param filebin input file stream (binary)
|
||||
\returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete
|
||||
|
||||
*/
|
||||
virtual char *readNextFrame(ifstream &filebin){
|
||||
// int afifo_length=0;
|
||||
uint16_t *afifo_cont;
|
||||
int ib=0;
|
||||
if (filebin.is_open()) {
|
||||
afifo_cont=new uint16_t[dataSize/2];
|
||||
while (filebin.read(((char*)afifo_cont)+ib,2)) {
|
||||
ib+=2;
|
||||
if (ib==dataSize) break;
|
||||
}
|
||||
if (ib>0) {
|
||||
iframe++;
|
||||
//cout << ib/2 << "-" << endl;
|
||||
//for (int i=0; i<ib/2; i++)
|
||||
//cout << i << " " << afifo_cont[i] << endl;
|
||||
return (char*)afifo_cont;
|
||||
} else {
|
||||
delete [] afifo_cont;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -121,7 +121,8 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
||||
|
||||
|
||||
|
||||
int getFrameNumber(char *buff){return *((int*)(buff+5))&0xffffff;};
|
||||
// int getFrameNumber(char *buff){return *((int*)buff)&0xffffffff;};
|
||||
int getFrameNumber(char *buff){return *((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
@ -199,7 +200,7 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np=0;
|
||||
int pn;
|
||||
int pn, po=0;
|
||||
char aa[8224];
|
||||
char *packet=(char *)aa;
|
||||
// cout << packetSize*nPackets << endl;
|
||||
@ -217,15 +218,16 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
||||
if (fnum<0)
|
||||
fnum= getFrameNumber(packet);
|
||||
|
||||
// cout << "fn: " << fnum << "\t pn: " << pn << endl;
|
||||
// cout << "fn: " << fnum << "\t pn: " << pn << endl;
|
||||
if (fnum>=0) {
|
||||
if (getFrameNumber(packet) !=fnum) {
|
||||
if (getFrameNumber(packet) !=fnum || pn<po) {
|
||||
|
||||
if (np==0){
|
||||
// delete [] data;
|
||||
return NULL;
|
||||
} else
|
||||
filebin.seekg(-8208,ios_base::cur);
|
||||
po =pn;
|
||||
return data;
|
||||
}
|
||||
if (pn>nPackets) {
|
||||
@ -234,6 +236,7 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
||||
|
||||
memcpy(data+(pn-1)*packetSize, packet, packetSize);
|
||||
np++;
|
||||
po =pn;
|
||||
|
||||
if (np==nPackets)
|
||||
break;
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define MOENCH03T1RECDATANEW_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
//#define VERSION_V2
|
||||
/**
|
||||
@short structure for a Detector Packet or Image Header
|
||||
@li frameNumber is the frame number
|
||||
@ -32,6 +33,10 @@
|
||||
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;
|
||||
|
||||
|
||||
|
@ -0,0 +1,321 @@
|
||||
#ifndef MOENCH03T1RECDATANEWRECT_H
|
||||
#define MOENCH03T1RECDATANEWRECT_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
#define VERT 1
|
||||
|
||||
/**
|
||||
@short structure for a Detector Packet or Image Header
|
||||
@li frameNumber is the frame number
|
||||
@li expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
@li packetNumber is the packet number
|
||||
@li bunchId is the bunch id from beamline
|
||||
@li timestamp is the time stamp with 10 MHz clock
|
||||
@li modId is the unique module id (unique even for left, right, top, bottom)
|
||||
@li xCoord is the x coordinate in the complete detector system
|
||||
@li yCoord is the y coordinate in the complete detector system
|
||||
@li zCoord is the z coordinate in the complete detector system
|
||||
@li debug is for debugging purposes
|
||||
@li roundRNumber is the round robin set number
|
||||
@li detType is the detector type see :: detectorType
|
||||
@li version is the version number of this structure format
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t frameNumber; /**< is the frame number */
|
||||
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
|
||||
uint32_t packetNumber; /**< is the packet number */
|
||||
uint64_t bunchId; /**< is the bunch id from beamline */
|
||||
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||
uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
|
||||
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||
uint32_t debug; /**< is for debugging purposes */
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
} sls_detector_header;
|
||||
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
||||
*/
|
||||
#ifdef HOR
|
||||
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) {
|
||||
#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,\
|
||||
0,25,50,75,0,25,50,75};
|
||||
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
int npackets=40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
int pix;
|
||||
|
||||
|
||||
int off=0;
|
||||
#ifdef OFF_1
|
||||
off=1;
|
||||
#endif
|
||||
cout << "This is a MOENCH with rectangular pixels!" << endl;
|
||||
|
||||
for (int ip=0; ip<npackets; ip++) {
|
||||
for (int is=0; is<128; is++) {
|
||||
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
i=128*ip+is;
|
||||
adc4=(int)iadc/4;
|
||||
if (i<sc_width*sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=adc_nr[iadc]+(i%sc_width);
|
||||
if (adc4%2==0) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
pix=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
|
||||
if (pix<0 || pix>=nSamples*2*32+sizeof(sls_detector_header))
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
ix=col;
|
||||
iy=row;
|
||||
#ifdef HOR
|
||||
if (row%2==off) {
|
||||
ix=2*col;
|
||||
iy=row/2;
|
||||
} else {
|
||||
ix=2*col+1;
|
||||
iy=row/2;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VERT
|
||||
if (col%2==off) {
|
||||
ix=col/2;
|
||||
iy=row*2+1;
|
||||
} else {
|
||||
ix=col/2;
|
||||
iy=row*2;
|
||||
}
|
||||
#endif
|
||||
dataMap[iy][ix]=pix;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* int ipacket; */
|
||||
/* int ibyte; */
|
||||
/* int ii=0; */
|
||||
/* for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){ */
|
||||
/* xmap[ibyte]=-1; */
|
||||
/* ymap[ibyte]=-1; */
|
||||
/* } */
|
||||
/* int off=sizeof(sls_detector_header)/2; */
|
||||
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
|
||||
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
|
||||
/* i=ipacket*8208/2+ibyte; */
|
||||
/* isample=ii/nadc; */
|
||||
/* if (isample<nSamples) { */
|
||||
/* iadc=ii%nadc; */
|
||||
/* adc4 = (int)iadc/4; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (adc4%2==0) { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2+iy; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* ii++; */
|
||||
/* // } */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
|
||||
|
||||
int getFrameNumber(char *buff){return ((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
char *retval=0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np=0;
|
||||
int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
ff=getFrameNumber(data);
|
||||
np=getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<dataSize) ndata=dsize;
|
||||
else ndata=dataSize;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -3,16 +3,16 @@
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
|
||||
class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
// int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int nSamples;
|
||||
const int offset;
|
||||
|
||||
public:
|
||||
|
||||
@ -25,7 +25,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2), nSamples(ns) {
|
||||
moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)) {
|
||||
|
||||
int nadc=32;
|
||||
int sc_width=25;
|
||||
@ -60,50 +60,48 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
dataMap[row][col]=(nadc*i+iadc)*2;//+16*(ip+1);
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=nSamples*2*32)
|
||||
dataMap[row][col]=(nadc*i+iadc)*2+offset;//+16*(ip+1);
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=dataSize)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ipacket;
|
||||
int ibyte;
|
||||
int ii=0;
|
||||
for (int ipacket=0; ipacket<npackets; ipacket++) {
|
||||
for (int ibyte=0; ibyte< 8192/2; ibyte++) {
|
||||
i=ipacket*8208/2+ibyte;
|
||||
/* if (ibyte<8) { */
|
||||
/* //header! */
|
||||
/* xmap[i]=-1; */
|
||||
/* ymap[i]=-1; */
|
||||
/* } else { */
|
||||
// ii=ibyte+128*32*ipacket;
|
||||
isample=ii/nadc;
|
||||
if (isample<nSamples) {
|
||||
iadc=ii%nadc;
|
||||
adc4 = (int)iadc/4;
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
if (adc4%2==0) {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2-1-iy;
|
||||
} else {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2+iy;
|
||||
}
|
||||
}
|
||||
|
||||
ii++;
|
||||
// }
|
||||
int ii=0;
|
||||
|
||||
for (i=0; i< dataSize; i++) {
|
||||
if (i<offset) {
|
||||
//header! */
|
||||
xmap[i]=-1;
|
||||
ymap[i]=-1;
|
||||
} else {
|
||||
// ii=ibyte+128*32*ipacket;
|
||||
isample=ii/nadc;
|
||||
if (isample<nSamples) {
|
||||
iadc=ii%nadc;
|
||||
adc4 = (int)iadc/4;
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
if (adc4%2==0) {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2-1-iy;
|
||||
} else {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2+iy;
|
||||
}
|
||||
}
|
||||
|
||||
ii++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
iframe=0;
|
||||
// iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
@ -127,7 +125,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
||||
|
||||
|
||||
|
||||
int getFrameNumber(char *buff){return iframe;};//*((int*)(buff+5))&0xffffff;};
|
||||
int getFrameNumber(char *buff){return *((int*)buff);};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
@ -215,8 +213,8 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, 32*2*nSamples) ){
|
||||
iframe++;
|
||||
ff=iframe;
|
||||
// iframe++;
|
||||
//ff=iframe;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -249,6 +247,8 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
||||
|
||||
|
||||
|
||||
// virtual int setFrameNumber(int ff){iframe=ff};
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "slsInterpolation.h"
|
||||
|
||||
#define M015
|
||||
//#define M015
|
||||
|
||||
#ifdef MYROOT1
|
||||
#include <TTree.h>
|
||||
@ -17,10 +17,7 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
#define XMIN 350/2
|
||||
#define XMAX 600/2
|
||||
#define YMIN 0
|
||||
#define YMAX 400
|
||||
|
||||
|
||||
class interpolatingDetector : public singlePhotonDetector {
|
||||
|
||||
@ -50,21 +47,23 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
commonModeSubtraction *cm=NULL,
|
||||
int nped=1000,
|
||||
int nd=100, int nnx=-1, int nny=-1) :
|
||||
singlePhotonDetector(d, 3,nsigma,sign, cm, nped, nd, nnx, nny) , interp(inte), id(0), xmin(XMIN), xmax(XMAX), ymin(YMIN), ymax(YMAX) {
|
||||
cout << "**"<< xmin << " " << xmax << " " << ymin << " " << ymax << endl;
|
||||
singlePhotonDetector(d, 3,nsigma,sign, cm, nped, nd, nnx, nny) , interp(inte), id(0) {
|
||||
//cout << "**"<< xmin << " " << xmax << " " << ymin << " " << ymax << endl;
|
||||
fi=new pthread_mutex_t ;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
interpolatingDetector(interpolatingDetector *orig) : singlePhotonDetector(orig) {
|
||||
interp=(orig->interp)->Clone();
|
||||
id=orig->id;
|
||||
xmin=orig->xmin;
|
||||
xmax=orig->xmax;
|
||||
ymin=orig->ymin;
|
||||
ymax=orig->ymax;
|
||||
// if (orig->interp)
|
||||
// interp=(orig->interp)->Clone();
|
||||
// else
|
||||
|
||||
interp=orig->interp;
|
||||
|
||||
id=orig->id;
|
||||
fi=orig->fi;
|
||||
}
|
||||
|
||||
|
||||
@ -72,29 +71,50 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
return new interpolatingDetector(this);
|
||||
}
|
||||
|
||||
virtual int setId(int i) {id=i; interp->setId(id); return id;};
|
||||
virtual int setId(int i) {
|
||||
id=i;
|
||||
// interp->setId(id);
|
||||
return id;
|
||||
};
|
||||
|
||||
virtual void prepareInterpolation(int &ok) {
|
||||
cout << "*"<< endl;
|
||||
#ifdef SAVE_ALL
|
||||
char tit[1000];
|
||||
sprintf(tit,"/scratch/ped_%d.tiff",id);
|
||||
writePedestals(tit);
|
||||
sprintf(tit,"/scratch/ped_rms_%d.tiff",id);
|
||||
writePedestalRMS(tit);
|
||||
if (gmap) {
|
||||
sprintf(tit,"/scratch/gmap_%d.tiff",id);
|
||||
writeGainMap(tit);
|
||||
}
|
||||
#endif
|
||||
if (interp)
|
||||
/* cout << "*"<< endl; */
|
||||
/* #ifdef SAVE_ALL */
|
||||
/* char tit[1000]; */
|
||||
/* sprintf(tit,"/scratch/ped_%d.tiff",id); */
|
||||
/* writePedestals(tit); */
|
||||
/* sprintf(tit,"/scratch/ped_rms_%d.tiff",id); */
|
||||
/* writePedestalRMS(tit); */
|
||||
/* if (gmap) { */
|
||||
/* sprintf(tit,"/scratch/gmap_%d.tiff",id); */
|
||||
/* writeGainMap(tit); */
|
||||
/* } */
|
||||
/* #endif */
|
||||
if (interp){
|
||||
pthread_mutex_lock(fi);
|
||||
interp->prepareInterpolation(ok);
|
||||
pthread_mutex_unlock(fi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void clearImage() {if (interp) interp->clearInterpolatedImage(); else singlePhotonDetector::clearImage();};
|
||||
void clearImage() {
|
||||
if (interp) {
|
||||
pthread_mutex_lock(fi);
|
||||
interp->clearInterpolatedImage();
|
||||
pthread_mutex_unlock(fi);
|
||||
} else
|
||||
singlePhotonDetector::clearImage();
|
||||
};
|
||||
|
||||
int getImageSize(int &nnx, int &nny, int &ns) {
|
||||
if (interp)
|
||||
return interp->getImageSize(nnx, nny, ns);
|
||||
else
|
||||
return analogDetector<uint16_t>::getImageSize(nnx, nny, ns);
|
||||
};
|
||||
|
||||
|
||||
int getImageSize(int &nnx, int &nny, int &ns) {if (interp) return interp->getImageSize(nnx, nny, ns); else return analogDetector<uint16_t>::getImageSize(nnx, nny, ns);};
|
||||
#ifdef MYROOT1
|
||||
virtual TH2F *getImage()
|
||||
#endif
|
||||
@ -107,7 +127,6 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
return interp->getInterpolatedImage();
|
||||
else
|
||||
return analogDetector<uint16_t>::getImage();
|
||||
//cout << "null " << endl;
|
||||
}
|
||||
|
||||
#ifdef MYROOT1
|
||||
@ -149,505 +168,104 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int addFrame(char *data, int *ph=NULL, int ff=0) {
|
||||
|
||||
|
||||
singlePhotonDetector::processData(data,ph);
|
||||
int nph=0;
|
||||
double val[ny][nx];
|
||||
int cy=(clusterSizeY+1)/2;
|
||||
int cs=(clusterSize+1)/2;
|
||||
int ir, ic;
|
||||
|
||||
double int_x,int_y, eta_x, eta_y;
|
||||
double max=0, tl=0, tr=0, bl=0,br=0, *v, vv;
|
||||
|
||||
if (ph==NULL)
|
||||
ph=image;
|
||||
|
||||
if (iframe<nDark) {
|
||||
addToPedestal(data);
|
||||
return 0;
|
||||
}
|
||||
newFrame();
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
|
||||
max=0;
|
||||
tl=0;
|
||||
tr=0;
|
||||
bl=0;
|
||||
br=0;
|
||||
tot=0;
|
||||
quadTot=0;
|
||||
quad=UNDEFINED_QUADRANT;
|
||||
|
||||
|
||||
|
||||
eventMask[iy][ix]=PEDESTAL;
|
||||
|
||||
|
||||
(clusters+nph)->rms=getPedestalRMS(ix,iy);
|
||||
|
||||
|
||||
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
|
||||
if ((iy+ir)>=iy && (iy+ir)<ny && (ix+ic)>=ix && (ix+ic)<nx) {
|
||||
val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir);
|
||||
}
|
||||
|
||||
v=&(val[iy+ir][ix+ic]);
|
||||
tot+=*v;
|
||||
if (ir<=0 && ic<=0)
|
||||
bl+=*v;
|
||||
if (ir<=0 && ic>=0)
|
||||
br+=*v;
|
||||
if (ir>=0 && ic<=0)
|
||||
tl+=*v;
|
||||
if (ir>=0 && ic>=0)
|
||||
tr+=*v;
|
||||
if (*v>max) {
|
||||
max=*v;
|
||||
}
|
||||
|
||||
|
||||
if (ir==0 && ic==0) {
|
||||
if (*v<-nSigma*cluster->rms)
|
||||
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
|
||||
}
|
||||
|
||||
}
|
||||
double int_x, int_y;
|
||||
double eta_x, eta_y;
|
||||
if (interp) {
|
||||
// cout << "int" << endl;
|
||||
pthread_mutex_lock(fi);
|
||||
for (nph=0; nph<nphFrame; nph++) {
|
||||
if (ff) {
|
||||
interp->addToFlatField((clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),eta_x, eta_y);
|
||||
} else {
|
||||
interp->getInterpolatedPosition((clusters+nph)->x, (clusters+nph)->y, (clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),int_x, int_y);
|
||||
interp->addToImage(int_x, int_y);
|
||||
}
|
||||
|
||||
if (bl>=br && bl>=tl && bl>=tr) {
|
||||
(clusters+nph)->quad=BOTTOM_LEFT;
|
||||
(clusters+nph)->quadTot=bl;
|
||||
} else if (br>=bl && br>=tl && br>=tr) {
|
||||
(clusters+nph)->quad=BOTTOM_RIGHT;
|
||||
(clusters+nph)->quadTot=br;
|
||||
} else if (tl>=br && tl>=bl && tl>=tr) {
|
||||
(clusters+nph)->quad=TOP_LEFT;
|
||||
(clusters+nph)->quadTot=tl;
|
||||
} else if (tr>=bl && tr>=tl && tr>=br) {
|
||||
(clusters+nph)->quad=TOP_RIGHT;
|
||||
(clusters+nph)->quadTot=tr;
|
||||
}
|
||||
|
||||
if (max>nSigma*cluster->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*cluster->rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*cluster->rms) {
|
||||
if (val[iy][ix]>=max) {
|
||||
eventMask[iy][ix]=PHOTON_MAX;
|
||||
(clusters+nph)->tot=tot;
|
||||
(clusters+nph)->x=ix;
|
||||
(clusters+nph)->y=iy;
|
||||
(clusters+nph)->iframe=det->getFrameNumber(data);
|
||||
(clusters+nph)->ped=getPedestal(ix,iy,0);
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
(clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (interp) {
|
||||
if (ff) {
|
||||
interp->addToFlatField((clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),eta_x, eta_y);
|
||||
} else {
|
||||
interp->getInterpolatedPosition(ix, iy, (clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),int_x, int_y);
|
||||
interp->addToImage(int_x, int_y);
|
||||
}
|
||||
} else
|
||||
image[ix+nx*iy]++;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
nph++;
|
||||
image[iy*nx+ix]++;
|
||||
|
||||
} else {
|
||||
eventMask[iy][ix]=PHOTON;
|
||||
}
|
||||
} else if (eventMask[iy][ix]==PEDESTAL) {
|
||||
addToPedestal(data,ix,iy);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
pthread_mutex_unlock(fi);
|
||||
}
|
||||
nphFrame=nph;
|
||||
nphTot+=nph;
|
||||
//cout << nphFrame << endl;
|
||||
// cout <<"**********************************"<< endl;
|
||||
writeClusters();
|
||||
return nphFrame;
|
||||
|
||||
};
|
||||
|
||||
/*********************************************************
|
||||
int addFrame(char *data, int ff=0) {
|
||||
|
||||
double g=1;
|
||||
|
||||
single_photon_hit *cl;
|
||||
single_photon_hit clust;
|
||||
if (clusters)
|
||||
cl=clusters;
|
||||
else
|
||||
cl=&clust;
|
||||
|
||||
|
||||
int ccs=clusterSize;
|
||||
int ccy=clusterSizeY;
|
||||
|
||||
double int_x,int_y, eta_x, eta_y;
|
||||
int nph=0;
|
||||
double rest[ny][nx];
|
||||
int cy=(clusterSizeY+1)/2;
|
||||
int cs=(clusterSize+1)/2;
|
||||
int ir, ic;
|
||||
double cc[2][2];
|
||||
double max=0, tl=0, tr=0, bl=0,br=0, v, vv;
|
||||
int xoff,yoff;
|
||||
int skip=0;
|
||||
// cout <<"fr"<< endl;
|
||||
double tthr;
|
||||
if (iframe<nDark) {
|
||||
//cout << iframe << "+"<< nDark <<endl;
|
||||
addToPedestal(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
newFrame();
|
||||
|
||||
|
||||
|
||||
|
||||
// cout << xmin << " " << xmax << " " << ymin << " " << ymax << endl;
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
// for (int ix=clusterSize/2; ix<clusterSize/2-1; ix++) {
|
||||
// for (int iy=clusterSizeY/2; iy<ny-clusterSizeY/2; iy++) {
|
||||
|
||||
// cout << ix << " " << iy << endl;
|
||||
eventMask[iy][ix]=PEDESTAL;
|
||||
|
||||
|
||||
tthr=nSigma*getPedestalRMS(ix,iy)/g;
|
||||
if (ix==xmin || iy==ymin)
|
||||
rest[iy][ix]=subtractPedestal(data,ix,iy);
|
||||
|
||||
|
||||
max=0;
|
||||
tl=0;
|
||||
tr=0;
|
||||
bl=0;
|
||||
br=0;
|
||||
tot=0;
|
||||
quadTot=0;
|
||||
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
if ((iy+ir)>=ymin && (iy+ir)<ymax && (ix+ic)>=xmin && (ix+ic)<xmax) {
|
||||
//cluster->set_data(rest[iy+ir][ix+ic], ic, ir);
|
||||
|
||||
if (ir>=0 && ic>=0 )
|
||||
rest[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir);
|
||||
|
||||
v=rest[iy+ir][ix+ic];//cluster->get_data(ic,ir);
|
||||
tot+=v;
|
||||
|
||||
if (ir<=0 && ic<=0)
|
||||
bl+=v;
|
||||
if (ir<=0 && ic>=0)
|
||||
br+=v;
|
||||
if (ir>=0 && ic<=0)
|
||||
tl+=v;
|
||||
if (ir>=0 && ic>=0)
|
||||
tr+=v;
|
||||
|
||||
if (v>max) {
|
||||
max=v;
|
||||
}
|
||||
// if (ir==0 && ic==0) {
|
||||
if (v>tthr) {
|
||||
eventMask[iy][ix]=NEIGHBOUR;
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rest[iy][ix]<=-tthr) {
|
||||
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
|
||||
//if (cluster->get_data(0,0)>=max) {
|
||||
} else if (max>tthr || tot>sqrt(ccy*ccs)*tthr || quadTot>sqrt(cy*cs)*tthr) {
|
||||
if (rest[iy][ix]>=max) {
|
||||
if (bl>=br && bl>=tl && bl>=tr) {
|
||||
cl->quad=BOTTOM_LEFT;
|
||||
cl->quadTot=bl;
|
||||
} else if (br>=bl && br>=tl && br>=tr) {
|
||||
cl->quad=BOTTOM_RIGHT;
|
||||
cl->quadTot=br;
|
||||
} else if (tl>=br && tl>=bl && tl>=tr) {
|
||||
cl->quad=TOP_LEFT;
|
||||
cl->quadTot=tl;
|
||||
} else if (tr>=bl && tr>=tl && tr>=br) {
|
||||
cl->quad=TOP_RIGHT;
|
||||
cl->quadTot=tr;
|
||||
}
|
||||
|
||||
|
||||
eventMask[iy][ix]=PHOTON_MAX;
|
||||
cl->tot=tot;
|
||||
cl->x=ix;
|
||||
cl->y=iy;
|
||||
cl->ped=getPedestal(ix,iy, 0);
|
||||
cl->rms=getPedestalRMS(ix,iy);
|
||||
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
if ((iy+ir)>=ymin && (iy+ir)<ymax && (ix+ic)>=xmin && (ix+ic)<xmax) {
|
||||
cl->set_data(rest[iy+ir][ix+ic],ic,ir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (interp) {
|
||||
if (ff) {
|
||||
#ifdef M015
|
||||
if (iy>100)
|
||||
#endif
|
||||
interp->addToFlatField(cl->quadTot,cl->quad,cl->get_cluster(),eta_x, eta_y);
|
||||
// if ((eta_x<0.1 || eta_x>0.9)&&(eta_y<0.1 || eta_y>0.9))
|
||||
// cout << ix << " " << iy << " " << eta_x <<" " << eta_y << endl;
|
||||
|
||||
} else {
|
||||
interp->getInterpolatedPosition(ix, iy, cl->quadTot,cl->quad,cl->get_cluster(),int_x, int_y);
|
||||
interp->addToImage(int_x, int_y);
|
||||
}
|
||||
|
||||
} else
|
||||
image[ix+nx*iy]++;
|
||||
|
||||
nph++;
|
||||
|
||||
if (clusters) cl=(clusters+nph);
|
||||
|
||||
|
||||
// rest[iy][ix]-=tthr;
|
||||
} else
|
||||
eventMask[iy][ix]=PHOTON;
|
||||
//else if (thr<=0 ) {
|
||||
//addToPedestal(data,ix,iy);
|
||||
// }
|
||||
}
|
||||
if (eventMask[iy][ix]==PEDESTAL) {
|
||||
addToPedestal(data,ix,iy);
|
||||
}
|
||||
}
|
||||
}
|
||||
return nph;
|
||||
}
|
||||
|
||||
******************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* for (int ix=0; ix<nx; ix++) { */
|
||||
/* for (int iy=0; iy<ny; iy++) { */
|
||||
/* skip=0; */
|
||||
/* max=0; */
|
||||
/* tl=0; */
|
||||
/* tr=0; */
|
||||
/* bl=0; */
|
||||
/* br=0; */
|
||||
/* tot=0; */
|
||||
/* quadTot=0; */
|
||||
/* quad=UNDEFINED_QUADRANT; */
|
||||
|
||||
|
||||
|
||||
|
||||
/* cl->rms=getPedestalRMS(ix,iy); */
|
||||
/* //(clusters+nph)->rms=getPedestalRMS(ix,iy); */
|
||||
|
||||
/* // cout << iframe << " " << nph << " " << ix << " " << iy << endl; */
|
||||
/* if (ix==0 || iy==0) */
|
||||
/* val[iy][ix]=subtractPedestal(data,ix,iy); */
|
||||
|
||||
/* if (val[iy][ix]<-nSigma*cl->rms) { */
|
||||
/* eventMask[iy][ix]=NEGATIVE_PEDESTAL; */
|
||||
/* // cout << "neg ped" << endl; */
|
||||
/* } else { */
|
||||
/* for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { */
|
||||
/* for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { */
|
||||
|
||||
|
||||
/* if ((iy+ir)>=0 && (iy+ir)<ny && (ix+ic)>=0 && (ix+ic)<nx) { */
|
||||
|
||||
/* if (ir>=0 && ic>=0) { */
|
||||
/* val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir); */
|
||||
/* eventMask[iy+ir][ix+ic]=PEDESTAL; */
|
||||
/* } */
|
||||
|
||||
/* // cout << ir << " " << ic << " " << val[iy+ir][ix+ic] << endl; */
|
||||
/* v=&(val[iy+ir][ix+ic]); */
|
||||
/* // if (skip==0) { */
|
||||
/* tot+=*v; */
|
||||
/* if (ir<=0 && ic<=0) */
|
||||
/* bl+=*v; */
|
||||
/* if (ir<=0 && ic>=0) */
|
||||
/* br+=*v; */
|
||||
/* if (ir>=0 && ic<=0) */
|
||||
/* tl+=*v; */
|
||||
/* if (ir>=0 && ic>=0) */
|
||||
/* tr+=*v; */
|
||||
/* if (*v>max) { */
|
||||
/* max=*v; */
|
||||
/* } */
|
||||
|
||||
/* } */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* if (bl>=br && bl>=tl && bl>=tr) { */
|
||||
/* cl->quad=BOTTOM_LEFT; */
|
||||
/* cl->quadTot=bl; */
|
||||
/* } else if (br>=bl && br>=tl && br>=tr) { */
|
||||
/* cl->quad=BOTTOM_RIGHT; */
|
||||
/* cl->quadTot=br; */
|
||||
/* } else if (tl>=br && tl>=bl && tl>=tr) { */
|
||||
/* cl->quad=TOP_LEFT; */
|
||||
/* cl->quadTot=tl; */
|
||||
/* } else if (tr>=bl && tr>=tl && tr>=br) { */
|
||||
/* cl->quad=TOP_RIGHT; */
|
||||
/* cl->quadTot=tr; */
|
||||
/* } */
|
||||
|
||||
/* if (max>nSigma*cl->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*cl->rms || (cl->quadTot)>sqrt(cy*cs)*nSigma*cl->rms) { */
|
||||
/* if (val[iy][ix]>=max) { */
|
||||
/* eventMask[iy][ix]=PHOTON_MAX; */
|
||||
/* cl->tot=tot; */
|
||||
/* cl->x=ix; */
|
||||
/* cl->y=iy; */
|
||||
/* cl->ped=getPedestal(ix,iy, 0); */
|
||||
|
||||
/* if (interp) { */
|
||||
/* if (ff) { */
|
||||
/* interp->addToFlatField(cl->quadTot,cl->quad,cl->get_cluster(),eta_x, eta_y); */
|
||||
/* // if ((eta_x<0.1 || eta_x>0.9)&&(eta_y<0.1 || eta_y>0.9)) */
|
||||
/* // cout << ix << " " << iy << " " << eta_x <<" " << eta_y << endl; */
|
||||
/* } else { */
|
||||
/* interp->getInterpolatedPosition(ix, iy, cl->quadTot,cl->quad,cl->get_cluster(),int_x, int_y); */
|
||||
/* interp->addToImage(int_x, int_y); */
|
||||
/* } */
|
||||
/* } else */
|
||||
/* image[ix+nx*iy]++; */
|
||||
|
||||
/* if (clusters) cl=(clusters+nph); */
|
||||
|
||||
/* nph++; */
|
||||
|
||||
/* } else { */
|
||||
/* eventMask[iy][ix]=PHOTON; */
|
||||
/* } */
|
||||
/* } else if (eventMask[iy][ix]==PEDESTAL) { */
|
||||
/* addToPedestal(data,ix,iy); */
|
||||
/* } */
|
||||
|
||||
/* } */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return nph; */
|
||||
|
||||
/* }; */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
virtual void processData(char *data, int *val=NULL) {
|
||||
if (interp){
|
||||
switch(fMode) {
|
||||
case ePedestal:
|
||||
addToPedestal(data);
|
||||
switch (dMode) {
|
||||
case eAnalog:
|
||||
// cout << "an" << endl;
|
||||
analogDetector<uint16_t>::processData(data,val);
|
||||
break;
|
||||
case eFlat:
|
||||
addFrame(data,val,1);
|
||||
case ePhotonCounting:
|
||||
// cout << "spc" << endl;
|
||||
singlePhotonDetector::processData(data,val);
|
||||
break;
|
||||
default:
|
||||
addFrame(data,val,0);
|
||||
//cout << "int" << endl;
|
||||
switch(fMode) {
|
||||
case ePedestal:
|
||||
addToPedestal(data);
|
||||
break;
|
||||
case eFlat:
|
||||
if (interp)
|
||||
addFrame(data,val,1);
|
||||
else
|
||||
singlePhotonDetector::processData(data,val);
|
||||
break;
|
||||
default:
|
||||
if (interp)
|
||||
addFrame(data,val,0);
|
||||
else
|
||||
singlePhotonDetector::processData(data,val);
|
||||
}
|
||||
}
|
||||
} else
|
||||
singlePhotonDetector::processData(data,val);
|
||||
|
||||
|
||||
};
|
||||
|
||||
virtual char *getInterpolation(){return (char*)interp;};
|
||||
|
||||
|
||||
virtual slsInterpolation *getInterpolation(){
|
||||
return interp;
|
||||
};
|
||||
|
||||
virtual slsInterpolation *setInterpolation(slsInterpolation *ii){
|
||||
int ok;
|
||||
interp=ii;
|
||||
/* pthread_mutex_lock(fi);
|
||||
if (interp)
|
||||
interp->prepareInterpolation(ok);
|
||||
pthread_mutex_unlock(fi); */
|
||||
// cout << "det" << endl;
|
||||
return interp;
|
||||
};
|
||||
|
||||
virtual void resetFlatField() { if (interp) {
|
||||
pthread_mutex_lock(fi);
|
||||
interp->resetFlatField();
|
||||
pthread_mutex_unlock(fi);
|
||||
}
|
||||
}
|
||||
|
||||
virtual int getNSubPixels(){ if (interp) return interp->getNSubPixels(); else return 1;}
|
||||
virtual int setNSubPixels(int ns) {
|
||||
if (interp) {
|
||||
pthread_mutex_lock(fi);
|
||||
interp->getNSubPixels();
|
||||
pthread_mutex_unlock(fi);
|
||||
}
|
||||
return getNSubPixels();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
slsInterpolation *interp;
|
||||
int id;
|
||||
//should put it to analogDetector
|
||||
int xmin, xmax, ymin, ymax;
|
||||
pthread_mutex_t *fi;
|
||||
};
|
||||
|
||||
|
||||
|
@ -14,49 +14,18 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
|
||||
public:
|
||||
eta2InterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nb, emin, emax) {
|
||||
// cout << "e2ib " << nb << " " << emin << " " << emax << endl;
|
||||
|
||||
if (nbeta<=0) {
|
||||
nbeta=nSubPixels*10;
|
||||
}
|
||||
if (etamin>=etamax) {
|
||||
etamin=-1;
|
||||
etamax=2;
|
||||
cout << ":" <<endl;
|
||||
}
|
||||
etastep=(etamax-etamin)/nbeta;
|
||||
#ifdef MYROOT1
|
||||
delete heta;
|
||||
delete hhx;
|
||||
delete hhy;
|
||||
heta=new TH2D("heta","heta",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||
hhx=new TH2D("hhx","hhx",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||
hhy=new TH2D("hhy","hhy",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
delete [] heta;
|
||||
delete [] hhx;
|
||||
delete [] hhy;
|
||||
heta=new int[nbeta*nbeta];
|
||||
hhx=new float[nbeta*nbeta];
|
||||
hhy=new float[nbeta*nbeta];
|
||||
/* if (etamin>=etamax) { */
|
||||
/* etamin=-1; */
|
||||
/* etamax=2; */
|
||||
/* // cout << ":" <<endl; */
|
||||
/* } */
|
||||
/* etastep=(etamax-etamin)/nbeta; */
|
||||
|
||||
#endif
|
||||
|
||||
// cout << nbeta << " " << etamin << " " << etamax << endl;
|
||||
};
|
||||
|
||||
eta2InterpolationBase(eta2InterpolationBase *orig): etaInterpolationBase(orig){ };
|
||||
|
||||
virtual eta2InterpolationBase* Clone()=0;/* {
|
||||
|
||||
return new eta2InterpolationBase(this);
|
||||
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////// /*It return position hit for the event in input */ //////////////
|
||||
@ -102,12 +71,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) {
|
||||
|
||||
double cc[2][2];
|
||||
double *cluster[3];
|
||||
int xoff, yoff;
|
||||
cluster[0]=cl;
|
||||
cluster[1]=cl+3;
|
||||
cluster[2]=cl+6;
|
||||
|
||||
switch (quad) {
|
||||
case BOTTOM_LEFT:
|
||||
xoff=0;
|
||||
@ -130,10 +94,10 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
}
|
||||
double etax, etay;
|
||||
if (nSubPixels>2) {
|
||||
cc[0][0]=cluster[yoff][xoff];
|
||||
cc[1][0]=cluster[yoff+1][xoff];
|
||||
cc[0][1]=cluster[yoff][xoff+1];
|
||||
cc[1][1]=cluster[yoff+1][xoff+1];
|
||||
cc[0][0]=cl[xoff+3*yoff];
|
||||
cc[1][0]=cl[xoff+3*(yoff+1)];
|
||||
cc[0][1]=cl[xoff+1+3*yoff];
|
||||
cc[1][1]=cl[xoff+1+3*(yoff+1)];
|
||||
calcEta(totquad,cc,etax,etay);
|
||||
}
|
||||
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
|
||||
@ -145,11 +109,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) {
|
||||
|
||||
double cc[2][2];
|
||||
int *cluster[3];
|
||||
int xoff, yoff;
|
||||
cluster[0]=cl;
|
||||
cluster[1]=cl+3;
|
||||
cluster[2]=cl+6;
|
||||
|
||||
switch (quad) {
|
||||
case BOTTOM_LEFT:
|
||||
@ -173,10 +133,10 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
}
|
||||
double etax, etay;
|
||||
if (nSubPixels>2) {
|
||||
cc[0][0]=cluster[yoff][xoff];
|
||||
cc[1][0]=cluster[yoff+1][xoff];
|
||||
cc[0][1]=cluster[yoff][xoff+1];
|
||||
cc[1][1]=cluster[yoff+1][xoff+1];
|
||||
cc[0][0]=cl[xoff+3*yoff];
|
||||
cc[1][0]=cl[xoff+3*(yoff+1)];
|
||||
cc[0][1]=cl[xoff+1+3*yoff];
|
||||
cc[1][1]=cl[xoff+1+3*(xoff+1)];
|
||||
calcEta(totquad,cc,etax,etay);
|
||||
}
|
||||
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
|
||||
@ -223,60 +183,46 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
|
||||
if (nSubPixels>2) {
|
||||
|
||||
#ifdef MYROOT1
|
||||
xpos_eta=(hhx->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels);
|
||||
ypos_eta=(hhy->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
ex=(etax-etamin)/etastep;
|
||||
ey=(etay-etamin)/etastep;
|
||||
if (ex<0) {
|
||||
cout << "x*"<< ex << endl;
|
||||
ex=0;
|
||||
}
|
||||
if (ex>=nbeta) {
|
||||
cout << "x?"<< ex << endl;
|
||||
ex=nbeta-1;
|
||||
|
||||
}
|
||||
if (ey<0) {
|
||||
cout << "y*"<< ey << endl;
|
||||
ey=0;
|
||||
}
|
||||
if (ey>=nbeta) {
|
||||
cout << "y?"<< ey << endl;
|
||||
ey=nbeta-1;
|
||||
|
||||
}
|
||||
ex=(etax-etamin)/etastep;
|
||||
ey=(etay-etamin)/etastep;
|
||||
if (ex<0) {
|
||||
cout << "x*"<< ex << endl;
|
||||
ex=0;
|
||||
}
|
||||
if (ex>=nbeta) {
|
||||
cout << "x?"<< ex << endl;
|
||||
ex=nbeta-1;
|
||||
}
|
||||
if (ey<0) {
|
||||
cout << "y*"<< ey << endl;
|
||||
ey=0;
|
||||
}
|
||||
if (ey>=nbeta) {
|
||||
cout << "y?"<< ey << endl;
|
||||
ey=nbeta-1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
xpos_eta=(((double)hhx[(ey*nbeta+ex)]))+dX ;///((double)nSubPixels);
|
||||
ypos_eta=(((double)hhy[(ey*nbeta+ex)]))+dY ;///((double)nSubPixels);
|
||||
//else
|
||||
//return 0;
|
||||
xpos_eta=(((double)hhx[(ey*nbeta+ex)]))+dX ;///((double)nSubPixels);
|
||||
ypos_eta=(((double)hhy[(ey*nbeta+ex)]))+dY ;///((double)nSubPixels);
|
||||
|
||||
#endif
|
||||
} else {
|
||||
xpos_eta=0.5*dX+0.25;
|
||||
ypos_eta=0.5*dY+0.25;
|
||||
}
|
||||
|
||||
int_x=((double)x) + xpos_eta+0.5;
|
||||
int_y=((double)y) + ypos_eta+0.5;
|
||||
int_x=((double)x) + xpos_eta+0.5;
|
||||
int_y=((double)y) + ypos_eta+0.5;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) {
|
||||
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) {
|
||||
double cc[2][2];
|
||||
int *cluster[3];
|
||||
int xoff, yoff;
|
||||
cluster[0]=cl;
|
||||
cluster[1]=cl+3;
|
||||
cluster[2]=cl+6;
|
||||
|
||||
switch (quad) {
|
||||
case BOTTOM_LEFT:
|
||||
@ -298,17 +244,11 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
default:
|
||||
;
|
||||
}
|
||||
cc[0][0]=cluster[yoff][xoff];
|
||||
cc[1][0]=cluster[yoff+1][xoff];
|
||||
cc[0][1]=cluster[yoff][xoff+1];
|
||||
cc[1][1]=cluster[yoff+1][xoff+1];
|
||||
cc[0][0]=cl[xoff+3*yoff];
|
||||
cc[1][0]=cl[xoff+3*(yoff+1)];
|
||||
cc[0][1]=cl[xoff+1+3*yoff];
|
||||
cc[1][1]=cl[xoff+1+3*(yoff+1)];
|
||||
|
||||
/* cout << cl[0] << " " << cl[1] << " " << cl[2] << endl; */
|
||||
/* cout << cl[3] << " " << cl[4] << " " << cl[5] << endl; */
|
||||
/* cout << cl[6] << " " << cl[7] << " " << cl[8] << endl; */
|
||||
/* cout <<"******"<<totquad << " " << quad << endl; */
|
||||
/* cout << cc[0][0]<< " " << cc[0][1] << endl; */
|
||||
/* cout << cc[1][0]<< " " << cc[1][1] << endl; */
|
||||
//calcMyEta(totquad,quad,cl,etax, etay);
|
||||
calcEta(totquad, cc,etax, etay);
|
||||
|
||||
@ -320,11 +260,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
|
||||
virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) {
|
||||
double cc[2][2];
|
||||
double *cluster[3];
|
||||
int xoff, yoff;
|
||||
cluster[0]=cl;
|
||||
cluster[1]=cl+3;
|
||||
cluster[2]=cl+6;
|
||||
|
||||
switch (quad) {
|
||||
case BOTTOM_LEFT:
|
||||
@ -346,10 +282,10 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
default:
|
||||
;
|
||||
}
|
||||
cc[0][0]=cluster[yoff][xoff];
|
||||
cc[1][0]=cluster[yoff+1][xoff];
|
||||
cc[0][1]=cluster[yoff][xoff+1];
|
||||
cc[1][1]=cluster[yoff+1][xoff+1];
|
||||
cc[0][0]=cl[xoff+3*yoff];
|
||||
cc[1][0]=cl[(yoff+1)*3+xoff];
|
||||
cc[0][1]=cl[yoff*3+xoff+1];
|
||||
cc[1][1]=cl[(yoff+1)*3+xoff+1];
|
||||
|
||||
/* cout << cl[0] << " " << cl[1] << " " << cl[2] << endl; */
|
||||
/* cout << cl[3] << " " << cl[4] << " " << cl[5] << endl; */
|
||||
@ -416,6 +352,37 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
return 0;
|
||||
};
|
||||
|
||||
virtual int *getInterpolatedImage(){
|
||||
int ipx, ipy;
|
||||
// cout << "ff" << endl;
|
||||
calcDiff(1, hhx, hhy); //get flat
|
||||
double avg=0;
|
||||
for (ipx=0; ipx<nSubPixels; ipx++)
|
||||
for (ipy=0; ipy<nSubPixels; ipy++)
|
||||
avg+=flat[ipx+ipy*nSubPixels];
|
||||
avg/=nSubPixels*nSubPixels;
|
||||
|
||||
for (int ibx=0 ; ibx<nSubPixels*nPixelsX; ibx++) {
|
||||
ipx=ibx%nSubPixels-nSubPixels/2;
|
||||
if (ipx<0) ipx=nSubPixels+ipx;
|
||||
for (int iby=0 ; iby<nSubPixels*nPixelsY; iby++) {
|
||||
ipy=iby%nSubPixels-nSubPixels/2;
|
||||
if (ipy<0) ipy=nSubPixels+ipy;
|
||||
// cout << ipx << " " << ipy << " " << ibx << " " << iby << endl;
|
||||
if (flat[ipx+ipy*nSubPixels]>0)
|
||||
hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX]*(avg/flat[ipx+ipy*nSubPixels]);
|
||||
else
|
||||
hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return hintcorr;
|
||||
};
|
||||
|
||||
/* protected: */
|
||||
|
||||
/* #ifdef MYROOT1 */
|
||||
|
@ -15,9 +15,9 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
|
||||
public:
|
||||
eta3InterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx, ny, ns, nb, emin, emax) {
|
||||
// cout << "e3ib " << nb << " " << emin << " " << emax << endl;
|
||||
if (nbeta<=0) {
|
||||
nbeta=nSubPixels*10;
|
||||
}
|
||||
/* if (nbeta<=0) { */
|
||||
/* nbeta=nSubPixels*10; */
|
||||
/* } */
|
||||
if (etamin>=etamax) {
|
||||
etamin=-1;
|
||||
etamax=1;
|
||||
@ -33,13 +33,13 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
|
||||
hhy=new TH2D("hhy","hhy",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
delete [] heta;
|
||||
delete [] hhx;
|
||||
delete [] hhy;
|
||||
/* delete [] heta; */
|
||||
/* delete [] hhx; */
|
||||
/* delete [] hhy; */
|
||||
|
||||
heta=new int[nbeta*nbeta];
|
||||
hhx=new float[nbeta*nbeta];
|
||||
hhy=new float[nbeta*nbeta];
|
||||
/* heta=new int[nbeta*nbeta]; */
|
||||
/* hhx=new float[nbeta*nbeta]; */
|
||||
/* hhy=new float[nbeta*nbeta]; */
|
||||
|
||||
#endif
|
||||
// cout << nbeta << " " << etamin << " " << etamax << endl;
|
||||
@ -47,7 +47,7 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
|
||||
|
||||
eta3InterpolationBase(eta3InterpolationBase *orig): etaInterpolationBase(orig){ };
|
||||
|
||||
virtual eta3InterpolationBase* Clone()=0;
|
||||
/* virtual eta3InterpolationBase* Clone()=0; */
|
||||
|
||||
|
||||
|
||||
|
@ -1,131 +1,137 @@
|
||||
#ifndef ETA_INTERPOLATION_ADAPTIVEBINS_H
|
||||
#define ETA_INTERPOLATION_ADAPTIVEBINS_H
|
||||
|
||||
|
||||
#include <cmath>
|
||||
#include "tiffIO.h"
|
||||
//#include "etaInterpolationBase.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
|
||||
|
||||
|
||||
class etaInterpolationAdaptiveBins : public etaInterpolationPosXY {
|
||||
|
||||
// protected:
|
||||
|
||||
|
||||
private:
|
||||
double calcDiff(double avg, float *hx, float *hy) {
|
||||
double p_tot=0;
|
||||
double diff=0;
|
||||
double bsize=1./nSubPixels;
|
||||
|
||||
for (int ipx=0; ipx<nSubPixels; ipx++) {
|
||||
for (int ipy=0; ipy<nSubPixels; ipy++) {
|
||||
p_tot=0;
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
if ( hx[ibx+iby*nbeta]>=((ipx)*bsize) && hx[ibx+iby*nbeta]<((ipx+1)*bsize) && hy[ibx+iby*nbeta]>=((ipy)*bsize) && hy[ibx+iby*nbeta]<((ipy+1)*bsize)) {
|
||||
p_tot+=heta[ibx+iby*nbeta];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << p_tot << " \t ";
|
||||
|
||||
|
||||
|
||||
diff+=(p_tot-avg)*(p_tot-avg);
|
||||
|
||||
}
|
||||
cout << "\n";
|
||||
}
|
||||
return diff;
|
||||
}
|
||||
|
||||
void iterate(float *newhhx, float *newhhy) {
|
||||
virtual void iterate(float *newhhx, float *newhhy) {
|
||||
|
||||
double bsize=1./nSubPixels;
|
||||
|
||||
double hy[nbeta]; //profile y
|
||||
double hx[nbeta]; //profile x
|
||||
double hix[nbeta]; //integral of projection x
|
||||
double hiy[nbeta]; //integral of projection y
|
||||
double hy[nSubPixels][nbeta]; //profile y
|
||||
double hx[nSubPixels][nbeta]; //profile x
|
||||
double hix[nSubPixels][nbeta]; //integral of projection x
|
||||
double hiy[nSubPixels][nbeta]; //integral of projection y
|
||||
int ipy, ipx;
|
||||
double tot_eta_x[nSubPixels];
|
||||
double tot_eta_y[nSubPixels];
|
||||
//for (int ipy=0; ipy<nSubPixels; ipy++) {
|
||||
|
||||
double tot_eta_x=0;
|
||||
double tot_eta_y=0;
|
||||
for (int ipy=0; ipy<nSubPixels; ipy++) {
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
hx[ibx]=0;
|
||||
hy[ibx]=0;
|
||||
for (ipy=0; ipy<nSubPixels; ipy++) {
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
hx[ipy][ibx]=0;
|
||||
hy[ipy][ibx]=0;
|
||||
}
|
||||
}
|
||||
|
||||
tot_eta_x=0;
|
||||
tot_eta_y=0;
|
||||
// cout << ipy << " " << ((ipy)*bsize) << " " << ((ipy+1)*bsize) << endl;
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
|
||||
if (hhy[ibx+iby*nbeta]>=((ipy)*bsize) && hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
||||
hx[ibx]+=heta[ibx+iby*nbeta];
|
||||
tot_eta_x+=heta[ibx+iby*nbeta];
|
||||
}
|
||||
ipy=hhy[ibx+iby*nbeta]*nSubPixels;
|
||||
if (ipy<0) ipy=0;
|
||||
if (ipy>=nSubPixels) ipy=nSubPixels-1;
|
||||
hx[ipy][ibx]+=heta[ibx+iby*nbeta];
|
||||
|
||||
|
||||
if (hhx[ibx+iby*nbeta]>=((ipy)*bsize) && hhx[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
||||
hy[iby]+=heta[ibx+iby*nbeta];
|
||||
tot_eta_y+=heta[ibx+iby*nbeta];
|
||||
}
|
||||
ipx=hhx[ibx+iby*nbeta]*nSubPixels;
|
||||
if (ipx<0) ipx=0;
|
||||
if (ipx>=nSubPixels) ipx=nSubPixels-1;
|
||||
hy[ipx][iby]+=heta[ibx+iby*nbeta];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hix[0]=hx[0];
|
||||
hiy[0]=hy[0];
|
||||
for (int ib=1; ib<nbeta; ib++) {
|
||||
hix[ib]=hix[ib-1]+hx[ib];
|
||||
hiy[ib]=hiy[ib-1]+hy[ib];
|
||||
}
|
||||
// tot_eta_x=hix[nbeta-1];
|
||||
// tot_eta_y=hiy[nbeta-1];
|
||||
/* cout << "ipx " << ipy << " x: " << tot_eta_x << " " << hix[10]<< " " << hix[nbeta-1] << endl; */
|
||||
/* cout << "ipy " << ipy << " y: " << tot_eta_y << " " << hiy[10]<< " " << hiy[nbeta-1] << endl; */
|
||||
|
||||
// for (int ipy=0; ipy<nSubPixels; ipy++) {
|
||||
for (ipy=0; ipy<nSubPixels; ipy++) {
|
||||
hix[ipy][0]=hx[ipy][0];
|
||||
hiy[ipy][0]=hy[ipy][0];
|
||||
for (int ib=1; ib<nbeta; ib++) {
|
||||
hix[ipy][ib]=hix[ipy][ib-1]+hx[ipy][ib];
|
||||
hiy[ipy][ib]=hiy[ipy][ib-1]+hy[ipy][ib];
|
||||
}
|
||||
tot_eta_x[ipy]=hix[ipy][nbeta-1]+1;
|
||||
tot_eta_y[ipy]=hiy[ipy][nbeta-1]+1;
|
||||
// cout << ipy << " " << tot_eta_x[ipy] << " " << tot_eta_y[ipy] << endl;
|
||||
|
||||
}
|
||||
// for (int ipy=0; ipy<nSubPixels; ipy++) {
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
|
||||
if ( hhy[ibx+iby*nbeta]>=((ipy)*bsize) && hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
||||
newhhx[ibx+iby*nbeta]=hix[ibx]/((double)tot_eta_x);
|
||||
if (newhhx[ibx+iby*nbeta]>1) cout << "***"<< ibx << " " << iby << newhhx[ibx+iby*nbeta] << endl;
|
||||
// if ( hhy[ibx+iby*nbeta]>=((ipy)*bsize) && hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
||||
ipy=hhy[ibx+iby*nbeta]*nSubPixels;
|
||||
|
||||
if (ipy<0) ipy=0;
|
||||
if (ipy>=nSubPixels) ipy=nSubPixels-1;
|
||||
|
||||
if (ipy>=0 && ipy<nSubPixels)
|
||||
if (tot_eta_x[ipy]>0)
|
||||
newhhx[ibx+iby*nbeta]=hix[ipy][ibx]/(tot_eta_x[ipy]);
|
||||
else
|
||||
cout << "Bad tot_etax " << ipy << " " << tot_eta_x[ipy] << endl;
|
||||
else
|
||||
cout << "** Bad value ipy " << ibx << " " << iby << " "<< ipy << " " << hhy[ibx+iby*nbeta]*nSubPixels << endl;
|
||||
// if (newhhx[ibx+iby*nbeta]>=1 || newhhx[ibx+iby*nbeta]<0 ) cout << "***"<< ibx << " " << iby << newhhx[ibx+iby*nbeta] << endl;
|
||||
// if (ipy==3 && ibx==10) cout << newhhx[ibx+iby*nbeta] << " " << hix[ibx] << " " << ibx+iby*nbeta << endl;
|
||||
}
|
||||
if (hhx[ibx+iby*nbeta]>=((ipy)*bsize) && hhx[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
||||
newhhy[ibx+iby*nbeta]=hiy[iby]/((double)tot_eta_y);
|
||||
if (newhhy[ibx+iby*nbeta]>1) cout << "***"<< ibx << " " << iby << newhhy[ibx+iby*nbeta] << endl;
|
||||
// }
|
||||
ipy=hhx[ibx+iby*nbeta]*nSubPixels;
|
||||
//if (hhx[ibx+iby*nbeta]>=((ipy)*bsize) && hhx[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
||||
if (ipy<0) ipy=0;
|
||||
if (ipy>=nSubPixels) ipy=nSubPixels-1;
|
||||
|
||||
if (ipy>=0 && ipy<nSubPixels)
|
||||
if (tot_eta_y[ipy]>0)
|
||||
newhhy[ibx+iby*nbeta]=hiy[ipy][iby]/(tot_eta_y[ipy]);
|
||||
else
|
||||
cout << "Bad tot_etay " << ipy << " " << tot_eta_y[ipy] << endl;
|
||||
else
|
||||
cout << "** Bad value ipx " << ibx << " " << iby << " "<< ipy << " " << hhx[ibx+iby*nbeta]*nSubPixels << endl;
|
||||
// if (newhhy[ibx+iby*nbeta]>=1 || newhhy[ibx+iby*nbeta]<0 ) cout << "***"<< ibx << " " << iby << newhhy[ibx+iby*nbeta] << endl;
|
||||
// if (ipy==3 && iby==10) cout << newhhy[ibx+iby*nbeta] << " " << hiy[iby] << " " << ibx+iby*nbeta << endl;
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
etaInterpolationAdaptiveBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){};
|
||||
etaInterpolationAdaptiveBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){
|
||||
// flat=new double[nSubPixels*nSubPixels]; flat_x=new double[nSubPixels]; flat_y=new double[nSubPixels];
|
||||
// flat=new double[nSubPixels*nSubPixels];
|
||||
};
|
||||
|
||||
etaInterpolationAdaptiveBins(etaInterpolationAdaptiveBins *orig): etaInterpolationPosXY(orig){};
|
||||
etaInterpolationAdaptiveBins(etaInterpolationAdaptiveBins *orig): etaInterpolationPosXY(orig){hintcorr=new int[nPixelsX*nPixelsY*nSubPixels];};
|
||||
|
||||
virtual etaInterpolationAdaptiveBins* Clone() {
|
||||
virtual etaInterpolationAdaptiveBins* Clone()=0;
|
||||
|
||||
return new etaInterpolationAdaptiveBins(this);
|
||||
/* return new etaInterpolationAdaptiveBins(this); */
|
||||
|
||||
};
|
||||
/* }; */
|
||||
|
||||
|
||||
|
||||
virtual void prepareInterpolation(int &ok)
|
||||
virtual void prepareInterpolation(int &ok) {
|
||||
prepareInterpolation(ok, 1000);
|
||||
}
|
||||
|
||||
virtual void prepareInterpolation(int &ok, int nint)
|
||||
{
|
||||
ok=1;
|
||||
cout << "Adaptive bins" << endl;
|
||||
|
||||
///*Eta Distribution Rebinning*///
|
||||
double bsize=1./nSubPixels; //precision
|
||||
@ -153,65 +159,36 @@ class etaInterpolationAdaptiveBins : public etaInterpolationPosXY {
|
||||
// }
|
||||
// }
|
||||
|
||||
etaInterpolationPosXY::prepareInterpolation(ok);
|
||||
etaInterpolationPosXY::prepareInterpolation(ok);
|
||||
|
||||
#ifdef SAVE_ALL
|
||||
|
||||
char tit[10000];
|
||||
float *etah=new float[nbeta*nbeta];
|
||||
int etabins=nbeta;
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
|
||||
etah[ii]=hhx[ii];
|
||||
}
|
||||
sprintf(tit,"/scratch/start_hhx.tiff");
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
etah[ii]=hhy[ii];
|
||||
}
|
||||
sprintf(tit,"/scratch/start_hhy.tiff");
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
|
||||
#endif
|
||||
int nint=1000;
|
||||
|
||||
double thr=1./((double)nSubPixels);
|
||||
double avg=tot_eta/((double)(nSubPixels*nSubPixels));
|
||||
cout << "total eta entries is :"<< tot_eta << " avg: "<< avg << endl;
|
||||
cout << "Start " << endl;
|
||||
double rms=sqrt(tot_eta);
|
||||
cout << "total eta entries is :"<< tot_eta << " avg: "<< avg << " rms: " << sqrt(tot_eta) << endl;
|
||||
double old_diff=calcDiff(avg, hhx, hhy), new_diff=old_diff+1, best_diff=old_diff;
|
||||
cout << " diff= " << old_diff << endl;
|
||||
|
||||
|
||||
// cout << " chi2= " << old_diff << " (rms= " << sqrt(tot_eta) << ")" << endl;
|
||||
cout << endl;
|
||||
cout << endl;
|
||||
debugSaveAll(0);
|
||||
int iint=0;
|
||||
float *newhhx=new float[nbeta*nbeta]; //profile x
|
||||
float *newhhy=new float[nbeta*nbeta]; //profile y
|
||||
float *besthhx=hhx; //profile x
|
||||
float *besthhy=hhy; //profile y
|
||||
while (iint<nint) {
|
||||
|
||||
cout << "Iteration " << iint << endl;
|
||||
cout << "Iteration "<< iint << " Chi2: " << old_diff << endl; //" Best: "<< best_diff << " RMS: "<< rms<< endl;
|
||||
while (iint<nint && best_diff > rms) {
|
||||
|
||||
/* #ifdef SAVE_ALL */
|
||||
/* if (iint%10==0) */
|
||||
/* debugSaveAll(iint); */
|
||||
/* #endif */
|
||||
// cout << "Iteration " << iint << endl;
|
||||
iterate(newhhx,newhhy);
|
||||
new_diff=calcDiff(avg, newhhx, newhhy);
|
||||
cout << " diff= " << new_diff << endl;
|
||||
/* #ifdef SAVE_ALL */
|
||||
/* for (int ii=0; ii<etabins*etabins; ii++) { */
|
||||
/* etah[ii]=newhhx[ii]; */
|
||||
/* if (etah[ii]>1 || etah[ii]<0 ) cout << "***"<< ii << etah[ii] << endl; */
|
||||
// cout << " chi2= " << new_diff << " (rms= " << sqrt(tot_eta) << ")"<<endl;
|
||||
|
||||
/* } */
|
||||
/* sprintf(tit,"/scratch/neweta_hhx_%d.tiff",iint); */
|
||||
/* WriteToTiff(etah, tit, etabins, etabins); */
|
||||
|
||||
/* for (int ii=0; ii<etabins*etabins; ii++) { */
|
||||
/* etah[ii]=newhhy[ii]; */
|
||||
/* if (etah[ii]>1 || etah[ii]<0 ) cout << "***"<< ii << etah[ii] << endl; */
|
||||
/* } */
|
||||
/* sprintf(tit,"/scratch/neweta_hhy_%d.tiff",iint); */
|
||||
/* WriteToTiff(etah, tit, etabins, etabins); */
|
||||
/* #endif */
|
||||
if (new_diff<best_diff) {
|
||||
best_diff=new_diff;
|
||||
besthhx=newhhx;
|
||||
@ -225,19 +202,33 @@ class etaInterpolationAdaptiveBins : public etaInterpolationPosXY {
|
||||
|
||||
hhx=newhhx;
|
||||
hhy=newhhy;
|
||||
|
||||
|
||||
#ifdef SAVE_ALL
|
||||
if (new_diff<=best_diff) {
|
||||
debugSaveAll(iint);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
newhhx=new float[nbeta*nbeta]; //profile x
|
||||
newhhy=new float[nbeta*nbeta]; //profile y
|
||||
|
||||
old_diff=new_diff;
|
||||
//} /* else { */
|
||||
/* cout << "Difference not decreasing after "<< iint << " iterations (" << old_diff << " < " << new_diff << ")"<< endl; */
|
||||
/* break; */
|
||||
/* } */
|
||||
|
||||
iint++;
|
||||
/* if (new_diff<old_diff){ */
|
||||
/* cout << "best difference at iteration "<< iint << " (" << new_diff << " < " << old_diff << ")"<< "Best: "<< best_diff << " RMS: "<< sqrt(tot_eta) << endl; */
|
||||
/* ; */
|
||||
/* } else { */
|
||||
// break;
|
||||
// }
|
||||
|
||||
old_diff=new_diff;
|
||||
|
||||
iint++;
|
||||
cout << "Iteration "<< iint << " Chi2: " << new_diff << endl; //" Best: "<< best_diff << " RMS: "<< rms<< endl;
|
||||
}
|
||||
delete [] newhhx;
|
||||
delete [] newhhy;
|
||||
delete [] newhhx;
|
||||
delete [] newhhy;
|
||||
|
||||
if (hhx!=besthhx)
|
||||
delete [] hhx;
|
||||
@ -248,34 +239,47 @@ class etaInterpolationAdaptiveBins : public etaInterpolationPosXY {
|
||||
hhy=besthhy;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cout << "Iteration "<< iint << " Chi2: " << best_diff << endl; //" Best: "<< best_diff << " RMS: "<< rms<< endl;
|
||||
#ifdef SAVE_ALL
|
||||
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
etah[ii]=hhx[ii];
|
||||
}
|
||||
sprintf(tit,"/scratch/eta_hhx_%d.tiff",id);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
etah[ii]=hhy[ii];
|
||||
}
|
||||
sprintf(tit,"/scratch/eta_hhy_%d.tiff",id);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
etah[ii]=heta[ii];
|
||||
}
|
||||
sprintf(tit,"/scratch/eta_%d.tiff",id);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
delete [] etah;
|
||||
debugSaveAll(iint);
|
||||
#endif
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
class eta2InterpolationAdaptiveBins : public virtual eta2InterpolationBase, public virtual etaInterpolationAdaptiveBins {
|
||||
public:
|
||||
eta2InterpolationAdaptiveBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax),eta2InterpolationBase(nx,ny,ns, nb, emin,emax),etaInterpolationAdaptiveBins(nx,ny,ns, nb, emin,emax){
|
||||
cout << "NSUBPIX is " << ns << " " << nSubPixels << endl;
|
||||
// cout << "e2pxy " << nb << " " << emin << " " << emax << endl;
|
||||
};
|
||||
|
||||
eta2InterpolationAdaptiveBins(eta2InterpolationAdaptiveBins *orig): etaInterpolationBase(orig), etaInterpolationAdaptiveBins(orig) {};
|
||||
|
||||
virtual eta2InterpolationAdaptiveBins* Clone() { return new eta2InterpolationAdaptiveBins(this);};
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class eta3InterpolationAdaptiveBins : public virtual eta3InterpolationBase, public virtual etaInterpolationAdaptiveBins {
|
||||
public:
|
||||
eta3InterpolationAdaptiveBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax),eta3InterpolationBase(nx,ny,ns, nb, emin,emax), etaInterpolationAdaptiveBins(nx,ny,ns, nb, emin,emax){
|
||||
cout << "e3pxy " << nbeta << " " << etamin << " " << etamax << " " << nSubPixels<< endl;
|
||||
};
|
||||
|
||||
eta3InterpolationAdaptiveBins(eta3InterpolationAdaptiveBins *orig): etaInterpolationBase(orig), etaInterpolationAdaptiveBins(orig) {};
|
||||
|
||||
virtual eta3InterpolationAdaptiveBins* Clone() { return new eta3InterpolationAdaptiveBins(this);};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -19,85 +19,62 @@ class etaInterpolationBase : public slsInterpolation {
|
||||
// cout << "eb " << nb << " " << emin << " " << emax << endl;
|
||||
// cout << nb << " " << etamin << " " << etamax << endl;
|
||||
if (nbeta<=0) {
|
||||
cout << "aaa:" <<endl;
|
||||
//cout << "aaa:" <<endl;
|
||||
nbeta=nSubPixels*10;
|
||||
}
|
||||
if (etamin>=etamax) {
|
||||
cout << "aaa:" <<endl;
|
||||
etamin=-1;
|
||||
etamax=2;
|
||||
}
|
||||
etastep=(etamax-etamin)/nbeta;
|
||||
#ifdef MYROOT1
|
||||
heta=new TH2D("heta","heta",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||
hhx=new TH2D("hhx","hhx",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||
hhy=new TH2D("hhy","hhy",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
heta=new int[nbeta*nbeta];
|
||||
hhx=new float[nbeta*nbeta];
|
||||
hhy=new float[nbeta*nbeta];
|
||||
rangeMin=etamin;
|
||||
rangeMax=etamax;
|
||||
flat= new double[nSubPixels*nSubPixels];
|
||||
hintcorr=new int [nSubPixels*nSubPixels*nPixelsX*nPixelsY];
|
||||
|
||||
#endif
|
||||
|
||||
//cout << nbeta << " " << etamin << " " << etamax << endl;
|
||||
};
|
||||
|
||||
etaInterpolationBase(etaInterpolationBase *orig): slsInterpolation(orig){
|
||||
nbeta=orig->nbeta;
|
||||
etamin=orig->etamin;
|
||||
etamax=orig->etamax;
|
||||
rangeMin=orig->rangeMin;
|
||||
rangeMax=orig->rangeMax;
|
||||
|
||||
|
||||
etastep=(etamax-etamin)/nbeta;
|
||||
#ifdef MYROOT1
|
||||
heta=(TH2D*)(orig->heta)->Clone("heta");
|
||||
hhx=(TH2D*)(orig->hhx)->Clone("hhx");
|
||||
hhy=(TH2D*)(orig->hhy)->Clone("hhy");
|
||||
#endif
|
||||
|
||||
#ifndef MYROOT1
|
||||
heta=new int[nbeta*nbeta];
|
||||
memcpy(heta,orig->heta,nbeta*nbeta*sizeof(int));
|
||||
hhx=new float[nbeta*nbeta];
|
||||
memcpy(hhx,orig->hhx,nbeta*nbeta*sizeof(float));
|
||||
hhy=new float[nbeta*nbeta];
|
||||
memcpy(hhy,orig->hhy,nbeta*nbeta*sizeof(float));
|
||||
|
||||
#endif
|
||||
|
||||
hintcorr=new int [nSubPixels*nSubPixels*nPixelsX*nPixelsY];
|
||||
|
||||
};
|
||||
|
||||
virtual etaInterpolationBase* Clone()=0;/*{
|
||||
return new etaInterpolationBase(this);
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef MYROOT1
|
||||
TH2D *setEta(TH2D *h, int nb=-1, double emin=1, double emax=0)
|
||||
{
|
||||
if (h) { heta=h;
|
||||
nbeta=heta->GetNbinsX();
|
||||
etamin=heta->GetXaxis()->GetXmin();
|
||||
etamax=heta->GetXaxis()->GetXmax();
|
||||
etastep=(etamax-etamin)/nbeta;
|
||||
}
|
||||
return heta;
|
||||
};
|
||||
TH2D *setFlatField(TH2D *h, int nb=-1, double emin=1, double emax=0)
|
||||
{
|
||||
return setEta(h, nb, emin, emax);
|
||||
|
||||
virtual void resetFlatField() {
|
||||
for (int ibx=0; ibx<nbeta*nbeta; ibx++) {
|
||||
heta[ibx]=0;
|
||||
hhx[ibx]=0;
|
||||
hhy[ibx]=0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
TH2D *getFlatField(){return setEta(NULL);};
|
||||
#endif
|
||||
|
||||
#ifndef MYROOT1
|
||||
int *setEta(int *h, int nb=-1, double emin=1, double emax=0)
|
||||
{
|
||||
if (h) {heta=h;
|
||||
if (h) {
|
||||
if (heta) delete [] heta;
|
||||
heta=h;
|
||||
nbeta=nb;
|
||||
if (nb<=0) nbeta=nSubPixels*10;
|
||||
etamin=emin;
|
||||
@ -106,6 +83,8 @@ class etaInterpolationBase : public slsInterpolation {
|
||||
etamin=-1;
|
||||
etamax=2;
|
||||
}
|
||||
rangeMin=etamin;
|
||||
rangeMax=etamax;
|
||||
etastep=(etamax-etamin)/nbeta;
|
||||
}
|
||||
return heta;
|
||||
@ -115,11 +94,13 @@ class etaInterpolationBase : public slsInterpolation {
|
||||
{
|
||||
return setEta(h, nb, emin, emax);
|
||||
};
|
||||
|
||||
|
||||
|
||||
int *getFlatField(){return setEta(NULL);};
|
||||
|
||||
int *getFlatField(int &nb, double &emin, double &emax){
|
||||
nb=nbeta;
|
||||
//cout << "igff* ff has " << nb << " bins " << endl;
|
||||
emin=etamin;
|
||||
emax=etamax;
|
||||
return getFlatField();
|
||||
@ -183,27 +164,7 @@ class etaInterpolationBase : public slsInterpolation {
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* ////////////////////////////////////////////////////////////////////////////// */
|
||||
|
||||
#ifdef MYROOT1
|
||||
TH2D *gethhx()
|
||||
{
|
||||
hhx->Scale((double)nSubPixels);
|
||||
return hhx;
|
||||
};
|
||||
|
||||
TH2D *gethhy()
|
||||
{
|
||||
hhy->Scale((double)nSubPixels);
|
||||
return hhy;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef MYROOT1
|
||||
float *gethhx()
|
||||
{
|
||||
// hhx->Scale((double)nSubPixels);
|
||||
@ -215,53 +176,193 @@ float *gethhx()
|
||||
// hhy->Scale((double)nSubPixels);
|
||||
return hhy;
|
||||
};
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////// /*It return position hit for the event in input */ //////////////
|
||||
/* virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y)=0; */
|
||||
/* virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y)=0; */
|
||||
/* virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y)=0; */
|
||||
/* virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y)=0; */
|
||||
/* virtual void getInterpolatedPosition(int x, int y, double etax, double etay, int corner, double &int_x, double &int_y)=0; */
|
||||
|
||||
|
||||
/* virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay)=0; */
|
||||
/* virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay)=0; */
|
||||
/* virtual int addToFlatField(double *cluster, double &etax, double &etay)=0; */
|
||||
/* virtual int addToFlatField(int *cluster, double &etax, double &etay)=0; */
|
||||
|
||||
virtual int addToFlatField(double etax, double etay){
|
||||
#ifdef MYROOT1
|
||||
heta->Fill(etax,etay);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
int ex,ey;
|
||||
ex=(etax-etamin)/etastep;
|
||||
ey=(etay-etamin)/etastep;
|
||||
if (ey<nbeta && ex<nbeta && ex>=0 && ey>=0)
|
||||
heta[ey*nbeta+ex]++;
|
||||
#endif
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
// virtual void prepareInterpolation(int &ok)=0;
|
||||
|
||||
|
||||
void debugSaveAll(int ind=0) {
|
||||
int ib, ibx, iby;
|
||||
char tit[10000];
|
||||
|
||||
float tot_eta=0;
|
||||
|
||||
float *etah=new float[nbeta*nbeta];
|
||||
int etabins=nbeta;
|
||||
int ibb=0;
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
|
||||
etah[ii]=heta[ii];
|
||||
tot_eta+=heta[ii];
|
||||
}
|
||||
sprintf(tit,"/scratch/eta.tiff",ind);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
ibb=(hhx[ii]*nSubPixels);
|
||||
etah[ii]=ibb;
|
||||
}
|
||||
sprintf(tit,"/scratch/eta_hhx_%d.tiff",ind);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
ibb=hhy[ii]*nSubPixels;
|
||||
etah[ii]=ibb;
|
||||
}
|
||||
sprintf(tit,"/scratch/eta_hhy_%d.tiff",ind);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
|
||||
|
||||
float *ftest=new float[nSubPixels*nSubPixels];
|
||||
|
||||
for (int ib=0; ib<nSubPixels*nSubPixels; ib++) ftest[ib]=0;
|
||||
|
||||
|
||||
//int ibx=0, iby=0;
|
||||
|
||||
for (int ii=0; ii<nbeta*nbeta; ii++) {
|
||||
|
||||
ibx=nSubPixels*hhx[ii];
|
||||
iby=nSubPixels*hhy[ii];
|
||||
if (ibx<0) ibx=0;
|
||||
if (iby<0) iby=0;
|
||||
if (ibx>=nSubPixels) ibx=nSubPixels-1;
|
||||
if (iby>=nSubPixels) iby=nSubPixels-1;
|
||||
|
||||
|
||||
if (ibx>=0 && ibx<nSubPixels && iby>=0 && iby<nSubPixels) {
|
||||
//
|
||||
// if (ibx>0 && iby>0) cout << ibx << " " << iby << " " << ii << endl;
|
||||
ftest[ibx+iby*nSubPixels]+=heta[ii];
|
||||
} else
|
||||
cout << "Bad interpolation "<< ii << " " << ibx << " " << iby<< endl;
|
||||
|
||||
}
|
||||
|
||||
sprintf(tit,"/scratch/ftest_%d.tiff",ind);
|
||||
WriteToTiff(ftest, tit, nSubPixels, nSubPixels);
|
||||
|
||||
//int ibx=0, iby=0;
|
||||
tot_eta/=nSubPixels*nSubPixels;
|
||||
int nbad=0;
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
ibx=nSubPixels*hhx[ii];
|
||||
iby=nSubPixels*hhy[ii];
|
||||
if (ftest[ibx+iby*nSubPixels]<tot_eta*0.5) {
|
||||
etah[ii]=1;
|
||||
nbad++;
|
||||
} else if(ftest[ibx+iby*nSubPixels]>tot_eta*2.){
|
||||
etah[ii]=2;
|
||||
nbad++;
|
||||
} else
|
||||
etah[ii]=0;
|
||||
}
|
||||
sprintf(tit,"/scratch/eta_bad_%d.tiff",ind);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
// cout << "Index: " << ind << "\t Bad bins: "<< nbad << endl;
|
||||
//int ibx=0, iby=0;
|
||||
|
||||
delete [] ftest;
|
||||
delete [] etah;
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
#ifdef MYROOT1
|
||||
TH2D *heta;
|
||||
TH2D *hhx;
|
||||
TH2D *hhy;
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
|
||||
double calcDiff(double avg, float *hx, float *hy) {
|
||||
//double p_tot=0;
|
||||
double diff=0, d;
|
||||
double bsize=1./nSubPixels;
|
||||
int nbad=0;
|
||||
double p_tot_x[nSubPixels], p_tot_y[nSubPixels], p_tot[nSubPixels*nSubPixels];
|
||||
double maxdiff=0, mindiff=avg*nSubPixels*nSubPixels;
|
||||
|
||||
int ipx, ipy;
|
||||
for (ipy=0; ipy<nSubPixels; ipy++) {
|
||||
for (ipx=0; ipx<nSubPixels; ipx++) {
|
||||
p_tot[ipx+ipy*nSubPixels]=0;
|
||||
}
|
||||
p_tot_y[ipy]=0;
|
||||
p_tot_x[ipy]=0;
|
||||
}
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
ipx=hx[ibx+iby*nbeta]*nSubPixels;
|
||||
if (ipx<0) ipx=0;
|
||||
if (ipx>=nSubPixels) ipx=nSubPixels-1;
|
||||
|
||||
ipy=hy[ibx+iby*nbeta]*nSubPixels;
|
||||
if (ipy<0) ipy=0;
|
||||
if (ipy>=nSubPixels) ipy=nSubPixels-1;
|
||||
|
||||
p_tot[ipx+ipy*nSubPixels]+=heta[ibx+iby*nbeta];
|
||||
p_tot_y[ipy]+=heta[ibx+iby*nbeta];
|
||||
p_tot_x[ipx]+=heta[ibx+iby*nbeta];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// cout << endl << endl;
|
||||
for (ipy=0; ipy<nSubPixels; ipy++) {
|
||||
cout.width(5);
|
||||
//flat_y[ipy]=p_tot_y[ipy];//avg/nSubPixels;
|
||||
for (ipx=0; ipx<nSubPixels; ipx++) {
|
||||
|
||||
// flat_x[ipx]=p_tot_x[ipx];///avg/nSubPixels;
|
||||
flat[ipx+nSubPixels*ipy]=p_tot[ipx+nSubPixels*ipy];///avg;
|
||||
d=p_tot[ipx+nSubPixels*ipy]-avg;
|
||||
if (d<0) d*=-1.;
|
||||
if (d>5*sqrt(avg) )
|
||||
nbad++;
|
||||
diff+=d*d;
|
||||
if (d<mindiff) mindiff=d;
|
||||
if (d>maxdiff) maxdiff=d;
|
||||
// cout << setprecision(4) << p_tot[ipx+nSubPixels*ipy] << " ";
|
||||
}
|
||||
|
||||
/* cout << "** " << setprecision(4) << flat_y[ipy]; */
|
||||
//cout << "\n";
|
||||
}
|
||||
/* cout << "**" << endl; cout.width(5); */
|
||||
/* for (ipx=0; ipx<nSubPixels; ipx++) { */
|
||||
/* cout << setprecision(4) << flat_x[ipx] << " "; */
|
||||
/* } */
|
||||
//cout << "**" << endl; cout.width(5);
|
||||
//cout << "Min diff: " << mindiff/sqrt(avg) << " Max diff: " << maxdiff/sqrt(avg) << " Nbad: " << nbad << endl;
|
||||
|
||||
|
||||
|
||||
// cout << "Bad pixels: " << 100.*(float)nbad/((float)(nSubPixels*nSubPixels)) << " %" << endl;
|
||||
return sqrt(diff);
|
||||
}
|
||||
|
||||
int *heta;
|
||||
float *hhx;
|
||||
float *hhy;
|
||||
#endif
|
||||
int nbeta;
|
||||
double etamin, etamax, etastep;
|
||||
double rangeMin, rangeMax;
|
||||
|
||||
|
||||
|
||||
double *flat;
|
||||
int *hintcorr;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,263 @@
|
||||
#ifndef ETA_INTERPOLATION_CLEVER_ADAPTIVEBINS_H
|
||||
#define ETA_INTERPOLATION_CLEVER_ADAPTIVEBINS_H
|
||||
|
||||
#include <cmath>
|
||||
#include "tiffIO.h"
|
||||
//#include "etaInterpolationBase.h"
|
||||
#include "etaInterpolationAdaptiveBins.h"
|
||||
|
||||
|
||||
//#define HSIZE 1
|
||||
|
||||
|
||||
class etaInterpolationCleverAdaptiveBins : public etaInterpolationAdaptiveBins {
|
||||
|
||||
private:
|
||||
|
||||
|
||||
// double *gradientX, *gradientY, *gradientXY;
|
||||
|
||||
|
||||
virtual void iterate(float *newhhx, float *newhhy) {
|
||||
|
||||
double bsize=1./nSubPixels;
|
||||
|
||||
/* double hy[nSubPixels*HSIZE][nbeta]; //profile y */
|
||||
/* double hx[nSubPixels*HSIZE][nbeta]; //profile x */
|
||||
// double hix[nSubPixels*HSIZE][nbeta]; //integral of projection x
|
||||
// double hiy[nSubPixels*HSIZE][nbeta]; //integral of projection y
|
||||
int ipy, ipx, ippx, ippy;
|
||||
// double tot_eta_x[nSubPixels*HSIZE];
|
||||
//double tot_eta_y[nSubPixels*HSIZE];
|
||||
|
||||
double mean=0;
|
||||
double maxflat=0, minflat=0, maxgradX=0, mingradX=0, maxgradY=0, mingradY=0, maxgr=0, mingr=0;
|
||||
|
||||
int ix_maxflat, iy_maxflat, ix_minflat, iy_minflat, ix_maxgrX, iy_maxgrX, ix_mingrX, iy_mingrX,ix_maxgrY, iy_maxgrY, ix_mingrY, iy_mingrY, ix_mingr, iy_mingr, ix_maxgr, iy_maxgr;
|
||||
int maskMin[nSubPixels*nSubPixels], maskMax[nSubPixels*nSubPixels];
|
||||
|
||||
|
||||
//for (int ipy=0; ipy<nSubPixels; ipy++) {
|
||||
|
||||
for (ipy=0; ipy<nSubPixels; ipy++) {
|
||||
for (ipx=0; ipx<nSubPixels; ipx++) {
|
||||
// cout << ipx << " " << ipy << endl;
|
||||
mean+=flat[ipx+nSubPixels*ipy]/((double)(nSubPixels*nSubPixels));
|
||||
}
|
||||
}
|
||||
|
||||
// cout << "Mean is " << mean << endl;
|
||||
|
||||
/*** Find local minima and maxima within the staistical uncertainty **/
|
||||
for (ipy=0; ipy<nSubPixels; ipy++) {
|
||||
for (ipx=0; ipx<nSubPixels; ipx++) {
|
||||
if (flat[ipx+nSubPixels*ipy]<mean-3.*sqrt(mean))maskMin[ipx+nSubPixels*ipy]=1; else maskMin[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>mean+3.*sqrt(mean)) maskMax[ipx+nSubPixels*ipy]=1; else maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (ipx>0 && ipy>0) {
|
||||
if (flat[ipx+nSubPixels*ipy]<flat[ipx-1+nSubPixels*(ipy-1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>flat[ipx-1+nSubPixels*(ipy-1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||
}
|
||||
if (ipx>0 && ipy<nSubPixels-1) {
|
||||
if (flat[ipx+nSubPixels*ipy]<flat[ipx-1+nSubPixels*(ipy+1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>flat[ipx-1+nSubPixels*(ipy+1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||
}
|
||||
if (ipy>0 && ipx<nSubPixels-1) {
|
||||
if (flat[ipx+nSubPixels*ipy]<flat[ipx+1+nSubPixels*(ipy-1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>flat[ipx+1+nSubPixels*(ipy-1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||
}
|
||||
if (ipy<nSubPixels-1 && ipx<nSubPixels-1) {
|
||||
if (flat[ipx+nSubPixels*ipy]<flat[ipx+1+nSubPixels*(ipy+1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>flat[ipx+1+nSubPixels*(ipy+1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||
}
|
||||
if (ipy<nSubPixels-1 ) {
|
||||
if (flat[ipx+nSubPixels*ipy]<flat[ipx+nSubPixels*(ipy+1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>flat[ipx+nSubPixels*(ipy+1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||
}
|
||||
if (ipx<nSubPixels-1) {
|
||||
if (flat[ipx+nSubPixels*ipy]<flat[ipx+1+nSubPixels*(ipy)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>flat[ipx+1+nSubPixels*(ipy)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||
}
|
||||
|
||||
if (ipy>0 ) {
|
||||
if (flat[ipx+nSubPixels*ipy]<flat[ipx+nSubPixels*(ipy-1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>flat[ipx+nSubPixels*(ipy-1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||
}
|
||||
|
||||
if (ipx>0 ) {
|
||||
if (flat[ipx+nSubPixels*ipy]<flat[ipx-1+nSubPixels*(ipy)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||
if (flat[ipx+nSubPixels*ipy]>flat[ipx-1+nSubPixels*(ipy)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||
}
|
||||
|
||||
// if (maskMin[ipx+nSubPixels*ipy]) cout << ipx << " " << ipy << " is a local minimum " << flat[ipx+nSubPixels*ipy] << endl;
|
||||
// if (maskMax[ipx+nSubPixels*ipy]) cout << ipx << " " << ipy << " is a local maximum "<< flat[ipx+nSubPixels*ipy] << endl;
|
||||
|
||||
}
|
||||
}
|
||||
int is_a_border=0;
|
||||
|
||||
//initialize the new partition to the previous one
|
||||
// int ibx_p, iby_p, ibx_n, iby_n;
|
||||
int ibbx, ibby;
|
||||
|
||||
|
||||
memcpy(newhhx,hhx,nbeta*nbeta*sizeof(float));
|
||||
memcpy(newhhy,hhy,nbeta*nbeta*sizeof(float));
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
|
||||
ippy=hhy[ibx+iby*nbeta]*nSubPixels;
|
||||
ippx=hhx[ibx+iby*nbeta]*nSubPixels;
|
||||
|
||||
|
||||
is_a_border=0;
|
||||
|
||||
if (maskMin[ippx+nSubPixels*ippy] || maskMax[ippx+nSubPixels*ippy]) {
|
||||
|
||||
|
||||
for (int ix=-1; ix<2; ix++) {
|
||||
ibbx=ibx+ix;
|
||||
if (ibbx<0) ibbx=0;
|
||||
if (ibbx>nbeta-1) ibbx=nbeta-1;
|
||||
for (int iy=-1; iy<2; iy++) {
|
||||
ibby=iby+iy;
|
||||
if (ibby<0) ibby=0;
|
||||
if (ibby>nbeta-1) ibby=nbeta-1;
|
||||
|
||||
|
||||
ipy=hhy[ibbx+ibby*nbeta]*nSubPixels;
|
||||
ipx=hhx[ibbx+ibby*nbeta]*nSubPixels;
|
||||
|
||||
|
||||
if (ipx!=ippx || ipy!=ippy) {
|
||||
is_a_border=1;
|
||||
if (maskMin[ippx+nSubPixels*ippy]) {
|
||||
//increase the region
|
||||
newhhx[ibbx+ibby*nbeta]=((double)ippx+0.5)/((double)nSubPixels);
|
||||
newhhy[ibbx+ibby*nbeta]=((double)ippy+0.5)/((double)nSubPixels);
|
||||
}
|
||||
if (maskMax[ippx+nSubPixels*ippy]) {
|
||||
//reduce the region
|
||||
newhhx[ibx+iby*nbeta]=((double)ipx+0.5)/((double)nSubPixels);
|
||||
newhhy[ibx+iby*nbeta]=((double)ipy+0.5)/((double)nSubPixels);
|
||||
}
|
||||
|
||||
// cout << ippx << " " << ippy << " " << ibx << " " << iby << " * " << ipx << " " << ipy << " " << ibbx << " " << ibby << endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Check that the resulting histograms are monotonic and they don't have holes!
|
||||
|
||||
for (int ibx=0; ibx<nbeta-1; ibx++) {
|
||||
for (int iby=0; iby<nbeta-1; iby++) {
|
||||
|
||||
ippy=newhhy[ibx+iby*nbeta]*nSubPixels;
|
||||
ippx=newhhx[ibx+iby*nbeta]*nSubPixels;
|
||||
|
||||
ipy=newhhy[ibx+(iby+1)*nbeta]*nSubPixels;
|
||||
ipx=newhhx[ibx+1+iby*nbeta]*nSubPixels;
|
||||
|
||||
if ( ippx>ipx)
|
||||
newhhx[ibx+1+iby*nbeta]=newhhx[ibx+iby*nbeta];
|
||||
else if (ipx >ippx+1)
|
||||
newhhx[ibx+1+iby*nbeta]=((double)(ippx+1+0.5))/((double)nSubPixels);
|
||||
|
||||
if ( ippy>ipy)
|
||||
newhhy[ibx+(iby+1)*nbeta]=newhhy[ibx+iby*nbeta];
|
||||
else if (ipy >ippy+1)
|
||||
newhhy[ibx+(iby+1)*nbeta]=((double)(ippy+1+0.5))/((double)nSubPixels);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
etaInterpolationCleverAdaptiveBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationAdaptiveBins(nx,ny,ns, nb, emin,emax){
|
||||
|
||||
|
||||
};
|
||||
|
||||
etaInterpolationCleverAdaptiveBins(etaInterpolationCleverAdaptiveBins *orig): etaInterpolationAdaptiveBins(orig){};
|
||||
|
||||
virtual etaInterpolationCleverAdaptiveBins* Clone()=0;
|
||||
|
||||
/* return new etaInterpolationCleverAdaptiveBins(this); */
|
||||
|
||||
/* }; */
|
||||
|
||||
|
||||
};
|
||||
|
||||
class eta2InterpolationCleverAdaptiveBins : public virtual eta2InterpolationBase, public virtual etaInterpolationCleverAdaptiveBins {
|
||||
public:
|
||||
eta2InterpolationCleverAdaptiveBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax),eta2InterpolationBase(nx,ny,ns, nb, emin,emax),etaInterpolationCleverAdaptiveBins(nx,ny,ns, nb, emin,emax){
|
||||
};
|
||||
|
||||
eta2InterpolationCleverAdaptiveBins(eta2InterpolationCleverAdaptiveBins *orig): etaInterpolationBase(orig), etaInterpolationCleverAdaptiveBins(orig) {};
|
||||
|
||||
virtual eta2InterpolationCleverAdaptiveBins* Clone() { return new eta2InterpolationCleverAdaptiveBins(this);};
|
||||
|
||||
// virtual int *getInterpolatedImage(){return eta2InterpolationBase::getInterpolatedImage();};
|
||||
|
||||
/* virtual int *getInterpolatedImage(){ */
|
||||
/* int ipx, ipy; */
|
||||
/* cout << "ff" << endl; */
|
||||
/* calcDiff(1, hhx, hhy); //get flat */
|
||||
/* double avg=0; */
|
||||
/* for (ipx=0; ipx<nSubPixels; ipx++) */
|
||||
/* for (ipy=0; ipy<nSubPixels; ipy++) */
|
||||
/* avg+=flat[ipx+ipy*nSubPixels]; */
|
||||
/* avg/=nSubPixels*nSubPixels; */
|
||||
|
||||
/* for (int ibx=0 ; ibx<nSubPixels*nPixelsX; ibx++) { */
|
||||
/* ipx=ibx%nSubPixels-nSubPixels; */
|
||||
/* if (ipx<0) ipx=nSubPixels+ipx; */
|
||||
/* for (int iby=0 ; iby<nSubPixels*nPixelsY; iby++) { */
|
||||
/* ipy=iby%nSubPixels-nSubPixels; */
|
||||
/* if (ipy<0) ipy=nSubPixels+ipy; */
|
||||
|
||||
/* if (flat[ipx+ipy*nSubPixels]>0) */
|
||||
/* hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX]*(avg/flat[ipx+ipy*nSubPixels]); */
|
||||
/* else */
|
||||
/* hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX]; */
|
||||
|
||||
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
|
||||
|
||||
/* return hintcorr; */
|
||||
/* }; */
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class eta3InterpolationCleverAdaptiveBins : public virtual eta3InterpolationBase, public virtual etaInterpolationCleverAdaptiveBins {
|
||||
public:
|
||||
eta3InterpolationCleverAdaptiveBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax),eta3InterpolationBase(nx,ny,ns, nb, emin,emax), etaInterpolationCleverAdaptiveBins(nx,ny,ns, nb, emin,emax){
|
||||
|
||||
};
|
||||
|
||||
eta3InterpolationCleverAdaptiveBins(eta3InterpolationCleverAdaptiveBins *orig): etaInterpolationBase(orig), etaInterpolationCleverAdaptiveBins(orig) {};
|
||||
|
||||
virtual eta3InterpolationCleverAdaptiveBins* Clone() { return new eta3InterpolationCleverAdaptiveBins(this);};
|
||||
};
|
||||
|
||||
#endif
|
@ -15,11 +15,11 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
||||
|
||||
etaInterpolationPosXY(etaInterpolationPosXY *orig): etaInterpolationBase(orig) {};
|
||||
|
||||
virtual etaInterpolationPosXY* Clone()=0;/** {
|
||||
virtual etaInterpolationPosXY* Clone()=0; /* { */
|
||||
|
||||
return new etaInterpolationPosXY(this);
|
||||
/* return new etaInterpolationPosXY(this); */
|
||||
|
||||
};*/
|
||||
/* }; */
|
||||
|
||||
virtual void prepareInterpolation(int &ok)
|
||||
{
|
||||
@ -51,16 +51,26 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
||||
double hix[nbeta]; //integral of projection x
|
||||
double hiy[nbeta]; //integral of projection y
|
||||
int ii=0;
|
||||
double etax, etay;
|
||||
for (int ib=0; ib<nbeta; ib++) {
|
||||
|
||||
tot_eta_x=0;
|
||||
tot_eta_y=0;
|
||||
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
hx[iby]=heta[iby+ib*nbeta];
|
||||
tot_eta_x+=hx[iby];
|
||||
hy[iby]=heta[ib+iby*nbeta];
|
||||
tot_eta_y+=hy[iby];
|
||||
etax=etamin+iby*etastep;
|
||||
//cout << etax << endl;
|
||||
if (etax>=0 && etax<=1)
|
||||
hx[iby]=heta[iby+ib*nbeta];
|
||||
else {
|
||||
hx[iby]=0;
|
||||
}
|
||||
// tot_eta_x+=hx[iby];
|
||||
if (etax>=0 && etax<=1)
|
||||
hy[iby]=heta[ib+iby*nbeta];
|
||||
else
|
||||
hy[iby]=0;
|
||||
// tot_eta_y+=hy[iby];
|
||||
}
|
||||
|
||||
hix[0]=hx[0];
|
||||
@ -72,22 +82,17 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
||||
}
|
||||
|
||||
ii=0;
|
||||
tot_eta_x=hix[nbeta-1]+1;
|
||||
tot_eta_y=hiy[nbeta-1]+1;
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
if (tot_eta_x==0) {
|
||||
hhx[ibx+ib*nbeta]=((float)ibx)/((float)nbeta);
|
||||
ii=(ibx)/nbeta;
|
||||
if (tot_eta_x<=0) {
|
||||
hhx[ibx+ib*nbeta]=-1;
|
||||
//ii=(ibx)/nbeta;
|
||||
} else //if (hix[ibx]>(ii+1)*tot_eta_x*bsize)
|
||||
{
|
||||
//ii++;
|
||||
// cout << ib << " x " << ibx << " " << tot_eta_x << " " << (ii)*tot_eta_x*bsize << " " << ii << endl;
|
||||
// }
|
||||
#ifdef MYROOT1
|
||||
hhx->SetBinContent(ibx+1,ib+1,ii);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
hhx[ibx+ib*nbeta]=hix[ibx]/((float)tot_eta_x);//ii;
|
||||
#endif
|
||||
//if (hix[ibx]>tot_eta_x*(ii+1)/nSubPixels) ii++;
|
||||
hhx[ibx+ib*nbeta]=hix[ibx]/tot_eta_x;
|
||||
}
|
||||
}
|
||||
/* if (ii!=(nSubPixels-1)) */
|
||||
@ -96,53 +101,55 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
||||
ii=0;
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
if (tot_eta_y==0) {
|
||||
hhx[ibx+ib*nbeta]=((float)ibx)/((float)nbeta);
|
||||
ii=(ibx*nSubPixels)/nbeta;
|
||||
} else //if (hiy[ibx]>(ii+1)*tot_eta_y*bsize)
|
||||
{
|
||||
//ii++;
|
||||
//cout << ib << " y " << ibx << " " << tot_eta_y << " "<< (ii)*tot_eta_y*bsize << " " << ii << endl;
|
||||
//}
|
||||
#ifdef MYROOT1
|
||||
hhy->SetBinContent(ib+1,ibx+1,ii);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
hhy[ib+ibx*nbeta]=hiy[ibx]/((float)tot_eta_y);//ii;
|
||||
#endif
|
||||
}
|
||||
if (tot_eta_y<=0) {
|
||||
hhy[ib+ibx*nbeta]=-1;
|
||||
//ii=(ibx*nSubPixels)/nbeta;
|
||||
} else {
|
||||
//if (hiy[ibx]>tot_eta_y*(ii+1)/nSubPixels) ii++;
|
||||
hhy[ib+ibx*nbeta]=hiy[ibx]/tot_eta_y;
|
||||
}
|
||||
}
|
||||
/* if (ii!=(nSubPixels-1)) */
|
||||
/* cout << ib << " y " << tot_eta_y << " " << (ii+1)*tot_eta_y*bsize << " " << ii << " " << hiy[nbeta-1]<< endl; */
|
||||
|
||||
// cout << "y " << nbeta << " " << (ii+1)*tot_eta_x*bsize << " " << ii << endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int ibx, iby, ib;
|
||||
|
||||
iby=0;
|
||||
while (hhx[iby*nbeta+nbeta/2]<0) iby++;
|
||||
for (ib=0; ib<iby;ib++) {
|
||||
for (ibx=0; ibx<nbeta;ibx++)
|
||||
hhx[ibx+nbeta*ib]=hhx[ibx+nbeta*iby];
|
||||
}
|
||||
iby=nbeta-1;
|
||||
|
||||
while (hhx[iby*nbeta+nbeta/2]<0) iby--;
|
||||
for (ib=iby+1; ib<nbeta;ib++) {
|
||||
for (ibx=0; ibx<nbeta;ibx++)
|
||||
hhx[ibx+nbeta*ib]=hhx[ibx+nbeta*iby];
|
||||
}
|
||||
|
||||
iby=0;
|
||||
while (hhy[nbeta/2*nbeta+iby]<0) iby++;
|
||||
for (ib=0; ib<iby;ib++) {
|
||||
for (ibx=0; ibx<nbeta;ibx++)
|
||||
hhy[ib+nbeta*ibx]=hhy[iby+nbeta*ibx];
|
||||
}
|
||||
iby=nbeta-1;
|
||||
|
||||
while (hhy[nbeta/2*nbeta+iby]<0) iby--;
|
||||
for (ib=iby+1; ib<nbeta;ib++) {
|
||||
for (ibx=0; ibx<nbeta;ibx++)
|
||||
hhy[ib+nbeta*ibx]=hhy[iby+nbeta*ibx];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef SAVE_ALL
|
||||
char tit[10000];
|
||||
|
||||
float *etah=new float[nbeta*nbeta];
|
||||
int etabins=nbeta;
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
etah[ii]=hhx[ii];
|
||||
}
|
||||
sprintf(tit,"/scratch/eta_hhx_%d.tiff",id);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
etah[ii]=hhy[ii];
|
||||
}
|
||||
sprintf(tit,"/scratch/eta_hhy_%d.tiff",id);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
etah[ii]=heta[ii];
|
||||
}
|
||||
sprintf(tit,"/scratch/eta_%d.tiff",id);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
delete [] etah;
|
||||
debugSaveAll();
|
||||
#endif
|
||||
return ;
|
||||
}
|
||||
@ -154,11 +161,15 @@ class eta2InterpolationPosXY : public virtual eta2InterpolationBase, public virt
|
||||
eta2InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax),eta2InterpolationBase(nx,ny,ns, nb, emin,emax),etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){
|
||||
// cout << "e2pxy " << nb << " " << emin << " " << emax << endl;
|
||||
};
|
||||
|
||||
eta2InterpolationPosXY(eta2InterpolationPosXY *orig): etaInterpolationBase(orig), etaInterpolationPosXY(orig) {};
|
||||
|
||||
virtual eta2InterpolationPosXY* Clone() { return new eta2InterpolationPosXY(this);};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class eta3InterpolationPosXY : public virtual eta3InterpolationBase, public virtual etaInterpolationPosXY {
|
||||
public:
|
||||
eta3InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax),eta3InterpolationBase(nx,ny,ns, nb, emin,emax), etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){
|
||||
|
@ -40,6 +40,20 @@ class linearInterpolation : public slsInterpolation{
|
||||
return;
|
||||
};
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y)
|
||||
{
|
||||
double sDum[2][2];
|
||||
double tot, totquad;
|
||||
double etax,etay;
|
||||
|
||||
int corner;
|
||||
corner=calcQuad(data, tot, totquad, sDum);
|
||||
if (nSubPixels>2)
|
||||
calcEta(totquad, sDum, etax, etay);
|
||||
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) {
|
||||
|
||||
@ -78,6 +92,7 @@ class linearInterpolation : public slsInterpolation{
|
||||
cc[1][1]=cluster[yoff+1][xoff+1];
|
||||
calcEta(totquad,cc,eta_x,eta_y);
|
||||
}
|
||||
// cout << x << " " << y << " " << eta_x << " " << eta_y << " " << int_x << " " << int_y << endl;
|
||||
return getInterpolatedPosition(x,y,eta_x, eta_y,quad,int_x,int_y);
|
||||
|
||||
|
||||
@ -86,6 +101,49 @@ class linearInterpolation : public slsInterpolation{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) {
|
||||
|
||||
double cc[2][2];
|
||||
int *cluster[3];
|
||||
int xoff, yoff;
|
||||
cluster[0]=cl;
|
||||
cluster[1]=cl+3;
|
||||
cluster[2]=cl+6;
|
||||
|
||||
switch (quad) {
|
||||
case BOTTOM_LEFT:
|
||||
xoff=0;
|
||||
yoff=0;
|
||||
break;
|
||||
case BOTTOM_RIGHT:
|
||||
xoff=1;
|
||||
yoff=0;
|
||||
break;
|
||||
case TOP_LEFT:
|
||||
xoff=0;
|
||||
yoff=1;
|
||||
break;
|
||||
case TOP_RIGHT:
|
||||
xoff=1;
|
||||
yoff=1;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
double etax, etay;
|
||||
if (nSubPixels>2) {
|
||||
cc[0][0]=cluster[yoff][xoff];
|
||||
cc[1][0]=cluster[yoff+1][xoff];
|
||||
cc[0][1]=cluster[yoff][xoff+1];
|
||||
cc[1][1]=cluster[yoff+1][xoff+1];
|
||||
calcEta(totquad,cc,etax,etay);
|
||||
}
|
||||
// cout << x << " " << y << " " << etax << " " << etay << " " << int_x << " " << int_y << endl;
|
||||
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -125,11 +183,11 @@ class linearInterpolation : public slsInterpolation{
|
||||
ypos_eta=(etay)+dY;
|
||||
} else {
|
||||
xpos_eta=0.5*dX+0.25;
|
||||
xpos_eta=0.5*dY+0.25;
|
||||
ypos_eta=0.5*dY+0.25;
|
||||
}
|
||||
int_x=((double)x) + xpos_eta;
|
||||
int_y=((double)y) + ypos_eta;
|
||||
|
||||
// cout <<"**"<< x << " " << y << " " << xpos_eta << " " << ypos_eta << " " << corner << endl;
|
||||
return;
|
||||
};
|
||||
|
||||
@ -162,8 +220,10 @@ class linearInterpolation : public slsInterpolation{
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual int addToFlatField(double *cluster, double &etax, double &etay){};
|
||||
virtual int addToFlatField(int *cluster, double &etax, double &etay){};
|
||||
virtual int addToFlatField(double etax, double etay){};
|
||||
virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) {};
|
||||
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) {};
|
||||
|
||||
protected:
|
||||
;
|
||||
|
@ -93,7 +93,7 @@ class noInterpolation : public slsInterpolation{
|
||||
|
||||
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay){return 0;};
|
||||
|
||||
|
||||
virtual void resetFlatField(){};
|
||||
protected:
|
||||
;
|
||||
// TRandom *eventGenerator;
|
||||
|
@ -1,12 +1,6 @@
|
||||
#ifndef SLS_INTERPOLATION_H
|
||||
#define SLS_INTERPOLATION_H
|
||||
|
||||
#ifdef MYROOT1
|
||||
#include <TObject.h>
|
||||
#include <TTree.h>
|
||||
#include <TH2F.h>
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
#ifndef MY_TIFF_IO_H
|
||||
#include "tiffIO.h"
|
||||
@ -24,7 +18,10 @@
|
||||
#endif
|
||||
#include <memory.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
//#ifdef MYROOT1
|
||||
//: public TObject
|
||||
//#endif
|
||||
@ -34,13 +31,7 @@ class slsInterpolation
|
||||
public:
|
||||
slsInterpolation(int nx=400, int ny=400, int ns=25) :nPixelsX(nx), nPixelsY(ny), nSubPixels(ns), id(0) {
|
||||
|
||||
#ifdef MYROOT1
|
||||
hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
#endif
|
||||
|
||||
#ifndef MYROOT1
|
||||
hint=new int[ns*nx*ns*ny];
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
@ -48,23 +39,30 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
nPixelsX=orig->nPixelsX;
|
||||
nPixelsY=orig->nPixelsY;
|
||||
nSubPixels=orig->nSubPixels;
|
||||
#ifdef MYROOT1
|
||||
hint=(TH2F*)(orig->hint)->Clone("hint");
|
||||
#endif
|
||||
|
||||
#ifndef MYROOT1
|
||||
hint=new int[nSubPixels*nPixelsX*nSubPixels*nPixelsY];
|
||||
memcpy(hint, orig->hint,nSubPixels*nPixelsX*nSubPixels*nPixelsY*sizeof(int));
|
||||
#endif
|
||||
hint=new int[nSubPixels*nPixelsX*nSubPixels*nPixelsY];
|
||||
memcpy(hint, orig->hint,nSubPixels*nPixelsX*nSubPixels*nPixelsY*sizeof(int));
|
||||
|
||||
};
|
||||
|
||||
virtual int setId(int i) {id=i; return id;};
|
||||
|
||||
virtual slsInterpolation* Clone() = 0;
|
||||
virtual slsInterpolation* Clone() =0; /*{
|
||||
return new slsInterpolation(this);
|
||||
}*/
|
||||
|
||||
int getNSubPixels() {return nSubPixels;};
|
||||
|
||||
|
||||
int setNSubPixels(int ns) {
|
||||
if (ns>0 && ns!=nSubPixels) {
|
||||
delete [] hint;
|
||||
nSubPixels=ns;
|
||||
hint=new int[nSubPixels*nPixelsX*nSubPixels*nPixelsY];
|
||||
}
|
||||
return nSubPixels;
|
||||
}
|
||||
|
||||
int getImageSize(int &nnx, int &nny, int &ns) {
|
||||
nnx=nSubPixels*nPixelsX;
|
||||
nny=nSubPixels*nPixelsY;
|
||||
@ -79,13 +77,13 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
|
||||
//create interpolated image
|
||||
//returns interpolated image
|
||||
#ifdef MYROOT1
|
||||
virtual TH2F *getInterpolatedImage(){return hint;};
|
||||
#endif
|
||||
|
||||
#ifndef MYROOT1
|
||||
virtual int *getInterpolatedImage(){return hint;};
|
||||
#endif
|
||||
virtual int *getInterpolatedImage(){
|
||||
// cout << "return interpolated image " << endl;
|
||||
/* for (int i=0; i<nSubPixels* nSubPixels* nPixelsX*nPixelsY; i++) { */
|
||||
/* cout << i << " " << hint[i] << endl; */
|
||||
/* } */
|
||||
return hint;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -93,11 +91,12 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
void *writeInterpolatedImage(const char * imgname) {
|
||||
//cout << "!" <<endl;
|
||||
float *gm=NULL;
|
||||
int *dummy=getInterpolatedImage();
|
||||
gm=new float[ nSubPixels* nSubPixels* nPixelsX*nPixelsY];
|
||||
if (gm) {
|
||||
for (int ix=0; ix<nPixelsX*nSubPixels; ix++) {
|
||||
for (int iy=0; iy<nPixelsY*nSubPixels; iy++) {
|
||||
gm[iy*nPixelsX*nSubPixels+ix]=hint[iy*nPixelsX*nSubPixels+ix];
|
||||
gm[iy*nPixelsX*nSubPixels+ix]=dummy[iy*nPixelsX*nSubPixels+ix];
|
||||
}
|
||||
}
|
||||
WriteToTiff(gm, imgname,nSubPixels* nPixelsX ,nSubPixels* nPixelsY);
|
||||
@ -121,16 +120,11 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
virtual void clearInterpolatedImage() {
|
||||
|
||||
|
||||
#ifdef MYROOT1
|
||||
hint->Reset();
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
for (int ix=0; ix<nPixelsX*nSubPixels; ix++) {
|
||||
for (int iy=0; iy<nPixelsY*nSubPixels; iy++) {
|
||||
hint[iy*nPixelsX*nSubPixels+ix]=0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
};
|
||||
@ -138,19 +132,18 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
|
||||
|
||||
|
||||
#ifdef MYROOT1
|
||||
TH2F *addToImage(double int_x, double int_y){hint->Fill(int_x, int_y); return hint;};
|
||||
#endif
|
||||
|
||||
#ifndef MYROOT1
|
||||
virtual int *addToImage(double int_x, double int_y){
|
||||
int iy=((double)nSubPixels)*int_y;
|
||||
int ix=((double)nSubPixels)*int_x;
|
||||
// cout << int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << endl;
|
||||
if (ix>=0 && ix<(nPixelsX*nSubPixels) && iy<(nSubPixels*nPixelsY) && iy>=0 )(*(hint+ix+iy*nPixelsX*nSubPixels))+=1;
|
||||
if (ix>=0 && ix<(nPixelsX*nSubPixels) && iy<(nSubPixels*nPixelsY) && iy>=0 ){
|
||||
// cout << int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << " " << hint[ix+iy*nPixelsX*nSubPixels];
|
||||
(*(hint+ix+iy*nPixelsX*nSubPixels))+=1;
|
||||
// cout << " " << hint[ix+iy*nPixelsX*nSubPixels] << endl;
|
||||
}// else
|
||||
// cout << "bad! "<< int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << endl;
|
||||
|
||||
return hint;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
virtual int addToFlatField(double *cluster, double &etax, double &etay)=0;
|
||||
@ -159,19 +152,13 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
virtual int addToFlatField(double totquad,int quad,double *cluster,double &etax, double &etay)=0;
|
||||
virtual int addToFlatField(double etax, double etay)=0;
|
||||
|
||||
#ifdef MYROOT1
|
||||
virtual TH2D *getFlatField(){return NULL;};
|
||||
virtual TH2D *setFlatField(TH2D *h, int nb=-1, double emin=-1, double emax=-1){return NULL;};
|
||||
virtual TH2D *getFlatField(int &nb, double &emin, double &emax){nb=0; emin=0; emax=0; return getFlatField();};
|
||||
#endif
|
||||
|
||||
#ifndef MYROOT1
|
||||
virtual int *getFlatField(){return NULL;};
|
||||
virtual int *setFlatField(int *h, int nb=-1, double emin=-1, double emax=-1){return NULL;};
|
||||
void *writeFlatField(const char * imgname){return NULL;};
|
||||
void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){return NULL;};
|
||||
virtual void *writeFlatField(const char * imgname){return NULL;};
|
||||
virtual void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){return NULL;};
|
||||
virtual int *getFlatField(int &nb, double &emin, double &emax){nb=0; emin=0; emax=0; return getFlatField();};
|
||||
#endif
|
||||
|
||||
virtual void resetFlatField()=0;
|
||||
|
||||
//virtual void Streamer(TBuffer &b);
|
||||
|
||||
@ -187,10 +174,10 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
static int calcQuad(double *cl, double &sum, double &totquad, double sDum[2][2]){
|
||||
|
||||
int corner = UNDEFINED_QUADRANT;
|
||||
double *cluster[3];
|
||||
cluster[0]=cl;
|
||||
cluster[1]=cl+3;
|
||||
cluster[2]=cl+6;
|
||||
/* double *cluster[3]; */
|
||||
/* cluster[0]=cl; */
|
||||
/* cluster[1]=cl+3; */
|
||||
/* cluster[2]=cl+6; */
|
||||
|
||||
sum=0;
|
||||
double sumBL=0;
|
||||
@ -200,11 +187,11 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
int xoff=0, yoff=0;
|
||||
for (int ix=0; ix<3; ix++) {
|
||||
for (int iy=0; iy<3; iy++) {
|
||||
sum+=cluster[iy][ix];
|
||||
if (ix<=1 && iy<=1) sumBL+=cluster[iy][ix];
|
||||
if (ix<=1 && iy>=1) sumTL+=cluster[iy][ix];
|
||||
if (ix>=1 && iy<=1) sumBR+=cluster[iy][ix];
|
||||
if (ix>=1 && iy>=1) sumTR+=cluster[iy][ix];
|
||||
sum+=cl[ix+3*iy];
|
||||
if (ix<=1 && iy<=1) sumBL+=cl[ix+iy*3];
|
||||
if (ix<=1 && iy>=1) sumTL+=cl[ix+iy*3];
|
||||
if (ix>=1 && iy<=1) sumBR+=cl[ix+iy*3];
|
||||
if (ix>=1 && iy>=1) sumTR+=cl[ix+iy*3];
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,6 +199,8 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
/* sDum[0][1] = cluster[0][1]; sDum[1][1] = cluster[1][1]; */
|
||||
corner = BOTTOM_LEFT;
|
||||
totquad=sumBL;
|
||||
xoff=0;
|
||||
yoff=0;
|
||||
|
||||
|
||||
if(sumTL >= totquad){
|
||||
@ -246,7 +235,7 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
|
||||
for (int ix=0; ix<2; ix++) {
|
||||
for (int iy=0; iy<2; iy++) {
|
||||
sDum[iy][ix] = cluster[iy+yoff][ix+xoff];
|
||||
sDum[iy][ix] = cl[ix+xoff+(iy+yoff)*3];
|
||||
}
|
||||
}
|
||||
|
||||
@ -368,7 +357,7 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
// int quad;
|
||||
for (int ix=0; ix<3; ix++) {
|
||||
for (int iy=0; iy<3; iy++) {
|
||||
val=cl[iy+3*ix];
|
||||
val=cl[ix+3*iy];
|
||||
sum+=val;
|
||||
if (iy==0) l+=val;
|
||||
if (iy==2) r+=val;
|
||||
@ -412,92 +401,92 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
}
|
||||
|
||||
|
||||
static int calcMyEta(double totquad, int quad, double *cl, double &etax, double &etay) {
|
||||
double l,r,t,b, sum;
|
||||
int yoff;
|
||||
switch (quad) {
|
||||
case BOTTOM_LEFT:
|
||||
case BOTTOM_RIGHT:
|
||||
yoff=0;
|
||||
break;
|
||||
case TOP_LEFT:
|
||||
case TOP_RIGHT:
|
||||
yoff=1;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
l=cl[0+yoff*3]+cl[0+yoff*3+3];
|
||||
r=cl[2+yoff*3]+cl[2+yoff*3+3];
|
||||
b=cl[0+yoff*3]+cl[1+yoff*3]*cl[2+yoff*3];
|
||||
t=cl[0+yoff*3+3]+cl[1+yoff*3+3]*cl[0+yoff*3+3];
|
||||
sum=t+b;
|
||||
if (sum>0) {
|
||||
etax=(-l+r)/sum;
|
||||
etay=(+t)/sum;
|
||||
}
|
||||
/* static int calcMyEta(double totquad, int quad, double *cl, double &etax, double &etay) { */
|
||||
/* double l,r,t,b, sum; */
|
||||
/* int yoff; */
|
||||
/* switch (quad) { */
|
||||
/* case BOTTOM_LEFT: */
|
||||
/* case BOTTOM_RIGHT: */
|
||||
/* yoff=0; */
|
||||
/* break; */
|
||||
/* case TOP_LEFT: */
|
||||
/* case TOP_RIGHT: */
|
||||
/* yoff=1; */
|
||||
/* break; */
|
||||
/* default: */
|
||||
/* ; */
|
||||
/* } */
|
||||
/* l=cl[0+yoff*3]+cl[0+yoff*3+3]; */
|
||||
/* r=cl[2+yoff*3]+cl[2+yoff*3+3]; */
|
||||
/* b=cl[0+yoff*3]+cl[1+yoff*3]*cl[2+yoff*3]; */
|
||||
/* t=cl[0+yoff*3+3]+cl[1+yoff*3+3]*cl[0+yoff*3+3]; */
|
||||
/* sum=t+b; */
|
||||
/* if (sum>0) { */
|
||||
/* etax=(-l+r)/sum; */
|
||||
/* etay=(+t)/sum; */
|
||||
/* } */
|
||||
|
||||
return -1;
|
||||
}
|
||||
/* return -1; */
|
||||
/* } */
|
||||
|
||||
static int calcMyEta(double totquad, int quad, int *cl, double &etax, double &etay) {
|
||||
double l,r,t,b, sum;
|
||||
int yoff;
|
||||
switch (quad) {
|
||||
case BOTTOM_LEFT:
|
||||
case BOTTOM_RIGHT:
|
||||
yoff=0;
|
||||
break;
|
||||
case TOP_LEFT:
|
||||
case TOP_RIGHT:
|
||||
yoff=1;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
l=cl[0+yoff*3]+cl[0+yoff*3+3];
|
||||
r=cl[2+yoff*3]+cl[2+yoff*3+3];
|
||||
b=cl[0+yoff*3]+cl[1+yoff*3]*cl[2+yoff*3];
|
||||
t=cl[0+yoff*3+3]+cl[1+yoff*3+3]*cl[0+yoff*3+3];
|
||||
sum=t+b;
|
||||
if (sum>0) {
|
||||
etax=(-l+r)/sum;
|
||||
etay=(+t)/sum;
|
||||
}
|
||||
/* static int calcMyEta(double totquad, int quad, int *cl, double &etax, double &etay) { */
|
||||
/* double l,r,t,b, sum; */
|
||||
/* int yoff; */
|
||||
/* switch (quad) { */
|
||||
/* case BOTTOM_LEFT: */
|
||||
/* case BOTTOM_RIGHT: */
|
||||
/* yoff=0; */
|
||||
/* break; */
|
||||
/* case TOP_LEFT: */
|
||||
/* case TOP_RIGHT: */
|
||||
/* yoff=1; */
|
||||
/* break; */
|
||||
/* default: */
|
||||
/* ; */
|
||||
/* } */
|
||||
/* l=cl[0+yoff*3]+cl[0+yoff*3+3]; */
|
||||
/* r=cl[2+yoff*3]+cl[2+yoff*3+3]; */
|
||||
/* b=cl[0+yoff*3]+cl[1+yoff*3]*cl[2+yoff*3]; */
|
||||
/* t=cl[0+yoff*3+3]+cl[1+yoff*3+3]*cl[0+yoff*3+3]; */
|
||||
/* sum=t+b; */
|
||||
/* if (sum>0) { */
|
||||
/* etax=(-l+r)/sum; */
|
||||
/* etay=(+t)/sum; */
|
||||
/* } */
|
||||
|
||||
return -1;
|
||||
}
|
||||
/* return -1; */
|
||||
/* } */
|
||||
|
||||
|
||||
|
||||
static int calcEta3X(double *cl, double &etax, double &etay, double &sum) {
|
||||
double l,r,t,b;
|
||||
sum=cl[0]+cl[1]+cl[2]+cl[3]+cl[4]+cl[5]+cl[6]+cl[7]+cl[8];
|
||||
if (sum>0) {
|
||||
l=cl[3];
|
||||
r=cl[5];
|
||||
b=cl[1];
|
||||
t=cl[7];
|
||||
etax=(-l+r)/sum;
|
||||
etay=(-b+t)/sum;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
/* static int calcEta3X(double *cl, double &etax, double &etay, double &sum) { */
|
||||
/* double l,r,t,b; */
|
||||
/* sum=cl[0]+cl[1]+cl[2]+cl[3]+cl[4]+cl[5]+cl[6]+cl[7]+cl[8]; */
|
||||
/* if (sum>0) { */
|
||||
/* l=cl[3]; */
|
||||
/* r=cl[5]; */
|
||||
/* b=cl[1]; */
|
||||
/* t=cl[7]; */
|
||||
/* etax=(-l+r)/sum; */
|
||||
/* etay=(-b+t)/sum; */
|
||||
/* } */
|
||||
/* return -1; */
|
||||
/* } */
|
||||
|
||||
|
||||
static int calcEta3X(int *cl, double &etax, double &etay, double &sum) {
|
||||
double l,r,t,b;
|
||||
sum=cl[0]+cl[1]+cl[2]+cl[3]+cl[4]+cl[5]+cl[6]+cl[7]+cl[8];
|
||||
if (sum>0) {
|
||||
l=cl[3];
|
||||
r=cl[5];
|
||||
b=cl[1];
|
||||
t=cl[7];
|
||||
etax=(-l+r)/sum;
|
||||
etay=(-b+t)/sum;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
/* static int calcEta3X(int *cl, double &etax, double &etay, double &sum) { */
|
||||
/* double l,r,t,b; */
|
||||
/* sum=cl[0]+cl[1]+cl[2]+cl[3]+cl[4]+cl[5]+cl[6]+cl[7]+cl[8]; */
|
||||
/* if (sum>0) { */
|
||||
/* l=cl[3]; */
|
||||
/* r=cl[5]; */
|
||||
/* b=cl[1]; */
|
||||
/* t=cl[7]; */
|
||||
/* etax=(-l+r)/sum; */
|
||||
/* etay=(-b+t)/sum; */
|
||||
/* } */
|
||||
/* return -1; */
|
||||
/* } */
|
||||
|
||||
|
||||
|
||||
@ -507,14 +496,8 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
protected:
|
||||
int nPixelsX, nPixelsY;
|
||||
int nSubPixels;
|
||||
#ifdef MYROOT1
|
||||
TH2F *hint;
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
int *hint;
|
||||
#endif
|
||||
int id;
|
||||
|
||||
int *hint;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,34 @@
|
||||
#module add CBFlib/0.9.5
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include
|
||||
|
||||
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -pthread -lrt -ltiff -O3
|
||||
|
||||
MAIN=moench03ClusterFinder.cpp
|
||||
|
||||
|
||||
all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
|
||||
|
||||
|
||||
|
||||
moenchClusterFinder: moench03ClusterFinder.cpp $(INCS) clean
|
||||
g++ -o moenchClusterFinder moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER
|
||||
|
||||
moenchMakeEta: moench03Interpolation.cpp $(INCS) clean
|
||||
g++ -o moenchMakeEta moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF
|
||||
|
||||
moenchInterpolation: moench03Interpolation.cpp $(INCS) clean
|
||||
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
|
||||
|
||||
moenchNoInterpolation: moench03NoInterpolation.cpp $(INCS) clean
|
||||
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
|
||||
|
||||
moenchPhotonCounter: moenchPhotonCounter.cpp $(INCS) clean
|
||||
g++ -o moenchPhotonCounter moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER
|
||||
|
||||
moenchAnalog: moenchPhotonCounter.cpp $(INCS) clean
|
||||
g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG
|
||||
|
||||
clean:
|
||||
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
|
||||
|
||||
|
@ -2,15 +2,20 @@
|
||||
CBFLIBDIR=/afs/psi.ch/project/sls_det_software/CBFlib-0.9.5
|
||||
ZMQLIB=../../slsReceiverSoftware/include
|
||||
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
INCDIR=-I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -I../interpolations/etaVEL -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/
|
||||
INCDIR=-I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/
|
||||
LIBHDF5=
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff -L$(ZMQLIB)
|
||||
#-I../interpolations/etaVEL
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -lhdf5 -ltiff -L$(ZMQLIB) -L$(CBFLIBDIR)/lib/ -O3
|
||||
#-L../../bin
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moenchZmqClusterFinder moenchZmqInterpolating
|
||||
aaa: moenchZmqProcess
|
||||
|
||||
all: moenchZmqClusterFinder moenchZmqInterpolating moenchZmqAnalog
|
||||
|
||||
moenchZmqProcess: moenchZmqProcess.cpp $(INCS) clean
|
||||
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ
|
||||
|
||||
moenchZmqInterpolating: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchZmqInterpolating moenchZmqInterpolating.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
@ -18,6 +23,10 @@ moenchZmqInterpolating: $(MAIN) $(INCS) clean
|
||||
moenchZmqClusterFinder: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchZmqClusterFinder moenchZmqClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
clean:
|
||||
rm -f moench03ZmqOnTheFlyEta moench03ZmqClusterFinder
|
||||
moenchZmqAnalog: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchZmqAnalog moenchZmqAnalog.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
clean:
|
||||
rm -f moench03ZmqInterpolating moench03ZmqClusterFinder moenchZmqAnalog moenchZmqProcess
|
||||
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
|
||||
ZMQLIB=../../slsReceiverSoftware/include
|
||||
INCDIR= -I$(ZMQLIB) -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -L$(ZMQLIB) -O3 -g
|
||||
#-L../../bin -lhdf5 -L.
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moenchZmqProcess
|
||||
|
||||
moenchZmqProcess: moenchZmqProcess.cpp clean
|
||||
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
|
||||
|
||||
clean:
|
||||
rm -f moenchZmqProcess
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
|
||||
CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
|
||||
#ZMQLIB=../slsReceiverSoftware/include
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/
|
||||
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff
|
||||
MAIN=moench03ReorderImage.cpp
|
||||
|
||||
all: moenchReorderImage moenchClusterFinder
|
||||
|
||||
|
||||
|
||||
moenchReorderImage: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchReorderImage $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER
|
||||
|
||||
moenchClusterFinder: moench03ClusterFinder.cpp
|
||||
g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER
|
||||
|
||||
|
||||
clean:
|
||||
rm -f moenchReorderImage moenchClusterFinder
|
||||
|
||||
|
@ -2,12 +2,14 @@
|
||||
#INCS= $(INCSROOT) moench03_receiver.h
|
||||
#LINKDEF=receiverGuiLinkDef.h
|
||||
|
||||
CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
|
||||
ZMQLIB=../slsReceiverSoftware/include
|
||||
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I$(ROOTSYS)/include
|
||||
#CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
|
||||
#ZMQLIB=../slsReceiverSoftware/include
|
||||
#LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(ROOTSYS)/include
|
||||
#-I$(CBFLIBDIR)/include/
|
||||
#LIBHDF5=
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -ltiff
|
||||
#-L$(CBFLIBDIR)/lib/ -lhdf5
|
||||
|
||||
MAIN=tiff_to_th2f.cpp
|
||||
|
||||
@ -18,8 +20,8 @@ all: tiff_to_th2f
|
||||
|
||||
tiff_to_th2f: $(MAIN) $(INCS)
|
||||
|
||||
g++ -o tiff_to_th2f $(MAIN) `root-config --cflags --glibs` -lMinuit -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) ../tiffIO.cpp
|
||||
|
||||
g++ -o tiff_to_th2f $(MAIN) `root-config --cflags --glibs` -lMinuit -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) ../tiffIO.cpp
|
||||
#$(LIBRARYCBF) $(LIBHDF5)
|
||||
clean:
|
||||
rm -f tiff_to_th2f
|
||||
|
||||
|
@ -2,11 +2,19 @@
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
#ifdef NEWRECEIVER
|
||||
#ifndef RECT
|
||||
#include "moench03T1ReceiverDataNew.h"
|
||||
#endif
|
||||
|
||||
#ifdef RECT
|
||||
#include "moench03T1ReceiverDataNewRect.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CSAXS_FP
|
||||
#include "moench03T1ReceiverData.h"
|
||||
#endif
|
||||
@ -14,6 +22,10 @@
|
||||
#include "moench03Ctb10GbT1Data.h"
|
||||
#endif
|
||||
|
||||
#ifdef REORDERED
|
||||
#include "moench03T1ReorderedData.h"
|
||||
#endif
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
@ -40,7 +52,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=8;
|
||||
int nthreads=1;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
@ -58,6 +70,9 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
#ifdef NEWRECEIVER
|
||||
#ifdef RECT
|
||||
cout << "Should be rectangular!" <<endl;
|
||||
#endif
|
||||
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
|
||||
cout << "RECEIVER DATA WITH ONE HEADER!"<<endl;
|
||||
#endif
|
||||
@ -72,6 +87,14 @@ int main(int argc, char *argv[]) {
|
||||
cout << "OLD RECEIVER DATA!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef REORDERED
|
||||
moench03T1ReorderedData *decoder=new moench03T1ReorderedData();
|
||||
cout << "REORDERED DATA!"<<endl;
|
||||
#endif
|
||||
|
||||
|
||||
decoder->getDetectorSize(nx,ny);
|
||||
cout << "nx " << nx << " ny " << ny << endl;
|
||||
|
||||
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
|
||||
@ -135,6 +158,7 @@ int main(int argc, char *argv[]) {
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
mt->setDetectorMode(ePhotonCounting);
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
@ -171,11 +195,18 @@ int main(int argc, char *argv[]) {
|
||||
// cout << "*"<<ifr++<<"*"<<ff<< endl;
|
||||
// cout << ff << " " << np << endl;
|
||||
// //push
|
||||
mt->pushData(buff);
|
||||
// for (int ix=0; ix<400; ix++)
|
||||
// for (int iy=0; iy<400; iy++) {
|
||||
// if (decoder->getChannel(buff, ix, iy)<3000 || decoder->getChannel(buff, ix, iy)>8000) {
|
||||
// cout << ifr << " " << ff << " " << ix << " " << iy << " " << decoder->getChannel(buff, ix, iy) << endl ;
|
||||
// }
|
||||
// }
|
||||
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
mt->nextThread();
|
||||
mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr%10000==0) cout << ifr << " " << ff << endl;
|
||||
ff=-1;
|
||||
|
@ -30,9 +30,10 @@ int main(int argc, char *argv[]) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl;
|
||||
return 0;
|
||||
}
|
||||
int ii=0;
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=1;
|
||||
int nthreads=5;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
@ -165,6 +166,14 @@ int main(int argc, char *argv[]) {
|
||||
mt->popFree(buff);
|
||||
|
||||
ff=-1;
|
||||
ii++;
|
||||
if (ii%10000==0) {
|
||||
|
||||
cout << ii << endl;
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
mt->writeImage("/scratch/tmp.tiff");
|
||||
}
|
||||
}
|
||||
// cout << "--" << endl;
|
||||
filebin.close();
|
||||
|
@ -14,39 +14,61 @@
|
||||
#include "single_photon_hit.h"
|
||||
#endif
|
||||
|
||||
#include "etaInterpolationPosXY.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
#include "noInterpolation.h"
|
||||
//#include "etaInterpolationAdaptiveBins.h"
|
||||
#include "etaInterpolationCleverAdaptiveBins.h"
|
||||
//#include "etaInterpolationRandomBins.h"
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
|
||||
#define MAX_ITERATIONS (nSubPixels*100)
|
||||
|
||||
#define XTALK
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FF
|
||||
if (argc<9) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " etafile outfile runmin runmax ns cmin cmax" << endl;
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile outfile runmin runmax ns cmin cmax" << endl;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FF
|
||||
if (argc<7) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile runmin runmax cmin cmax" << endl;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
int iarg=4;
|
||||
char infname[10000];
|
||||
char fname[10000];
|
||||
char outfname[10000];
|
||||
int runmin=atoi(argv[4]);
|
||||
int runmax=atoi(argv[5]);
|
||||
int nsubpix=atoi(argv[6]);
|
||||
float cmin=atof(argv[7]);
|
||||
float cmax=atof(argv[8]);
|
||||
#ifndef FF
|
||||
iarg=4;
|
||||
#endif
|
||||
|
||||
#ifdef FF
|
||||
iarg=3;
|
||||
#endif
|
||||
int runmin=atoi(argv[iarg++]);
|
||||
int runmax=atoi(argv[iarg++]);
|
||||
cout << "Run min: " << runmin << endl;
|
||||
cout << "Run max: " << runmax << endl;
|
||||
|
||||
int nsubpix=4;
|
||||
#ifndef FF
|
||||
nsubpix=atoi(argv[iarg++]);
|
||||
cout << "Subpix: " << nsubpix << endl;
|
||||
#endif
|
||||
float cmin=atof(argv[iarg++]);
|
||||
float cmax=atof(argv[iarg++]);
|
||||
cout << "Energy min: " << cmin << endl;
|
||||
cout << "Energy max: " << cmax << endl;
|
||||
//int etabins=500;
|
||||
int etabins=1000;//nsubpix*2*100;
|
||||
double etamin=-1, etamax=2;
|
||||
//double etamin=-0.1, etamax=1.1;
|
||||
double eta3min=-2, eta3max=2;
|
||||
int quad;
|
||||
double sum, totquad;
|
||||
@ -58,9 +80,6 @@ int main(int argc, char *argv[]) {
|
||||
int ix, iy, isx, isy;
|
||||
int nframes=0, lastframe=-1;
|
||||
double d_x, d_y, res=5, xx, yy;
|
||||
#ifdef MANYFILES
|
||||
int ff=1000;
|
||||
#endif
|
||||
int nph=0, badph=0, totph=0;
|
||||
FILE *f=NULL;
|
||||
|
||||
@ -72,32 +91,29 @@ int main(int argc, char *argv[]) {
|
||||
single_photon_hit cl(3,3);
|
||||
#endif
|
||||
|
||||
#ifdef XTALK
|
||||
int old_val[3][3];
|
||||
int new_val[3][3];
|
||||
double xcorr=0.04;
|
||||
|
||||
// int ix=0;
|
||||
int nSubPixels=nsubpix;
|
||||
#ifndef NOINTERPOLATION
|
||||
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
//eta2InterpolationCleverAdaptiveBins *interp=new eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
#endif
|
||||
#ifdef NOINTERPOLATION
|
||||
noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
#endif
|
||||
|
||||
|
||||
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
eta3InterpolationPosXY *interp3=new eta3InterpolationPosXY(NC, NR, nsubpix, etabins, eta3min, eta3max);
|
||||
noInterpolation *dummy=new noInterpolation(NC, NR, nsubpix);
|
||||
noInterpolation *nointerp=new noInterpolation(NC, NR, nsubpix);
|
||||
noInterpolation *mult=new noInterpolation(NC, NR, nsubpix);
|
||||
//etaInterpolationAdaptiveBins *interp=new etaInterpolationAdaptiveBins (NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
//etaInterpolationRandomBins *interp=new etaInterpolationRandomBins (NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
//#ifndef FF
|
||||
cout << "read ff " << argv[2] << endl;
|
||||
sprintf(fname,"%s_eta2.tiff",argv[2]);
|
||||
interp->readFlatField(fname);
|
||||
interp->prepareInterpolation(ok);
|
||||
|
||||
sprintf(fname,"%s_eta3.tiff",argv[2]);
|
||||
interp3->readFlatField(fname);
|
||||
interp3->prepareInterpolation(ok);
|
||||
//#endif
|
||||
#ifndef FF
|
||||
#ifndef NOINTERPOLATION
|
||||
cout << "read ff " << argv[2] << endl;
|
||||
sprintf(fname,"%s",argv[2]);
|
||||
interp->readFlatField(fname);
|
||||
interp->prepareInterpolation(ok);//, MAX_ITERATIONS);
|
||||
#endif
|
||||
// return 0;
|
||||
#endif
|
||||
#ifdef FF
|
||||
cout << "Will write eta file " << argv[2] << endl;
|
||||
#endif
|
||||
|
||||
int *img;
|
||||
float *totimg=new float[NC*NR*nsubpix*nsubpix];
|
||||
@ -110,20 +126,18 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FF
|
||||
|
||||
float ff[nsubpix*nsubpix];
|
||||
float *ffimg=new float[NC*NR*nsubpix*nsubpix];
|
||||
float totff=0;
|
||||
|
||||
|
||||
sprintf(outfname,argv[2]);
|
||||
#endif
|
||||
|
||||
int irun;
|
||||
for (irun=runmin; irun<runmax; irun++) {
|
||||
sprintf(infname,argv[1],irun);
|
||||
#ifndef MANYFILES
|
||||
#ifndef FF
|
||||
sprintf(outfname,argv[3],irun);
|
||||
#endif
|
||||
|
||||
f=fopen(infname,"r");
|
||||
if (f) {
|
||||
cout << infname << endl;
|
||||
@ -138,185 +152,98 @@ int main(int argc, char *argv[]) {
|
||||
// f0=cl.iframe;
|
||||
if (nframes==0) f0=lastframe;
|
||||
nframes++;
|
||||
#ifdef MANYFILES
|
||||
if (nframes%ff==0) {
|
||||
sprintf(outfname,argv[3],irun,nframes-ff);
|
||||
cout << outfname << endl;
|
||||
interp->writeInterpolatedImage(outfname);
|
||||
interp->clearInterpolatedImage();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
#ifdef XTALK
|
||||
if ((cl.x+1)%25!=0) {
|
||||
for (int ix=-1; ix<2; ix++) {
|
||||
for (int iy=-1; iy<2; iy++) {
|
||||
old_val[iy+1][ix+1]=cl.get_data(ix,iy);
|
||||
if (ix>=0) {
|
||||
new_val[iy+1][ix+1]=old_val[iy+1][ix+1]-old_val[iy+1][ix]*xcorr;
|
||||
cl.set_data(new_val[iy+1][ix+1],ix,iy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
||||
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && totquad<cmax && quad<cmax) {
|
||||
nph++;
|
||||
// if (sum>200 && sum<580) {
|
||||
// interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y);
|
||||
interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
|
||||
//quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
||||
quad=interp->calcEta(cl.get_cluster(), etax, etay, sum, totquad, sDum);
|
||||
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && sum<cmax ) {
|
||||
nph++;
|
||||
// if (sum>200 && sum<580) {
|
||||
// interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y);
|
||||
// #ifdef SOLEIL
|
||||
// if (cl.x>210 && cl.x<240 && cl.y>210 && cl.y<240) {
|
||||
// #endif
|
||||
#ifndef FF
|
||||
// interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
|
||||
interp->getInterpolatedPosition(cl.x,cl.y, etax, etay, quad,int_x, int_y);
|
||||
// cout <<"**************"<< endl;
|
||||
// cout << cl.x << " " << cl.y << " " << sum << endl;
|
||||
// cl.print();
|
||||
// cout << int_x << " " << int_y << endl;
|
||||
// cout <<"**************"<< endl;
|
||||
// if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
|
||||
interp->addToImage(int_x, int_y);
|
||||
interp3->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int3_x, int3_y);
|
||||
interp3->addToImage(int3_x, int3_y);
|
||||
nointerp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),noint_x, noint_y);
|
||||
nointerp->addToImage(noint_x, noint_y);
|
||||
|
||||
|
||||
d_x= (int_x-int3_x)*25.;
|
||||
d_y= (int_y-int3_y)*25.;
|
||||
dummy->calcEta(totquad, sDum, etax, etay);
|
||||
xx=int_x;
|
||||
yy=int_y;
|
||||
if (etax<0.1 || etax>0.9) xx=int3_x;
|
||||
if (etay<0.1 || etay>0.9) yy=int3_y;
|
||||
dummy->addToImage(xx,yy);
|
||||
|
||||
if (d_x>res || d_x<-res || d_y>res || d_y<-res) {
|
||||
badph++;
|
||||
// cout << "delta (um): "<< d_x << " " << d_y << " " << cl.x << " " << cl.y << endl;
|
||||
// cout << sum << " " << totquad << " " << etax << " "<< etay << endl;
|
||||
// //cout<< int_x << " " << int_y << " " << int3_x << " " << int3_y << endl;
|
||||
if (int_x<0 || int_y<0 || int_x>400 || int_y>400) {
|
||||
cout <<"**************"<< endl;
|
||||
cout << cl.x << " " << cl.y << " " << sum << endl;
|
||||
cl.print();
|
||||
cout << int_x << " " << int_y << endl;
|
||||
cout <<"**************"<< endl;
|
||||
}
|
||||
mult->addToImage(noint_x, noint_y);
|
||||
#endif
|
||||
#ifdef FF
|
||||
// interp->addToFlatField(cl.get_cluster(), etax, etay);
|
||||
// #ifdef UCL
|
||||
// if (cl.x>50)
|
||||
// #endif
|
||||
// if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
|
||||
interp->addToFlatField(etax, etay);
|
||||
// if (etax==0 || etay==0) cout << cl.x << " " << cl.y << endl;
|
||||
|
||||
if (nph%1000000==0) cout << nph << endl;
|
||||
if (nph%100000000==0) {
|
||||
sprintf(outfname,"%s_inteta2.tiff", argv[3]);
|
||||
#endif
|
||||
// #ifdef SOLEIL
|
||||
// }
|
||||
// #endif
|
||||
|
||||
if (nph%1000000==0) cout << nph << endl;
|
||||
if (nph%10000000==0) {
|
||||
#ifndef FF
|
||||
interp->writeInterpolatedImage(outfname);
|
||||
sprintf(outfname,"%s_inteta3.tiff", argv[3]);
|
||||
interp3->writeInterpolatedImage(outfname);
|
||||
sprintf(outfname,"%s_mix.tiff", argv[3]);
|
||||
dummy->writeInterpolatedImage(outfname);
|
||||
sprintf(outfname,"%s_noint.tiff", argv[3]);
|
||||
nointerp->writeInterpolatedImage(outfname);
|
||||
sprintf(outfname,"%s_mult.tiff", argv[3]);
|
||||
mult->writeInterpolatedImage(outfname);
|
||||
}
|
||||
|
||||
} else {
|
||||
mult->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
|
||||
for (int imult=0; imult<2.*sum/(cmax+cmin); imult++) mult->addToImage(int_x, int_y);
|
||||
}
|
||||
#endif
|
||||
#ifdef FF
|
||||
interp->writeFlatField(outfname);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
fclose(f);
|
||||
#ifdef FF
|
||||
interp->writeFlatField(outfname);
|
||||
#endif
|
||||
|
||||
#ifndef FF
|
||||
interp->writeInterpolatedImage(outfname);
|
||||
|
||||
img=interp->getInterpolatedImage();
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
ff[isy*nsubpix+isx]=0;
|
||||
}
|
||||
}
|
||||
totff=0;
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR-100; iy++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
ff[isy*nsubpix+isx]+=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
totff+=ff[isy*nsubpix+isx];
|
||||
}
|
||||
}
|
||||
totff/=nsubpix*nsubpix;
|
||||
|
||||
|
||||
if (totff) {
|
||||
|
||||
cout << "ff: " << totff << endl;
|
||||
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
ff[isy*nsubpix+isx]/=totff;
|
||||
cout << ff[isy*nsubpix+isx] << "\t";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
ffimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]/ff[isy*nsubpix+isx];
|
||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]+=ffimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
|
||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]+=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << "writing eta!" << endl;
|
||||
WriteToTiff(ffimg, outfname,NC*nsubpix,NR*nsubpix);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
#ifndef FF
|
||||
|
||||
#ifdef MANYFILES
|
||||
sprintf(outfname,argv[3],irun,nframes-ff);
|
||||
cout << outfname << endl;
|
||||
#endif
|
||||
sprintf(outfname,"%s_inteta2.tiff", argv[3]);
|
||||
interp->writeInterpolatedImage(outfname);
|
||||
sprintf(outfname,"%s_inteta3.tiff", argv[3]);
|
||||
interp3->writeInterpolatedImage(outfname);
|
||||
sprintf(outfname,"%s_mix.tiff", argv[3]);
|
||||
dummy->writeInterpolatedImage(outfname);
|
||||
sprintf(outfname,"%s_mult.tiff", argv[3]);
|
||||
mult->writeInterpolatedImage(outfname);
|
||||
|
||||
#ifndef MANYFILES
|
||||
img=interp->getInterpolatedImage();
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]+=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
cout << "Read " << nframes << " frames (first frame: " << f0 << " last frame: " << lastframe << " delta:" << lastframe-f0 << ")"<<endl;
|
||||
cout << "Read " << nframes << " frames (first frame: " << f0 << " last frame: " << lastframe << " delta:" << lastframe-f0 << ") nph="<< nph <<endl;
|
||||
interp->clearInterpolatedImage();
|
||||
interp3->clearInterpolatedImage();
|
||||
dummy->clearInterpolatedImage();
|
||||
mult->clearInterpolatedImage();
|
||||
#endif
|
||||
|
||||
} else
|
||||
cout << "could not open file " << infname << endl;
|
||||
}
|
||||
cout << irun << " " << runmax << endl;
|
||||
#ifndef MANYFILES
|
||||
#ifndef FF
|
||||
sprintf(outfname,argv[3],11111);
|
||||
WriteToTiff(totimg, outfname,NC*nsubpix,NR*nsubpix);
|
||||
#endif
|
||||
cout << "Filled " << nph << " (/"<< totph <<") of which " << badph << " badly interpolated " << endl;
|
||||
|
||||
#ifdef FF
|
||||
interp->writeFlatField(outfname);
|
||||
#endif
|
||||
|
||||
cout << "Filled " << nph << " (/"<< totph <<") " << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,269 @@
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
//#define DOUBLE_SPH
|
||||
//#define MANYFILES
|
||||
|
||||
#ifdef DOUBLE_SPH
|
||||
#include "single_photon_hit_double.h"
|
||||
#endif
|
||||
|
||||
#ifndef DOUBLE_SPH
|
||||
#include "single_photon_hit.h"
|
||||
#endif
|
||||
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
#include "noInterpolation.h"
|
||||
#include "etaInterpolationCleverAdaptiveBins.h"
|
||||
//#include "etaInterpolationRandomBins.h"
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
#define MAX_ITERATIONS (nSubPixels*100)
|
||||
#define MAX_EBINS 100
|
||||
#define XTALK
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
#ifndef FF
|
||||
if (argc<9) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile outfile runmin runmax ns cmin cmax" << endl;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FF
|
||||
if (argc<7) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile runmin runmax cmin cmax" << endl;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
int iarg=4;
|
||||
char infname[10000];
|
||||
char fname[10000];
|
||||
char outfname[10000];
|
||||
#ifndef FF
|
||||
iarg=4;
|
||||
#endif
|
||||
|
||||
#ifdef FF
|
||||
iarg=3;
|
||||
#endif
|
||||
int runmin=atoi(argv[iarg++]);
|
||||
int runmax=atoi(argv[iarg++]);
|
||||
cout << "Run min: " << runmin << endl;
|
||||
cout << "Run max: " << runmax << endl;
|
||||
|
||||
int nsubpix=4;
|
||||
#ifndef FF
|
||||
nsubpix=atoi(argv[iarg++]);
|
||||
cout << "Subpix: " << nsubpix << endl;
|
||||
#endif
|
||||
float cmin=atof(argv[iarg++]);
|
||||
float cmax=atof(argv[iarg++]);
|
||||
cout << "Energy min: " << cmin << endl;
|
||||
cout << "Energy max: " << cmax << endl;
|
||||
int n_ebins=1;
|
||||
if (argc>iarg)
|
||||
n_ebins=atoi(argv[iarg++]);
|
||||
//int etabins=500;
|
||||
int etabins=1000;//nsubpix*2*100;
|
||||
double etamin=-1, etamax=2;
|
||||
//double etamin=-0.1, etamax=1.1;
|
||||
double eta3min=-2, eta3max=2;
|
||||
int quad;
|
||||
double sum, totquad;
|
||||
double sDum[2][2];
|
||||
double etax, etay, int_x, int_y;
|
||||
double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y;
|
||||
int ok;
|
||||
int f0=-1;
|
||||
int ix, iy, isx, isy;
|
||||
int nframes=0, lastframe=-1;
|
||||
double d_x, d_y, res=5, xx, yy;
|
||||
int nph=0, badph=0, totph=0;
|
||||
FILE *f=NULL;
|
||||
|
||||
#ifdef DOUBLE_SPH
|
||||
single_photon_hit_double cl(3,3);
|
||||
#endif
|
||||
|
||||
#ifndef DOUBLE_SPH
|
||||
single_photon_hit cl(3,3);
|
||||
#endif
|
||||
|
||||
int nSubPixels=nsubpix;
|
||||
|
||||
int iebin=0;
|
||||
double eb_size=(cmax-cmin)/n_ebins;
|
||||
#ifndef NOINTERPOLATION
|
||||
// eta2InterpolationPosXY *interp[MAX_EBINS];
|
||||
eta2InterpolationCleverAdaptiveBins *interp[MAX_EBINS];
|
||||
for (int i=0; i< n_ebins; i++) {
|
||||
//interp[i]=new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
interp[i]=new eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
}
|
||||
#endif
|
||||
#ifdef NOINTERPOLATION
|
||||
noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef FF
|
||||
#ifndef NOINTERPOLATION
|
||||
cout << "read ff " << argv[2] << endl;
|
||||
for (int i=0; i< n_ebins; i++) {
|
||||
sprintf(fname,argv[2],i);
|
||||
interp[i]->readFlatField(fname);
|
||||
interp[i]->prepareInterpolation(ok);//, MAX_ITERATIONS);
|
||||
}
|
||||
#endif
|
||||
// return 0;
|
||||
#endif
|
||||
#ifdef FF
|
||||
cout << "Will write eta file " << argv[2] << endl;
|
||||
#endif
|
||||
|
||||
int *img;
|
||||
float *totimg=new float[NC*NR*nsubpix*nsubpix];
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FF
|
||||
sprintf(outfname,argv[2]);
|
||||
#endif
|
||||
|
||||
int irun;
|
||||
for (irun=runmin; irun<runmax; irun++) {
|
||||
sprintf(infname,argv[1],irun);
|
||||
#ifndef FF
|
||||
sprintf(outfname,argv[3],irun);
|
||||
#endif
|
||||
|
||||
f=fopen(infname,"r");
|
||||
if (f) {
|
||||
cout << infname << endl;
|
||||
nframes=0;
|
||||
f0=-1;
|
||||
|
||||
while (cl.read(f)) {
|
||||
totph++;
|
||||
if (lastframe!=cl.iframe) {
|
||||
lastframe=cl.iframe;
|
||||
// cout << cl.iframe << endl;
|
||||
// f0=cl.iframe;
|
||||
if (nframes==0) f0=lastframe;
|
||||
nframes++;
|
||||
}
|
||||
//quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
||||
quad=interp[0]->calcEta(cl.get_cluster(), etax, etay, sum, totquad, sDum);
|
||||
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && sum<cmax ) {
|
||||
nph++;
|
||||
iebin=(sum-cmin)/eb_size;
|
||||
if (iebin>=0 && iebin<n_ebins) {
|
||||
// if (sum>200 && sum<580) {
|
||||
// interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y);
|
||||
// #ifdef SOLEIL
|
||||
// if (cl.x>210 && cl.x<240 && cl.y>210 && cl.y<240) {
|
||||
// #endif
|
||||
#ifndef FF
|
||||
// interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
|
||||
interp[iebin]->getInterpolatedPosition(cl.x,cl.y, etax, etay, quad,int_x, int_y);
|
||||
// cout <<"**************"<< endl;
|
||||
// cout << cl.x << " " << cl.y << " " << sum << endl;
|
||||
// cl.print();
|
||||
// cout << int_x << " " << int_y << endl;
|
||||
// cout <<"**************"<< endl;
|
||||
if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
|
||||
interp[iebin]->addToImage(int_x, int_y);
|
||||
#endif
|
||||
#ifdef FF
|
||||
// interp->addToFlatField(cl.get_cluster(), etax, etay);
|
||||
#ifdef UCL
|
||||
if (cl.x>50)
|
||||
#endif
|
||||
if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
|
||||
interp[iebin]->addToFlatField(etax, etay);
|
||||
// if (etax==0 || etay==0) cout << cl.x << " " << cl.y << endl;
|
||||
|
||||
#endif
|
||||
// #ifdef SOLEIL
|
||||
// }
|
||||
// #endif
|
||||
|
||||
if (nph%1000000==0) cout << nph << endl;
|
||||
if (nph%10000000==0) {
|
||||
#ifndef FF
|
||||
for (int i=0; i<n_ebins; i++) {
|
||||
sprintf(outfname,argv[3],i);
|
||||
interp[i]->writeInterpolatedImage(outfname);
|
||||
}
|
||||
#endif
|
||||
#ifdef FF
|
||||
for (int i=0; i<n_ebins; i++) {
|
||||
sprintf(outfname,argv[2],i);
|
||||
cout << outfname << " " << argv[2] << " " << i << endl;
|
||||
interp[i]->writeFlatField(outfname);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
fclose(f);
|
||||
#ifdef FF
|
||||
for (int i=0; i<n_ebins; i++) {
|
||||
sprintf(outfname,argv[2],i);
|
||||
cout << outfname << " " << argv[2] << " " << i << endl;
|
||||
interp[i]->writeFlatField(outfname);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FF
|
||||
for (int i=0; i<n_ebins; i++) {
|
||||
sprintf(outfname,argv[3],i,irun);
|
||||
interp[i]->writeInterpolatedImage(outfname);
|
||||
img=interp[i]->getInterpolatedImage();
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]+=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//interp[i]->clearInterpolatedImage();
|
||||
}
|
||||
cout << "Read " << nframes << " frames (first frame: " << f0 << " last frame: " << lastframe << " delta:" << lastframe-f0 << ")"<<endl;
|
||||
#endif
|
||||
|
||||
} else
|
||||
cout << "could not open file " << infname << endl;
|
||||
}
|
||||
#ifndef FF
|
||||
sprintf(outfname,argv[3], 11111);
|
||||
WriteToTiff(totimg, outfname,NC*nsubpix,NR*nsubpix);
|
||||
#endif
|
||||
|
||||
#ifdef FF
|
||||
interp[iebin]->writeFlatField(outfname);
|
||||
#endif
|
||||
|
||||
cout << "Filled " << nph << " (/"<< totph <<") " << endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,163 @@
|
||||
//#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
|
||||
#include "moench03T1ReceiverDataNew.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <ctime>
|
||||
using namespace std;
|
||||
|
||||
#define NX 400 //number of x pixels
|
||||
#define NY 400 //number of y pixels
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
if (argc<6) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl;
|
||||
return 1;
|
||||
}
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=8;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
|
||||
|
||||
|
||||
|
||||
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
|
||||
|
||||
|
||||
uint16_t data[NY*NX];
|
||||
|
||||
|
||||
int* image;
|
||||
|
||||
int ff, np;
|
||||
int dsize=decoder->getDataSize();
|
||||
|
||||
|
||||
//char data[dsize];
|
||||
|
||||
ifstream filebin;
|
||||
char *indir=argv[1];
|
||||
char *outdir=argv[2];
|
||||
char *fformat=argv[3];
|
||||
int runmin=atoi(argv[4]);
|
||||
int runmax=atoi(argv[5]);
|
||||
|
||||
char fname[10000];
|
||||
char outfname[10000];
|
||||
// strcpy(pedfname,argv[6]);
|
||||
char fn[10000];
|
||||
|
||||
std::time_t end_time;
|
||||
|
||||
FILE *of=NULL;
|
||||
cout << "input directory is " << indir << endl;
|
||||
cout << "output directory is " << outdir << endl;
|
||||
cout << "fileformat is " << fformat << endl;
|
||||
|
||||
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char buff[dsize];
|
||||
|
||||
|
||||
|
||||
|
||||
int ifr=0;
|
||||
|
||||
|
||||
for (int irun=runmin; irun<runmax; irun++) {
|
||||
sprintf(fn,fformat,irun);
|
||||
sprintf(fname,"%s/%s.raw",indir,fn);
|
||||
sprintf(outfname,"%s/%s_image.raw",outdir,fn);
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
// cout << fname << " " << outfname << " " << imgfname << endl;
|
||||
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||
// //open file
|
||||
if (filebin.is_open()){
|
||||
of=fopen(outfname,"w");
|
||||
if (of) {
|
||||
;
|
||||
} else {
|
||||
cout << "Could not open "<< outfname << " for writing " << endl;
|
||||
return 1;
|
||||
}
|
||||
// //while read frame
|
||||
ff=-1;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
for (int ix=0; ix<400; ix++) {
|
||||
for (int iy=0; iy<400; iy++) {
|
||||
data[iy*400+ix]=decoder->getChannel(buff,ix,iy);
|
||||
if (data[iy*NX+ix]<3000 || data[iy*NX+ix]>8000) {
|
||||
cout << ifr << " " << ff << " " << ix << " " << iy << " " << data[iy*NX+ix] << " " << decoder->getChannel(buff,ix,iy) << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
ifr++;
|
||||
|
||||
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
|
||||
|
||||
if (ifr%10000==0) cout << ifr << " " << ff << endl;
|
||||
ff=-1;
|
||||
// break;
|
||||
}
|
||||
cout << "--" << endl;
|
||||
filebin.close();
|
||||
// //close file
|
||||
// //join threads
|
||||
|
||||
if (of)
|
||||
fclose(of);
|
||||
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,272 +0,0 @@
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
#include "interpolatingDetector.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=20;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
char outfname[10000];
|
||||
|
||||
|
||||
moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
// cout << "decoder "<< endl;
|
||||
//etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
|
||||
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
|
||||
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
//interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 100);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
|
||||
char tit[10000];
|
||||
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
char* buff;
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
//mt->setFrameMode(eFrame);
|
||||
mt->setFrameMode(eFlat);
|
||||
|
||||
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// help
|
||||
if (argc < 2 || (argc > 2)) {
|
||||
cprintf(RED, "Help: %s [receive socket ip]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip = argv[1];
|
||||
uint32_t portnum = 30001;//atoi(argv[2]);
|
||||
// char fn[10000];
|
||||
// strcpy(fn, argv[2]);
|
||||
// send parameters if any
|
||||
// char* socketip2 = 0;
|
||||
// uint32_t portnum2 = 0;
|
||||
// if (argc > 4) {
|
||||
// send = true;
|
||||
// socketip2 = argv[4];
|
||||
// portnum2 = atoi(argv[5]);
|
||||
// }
|
||||
cout << "\nrx socket ip : " << socketip ; // <<
|
||||
// "\nrx port num : " << portnum <<
|
||||
// "\nsize : " << size;
|
||||
// "\nfname : " << fn ;
|
||||
// if (send) {
|
||||
// cout << "\nsd socket ip : " << socketip2 <<
|
||||
// "\nsd port num : " << portnum2;
|
||||
// }
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
// ZmqSocket* zmqsocket2 = 0;
|
||||
// if (send) {
|
||||
// zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
// if (zmqsocket2->IsError()) {
|
||||
// bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
// delete zmqsocket2;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
// }
|
||||
|
||||
|
||||
// cout << "size " << 327680/sizeof(int) << endl;
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
string filename = "";
|
||||
int nnx, nny, nns;
|
||||
int imsize=filter->getImageSize(nnx,nny,nns);
|
||||
//int imsize=nx*ny;
|
||||
int i_image=0;
|
||||
cout << "Image size is "<< nnx << " " << nny << " " << nns << " " << imsize << endl;
|
||||
int iframe=0;
|
||||
int ff=0;
|
||||
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// cprintf(GREEN, "Got ?\n");
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
|
||||
cprintf(RED, "Acquisition finished\n");
|
||||
|
||||
|
||||
|
||||
cout << "Received " << ff << " frames for a total of "<< iframe << endl;
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
// if (send) {
|
||||
// zmqsocket2->SendData((char*)(mt->getImage()),imsize*sizeof(int));
|
||||
// cprintf(BLUE, "Sent Interpolated image\n");
|
||||
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// // cprintf(RED, "Sent Dummy\n");
|
||||
// }
|
||||
// if (save) {
|
||||
sprintf(tit,"%s_%05d.tiff",filename.c_str(), ff);
|
||||
// cout << tit << endl;
|
||||
mt->writeImage(tit);
|
||||
mt->clearImage();
|
||||
// }
|
||||
// sprintf(tit,"%s_%05d_eta_i.tiff",filename.c_str(), ff);
|
||||
// interp->writeFlatField(tit);
|
||||
// sprintf(tit,"%s_%05d_eta.tiff",filename.c_str(), ff);
|
||||
// cout << tit << endl;
|
||||
// mt->writeFlatField(tit);
|
||||
|
||||
i_image++;
|
||||
ff=0;
|
||||
// dont get data
|
||||
continue; //continue to not get out
|
||||
}
|
||||
|
||||
if (ff==0)
|
||||
cprintf(GREEN, "Start acquisition \n");
|
||||
// cout << filename << endl;
|
||||
// cprintf(GREEN, "Got Header \n");
|
||||
// get data
|
||||
// cprintf(GREEN, "Got Header\n");
|
||||
//image=(int*)buff;
|
||||
//cout << buff << endl;
|
||||
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
|
||||
// int length = zmqsocket->ReceiveData(0, (int*)image, size);
|
||||
// cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
iframe++;
|
||||
ff++;
|
||||
// if (iframe%p==0) {
|
||||
|
||||
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
// sprintf(tit,"tmp.tiff",filename.c_str(), i_image);
|
||||
// mt->writeImage(tit);
|
||||
// // mt->clearImage();
|
||||
// // }
|
||||
// //interp->writeFlatField(tit);
|
||||
// // i_image++;
|
||||
// // sprintf(tit,"%s_tmp.tiff",fn);
|
||||
// // mt->writeImage(tit);
|
||||
// // //mt->clearImage();
|
||||
|
||||
// // cout <<"*"<< iprog++ << endl;
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //stream data from socket 2
|
||||
// if (send) {
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
|
||||
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
// cprintf(GREEN, "Sent Header\n");
|
||||
|
||||
// zmqsocket2->SendData((char*)image,length);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
// }
|
||||
|
||||
|
||||
}// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
// if (send)
|
||||
// delete zmqsocket2;
|
||||
|
||||
|
||||
// cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,306 +0,0 @@
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
#include "interpolatingDetector.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
|
||||
int p=1000; //1.5s with 15ms period
|
||||
int fifosize=1000;
|
||||
int nthreads=8;
|
||||
int nsubpix=2;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
char outfname[10000];
|
||||
|
||||
if (nsubpix>2) p=5000;
|
||||
|
||||
|
||||
moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
// cout << "decoder "<< endl;
|
||||
etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
|
||||
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
|
||||
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 100);
|
||||
// singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
|
||||
char tit[10000];
|
||||
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
char* buff;
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
//
|
||||
if (nsubpix>2)
|
||||
mt->setFrameMode(eFlat);
|
||||
else
|
||||
mt->setFrameMode(eFrame);
|
||||
|
||||
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// help
|
||||
if (argc < 2 || (argc > 2)) {
|
||||
cprintf(RED, "Help: %s [receive socket ip]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip = argv[1];
|
||||
uint32_t portnum = 30001;//atoi(argv[2]);
|
||||
// char fn[10000];
|
||||
// strcpy(fn, argv[2]);
|
||||
// send parameters if any
|
||||
// char* socketip2 = 0;
|
||||
// uint32_t portnum2 = 0;
|
||||
// if (argc > 4) {
|
||||
// send = true;
|
||||
// socketip2 = argv[4];
|
||||
// portnum2 = atoi(argv[5]);
|
||||
// }
|
||||
cout << "\nrx socket ip : " << socketip ; // <<
|
||||
// "\nrx port num : " << portnum <<
|
||||
// "\nsize : " << size;
|
||||
// "\nfname : " << fn ;
|
||||
// if (send) {
|
||||
// cout << "\nsd socket ip : " << socketip2 <<
|
||||
// "\nsd port num : " << portnum2;
|
||||
// }
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
// ZmqSocket* zmqsocket2 = 0;
|
||||
// if (send) {
|
||||
// zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
// if (zmqsocket2->IsError()) {
|
||||
// bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
// delete zmqsocket2;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
// }
|
||||
|
||||
|
||||
// cout << "size " << 327680/sizeof(int) << endl;
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
string filename = "";
|
||||
int nnx, nny, nns;
|
||||
int imsize=filter->getImageSize(nnx,nny,nns);
|
||||
//int imsize=nx*ny;
|
||||
int i_image=0;
|
||||
cout << "Image size is "<< nnx << " " << nny << " " << nns << " " << imsize << endl;
|
||||
int iframe=0;
|
||||
int ff=0;
|
||||
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// cprintf(GREEN, "Got ?\n");
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
|
||||
cprintf(RED, "Acquisition finished\n");
|
||||
|
||||
|
||||
|
||||
cout << "Received " << ff << " frames for a total of "<< iframe << endl;
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
// if (send) {
|
||||
// zmqsocket2->SendData((char*)(mt->getImage()),imsize*sizeof(int));
|
||||
// cprintf(BLUE, "Sent Interpolated image\n");
|
||||
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// // cprintf(RED, "Sent Dummy\n");
|
||||
// }
|
||||
// if (save) {
|
||||
// if (iframe>p) {
|
||||
sprintf(tit,"%s_%05d_%05d.tiff",filename.c_str(), ff, i_image);
|
||||
cout << tit << endl;
|
||||
mt->writeImage(tit);
|
||||
sprintf(tit,"/home/l_msdetect/slsbl/x07mb/x07mbop/Data1/2017/11/06/tmp.tiff");
|
||||
cout <<"*"<< iframe<< endl;
|
||||
mt->writeImage(tit);
|
||||
mt->clearImage();
|
||||
//}
|
||||
|
||||
|
||||
|
||||
// }
|
||||
//sprintf(tit,"%s_%05d_eta_i.tiff",filename.c_str(), ff);
|
||||
//interp->writeFlatField(tit);
|
||||
// sprintf(tit,"%s_%05d_eta_%d.tiff",filename.c_str(), ff, acqIndex);
|
||||
// // cout << tit << endl;
|
||||
// mt->writeFlatField(tit);
|
||||
|
||||
i_image++;
|
||||
ff=0;
|
||||
//filter->newDataSet();
|
||||
|
||||
// dont get data
|
||||
continue; //continue to not get out
|
||||
}
|
||||
|
||||
if (ff==0)
|
||||
cprintf(GREEN, "Start acquisition %d\n",acqIndex);
|
||||
// cout << filename << endl;
|
||||
// cprintf(GREEN, "Got Header \n");
|
||||
// get data
|
||||
// cprintf(GREEN, "Got Header\n");
|
||||
//image=(int*)buff;
|
||||
//cout << buff << endl;
|
||||
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
|
||||
// int length = zmqsocket->ReceiveData(0, (int*)image, size);
|
||||
// cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
iframe++;
|
||||
if (nsubpix>2) {
|
||||
if (iframe==p) {
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->prepareInterpolation(ok);
|
||||
|
||||
sprintf(tit,"%s_%05d_eta.tiff",filename.c_str(), ff);
|
||||
cout << tit << endl;
|
||||
mt->writeFlatField(tit);
|
||||
}
|
||||
} //else {
|
||||
// cout << iframe << " " << p << endl;
|
||||
if (iframe%p==0) {
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
sprintf(tit,"/home/l_msdetect/slsbl/x07mb/x07mbop/Data1/2017/11/06/tmp.tiff");
|
||||
cout <<"*"<< iframe<< endl;
|
||||
mt->writeImage(tit);
|
||||
// mt->clearImage();
|
||||
}
|
||||
//}
|
||||
ff++;
|
||||
// if (iframe%p==0) {
|
||||
|
||||
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
// sprintf(tit,"tmp.tiff",filename.c_str(), i_image);
|
||||
// mt->writeImage(tit);
|
||||
// // mt->clearImage();
|
||||
// // }
|
||||
// //interp->writeFlatField(tit);
|
||||
// // i_image++;
|
||||
// // sprintf(tit,"%s_tmp.tiff",fn);
|
||||
// // mt->writeImage(tit);
|
||||
// // //mt->clearImage();
|
||||
|
||||
// // cout <<"*"<< iprog++ << endl;
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //stream data from socket 2
|
||||
// if (send) {
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
|
||||
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
// cprintf(GREEN, "Sent Header\n");
|
||||
|
||||
// zmqsocket2->SendData((char*)image,length);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
// }
|
||||
|
||||
|
||||
}// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
// if (send)
|
||||
// delete zmqsocket2;
|
||||
|
||||
|
||||
// cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,251 +0,0 @@
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
//#include "singlePhotonDetector.h"
|
||||
#include "interpolatingDetector.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
|
||||
int p=1000;
|
||||
int fifosize=1000;
|
||||
int nthreads=6;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
char outfname[10000];
|
||||
|
||||
|
||||
moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
// cout << "decoder "<< endl;
|
||||
etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
|
||||
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
|
||||
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
// interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 100);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
|
||||
char tit[10000];
|
||||
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
char* buff;
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
mt->setFrameMode(eFrame);
|
||||
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// help
|
||||
if (argc < 3 || (argc > 3)) {
|
||||
cprintf(RED, "Help: %s [receive socket ip] [fname]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip = argv[1];
|
||||
uint32_t portnum = 30001;//atoi(argv[2]);
|
||||
char fn[10000];
|
||||
strcpy(fn, argv[2]);
|
||||
// send parameters if any
|
||||
// char* socketip2 = 0;
|
||||
// uint32_t portnum2 = 0;
|
||||
// if (argc > 4) {
|
||||
// send = true;
|
||||
// socketip2 = argv[4];
|
||||
// portnum2 = atoi(argv[5]);
|
||||
// }
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
// "\nrx port num : " << portnum <<
|
||||
// "\nsize : " << size;
|
||||
"\nfname : " << fn ;
|
||||
// if (send) {
|
||||
// cout << "\nsd socket ip : " << socketip2 <<
|
||||
// "\nsd port num : " << portnum2;
|
||||
// }
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
// ZmqSocket* zmqsocket2 = 0;
|
||||
// if (send) {
|
||||
// zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
// if (zmqsocket2->IsError()) {
|
||||
// bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
// delete zmqsocket2;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
// }
|
||||
|
||||
|
||||
cout << "size " << 327680/sizeof(int) << endl;
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
string filename = "";
|
||||
int nnx, nny, nns;
|
||||
int imsize=filter->getImageSize(nnx,nny,nns);
|
||||
//int imsize=nx*ny;
|
||||
int i_image=0;
|
||||
cout << "Image size is "<< nnx << " " << nny << " " << nns << " " << imsize << endl;
|
||||
int iframe=0;
|
||||
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// cprintf(GREEN, "Got ?\n");
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
|
||||
cprintf(RED, "Acquisition finished\n");
|
||||
|
||||
|
||||
|
||||
cout << "Recieved " << iframe << " frames " << endl;
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
// if (send) {
|
||||
// zmqsocket2->SendData((char*)(mt->getImage()),imsize*sizeof(int));
|
||||
// cprintf(BLUE, "Sent Interpolated image\n");
|
||||
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// // cprintf(RED, "Sent Dummy\n");
|
||||
// }
|
||||
// if (save) {
|
||||
sprintf(tit,"%s_%d.tiff",fn, i_image);
|
||||
mt->writeImage(tit);
|
||||
mt->clearImage();
|
||||
// }
|
||||
//interp->writeFlatField(tit);
|
||||
i_image++;
|
||||
// dont get data
|
||||
continue; //continue to not get out
|
||||
}
|
||||
// cprintf(GREEN, "Got Header \n");
|
||||
// get data
|
||||
// cprintf(GREEN, "Got Header\n");
|
||||
//image=(int*)buff;
|
||||
//cout << buff << endl;
|
||||
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
|
||||
// int length = zmqsocket->ReceiveData(0, (int*)image, size);
|
||||
// cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
iframe++;
|
||||
// if (iframe%p==0) {
|
||||
|
||||
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
// sprintf(tit,"%s_tmp.tiff",fn);
|
||||
// mt->writeImage(tit);
|
||||
// //mt->clearImage();
|
||||
|
||||
// cout <<"*"<< iprog++ << endl;
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //stream data from socket 2
|
||||
// if (send) {
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
|
||||
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
// cprintf(GREEN, "Sent Header\n");
|
||||
|
||||
// zmqsocket2->SendData((char*)image,length);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
// }
|
||||
|
||||
|
||||
}// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
// if (send)
|
||||
// delete zmqsocket2;
|
||||
|
||||
|
||||
// cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,219 +0,0 @@
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
|
||||
#include "interpolatingDetector.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
#include "linearInterpolation.h"
|
||||
#include "noInterpolation.h"
|
||||
#include "multiThreadedDetector.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [image size] [send_socket ip] [send port number]
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
int nthreads=3;
|
||||
int nsubpix=5;
|
||||
int etabins=550;
|
||||
double etamin=-1, etamax=2;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ok;
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
char* buff;
|
||||
|
||||
moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
// cout << "decoder "<< endl;
|
||||
etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
|
||||
//linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
|
||||
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 10);
|
||||
|
||||
|
||||
|
||||
|
||||
filter->readPedestals("/scratch/ped_100.tiff");
|
||||
interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
cout << "filter "<< endl;
|
||||
|
||||
|
||||
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
|
||||
multiThreadedDetector *mt=new multiThreadedDetector(filter,nthreads,100);
|
||||
|
||||
|
||||
|
||||
mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// help
|
||||
if (argc < 4 || (argc > 4 && argc != 6)) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [image size] [send_socket ip] [send starting port number]\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip = argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int size = atoi(argv[3]);
|
||||
|
||||
// send parameters if any
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
if (argc > 4) {
|
||||
send = true;
|
||||
socketip2 = argv[4];
|
||||
portnum2 = atoi(argv[5]);
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum <<
|
||||
"\nsize : " << size;
|
||||
if (send) {
|
||||
cout << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
if (send) {
|
||||
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
if (zmqsocket2->IsError()) {
|
||||
bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
delete zmqsocket2;
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
string filename = "";
|
||||
int imsize=nx*ny*nsubpix*nsubpix;
|
||||
int i_image=0;
|
||||
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
|
||||
cprintf(RED, "Acquisition finished\n");
|
||||
|
||||
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
if (send) {
|
||||
zmqsocket2->SendData((char*)(mt->getInterpolatedImage()),imsize*sizeof(int));
|
||||
cprintf(BLUE, "Sent Interpolated image\n");
|
||||
// zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// cprintf(RED, "Sent Dummy\n");
|
||||
}
|
||||
if (save) {
|
||||
char tit[10000];
|
||||
sprintf(tit,"/scratch/int_image_%d.tiff",i_image);
|
||||
mt->writeInterpolatedImage(tit);
|
||||
mt->clearInterpolatedImage(tit);
|
||||
}
|
||||
i_image++;
|
||||
// dont get data
|
||||
break; //continue to not get out
|
||||
}
|
||||
cprintf(GREEN, "Got Header \n");
|
||||
// get data
|
||||
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
|
||||
cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //stream data from socket 2
|
||||
// if (send) {
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
|
||||
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
// cprintf(GREEN, "Sent Header\n");
|
||||
|
||||
// zmqsocket2->SendData((char*)image,length);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
// }
|
||||
|
||||
|
||||
}// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
if (send)
|
||||
delete zmqsocket2;
|
||||
|
||||
|
||||
cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,248 +0,0 @@
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
// #include "etaInterpolationPosXY.h"
|
||||
#include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
//#include "singlePhotonDetector.h"
|
||||
#include "interpolatingDetector.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
|
||||
int p=1000;
|
||||
int fifosize=1000;
|
||||
int nthreads=6;
|
||||
int nsubpix=2;
|
||||
// int etabins=550;
|
||||
// double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
char* buff;
|
||||
int iprog=0;
|
||||
char outfname[10000];
|
||||
|
||||
|
||||
moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
// cout << "decoder "<< endl;
|
||||
//etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
|
||||
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
|
||||
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
// interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 10);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
|
||||
char tit[10000];
|
||||
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
|
||||
mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// help
|
||||
if (argc < 4 || (argc > 4 && argc != 6)) {
|
||||
cprintf(RED, "Help: %s [receive socket ip] [receive starting port number] [fname]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip = argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
char fn[10000];
|
||||
strcpy(fn, argv[3]);
|
||||
// send parameters if any
|
||||
// char* socketip2 = 0;
|
||||
// uint32_t portnum2 = 0;
|
||||
// if (argc > 4) {
|
||||
// send = true;
|
||||
// socketip2 = argv[4];
|
||||
// portnum2 = atoi(argv[5]);
|
||||
// }
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum <<
|
||||
// "\nsize : " << size;
|
||||
"\nfname : " << fn ;
|
||||
// if (send) {
|
||||
// cout << "\nsd socket ip : " << socketip2 <<
|
||||
// "\nsd port num : " << portnum2;
|
||||
// }
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
// ZmqSocket* zmqsocket2 = 0;
|
||||
// if (send) {
|
||||
// zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
// if (zmqsocket2->IsError()) {
|
||||
// bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
// delete zmqsocket2;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
string filename = "";
|
||||
int nnx, nny, nns;
|
||||
int imsize=filter->getImageSize(nnx,nny,nns);
|
||||
//int imsize=nx*ny;
|
||||
int i_image=0;
|
||||
|
||||
int iframe=0;
|
||||
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
|
||||
cprintf(RED, "Acquisition finished\n");
|
||||
|
||||
|
||||
|
||||
cout << "Recieved " << iframe << " frames " << endl;
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
cout << "threads done " << endl;
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
// if (send) {
|
||||
// zmqsocket2->SendData((char*)(mt->getImage()),imsize*sizeof(int));
|
||||
// cprintf(BLUE, "Sent Interpolated image\n");
|
||||
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// // cprintf(RED, "Sent Dummy\n");
|
||||
// }
|
||||
// if (save) {
|
||||
sprintf(tit,"%s_%d.tiff",fn, i_image);
|
||||
cout << tit << endl;
|
||||
mt->writeImage(tit);
|
||||
cout << "wrote" << endl;
|
||||
mt->clearImage();
|
||||
// }
|
||||
i_image++;
|
||||
// dont get data
|
||||
continue; //continue to not get out
|
||||
}
|
||||
// cprintf(GREEN, "Got Header \n");
|
||||
// get data
|
||||
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
|
||||
// cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
iframe++;
|
||||
if (iframe%p==0) {
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
sprintf(tit,"%s_tmp.tiff",fn);
|
||||
mt->writeImage(tit);
|
||||
//mt->clearImage();
|
||||
|
||||
cout <<"*"<< iprog++ << endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //stream data from socket 2
|
||||
// if (send) {
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
|
||||
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
// cprintf(GREEN, "Sent Header\n");
|
||||
|
||||
// zmqsocket2->SendData((char*)image,length);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
// }
|
||||
|
||||
|
||||
}// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
// if (send)
|
||||
// delete zmqsocket2;
|
||||
|
||||
|
||||
cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
242
slsDetectorCalibration/moenchExecutables/moenchAnalog.cpp
Normal file
242
slsDetectorCalibration/moenchExecutables/moenchAnalog.cpp
Normal file
@ -0,0 +1,242 @@
|
||||
//#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
#ifdef NEWRECEIVER
|
||||
#include "moench03T1ReceiverDataNew.h"
|
||||
#endif
|
||||
#ifdef CSAXS_FP
|
||||
#include "moench03T1ReceiverData.h"
|
||||
#endif
|
||||
#ifdef OLDDATA
|
||||
#include "moench03Ctb10GbT1Data.h"
|
||||
#endif
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctime>
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
if (argc<4) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname [pedfile] [threshold]" << endl;
|
||||
return 1;
|
||||
}
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=8;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
|
||||
|
||||
|
||||
#ifdef NEWRECEIVER
|
||||
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
|
||||
cout << "RECEIVER DATA WITH ONE HEADER!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef CSAXS_FP
|
||||
moench03T1ReceiverData *decoder=new moench03T1ReceiverData();
|
||||
cout << "RECEIVER DATA WITH ALL HEADERS!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef OLDDATA
|
||||
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
|
||||
cout << "OLD RECEIVER DATA!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifndef ANALOG
|
||||
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
|
||||
// char tit[10000];
|
||||
cout << "filter " << endl;
|
||||
#endif
|
||||
|
||||
#ifdef ANALOG
|
||||
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(decoder, 1, 0, nped);
|
||||
// char tit[10000];
|
||||
cout << "filter " << endl;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
int ff, np;
|
||||
int dsize=decoder->getDataSize();
|
||||
cout << " data size is " << dsize;
|
||||
|
||||
|
||||
char data[dsize];
|
||||
|
||||
ifstream filebin;
|
||||
char *indir=argv[1];
|
||||
char *outdir=argv[2];
|
||||
char *fformat=argv[3];
|
||||
char *pedfile=NULL;
|
||||
if (argc>=5) {
|
||||
pedfile=argv[4];
|
||||
}
|
||||
double thr=0;
|
||||
if (argc>=6) {
|
||||
thr=atoi(argv[5]);
|
||||
}
|
||||
|
||||
|
||||
char fname[10000];
|
||||
char imgfname[10000];
|
||||
// strcpy(pedfname,argv[6]);
|
||||
char fn[10000];
|
||||
|
||||
std::time_t end_time;
|
||||
|
||||
FILE *of=NULL;
|
||||
cout << "input directory is " << indir << endl;
|
||||
cout << "output directory is " << outdir << endl;
|
||||
cout << "input file is " << fformat << endl;
|
||||
if (pedfile)
|
||||
cout << "pedestal file is " << pedfile << endl;
|
||||
if (thr>0) {
|
||||
cout << "threshold is " << thr << endl;
|
||||
filter->setThreshold(thr);
|
||||
}
|
||||
|
||||
filter->setROI(0,150,0,150);
|
||||
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
cout << "mt " << endl;
|
||||
|
||||
int ifr=0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (int irun=0; irun<2; irun++) {
|
||||
if (irun>0) {
|
||||
mt->setFrameMode(eFrame);
|
||||
// sprintf(fn,fformat,irun);
|
||||
sprintf(fname,"%s/%s.raw",indir,fformat);
|
||||
// sprintf(outfname,"%s/%s.clust",outdir,fn);
|
||||
sprintf(imgfname,"%s/%s.tiff",outdir,fformat);
|
||||
} else {
|
||||
mt->setFrameMode(ePedestal);
|
||||
// sprintf(fn,fformat,irun);
|
||||
sprintf(fname,"%s/%s.raw",indir,pedfile);
|
||||
// sprintf(outfname,"%s/%s.clust",outdir,fn);
|
||||
// sprintf(imgfname,"%s/%s.tiff",outdir,fn);
|
||||
}
|
||||
cout << fname << endl;
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
// cout << fname << " " << outfname << " " << imgfname << endl;
|
||||
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||
// //open file
|
||||
if (filebin.is_open()){
|
||||
// of=fopen(outfname,"w");
|
||||
// if (of) {
|
||||
// mt->setFilePointer(of);
|
||||
// // cout << "file pointer set " << endl;
|
||||
// } else {
|
||||
// cout << "Could not open "<< outfname << " for writing " << endl;
|
||||
// mt->setFilePointer(NULL);
|
||||
// return 1;
|
||||
// }
|
||||
// //while read frame
|
||||
ff=-1;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
// cout << "*"<<ifr++<<"*"<<ff<< endl;
|
||||
// cout << ff << " " << np << endl;
|
||||
// //push
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr%10000==0) cout << ifr << " " << ff << endl;
|
||||
ff=-1;
|
||||
}
|
||||
cout << "--" << endl;
|
||||
filebin.close();
|
||||
// //close file
|
||||
// //join threads
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
// if (of)
|
||||
// fclose(of);
|
||||
if (irun>0) {
|
||||
cout << "Writing tiff to " << imgfname << endl;
|
||||
mt->writeImage(imgfname);
|
||||
// mt->clearImage();
|
||||
}
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
358
slsDetectorCalibration/moenchExecutables/moenchPhotonCounter.cpp
Normal file
358
slsDetectorCalibration/moenchExecutables/moenchPhotonCounter.cpp
Normal file
@ -0,0 +1,358 @@
|
||||
//#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
#define VERSION_V1
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
#ifdef NEWRECEIVER
|
||||
#ifndef RECT
|
||||
#include "moench03T1ReceiverDataNew.h"
|
||||
#endif
|
||||
|
||||
#ifdef RECT
|
||||
#include "moench03T1ReceiverDataNewRect.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CSAXS_FP
|
||||
#include "moench03T1ReceiverData.h"
|
||||
#endif
|
||||
#ifdef OLDDATA
|
||||
#include "moench03Ctb10GbT1Data.h"
|
||||
#endif
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctime>
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
if (argc<4) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname [runmin] [runmax] [pedfile] [threshold] [nframes] [xmin xmax ymin ymax]" << endl;
|
||||
cout << "threshold <0 means analog; threshold=0 means cluster finder; threshold>0 means photon counting" << endl;
|
||||
cout << "nframes <0 means sum everything; nframes=0 means one file per run; nframes>0 means one file every nframes" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=1;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=10000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
|
||||
int cf=0;
|
||||
|
||||
#ifdef NEWRECEIVER
|
||||
#ifdef RECT
|
||||
cout << "Should be rectangular!" <<endl;
|
||||
#endif
|
||||
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
|
||||
cout << "RECEIVER DATA WITH ONE HEADER!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef CSAXS_FP
|
||||
moench03T1ReceiverData *decoder=new moench03T1ReceiverData();
|
||||
cout << "RECEIVER DATA WITH ALL HEADERS!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef OLDDATA
|
||||
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
|
||||
cout << "OLD RECEIVER DATA!"<<endl;
|
||||
#endif
|
||||
|
||||
int nx=400, ny=400;
|
||||
|
||||
decoder->getDetectorSize(nx,ny);
|
||||
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
int ff, np;
|
||||
int dsize=decoder->getDataSize();
|
||||
//cout << " data size is " << dsize;
|
||||
|
||||
|
||||
char data[dsize];
|
||||
|
||||
ifstream filebin;
|
||||
char *indir=argv[1];
|
||||
char *outdir=argv[2];
|
||||
char *fformat=argv[3];
|
||||
int runmin=0;
|
||||
|
||||
// cout << "argc is " << argc << endl;
|
||||
if (argc>=5) {
|
||||
runmin=atoi(argv[4]);
|
||||
}
|
||||
|
||||
int runmax=runmin;
|
||||
|
||||
if (argc>=6) {
|
||||
runmax=atoi(argv[5]);
|
||||
}
|
||||
|
||||
char *pedfile=NULL;
|
||||
if (argc>=7) {
|
||||
pedfile=argv[6];
|
||||
}
|
||||
double thr=0;
|
||||
double thr1=1;
|
||||
|
||||
if (argc>=8) {
|
||||
thr=atoi(argv[7]);
|
||||
}
|
||||
|
||||
|
||||
int nframes=0;
|
||||
|
||||
if (argc>=9) {
|
||||
nframes=atoi(argv[8]);
|
||||
}
|
||||
int xmin=0, xmax=nx, ymin=0, ymax=ny;
|
||||
if (argc>=13) {
|
||||
xmin=atoi(argv[9]);
|
||||
xmax=atoi(argv[10]);
|
||||
ymin=atoi(argv[11]);
|
||||
ymax=atoi(argv[12]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char ffname[10000];
|
||||
char fname[10000];
|
||||
char imgfname[10000];
|
||||
char cfname[10000];
|
||||
char fn[10000];
|
||||
|
||||
std::time_t end_time;
|
||||
|
||||
FILE *of=NULL;
|
||||
cout << "input directory is " << indir << endl;
|
||||
cout << "output directory is " << outdir << endl;
|
||||
cout << "input file is " << fformat << endl;
|
||||
cout << "runmin is " << runmin << endl;
|
||||
cout << "runmax is " << runmax << endl;
|
||||
if (pedfile)
|
||||
cout << "pedestal file is " << pedfile << endl;
|
||||
//#ifndef ANALOG
|
||||
if (thr>0) {
|
||||
cout << "threshold is " << thr << endl;
|
||||
|
||||
//#ifndef ANALOG
|
||||
filter->setThreshold(thr);
|
||||
//#endif
|
||||
|
||||
} else
|
||||
cf=1;
|
||||
//#endif
|
||||
|
||||
|
||||
filter->setROI(xmin,xmax,ymin,ymax);
|
||||
#ifdef SOLEIL
|
||||
filter->setROI(150,210,170,230);
|
||||
nframes=-1;
|
||||
#endif
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
char* buff;
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
#ifndef ANALOG
|
||||
mt->setDetectorMode(ePhotonCounting);
|
||||
cout << "Counting!" << endl;
|
||||
if (thr>0) {
|
||||
cf=0;
|
||||
}
|
||||
#endif
|
||||
//{
|
||||
#ifdef ANALOG
|
||||
mt->setDetectorMode(eAnalog);
|
||||
cout << "Analog!" << endl;
|
||||
cf=0;
|
||||
// thr1=thr;
|
||||
#endif
|
||||
// }
|
||||
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// cout << "mt " << endl;
|
||||
|
||||
int ifr=0;
|
||||
|
||||
|
||||
|
||||
|
||||
if (pedfile) {
|
||||
cout << "PEDESTAL " ;
|
||||
sprintf(fname,"%s.raw",pedfile);
|
||||
cout << fname << endl ;
|
||||
sprintf(imgfname,"%s/pedestals.tiff",outdir,fformat);
|
||||
std::time(&end_time);
|
||||
cout << "aaa" << std::ctime(&end_time) << endl;
|
||||
|
||||
|
||||
mt->setFrameMode(ePedestal);
|
||||
// sprintf(fn,fformat,irun);
|
||||
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||
// //open file
|
||||
if (filebin.is_open()){
|
||||
ff=-1;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
if (np==40) {
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr%10000==0)
|
||||
cout << ifr << " " << ff << " " << np << endl;
|
||||
} else
|
||||
cout << ifr << " " << ff << " " << np << endl;
|
||||
ff=-1;
|
||||
}
|
||||
filebin.close();
|
||||
while (mt->isBusy()) {;}
|
||||
mt->writePedestal(imgfname);
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
} else
|
||||
cout << "Could not open pedestal file "<< fname << " for reading " << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ifr=0;
|
||||
int ifile=0;
|
||||
|
||||
mt->setFrameMode(eFrame);
|
||||
|
||||
for (int irun=runmin; irun<=runmax; irun++) {
|
||||
cout << "DATA " ;
|
||||
// sprintf(fn,fformat,irun);
|
||||
sprintf(ffname,"%s/%s.raw",indir,fformat);
|
||||
sprintf(fname,ffname,irun);
|
||||
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
|
||||
sprintf(imgfname,ffname,irun);
|
||||
sprintf(ffname,"%s/%s.clust",outdir,fformat);
|
||||
sprintf(cfname,ffname,irun);
|
||||
cout << fname << " " ;
|
||||
cout << imgfname << endl;
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
// cout << fname << " " << outfname << " " << imgfname << endl;
|
||||
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||
// //open file
|
||||
ifile=0;
|
||||
if (filebin.is_open()){
|
||||
if (thr<=0 && cf!=0) { //cluster finder
|
||||
if (of==NULL) {
|
||||
of=fopen(cfname,"w");
|
||||
if (of) {
|
||||
mt->setFilePointer(of);
|
||||
cout << "file pointer set " << endl;
|
||||
} else {
|
||||
cout << "Could not open "<< cfname << " for writing " << endl;
|
||||
mt->setFilePointer(NULL);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// //while read frame
|
||||
ff=-1;
|
||||
ifr=0;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
if (np==40) {
|
||||
// cout << "*"<<ifr++<<"*"<<ff<< endl;
|
||||
// cout << ff << " " << np << endl;
|
||||
// //push
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr%1000==0) cout << ifr << " " << ff << endl;
|
||||
if (nframes>0) {
|
||||
if (ifr%nframes==0) {
|
||||
//The name has an additional "_fXXXXX" at the end, where "XXXXX" is the initial frame number of the image (0,1000,2000...)
|
||||
|
||||
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
|
||||
sprintf(imgfname,ffname,irun);
|
||||
//cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
mt->clearImage();
|
||||
ifile++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
cout << ifr << " " << ff << " " << np << endl;
|
||||
ff=-1;
|
||||
}
|
||||
cout << "--" << endl;
|
||||
filebin.close();
|
||||
// //close file
|
||||
// //join threads
|
||||
while (mt->isBusy()) {;}
|
||||
if (nframes>=0) {
|
||||
if (nframes>0) {
|
||||
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
|
||||
sprintf(imgfname,ffname,irun);
|
||||
}
|
||||
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
|
||||
sprintf(imgfname,ffname,irun);
|
||||
cout << "Writing tiff to " << imgfname << " " << thr1 <<endl;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
mt->clearImage();
|
||||
if (of) {
|
||||
fclose(of);
|
||||
of=NULL;
|
||||
mt->setFilePointer(NULL);
|
||||
}
|
||||
}
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << endl;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
394
slsDetectorCalibration/moenchExecutables/moenchZmqAnalog.cpp
Normal file
394
slsDetectorCalibration/moenchExecutables/moenchZmqAnalog.cpp
Normal file
@ -0,0 +1,394 @@
|
||||
//#define ROOTSPECTRUM
|
||||
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
|
||||
#include "sls_receiver_defs.h"
|
||||
#include "ZmqSocket.h"
|
||||
#include "moench03T1ZmqDataNew.h"
|
||||
|
||||
#ifdef ROOTSPECTRUM
|
||||
#include <TPaveText.h>
|
||||
#include <TLegend.h>
|
||||
#include <TF1.h>
|
||||
#include <TGraphErrors.h>
|
||||
#include <TH2F.h>
|
||||
#include <TASImage.h>
|
||||
#include <TImage.h>
|
||||
#include <TFile.h>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "tiffIO.h"
|
||||
|
||||
#include<iostream>
|
||||
|
||||
//#include "analogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [send_socket ip] [send port number]
|
||||
*
|
||||
*/
|
||||
int fifosize=1000;
|
||||
int nthreads=20;
|
||||
char* buff;
|
||||
char tit[10000];
|
||||
// help
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int size = 32*2*5000;//atoi(argv[3]);
|
||||
|
||||
// send parameters if any
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
if (argc > 3) {
|
||||
send = true;
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum ;
|
||||
if (send) {
|
||||
cout << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
||||
//singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10);
|
||||
//filter->setROI(250, 400, 30, 150);
|
||||
float threshold=1;
|
||||
if (argc > 5) {
|
||||
threshold=atof(argv[5]);
|
||||
filter->setThreshold(threshold);
|
||||
cout << "Threshold set to " << threshold << endl;
|
||||
}
|
||||
|
||||
int nnx, nny, nns;
|
||||
int imsize=filter->getImageSize(nnx,nny,nns);
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
cout << "det " << endl;
|
||||
int16_t dout[400*400];
|
||||
double ddark[400*400];
|
||||
cout << "dout " << endl;
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
#ifdef ROOTSPECTRUM
|
||||
TH2F *h2=NULL;
|
||||
TH2F *hmap=NULL;
|
||||
TFile *froot=NULL;
|
||||
|
||||
h2=new TH2F("hs","hs",500,-500,500,400*400,-0.5,400*400-0.5);
|
||||
hmap=new TH2F("hmap","hmap",400,-0.5,400-0.5,400,-0.5,400-0.5);
|
||||
#endif
|
||||
cout << "zmq1 " << endl;
|
||||
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
zmqsocket->Connect();
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
cout << "zmq2 " << endl;
|
||||
if (send) {
|
||||
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
if (zmqsocket2->IsError()) {
|
||||
bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
delete zmqsocket2;
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
zmqsocket2->Connect();
|
||||
printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
// zmqsocket2->Disconnect();
|
||||
}
|
||||
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
uint64_t fileindex = -1;
|
||||
string filename = "";
|
||||
//char* image = new char[size];
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
|
||||
int *nph;//[400*400];
|
||||
int iframe=0;
|
||||
char rootfname[10000];
|
||||
|
||||
char fname[10000];
|
||||
char ff[10000];
|
||||
int fi;
|
||||
int length;
|
||||
char newped=-1, ped=-1, dat=-1, isdark=-1;
|
||||
|
||||
double *peds;
|
||||
int *im;
|
||||
int fnumber;
|
||||
float *gm=new float[400*400];
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){
|
||||
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
|
||||
cprintf(RED, "Got Dummy\n");
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
if (dat==1) {
|
||||
|
||||
sprintf(tit,"%s_%lld.tiff",filename.c_str(),fi);
|
||||
cout << tit << endl;
|
||||
im=mt->getImage(nnx,nny,nns);
|
||||
if (isdark) cout << "getting dark "<< endl;
|
||||
else cout << "subtracting dark"<< endl;
|
||||
if (gm) {
|
||||
for (int ii=0; ii<400*400; ii++) {
|
||||
// if (image[ix]>0) cout << ix << " " << image[ix]<< endl;
|
||||
if (isdark) {
|
||||
ddark[ii]=(double)im[ii]/((double)iframe);
|
||||
if (ddark[ii]>0) cout << "*" ;
|
||||
gm[ii]=im[ii];
|
||||
if (send) dout[ii]=im[ii];
|
||||
} else {
|
||||
gm[ii]=im[ii];//-ddark[ii]*iframe;
|
||||
if (gm[ii]<0) gm[ii]=0;
|
||||
if (send) dout[ii]=gm[ii];
|
||||
}
|
||||
//cout << endl;
|
||||
|
||||
}
|
||||
cout << endl;
|
||||
//cout << "image " << nnx << " " << nny << endl;
|
||||
WriteToTiff(gm,tit ,nnx, nny);
|
||||
// delete [] gm;
|
||||
} else cout << "Could not allocate float image " << endl;
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
sprintf(tit,"%s_%lld.tiff",filename.c_str(),fi);
|
||||
cout << tit << endl;
|
||||
mt->writePedestal(tit);
|
||||
|
||||
}
|
||||
|
||||
// mt->writeImage(tit);
|
||||
// cout << "wrote" << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (send) {
|
||||
if (dat==1) {
|
||||
//im=mt->getImage(nnx,nny,nns);
|
||||
|
||||
//if (im)
|
||||
// cout << "got image" << endl;
|
||||
//else
|
||||
// cout << "could not get image" << endl;
|
||||
|
||||
|
||||
//for (int ii=0; ii<400*400; ii++) {
|
||||
//if (im[ii]>0)
|
||||
//cout << im[ii] << endl;
|
||||
// if (im[ii]>=0)
|
||||
|
||||
// if (isdark) {
|
||||
//ddark[ii]=im[ii];
|
||||
// dout[ii]=im[ii];
|
||||
// } else {
|
||||
// dout[ii]=im[ii]-ddark[ii];
|
||||
// if (dout[ii]<0) dout[ii]=0;
|
||||
// }
|
||||
// else
|
||||
// dout[ii]=0;
|
||||
//else
|
||||
//dout[ii]=0;
|
||||
// cout << im[ii] << " " << dout[ii] << endl;
|
||||
// }
|
||||
//for (int iiy=49; iiy<52; iiy++)
|
||||
// for (int iix=80; iix<83; iix++)
|
||||
// dout[iiy*400+iix]=0;
|
||||
;
|
||||
} else {
|
||||
peds=mt->getPedestal();
|
||||
// sprintf(tit,"%s_%lld.tiff",filename.c_str(),fi);
|
||||
//cout << tit << endl;
|
||||
//mt->writePedestal(tit);
|
||||
if (peds)
|
||||
cout << "got peds" << endl;
|
||||
else
|
||||
cout << "could not get peds" << endl;
|
||||
for (int ii=0; ii<400*400; ii++) {
|
||||
dout[ii]=peds[ii];
|
||||
// if (ii%400==10 && ii/400==10)
|
||||
// cout << ii/400 << " " << ii%400 << " " << peds[ii] << " " << dout[ii] << endl;
|
||||
// if (ii%400==100 && ii/400==100)
|
||||
// cout << ii/400 << " " << ii%400 << " " << peds[ii] << " " << dout[ii] << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
// if (zmqsocket2->IsError()) {
|
||||
// bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
// delete zmqsocket2;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// zmqsocket2->Connect();
|
||||
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
//zmqsocket2->Connect();
|
||||
|
||||
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,ff, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
|
||||
|
||||
zmqsocket2->SendData((char*)dout,length);
|
||||
cprintf(GREEN, "Sent Data %d \n",length);
|
||||
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
// zmqsocket2->Disconnect();
|
||||
|
||||
// delete zmqsocket2;
|
||||
}
|
||||
cout << "Acquired "<< iframe << " frames " << endl;
|
||||
iframe=0;
|
||||
newped=-1;
|
||||
ped=-1;
|
||||
dat=-1;
|
||||
mt->clearImage();
|
||||
isdark=0;
|
||||
continue; //continue to not get out
|
||||
}
|
||||
// cprintf(GREEN, "Got Header \n");
|
||||
|
||||
strcpy(ff,filename.c_str());
|
||||
fi=fileindex;
|
||||
//isdark=0;
|
||||
if (newped<0) {
|
||||
if (filename.find("newped")!=std::string::npos) {
|
||||
cout << "NEWPED" << endl;
|
||||
if (newped<=0) {
|
||||
newped=1;
|
||||
ped=1;
|
||||
while (mt->isBusy()) {;}
|
||||
mt->newDataSet(); //resets pedestal
|
||||
mt->setFrameMode(ePedestal);
|
||||
cout << "New data set"<< endl;
|
||||
}
|
||||
} else {
|
||||
newped=0;
|
||||
}
|
||||
}
|
||||
if (ped<0) {
|
||||
if (filename.find("ped")!=std::string::npos) {
|
||||
ped=1;
|
||||
dat=0;
|
||||
while (mt->isBusy()) {;}
|
||||
mt->setFrameMode(ePedestal);
|
||||
cout << "pedestal!"<< endl;
|
||||
} else {
|
||||
ped=0;
|
||||
dat=1;
|
||||
while (mt->isBusy()) {;}
|
||||
mt->setFrameMode(eFrame);
|
||||
cout << "data!"<< endl;
|
||||
if (filename.find("dark")!=std::string::npos) {
|
||||
isdark=1;
|
||||
cout << "this is a dark image" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// get data
|
||||
length = zmqsocket->ReceiveData(0, buff, size);
|
||||
// cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
// if (iframe<10) {
|
||||
// filter->addToPedestal(image);
|
||||
//} else {
|
||||
//SLOW!!!
|
||||
//***
|
||||
//filter->getNPhotons(image);
|
||||
//nph=filter->getImage();
|
||||
//filter->addToPedestal(image);
|
||||
//*****
|
||||
|
||||
// cprintf(BLUE, "Data processed\n");
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
//stream data from socket 2
|
||||
|
||||
iframe++;
|
||||
}
|
||||
|
||||
// }// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
if (send)
|
||||
delete zmqsocket2;
|
||||
|
||||
|
||||
cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -8,6 +8,12 @@
|
||||
#include <fstream>
|
||||
#include "tiffIO.h"
|
||||
|
||||
|
||||
//#define NEWZMQ
|
||||
#ifdef NEWZMQ
|
||||
#include <rapidjson/document.h> //json header in zmq stream
|
||||
#endif
|
||||
|
||||
#include<iostream>
|
||||
|
||||
//#include "analogDetector.h"
|
||||
@ -30,87 +36,129 @@ int main(int argc, char *argv[]) {
|
||||
int fifosize=1000;
|
||||
int nthreads=20;
|
||||
// help
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n");
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int maxSize = 32*2*8192;//5000;//atoi(argv[3]);
|
||||
int size= 32*2*5000;
|
||||
int multisize=size;
|
||||
// send parameters if any
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
if (argc > 3) {
|
||||
send = true;
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum ;
|
||||
if (send) {
|
||||
cout << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10);
|
||||
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
ZmqSocket* zmqsocket=NULL;
|
||||
|
||||
#ifdef NEWZMQ
|
||||
// receive socket
|
||||
try{
|
||||
#endif
|
||||
|
||||
zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
|
||||
|
||||
#ifdef NEWZMQ
|
||||
} catch (...) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int size = 32*2*5000;//atoi(argv[3]);
|
||||
|
||||
// send parameters if any
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
if (argc > 3) {
|
||||
send = true;
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum ;
|
||||
if (send) {
|
||||
cout << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10);
|
||||
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEWZMQ
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
zmqsocket->Connect();
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
#endif
|
||||
if (zmqsocket->Connect()) {
|
||||
cprintf(RED, "Error: Could not connect to socket %s\n",
|
||||
zmqsocket->GetZmqServerAddress());
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
} else
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
cout << "zmq2 " << endl;
|
||||
if (send) {
|
||||
#ifdef NEWZMQ
|
||||
// receive socket
|
||||
try{
|
||||
#endif
|
||||
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
|
||||
|
||||
|
||||
#ifdef NEWZMQ
|
||||
} catch (...) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
delete zmqsocket2;
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEWZMQ
|
||||
if (zmqsocket2->IsError()) {
|
||||
bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
cprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
delete zmqsocket2;
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
zmqsocket2->Connect();
|
||||
printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
#endif
|
||||
if (zmqsocket2->Connect()) {
|
||||
cprintf(RED, "Error: Could not connect to socket %s\n",
|
||||
zmqsocket2->GetZmqServerAddress());
|
||||
delete zmqsocket2;
|
||||
return EXIT_FAILURE;
|
||||
} else
|
||||
printf("Zmq Client at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
|
||||
}
|
||||
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
uint32_t subFrameIndex = -1;
|
||||
uint64_t fileindex = -1;
|
||||
string filename = "";
|
||||
char* image = new char[size];
|
||||
// char* image = new char[size];
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
|
||||
uint32_t flippedDataX = -1;
|
||||
int *nph;
|
||||
int iframe=0;
|
||||
char ofname[10000];
|
||||
@ -119,17 +167,57 @@ int main(int argc, char *argv[]) {
|
||||
int length;
|
||||
int *detimage;
|
||||
int nnx, nny,nns;
|
||||
uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0;
|
||||
filter->getImageSize(nnx, nny,nns);
|
||||
int16_t *dout=new int16_t [nnx*nny];
|
||||
// infinite loop
|
||||
uint32_t packetNumber = 0;
|
||||
uint64_t bunchId = 0;
|
||||
uint64_t timestamp = 0;
|
||||
int16_t modId = 0;
|
||||
uint16_t xCoord = 0;
|
||||
uint16_t yCoord = 0;
|
||||
uint16_t zCoord = 0;
|
||||
uint32_t debug = 0;
|
||||
uint32_t dr = 16;
|
||||
uint16_t roundRNumber = 0;
|
||||
uint8_t detType = 0;
|
||||
uint8_t version = 0;
|
||||
int* flippedData = 0;
|
||||
char* additionalJsonHeader = 0;
|
||||
|
||||
uint32_t threshold=0;
|
||||
|
||||
uint32_t xmin=0, xmax=400, ymin=0, ymax=400;
|
||||
|
||||
string frameMode_s, detectorMode_s;
|
||||
|
||||
int emin, emax;
|
||||
|
||||
|
||||
int newFrame=1;
|
||||
|
||||
while(1) {
|
||||
|
||||
|
||||
// cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
#ifndef NEWZMQ
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){
|
||||
#endif
|
||||
|
||||
#ifdef NEWZMQ
|
||||
rapidjson::Document doc;
|
||||
if (!zmqsocket->ReceiveHeader(0, doc, SLS_DETECTOR_JSON_HEADER_VERSION)) {
|
||||
zmqsocket->CloseHeaderMessage();
|
||||
|
||||
#endif
|
||||
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
|
||||
cprintf(RED, "Got Dummy\n");
|
||||
|
||||
|
||||
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
|
||||
@ -142,8 +230,18 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
if (send) {
|
||||
strcpy(fname,filename.c_str());
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,16,fileindex,400,400,400*400, acqIndex,frameIndex,fname, acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
#ifdef NEWZMQ
|
||||
//zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dynamicRange, fileindex,
|
||||
// nnx, nny, nns*dynamicRange/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
|
||||
|
||||
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex,
|
||||
nnx, nny, nns*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NEWZMQ
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
#endif
|
||||
|
||||
zmqsocket2->SendData((char*)dout,length);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
@ -161,9 +259,112 @@ int main(int argc, char *argv[]) {
|
||||
of=NULL;
|
||||
}
|
||||
|
||||
newFrame=1;
|
||||
continue; //continue to not get out
|
||||
}
|
||||
|
||||
#ifdef NEWZMQ
|
||||
if (newFrame) {
|
||||
// acqIndex, frameIndex, subframeIndex, filename, fileindex
|
||||
size = doc["size"].GetUint();
|
||||
multisize = size;// * zmqsocket->size();
|
||||
dynamicRange = doc["bitmode"].GetUint();
|
||||
nPixelsX = doc["shape"][0].GetUint();
|
||||
nPixelsY = doc["shape"][1].GetUint();
|
||||
filename = doc["fname"].GetString();
|
||||
acqIndex = doc["acqIndex"].GetUint64();
|
||||
frameIndex = doc["fIndex"].GetUint64();
|
||||
fileindex = doc["fileIndex"].GetUint64();
|
||||
subFrameIndex = doc["expLength"].GetUint();
|
||||
xCoord = doc["xCoord"].GetUint();
|
||||
yCoord = doc["yCoord"].GetUint();
|
||||
zCoord = doc["zCoord"].GetUint();
|
||||
flippedDataX=doc["flippedDataX"].GetUint();
|
||||
packetNumber=doc["packetNumber"].GetUint();
|
||||
bunchId=doc["bunchId"].GetUint();
|
||||
timestamp=doc["timestamp"].GetUint();
|
||||
modId=doc["modId"].GetUint();
|
||||
debug=doc["debug"].GetUint();
|
||||
roundRNumber=doc["roundRNumber"].GetUint();
|
||||
detType=doc["detType"].GetUint();
|
||||
version=doc["version"].GetUint();
|
||||
|
||||
|
||||
|
||||
cprintf(BLUE, "Header Info:\n"
|
||||
"size: %u\n"
|
||||
"multisize: %u\n"
|
||||
"dynamicRange: %u\n"
|
||||
"nPixelsX: %u\n"
|
||||
"nPixelsY: %u\n"
|
||||
"currentFileName: %s\n"
|
||||
"currentAcquisitionIndex: %lu\n"
|
||||
"currentFrameIndex: %lu\n"
|
||||
"currentFileIndex: %lu\n"
|
||||
"currentSubFrameIndex: %u\n"
|
||||
"xCoordX: %u\n"
|
||||
"yCoordY: %u\n"
|
||||
"zCoordZ: %u\n"
|
||||
"flippedDataX: %u\n"
|
||||
"packetNumber: %u\n"
|
||||
"bunchId: %u\n"
|
||||
"timestamp: %u\n"
|
||||
"modId: %u\n"
|
||||
"debug: %u\n"
|
||||
"roundRNumber: %u\n"
|
||||
"detType: %u\n"
|
||||
"version: %u\n",
|
||||
size, multisize, dynamicRange, nPixelsX, nPixelsY,
|
||||
filename.c_str(), acqIndex,
|
||||
frameIndex, fileindex, subFrameIndex,
|
||||
xCoord, yCoord,zCoord,
|
||||
flippedDataX, packetNumber, bunchId, timestamp, modId, debug, roundRNumber, detType, version);
|
||||
|
||||
|
||||
if (doc.HasMember("threshold")) {
|
||||
version=doc["threshold"].GetUint();
|
||||
|
||||
}
|
||||
|
||||
if (doc.HasMember("roi")) {
|
||||
xmin=doc["roi"][0].GetUint();
|
||||
xmax=doc["roi"][1].GetUint();
|
||||
ymin=doc["roi"][2].GetUint();
|
||||
ymax=doc["roi"][3].GetUint();
|
||||
|
||||
}
|
||||
|
||||
if (doc.HasMember("frameMode")) {
|
||||
frameMode_s=doc["frameMode"].GetString();
|
||||
|
||||
}
|
||||
|
||||
if (doc.HasMember("detectorMode")) {
|
||||
detectorMode_s=doc["detectorMode"].GetString();
|
||||
|
||||
}
|
||||
|
||||
if (doc.HasMember("energyRange")) {
|
||||
emin=doc["energyRange"][0].GetUint();
|
||||
emax=doc["energyRange"][0].GetUint();
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (doc.HasMember("dynamicRange")) {
|
||||
dr=doc["dynamicRange"].GetUint();
|
||||
}
|
||||
|
||||
if (doc.HasMember("nSubPixels")) {
|
||||
nsubPixels=doc["nSubPixels"].GetUint();
|
||||
}
|
||||
|
||||
|
||||
|
||||
newFrame=0;
|
||||
zmqsocket->CloseHeaderMessage();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (of==NULL) {
|
||||
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
|
||||
|
@ -22,55 +22,86 @@ using namespace std;
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [send_socket ip] [send port number]
|
||||
*
|
||||
*/
|
||||
|
||||
int nthreads=20;
|
||||
int nsigma=5;
|
||||
int xmin=0;
|
||||
int xmax=400;
|
||||
int ymin=0;
|
||||
int ymax=400;
|
||||
int nsubpixels=2;
|
||||
|
||||
|
||||
FILE *of=NULL;
|
||||
int fifosize=1000;
|
||||
int nthreads=20;
|
||||
int nsubpixels=2;
|
||||
// help
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
int int_ready=0;
|
||||
int ok;
|
||||
// help
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: %s [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number] [nsubpixels] [nthreads] [nsigma] [xmin xmax ymin ymax]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int size = 32*2*5000;//atoi(argv[3]);
|
||||
int size = 32*2*5000;//atoi(argv[3]);
|
||||
bool send = false;
|
||||
|
||||
// send parameters if any
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
if (argc > 3) {
|
||||
send = true;
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
|
||||
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
if (argc > 3) {
|
||||
send = true;
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
}
|
||||
if (argc > 5) {
|
||||
nsubpixels=atoi(argv[5]);
|
||||
}
|
||||
if (argc>6) {
|
||||
nthreads=atoi(argv[6]);
|
||||
}
|
||||
if (argc>7) {
|
||||
nsigma=atoi(argv[7]);
|
||||
}
|
||||
if (argc>11) {
|
||||
xmin=atoi(argv[8]);
|
||||
xmax=atoi(argv[8]);
|
||||
ymin=atoi(argv[10]);
|
||||
ymax=atoi(argv[11]);
|
||||
}
|
||||
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum ;
|
||||
if (send) {
|
||||
cout << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum ;
|
||||
if (send) {
|
||||
cout << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << endl;
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
int npx, npy;
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
det->getDetectorSize(npx, npy);
|
||||
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
||||
//singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10);
|
||||
linearInterpolation *interp=new linearInterpolation(npx,npy,nsubpixels);
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, 5, 1, 0, 1000, 100,npx,npy);
|
||||
cout << endl;
|
||||
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
int npx, npy;
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
det->getDetectorSize(npx, npy);
|
||||
linearInterpolation *interp=new linearInterpolation(npx,npy,nsubpixels);
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, nsigma, 1, 0, 1000, 100,npx,npy);
|
||||
cout << "Setting noise cut to " << nsigma << " sigma"<< endl;
|
||||
filter->setROI(xmin,xmax,ymin,ymax);
|
||||
cout << "Setting ROI to "<< xmin << " " << xmax << " " << ymin << " " << ymax << endl;
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
mt->setFrameMode(eFrame);
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
int frameMode=eFrame;
|
||||
mt->setFrameMode(frameMode);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
@ -80,9 +111,6 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
|
||||
|
||||
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
@ -93,7 +121,6 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
cout << "zmq2 " << endl;
|
||||
if (send) {
|
||||
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
if (zmqsocket2->IsError()) {
|
||||
@ -113,6 +140,9 @@ int main(int argc, char *argv[]) {
|
||||
uint32_t subframeIndex = -1;
|
||||
uint64_t fileindex = -1;
|
||||
string filename = "";
|
||||
char ffname[10000];
|
||||
int ffindex;
|
||||
|
||||
char* image = new char[size];
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
|
||||
@ -138,36 +168,54 @@ int main(int argc, char *argv[]) {
|
||||
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
|
||||
// cprintf(RED, "Got Dummy\n");
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
if (frameMode==ePedestal) {
|
||||
detped=mt->getPedestal();
|
||||
if (detped) {
|
||||
|
||||
|
||||
detimage=mt->getImage(nix,niy,nis);
|
||||
|
||||
if (detimage) {
|
||||
for (ix=0; ix<nnx; ix++) {
|
||||
for (iy=0; iy<nny; iy++) {
|
||||
dout[iy*nnx+ix]=0;
|
||||
for (isx=0; isx<nis; isx++) {
|
||||
for (isy=0; isy<nis; isy++) {
|
||||
dout[iy*nnx+ix]+=detimage[(iy+isy)*nix+(ix+isx)];
|
||||
}
|
||||
for (ix=0; ix<400; ix++) {
|
||||
for (iy=0; iy<400; iy++) {
|
||||
dout[iy*400+ix]+=detped[iy*400+ix];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (send) {
|
||||
strcpy(fname,filename.c_str());
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,16,fileindex,400,400,400*400, acqIndex,frameIndex,fname, acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
|
||||
zmqsocket2->SendData((char*)dout,length);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
} else {
|
||||
detimage=mt->getImage(nix,niy,nis);
|
||||
if (detimage) {
|
||||
for (ix=0; ix<nix/nis; ix++) {
|
||||
for (iy=0; iy<niy/nis; iy++) {
|
||||
dout[iy*(nix/nis)+ix]=0;
|
||||
}
|
||||
}
|
||||
for (ix=0; ix<nix; ix++) {
|
||||
for (iy=0; iy<niy; iy++) {
|
||||
dout[(iy/nis)*(nix/nis)+(ix/nis)]+=detimage[iy*nix+ix];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(ofname,"%s_%d.tiff",filename.c_str(),fileindex);
|
||||
|
||||
|
||||
|
||||
if (send) {
|
||||
strcpy(fname,filename.c_str());
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,16,fileindex,400,400,400*400, acqIndex,frameIndex,fname, acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
|
||||
zmqsocket2->SendData((char*)dout,length);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
}
|
||||
|
||||
sprintf(ofname,"%s_%d.tiff",ffname,ffindex);
|
||||
if (frameMode==eFlat)
|
||||
mt->writeFlatField(ofname);
|
||||
else if (frameMode==ePedestal)
|
||||
mt->writePedestal(ofname);
|
||||
else
|
||||
mt->writeImage(ofname);
|
||||
|
||||
}
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
if (send) {
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
@ -185,6 +233,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
if (of==NULL) {
|
||||
while (mt->isBusy()) {;}
|
||||
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
|
||||
of=fopen(ofname,"w");
|
||||
if (of) {
|
||||
@ -193,6 +242,32 @@ int main(int argc, char *argv[]) {
|
||||
cout << "Could not open "<< ofname << " for writing " << endl;
|
||||
mt->setFilePointer(NULL);
|
||||
}
|
||||
ffindex=fileindex;
|
||||
strcpy(ffname,filename.c_str());
|
||||
if (filename.find("flat")!=std::string::npos) {
|
||||
cout << "add to ff" << endl;
|
||||
frameMode=eFlat;//ePedestal;
|
||||
int_ready=0;
|
||||
|
||||
} else if (filename.find("newped")!=std::string::npos) {
|
||||
frameMode=ePedestal;
|
||||
cout << "new pedestal" << endl;
|
||||
|
||||
mt->newDataSet();
|
||||
} else if (filename.find("ped")!=std::string::npos){
|
||||
frameMode=ePedestal;
|
||||
cout << "pedestal" << endl;
|
||||
} else {
|
||||
frameMode=eFrame;
|
||||
cout << "data" << endl;
|
||||
if (int_ready==0) {
|
||||
mt->prepareInterpolation(ok);
|
||||
cout << "prepare interpolation " << endl;
|
||||
int_ready=1;
|
||||
}
|
||||
}
|
||||
|
||||
mt->setFrameMode(frameMode);
|
||||
}
|
||||
|
||||
// get data
|
||||
|
710
slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp
Normal file
710
slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp
Normal file
@ -0,0 +1,710 @@
|
||||
#define WRITE_QUAD
|
||||
|
||||
#include "sls_receiver_defs.h"
|
||||
#include "ZmqSocket.h"
|
||||
#include "moench03T1ZmqDataNew.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "tiffIO.h"
|
||||
|
||||
//#define NEWZMQ
|
||||
#ifdef NEWZMQ
|
||||
#include <rapidjson/document.h> //json header in zmq stream
|
||||
#endif
|
||||
|
||||
#include<iostream>
|
||||
|
||||
//#include "analogDetector.h"
|
||||
//#include "multiThreadedAnalogDetector.h"
|
||||
//#include "singlePhotonDetector.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
//#include "multiThreadedCountingDetector.h"
|
||||
#include "multiThreadedInterpolatingDetector.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
//#include <chrono>
|
||||
#include <ctime> // time_t
|
||||
#include <cstdio>
|
||||
|
||||
using namespace std;
|
||||
//using namespace std::chrono;
|
||||
|
||||
//#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
// myDet->setNetworkParameter(ADDITIONAL_JSON_HEADER, " \"what\":\"nothing\" ");
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [send_socket ip] [send port number]
|
||||
*
|
||||
*/
|
||||
FILE *of=NULL;
|
||||
int fifosize=5000;
|
||||
int etabins=1000;//nsubpix*2*100;
|
||||
double etamin=-1, etamax=2;
|
||||
// help
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number] [nthreads] [nsubpix] [etafile]\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
// send parameters if any
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
|
||||
|
||||
int ok;
|
||||
|
||||
// high_resolution_clock::time_point t1;
|
||||
// high_resolution_clock::time_point t2 ;
|
||||
time_t begin,end,finished;
|
||||
|
||||
|
||||
if (argc > 4) {
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
if (portnum2>0)
|
||||
send = true;
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum ;
|
||||
if (send) {
|
||||
cout << "\ntx socket ip : " << socketip2 <<
|
||||
"\ntx port num : " << portnum2;
|
||||
}
|
||||
int nthreads=5;
|
||||
if (argc>5)
|
||||
nthreads=atoi(argv[5]);
|
||||
|
||||
cout << "Number of threads is: " << nthreads << endl;
|
||||
int nSubPixels=2;
|
||||
if (argc>6)
|
||||
nSubPixels=atoi(argv[6]);
|
||||
cout << "Number of subpixels is: " << nSubPixels << endl;
|
||||
|
||||
char *etafname=NULL;
|
||||
if (argc>7) {
|
||||
etafname=argv[7];
|
||||
cout << "Eta file name is: " << etafname << endl;
|
||||
}
|
||||
|
||||
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
cout << endl << " det" <<endl;
|
||||
int npx, npy;
|
||||
det->getDetectorSize(npx, npy);
|
||||
|
||||
|
||||
|
||||
|
||||
int maxSize = npx*npy*2;//32*2*8192;//5000;//atoi(argv[3]);
|
||||
int size= maxSize;//32*2*5000;
|
||||
int multisize=size;
|
||||
int dataSize=size;
|
||||
|
||||
char dummybuff[size];
|
||||
|
||||
|
||||
|
||||
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
||||
#ifndef INTERP
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10);
|
||||
|
||||
multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
|
||||
|
||||
// multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
#endif
|
||||
#ifdef INTERP
|
||||
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(npx, npy, nSubPixels, etabins, etamin, etamax);
|
||||
|
||||
if (etafname) interp->readFlatField(etafname);
|
||||
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, 5, 1, 0, 1000, 10);
|
||||
multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
char* buff;
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
ZmqSocket* zmqsocket=NULL;
|
||||
|
||||
#ifdef NEWZMQ
|
||||
// receive socket
|
||||
try{
|
||||
#endif
|
||||
|
||||
zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
|
||||
|
||||
#ifdef NEWZMQ
|
||||
} catch (...) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEWZMQ
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif
|
||||
if (zmqsocket->Connect()) {
|
||||
cprintf(RED, "Error: Could not connect to socket %s\n",
|
||||
zmqsocket->GetZmqServerAddress());
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
} else
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
// cout << "zmq2 " << endl;
|
||||
if (send) {
|
||||
#ifdef NEWZMQ
|
||||
// receive socket
|
||||
try{
|
||||
#endif
|
||||
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
|
||||
|
||||
|
||||
#ifdef NEWZMQ
|
||||
} catch (...) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
// delete zmqsocket2;
|
||||
// zmqsocket2=NULL;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
send = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEWZMQ
|
||||
if (zmqsocket2->IsError()) {
|
||||
cprintf(RED, "AAA Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
// delete zmqsocket2;
|
||||
//delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
send = false;
|
||||
}
|
||||
#endif
|
||||
if (zmqsocket2->Connect()) {
|
||||
cprintf(RED, "BBB Error: Could not connect to socket %s\n",
|
||||
zmqsocket2->GetZmqServerAddress());
|
||||
// delete zmqsocket2;
|
||||
send = false;
|
||||
// return EXIT_FAILURE;
|
||||
} else
|
||||
printf("Zmq Client at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
|
||||
}
|
||||
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subFrameIndex = -1;
|
||||
uint64_t fileindex = -1;
|
||||
string filename = "";
|
||||
// char* image = new char[size];
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
uint32_t flippedDataX = -1;
|
||||
int *nph;
|
||||
int iframe=0;
|
||||
char ofname[10000];
|
||||
|
||||
char fname[10000];
|
||||
int length;
|
||||
int *detimage;
|
||||
int nnx, nny,nns;
|
||||
uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0;
|
||||
// infinite loop
|
||||
uint32_t packetNumber = 0;
|
||||
uint64_t bunchId = 0;
|
||||
uint64_t timestamp = 0;
|
||||
int16_t modId = 0;
|
||||
uint16_t xCoord = 0;
|
||||
uint16_t yCoord = 0;
|
||||
uint16_t zCoord = 0;
|
||||
uint32_t debug = 0;
|
||||
//uint32_t dr = 16;
|
||||
//int16_t *dout;//=new int16_t [nnx*nny];
|
||||
uint32_t dr = 32;
|
||||
int32_t *dout=NULL;//=new int32_t [nnx*nny];
|
||||
uint32_t nSigma=5;
|
||||
uint16_t roundRNumber = 0;
|
||||
uint8_t detType = 0;
|
||||
uint8_t version = 0;
|
||||
int* flippedData = 0;
|
||||
char* additionalJsonHeader = 0;
|
||||
|
||||
int32_t threshold=0;
|
||||
|
||||
int32_t xmin=0, xmax=400, ymin=0, ymax=400;
|
||||
|
||||
string frameMode_s, detectorMode_s, intMode_s;
|
||||
|
||||
int emin, emax;
|
||||
int resetFlat=0;
|
||||
int resetPed=0;
|
||||
int nsubPixels=1;
|
||||
int isPedestal;
|
||||
int isFlat=0;
|
||||
int newFrame=1;
|
||||
detectorMode dMode;
|
||||
frameMode fMode;
|
||||
double *ped;
|
||||
|
||||
filter->getImageSize(nnx, nny,nns);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
while(1) {
|
||||
|
||||
|
||||
// cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
#ifndef NEWZMQ
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){
|
||||
#endif
|
||||
|
||||
#ifdef NEWZMQ
|
||||
rapidjson::Document doc;
|
||||
if (!zmqsocket->ReceiveHeader(0, doc, SLS_DETECTOR_JSON_HEADER_VERSION)) {
|
||||
/* zmqsocket->CloseHeaderMessage();*/
|
||||
|
||||
#endif
|
||||
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
|
||||
// cprintf(RED, "Got Dummy\n");
|
||||
// t1=high_resolution_clock::now();
|
||||
time(&end);
|
||||
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
if (of) {
|
||||
fclose(of);
|
||||
of=NULL;
|
||||
}
|
||||
if (newFrame>0) {
|
||||
cprintf(RED,"DIDn't receive any data!\n");
|
||||
if (send) {
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
}
|
||||
} else {
|
||||
if (fMode==ePedestal) {
|
||||
sprintf(ofname,"%s_%d_ped.tiff",fname,fileindex);
|
||||
mt->writePedestal(ofname);
|
||||
cout << "Writing pedestal to " << ofname << endl;
|
||||
}
|
||||
#ifdef INTERP
|
||||
else if (fMode==eFlat) {
|
||||
mt->prepareInterpolation(ok);
|
||||
sprintf(ofname,"%s_%d_eta.tiff",fname,fileindex);
|
||||
mt->writeFlatField(ofname);
|
||||
cout << "Writing eta to " << ofname << endl;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
sprintf(ofname,"%s_%d.tiff",fname,fileindex);
|
||||
mt->writeImage(ofname);
|
||||
cout << "Writing image to " << ofname << endl;
|
||||
}
|
||||
// cout << nns*nnx*nny*nns*dr/8 << " " << length << endl;
|
||||
|
||||
if (send) {
|
||||
|
||||
if (fMode==ePedestal) {
|
||||
cprintf(MAGENTA,"Get pedestal!\n");
|
||||
nns=1;
|
||||
nnx=npx;
|
||||
nny=npy;
|
||||
//dout= new int16_t[nnx*nny*nns*nns];
|
||||
dout= new int32_t[nnx*nny*nns*nns];
|
||||
// cout << "get pedestal " << endl;
|
||||
ped=mt->getPedestal();
|
||||
// cout << "got pedestal " << endl;
|
||||
for (int ix=0; ix<nnx*nny; ix++) {
|
||||
|
||||
dout[ix]=ped[ix];
|
||||
// if (ix<100*400)
|
||||
// cout << ix << " " << ped[ix] << endl;
|
||||
}
|
||||
|
||||
}
|
||||
#ifdef INTERP
|
||||
else if (fMode==eFlat) {
|
||||
int nb;
|
||||
double emi, ema;
|
||||
int *ff=mt->getFlatField(nb, emi, ema);
|
||||
nnx=nb;
|
||||
nny=nb;
|
||||
dout= new int32_t[nb*nb];
|
||||
for (int ix=0; ix<nb*nb; ix++) {
|
||||
dout[ix]=ff[ix];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
detimage=mt->getImage(nnx,nny,nns);
|
||||
cprintf(MAGENTA,"Get image!\n");
|
||||
cout << nnx << " " << nny << " " << nns << endl;
|
||||
// nns=1;
|
||||
// nnx=npx;
|
||||
// nny=npy;
|
||||
// nnx=nnx*nns;
|
||||
//nny=nny*nns;
|
||||
dout= new int32_t[nnx*nny];
|
||||
for (int ix=0; ix<nnx*nny; ix++) {
|
||||
// for (int iy=0; iy<nny*nns; iy++) {
|
||||
// for (int isx=0; isx<nns; isx++) {
|
||||
// for (int isy=0; isy<nns; isy++) {
|
||||
// if (isx==0 && isy==0)
|
||||
// dout[iy*nnx+ix]=detimage[(iy+isy)*nnx*nns+ix+isx];
|
||||
// else
|
||||
// dout[iy*nnx+ix]+=detimage[(iy+isy)*nnx*nns+ix+isx];
|
||||
|
||||
// }
|
||||
// }
|
||||
dout[ix]=detimage[ix];
|
||||
if (dout[ix]<0) dout[ix]=0;
|
||||
// cout << ix << " " << dout[ix] << endl;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef NEWZMQ
|
||||
cout << "Sending image size " << nnx << " " << nny << endl;
|
||||
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NEWZMQ
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
#endif
|
||||
|
||||
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
if (dout)
|
||||
delete [] dout;
|
||||
dout=NULL;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
mt->clearImage();
|
||||
|
||||
newFrame=1;
|
||||
//t2 = high_resolution_clock::now();
|
||||
|
||||
time(&finished);
|
||||
// auto meas_duration = duration_cast<microseconds>( t2 - t0 ).count();
|
||||
// auto real_duration = duration_cast<microseconds>( t2 - t1 ).count();
|
||||
|
||||
cout << "Measurement lasted " << difftime(end,begin) << endl;
|
||||
cout << "Processing lasted " << difftime(finished,begin) << endl;
|
||||
continue; //continue to not get out
|
||||
|
||||
|
||||
}
|
||||
|
||||
#ifdef NEWZMQ
|
||||
if (newFrame) {
|
||||
time(&begin);
|
||||
// t0 = high_resolution_clock::now();
|
||||
//cout <<"new frame" << endl;
|
||||
|
||||
// acqIndex, frameIndex, subframeIndex, filename, fileindex
|
||||
size = doc["size"].GetUint();
|
||||
// multisize = size;// * zmqsocket->size();
|
||||
dynamicRange = doc["bitmode"].GetUint();
|
||||
// nPixelsX = doc["shape"][0].GetUint();
|
||||
// nPixelsY = doc["shape"][1].GetUint();
|
||||
filename = doc["fname"].GetString();
|
||||
//acqIndex = doc["acqIndex"].GetUint64();
|
||||
//frameIndex = doc["fIndex"].GetUint64();
|
||||
fileindex = doc["fileIndex"].GetUint64();
|
||||
//subFrameIndex = doc["expLength"].GetUint();
|
||||
//packetNumber=doc["packetNumber"].GetUint();
|
||||
//bunchId=doc["bunchId"].GetUint();
|
||||
//timestamp=doc["timestamp"].GetUint();
|
||||
//modId=doc["modId"].GetUint();
|
||||
//debug=doc["debug"].GetUint();
|
||||
//roundRNumber=doc["roundRNumber"].GetUint();
|
||||
//detType=doc["detType"].GetUint();
|
||||
//version=doc["version"].GetUint();
|
||||
|
||||
dataSize=size;
|
||||
|
||||
strcpy(fname,filename.c_str());
|
||||
|
||||
// cprintf(BLUE, "Header Info:\n"
|
||||
// "size: %u\n"
|
||||
// "multisize: %u\n"
|
||||
// "dynamicRange: %u\n"
|
||||
// "nPixelsX: %u\n"
|
||||
// "nPixelsY: %u\n"
|
||||
// "currentFileName: %s\n"
|
||||
// "currentAcquisitionIndex: %lu\n"
|
||||
// "currentFrameIndex: %lu\n"
|
||||
// "currentFileIndex: %lu\n"
|
||||
// "currentSubFrameIndex: %u\n"
|
||||
// "xCoordX: %u\n"
|
||||
// "yCoordY: %u\n"
|
||||
// "zCoordZ: %u\n"
|
||||
// "flippedDataX: %u\n"
|
||||
// "packetNumber: %u\n"
|
||||
// "bunchId: %u\n"
|
||||
// "timestamp: %u\n"
|
||||
// "modId: %u\n"
|
||||
// "debug: %u\n"
|
||||
// "roundRNumber: %u\n"
|
||||
// "detType: %u\n"
|
||||
// "version: %u\n",
|
||||
// size, multisize, dynamicRange, nPixelsX, nPixelsY,
|
||||
// filename.c_str(), acqIndex,
|
||||
// frameIndex, fileindex, subFrameIndex,
|
||||
// xCoord, yCoord,zCoord,
|
||||
// flippedDataX, packetNumber, bunchId, timestamp, modId, debug, roundRNumber, detType, version);
|
||||
|
||||
/* Analog detector commands */
|
||||
isPedestal=0;
|
||||
isFlat=0;
|
||||
fMode=eFrame;
|
||||
frameMode_s="frame";
|
||||
cprintf(MAGENTA, "Frame mode: ");
|
||||
if (doc.HasMember("frameMode")) {
|
||||
if (doc["frameMode"].IsString()) {
|
||||
frameMode_s=doc["frameMode"].GetString();
|
||||
if (frameMode_s == "pedestal"){
|
||||
fMode=ePedestal;
|
||||
isPedestal=1;
|
||||
} else if (frameMode_s == "newPedestal"){
|
||||
mt->newDataSet(); //resets pedestal
|
||||
// cprintf(MAGENTA, "Resetting pedestal\n");
|
||||
fMode=ePedestal;
|
||||
isPedestal=1;
|
||||
}
|
||||
#ifdef INTERP
|
||||
else if (frameMode_s == "flatfield") {
|
||||
fMode=eFlat;
|
||||
isFlat=1;
|
||||
} else if (frameMode_s == "newFlatfield") {
|
||||
mt->resetFlatField();
|
||||
isFlat=1;
|
||||
cprintf(MAGENTA, "Resetting flatfield\n");
|
||||
fMode=eFlat;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
fMode=eFrame;
|
||||
isPedestal=0;
|
||||
isFlat=0;
|
||||
fMode=eFrame;
|
||||
frameMode_s="frame";
|
||||
}
|
||||
}
|
||||
}
|
||||
cprintf(MAGENTA, "%s\n" , frameMode_s.c_str());
|
||||
mt->setFrameMode(fMode);
|
||||
|
||||
// threshold=0;
|
||||
cprintf(MAGENTA, "Threshold: ");
|
||||
if (doc.HasMember("threshold")) {
|
||||
if (doc["threshold"].IsInt()) {
|
||||
threshold=doc["threshold"].GetInt();
|
||||
mt->setThreshold(threshold);
|
||||
}
|
||||
}
|
||||
cprintf(MAGENTA, "%d\n", threshold);
|
||||
|
||||
xmin=0;
|
||||
xmax=npx;
|
||||
ymin=0;
|
||||
ymax=npy;
|
||||
cprintf(MAGENTA, "ROI: ");
|
||||
if (doc.HasMember("roi")) {
|
||||
if (doc["roi"].IsArray()) {
|
||||
if (doc["roi"].Size() > 0 )
|
||||
if (doc["roi"][0].IsInt())
|
||||
xmin=doc["roi"][0].GetInt();
|
||||
|
||||
if (doc["roi"].Size() > 1 )
|
||||
if (doc["roi"][1].IsInt())
|
||||
xmax=doc["roi"][1].GetInt();
|
||||
|
||||
if (doc["roi"].Size() > 2 )
|
||||
if (doc["roi"][2].IsInt())
|
||||
ymin=doc["roi"][2].GetInt();
|
||||
|
||||
if (doc["roi"].Size() > 3 )
|
||||
if (doc["roi"][3].IsInt())
|
||||
ymax=doc["roi"][3].GetInt();
|
||||
}
|
||||
}
|
||||
|
||||
cprintf(MAGENTA, "%d %d %d %d\n", xmin, xmax, ymin, ymax);
|
||||
mt->setROI(xmin, xmax, ymin, ymax);
|
||||
|
||||
if (doc.HasMember("dynamicRange")) {
|
||||
dr=doc["dynamicRange"].GetUint();
|
||||
dr=32;
|
||||
}
|
||||
|
||||
dMode=eAnalog;
|
||||
detectorMode_s="analog";
|
||||
cprintf(MAGENTA, "Detector mode: ");
|
||||
if (doc.HasMember("detectorMode")) {
|
||||
if (doc["detectorMode"].IsString()) {
|
||||
detectorMode_s=doc["detectorMode"].GetString();
|
||||
#ifdef INTERP
|
||||
if (detectorMode_s == "interpolating"){
|
||||
dMode=eInterpolating;
|
||||
mt->setInterpolation(interp);
|
||||
} else
|
||||
#endif
|
||||
if (detectorMode_s == "counting"){
|
||||
dMode=ePhotonCounting;
|
||||
#ifdef INTERP
|
||||
mt->setInterpolation(NULL);
|
||||
#endif
|
||||
} else {
|
||||
dMode=eAnalog;
|
||||
#ifdef INTERP
|
||||
mt->setInterpolation(NULL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mt->setDetectorMode(dMode);
|
||||
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
|
||||
|
||||
// cout << "done " << endl;
|
||||
|
||||
// /* Single Photon Detector commands */
|
||||
// nSigma=5;
|
||||
// if (doc.HasMember("nSigma")) {
|
||||
// if (doc["nSigma"].IsInt())
|
||||
// nSigma=doc["nSigma"].GetInt();
|
||||
// mt->setNSigma(nSigma);
|
||||
// }
|
||||
|
||||
// emin=-1;
|
||||
// emax=-1;
|
||||
// if (doc.HasMember("energyRange")) {
|
||||
// if (doc["energyRange"].IsArray()) {
|
||||
// if (doc["energyRange"].Size() > 0 )
|
||||
// if (doc["energyRange"][0].IsInt())
|
||||
// emin=doc["energyRange"][0].GetInt();
|
||||
|
||||
// if (doc["energyRange"].Size() > 1 )
|
||||
// if (doc["energyRange"][1].IsInt())
|
||||
// emax=doc["energyRange"][1].GetUint();
|
||||
// }
|
||||
// }
|
||||
// if (doc.HasMember("eMin")) {
|
||||
// if (doc["eMin"][1].IsInt())
|
||||
// emin=doc["eMin"].GetInt();
|
||||
// }
|
||||
// if (doc.HasMember("eMax")) {
|
||||
// if (doc["eMax"][1].IsInt())
|
||||
// emin=doc["eMax"].GetInt();
|
||||
// }
|
||||
// mt->setEnergyRange(emin,emax);
|
||||
|
||||
// /* interpolating detector commands */
|
||||
|
||||
// if (doc.HasMember("nSubPixels")) {
|
||||
// if (doc["nSubPixels"].IsUint())
|
||||
// nSubPixels=doc["nSubPixels"].GetUint();
|
||||
// mt->setNSubPixels(nSubPixels);
|
||||
// }
|
||||
|
||||
|
||||
newFrame=0;
|
||||
/* zmqsocket->CloseHeaderMessage();*/
|
||||
}
|
||||
#endif
|
||||
|
||||
// cout << "file" << endl;
|
||||
// cout << "data " << endl;
|
||||
if (of==NULL) {
|
||||
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
|
||||
of=fopen(ofname,"w");
|
||||
if (of) {
|
||||
mt->setFilePointer(of);
|
||||
}else {
|
||||
cout << "Could not open "<< ofname << " for writing " << endl;
|
||||
mt->setFilePointer(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// cout << "data" << endl;
|
||||
// get data
|
||||
// acqIndex = doc["acqIndex"].GetUint64();
|
||||
frameIndex = doc["fIndex"].GetUint64();
|
||||
// subFrameIndex = doc["expLength"].GetUint();
|
||||
|
||||
// bunchId=doc["bunchId"].GetUint();
|
||||
// timestamp=doc["timestamp"].GetUint();
|
||||
packetNumber=doc["packetNumber"].GetUint();
|
||||
// cout << acqIndex << " " << frameIndex << " " << subFrameIndex << " "<< bunchId << " " << timestamp << " " << packetNumber << endl;
|
||||
if (packetNumber>=40) {
|
||||
//*((int*)buff)=frameIndex;
|
||||
memcpy(buff,&frameIndex,sizeof(int));
|
||||
length = zmqsocket->ReceiveData(0, buff+sizeof(int), size);
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
} else {
|
||||
cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber);
|
||||
length = zmqsocket->ReceiveData(0, dummybuff, size);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
iframe++;
|
||||
|
||||
} // exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
if (send)
|
||||
delete zmqsocket2;
|
||||
|
||||
|
||||
cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef MULTITHREADED_ANALOG_DETECTOR_H
|
||||
#define MULTITHREADED_ANALOG_DETECTOR_H
|
||||
|
||||
#define MAXTHREADS 1000
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
@ -14,11 +16,8 @@
|
||||
#include <cstdlib>
|
||||
#include <pthread.h>
|
||||
|
||||
//#include "analogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
#include "analogDetector.h"
|
||||
#include "circularFifo.h"
|
||||
#include "slsInterpolation.h"
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -28,6 +27,7 @@
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
class threadedAnalogDetector
|
||||
{
|
||||
public:
|
||||
@ -36,12 +36,25 @@ public:
|
||||
det=d;
|
||||
fifoFree=new CircularFifo<char>(fs);
|
||||
fifoData=new CircularFifo<char>(fs);
|
||||
mem=(char*)malloc(fs*det->getDataSize());
|
||||
// cout << "data size is " << det->getDataSize()*fs << endl;
|
||||
for (int i=0; i<fs; i++) {
|
||||
mm=mem+i*det->getDataSize();
|
||||
fifoFree->push(mm);
|
||||
|
||||
/* mem=(char*)calloc(fs, det->getDataSize()); */
|
||||
/* if (mem) */
|
||||
/* memset(mem,0, fs*det->getDataSize()); */
|
||||
int i;
|
||||
for (i=0; i<fs; i++) {
|
||||
//
|
||||
// mm=mem+i*det->getDataSize();
|
||||
// cout << i << endl;
|
||||
mm=(char*)calloc(1, det->getDataSize());
|
||||
if (mm) {
|
||||
//memset(mm,0, det->getDataSize());
|
||||
fifoFree->push(mm);
|
||||
} else
|
||||
break;
|
||||
}
|
||||
if (i<fs) cout << "Could allocate only "<< i <<" frames";
|
||||
|
||||
|
||||
busy=0;
|
||||
stop=1;
|
||||
fMode=eFrame;
|
||||
@ -49,8 +62,27 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual int setFrameMode(int fm) {fMode=fm; if (fMode>=0) det->setFrameMode((frameMode)fMode);};
|
||||
virtual int setFrameMode(int fm) {
|
||||
if (fm>=0) {
|
||||
det->setFrameMode((frameMode)fm);
|
||||
fMode=fm;
|
||||
}
|
||||
return fMode;
|
||||
};
|
||||
virtual double setThreshold(double th) {return det->setThreshold(th);};
|
||||
|
||||
|
||||
|
||||
virtual void setROI(int xmin, int xmax, int ymin, int ymax) {det->setROI(xmin,xmax,ymin,ymax);};
|
||||
virtual int setDetectorMode(int dm) {
|
||||
if (dm>=0) {
|
||||
det->setDetectorMode((detectorMode)dm);
|
||||
dMode=dm;
|
||||
}
|
||||
return dMode;
|
||||
};
|
||||
|
||||
virtual void newDataSet(){det->newDataSet();};
|
||||
//fMode=fm; return fMode;}
|
||||
|
||||
/* void prepareInterpolation(int &ok) { */
|
||||
@ -91,46 +123,10 @@ public:
|
||||
//protected:
|
||||
/** Implement this method in your subclass with the code you want your thread to run. */
|
||||
//virtual void InternalThreadEntry() = 0;
|
||||
virtual void *writeImage(const char * imgname) {cout << "a" <<endl; return det->writeImage(imgname);};
|
||||
virtual void *writeImage(const char * imgname) {return det->writeImage(imgname);};
|
||||
|
||||
virtual void clearImage(){det->clearImage();};
|
||||
|
||||
virtual void prepareInterpolation(int &ok){
|
||||
slsInterpolation *interp=(slsInterpolation*)det->getInterpolation();
|
||||
if (interp)
|
||||
interp->prepareInterpolation(ok);
|
||||
}
|
||||
|
||||
virtual int *getFlatField(){
|
||||
slsInterpolation *interp=(slsInterpolation*)det->getInterpolation();
|
||||
if (interp)
|
||||
return interp->getFlatField();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual int *setFlatField(int *ff, int nb, double emin, double emax){
|
||||
slsInterpolation *interp=(slsInterpolation*)det->getInterpolation();
|
||||
if (interp)
|
||||
return interp->setFlatField(ff, nb, emin, emax);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual int *getFlatField(int &nb, double emi, double ema){
|
||||
slsInterpolation *interp=(slsInterpolation*)det->getInterpolation();
|
||||
int *ff;
|
||||
if (interp) {
|
||||
ff=interp->getFlatField(nb,emi,ema);
|
||||
// cout << "tdgff* ff has " << nb << " bins " << endl;
|
||||
return ff;
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual char *getInterpolation() {
|
||||
return det->getInterpolation();
|
||||
}
|
||||
|
||||
virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){det->setPedestal(ped,rms,m);};
|
||||
|
||||
@ -157,11 +153,79 @@ public:
|
||||
FILE *getFilePointer(){return det->getFilePointer();};
|
||||
|
||||
|
||||
void setMutex(pthread_mutex_t *fmutex){det->setMutex(fmutex);};
|
||||
|
||||
private:
|
||||
virtual double setNSigma(double n) {return det->setNSigma(n);};
|
||||
virtual void setEnergyRange(double emi, double ema) {det->setEnergyRange(emi,ema);};
|
||||
|
||||
|
||||
virtual void prepareInterpolation(int &ok){
|
||||
slsInterpolation *interp=det->getInterpolation();
|
||||
if (interp)
|
||||
interp->prepareInterpolation(ok);
|
||||
}
|
||||
|
||||
virtual int *getFlatField(){
|
||||
slsInterpolation *interp=(det)->getInterpolation();
|
||||
if (interp)
|
||||
return interp->getFlatField();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual int *setFlatField(int *ff, int nb, double emin, double emax){
|
||||
slsInterpolation *interp=(det)->getInterpolation();
|
||||
if (interp)
|
||||
return interp->setFlatField(ff, nb, emin, emax);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *writeFlatField(const char * imgname) {
|
||||
slsInterpolation *interp=(det)->getInterpolation();
|
||||
cout << "interp " << interp << endl;
|
||||
if (interp) {
|
||||
cout << imgname << endl;
|
||||
interp->writeFlatField(imgname);
|
||||
}
|
||||
}
|
||||
void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){
|
||||
slsInterpolation *interp=(det)->getInterpolation();
|
||||
if (interp)
|
||||
interp->readFlatField(imgname, nb, emin, emax);
|
||||
}
|
||||
|
||||
virtual int *getFlatField(int &nb, double emi, double ema){
|
||||
slsInterpolation *interp=(det)->getInterpolation();
|
||||
int *ff=NULL;
|
||||
if (interp) {
|
||||
ff=interp->getFlatField(nb,emi,ema);
|
||||
}
|
||||
return ff;
|
||||
}
|
||||
|
||||
virtual slsInterpolation *getInterpolation() {
|
||||
return (det)->getInterpolation();
|
||||
}
|
||||
|
||||
virtual void resetFlatField() {
|
||||
slsInterpolation *interp=(det)->getInterpolation();
|
||||
if (interp) interp->resetFlatField();//((interpolatingDetector*)det)->resetFlatField();
|
||||
}
|
||||
|
||||
|
||||
virtual int setNSubPixels(int ns) {
|
||||
slsInterpolation *interp=(det)->getInterpolation();
|
||||
if (interp) return interp->setNSubPixels(ns);
|
||||
else return 1;};
|
||||
|
||||
|
||||
virtual slsInterpolation *setInterpolation(slsInterpolation *f){
|
||||
return (det)->setInterpolation(f);
|
||||
};
|
||||
protected:
|
||||
analogDetector<uint16_t> *det;
|
||||
int fMode;
|
||||
int dMode;
|
||||
int *dataSize;
|
||||
pthread_t _thread;
|
||||
char *mem;
|
||||
@ -176,6 +240,7 @@ private:
|
||||
threadedAnalogDetector *This=((threadedAnalogDetector *)ptr);
|
||||
return This->processData();
|
||||
}
|
||||
|
||||
void * processData() {
|
||||
busy=1;
|
||||
while (!stop) {
|
||||
@ -201,7 +266,7 @@ private:
|
||||
class multiThreadedAnalogDetector
|
||||
{
|
||||
public:
|
||||
multiThreadedAnalogDetector(analogDetector<uint16_t> *d, int n, int fs=1000) : nThreads(n), ithread(0) {
|
||||
multiThreadedAnalogDetector(analogDetector<uint16_t> *d, int n, int fs=1000) : stop(0), nThreads(n), ithread(0) {
|
||||
dd[0]=d;
|
||||
if (nThreads==1)
|
||||
dd[0]->setId(100);
|
||||
@ -213,14 +278,14 @@ public:
|
||||
}
|
||||
|
||||
for (int i=0; i<nThreads; i++) {
|
||||
cout << "**" << i << endl;
|
||||
dets[i]=new threadedAnalogDetector(dd[i], fs);
|
||||
}
|
||||
|
||||
int nnx, nny, ns;
|
||||
int nn=dets[0]->getImageSize(nnx, nny,ns);
|
||||
image=new int[nn];
|
||||
image=NULL;
|
||||
ff=NULL;
|
||||
ped=NULL;
|
||||
cout << "Ithread is " << ithread << endl;
|
||||
}
|
||||
|
||||
~multiThreadedAnalogDetector() {
|
||||
@ -229,26 +294,43 @@ public:
|
||||
delete dets[i];
|
||||
for (int i=1; i<nThreads; i++)
|
||||
delete dd[i];
|
||||
delete [] image;
|
||||
//delete [] image;
|
||||
}
|
||||
|
||||
|
||||
int setFrameMode(int fm) { int ret; for (int i=0; i<nThreads; i++) ret=dets[i]->setFrameMode(fm); return ret;};
|
||||
virtual int setFrameMode(int fm) { int ret; for (int i=0; i<nThreads; i++) { ret=dets[i]->setFrameMode(fm);} return ret;};
|
||||
virtual double setThreshold(int fm) { double ret; for (int i=0; i<nThreads; i++) ret=dets[i]->setThreshold(fm); return ret;};
|
||||
virtual int setDetectorMode(int dm) { int ret; for (int i=0; i<nThreads; i++) ret=dets[i]->setDetectorMode(dm); return ret;};
|
||||
virtual void setROI(int xmin, int xmax, int ymin, int ymax) { for (int i=0; i<nThreads; i++) dets[i]->setROI(xmin, xmax,ymin,ymax);};
|
||||
|
||||
int *getImage(int &nnx, int &nny, int &ns) {
|
||||
|
||||
virtual void newDataSet(){for (int i=0; i<nThreads; i++) dets[i]->newDataSet();};
|
||||
|
||||
virtual int *getImage(int &nnx, int &nny, int &ns) {
|
||||
int *img;
|
||||
// int nnx, nny, ns;
|
||||
int nn=dets[0]->getImageSize(nnx, nny, ns);
|
||||
// int nnx, nny, ns;
|
||||
int nn=dets[0]->getImageSize(nnx, nny,ns);
|
||||
if (image) {
|
||||
delete image;
|
||||
image=NULL;
|
||||
}
|
||||
image=new int[nn];
|
||||
//int nn=dets[0]->getImageSize(nnx, nny, ns);
|
||||
//for (i=0; i<nn; i++) image[i]=0;
|
||||
|
||||
for (int ii=0; ii<nThreads; ii++) {
|
||||
// cout << ii << " " << dets[ii]->getImageSize(nnx, nny, ns) << " " << nnx << " " << nny << " " << ns << endl;
|
||||
//cout << ii << " " << nn << " " << nnx << " " << nny << " " << ns << endl;
|
||||
img=dets[ii]->getImage();
|
||||
for (int i=0; i<nn; i++) {
|
||||
if (ii==0)
|
||||
image[i]=img[i];
|
||||
else
|
||||
// if (img[i]>0)
|
||||
image[i]=img[i];
|
||||
// else
|
||||
// image[i]=0;
|
||||
else //if (img[i]>0)
|
||||
image[i]+=img[i];
|
||||
//if (img[i]) cout << "det " << ii << " pix " << i << " val " << img[i] << " " << image[i] << endl;
|
||||
}
|
||||
|
||||
}
|
||||
@ -257,7 +339,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
void clearImage() {
|
||||
virtual void clearImage() {
|
||||
|
||||
for (int ii=0; ii<nThreads; ii++) {
|
||||
dets[ii]->clearImage();
|
||||
@ -265,7 +347,7 @@ public:
|
||||
|
||||
}
|
||||
|
||||
virtual void *writeImage(const char * imgname) {
|
||||
virtual void *writeImage(const char * imgname, double t=1) {
|
||||
/* #ifdef SAVE_ALL */
|
||||
/* for (int ii=0; ii<nThreads; ii++) { */
|
||||
/* char tit[10000];cout << "m" <<endl; */
|
||||
@ -280,8 +362,15 @@ public:
|
||||
float *gm=new float[nn];
|
||||
if (gm) {
|
||||
for (int ix=0; ix<nn; ix++) {
|
||||
// if (image[ix]>0) cout << ix << " " << image[ix]<< endl;
|
||||
gm[ix]=image[ix];
|
||||
if (t) {
|
||||
if (image[ix]<0)
|
||||
gm[ix]=0;
|
||||
else
|
||||
gm[ix]=(image[ix])/t;
|
||||
} else
|
||||
gm[ix]=image[ix];
|
||||
|
||||
//if (image[ix]>0 && ix/nnx<350) cout << ix/nnx << " " << ix%nnx << " " << image[ix]<< " " << gm[ix] << endl;
|
||||
}
|
||||
//cout << "image " << nnx << " " << nny << endl;
|
||||
WriteToTiff(gm,imgname ,nnx, nny);
|
||||
@ -292,11 +381,12 @@ public:
|
||||
|
||||
|
||||
virtual void StartThreads() {
|
||||
for (int i=0; i<nThreads; i++)
|
||||
for (int i=0; i<nThreads; i++) {
|
||||
dets[i]->StartThread();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void StopThreads() {
|
||||
@ -306,7 +396,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
int isBusy() {
|
||||
virtual int isBusy() {
|
||||
int ret=0, ret1;
|
||||
for (int i=0; i<nThreads; i++) {
|
||||
ret1=dets[i]->isBusy();
|
||||
@ -317,125 +407,21 @@ public:
|
||||
}
|
||||
|
||||
|
||||
bool pushData(char* &ptr) {
|
||||
virtual bool pushData(char* &ptr) {
|
||||
dets[ithread]->pushData(ptr);
|
||||
}
|
||||
|
||||
bool popFree(char* &ptr) {
|
||||
virtual bool popFree(char* &ptr) {
|
||||
// cout << ithread << endl;
|
||||
dets[ithread]->popFree(ptr);
|
||||
}
|
||||
|
||||
int nextThread() {
|
||||
virtual int nextThread() {
|
||||
ithread++;
|
||||
if (ithread==nThreads) ithread=0;
|
||||
return ithread;
|
||||
}
|
||||
|
||||
virtual void prepareInterpolation(int &ok){
|
||||
getFlatField(); //sum up all etas
|
||||
setFlatField(); //set etas to all detectors
|
||||
for (int i=0; i<nThreads; i++) {
|
||||
dets[i]->prepareInterpolation(ok);
|
||||
}
|
||||
}
|
||||
|
||||
virtual int *getFlatField(){
|
||||
int nb=0;
|
||||
double emi, ema;
|
||||
int *f0;
|
||||
slsInterpolation* inte=(slsInterpolation*)dets[0]->getInterpolation();
|
||||
if (inte) {
|
||||
if (inte->getFlatField(nb,emi,ema)) {
|
||||
if (ff) delete [] ff;
|
||||
ff=new int[nb*nb];
|
||||
for (int i=0; i<nThreads; i++) {
|
||||
// cout << "mtgff* ff has " << nb << " bins " << endl;
|
||||
inte=(slsInterpolation*)dets[i]->getInterpolation();
|
||||
f0=inte->getFlatField();
|
||||
if (f0) {
|
||||
// cout << "ff " << i << endl;
|
||||
for (int ib=0; ib<nb*nb; ib++) {
|
||||
if (i==0)
|
||||
ff[ib]=f0[ib];
|
||||
else
|
||||
ff[ib]+=f0[ib];
|
||||
/* if (i==0 && f0[ib]>0) */
|
||||
/* cout << i << " " << ib << " " << f0[ib] << " " << ff[ib] << endl; */
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return ff;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
virtual int *setFlatField(int *h=NULL, int nb=-1, double emin=1, double emax=0){
|
||||
//int nb=0;
|
||||
double emi, ema;
|
||||
slsInterpolation* inte=(slsInterpolation*)dets[0]->getFlatField(nb,emi,ema);
|
||||
if (inte) {
|
||||
if (h==NULL) h=ff;
|
||||
for (int i=0; i<nThreads; i++) {
|
||||
dets[i]->setFlatField(h, nb, emin, emax);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
void *writeFlatField(const char * imgname){
|
||||
|
||||
int nb=0;
|
||||
double emi, ema;
|
||||
slsInterpolation* inte=(slsInterpolation*)dets[0]->getFlatField(nb,emi,ema);
|
||||
if (inte) {
|
||||
if (getFlatField()) {
|
||||
// cout << "mtwff* ff has " << nb << " bins " << endl;
|
||||
float *gm=new float[nb*nb];
|
||||
if (gm) {
|
||||
for (int ix=0; ix<nb*nb; ix++) {
|
||||
gm[ix]=ff[ix];
|
||||
}
|
||||
WriteToTiff(gm,imgname ,nb, nb);
|
||||
delete [] gm;
|
||||
} else cout << "Could not allocate float image " << endl;
|
||||
}
|
||||
} else
|
||||
cout << "Not interpolating detector! " << endl;
|
||||
|
||||
return NULL;
|
||||
|
||||
};
|
||||
|
||||
|
||||
void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){
|
||||
|
||||
int* inte=(int*)dets[0]->getFlatField(nb,emin,emax);
|
||||
if (inte) {
|
||||
uint32 nnx;
|
||||
uint32 nny;
|
||||
float *gm=ReadFromTiff(imgname, nnx, nny);
|
||||
if (ff) delete [] ff;
|
||||
if (nnx>nb) nb=nnx;
|
||||
if (nny>nb) nb=nny;
|
||||
ff=new int[nb*nb];
|
||||
|
||||
for (int ix=0; ix<nb*nb; ix++) {
|
||||
ff[ix]=gm[ix];
|
||||
}
|
||||
delete [] gm;
|
||||
return setFlatField(ff,nb,emin,emax);
|
||||
} else
|
||||
cout << "Not interpolating detector! " << endl;
|
||||
|
||||
return NULL;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
virtual double *getPedestal(){
|
||||
int nx, ny;
|
||||
@ -446,15 +432,25 @@ public:
|
||||
|
||||
for (int i=0; i<nThreads; i++) {
|
||||
//inte=(slsInterpolation*)dets[i]->getInterpolation(nb,emi,ema);
|
||||
// cout << i << endl;
|
||||
p0=dets[i]->getPedestal(p0);
|
||||
if (p0) {
|
||||
if (i==0) {
|
||||
|
||||
for (int ib=0; ib<nx*ny; ib++) {
|
||||
ped[ib]+=p0[ib];
|
||||
ped[ib]=p0[ib]/((double)nThreads);
|
||||
// cout << p0[ib] << " ";
|
||||
}
|
||||
} else {
|
||||
for (int ib=0; ib<nx*ny; ib++) {
|
||||
ped[ib]+=p0[ib]/((double)nThreads);
|
||||
// cout << p0[ib] << " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete [] p0;
|
||||
}
|
||||
delete [] p0;
|
||||
return ped;
|
||||
};
|
||||
|
||||
@ -475,7 +471,7 @@ public:
|
||||
|
||||
|
||||
|
||||
void *writePedestal(const char * imgname){
|
||||
virtual void *writePedestal(const char * imgname){
|
||||
|
||||
int nx, ny;
|
||||
dets[0]->getDetectorSize(nx,ny);
|
||||
@ -495,7 +491,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
void *readPedestal(const char * imgname, int nb=-1, double emin=1, double emax=0){
|
||||
virtual void *readPedestal(const char * imgname, int nb=-1, double emin=1, double emax=0){
|
||||
|
||||
int nx, ny;
|
||||
dets[0]->getDetectorSize(nx,ny);
|
||||
@ -524,7 +520,7 @@ public:
|
||||
\param f file pointer
|
||||
\returns current file pointer
|
||||
*/
|
||||
FILE *setFilePointer(FILE *f){
|
||||
virtual FILE *setFilePointer(FILE *f){
|
||||
for (int i=0; i<nThreads; i++) {
|
||||
dets[i]->setFilePointer(f);
|
||||
//dets[i]->setMutex(&fmutex);
|
||||
@ -532,18 +528,18 @@ public:
|
||||
return dets[0]->getFilePointer();
|
||||
};
|
||||
|
||||
/** gets file pointer where to write the clusters to
|
||||
\returns current file pointer
|
||||
*/
|
||||
FILE *getFilePointer(){return dets[0]->getFilePointer();};
|
||||
/** gets file pointer where to write the clusters to
|
||||
\returns current file pointer
|
||||
*/
|
||||
virtual FILE *getFilePointer(){return dets[0]->getFilePointer();};
|
||||
|
||||
|
||||
|
||||
private:
|
||||
protected:
|
||||
bool stop;
|
||||
const int nThreads;
|
||||
threadedAnalogDetector *dets[20];
|
||||
analogDetector<uint16_t> *dd[20];
|
||||
threadedAnalogDetector *dets[MAXTHREADS];
|
||||
analogDetector<uint16_t> *dd[MAXTHREADS];
|
||||
int ithread;
|
||||
int *image;
|
||||
int *ff;
|
||||
|
51
slsDetectorCalibration/multiThreadedCountingDetector.h
Normal file
51
slsDetectorCalibration/multiThreadedCountingDetector.h
Normal file
@ -0,0 +1,51 @@
|
||||
#ifndef MULTITHREADED_COUNTING_DETECTOR_H
|
||||
#define MULTITHREADED_COUNTING_DETECTOR_H
|
||||
|
||||
|
||||
#include "singlePhotonDetector.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
//#include <mutex>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
/* class threadedCountingDetector : public threadedAnalogDetector */
|
||||
/* { */
|
||||
/* public: */
|
||||
/* threadedCountingDetector(singlePhotonDetector *d, int fs=10000) : threadedAnalogDetector(d,fs) {}; */
|
||||
|
||||
|
||||
/* }; */
|
||||
|
||||
|
||||
|
||||
class multiThreadedCountingDetector : public multiThreadedAnalogDetector
|
||||
{
|
||||
public:
|
||||
multiThreadedCountingDetector(singlePhotonDetector *d, int n, int fs=1000) : multiThreadedAnalogDetector(d,n,fs) { };
|
||||
|
||||
virtual double setNSigma(double n) {double ret; for (int i=0; i<nThreads; i++) ret=(dets[i])->setNSigma(n); return ret;};
|
||||
virtual void setEnergyRange(double emi, double ema) {for (int i=0; i<nThreads; i++) (dets[i])->setEnergyRange(emi,ema);};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
112
slsDetectorCalibration/multiThreadedInterpolatingDetector.h
Normal file
112
slsDetectorCalibration/multiThreadedInterpolatingDetector.h
Normal file
@ -0,0 +1,112 @@
|
||||
#ifndef MULTITHREADED_INTERPOLATING_DETECTOR_H
|
||||
#define MULTITHREADED_INTERPOLATING_DETECTOR_H
|
||||
|
||||
|
||||
#include "interpolatingDetector.h"
|
||||
#include "multiThreadedCountingDetector.h"
|
||||
//#include <mutex>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
class multiThreadedInterpolatingDetector : public multiThreadedCountingDetector
|
||||
{
|
||||
public:
|
||||
multiThreadedInterpolatingDetector(interpolatingDetector *d, int n, int fs=1000) : multiThreadedCountingDetector(d,n,fs) { };
|
||||
|
||||
virtual void prepareInterpolation(int &ok){
|
||||
/* getFlatField(); //sum up all etas */
|
||||
/* setFlatField(); //set etas to all detectors */
|
||||
/* for (int i=0; i<nThreads; i++) { */
|
||||
(dets[0])->prepareInterpolation(ok);
|
||||
// }
|
||||
}
|
||||
|
||||
virtual int *getFlatField(){
|
||||
return (dets[0])->getFlatField();
|
||||
}
|
||||
|
||||
virtual int *getFlatField(int &nb, double emi, double ema){
|
||||
return (dets[0])->getFlatField(nb,emi,ema);
|
||||
}
|
||||
|
||||
virtual int *setFlatField(int *h=NULL, int nb=-1, double emin=1, double emax=0){
|
||||
return (dets[0])->setFlatField(h,nb,emin,emax);
|
||||
};
|
||||
|
||||
void *writeFlatField(const char * imgname){
|
||||
dets[0]->writeFlatField(imgname);
|
||||
};
|
||||
|
||||
|
||||
void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){
|
||||
(dets[0])->readFlatField(imgname, nb, emin, emax);
|
||||
};
|
||||
|
||||
|
||||
virtual int setNSubPixels(int ns) { return (dets[0])->setNSubPixels(ns);};
|
||||
|
||||
virtual void resetFlatField() {(dets[0])->resetFlatField();};
|
||||
|
||||
|
||||
/** sets file pointer where to write the clusters to
|
||||
\param f file pointer
|
||||
\returns current file pointer
|
||||
*/
|
||||
virtual slsInterpolation *setInterpolation(slsInterpolation *f){
|
||||
int ok;
|
||||
for (int i=0; i<nThreads; i++)
|
||||
(dets[i])->setInterpolation(f);
|
||||
return (dets[0])->getInterpolation();
|
||||
};
|
||||
|
||||
virtual slsInterpolation *getInterpolation(){
|
||||
|
||||
return (dets[0])->getInterpolation();
|
||||
};
|
||||
|
||||
|
||||
|
||||
virtual int *getImage(int &nnx, int &nny, int &ns) {
|
||||
if (getInterpolation()==NULL) return multiThreadedAnalogDetector::getImage(nnx,nny,ns);
|
||||
//if one interpolates, the whole image is stored in detector 0;
|
||||
int *img;
|
||||
// int nnx, nny, ns;
|
||||
// int nnx, nny, ns;
|
||||
int nn=dets[0]->getImageSize(nnx, nny,ns);
|
||||
if (image) {
|
||||
delete image;
|
||||
image=NULL;
|
||||
}
|
||||
image=new int[nn];
|
||||
img=dets[0]->getImage();
|
||||
for (int i=0; i<nn; i++) {
|
||||
image[i]=img[i];
|
||||
}
|
||||
return image;
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -58,11 +58,13 @@ public analogDetector<uint16_t> {
|
||||
int sign=1,
|
||||
commonModeSubtraction *cm=NULL,
|
||||
int nped=1000,
|
||||
int nd=100, int nnx=-1, int nny=-1, double *gm=NULL) : analogDetector<uint16_t>(d, sign, cm, nped, nnx, nny, gm), nDark(nd), eventMask(NULL),nSigma (nsigma), clusterSize(csize), clusterSizeY(csize), clusters(NULL), quad(UNDEFINED_QUADRANT), tot(0), quadTot(0) {
|
||||
int nd=100, int nnx=-1, int nny=-1, double *gm=NULL) : analogDetector<uint16_t>(d, sign, cm, nped, nnx, nny, gm), nDark(nd), eventMask(NULL),nSigma (nsigma), clusterSize(csize), clusterSizeY(csize), clusters(NULL), quad(UNDEFINED_QUADRANT), tot(0), quadTot(0), eMin(-1), eMax(-1) {
|
||||
|
||||
|
||||
|
||||
|
||||
fm=new pthread_mutex_t ;
|
||||
|
||||
eventMask=new eventType*[ny];
|
||||
for (int i=0; i<ny; i++) {
|
||||
eventMask[i]=new eventType[nx];
|
||||
@ -101,6 +103,8 @@ public analogDetector<uint16_t> {
|
||||
for (int i=0; i<ny; i++) {
|
||||
eventMask[i]=new eventType[nx];
|
||||
}
|
||||
eMin=orig->eMin;
|
||||
eMax=orig->eMax;
|
||||
|
||||
|
||||
nSigma=orig->nSigma;
|
||||
@ -112,6 +116,7 @@ public analogDetector<uint16_t> {
|
||||
// cluster=clusters;
|
||||
|
||||
setClusterSize(clusterSize);
|
||||
fm=orig->fm;
|
||||
|
||||
quad=UNDEFINED_QUADRANT;
|
||||
tot=0;
|
||||
@ -136,7 +141,7 @@ public analogDetector<uint16_t> {
|
||||
\param n number of sigma to be set (0 or negative gets)
|
||||
\returns actual number of sigma parameter
|
||||
*/
|
||||
double setNSigma(double n=-1){if (n>0) nSigma=n; return nSigma;}
|
||||
double setNSigma(double n=-1){if (n>=0) nSigma=n; return nSigma;}
|
||||
|
||||
/** sets/gets cluster size
|
||||
\param n cluster size to be set, (0 or negative gets). If even is incremented by 1.
|
||||
@ -178,19 +183,19 @@ public analogDetector<uint16_t> {
|
||||
//nph=new int[nx*ny];
|
||||
|
||||
double rest[ny][nx];
|
||||
int cy=(clusterSizeY+1)/2;
|
||||
int cs=(clusterSize+1)/2;
|
||||
int cy=(clusterSizeY+1)/2; //quad size
|
||||
int cs=(clusterSize+1)/2; //quad size
|
||||
|
||||
int ccs=clusterSize;
|
||||
int ccy=clusterSizeY;
|
||||
int ccs=clusterSize; //cluster size
|
||||
int ccy=clusterSizeY; //cluster size
|
||||
|
||||
double g=1.;
|
||||
|
||||
|
||||
double tthr=thr;
|
||||
double tthr=thr, tthr1, tthr2;
|
||||
int nn=0;
|
||||
double max=0, tl=0, tr=0, bl=0,br=0, v;
|
||||
|
||||
double rms=0;
|
||||
|
||||
int cm=0;
|
||||
if (cmSub) cm=1;
|
||||
@ -210,204 +215,122 @@ public analogDetector<uint16_t> {
|
||||
if (thr>0) {
|
||||
newFrame();
|
||||
if (cmSub) {
|
||||
cout << "add to common mode?"<< endl;
|
||||
addToCommonMode(data);
|
||||
}
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
if (det->isGood(ix,iy)) {
|
||||
val=subtractPedestal(data,ix,iy, cm);
|
||||
|
||||
val=subtractPedestal(data,ix,iy, cm);
|
||||
nn=analogDetector<uint16_t>::getNPhotons(data,ix,iy);//val/thr;//
|
||||
if (nn>0) {
|
||||
nph[ix+nx*iy]+=nn;
|
||||
rest[iy][ix]=(val-nn*thr);//?+0.5*thr
|
||||
nphFrame+=nn;
|
||||
nphTot+=nn;
|
||||
} else
|
||||
rest[iy][ix]=val;
|
||||
|
||||
nn=val/tthr;//analogDetector<uint16_t>::getNPhotons(data,ix,iy);
|
||||
nph[ix+nx*iy]+=nn;
|
||||
rest[iy][ix]=(val-nn*tthr);
|
||||
|
||||
nphFrame+=nn;
|
||||
nphTot+=nn;
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
|
||||
// for (int ix=clusterSize/2; ix<clusterSize/2-1; ix++) {
|
||||
// for (int iy=clusterSizeY/2; iy<ny-clusterSizeY/2; iy++) {
|
||||
eventMask[iy][ix]=PEDESTAL;
|
||||
max=0;
|
||||
tl=0;
|
||||
tr=0;
|
||||
bl=0;
|
||||
br=0;
|
||||
tot=0;
|
||||
quadTot=0;
|
||||
if (det->isGood(ix,iy)) {
|
||||
eventMask[iy][ix]=PEDESTAL;
|
||||
max=0;
|
||||
tl=0;
|
||||
tr=0;
|
||||
bl=0;
|
||||
br=0;
|
||||
tot=0;
|
||||
quadTot=0;
|
||||
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
if ((iy+ir)>=0 && (iy+ir)<ny && (ix+ic)>=0 && (ix+ic)<nx) {
|
||||
//clusters->set_data(rest[iy+ir][ix+ic], ic, ir);
|
||||
if (rest[iy][ix]>0.25*thr) {
|
||||
eventMask[iy][ix]=NEIGHBOUR;
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
if ((iy+ir)>=0 && (iy+ir)<ny && (ix+ic)>=0 && (ix+ic)<nx) {
|
||||
//clusters->set_data(rest[iy+ir][ix+ic], ic, ir);
|
||||
|
||||
|
||||
v=rest[iy+ir][ix+ic];//clusters->get_data(ic,ir);
|
||||
tot+=v;
|
||||
v=rest[iy+ir][ix+ic];//clusters->get_data(ic,ir);
|
||||
tot+=v;
|
||||
|
||||
if (ir<=0 && ic<=0)
|
||||
bl+=v;
|
||||
if (ir<=0 && ic>=0)
|
||||
br+=v;
|
||||
if (ir>=0 && ic<=0)
|
||||
tl+=v;
|
||||
if (ir>=0 && ic>=0)
|
||||
tr+=v;
|
||||
if (ir<=0 && ic<=0)
|
||||
bl+=v;
|
||||
if (ir<=0 && ic>=0)
|
||||
br+=v;
|
||||
if (ir>=0 && ic<=0)
|
||||
tl+=v;
|
||||
if (ir>=0 && ic>=0)
|
||||
tr+=v;
|
||||
|
||||
if (v>max) {
|
||||
max=v;
|
||||
}
|
||||
// if (ir==0 && ic==0) {
|
||||
if (v>tthr) {
|
||||
eventMask[iy][ix]=NEIGHBOUR;
|
||||
if (v>max) {
|
||||
max=v;
|
||||
}
|
||||
// if (ir==0 && ic==0) {
|
||||
//}
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
if (rest[iy][ix]>=max) {
|
||||
if (bl>=br && bl>=tl && bl>=tr) {
|
||||
quad=BOTTOM_LEFT;
|
||||
quadTot=bl;
|
||||
} else if (br>=bl && br>=tl && br>=tr) {
|
||||
quad=BOTTOM_RIGHT;
|
||||
quadTot=br;
|
||||
} else if (tl>=br && tl>=bl && tl>=tr) {
|
||||
quad=TOP_LEFT;
|
||||
quadTot=tl;
|
||||
} else if (tr>=bl && tr>=tl && tr>=br) {
|
||||
quad=TOP_RIGHT;
|
||||
quadTot=tr;
|
||||
}
|
||||
|
||||
if (nSigma==0) {
|
||||
tthr=thr;
|
||||
tthr1=thr;
|
||||
tthr2=thr;
|
||||
} else {
|
||||
|
||||
rms=getPedestalRMS(ix,iy);
|
||||
tthr=nSigma*rms;
|
||||
|
||||
tthr1=nSigma*sqrt(clusterSize*clusterSizeY)*rms;
|
||||
tthr2=nSigma*sqrt((clusterSize+1)/2.*((clusterSizeY+1)/2.))*rms;
|
||||
|
||||
|
||||
if (thr>2*tthr) tthr=thr-tthr;
|
||||
if (thr>2*tthr1) tthr1=tthr-tthr1;
|
||||
if (thr>2*tthr2) tthr2=tthr-tthr2;
|
||||
|
||||
}
|
||||
|
||||
if (tot>tthr1 || quadTot>tthr2 || max>tthr) {
|
||||
eventMask[iy][ix]=PHOTON;
|
||||
nph[ix+nx*iy]++;
|
||||
rest[iy][ix]-=thr;
|
||||
nphFrame++;
|
||||
nphTot++;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rest[iy][ix]>=max) {
|
||||
if (bl>=br && bl>=tl && bl>=tr) {
|
||||
quad=BOTTOM_LEFT;
|
||||
quadTot=bl;
|
||||
} else if (br>=bl && br>=tl && br>=tr) {
|
||||
quad=BOTTOM_RIGHT;
|
||||
quadTot=br;
|
||||
} else if (tl>=br && tl>=bl && tl>=tr) {
|
||||
quad=TOP_LEFT;
|
||||
quadTot=tl;
|
||||
} else if (tr>=bl && tr>=tl && tr>=br) {
|
||||
quad=TOP_RIGHT;
|
||||
quadTot=tr;
|
||||
}
|
||||
if (max>tthr || tot>sqrt(ccy*ccs)*tthr || quadTot>sqrt(cy*cs)*tthr) {
|
||||
eventMask[iy][ix]=PHOTON;
|
||||
nph[ix+nx*iy]++;
|
||||
nphFrame++;
|
||||
nphTot++;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// cout << iframe << " " << nphFrame << " " << nphTot << endl;
|
||||
//cout << iframe << " " << nph << endl;
|
||||
} else return getClusters(data, nph);
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
|
||||
/** finds event type for pixel and fills cluster structure. The algorithm loops only if the evenMask for this pixel is still undefined.
|
||||
if pixel or cluster around it are above threshold (nsigma*pedestalRMS) cluster is filled and pixel mask is PHOTON_MAX (if maximum in cluster) or NEIGHBOUR; If PHOTON_MAX, the elements of the cluster are also set as NEIGHBOURs in order to speed up the looping
|
||||
if below threshold the pixel is either marked as PEDESTAL (and added to the pedestal calculator) or NEGATIVE_PEDESTAL is case it's lower than -threshold, otherwise the pedestal average would drift to negative values while it should be 0.
|
||||
|
||||
/param data pointer to the data
|
||||
/param ix pixel x coordinate
|
||||
/param iy pixel y coordinate
|
||||
/param cm enable(1)/disable(0) common mode subtraction (if defined).
|
||||
/returns event type for the given pixel
|
||||
*/
|
||||
eventType getEventType(char *data, int ix, int iy, int cm=0) {
|
||||
|
||||
// eventType ret=PEDESTAL;
|
||||
double max=0, tl=0, tr=0, bl=0,br=0, v;
|
||||
// cout << iframe << endl;
|
||||
|
||||
int cy=(clusterSizeY+1)/2;
|
||||
int cs=(clusterSize+1)/2;
|
||||
double val;
|
||||
tot=0;
|
||||
quadTot=0;
|
||||
quad=UNDEFINED_QUADRANT;
|
||||
|
||||
if (iframe<nDark) {
|
||||
addToPedestal(data, ix,iy);
|
||||
return UNDEFINED_EVENT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// if (eventMask[iy][ix]==UNDEFINED) {
|
||||
|
||||
eventMask[iy][ix]=PEDESTAL;
|
||||
|
||||
|
||||
clusters->x=ix;
|
||||
clusters->y=iy;
|
||||
clusters->rms=getPedestalRMS(ix,iy);
|
||||
clusters->ped=getPedestal(ix,iy, cm);
|
||||
|
||||
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
if ((iy+ir)>=0 && (iy+ir)<ny && (ix+ic)>=0 && (ix+ic)<nx) {
|
||||
|
||||
v=subtractPedestal(data, ix+ic, iy+ir);
|
||||
|
||||
clusters->set_data(v, ic, ir);
|
||||
// v=clusters->get_data(ic,ir);
|
||||
tot+=v;
|
||||
if (ir<=0 && ic<=0)
|
||||
bl+=v;
|
||||
if (ir<=0 && ic>=0)
|
||||
br+=v;
|
||||
if (ir>=0 && ic<=0)
|
||||
tl+=v;
|
||||
if (ir>=0 && ic>=0)
|
||||
tr+=v;
|
||||
|
||||
if (v>max) {
|
||||
max=v;
|
||||
}
|
||||
if (ir==0 && ic==0) {
|
||||
if (v<-nSigma*clusters->rms)
|
||||
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bl>=br && bl>=tl && bl>=tr) {
|
||||
quad=BOTTOM_LEFT;
|
||||
quadTot=bl;
|
||||
} else if (br>=bl && br>=tl && br>=tr) {
|
||||
quad=BOTTOM_RIGHT;
|
||||
quadTot=br;
|
||||
} else if (tl>=br && tl>=bl && tl>=tr) {
|
||||
quad=TOP_LEFT;
|
||||
quadTot=tl;
|
||||
} else if (tr>=bl && tr>=tl && tr>=br) {
|
||||
quad=TOP_RIGHT;
|
||||
quadTot=tr;
|
||||
}
|
||||
|
||||
if (max>nSigma*clusters->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*clusters->rms || quadTot>cy*cs*nSigma*clusters->rms) {
|
||||
if (clusters->get_data(0,0)>=max) {
|
||||
eventMask[iy][ix]=PHOTON_MAX;
|
||||
} else {
|
||||
eventMask[iy][ix]=PHOTON;
|
||||
}
|
||||
} else if (eventMask[iy][ix]==PEDESTAL) {
|
||||
if (cm==0) {
|
||||
if (det)
|
||||
val=dataSign*det->getValue(data, ix, iy);
|
||||
else
|
||||
val=((double**)data)[iy][ix];
|
||||
addToPedestal(val,ix,iy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return eventMask[iy][ix];
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -430,6 +353,7 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
|
||||
double max=0, tl=0, tr=0, bl=0,br=0, *v, vv;
|
||||
int cm=0;
|
||||
int good=1;
|
||||
if (cmSub) cm=1;
|
||||
if (ph==NULL)
|
||||
ph=image;
|
||||
@ -446,103 +370,112 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
addToCommonMode(data);
|
||||
|
||||
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
|
||||
max=0;
|
||||
tl=0;
|
||||
tr=0;
|
||||
bl=0;
|
||||
br=0;
|
||||
tot=0;
|
||||
quadTot=0;
|
||||
quad=UNDEFINED_QUADRANT;
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
if (det->isGood(ix,iy)) {
|
||||
max=0;
|
||||
tl=0;
|
||||
tr=0;
|
||||
bl=0;
|
||||
br=0;
|
||||
tot=0;
|
||||
quadTot=0;
|
||||
quad=UNDEFINED_QUADRANT;
|
||||
|
||||
|
||||
|
||||
eventMask[iy][ix]=PEDESTAL;
|
||||
eventMask[iy][ix]=PEDESTAL;
|
||||
|
||||
|
||||
(clusters+nph)->rms=getPedestalRMS(ix,iy);
|
||||
// cluster=clusters+nph;
|
||||
(clusters+nph)->rms=getPedestalRMS(ix,iy);
|
||||
// cluster=clusters+nph;
|
||||
|
||||
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
|
||||
if ((iy+ir)>=iy && (iy+ir)<ny && (ix+ic)>=ix && (ix+ic)<nx) {
|
||||
val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir, cm);
|
||||
}
|
||||
|
||||
v=&(val[iy+ir][ix+ic]);
|
||||
tot+=*v;
|
||||
if (ir<=0 && ic<=0)
|
||||
bl+=*v;
|
||||
if (ir<=0 && ic>=0)
|
||||
br+=*v;
|
||||
if (ir>=0 && ic<=0)
|
||||
tl+=*v;
|
||||
if (ir>=0 && ic>=0)
|
||||
tr+=*v;
|
||||
if (*v>max) {
|
||||
max=*v;
|
||||
}
|
||||
|
||||
|
||||
if (ir==0 && ic==0) {
|
||||
if (*v<-nSigma*(clusters+nph)->rms)
|
||||
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
|
||||
else if (*v>nSigma*(clusters+nph)->rms)
|
||||
eventMask[iy][ix]=PHOTON;
|
||||
}
|
||||
|
||||
if ((iy+ir)>=iy && (iy+ir)<ny && (ix+ic)>=ix && (ix+ic)<nx) {
|
||||
val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir, cm);
|
||||
}
|
||||
|
||||
v=&(val[iy+ir][ix+ic]);
|
||||
tot+=*v;
|
||||
if (ir<=0 && ic<=0)
|
||||
bl+=*v;
|
||||
if (ir<=0 && ic>=0)
|
||||
br+=*v;
|
||||
if (ir>=0 && ic<=0)
|
||||
tl+=*v;
|
||||
if (ir>=0 && ic>=0)
|
||||
tr+=*v;
|
||||
if (*v>max) {
|
||||
max=*v;
|
||||
}
|
||||
|
||||
|
||||
if (ir==0 && ic==0) {
|
||||
if (*v<-nSigma*(clusters+nph)->rms)
|
||||
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (eventMask[iy][ix]==PHOTON && val[iy][ix]<max)
|
||||
continue;
|
||||
|
||||
if (bl>=br && bl>=tl && bl>=tr) {
|
||||
(clusters+nph)->quad=BOTTOM_LEFT;
|
||||
(clusters+nph)->quadTot=bl;
|
||||
} else if (br>=bl && br>=tl && br>=tr) {
|
||||
(clusters+nph)->quad=BOTTOM_RIGHT;
|
||||
if (bl>=br && bl>=tl && bl>=tr) {
|
||||
(clusters+nph)->quad=BOTTOM_LEFT;
|
||||
(clusters+nph)->quadTot=bl;
|
||||
} else if (br>=bl && br>=tl && br>=tr) {
|
||||
(clusters+nph)->quad=BOTTOM_RIGHT;
|
||||
(clusters+nph)->quadTot=br;
|
||||
} else if (tl>=br && tl>=bl && tl>=tr) {
|
||||
(clusters+nph)->quad=TOP_LEFT;
|
||||
(clusters+nph)->quadTot=tl;
|
||||
} else if (tr>=bl && tr>=tl && tr>=br) {
|
||||
(clusters+nph)->quad=TOP_RIGHT;
|
||||
(clusters+nph)->quadTot=tr;
|
||||
}
|
||||
} else if (tl>=br && tl>=bl && tl>=tr) {
|
||||
(clusters+nph)->quad=TOP_LEFT;
|
||||
(clusters+nph)->quadTot=tl;
|
||||
} else if (tr>=bl && tr>=tl && tr>=br) {
|
||||
(clusters+nph)->quad=TOP_RIGHT;
|
||||
(clusters+nph)->quadTot=tr;
|
||||
}
|
||||
|
||||
if (max>nSigma*(clusters+nph)->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*(clusters+nph)->rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*(clusters+nph)->rms) {
|
||||
if (val[iy][ix]>=max) {
|
||||
if (max>nSigma*(clusters+nph)->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*(clusters+nph)->rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*(clusters+nph)->rms) {
|
||||
if (val[iy][ix]>=max) {
|
||||
eventMask[iy][ix]=PHOTON_MAX;
|
||||
(clusters+nph)->tot=tot;
|
||||
(clusters+nph)->x=ix;
|
||||
(clusters+nph)->y=iy;
|
||||
(clusters+nph)->iframe=det->getFrameNumber(data);
|
||||
// (clusters+nph)->iframe=det->getFrameNumber(data);
|
||||
// cout << det->getFrameNumber(data) << " " << (clusters+nph)->iframe << endl;
|
||||
(clusters+nph)->ped=getPedestal(ix,iy,0);
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
(clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir);
|
||||
}
|
||||
}
|
||||
// cout << (clusters+nph)->iframe << " " << ix << " " << nph << " " << tot << " " << (clusters+nph)->quadTot << endl;
|
||||
nph++;
|
||||
image[iy*nx+ix]++;
|
||||
good=1;
|
||||
if (eMin>0 && tot<eMin) good=0;
|
||||
if (eMax>0 && tot>eMax) good=0;
|
||||
if (good) {
|
||||
nph++;
|
||||
image[iy*nx+ix]++;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
eventMask[iy][ix]=PHOTON;
|
||||
}
|
||||
} else if (eventMask[iy][ix]==PEDESTAL) {
|
||||
addToPedestal(data,ix,iy,cm);
|
||||
} else if (eventMask[iy][ix]==PEDESTAL) {
|
||||
addToPedestal(data,ix,iy,cm);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
nphFrame=nph;
|
||||
nphTot+=nph;
|
||||
//cout << nphFrame << endl;
|
||||
// cout <<"**********************************"<< endl;
|
||||
writeClusters();
|
||||
// cout <<"**********************************"<< det->getFrameNumber(data) << " " << nphFrame << endl;
|
||||
writeClusters(det->getFrameNumber(data));
|
||||
return image;
|
||||
|
||||
};
|
||||
@ -627,13 +560,27 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
|
||||
*/
|
||||
|
||||
static void writeClusters(FILE *f, single_photon_hit *clusters, int nph){for (int i=0; i<nph; i++) (clusters+i)->write(f);};
|
||||
void writeClusters(FILE *f){for (int i=0; i<nphFrame; i++) (clusters+i)->write(f);};
|
||||
void writeClusters(){if (myFile) {
|
||||
static void writeClusters(FILE *f, single_photon_hit *cl, int nph, int fn=0){
|
||||
|
||||
/* #ifndef OLDFORMAT */
|
||||
/* if (fwrite((void*)&fn, 1, sizeof(int), f)) */
|
||||
/* if (fwrite((void*)&nph, 1, sizeof(int), f)) */
|
||||
/* #endif */
|
||||
for (int i=0; i<nph; i++) (cl+i)->write(f);
|
||||
};
|
||||
void writeClusters(FILE *f, int fn=0){
|
||||
writeClusters(f,clusters,nphFrame, fn);
|
||||
//for (int i=0; i<nphFrame; i++)
|
||||
//(clusters+i)->write(f);
|
||||
};
|
||||
void writeClusters(int fn){
|
||||
if (myFile) {
|
||||
//cout << "++" << endl;
|
||||
pthread_mutex_lock(fm);
|
||||
for (int i=0; i<nphFrame; i++)
|
||||
(clusters+i)->write(myFile);
|
||||
// cout <<"**********************************"<< fn << " " << nphFrame << endl;
|
||||
writeClusters(myFile,clusters,nphFrame, fn);
|
||||
// for (int i=0; i<nphFrame; i++)
|
||||
// (clusters+i)->write(myFile);
|
||||
pthread_mutex_unlock(fm);
|
||||
//cout << "--" << endl;
|
||||
}
|
||||
@ -644,21 +591,36 @@ void writeClusters(FILE *f){for (int i=0; i<nphFrame; i++) (clusters+i)->write(f
|
||||
// cout << "sp" << endl;
|
||||
switch(fMode) {
|
||||
case ePedestal:
|
||||
//cout <<"spc add to ped " << endl;
|
||||
addToPedestal(data);
|
||||
break;
|
||||
default:
|
||||
getNPhotons(data,val);
|
||||
switch (dMode) {
|
||||
case eAnalog:
|
||||
analogDetector<uint16_t>::processData(data,val);
|
||||
break;
|
||||
default:
|
||||
// cout <<"spc " << endl;
|
||||
getNPhotons(data,val);
|
||||
}
|
||||
}
|
||||
iframe++;
|
||||
// cout << "done" << endl;
|
||||
};
|
||||
int getPhFrame(){return nphFrame;};
|
||||
int getPhTot(){return nphTot;};
|
||||
|
||||
void setEnergyRange(double emi, double ema){eMin=emi; eMax=ema;};
|
||||
void getEnergyRange(double &emi, double &ema){emi=eMin; ema=eMax;};
|
||||
|
||||
void setMutex(pthread_mutex_t *m){fm=m;};
|
||||
|
||||
protected:
|
||||
|
||||
int nDark; /**< number of frames to be used at the beginning of the dataset to calculate pedestal without applying photon discrimination */
|
||||
eventType **eventMask; /**< matrix of event type or each pixel */
|
||||
double nSigma; /**< number of sigma parameter for photon discrimination */
|
||||
double eMin, eMax;
|
||||
int clusterSize; /**< cluster size in the x direction */
|
||||
int clusterSizeY; /**< cluster size in the y direction i.e. 1 for strips, clusterSize for pixels */
|
||||
// single_photon_hit *cluster; /**< single photon hit data structure */
|
||||
@ -669,6 +631,7 @@ void writeClusters(FILE *f){for (int i=0; i<nphFrame; i++) (clusters+i)->write(f
|
||||
int nphTot;
|
||||
int nphFrame;
|
||||
|
||||
pthread_mutex_t *fm;
|
||||
|
||||
};
|
||||
|
||||
|
@ -38,8 +38,62 @@ class single_photon_hit {
|
||||
size_t write(FILE *myFile) {
|
||||
//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))
|
||||
// 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, 2, sizeof(int16_t), myFile))
|
||||
return fwrite((void*)data, 1, dx*dy*sizeof(int), myFile);
|
||||
#endif
|
||||
#ifdef WRITE_QUAD
|
||||
// printf("quad ");
|
||||
int qq[4];
|
||||
switch(quad) {
|
||||
case TOP_LEFT:
|
||||
qq[0]=data[3];
|
||||
qq[1]=data[4];
|
||||
qq[2]=data[6];
|
||||
qq[3]=data[7];
|
||||
x=x-1;
|
||||
y=y;
|
||||
break;
|
||||
|
||||
case TOP_RIGHT:
|
||||
qq[0]=data[4];
|
||||
qq[1]=data[5];
|
||||
qq[2]=data[7];
|
||||
qq[3]=data[8];
|
||||
x=x;
|
||||
y=y;
|
||||
break;
|
||||
|
||||
|
||||
case BOTTOM_LEFT:
|
||||
qq[0]=data[0];
|
||||
qq[1]=data[1];
|
||||
qq[2]=data[3];
|
||||
qq[3]=data[4];
|
||||
x=x-1;
|
||||
y=y-1;
|
||||
break;
|
||||
case BOTTOM_RIGHT:
|
||||
qq[0]=data[1];
|
||||
qq[1]=data[2];
|
||||
qq[2]=data[4];
|
||||
qq[3]=data[5];
|
||||
x=x;
|
||||
y=y-1;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
if (fwrite((void*)&x, 2, sizeof(int16_t), myFile))
|
||||
return fwrite((void*)qq, 1, 4*sizeof(int), myFile);
|
||||
#endif
|
||||
return 0;
|
||||
};
|
||||
|
||||
@ -50,11 +104,126 @@ class single_photon_hit {
|
||||
size_t read(FILE *myFile) {
|
||||
//fread((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile);
|
||||
|
||||
if (fread((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile))
|
||||
//#ifdef OLDFORMAT
|
||||
if (fread((void*)&iframe, 1, sizeof(int), myFile)) {}
|
||||
//#endif
|
||||
#ifndef WRITE_QUAD
|
||||
// printf( "no quad \n");
|
||||
if (fread((void*)&x, 2, sizeof(int16_t), myFile))
|
||||
return fread((void*)data, 1, dx*dy*sizeof(int), myFile);
|
||||
#endif
|
||||
#ifdef WRITE_QUAD
|
||||
int qq[4];
|
||||
// printf( "quad \n");
|
||||
if (fread((void*)&x, 2, sizeof(int16_t), myFile))
|
||||
if (fread((void*)qq, 1, 4*sizeof(int), myFile)) {
|
||||
|
||||
quad=TOP_RIGHT;
|
||||
int mm=qq[0];
|
||||
for (int i=1; i<4; i++) {
|
||||
if (qq[i]<mm) {
|
||||
switch (i) {
|
||||
case 1:
|
||||
quad=TOP_LEFT;
|
||||
break;
|
||||
case 2:
|
||||
quad=BOTTOM_RIGHT;
|
||||
break;
|
||||
case 3:
|
||||
quad=BOTTOM_LEFT;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
switch(quad) {
|
||||
case TOP_LEFT:
|
||||
data[0]=0;
|
||||
data[1]=0;
|
||||
data[2]=0;
|
||||
data[3]=qq[0];
|
||||
data[4]=qq[1];
|
||||
data[5]=0;
|
||||
data[6]=qq[2];
|
||||
data[7]=qq[3];
|
||||
data[8]=0;
|
||||
x=x+1;
|
||||
y=y;
|
||||
break;
|
||||
|
||||
case TOP_RIGHT:
|
||||
data[0]=0;
|
||||
data[1]=0;
|
||||
data[2]=0;
|
||||
data[3]=0;
|
||||
data[4]=qq[0];
|
||||
data[5]=qq[1];
|
||||
data[6]=0;
|
||||
data[7]=qq[2];
|
||||
data[8]=qq[3];
|
||||
x=x;
|
||||
y=y;
|
||||
break;
|
||||
|
||||
|
||||
case BOTTOM_LEFT:
|
||||
data[0]=qq[0];
|
||||
data[1]=qq[1];
|
||||
data[2]=0;
|
||||
data[3]=qq[2];
|
||||
data[4]=qq[3];
|
||||
data[5]=0;
|
||||
data[6]=0;
|
||||
data[7]=0;
|
||||
data[8]=0;
|
||||
x=x+1;
|
||||
y=y+1;
|
||||
break;
|
||||
case BOTTOM_RIGHT:
|
||||
data[0]=0;
|
||||
data[1]=qq[0];
|
||||
data[2]=qq[1];
|
||||
data[3]=0;
|
||||
data[4]=qq[2];
|
||||
data[5]=qq[3];
|
||||
data[6]=0;
|
||||
data[7]=0;
|
||||
data[8]=0;
|
||||
x=x;
|
||||
y=y+1;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
void print() {
|
||||
|
||||
int ix, iy;
|
||||
|
||||
for (int iy=0; iy<dy; iy++) {
|
||||
for (int ix=0; ix<dx; ix++) {
|
||||
printf("%d \t",data[ix+iy*dx]);
|
||||
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
assign the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0)
|
||||
\param v value to be set
|
||||
|
@ -331,8 +331,6 @@ class slsDetectorData {
|
||||
*/
|
||||
virtual char *readNextFrame(ifstream &filebin)=0;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@ void *WriteToTiff(float * imgData, const char * imgname, int nrow, int ncol){
|
||||
int sampleperpixel=1;
|
||||
// unsigned char * buff=NULL;
|
||||
tsize_t linebytes;
|
||||
cout << "--" <<endl;
|
||||
// cout << "--" <<endl;
|
||||
TIFF * tif = TIFFOpen(imgname,"w");
|
||||
if (tif) {
|
||||
TIFFSetField(tif,TIFFTAG_IMAGEWIDTH,ncol);
|
||||
|
@ -21,34 +21,40 @@ using namespace std;
|
||||
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
|
||||
qClient *cl =new qClient(argv[1]);
|
||||
qClient* cl = 0;
|
||||
try {
|
||||
cl = new qClient(argv[1]);
|
||||
} catch(...) {
|
||||
return 0;
|
||||
}
|
||||
cl->executeLine(argc-2, argv+2);
|
||||
|
||||
delete cl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
qClient::qClient(char* hostname){
|
||||
//create socket
|
||||
mySocket = new MySocketTCP(hostname, DEFAULT_GUI_PORTNO);
|
||||
if (mySocket->getErrorStatus()){
|
||||
cout << "Error: could not connect to host:" << hostname << " with port " << DEFAULT_GUI_PORTNO << endl;
|
||||
delete mySocket;
|
||||
exit(-1);
|
||||
}
|
||||
qClient::qClient(char* hostname):
|
||||
mySocket(0),
|
||||
myStopSocket(0){
|
||||
|
||||
//create socket to connect to stop server
|
||||
myStopSocket = new MySocketTCP(hostname, DEFAULT_GUI_PORTNO+1);
|
||||
if (myStopSocket->getErrorStatus()){
|
||||
cout << "Error: could not connect to host:" << hostname << " with port " << DEFAULT_GUI_PORTNO + 1 << endl;
|
||||
delete myStopSocket;
|
||||
exit(-1);
|
||||
try {
|
||||
// control socket
|
||||
mySocket = new MySocketTCP(hostname, DEFAULT_GUI_PORTNO);
|
||||
// stop socket
|
||||
myStopSocket = new MySocketTCP(hostname, DEFAULT_GUI_PORTNO+1);
|
||||
} catch(...) {
|
||||
if (mySocket == 0)
|
||||
cout << "Error: could not connect to control server:" <<
|
||||
hostname << " with port " << DEFAULT_GUI_PORTNO << endl;
|
||||
else
|
||||
cout << "Error: could not connect to stop server:" <<
|
||||
hostname << " with port " << DEFAULT_GUI_PORTNO + 1 << endl;
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -93,7 +99,7 @@ int qClient::executeLine(int narg, char *args[]){
|
||||
else if (argument == "stop")
|
||||
stopAcquisition();
|
||||
else{
|
||||
cout << "Error: could not parse arguments: " << argument << endl;
|
||||
cprintf(RED,"Error: could not parse arguments: %s\n", argument.c_str());
|
||||
printCommands();
|
||||
return FAIL;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@
|
||||
<enum>QTabWidget::North</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="elideMode">
|
||||
<enum>Qt::ElideLeft</enum>
|
||||
@ -124,7 +124,7 @@
|
||||
<rect>
|
||||
<x>5</x>
|
||||
<y>10</y>
|
||||
<width>467</width>
|
||||
<width>495</width>
|
||||
<height>66</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -946,7 +946,7 @@ An extension given by the modules serial number will be attached.
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>135</y>
|
||||
<y>132</y>
|
||||
<width>736</width>
|
||||
<height>171</height>
|
||||
</rect>
|
||||
@ -960,7 +960,7 @@ An extension given by the modules serial number will be attached.
|
||||
<x>420</x>
|
||||
<y>140</y>
|
||||
<width>291</width>
|
||||
<height>25</height>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -975,9 +975,9 @@ An extension given by the modules serial number will be attached.
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>25</x>
|
||||
<y>25</y>
|
||||
<y>21</y>
|
||||
<width>686</width>
|
||||
<height>148</height>
|
||||
<height>119</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
@ -1355,9 +1355,9 @@ An extension given by the modules serial number will be attached.
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>35</x>
|
||||
<y>15</y>
|
||||
<y>10</y>
|
||||
<width>686</width>
|
||||
<height>146</height>
|
||||
<height>123</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
@ -1949,15 +1949,15 @@ Exposure Time of a sub frame. Only for Eiger in 32 bit mode
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><nobr>
|
||||
Period between sub frames. Only for Eiger in 32 bit mode.
|
||||
Dead time between sub frames. Only for Eiger in 32 bit mode.
|
||||
</nobr><br><nobr>
|
||||
Default value is 0. A value less than the required minimum is ignored.
|
||||
</nobr><br><nobr>
|
||||
#subperiod#
|
||||
#subdeadtime#
|
||||
</nobr></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sub Frame Period:</string>
|
||||
<string>Sub Frame Dead Time:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -1,9 +1,9 @@
|
||||
Path: slsDetectorsPackage/slsDetectorGui
|
||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repsitory UUID: 51fd9ed423b7a8fb45a76b4f48316537c4fb0f5d
|
||||
Revision: 505
|
||||
Branch: developer
|
||||
Repsitory UUID: d2bce7e372c241cd235977b92be18555bca6a77d
|
||||
Revision: 521
|
||||
Branch: 4.0.0
|
||||
Last Changed Author: Dhanya_Thattil
|
||||
Last Changed Rev: 3818
|
||||
Last Changed Date: 2018-05-15 13:48:54.000000002 +0200 ./src/qTabSettings.cpp
|
||||
Last Changed Rev: 4020
|
||||
Last Changed Date: 2018-09-27 16:09:16.000000002 +0200 ./src/qTabSettings.cpp
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||
#define GITREPUUID "51fd9ed423b7a8fb45a76b4f48316537c4fb0f5d"
|
||||
#define GITREPUUID "d2bce7e372c241cd235977b92be18555bca6a77d"
|
||||
#define GITAUTH "Dhanya_Thattil"
|
||||
#define GITREV 0x3818
|
||||
#define GITDATE 0x20180515
|
||||
#define GITBRANCH "developer"
|
||||
#define GITREV 0x4020
|
||||
#define GITDATE 0x20180927
|
||||
#define GITBRANCH "4.0.0"
|
||||
|
@ -246,7 +246,7 @@ void qDrawPlot::SetupWidgetWindow(){
|
||||
this->setLayout(layout);
|
||||
|
||||
histFrameIndexTitle = new QLabel("");
|
||||
|
||||
histFrameIndexTitle->setFixedHeight(10);
|
||||
boxPlot = new QGroupBox("");
|
||||
layout->addWidget(boxPlot,1,0);
|
||||
boxPlot->setAlignment(Qt::AlignHCenter);
|
||||
|
@ -27,7 +27,7 @@ int qServer::gui_server_thread_running(0);
|
||||
|
||||
|
||||
qServer::qServer(qDetectorMain *t):
|
||||
myMainTab(t), mySocket(NULL),myStopSocket(NULL),port_no(DEFAULT_GUI_PORTNO),lockStatus(0),checkStarted(0),checkStopStarted(0){
|
||||
myMainTab(t), mySocket(0),myStopSocket(0),port_no(DEFAULT_GUI_PORTNO),lockStatus(0),checkStarted(0),checkStopStarted(0){
|
||||
strcpy(mess,"");
|
||||
FunctionTable();
|
||||
|
||||
@ -196,7 +196,7 @@ int qServer::StartStopServer(int start){
|
||||
pthread_join(gui_server_thread,NULL);
|
||||
if(mySocket){
|
||||
delete mySocket;
|
||||
mySocket = NULL;
|
||||
mySocket = 0;
|
||||
}
|
||||
|
||||
if(myStopSocket)
|
||||
@ -204,7 +204,7 @@ int qServer::StartStopServer(int start){
|
||||
pthread_join(gui_stop_server_thread,NULL);
|
||||
if(myStopSocket){
|
||||
delete myStopSocket;
|
||||
myStopSocket = NULL;
|
||||
myStopSocket = 0;
|
||||
}
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
@ -235,8 +235,10 @@ int qServer::StopServer(){
|
||||
#endif
|
||||
int ret = qDefs::OK;
|
||||
|
||||
myStopSocket = new MySocketTCP(port_no+1);
|
||||
if (myStopSocket->getErrorStatus()){
|
||||
try {
|
||||
MySocketTCP* s = new MySocketTCP(port_no+1);
|
||||
myStopSocket = s;
|
||||
} catch(...) {
|
||||
gui_server_thread_running = 0;
|
||||
qDefs::Message(qDefs::WARNING,"Could not start gui stop server socket","qServer::StopServer");
|
||||
}
|
||||
@ -270,7 +272,7 @@ int qServer::StopServer(){
|
||||
//delete socket(via exit server)
|
||||
if(myStopSocket){
|
||||
delete myStopSocket;
|
||||
myStopSocket = NULL;
|
||||
myStopSocket = 0;
|
||||
}
|
||||
|
||||
if(!gui_server_thread_running)
|
||||
@ -300,8 +302,10 @@ int qServer::StartServer(){
|
||||
#endif
|
||||
int ret = qDefs::OK;
|
||||
|
||||
mySocket = new MySocketTCP(port_no);
|
||||
if (mySocket->getErrorStatus()){
|
||||
try {
|
||||
MySocketTCP* s = new MySocketTCP(port_no);
|
||||
mySocket = s;
|
||||
} catch(...) {
|
||||
gui_server_thread_running = 0;
|
||||
qDefs::Message(qDefs::WARNING,"Could not start gui server socket","qServer::StartServer");
|
||||
}
|
||||
@ -335,7 +339,7 @@ int qServer::StartServer(){
|
||||
//delete socket(via exit server)
|
||||
if(mySocket){
|
||||
delete mySocket;
|
||||
mySocket = NULL;
|
||||
mySocket = 0;
|
||||
}
|
||||
|
||||
if(!gui_server_thread_running)
|
||||
|
@ -233,7 +233,7 @@ void qTabAdvanced::SetupWidgetWindow(){
|
||||
spinSubExpTime->setValue(time);
|
||||
comboSubExpTimeUnit->setCurrentIndex((int)unit);
|
||||
//period
|
||||
time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::SUBFRAME_PERIOD,-1)*(1E-9))));
|
||||
time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,-1)*(1E-9))));
|
||||
spinSubPeriod->setValue(time);
|
||||
comboSubPeriodUnit->setCurrentIndex((int)unit);
|
||||
|
||||
@ -1342,13 +1342,13 @@ void qTabAdvanced::SetSubPeriod() {
|
||||
"/" << spinSubPeriod->value() <<
|
||||
qDefs::getUnitString((qDefs::timeUnit)comboSubPeriodUnit->currentIndex()) << endl;
|
||||
#endif
|
||||
myDet->setTimer(slsDetectorDefs::SUBFRAME_PERIOD,(int64_t)timeNS);
|
||||
myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,(int64_t)timeNS);
|
||||
qDefs::checkErrorMessage(myDet,"qTabAdvanced::SetSubPeriod");
|
||||
|
||||
// update value in gui
|
||||
qDefs::timeUnit unit;
|
||||
double time = qDefs::getCorrectTime(unit,((double)(
|
||||
myDet->setTimer(slsDetectorDefs::SUBFRAME_PERIOD,-1)*(1E-9))));
|
||||
myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,-1)*(1E-9))));
|
||||
spinSubPeriod->setValue(time);
|
||||
comboSubPeriodUnit->setCurrentIndex((int)unit);
|
||||
|
||||
@ -1605,7 +1605,7 @@ void qTabAdvanced::Refresh(){
|
||||
comboSubExpTimeUnit->setCurrentIndex((int)unit);
|
||||
|
||||
// subperiod
|
||||
time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::SUBFRAME_PERIOD,-1)*(1E-9))));
|
||||
time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::SUBFRAME_DEADTIME,-1)*(1E-9))));
|
||||
spinSubPeriod->setValue(time);
|
||||
comboSubPeriodUnit->setCurrentIndex((int)unit);
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user