Compare commits

...

172 Commits

Author SHA1 Message Date
70048a9220 added photon counter no thread 2021-03-12 08:41:48 +01:00
f11cc4a7f3 Merge branch 'moench' of https://github.com/slsdetectorgroup/slsDetectorPackage into moench 2020-07-16 12:30:30 +02:00
f99c431722 changing zmq process to allow for partial readout and fixing interpolation 2020-07-16 12:27:40 +02:00
bce4a615fa some fixes from 4.2.0 that might be important formoench 2020-06-19 13:30:56 +02:00
8747ca04f3 zmq back in 2020-06-19 13:28:54 +02:00
2afa620a97 pedestal and data structures moved from 2D to 1D array; fixed bug with the file pointer in the zmq process 2020-06-16 13:52:36 +02:00
1d9341f031 Merge branch 'moench' of https://github.com/slsdetectorgroup/slsDetectorPackage into moench 2020-06-03 10:43:53 +02:00
ab3877d9dd function to write pedestal rms and some fixes 2020-06-03 10:43:16 +02:00
2a31e921ac memory leak when running single task 2020-04-20 13:42:33 +02:00
eac02479c5 rxr bug fix: master file not created, rxr does not return 2020-04-20 11:40:21 +02:00
8096d4078c Merge branch 'moench' of https://github.com/slsdetectorgroup/slsDetectorPackage into moench 2020-04-17 17:24:01 +02:00
5710dda12a fixed mistake in moench03 data stucture when calculating xmap, ymap 2020-04-17 17:23:24 +02:00
a510010b27 rxr bug fix: master file not created, rxr does not return 2020-04-16 16:08:34 +02:00
c55d19dbfe some corrections to cluster writing 2020-04-14 17:48:04 +02:00
163eb2710f Some fixes to the offline processing - could also affect hte zmq process 2020-04-06 09:42:38 +02:00
95351d0924 fixed bug by pedestal cloning 2020-03-24 12:05:10 +01:00
ded757b40c Merge branch 'moench' of https://github.com/slsdetectorgroup/slsDetectorPackage into moench 2020-03-19 11:29:05 +01:00
8b6eb0985f one of client warnings fixed 2020-03-19 11:28:16 +01:00
14b572cdd9 Merge branch 'moench' of https://github.com/slsdetectorgroup/slsDetectorPackage into moench 2020-03-19 11:16:10 +01:00
770ca7bb96 zmq fix sprintf serveraddress 2020-03-19 11:15:49 +01:00
d551bac3f7 fixed warnings to avoid crashing 2020-03-19 11:13:56 +01:00
d43d74a92d fixed warning for fname in zmqheader 2020-03-19 10:18:37 +01:00
e61d1a1651 zmqsocket bug fix: memcpy source and destination overlap 2020-02-25 10:28:23 +01:00
63f5b52a6e jctbDetectorServer compilation flags match only for moench 2020-02-19 12:26:35 +01:00
53ba22dbc4 fixed for current rectangular sensor geometry 2020-02-18 11:37:10 +01:00
124e2a7714 now rectangular interpolation possible 2020-02-18 11:36:31 +01:00
fcd4821b8d fixed compilation problem with rectangular pixels for zmq process 2020-02-18 11:23:54 +01:00
940c8f05cd interpolation without quads 2020-01-24 15:32:48 +01:00
e4ab4547db Interpolation in both directions for rect pixels works, saving of the rectangular image is done by rebinning 2020-01-15 17:27:46 +01:00
27f2321d64 fixed probelm with interpolation of rectangular pixels 2019-12-10 11:10:58 +01:00
545684c8e3 Fixed corordinate inversion 2019-12-09 16:51:15 +01:00
9584ea626d Interpolation changed for rectangular pixels 2019-12-09 13:53:11 +01:00
a2c26664ee added and corrected data structures for rectangular pixels 2019-12-06 12:17:31 +01:00
02a36a148f fixed process make file 2019-11-07 13:28:03 +01:00
142b184e62 fixed last frame with subframes 2019-09-30 12:43:37 +02:00
dd2fe28ce6 finxed subframe index in zmq process 2019-09-30 12:39:49 +02:00
0afd096eae removed log messages in receiver 2019-09-30 12:27:48 +02:00
98ae93fdde Possibility to sum up only fractions of frames in the Zmq process 2019-09-27 13:05:29 +02:00
c654ac7f1f Added sls_detector_process executable for acquire blocking on zmq 2019-09-27 10:12:21 +02:00
db2742495a Added defines to invert the data for HIGHZ in the moench data structures 2019-09-26 12:22:23 +02:00
d0c5c2a6e5 moenchZmqProcess and Makefile adjusted to work with this branch 2019-09-26 11:42:10 +02:00
2c09d394a6 slsDetectorCalibration updated to latest version 2019-09-26 11:34:11 +02:00
52f74142b1 Moench working version 2019-03-28 13:29:12 +01:00
18ab437ae5 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2019-02-06 16:30:59 +01:00
3b56091e2f new header for raw files 2019-02-06 16:30:37 +01:00
dcad6c80ce minor modifications for interpolation and mythe data structure 2019-02-06 16:22:17 +01:00
6abfdcb2c8 manual 2019-02-04 10:48:42 +01:00
9e5ec6a57b only destroy sem if it was initialized 2019-01-16 11:54:01 +01:00
9d3134c3de Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2018-12-14 18:11:46 +01:00
563d644d2f Improved the interpolation with adaptive bins and implemented flat field correction when saving the interpolated images 2018-12-14 18:11:12 +01:00
e379b98631 added header files 2018-12-12 16:10:01 +01:00
f98259adc9 added build requirements to subpackages 2018-12-12 15:50:55 +01:00
88e0914405 added conda recipe as a test 2018-12-12 15:23:24 +01:00
9d8aa5fe91 Works with CTB5 (and should be backward compatible with the rest) 2018-12-06 17:26:54 +01:00
dceea92f1a Fixed big problem with CPU readout 2018-12-06 12:58:54 +01:00
2815458652 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2018-12-06 10:55:32 +01:00
d8140d8db9 anna version 2018-12-06 10:55:18 +01:00
4d0090dfcc ctb server: added brackets around char* in write to socket 2018-11-21 15:57:46 +01:00
e98d60c26e updated ctb binary 2018-11-21 15:35:59 +01:00
cd3135c01d loophole for blackfin not checking the data sent, hence splitting data to a few packets when size > 30k bytes 2018-11-21 15:34:58 +01:00
40dedb8b07 manual 2018-11-16 17:47:41 +01:00
2e83db7d45 changed cluster file format 2018-11-09 12:34:14 +01:00
817736fcd5 after merging with developer 2018-11-02 10:48:06 +01:00
660ed4c177 changed users set/getDetectorsize API to include a single ROI 2018-10-25 14:11:40 +02:00
0d96272db5 manual 2018-10-23 11:29:27 +02:00
38a6393dde fixed probelem with multiThreadedInterpolatingDetector 2018-10-16 17:17:24 +02:00
4aa720eecb added data structure for moench03 rectangual pixels module 019 2018-10-11 09:32:47 +02:00
d68c3b73a8 pdf manual 2018-10-05 14:30:54 +02:00
def79807f6 merge conflict resolved from 4.0.0 2018-09-28 16:28:21 +02:00
eb89d12f41 updated readme and eiger_short 2018-09-28 15:09:31 +02:00
c477970cf0 manual updated 2018-09-28 11:47:25 +02:00
03ae32dcf3 updated manuals 2018-09-27 18:32:20 +02:00
5a394c080f updated release 2018-09-27 18:29:33 +02:00
e631414526 updated version 2018-09-27 18:23:08 +02:00
d2bce7e372 updated release.txt 2018-09-27 18:21:48 +02:00
f9b95b63eb gotthard server: made gotthard server readout only via udp, readframe just waits for acquisition to be done, does not allocate ram, receiver: removed positions hardcoded in 1d, should be 2d for all 2018-09-27 18:20:03 +02:00
c2db073d5e receiver and client: changed xcoord to row and ycoord to column, zcoord to reserved 2018-09-26 15:03:04 +02:00
970d448e73 receiver: using namespace std removed from all the headers and the bug fixes for that for hdf5 2018-09-26 10:53:45 +02:00
b236c14a66 Merge branch '4.0.0' of github.com:slsdetectorgroup/slsDetectorPackage into 4.0.0 2018-09-25 18:01:02 +02:00
80c0d4e10e gui: bug fix advanced tab (network and trimming) was a mess 2018-09-25 18:00:21 +02:00
46db575cc4 updating release.txt 2018-09-25 17:30:38 +02:00
6f0c505c01 Merge branch '4.0.0' of github.com:slsdetectorgroup/slsDetectorPackage into 4.0.0 2018-09-25 14:24:26 +02:00
06d698166f updated dicsard commands in RELEASE.txt 2018-09-25 14:23:22 +02:00
5a139d70b5 gotthard and jungfrau server binary updated for API 2018-09-25 14:08:34 +02:00
33d1b11279 jungfrau server updated for API version change 2018-09-25 14:04:54 +02:00
b163180d6f updating API versions 2018-09-25 14:02:22 +02:00
cab9dff225 Merge branch '4.0.0' of github.com:slsdetectorgroup/slsDetectorPackage into 4.0.0 2018-09-25 13:55:42 +02:00
7d8188fc11 gotthard server binary updated: config file not read a second time after detector start up 2018-09-25 13:55:26 +02:00
64229ca32b changed operator() to const 2018-09-25 11:20:44 +02:00
ae8678cdc2 New Zmq header staructur implemented and works, still different number of pixels in the GUI should be fixed (but it does not crash) 2018-09-25 09:36:47 +02:00
4aa0d26f26 gotthard server: trying to resolve roi problem that is only affected by latest firmware 2018-09-21 17:29:43 +02:00
c52025dd7c manual 2018-09-21 12:04:33 +02:00
9f84bf7175 gui: crashing when using roi fixed 2018-09-20 18:10:10 +02:00
235002cdd4 gui: fixed title height 2018-09-20 14:48:36 +02:00
c784f0f539 client: moved shortenable to roi in reciever, roi not yet written in master file 2018-09-19 17:35:26 +02:00
961489edb1 bugfix gotthard server and client to set roi and disable it, problem still exists with frame numbering between roi modes but can only be fixed in firmware 2018-09-18 18:02:01 +02:00
255931bbde release.txt: no overflow is the defaulkt option and not the overflow option 2018-09-18 10:28:49 +02:00
781152a772 slsDetectorSoftware bug fix: gappixels for x initialized wrong 2018-09-17 18:13:26 +02:00
7b4910ee87 branch 2018-09-17 14:59:08 +02:00
021212372b root converter 2018-09-17 14:54:19 +02:00
59cb9c84c2 bug fix slsdetectorgui: xcoord and y coord are actually col and row indices 2018-09-17 14:35:31 +02:00
e8612a481c receonstruction 2018-09-17 12:47:18 +02:00
d67b4765ea Removing redundant null byte from end of json header 2018-09-17 12:32:33 +02:00
8773de93e9 server first 2018-09-17 11:03:31 +02:00
ef20fa6f3c start documenting cbf converter 2018-09-14 18:05:28 +02:00
19e7ced332 moench zmq process implemented - command implementation is missing 2018-09-13 16:07:43 +02:00
f288390255 Zmq communication uses additional headers, moench processing fixed 2018-09-11 17:05:11 +02:00
30e060b3b1 gap pixels basics 2018-09-04 11:16:31 +02:00
29ba9ae6f7 some updates for 4.0.0 2018-09-03 16:34:06 +02:00
2b2b53f598 update 2018-09-03 13:57:21 +02:00
1ebb07198a deadtimesubperiod 2018-08-31 21:36:38 +02:00
ed0b22b500 updated binaries 2018-08-24 13:18:51 +02:00
548036a602 selective merge from branch 4.0.0 conflict fix 2018-08-24 13:12:55 +02:00
1b55fdad86 merged selected patches from 4.0.0 branch 2018-08-24 13:10:16 +02:00
14c899e7cf removed some manual warnings 2018-08-24 12:34:06 +02:00
b3d4e90f7f sls_detector_software is obsolete, conda packet sls_detector_lib or sls_detector_gui 2018-08-23 16:52:52 +02:00
cedd275892 conflict fix, minor 2018-08-23 16:24:17 +02:00
588037fd18 updated release version 2018-08-23 16:23:24 +02:00
1700d9884a Updated release.txt, minor indentation 2018-08-23 16:08:24 +02:00
e0b8fb3609 updated manuals, jungfrau server (reqd firmware vversion) 2018-08-23 15:52:12 +02:00
b7f62fcd47 updated release.txt 2018-08-23 13:07:38 +02:00
5b6ec303d7 manual api mainclient fix for enum FAIL 2018-08-23 13:00:49 +02:00
cea6c30ded updating release.txt, version API 2018-08-23 12:48:08 +02:00
0781344117 updating binaries 2018-08-22 19:00:21 +02:00
63c130a380 client:updated users class and release.txt 2018-08-22 18:08:35 +02:00
7945d15beb client: updating release.txt, updating command line help, catching slsDetectorUsers exception from multislsdetector constructor 2018-08-21 18:49:29 +02:00
4e446f1f39 eiger server: changed subperiod to subdeadtime, changing subexptime or subdeadtime sets subperiod in eiger server 2018-08-17 13:45:09 +02:00
83600fcb15 Added data structure for moench02 dynamic gain switching 2018-08-17 12:29:07 +02:00
2a28333a96 jungfrau server: allow check version in update mode 2018-08-16 15:09:29 +02:00
830f92dedc client and receiver: silent mode put into shared memory, works properly now 2018-08-15 19:51:04 +02:00
87e8333dfd slsDetectorSoftware & eiger server: fixed coordinates in 2 d, but switch to row (x), col(y); numdetx and numdety sent to all receivers now, likely bug fix virtual file linked in master for 1 mod jungfrau; xccoord and y coord calculated at setdetector pos and given to listener 2018-08-15 19:02:16 +02:00
b3ccd5e1a1 slsReceiverSoftware: bugfix double acquire did not write parameter file cuz vector.push_back always never clearing when closing current file 2018-08-14 19:11:52 +02:00
f0ac49190a slsReceiver:trying to get deactivate to work 2018-08-14 15:06:06 +02:00
921ae01bbe jungfrau module data, fixel moench02 for jctb and jctb server actualized for both buses 2018-08-13 16:27:36 +02:00
fa175ac934 eiger server: updated binaries 2018-08-10 19:14:52 +02:00
0018fa46f8 slsDetectorSoftware: Eiger server, added 3 commands, measuredperiod,measuredsubperiod, status trigger. measured period is in 10ns in det server, status trigger reads reg,sets bit and unsets bit 2018-08-10 19:14:05 +02:00
c934e92a41 Merge branch 'mainexceptions' into developer 2018-08-10 17:10:15 +02:00
da4253fe13 Exception handling from constructors for slsDetector and multiSlsDetector, zmqsockets deleted first in multi freeshm/constructor, removed unnecessary exceptions from exceptions list, replaced in slsDetector socket assign from NULL to 0 2018-08-10 17:07:29 +02:00
3cab1bc0fe minor cleaning of ZmqSocket 2018-08-10 14:34:59 +02:00
d74a8368b8 commented find pkg png 2018-08-10 14:11:16 +02:00
39ebd81230 Zmqsocket merge with Erik's (removing header message) and mine(socketdescriptor safe destruction in constructor exception) 2018-08-09 18:21:30 +02:00
823c855ef4 Zmqsocket merge with Erik's (removing header message) and mine(socketdescriptor safe destruction in constructor exception) 2018-08-09 18:19:47 +02:00
7fadf4feb4 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2018-08-09 18:15:59 +02:00
f86578cfc3 minor fix 2018-08-09 18:15:35 +02:00
a0512a01d5 Exceptions: zmq socket class descriptors made into its own class for auto destruction upon construction exception, similarly for other try blocks. slsDetector and multislsdetector left to do 2018-08-09 18:12:56 +02:00
bdd37fa7c2 commenting zmq detail 2018-08-09 17:58:55 +02:00
a96a019435 string lenght 2018-08-09 17:46:07 +02:00
dd3f4aa81d switched from zmq_msg_revc to zmq_recv 2018-08-09 17:40:04 +02:00
1102153d2b Exceptions handling in constructor for genericSocket, created object to handle both socket descriptors upon throwing exception in constructor (as raw pointers wont get destructed automatically) 2018-08-09 15:43:56 +02:00
ab7e63c20f Moved sls_detector_exceptions to sls_receiver_exceptions & its consequences 2018-08-08 15:43:29 +02:00
f1333c7a90 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2018-08-08 14:47:22 +02:00
e77cdb35dd socket: refactored genericsocket a bit to make socketdescriptor readable 2018-08-08 14:47:07 +02:00
52b1e98726 merge 2018-08-08 12:06:14 +02:00
df75fef6f6 reordered moenchExecutables 2018-08-08 11:27:46 +02:00
44fdc46c11 some changes in the moench executables 2018-08-08 10:23:35 +02:00
147194e8af slsDetector: connect stop socket in checkonline so that it does not stick to its initialized default file descriptor zero (which gets closed upon socket deletion) 2018-08-03 14:54:32 +02:00
05055eb283 slsReceiver: deleting slsReceiverUsers object before calling start() gives seg fault 2018-08-03 09:32:31 +02:00
0dc1e10bd3 slsDetectorSoftware: order of zmq deletion in multi destructor to first because api using zmq to get data will need to be deleted first 2018-07-30 18:51:18 +02:00
e38e500e16 manual example api: fixed the makefile include 2018-07-30 18:36:49 +02:00
134f13fc52 slsDetectorSoftware: back to original multi threading setTimer (removed parallelCallDetectorMember) due to change in function signature 2018-07-30 18:00:18 +02:00
41fb6c26a2 slsDetectorSoftware: from 3.1.4: being able to get timer values individually from the users class since gotthard 25um master and slave will have different delay values 2018-07-30 17:47:37 +02:00
73fcef5f6d slsReceiverSoftware: bitset storage in case the libarary changes contiguous representation, also changed hdf5 representation from 512 byte (to_string) to just passing char* to keep at 64 bytes 2018-07-30 12:05:22 +02:00
e9cc91698e Merge branch '3.3.0-rc' into developer 2018-07-26 13:46:58 +02:00
6213b5e07a gotthard server and slsDetectorSoftware: more accuracy when converting from double to int64_t by adding 0.5, improved clock precision of gotthard from 32.1 to 32.007729 2018-07-26 13:46:41 +02:00
08aacf76ac Merge branch '3.3.0-rc' into developer 2018-07-23 15:03:13 +02:00
711e0d771e slsDetectorSoftware: users setSettings(-1) gives undefined settings. fixed 2018-07-23 15:03:00 +02:00
2fc98c7a54 updated binaries, eiger jungfrau 2018-07-18 15:04:47 +02:00
3b6ead7783 slsReceiver: HDF5: unlimited max dimension in x (#numImages), x dim gets incremented by #frames when it gets an extra image, removed virtual_ naming in parameter names, small cased parameter names 2018-07-18 14:05:31 +02:00
40c96b5562 Updated Makefiles, Cmakelists.txt to compile slsMultiReceiver properly and with HDF5 and fixed compiler warnings 2018-07-18 12:29:19 +02:00
6bb7195a2c slsReceiver: master file limited by size of 1000 bytes 2018-07-17 15:41:43 +02:00
9ae1289616 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2018-04-27 15:14:19 +02:00
3baa677a2e minor changes by Anna 2018-04-27 15:14:09 +02:00
266 changed files with 14570 additions and 12921 deletions

45
.travis.yml Normal file
View 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

View File

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

View File

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

View File

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

View File

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

22
cmk.sh
View File

@ -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,11 +55,12 @@ 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"
REBUILD=1
CLEAN=1
;;
c)
echo "Clean Required"
@ -67,6 +70,7 @@ while getopts ":bchd:j:trg" opt ; do
echo "Building of CMake files with HDF5 option Required"
HDF5=1
REBUILD=1
CLEAN=1
;;
d)
echo "New HDF5 directory: $OPTARG"
@ -80,17 +84,24 @@ while getopts ":bchd:j:trg" opt ; do
echo "Compiling Options: Text Client"
TEXTCLIENT=1
REBUILD=1
CLEAN=1
;;
r)
echo "Compiling Options: Receiver"
RECEIVER=1
REBUILD=1
CLEAN=1
;;
g)
echo "Compiling Options: GUI"
GUI=1
REBUILD=1
;;
CLEAN=1
;;
e)
echo "Compiling Options: Debug"
DEBUG=1
;;
\?)
echo "Invalid option: -$OPTARG"
usage
@ -145,7 +156,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

View 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

View 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

View 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

View File

@ -0,0 +1,499 @@
hostname bchip071+
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 1954
0:rx_udpport 32411
####gui listening to
zmqport 50001
####data streaming out of
rx_zmqport 50003
#zmqip 129.129.202.86
#0:rx_udpip 10.1.2.117
#0:detectorip 10.1.2.19
#rx_zmqip 10.1.2.117
#0:rx_hostname mpc2608
zmqip 129.129.202.98
0:rx_udpip 10.1.1.102
0:detectorip 10.1.1.19
rx_zmqip 10.1.1.102
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 mx-test-1
#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 200
period 0.005
r_discardpolicy discardpartial
frames 100
period 0.1
outdir /mnt/moench_data/scratch/
enablefwrite 0

View File

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

View File

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

View File

@ -1 +0,0 @@
../../slsReceiverSoftware/include/ansi.h

View File

@ -1 +0,0 @@
../../slsDetectorSoftware/slsDetectorAnalysis/detectorData.h

View File

@ -1 +0,0 @@
../../build/bin/libSlsDetector.so

View File

@ -1 +0,0 @@
../../build/bin/libSlsReceiver.so

View File

@ -1 +0,0 @@
../../slsReceiverSoftware/include/libzmq.a

View File

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

View File

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

View File

@ -81,7 +81,11 @@ LATEX_HIDE_INDICES = YES
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

View File

@ -1 +0,0 @@
../../slsDetectorSoftware/slsDetector/slsDetectorUsers.h

View File

@ -1 +0,0 @@
../../slsReceiverSoftware/include/slsReceiverUsers.h

View File

@ -1 +0,0 @@
../../slsReceiverSoftware/include/sls_receiver_defs.h

View File

@ -1 +0,0 @@
../../slsReceiverSoftware/include/sls_receiver_funcs.h

View File

@ -1 +0,0 @@
../../slsReceiverSoftware/include/zmq.h

Binary file not shown.

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

View File

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

View File

@ -1 +0,0 @@
../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualMaster

View File

@ -1 +0,0 @@
../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualSlave

View File

@ -0,0 +1 @@
../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv4.0.0.22.0

View File

@ -1 +0,0 @@
../slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_virtual

View File

@ -0,0 +1 @@
../slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServerv4.0.0.3

View File

@ -1 +0,0 @@
../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_virtual

View File

@ -0,0 +1 @@
../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv4.0.0.0

View File

@ -1,2 +0,0 @@
*.o
*.*~

View File

@ -33,16 +33,17 @@ class MovingStat
{
if (m>=0) m_n = m; else m_n = n;
m_newM=val*m_n;
// cout << "set " << val << " " << m << " " << m_n << " " << m_newM << endl;
SetRMS(rms);
}
/**
/**
clears the moving average number of samples parameter, mean and standard deviation
*/
void SetRMS(double rms)
{
if (rms<=0) {
m_newM2=m_newM*m_newM/n;
m_n=0;
//m_n=0;
} else {
if (m_n>0)
m_newM2=(m_n*rms*rms+m_newM*m_newM/m_n);
@ -120,6 +121,7 @@ class MovingStat
*/
inline double Mean() const
{
// cout << "get " << m_n << " " << m_newM << " " << m_newM/m_n << endl;
return (m_n > 0) ? m_newM/m_n : 0.0;
}

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

View File

@ -6,8 +6,10 @@
#include <pthread.h>
#include "slsDetectorData.h"
#include "pedestalSubtraction.h"
#include "commonModeSubtraction.h"
#include "commonModeSubtractionNew.h"
#include "ghostSummation.h"
#include "tiffIO.h"
#include "slsInterpolation.h"
#ifdef ROOTSPECTRUM
@ -29,6 +31,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
@ -56,16 +62,16 @@ template <class dataType> class analogDetector {
analogDetector(slsDetectorData<dataType> *d, int sign=1,
commonModeSubtraction *cm=NULL, int nped=1000, int nnx=-1, int nny=-1, double *gm=NULL) : det(d), nx(nnx), ny(nny), stat(NULL), cmSub(cm), iframe(-1), dataSign(sign), gmap(gm), id(0) {
commonModeSubtraction *cm=NULL, int nped=1000, int nnx=-1, int nny=-1, double *gm=NULL, ghostSummation<dataType> *gs=NULL) : det(d), nx(nnx), ny(nny), stat(NULL), cmSub(cm), dataSign(sign), iframe(-1), gmap(gm), ghSum(gs), id(0) {
if (det)
det->getDetectorSize(nx,ny);
stat=new pedestalSubtraction*[ny];
stat=new pedestalSubtraction[ny*nx];
for (int i=0; i<ny; i++) {
stat[i]=new pedestalSubtraction[nx];
// stat[i]=new pedestalSubtraction[nx];
for (int ix=0; ix<nx; ix++) {
stat[i][ix].SetNPedestals(nped);
stat[i*nx+ix].SetNPedestals(nped);
}
}
image=new int[nx*ny];
@ -76,7 +82,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
@ -90,7 +95,7 @@ template <class dataType> class analogDetector {
/**
destructor. Deletes the pdestalSubtraction array and the image
*/
virtual ~analogDetector() {for (int i=0; i<ny; i++) delete [] stat[i]; delete [] stat; delete [] image;
virtual ~analogDetector() {for (int i=0; i<ny; i++) delete [] stat; delete [] image;
#ifdef ROOTSPECTRUM
delete hs;
#ifdef ROOTCLUST
@ -114,7 +119,7 @@ template <class dataType> class analogDetector {
dataSign=orig->dataSign;
iframe=orig->iframe;
gmap=orig->gmap;
cmSub=orig->cmSub;
// cmSub=orig->cmSub;
id=orig->id;
xmin=orig->xmin;
xmax=orig->xmax;
@ -124,19 +129,15 @@ template <class dataType> class analogDetector {
// nSigma=orig->nSigma;
fMode=orig->fMode;
myFile=orig->myFile;
fm=orig->fm;
stat=new pedestalSubtraction*[ny];
for (int i=0; i<ny; i++) {
stat[i]=new pedestalSubtraction[nx];
}
stat=new pedestalSubtraction[ny*nx];
int nped=orig->SetNPedestals();
//cout << nped << " " << orig->getPedestal(ix,iy) << orig->getPedestalRMS(ix,iy) << endl;
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
stat[iy][ix].SetNPedestals(nped);
stat[iy*nx+ix].SetNPedestals(nped);
setPedestal(ix,iy,orig->getPedestal(ix,iy),orig->getPedestalRMS(ix,iy),orig->GetNPedestals(ix,iy));
}
}
@ -150,7 +151,16 @@ template <class dataType> class analogDetector {
hs9=(TH2F*)(orig->hs9)->Clone();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5);
#endif
#endif
if (orig->cmSub) {
cmSub=(orig->cmSub)->Clone();
cout <<"cloning cm" << endl;
}
else cmSub=NULL;
if (orig->ghSum) {
ghSum=(orig->ghSum)->Clone();
cout <<"cloning gs" << endl;
}
else ghSum=NULL;
}
@ -186,7 +196,7 @@ template <class dataType> class analogDetector {
\param nns reference to number of subpixels for interpolating detector, will always be 1 in this case
\returns number of pixels of the detector image
*/
virtual int getImageSize(int &nnx, int &nny, int &nns){nnx=nx; nny=ny; nns=1; return nx*ny;};
virtual int getImageSize(int &nnx, int &nny, int &nnsx, int &nnsy){nnx=nx; nny=ny; nnsx=1; nnsy=1; return nx*ny;};
/**
Returns data size of the detector image matrix
\param nnx reference to pixel size in x
@ -213,14 +223,18 @@ template <class dataType> class analogDetector {
\returns pointer to current gain map is file reading succeeded, NULL is file reading didn't work.
*/
double *readGainMap(const char * imgname) {
uint32 nnx, nny;
float *gm=ReadFromTiff( imgname, nny, nnx);
uint32 unnx, unny;
int nnx, nny;
float *gm=ReadFromTiff( imgname, unny, unnx);
nnx=unnx;
nny=unny;
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 iy=0; iy<nny; iy++) {
for (int ix=0; ix<nnx; ix++) {
gmap[iy*nnx+ix]=gm[iy*nnx+ix];
// cout << gmap[iy*nnx+ix] << " " ;
}
}
return gmap;
@ -237,8 +251,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];
}
}
@ -255,7 +269,7 @@ template <class dataType> class analogDetector {
iframe=-1;
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++) {
stat[iy][ix].Clear();
stat[iy*nx+ix].Clear();
image[iy*nx+ix]=0;
}
if (cmSub) cmSub->Clear();
@ -272,6 +286,14 @@ template <class dataType> class analogDetector {
/** resets the commonModeSubtraction and increases the frame index */
virtual void newFrame(){iframe++; if (cmSub) cmSub->newFrame();};
/** resets the commonModeSubtraction and increases the frame index */
virtual void newFrame(char *data){
iframe++;
if (cmSub) cmSub->newFrame();
calcGhost(data);
// cout << getId() << " Calc ghost " << getGhost(15,15) << endl;
};
/** sets the commonModeSubtraction algorithm to be used
@ -286,6 +308,11 @@ template <class dataType> class analogDetector {
commonModeSubtraction *getCommonModeSubtraction() {return cmSub;};
ghostSummation<dataType> *getGhostSummation(){return ghSum;};
ghostSummation<dataType> *setGhostSummation(ghostSummation<dataType> *gs){ghSum=gs; return ghSum;};
/**
sets the sign of the data
\param sign 1 means positive values for photons, -1 negative, 0 gets
@ -301,12 +328,18 @@ template <class dataType> class analogDetector {
\param iy pixel y coordinate
\param cm 1 adds the value to common mod, 0 skips it. Defaults to 0. - not properly implemented
*/
virtual void addToPedestal(double val, int ix, int iy=0, int cm=0){
virtual void addToPedestal(double val, int ix, int iy, int cm=0){
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
// cout << val << " " ;
if (cmSub && cm>0) {
val-= getCommonMode(ix, iy);
}
stat[iy][ix].addToPedestal(val);
// cout << val << " " ;
val+=getGhost(ix,iy);
// cout << val ;
// cout << endl;
stat[iy*nx+ix].addToPedestal(val);
/* if (cmSub && cm>0) { */
/* if (det) if (det->isGood(ix, iy)==0) return; */
/* cmSub->addToCommonMode(val, ix, iy); */
@ -315,28 +348,47 @@ template <class dataType> class analogDetector {
}
double getCommonMode(int ix, int iy) {
if (cmSub) return cmSub->getCommonMode(ix, iy);
else return 0;
if (cmSub) {
return cmSub->getCommonMode(ix, iy);
}
return 0;
}
virtual void addToCommonMode(char *data){
// cout << "+"<< getId() << endl;
if (cmSub) {
for (int ix=xmin; ix<xmax; ix++) {
//cout << "*" << endl;
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 << ":";
// }
}
}
//cout << "cm " << getCommonMode(0,0) << " " << getCommonMode(1,0) << endl;
}
}
virtual void addToCommonMode(char *data, int ix, int iy=0){
// cout <<".";
if (cmSub) {
//cout <<":";
if (det) if (det->isGood(ix, iy)==0) return;
if (getNumpedestals(ix,iy)>0){
cmSub->addToCommonMode(subtractPedestal(data,ix,iy,0), ix, iy);
// cout << ix << " " <<subtractPedestal(data,ix,iy,0) << endl;
double val;
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,0));
} else
val= (((double*)data)[iy*nx+ix]-getPedestal(ix,iy));
val+=getGhost(ix,iy);
cmSub->addToCommonMode(val, ix, iy);
//cout << ":";
}
}
}
@ -347,12 +399,13 @@ template <class dataType> class analogDetector {
\param cm 0 (default) without common mode subtraction, 1 with common mode subtraction (if defined)
\returns pedestal value
*/
virtual double getPedestal(int ix, int iy, int cm=0){
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
if (cmSub && cm>0)
return stat[iy][ix].getPedestal()+getCommonMode(ix,iy);
else return stat[iy][ix].getPedestal();
else return -1;
virtual double getPedestal (int ix, int iy, int cm=0){
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
if (cmSub && cm>0) {
return stat[iy*nx+ix].getPedestal()+getCommonMode(ix,iy);
} else return stat[iy*nx+ix].getPedestal();
} else return -1;
};
@ -363,15 +416,22 @@ template <class dataType> class analogDetector {
\returns pedestal rms
*/
virtual double getPedestalRMS(int ix, int iy){
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
return stat[iy][ix].getPedestalRMS();
else return -1;
double g=1;
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
if (gmap) {
g=gmap[iy*nx+ix];
if (g==0) g=-1.;
}
return stat[iy*nx+ix].getPedestalRMS()/g;//divide by gain?
}
return -1;
};
virtual int getNumpedestals(int ix, int iy){
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
return stat[iy][ix].getNumpedestals();
else return -1;
return stat[iy*nx+ix].getNumpedestals();
return -1;
};
/**
gets pedestal (and common mode)
@ -381,11 +441,13 @@ template <class dataType> class analogDetector {
\returns pedestal value
*/
virtual double* getPedestal(double *ped){
if (ped==NULL)
if (ped==NULL) {
ped=new double[nx*ny];
for (int ix=0; ix<nx; ix++) {
for (int iy=0; iy<ny; iy++) {
ped[iy*nx+ix]=stat[iy][ix].getPedestal();
}
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
ped[iy*nx+ix]=stat[iy*nx+ix].getPedestal();
//cout << ped[iy*nx+ix] << " " ;
}
}
return ped;
@ -398,11 +460,12 @@ template <class dataType> class analogDetector {
\returns pedestal rms
*/
virtual double* getPedestalRMS(double *ped=NULL){
if (ped==NULL)
if (ped==NULL) {
ped=new double[nx*ny];
for (int ix=0; ix<nx; ix++) {
for (int iy=0; iy<ny; iy++) {
ped[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
}
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
ped[iy*nx+ix]=stat[iy*nx+ix].getPedestalRMS();
}
}
return ped;
@ -428,7 +491,7 @@ template <class dataType> class analogDetector {
\param rms rms to be set if any, defaults to 0
\param m number of pedestal samples to be set or the moving stat structure is any, defaults to 0
*/
virtual void setPedestal(int ix, int iy, double val, double rms=0, int m=-1){if (ix>=0 && ix<nx && iy>=0 && iy<ny) stat[iy][ix].setPedestal(val,rms, m);};
virtual void setPedestal(int ix, int iy, double val, double rms=0, int m=-1){if (ix>=0 && ix<nx && iy>=0 && iy<ny) stat[iy*nx+ix].setPedestal(val,rms, m);};
/**
sets pedestal
@ -440,13 +503,14 @@ 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 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);
stat[iy*nx+ix].setPedestal(ped[iy*nx+ix],rr, m);
// cout << ix << " " << iy << " " << ped[iy*nx+ix] << " " << stat[iy*nx+ix].getPedestal() << endl;
};
};
}
@ -459,7 +523,7 @@ template <class dataType> class analogDetector {
\param iy pixel y coordinate
\param rms value to set
*/
virtual void setPedestalRMS(int ix, int iy, double rms=0){if (ix>=0 && ix<nx && iy>=0 && iy<ny) stat[iy][ix].setPedestalRMS(rms);};
virtual void setPedestalRMS(int ix, int iy, double rms=0){if (ix>=0 && ix<nx && iy>=0 && iy<ny) stat[iy*nx+ix].setPedestalRMS(rms);};
@ -469,15 +533,32 @@ 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++) {
stat[iy][ix].setPedestalRMS(rms[iy*nx+ix]);
for (int ix=xmin; ix<xmax; ix++) {
stat[iy*nx+ix].setPedestalRMS(rms[iy*nx+ix]);
};
};
}
virtual void calcGhost(char *data, int ix, int iy=1) {
if (ghSum) {
ghSum->calcGhost(data, ix, iy);
}
};
virtual void calcGhost(char *data){if (ghSum) {
ghSum->calcGhost(data);
// cout << getId() << " @ " << ghSum->getXTalk() << " " << ghSum->getGhost(15,15) << endl;
}
};
virtual double getGhost(int ix, int iy) {if (ghSum) return ghSum->getGhost(ix, iy); return 0;};
/**
write 32bit tiff file with detector image data
@ -493,8 +574,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,12 +622,12 @@ 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(); */
/* gm[iy*nx+ix]=stat[iy*nx+ix].getPedestal()-cmSub->getCommonMode(); */
/* else */
gm[iy*nx+ix]=stat[iy][ix].getPedestal();
gm[iy*nx+ix]=stat[iy*nx+ix].getPedestal();
#ifdef ROOTSPECTRUM
hmap->SetBinContent(ix+1, iy+1,gm[iy*nx+ix]);
#endif
@ -588,15 +669,15 @@ template <class dataType> class analogDetector {
if (gm) {
for (int ix=0; ix<nnx; ix++) {
for (int iy=0; iy<nny; iy++) {
stat[iy][ix].setPedestal(gm[iy*nx+ix],-1,-1);
for (int ix=0; ix<nnx; ix++) {
stat[iy*nx+ix].setPedestal(gm[iy*nx+ix],-1,-1);
}
}
delete [] gm;
return 1;
}
return NULL;
return 0;
}
/**
@ -613,15 +694,15 @@ 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];
}
}
delete [] gm;
return 1;
}
return NULL;
return 0;
}
@ -639,9 +720,9 @@ 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++) {
gm[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
for (int ix=0; ix<nx; ix++) {
gm[iy*nx+ix]=stat[iy*nx+ix].getPedestalRMS();
}
}
ret=WriteToTiff(gm, imgname, ny, nx);
@ -661,9 +742,9 @@ 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++) {
stat[iy][ix].setPedestalRMS(gm[iy*nx+ix]);
for (int ix=0; ix<nnx; ix++) {
stat[iy*nx+ix].setPedestalRMS(gm[iy*nx+ix]);
}
}
delete [] gm;
@ -681,25 +762,34 @@ template <class dataType> class analogDetector {
Adds all the data for each pixels in the selected region of interest to the pedestal
\param data pointer to the data
*/
virtual void addToPedestal(char *data, int cm=0) {
// cout << "add to pedestal " << endl;
newFrame(data);
newFrame();
if (cmSub) {
//calcGhost(data);
if (cmSub && cm) {
// cout <<",";
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 iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) {
if (det->isGood(ix,iy)) {
// addToPedestal(data,ix,iy,1);
addToPedestal(data,ix,iy,cm);
//if (ix==10 && iy==10)
// cout <<ix << " " << iy << " " << getPedestal(ix,iy)<< endl;
#ifdef ROOTSPECTRUM
subtractPedestal(data,ix,iy,cm);
#endif
}
}
}
@ -709,6 +799,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
@ -772,7 +863,7 @@ template <class dataType> class analogDetector {
*/
virtual void addToPedestal(char *data, int ix, int iy=0, int cm=0) {
virtual void addToPedestal(char *data, int ix, int iy, int cm=0) {
double val;
@ -782,13 +873,14 @@ template <class dataType> class analogDetector {
val=dataSign*det->getValue(data, ix, iy);
else
val=((double*)data)[iy*nx+ix];
/* if (ix==10 && iy==10) */
/* cout << ix << " " << iy << " " << val ; */
// cout << val << endl;
/* 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) */
// cout << val << endl;
/* if (ix==10 && iy==10) */
/* cout <<" " << getPedestal(ix,iy)<< endl; */
/* if (ix==100 && iy==100) */
/* cout << " " << getPedestal(ix,iy)<< endl; */
@ -808,14 +900,17 @@ template <class dataType> class analogDetector {
virtual int *subtractPedestal(char *data, int *val=NULL, int cm=0) {
newFrame();
newFrame(data);
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);
//calcGhost(data);
for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) {
if (det->isGood(ix,iy))
val[iy*nx+ix]+=subtractPedestal(data, ix, iy,cm);
}
}
return val;
@ -836,18 +931,25 @@ template <class dataType> class analogDetector {
virtual double subtractPedestal(char *data, int ix, int iy=0, int cm=0) {
double g=1.;
double val;
double val =0;
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
if (gmap) {
g=gmap[iy*nx+ix];
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;
//if (val>=0.5*thr)
// cout << val << " " << (dataSign*det->getValue(data, ix, iy)-getPedestal(ix,iy,cm)) << " " << g << " ";
val+=getGhost(ix,iy)/g;
#ifdef ROOTSPECTRUM
hs->Fill(val,(iy-ymin)*(xmax-xmin)+(ix-xmin));
#ifdef ROOTCLUST
@ -879,6 +981,7 @@ template <class dataType> class analogDetector {
#endif
return val;
}
return val;
};
@ -906,8 +1009,7 @@ template <class dataType> class analogDetector {
int nph=0;
double v;
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
v=subtractPedestal(data,ix,iy);
v=subtractPedestal(data,ix,iy,1);
/* // cout << v << " " ; */
/* #ifdef ROOTSPECTRUM */
/* // cout << (iy-ymin)*(xmax-xmin)+(ix-xmin) << endl; */
@ -916,8 +1018,14 @@ template <class dataType> class analogDetector {
if (thr>0) {
v+=0.5*thr;
nph=v/thr;
if (nph>0)
/* if (ix ==10 && iy<20) */
/* cout << det->getValue(data,ix,iy) << " " << stat[iy*nx+ix].getPedestal() << " " << getCommonMode(ix,iy) << " " << getPedestal(ix,iy,0)<< " " << getPedestal(ix,iy,1) << endl; */
// cout << subtractPedestal(data,ix,iy,0) << " " << subtractPedestal(data,ix,iy,1) << " " << nph << endl;
if (nph>0) {
//cout << " " << nph << endl;
return nph;
}
return 0;
}
return v;
@ -933,16 +1041,18 @@ template <class dataType> class analogDetector {
*/
int *getNPhotons(char *data, int *nph=NULL) {
double val;
//double val;
if (nph==NULL)
nph=image;
newFrame();
newFrame(data);
//calcGhost(data);
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 iy=ymin; iy<ymax; 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 +1064,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,10 +1095,10 @@ 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++)
stat[iy][ix].SetNPedestals(i);
return stat[0][0].SetNPedestals();
for (ix=0; ix<nx; ix++)
stat[iy*nx+ix].SetNPedestals(i);
return stat[0].SetNPedestals();
};
/** gets number of samples for moving average pedestal calculation
@ -996,7 +1106,7 @@ template <class dataType> class analogDetector {
*/
int GetNPedestals(int ix, int iy) {
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
return stat[iy][ix].GetNPedestals();
return stat[iy*nx+ix].GetNPedestals();
else
return -1;
};
@ -1018,10 +1128,16 @@ 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);
newFrame(data);
//calcGhost(data);
addToCommonMode(data);
for (int iy=ymi; iy<yma; 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 +1154,17 @@ template <class dataType> class analogDetector {
virtual void processData(char *data,int *val=NULL) {
switch(fMode) {
case ePedestal:
// cout << "ped " << endl;
addToPedestal(data);
//cout << "analog ped " << endl;
addToPedestal(data,1);
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 +1178,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,17 +1203,43 @@ 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 */
int nx; /**< Size of the detector in x direction */
int ny; /**< Size of the detector in y direction */
pedestalSubtraction **stat; /**< pedestalSubtraction class */
pedestalSubtraction *stat; /**< pedestalSubtraction class */
commonModeSubtraction *cmSub;/**< commonModeSubtraction class */
int dataSign; /**< sign of the data i.e. 1 if photon is positive, -1 if negative */
int iframe; /**< frame number (not from file but incremented within the dataset every time newFrame is called */
double *gmap;
ghostSummation<dataType> *ghSum;/**< ghostSummation class */
int *image;
int id;
//int xmin, xmax, ymin, ymax; int xmin; /**< minimum x of the region of interest */
@ -1092,6 +1250,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 +1261,6 @@ FILE *getFilePointer(){return myFile;};
TH2F *hs9;
#endif
#endif
pthread_mutex_t *fm;
};
#endif

View File

@ -0,0 +1,127 @@
#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) : nsigma(ns), nROI(iroi) {
mean=new double[nROI];
mean2=new double[nROI];
nCm=new double[nROI];
};
/** destructor - deletes the moving average(s) and the sum of pedestals calculator(s) */
virtual ~commonModeSubtraction() {delete [] mean; delete [] mean2; delete [] nCm;};
/* commonModeSubtraction(commonModeSubtraction *cs) { */
/* if (cs) new commonModeSubtraction(cs->getNRoi(), cs->nsigma); */
/* } */
virtual commonModeSubtraction *Clone() {
return new commonModeSubtraction(this->nROI, this->nsigma);
}
/** clears the moving average and the sum of pedestals calculation - virtual func*/
virtual void Clear(){
for (int i=0; i<nROI; i++) {
mean[i]=0;
nCm[i]=0;
mean2[i]=0;
}};
/** adds the average of pedestals to the moving average and reinitializes the calculation of the sum of pedestals for all ROIs. - virtual func*/
virtual void newFrame(){
//cout << "Reset CM" << endl;
for (int i=0; i<nROI; i++) {
// if (nCm[i]>0) cmStat[i].Calc(cmPed[i]/nCm[i]);
nCm[i]=0;
mean[i]=0;
mean2[i]=0;
}};
/** adds the pixel to the sum of pedestals -- virtual func must be overloaded to define the regions of interest
\param val value to add
\param ix pixel x coordinate
\param iy pixel y coordinate
*/
virtual void addToCommonMode(double val, int ix=0, int iy=0) {
int iroi=getROI(ix,iy);
// if (iroi==0) val=100;
// else val=-100;
// if (isc>=0 && isc<nROI) {
// cout << ix << " " << iy << " " << iroi << endl;
//if (ix==15 && iy==15) cout << "=" << val << endl;
if (iroi>=0 && iroi<nROI) {
// cout << ix << " " << iy << " " << iroi << endl;
mean[iroi]+=val;
mean2[iroi]+=val*val;
nCm[iroi]++;
}
};
/** gets the common mode i.e. the difference between the current average sum of pedestals mode and the average pedestal
\param ix pixel x coordinate
\param iy pixel y coordinate
\return the difference between the current average sum of pedestals and the average pedestal
*/
virtual double getCommonMode(int ix=0, int iy=0) {
int iroi=getROI(ix,iy);
/* if (iroi==0) */
/* return 100; */
/* else */
/* return -100; */
// cout << "*" << ix << " " << iy << " " << iroi << " " << mean[iroi] << " " << nCm[iroi]<< endl;
// if (ix==15 && iy==15) cout << "-" << mean[iroi]/nCm[iroi] << endl;
if (iroi>=0 && iroi<nROI) {
if (nCm[iroi]>0)
return mean[iroi]/nCm[iroi];
}
return 0;
};
/** 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;};
int getNRoi(){return nROI;};
protected:
double *mean; /**<array of moving average of the pedestal average per region of interest */
double *mean2; /**< array storing the sum of pedestals per region of interest */
double *nCm; /**< array storing the number of pixels currently contributing to the pedestals */
int nsigma; /** number of rms above which the pedestal should be considered as a photon */
const int nROI; /**< constant parameter for number of regions on which the common mode should be calculated separately e.g. supercolumns */
};
#endif

View File

@ -43,9 +43,9 @@ 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;
//int iarg;
int64_t word, *wp;
short unsigned int* val=new short unsigned int[nch];
int bit[64];
@ -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;
}

View 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

View File

@ -0,0 +1,171 @@
#ifndef DESERIALIZER_H
#define DESERIALIZER_H
#include <vector>
class deserializer : public slsDetectorData<int> {
public:
deserializer( std::vector <int> dbl, int nch=64*3,int dr=24, int off=2): slsDetectorData<int>(nch,1,nch*dr*8+off*8,NULL,NULL,NULL), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch), dbitlist(dbl) {};
deserializer( std::vector <int> dbl, int nch,int dr, int off, int ds): slsDetectorData<int>(nch,1,ds,NULL,NULL,NULL), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch), dbitlist(dbl) {};
virtual void getPixel(int ip, int &x, int &y) {x=-1; y=-1;};
virtual int getChannel(char *data, int ix, int iy=0) {
int ret=-1;
if (ix>=0 && ix<numberOfCounters) {
int *val=deserializeAll(data,dbitlist,dynamicRange,numberOfCounters,serialOffset);
ret=val[ix];
delete [] val;
}
return ret;
};
virtual int getFrameNumber(char *buff) {return frameNumber;};
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
ndata=dsize;
return data;
}
virtual char *readNextFrame(ifstream &filebin) {
char *data=NULL;
if (filebin.is_open()) {
data=new char[dataSize];
filebin.read(data,dataSize);
}
return data;
}
virtual int **getData(char *ptr, int dsize=-1) {
int **val;
val=new int*[1];
val[0]=deserializeAll(ptr,dbitlist,dynamicRange,nx,serialOffset);
return val;
}
static int* deserializeAll(char *ptr, std::vector <int> dbl, int dr=24, int nch=64*3, int off=5) {
// off=0;
//int iarg;
int64_t word, *wp;
int* val=new int[nch];
int ioff=0;
int idr=0;
int ib=0;
int iw=0;
int ii=0;
int ich;
int nb=dbl.size();
idr=0;
for (ib=0; ib<nch; ib++) {
val[ib]=0;
}
wp=(int64_t*)ptr;
for (iw=0; iw<nch/nb; iw) {
word=*wp;;
if (ioff<off) {
ioff++;
// cout <<"*";
} else {
//if (idr<16) {
ib=0;
for (const auto &bit : dbl) {
ich=iw+nch/nb*(ib);
if (word&(1<<bit) && ich<nch) {
//cout << "+" ;
val[ich]|=(1<<idr);
} //else {
//cout << "-" ;
//}
ib++;
}
}
idr++;
if (idr==dr) {
idr=0;
// cout << dec << " " << iw << " " << val[iw] << " " << val[iw+nch/2] << endl;
cout <<dec << iw<<endl;
iw++;
}//end if()
//end else()
wp+=1;
ii++;
}//end for
return val;
}
static int* deserializeList(char *ptr, std::vector <int> dbl, int dr=24, int nch=64*3, int off=5) {
// off=0;
//int iarg;
// int64_t word;
int* val=new int[nch];
//int ioff=0;
int idr=0;
int ib=0;
int iw=0;
int ii=0;
int ich;
int nb=dbl.size();
char *dval;
idr=0;
for (ib=0; ib<nch; ib++) {
val[ib]=0;
}
dval=ptr;
ib=0;
ich=0;
for (const auto &bit : dbl) {
//ioff=off;
idr=0;
for (iw=0; iw<(nch*dr/nb)/8; iw++) {
val[ich]|=(*dval)<<idr;
idr+=8;
dval++;
if (idr>=dr) {
idr=0;
ich++;
}
}
ii++;
ib++;
}//end for
return val;
}
virtual int setFrameNumber(int f=0) {if (f>=0) frameNumber=f; return frameNumber; };
virtual int setDynamicRange(int d=-1) {if (d>0 && d<=24) dynamicRange=d; return dynamicRange;};
virtual int setSerialOffset(int d=-1) {if (d>=0) serialOffset=d; return serialOffset;};
virtual int setNumberOfCounters(int d=-1) {if (d>=0) numberOfCounters=d; return numberOfCounters;};
virtual std::vector <int> setDBitList(std::vector <int> dbl) {dbitlist=dbl; return dbitlist;};
virtual std::vector <int> getDBitList() {return dbitlist;};
private:
int dynamicRange;
int serialOffset;
int frameNumber;
int numberOfCounters;
std::vector <int> dbitlist;
};
#endif

View File

@ -1,470 +0,0 @@
#ifndef EIGERMODULEDATA_H
#define EIGERMODULEDATA_H
#include "slsReceiverData.h"
class eigerHalfModuleData : public slsReceiverData<uint32_t> {
public:
/**
Implements the slsReceiverData structure for the eiger prototype read out by a half module i.e. using the slsReceiver
(256*256 pixels, 512 packets for 16 bit mode, 256 for 8, 128 for 4, 1024 for 32, 1040 etc.)
\param d dynamic range
\param c crosstalk parameter for the output buffer
*/
eigerHalfModuleData(bool t, bool l, int dr, int tg, int psize, int dsize, int npf, int x, int y, double c=0):
slsReceiverData<uint32_t>(x, y, npf, psize),
top(t), left(l),
dynamicRange(dr), tenGiga(tg),
packetSize(psize), onepacketdataSize(dsize), numberofPacketsPerFrame(npf),
xtalk(c),
header_t(0), footer_t(0){
int **dMap;
uint32_t **dMask;
dMap=new int*[ny];
dMask=new uint32_t*[ny];
for (int i = 0; i < ny; i++) {
dMap[i] = new int[nx];
dMask[i] = new uint32_t[nx];
}
//Map
int totalNumberOfBytes = numberofPacketsPerFrame * packetSize;
int iPacket = 8;
int iData = 0;
int increment = (dynamicRange/8);
int ic_increment = 1;
if (dynamicRange == 4) {
increment = 1;
ic_increment = 2;
}
if(top){
for (int ir=0; ir<ny; ir++) {
for (int ic=0; ic<nx; ic = ic + ic_increment) {
dMap[ir][ic] = iPacket;
iPacket += increment;
iData += increment;
//increment header
if(iData >= onepacketdataSize){
iPacket += 16;
iData = 0;
}
}
}
}
//bottom
else{
iData = 0;
int numbytesperline;
switch(dynamicRange){
case 4: numbytesperline = 256; break;
case 8: numbytesperline = 512; break;
case 16:numbytesperline = 1024; break;
case 32:numbytesperline = 2048; break;
}
iPacket = totalNumberOfBytes - numbytesperline - 8;
if((dynamicRange == 32) && (!tenGiga))
iPacket -= 16;
for (int ir=0; ir<ny; ir++) {
for (int ic=0; ic<nx; ic = ic + ic_increment) {
dMap[ir][ic] = iPacket;
iPacket += increment;
iData += increment;
//--------------------32 bit 1giga -------------------
if((dynamicRange == 32) && (!tenGiga)){
if(iData == numbytesperline){
iPacket -= (numbytesperline*2 + 16*3);
iData = 0;
}
if(iData == onepacketdataSize){
iPacket += 16;
}
}//------------end of 32 bit -------------------------
else if((iData % numbytesperline) == 0){
iPacket -= (numbytesperline*2);
if(iData == onepacketdataSize){
iPacket -= 16;
iData = 0;
}
}
//---------------------------------------------------
}
}
}
//Mask
for(int ir=0; ir<ny; ++ir)
for(int ic=0; ic<nx; ++ic)
dMask[ir][ic] = 0x0;
setDataMap(dMap);
setDataMask(dMask);
};
/** Returns the frame number for the given dataset.
\param buff pointer to the dataset
\returns frame number
*/
int getFrameNumber(char *buff){
footer_t = (eiger_packet_footer_t*)(buff + onepacketdataSize + sizeof(eiger_packet_header_t));
return ((uint32_t)(*( (uint64_t*) footer_t)));
};
/** gets the packets number
\param buff pointer to the memory
\returns packet number
*/
int getPacketNumber(char *buff){
footer_t = (eiger_packet_footer_t*)(buff + onepacketdataSize + sizeof(eiger_packet_header_t));
return(*( (uint16_t*) footer_t->packetnum));
};
/**
returns the pixel value as double correcting for the output buffer crosstalk
\param data pointer to the memory
\param ix coordinate in the x direction
\param iy coordinate in the y direction
\returns channel value as double
*/
double getValue(char *data, int ix, int iy=0) {
// cout << "##" << (void*)data << " " << ix << " " <<iy << endl;
if (xtalk==0)
return getChannelwithMissingPackets(data, ix, iy);
else
return getChannelwithMissingPackets(data, ix, iy)-xtalk * getChannelwithMissingPackets(data, ix-1, iy);
};
/**
Returns the value of the selected channel for the given dataset. Virtual function, can be overloaded.
\param data pointer to the dataset (including headers etc)
\param ix pixel number in the x direction
\param iy pixel number in the y direction
\returns data for the selected channel, with inversion if required
*/
virtual int getChannelwithMissingPackets(char *data, int ix, int iy) {
uint32_t m=0, n = 0;
int linesperpacket,newix, newiy,origX;
//cout <<"ix:"<<ix<<" nx:"<<nx<<" iy:"<<iy<<" ny:"<<ny<<" datamap[iy][ix]:"<< dataMap[iy][ix] <<" datasize:"<< dataSize <<endl;
if (ix>=0 && ix<nx && iy>=0 && iy<ny && dataMap[iy][ix]>=0 && dataMap[iy][ix]<dataSize) {
m=dataMask[iy][ix];
//pixelpos1d = (nx * iy + ix);
switch(dynamicRange){
case 4: if(tenGiga) linesperpacket=16; else linesperpacket=4;break;
case 8: if(tenGiga) linesperpacket=8; else linesperpacket=2;break;
case 16: if(tenGiga) linesperpacket=4; else linesperpacket=1;break;
case 32: if(tenGiga) linesperpacket=2; else linesperpacket=1;break;
}
//each byte is shared by 2 pixels for 4 bit mode
origX = ix;
if((dynamicRange == 4) && (ix%2))
ix--;
// ------check if missing packet, get to pixel at start of packet-----------------
//to get the starting of a packet (except 1g 32 bit)
newix = 0;
// 0.5 Lines per packet for 1g 32 bit
if(dynamicRange == 32 && !tenGiga)
newix = ix - (ix%256);
//iy divided by linesperpacket depending on bitmode
if(!(iy%linesperpacket))
newiy = iy;
else
newiy = (iy - (iy%linesperpacket));
header_t = (eiger_packet_header_t*)((char*)(data +(dataMap[newiy][newix]-8)));
uint16_t identifier = (uint16_t)*( (uint16_t*) header_t->missingpacket);
if(identifier==deactivatedPacketValue){
// cprintf(RED,"deactivated packet\n");
return -2;
}
// -----END OF CHECK -------------------------------------------------------------
}else{
cprintf(RED,"outside limits\n");
return -99;
}
//get proper data
n = ((uint32_t)(*((uint32_t*)(((char*)data)+(dataMap[iy][ix])))));
//each byte is shared by 2 pixels for 4 bit mode
if(dynamicRange == 4){
if(ix != origX)
return ((n & 0xf0)>>4)^m;
return (n & 0xf)^m;
}
else if(dynamicRange == 8) return (n & 0xff)^m;
else if(dynamicRange == 16) return (n & 0xffff)^m;
else return (n & 0xffffffff)^m;
};
/** sets the output buffer crosstalk correction parameter
\param c output buffer crosstalk correction parameter to be set
\returns current value for the output buffer crosstalk correction parameter
*/
double setXTalk(double c) {xtalk=c; return xtalk;}
/** gets the output buffer crosstalk parameter
\returns current value for the output buffer crosstalk correction parameter
*/
double getXTalk() {return xtalk;}
void getChannelArray(double* data, char* buffer){
for(int iy = 0; iy < ny; iy++){
for(int ix = 0; ix < nx; ix++){
data[iy*nx+ix] = getValue((char*)buffer,ix,iy);
//cprintf(BLUE,"%d,%d :%f\n",ix,iy,value);
}
}
}
int* decodeData(int *datain) {
int dataBytes = numberofPacketsPerFrame * onepacketdataSize;
int nch = nx*ny;
int* dataout = new int [nch];
char *ptr=(char*)datain;
char iptr;
const int bytesize=8;
int ival=0;
int ipos=0, ichan=0, ibyte;
switch (dynamicRange) {
case 4:
for (ibyte=0; ibyte<dataBytes; ++ibyte) {//for every byte (1 pixel = 1/2 byte)
iptr=ptr[ibyte]&0xff; //???? a byte mask
for (ipos=0; ipos<2; ++ipos) { //loop over the 8bit (twice)
ival=(iptr>>(ipos*4))&0xf; //pick the right 4bit
dataout[ichan]=ival;
ichan++;
}
}
break;
case 8:
for (ichan=0; ichan<dataBytes; ++ichan) {//for every pixel (1 pixel = 1 byte)
ival=ptr[ichan]&0xff; //????? a byte mask
dataout[ichan]=ival;
}
break;
case 16:
for (ichan=0; ichan<nch; ++ichan) { //for every pixel
ival=0;
for (ibyte=0; ibyte<2; ++ibyte) { //for each byte (concatenate 2 bytes to get 16 bit value)
iptr=ptr[ichan*2+ibyte];
ival|=((iptr<<(ibyte*bytesize))&(0xff<<(ibyte*bytesize)));
}
dataout[ichan]=ival;
}
break;
default:
//for every 32 bit (every element in datain array)
for (ichan=0; ichan<nch; ++ichan) { //for every pixel
ival=datain[ichan]&0xffffff;
dataout[ichan]=ival;
}
}
return dataout;
};
int* readNextFrameOnlyData(ifstream &filebin, int& fnum) {
int framesize = numberofPacketsPerFrame * onepacketdataSize;
int* data = new int[framesize/(sizeof(int))];
char *packet=new char[packetSize];
fnum = -1;
int pn=-1;
int dataoffset = 0;
if (filebin.is_open()) {
while (filebin.read(packet,packetSize)) {
fnum = getFrameNumber(packet); //cout << "fn:"<<fn<<endl;
pn = getPacketNumber(packet); //cout << "pn:"<<pn<<endl;
memcpy(((char*)data)+dataoffset,packet+DATA_PACKET_HEADER_SIZE,onepacketdataSize);
dataoffset+=onepacketdataSize;
if(pn == numberofPacketsPerFrame)
break;
}
}
delete [] packet;
if(!dataoffset){
delete [] data;
return NULL;
}
return data;
}
/*
when u get packet form next frames
//to remember the position to read next frame
filebin.seekg (position, filebin.beg);
position = filebin.tellg();
*/
int *readNextFramewithMissingPackets(ifstream &filebin, int& fnum) {
int* data = new int[(numberofPacketsPerFrame * onepacketdataSize)/(sizeof(int))];
char *packet=new char[packetSize];
fnum = -1;
int pnum = 0;
int fn = -1;
int pn =-1;
int dataoffset = 0;
int missingpackets;
if (filebin.is_open()) {
while (filebin.read(packet,packetSize)) {
fn = getFrameNumber(packet); //cout << "fn:"<<fn<<endl;
pn = getPacketNumber(packet); //cout << "pn:"<<pn<<endl;
//first packet
if(fnum == -1){
fnum = fn;
}
//next frame packet
else if (fnum != fn){
//set file reading to the last frame's packet in file
filebin.seekg(-packetSize, ios::cur);//filebin.beg
break;
}
//missing packets
missingpackets = pn - pnum - 1;
if(missingpackets){
memset(((char*)data)+dataoffset,0xFF,missingpackets*onepacketdataSize);
dataoffset+=(missingpackets*onepacketdataSize);
pnum+=missingpackets;
}
memcpy(((char*)data)+dataoffset,packet+DATA_PACKET_HEADER_SIZE,onepacketdataSize);
dataoffset+=onepacketdataSize;
pnum++;
if(pnum == numberofPacketsPerFrame)
break;
}
}
delete [] packet;
if(!pnum){
delete [] data;
return NULL;
}
//missing packets (added here to also catch end of file)
missingpackets = numberofPacketsPerFrame - pnum;
if(missingpackets){
memset(((char*)data)+dataoffset,0xFF,missingpackets*onepacketdataSize);
dataoffset+=(missingpackets*onepacketdataSize);
}
return data;
}
private:
/** Missing Packet identifier value */
const static uint16_t deactivatedPacketValue = 0xFEFE;
const static int DATA_PACKET_HEADER_SIZE = 8;
const bool top;
const bool left;
const int dynamicRange;
const bool tenGiga;
const int packetSize;
const int onepacketdataSize;
const int numberofPacketsPerFrame;
double xtalk; /**<output buffer crosstalk correction parameter */
/** structure of an eiger packet*/
typedef struct{
unsigned char subframenum[4];
unsigned char missingpacket[2];
unsigned char portnum[1];
unsigned char dynamicrange[1];
} eiger_packet_header_t;
typedef struct{
unsigned char framenum[6];
unsigned char packetnum[2];
} eiger_packet_footer_t;
eiger_packet_header_t* header_t;
eiger_packet_footer_t* footer_t;
};
#endif

View File

@ -1,148 +0,0 @@
#ifndef GOTTHARDMODULEDATA_H
#define GOTTHARDMODULEDATA_H
#include "slsReceiverData.h"
#define FRAMEMASK 0xFFFFFFFE
#define PACKETMASK 1
#define FRAMEOFFSET 0x1
class gotthardModuleData : public slsReceiverData<uint16_t> {
public:
/**
Implements the slsReceiverData structure for the gotthard read out by a module i.e. using the slsReceiver
(1x1280 pixels, 2 packets 1286 large etc.)
\param c crosstalk parameter for the output buffer
*/
gotthardModuleData(double c=0): slsReceiverData<uint16_t>(xpixels, ypixels, npackets, buffersize), xtalk(c) {
uint16_t **dMask;
int **dMap;
int ix, iy;
int initial_offset = 2;
int offset = initial_offset;
dMask=new uint16_t*[ypixels];
dMap=new int*[ypixels];
for (int i = 0; i < ypixels; i++) {
dMap[i] = new int[xpixels];
dMask[i] = new uint16_t[xpixels];
}
for(ix=0; ix<ypixels; ++ix)
for(iy=0; iy<xpixels; ++iy)
dMask[ix][iy] = 0x0;
for(ix=0; ix<ypixels; ++ix){
if(ix == (ypixels/2)){
offset += initial_offset;//2
offset++;
}
for(iy=0; iy<xpixels; ++iy){
dMap[ix][iy] = offset;
offset++;
}
}
setDataMap(dMap);
setDataMask(dMask);
};
/**
Returns the frame number for the given dataset.
\param buff pointer to the dataset
\returns frame number
*/
int getFrameNumber(char *buff){
int np=(*(int*)buff);
//gotthards frame header must be incremented
++np;
//packet index should be 1 or 2
return ((np&FRAMEMASK)>>FRAMEOFFSET);
};
/**
gets the packets number (last packet is labelled with 0 and is replaced with 40)
\param buff pointer to the memory
\returns packet number
*/
int getPacketNumber(char *buff){
int np=(*(int*)buff);
//gotthards frame header must be incremented
++np;
//packet index should be 1 or 2
return ((np&PACKETMASK)+1);
};
/**
returns the pixel value as double correcting for the output buffer crosstalk
\param data pointer to the memory
\param ix coordinate in the x direction
\param iy coordinate in the y direction
\returns channel value as double
*/
double getValue(char *data, int ix, int iy=0) {
//check how it is for gotthard
if (xtalk==0)
return slsDetectorData<uint16_t>::getValue(data, ix, iy);
else
return slsDetectorData<uint16_t>::getValue(data, ix, iy)-xtalk*slsDetectorData<uint16_t>::getValue(data, ix-1, iy);
};
/** sets the output buffer crosstalk correction parameter
\param c output buffer crosstalk correction parameter to be set
\returns current value for the output buffer crosstalk correction parameter
*/
double setXTalk(double c) {xtalk=c; return xtalk;}
/** gets the output buffer crosstalk parameter
\returns current value for the output buffer crosstalk correction parameter
*/
double getXTalk() {return xtalk;}
private:
double xtalk; /**<output buffer crosstalk correction parameter */
const static int xpixels = 1280;
const static int ypixels = 1;
const static int npackets = 2;
const static int buffersize = 1286;
};
#endif

View File

@ -1,170 +0,0 @@
#ifndef GOTTHARDMODULEDATANEW_H
#define GOTTHARDMODULEDATANEW_H
#include "slsDetectorData.h"
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 gotthardModuleDataNew : public slsDetectorData<uint16_t> {
private:
int iframe;
const int offset;
public:
/**
Implements the slsReceiverData structure for the gotthard read out by a module i.e. using the slsReceiver
(1x1280 pixels, 2 packets 1286 large etc.)
\param c crosstalk parameter for the output buffer
*/
gotthardModuleDataNew(int off=24*2, int nch=1280): slsDetectorData<uint16_t>(nch, 1, nch*2+off), offset(off) {
uint16_t **dMask;
int **dMap;
int ix, iy;
int ypixels=1;
int xpixels=nch;
dMask=new uint16_t*[1];
dMap=new int*[1];
dMap[0] = new int[nch];
dMask[0] = new uint16_t[nch];
for(int ix=0; ix<xpixels; ix++) {
dMap[0][ix] = 2*ix+offset;
dMask[0][ix] = 0x0;
}
setDataMap(dMap);
setDataMask(dMask);
};
/**
Returns the frame number for the given dataset.
\param buff pointer to the dataset
\returns frame number
*/
int getFrameNumber(char *buff){if (offset>=sizeof(sls_detector_header)) return ((sls_detector_header*)buff)->frameNumber; return iframe;};//*((int*)(buff+5))&0xffffff;};
/**
gets the packets number (last packet is labelled with 0 and is replaced with 40)
\param buff pointer to the memory
\returns packet number
*/
int getPacketNumber(char *buff){if (offset>=sizeof(sls_detector_header))return ((sls_detector_header*)buff)->packetNumber;};
/**
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
\param data pointer to the memory to be analyzed
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
\param dsize size of the memory slot to be analyzed
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
*/
virtual char *findNextFrame(char *data, int &ndata, int dsize){
if (dsize<dataSize) ndata=dsize;
else ndata=dataSize;
return data;
}
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int &ff) {
int np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
char *data=new char[dataSize];
char *d=readNextFrame(filebin, ff, np, data);
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
np=0;
int pn;
// cout << dataSize << endl;
if (ff>=0)
fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, dataSize) ){
ff=getFrameNumber(data);
np=getPacketNumber(data);
return data;
}
}
return NULL;
};
};
#endif

View File

@ -1,156 +0,0 @@
#ifndef JUNGFRAU02DATA_H
#define JUNGFRAU02DATA_H
#include "chiptestBoardData.h"
class jungfrau02Data : public chiptestBoardData {
public:
/* test :) */
/**
Implements the chiptestBoardData structure for the jungfrau02 prototype
(48x48 pixels, ADC2 for analog output, 2 more ADCs used for readout of digital bits, pixel offset configurable.)
\param c crosstalk parameter for the output buffer
*/
jungfrau02Data(int nadc, int offset, double c=0): chiptestBoardData(48, 48, nadc, offset),
xtalk(c) {
uint16_t **dMask;
int **dMap;
dMask=new uint16_t*[48];
dMap=new int*[48];
for (int i = 0; i < 48; i++) {
dMap[i] = new int[48];
dMask[i] = new uint16_t[48];
}
for (int iy=0; iy<48; iy++) {
for (int ix=0; ix<48; ix++) {
dMap[ix][iy]=offset+(iy*48+ix)*nAdc;//dMap[iy][ix]=offset+(iy*48+ix)*nAdc;
// cout << ix << " " << iy << " " << dMap[ix][iy] << endl;
}
}
cout << (0,0) << " " << dMap[0][0] << endl;
cout << (47,47) << " " << dMap[47][47] << endl;
for (int ix=0; ix<48; ix++) {
for (int iy=0; iy<48; iy++)
dMask[iy][ix]=0x0;
setDataMap(dMap);
setDataMask(dMask);
}
};
/**
Returns the value of the selected channel for the given dataset. Since the ADC is only 14bit wide, only bit 0-13 are occupied. If the gain bits are read out, they are returned in bit 14-15.
\param data pointer to the dataset (including headers etc)
\param ix pixel number in the x direction
\param iy pixel number in the y direction
\returns data for the selected channel, with inversion if required
*/
virtual uint16_t getChannel(char *data, int ix, int iy=0) {
uint16_t m=0, d=0;
if (ix>=0 && ix<nx && iy>=0 && iy<ny && dataMap[iy][ix]>=0 && dataMap[iy][ix]<dataSize) {
m=dataMask[iy][ix];
d=*(((uint16_t*)(data))+dataMap[iy][ix]);
// cout << ix << " " << iy << " " << (uint16_t*)data << " " << ((uint16_t*)(data))+dataMap[iy][ix] << " " << d << endl;
if (nAdc==3) {
//cout << "Gain bit!" << endl;
if (*((uint16_t*)(data)+dataMap[iy][ix]+2)>8000) //exchange if gainBits==2 is returned!
d|=(1<<14); // gain bit 1
if (*((uint16_t*)(data)+dataMap[iy][ix]+1)>8000) //exchange if gainBits==2 is returned!
d|=(1<<15); // gain bit 0
}
}
return d^m;
};
/**
returns the pixel value as double correcting for the output buffer crosstalk
\param data pointer to the memory
\param ix coordinate in the x direction
\param iy coordinate in the y direction
\returns channel value as double
*/
double getValue(char *data, int ix, int iy=0) {
// cout << "##" << (void*)data << " " << ix << " " <<iy << endl;
uint16_t d=getChannel(data, ix, iy);
// cout << d << " " << (d&0x3fff) << endl;
if (xtalk==0 || ix==0)
return (double)(getChannel(data, ix, iy)&0x3fff);
else
return (double)(getChannel(data, ix, iy)&0x3fff)-xtalk* (double)(getChannel(data, ix, iy)&0x3fff);
};
/**
returns the gain bit value, i.e. returns 0 if(GB0==0 && GB1==0), returns 1 if(GB0==1 && GB1==0), returns 3 if(GB0==1 && GB1==1), if it returns 2 -> the gain bits are read out the wrong way around (i.e. GB0 and GB1 have to be reversed!)
\param data pointer to the memory
\param ix coordinate in the x direction
\param iy coordinate in the y direction
\returns gain bits as int
*/
int getGainBits(char *data, int ix, int iy=0) {
uint16_t d=getChannel(data, ix, iy);
return ((d&0xc000)>>14);
};
//*/
/** sets the output buffer crosstalk correction parameter
\param c output buffer crosstalk correction parameter to be set
\returns current value for the output buffer crosstalk correction parameter
*/
double setXTalk(double c) {xtalk=c; return xtalk;}
/** gets the output buffer crosstalk parameter
\returns current value for the output buffer crosstalk correction parameter
*/
double getXTalk() {return xtalk;}
private:
double xtalk; /**<output buffer crosstalk correction parameter */
};
#endif

View File

@ -1,155 +0,0 @@
#ifndef JUNGFRAU10MODULEDATA_H
#define JUNGFRAU10MODULEBDATA_H
#include "slsDetectorData.h"
class jungfrau10ModuleData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
int sc_height;
public:
/**
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
(160x160 pixels, 40 packets 1286 large etc.)
\param c crosstalk parameter for the output buffer
*/
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) {
int row, col;
int isample;
int iadc;
int ix, iy;
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;
}
}
}
};
/**
Returns the frame number for the given dataset. Purely virtual func.
\param buff pointer to the dataset
\returns frame number
*/
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
*/
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
*/
char *readNextFrame(ifstream &filebin){
// int afifo_length=0;
uint16_t *afifo_cont;
int ib=0;
if (filebin.is_open()) {
afifo_cont=new uint16_t[dataSize/2];
while (filebin.read(((char*)afifo_cont)+ib,2)) {
ib+=2;
if (ib==dataSize) break;
}
if (ib>0) {
iframe++;
// cout << ib << "-" << endl;
return (char*)afifo_cont;
} else {
delete [] afifo_cont;
return NULL;
}
}
return NULL;
};
};
#endif

View File

@ -1,246 +0,0 @@
#ifndef MOENCH02CTB10GBDATA_H
#define MOENCH02CTB10GBDATA_H
#include <stdio.h>
#include "slsDetectorData.h"
#include "slsReceiverData.h"
class moench02Ctb10GbData : public slsReceiverData<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
*/
moench02Ctb10GbData(int ns=6400): slsReceiverData<uint16_t>(160, 160, 50, 8208) , nadc(4), sc_width(40), sc_height(160) {
int adc_nr[4]={120,0,80,40};
int row, col;
int isample;
int iadc;
int ix, iy;
int i;
int npackets=50;
maplength = 8208*npackets;
//this->setDataSize(maplength);
/* maplength=this->getDataSize()/2; */
for (int ip=0; ip<npackets; ip++) {
for (int is=0; is<128; is++) {
for (iadc=0; iadc<nadc; iadc++) {
i=128*ip+is;
if (i<sc_width*sc_height) {
col=adc_nr[iadc]+(i%sc_width);
row=i/sc_width;
dataMap[row][col]=(32*i+iadc+2)*2+16*(ip+1);
if (dataMap[row][col]<0 || dataMap[row][col]>=8208*npackets) {
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
}
}
int ibyte;
int ii=0;
for (int ipacket=0; ipacket<npackets; ipacket++) {
for (int ibyte=0; ibyte< 8208/2; ibyte++) {
i=ipacket*8208/2+ibyte;
if(ibyte<8){
xmap[i]=-1;
ymap[i]=-1;
}else{
isample=ii/32;
iadc=ii%32;
ix=isample%sc_width;
iy=isample/sc_width;
if(iadc>=2 && iadc<=5){
xmap[i]=adc_nr[iadc-2]+ix;
ymap[i]=iy;
}else{
xmap[i]=-1;
ymap[i]=-1;
}
ii++;
}
}//end loop on bytes
}//end loop on packets
iframe=0;
cout << "data struct created" << endl;
};
void getPixel(int ip, int &x, int &y) {
if(ip>=0 && ip<maplength){
x=xmap[ip];
y=ymap[ip];
}else{
cerr<<"WRONG ARRAY LENGTH"<<endl;
cerr<<"Trying to access the "<<ip<<"-th element"<<endl;
}
};
/**
Returns the frame number for the given dataset. Purely virtual func.
\param buff pointer to the dataset
\returns frame number
*/
int getFrameNumber(char *buff){return *((int*)buff)&0xffffffff;};
/* 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;
*/
int getPacketNumber(char *buff){return ((*(((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, int &np) {
char *data=new char[packetSize*nPackets];
char *retval=0;
int nd;
np=0;
int pn;
char aa[8224]={0};
char *packet=(char *)aa;
int fnum = -1;
if (ff>=0)
fnum=ff;
if (filebin.is_open()) {
cout << "+";
while(filebin.read((char*)packet, 8208)){
pn=getPacketNumber(packet);
if (fnum<0)
fnum= getFrameNumber(packet);
if (fnum>=0) {
if (getFrameNumber(packet) !=fnum) {
if (np==0){
cout << "-";
delete [] data;
return NULL;
} else
filebin.seekg(-8208,ios_base::cur);
return data;
}
memcpy(data+(pn-1)*packetSize, packet, packetSize);
np++;
if (np==nPackets)
break;
if (pn==nPackets)
break;
}
}
}else{
cerr<<filebin<<" not open!!!"<<endl;
return NULL;
}
if (np==0){
cout << "?";
delete [] data;
return NULL;
}// else if (np<nPackets)
// cout << "Frame " << fnum << " lost " << nPackets-np << " packets " << endl;
return data;
};
virtual char *readNextFrame(ifstream &filebin) {
int fnum=-1, np;
return readNextFrame(filebin, fnum, np);
};
};
#endif

View File

@ -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 (iadc=0; iadc<nadc; iadc++) {
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_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;
@ -71,15 +81,15 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
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{
}/*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;

View File

@ -1,137 +0,0 @@
#ifndef MOENCH02MODULEDATA_H
#define MOENCH02MODULEDATA_H
#include "slsReceiverData.h"
class moench02ModuleData : public slsReceiverData<uint16_t> {
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
*/
moench02ModuleData(double c=0): slsReceiverData<uint16_t>(160, 160, 40, 1286),
xtalk(c) {
uint16_t **dMask;
int **dMap;
int ix, iy;
dMask=new uint16_t*[160];
dMap=new int*[160];
for (int i = 0; i < 160; i++) {
dMap[i] = new int[160];
dMask[i] = new uint16_t[160];
}
for (int isc=0; isc<4; isc++) {
for (int ip=0; ip<10; ip++) {
for (int ir=0; ir<16; ir++) {
for (int ic=0; ic<40; ic++) {
ix=isc*40+ic;
iy=ip*16+ir;
dMap[iy][ix]=1286*(isc*10+ip)+2*ir*40+2*ic+4;
// cout << ix << " " << iy << " " << dMap[ix][iy] << endl;
}
}
}
}
for (ix=0; ix<120; ix++) {
for (iy=0; iy<160; iy++)
dMask[iy][ix]=0x3fff;
}
for (ix=120; ix<160; ix++) {
for (iy=0; iy<160; iy++)
dMask[iy][ix]=0x0;
}
setDataMap(dMap);
setDataMask(dMask);
};
/**
gets the packets number (last packet is labelled with 0 and is replaced with 40)
\param buff pointer to the memory
\returns packet number
*/
int getPacketNumber(char *buff){
int np=(*(int*)buff)&0xff;
if (np==0)
np=40;
return np;
};
/**
returns the pixel value as double correcting for the output buffer crosstalk
\param data pointer to the memory
\param ix coordinate in the x direction
\param iy coordinate in the y direction
\returns channel value as double
*/
double getValue(char *data, int ix, int iy=0) {
// cout << "##" << (void*)data << " " << ix << " " <<iy << endl;
if (xtalk==0 || ix%40==0)
return slsDetectorData<uint16_t>::getValue(data, ix, iy);
else
return slsDetectorData<uint16_t>::getValue(data, ix, iy)-xtalk*slsDetectorData<uint16_t>::getValue(data, ix-1, iy);
};
/** sets the output buffer crosstalk correction parameter
\param c output buffer crosstalk correction parameter to be set
\returns current value for the output buffer crosstalk correction parameter
*/
double setXTalk(double c) {xtalk=c; return xtalk;}
/** gets the output buffer crosstalk parameter
\returns current value for the output buffer crosstalk correction parameter
*/
double getXTalk() {return xtalk;}
private:
double xtalk; /**<output buffer crosstalk correction parameter */
};
#endif

View File

@ -1,285 +0,0 @@
#ifndef MOENCH03CTB10GBDATA_H
#define MOENCH03CTB10GBDATA_H
#include "slsReceiverData.h"
class moench03Ctb10GbData : public slsReceiverData<uint16_t> {
protected:
int iframe;
int nadc;
int sc_width;
int sc_height;
public:
/**
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
(160x160 pixels, 40 packets 1286 large etc.)
\param c crosstalk parameter for the output buffer
*/
// moench03Ctb10GbData(int ns=5000): slsDetectorData<uint16_t>(400, 400, 8208*40, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) {
moench03Ctb10GbData(int ns=5000): slsReceiverData<uint16_t>(400, 400, 40, 8208), nadc(32), sc_width(25), sc_height(200) {
int adc_nr[32]={200,225,250,275,300,325,350,375,\
0,25,50,75,100,125,150,175,\
175,150,125,100,75,50,25,0,\
375,350,325,300,275,250,225,200};
int row, col;
int isample;
int iadc;
int ix, iy;
int npackets=40;
int i;
for (int ip=0; ip<npackets; ip++) {
for (int is=0; is<128; is++) {
for (iadc=0; iadc<nadc; iadc++) {
i=128*ip+is;
if (i<sc_width*sc_height) {
// for (int i=0; i<sc_width*sc_height; i++) {
col=adc_nr[iadc]+(i%sc_width);
if (iadc<16) {
row=199-i/sc_width;
} else {
row=200+i/sc_width;
}
dataMap[row][col]=(nadc*i+iadc)*2+16*(ip+1);
if (dataMap[row][col]<0 || dataMap[row][col]>=8208*40)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
}
int ipacket;
int ibyte;
int ii=0;
for (int ipacket=0; ipacket<npackets; ipacket++) {
for (int ibyte=0; ibyte< 8208/2; ibyte++) {
i=ipacket*8208/2+ibyte;
if (ibyte<8) {
//header!
xmap[i]=-1;
ymap[i]=-1;
} else {
// ii=ibyte+128*32*ipacket;
isample=ii/nadc;
iadc=ii%nadc;
ix=isample%sc_width;
iy=isample/sc_width;
if (iadc<(nadc/2)) {
xmap[i]=adc_nr[iadc]+ix;
ymap[i]=ny/2-1-iy;
} else {
xmap[i]=adc_nr[iadc]+ix;
ymap[i]=ny/2+iy;
}
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
*/
int getFrameNumber(char *buff){return *((int*)buff)&0xffffffff;};
/**
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 ((*(((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& fnum, char *data=NULL) {
int dd=0;
if (data==NULL) {
data=new char[packetSize*nPackets];
dd=1;
}
char *retval=0;
int np=0, nd;
fnum = -1;
int pn;
char aa[8224];
char *packet=(char *)aa;
int place;
if (filebin.is_open()) {
place=filebin.tellg();
while(filebin.read((char*)packet, 8208) && np<nPackets){
pn=getPacketNumber(packet);
if (pn==1 && fnum<0)
fnum= getFrameNumber(packet);
// cout <<getFrameNumber(packet)<< " fn: " << fnum << "\t pn: " << pn << " np " << np << endl;
if (fnum>=0) {
if (getFrameNumber(packet) !=fnum) {
cout << "-"<<endl;
filebin.seekg(place);
if (np==0){
if (dd)
delete [] data;
return NULL;
} else {
return data;
}
}
memcpy(data+(pn-1)*packetSize, packet, packetSize);
np++;
if (np==nPackets)
return data;
}
place=filebin.tellg();
}
}
if (np==0){
cout << "-"<<endl;
filebin.seekg(place);
if (dd)
delete [] data;
return NULL;
}
//filebin.seekg(place);
return data;
};
/* virtual char *readNextFrame(ifstream &filebin, int& fnum) { */
/* char *data=new char[packetSize*nPackets]; */
/* char *retval=0; */
/* int np=0, nd; */
/* fnum = -1; */
/* int pn; */
/* char aa[8224]; */
/* char *packet=(char *)aa; */
/* if (filebin.is_open()) { */
/* while(filebin.read((char*)packet, 8208) && np<nPackets){ */
/* pn=getPacketNumber(packet); */
/* if (pn==1 && fnum<0) */
/* fnum= getFrameNumber(packet); */
/* // cout << "fn: " << fnum << "\t pn: " << pn << endl; */
/* if (fnum>=0) { */
/* if (getFrameNumber(packet) !=fnum) { */
/* if (np==0){ */
/* delete [] data; */
/* return NULL; */
/* } else */
/* return data; */
/* } */
/* memcpy(data+(pn-1)*packetSize, packet, packetSize); */
/* np++; */
/* } */
/* } */
/* } */
/* if (np==0){ */
/* delete [] data; */
/* return NULL; */
/* } */
/* }; */
int getPacketNumber(int x, int y) {return dataMap[y][x]/8208;};
};
#endif

View File

@ -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;
@ -72,9 +77,9 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
int row, col;
int isample;
// int isample;
int iadc;
int ix, iy;
// int ix, iy;
int npackets=40;
int i;
@ -94,43 +99,46 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
} else {
row=200+i/sc_width;
}
dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
if (dataMap[row][col]<0 || dataMap[row][col]>=nSamples*2*32)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
dataMap[row*nx+col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
#ifdef HIGHZ
dataMask[row*nx+col]=0x3fff;
#endif
if (dataMap[row*nx+col]<0 || dataMap[row*nx+col]>=nSamples*2*32)
cout << "Error: pointer " << dataMap[row*nx+col] << " out of range "<< endl;
}
}
}
}
int ipacket;
int ibyte;
int ii=0;
for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){
xmap[ibyte]=-1;
ymap[ibyte]=-1;
}
int off=sizeof(sls_detector_header)/2;
for (ipacket=0; ipacket<npackets; ipacket++) {
for (ibyte=0; ibyte< 8192/2; ibyte++) {
i=ipacket*8208/2+ibyte;
isample=ii/nadc;
if (isample<nSamples) {
iadc=ii%nadc;
adc4 = (int)iadc/4;
ix=isample%sc_width;
iy=isample/sc_width;
if (adc4%2==0) {
xmap[i+off]=adc_nr[iadc]+ix;
ymap[i+off]=ny/2-1-iy;
} else {
xmap[i+off]=adc_nr[iadc]+ix;
ymap[i+off]=ny/2+iy;
}
}
ii++;
// }
}
}
// int ipacket;
// int ibyte;
// int ii=0;
// for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){
// xmap[ibyte]=-1;
// ymap[ibyte]=-1;
// }
// int off=sizeof(sls_detector_header)/2;
// for (ipacket=0; ipacket<npackets; ipacket++) {
// for (ibyte=0; ibyte< 8192/2; ibyte++) {
// i=ipacket*8208/2+ibyte;
// isample=ii/nadc;
// if (isample<nSamples) {
// iadc=ii%nadc;
// adc4 = (int)iadc/4;
// ix=isample%sc_width;
// iy=isample/sc_width;
// if (adc4%2==0) {
// xmap[i+off]=adc_nr[iadc]+ix;
// ymap[i+off]=ny/2-1-iy;
// } else {
// xmap[i+off]=adc_nr[iadc]+ix;
// ymap[i+off]=ny/2+iy;
// }
// }
// ii++;
// // }
// }
// }
iframe=0;
// cout << "data struct created" << endl;
@ -232,15 +240,15 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
np=0;
int pn;
//char *retval=0;
// int nd;
//int fnum = -1;
// np=0;
// int pn;
// cout << dataSize << endl;
if (ff>=0)
fnum=ff;
// if (ff>=0)
// fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, dataSize) ){

View File

@ -0,0 +1,324 @@
#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 */
#ifndef VERSION_V1
uint64_t packetCaught[8]; /**< is the version number of this structure format */
#endif
} sls_detector_header;
class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
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

View File

@ -0,0 +1,176 @@
#ifndef MOENCH03T1REORDERED_H
#define MOENCH03T1REORDERED_H
#include "slsDetectorData.h"
class moench03T1ReorderedData : public slsDetectorData<uint16_t> {
private:
public:
/**
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
(160x160 pixels, 40 packets 1286 large etc.)
\param c crosstalk parameter for the output buffer
fwrite(&ff, 8, 1,of);//write detector frame number
fwrite(&ifr, 8, 1,of);//write datset frame number
fwrite(data,2,NX*NY,of);//write reordered data
*/
moench03T1ReorderedData(): slsDetectorData<uint16_t>(400, 400, 2*400*400+2*8) {
for (int iy=0; iy<400; iy++)
for (int ix=0; ix<400; ix++)
dataMap[iy][ix]=2*8+2*(iy*400+ix);
int ibyte;
for (ibyte=0; ibyte<8; ibyte++){
xmap[ibyte]=-1;
ymap[ibyte]=-1;
}
for (ibyte=0; ibyte<400*400; ibyte++){
xmap[ibyte+8]=ibyte%400;
ymap[ibyte+8]=ibyte/400;
}
// cout << "data struct created" << endl;
};
/**
Returns the frame number for the given dataset. Purely virtual func.
\param buff pointer to the dataset
\returns frame number
*/
/* class jfrau_packet_header_t { */
/* public: */
/* unsigned char reserved[4]; */
/* unsigned char packetNumber[1]; */
/* unsigned char frameNumber[3]; */
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff){return *((int*)buff);};
/* /\** */
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
/* \param data pointer to the memory to be analyzed */
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
/* \param dsize size of the memory slot to be analyzed */
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
/* *\/ */
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
/* /\** */
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
/* \param filebin input file stream (binary) */
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
/* *\/ */
/* virtual char *readNextFrame(ifstream &filebin){ */
/* // int afifo_length=0; */
/* uint16_t *afifo_cont; */
/* int ib=0; */
/* if (filebin.is_open()) { */
/* afifo_cont=new uint16_t[dataSize/2]; */
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
/* ib+=2; */
/* if (ib==dataSize) break; */
/* } */
/* if (ib>0) { */
/* iframe++; */
/* // cout << ib << "-" << endl; */
/* return (char*)afifo_cont; */
/* } else { */
/* delete [] afifo_cont; */
/* return NULL; */
/* } */
/* } */
/* return NULL; */
/* }; */
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int &ff) {
int np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
char *data=new char[dataSize];
char *d=readNextFrame(filebin, ff, np, data);
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
np=0;
int pn;
if (ff>=0)
fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, dataSize) ){
ff=getFrameNumber(data);
np=40;
return data;
}
}
return NULL;
};
/**
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
\param data pointer to the memory to be analyzed
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
\param dsize size of the memory slot to be analyzed
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
*/
virtual char *findNextFrame(char *data, int &ndata, int dsize){
if (dsize<dataSize) ndata=dsize;
else ndata=dataSize;
return data;
}
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
};
#endif

View File

@ -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;
@ -37,7 +37,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
0,25,50,75,0,25,50,75};
int row, col;
int isample;
int iadc;
int ix, iy;
@ -60,50 +60,51 @@ 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)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
dataMap[row*nx+col]=(nadc*i+iadc)*2+offset;//+16*(ip+1);
#ifdef HIGHZ
dataMask[row*nx+col]=0x3fff;
#endif
if (dataMap[row*nx+col]<0 || dataMap[row*nx+col]>=dataSize)
cout << "Error: pointer " << dataMap[row*nx+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;
}
}
for (i=0; i< dataSize/2; i++) {
if (i<offset/2) {
//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++;
// }
ii++;
}
}
iframe=0;
// iframe=0;
// cout << "data struct created" << endl;
};
@ -127,7 +128,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;};
/**
@ -203,24 +204,24 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
/* char *retval=0; */
/* int nd; */
/* int fnum = -1; */
np=0;
int pn;
/* int pn; */
if (ff>=0)
fnum=ff;
/* if (ff>=0) */
/* fnum=ff; */
if (filebin.is_open()) {
if (filebin.read(data, 32*2*nSamples) ){
iframe++;
ff=iframe;
// iframe++;
//ff=iframe;
return data;
}
}
return NULL;
return NULL;
@ -249,6 +250,8 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
// virtual int setFrameNumber(int ff){iframe=ff};

View File

@ -1,10 +1,12 @@
#ifndef MOENCH03CTB10GBT1DATA_H
#define MOENCH03CTB10GBT1DATA_H
#include "slsReceiverData.h"
#ifndef MOENCH03T1ZMQNEWRECT_H
#define MOENCH03T1ZMQNEWRECT_H
#include "slsDetectorData.h"
#define VERT 1
class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
private:
@ -12,9 +14,12 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
int nadc;
int sc_width;
int sc_height;
public:
const int nSamples;
const int offset;
public:
/**
@ -23,9 +28,16 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
\param c crosstalk parameter for the output buffer
*/
moench03Ctb10GbT1Data(int ns=5000): slsReceiverData<uint16_t>(400, 400, 40, 8208), nadc(32), sc_width(25), sc_height(200) {
#ifdef HOR
moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(800, 200, ns*2*32), nSamples(ns), offset(sizeof(int)) {
#endif
#ifdef VERT
moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(200, 800, ns*2*32), nSamples(ns), offset(sizeof(int)) {
#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,\
@ -34,13 +46,21 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
int row, col;
int isample;
// int isample;
int iadc;
int ix, iy;
int npackets=40;
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++) {
@ -56,46 +76,67 @@ class moench03Ctb10GbT1Data : public slsReceiverData<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]>=8208*40)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
pix=(nadc*i+iadc)*2+offset;//+16*(ip+1);
if (pix<0 || pix>=nSamples*2*32)
cout << "Error: pointer " << pix << " out of range "<< endl;
ix=col;
iy=row;
//col and row have to do with data sequence
//ix and iy have to do with implant position
#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*nx+ix]=pix;
}
}
}
}
int ipacket;
int ibyte;
int ii=0;
for (int ipacket=0; ipacket<npackets; ipacket++) {
for (int ibyte=0; ibyte< 8208/2; ibyte++) {
i=ipacket*8208/2+ibyte;
if (ibyte<8) {
//header!
xmap[i]=-1;
ymap[i]=-1;
} else {
// ii=ibyte+128*32*ipacket;
isample=ii/nadc;
iadc=ii%nadc;
adc4 = (int)iadc/4;
ix=isample%sc_width;
iy=isample/sc_width;
if (adc4%2==0) {
xmap[i]=adc_nr[iadc]+ix;
ymap[i]=ny/2-1-iy;
} else {
xmap[i]=adc_nr[iadc]+ix;
ymap[i]=ny/2+iy;
}
ii++;
}
}
}
/* 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;
@ -121,7 +162,7 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
int getFrameNumber(char *buff){return *((int*)(buff+5))&0xffffff;};
int getFrameNumber(char *buff){return *((int*)buff);};//*((int*)(buff+5))&0xffffff;};
/**
@ -132,7 +173,7 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
*/
int getPacketNumber(char *buff){return ((*(((int*)(buff+4))))&0xff)+1;};
int getPacketNumber(char *buff){return 0;}//((*(((int*)(buff+4))))&0xff)+1;};
/* /\** */
@ -187,77 +228,63 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
};
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
char *data=new char[packetSize*nPackets];
char *data=new char[32*2*nSamples];
char *d=readNextFrame(filebin, ff, np, data);
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
/* char *retval=0; */
/* int nd; */
/* int fnum = -1; */
np=0;
int pn;
char aa[8224];
char *packet=(char *)aa;
// cout << packetSize*nPackets << endl;
if (ff>=0)
fnum=ff;
/* int pn; */
/* if (ff>=0) */
/* fnum=ff; */
if (filebin.is_open()) {
while(filebin.read((char*)packet, 8208) ){
pn=getPacketNumber(packet);
if (fnum<0)
fnum= getFrameNumber(packet);
// cout << "fn: " << fnum << "\t pn: " << pn << endl;
if (fnum>=0) {
if (getFrameNumber(packet) !=fnum) {
if (np==0){
// delete [] data;
return NULL;
} else
filebin.seekg(-8208,ios_base::cur);
return data;
}
if (pn>nPackets) {
cout << "Bad packet number " << pn << endl;
}
memcpy(data+(pn-1)*packetSize, packet, packetSize);
np++;
if (np==nPackets)
break;
if (pn==nPackets)
break;
}
if (filebin.read(data, 32*2*nSamples) ){
// iframe++;
//ff=iframe;
return data;
}
}
return NULL;
}
if (np==0){
// delete [] data;
return NULL;
}
ff=fnum;
return data;
};
/**
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
\param data pointer to the memory to be analyzed
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
\param dsize size of the memory slot to be analyzed
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
*/
virtual char *findNextFrame(char *data, int &ndata, int dsize){
if (dsize<32*2*nSamples) ndata=dsize;
else ndata=32*2*nSamples;
return data;
}
// virtual int setFrameNumber(int ff){iframe=ff};
@ -268,13 +295,7 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
int getPacketNumber(int x, int y) {return dataMap[y][x]/8208;};
int getPacketNumber(int x, int y) {return 0;};
};
@ -282,3 +303,4 @@ int getPacketNumber(int x, int y) {return dataMap[y][x]/8208;};
#endif

View File

@ -1,285 +0,0 @@
#ifndef MOENCH03TCTB10GBDATA_H
#define MOENCH03TCTB10GBDATA_H
#include "moench03Ctb10GbData.h"
class moench03TCtb10GbData : public moench03Ctb10GbData { //slsReceiverData<uint16_t> {
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
*/
// moench03TCtb10GbData(int ns=5000): slsDetectorData<uint16_t>(400, 400, 8208*40, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) {
moench03TCtb10GbData(int ns=5000): moench03Ctb10GbData(ns) {//slsReceiverData<uint16_t>(400, 400, 40, 8208), nadc(32), sc_width(25), sc_height(200) {
// cout <<"constructor"<< endl;
// nadc=32;
int adc_nr[32]={300,325,350,375,300,325,350,375, \
200,225,250,275,200,225,250,275,\
100,125,150,175,100,125,150,175,\
0,25,50,75,0,25,50,75};
int row, col;
int isample;
int iadc;
int ix, iy;
int npackets=40;
int i;
int adc4(0);
for (int ip=0; ip<npackets; ip++) {
for (int is=0; is<128; is++) {
for (iadc=0; iadc<nadc; iadc++) {
i=128*ip+is;
//cout << i << endl;
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) {
// if (iadc<(nadc/2)) {
row=199-i/sc_width;
} else {
row=200+i/sc_width;
}
dataMap[row][col]=(nadc*i+iadc)*2+16*(ip+1);
if (dataMap[row][col]<0 || dataMap[row][col]>=8208*40)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
}
// cout <<"map"<< endl;
int ipacket;
int ibyte;
int ii=0;
for (int ipacket=0; ipacket<npackets; ipacket++) {
for (int ibyte=0; ibyte< 8208/2; ibyte++) {
i=ipacket*8208/2+ibyte;
// cout << i << " ";
if (ibyte<8) {
//header!
xmap[i]=-1;
ymap[i]=-1;
} else {
// ii=ibyte+128*32*ipacket;
// cout << nadc << endl;
isample=ii/nadc;
iadc=ii%nadc;
adc4 = (int)iadc/4;
ix=isample%sc_width;
iy=isample/sc_width;
// cout << isample << " " << iadc << " " << ix << " " << iy ;//<< endl;
if (adc4%2==0) {//iadc<(nadc/2)) {
//if (iadc<(nadc/2)) {
xmap[i]=adc_nr[iadc]+ix;
ymap[i]=ny/2-1-iy;
} else {
xmap[i]=adc_nr[iadc]+ix;
ymap[i]=ny/2+iy;
}
ii++;
}
}
}
/* int ipacket; */
/* int ibyte; */
/* int ii=0; */
/* for (int ipacket=0; ipacket<npackets; ipacket++) { */
/* for (int ibyte=0; ibyte< 8208/2; ibyte++) { */
/* i=ipacket*8208/2+ibyte; */
/* cout << i << endl; */
/* if (ibyte<8) { */
/* //header! */
/* xmap[i]=-1; */
/* ymap[i]=-1; */
/* } else { */
/* ii=ibyte+128*32*ipacket; */
/* isample=ii/nadc; */
/* iadc=ii%nadc; */
/* adc4 = (int)iadc/4; */
/* ix=isample%sc_width; */
/* iy=isample/sc_width; */
/* if (adc4%2==0) { */
/* xmap[i]=adc_nr[iadc]+ix; */
/* ymap[i]=ny/2-1-iy; */
/* } else { */
/* xmap[i]=adc_nr[iadc]+ix; */
/* ymap[i]=ny/2+iy; */
/* } */
/* ii++; */
/* } */
/* } */
/* } */
// cout <<"done"<< endl;
iframe=0;
// cout << "data struct created" << endl;
};
/* /\** */
/* Returns the frame number for the given dataset. Purely virtual func. */
/* \param buff pointer to the dataset */
/* \returns frame number */
/* *\/ */
/* int getFrameNumber(char *buff){return *((int*)buff)&0xffffffff;}; */
/* /\** */
/* 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 ((*(((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, int &np) { */
/* char *data=new char[packetSize*nPackets]; */
/* char *retval=0; */
/* int nd; */
/* np=0; */
/* int pn; */
/* char aa[8224]={0}; */
/* char *packet=(char *)aa; */
/* int fnum = -1; */
/* if (ff>=0) */
/* fnum=ff; */
/* if (filebin.is_open()) { */
/* cout << "+"; */
/* while(filebin.read((char*)packet, 8208)){ */
/* pn=getPacketNumber(packet); */
/* if (fnum<0) */
/* fnum= getFrameNumber(packet); */
/* if (fnum>=0) { */
/* if (getFrameNumber(packet) !=fnum) { */
/* if (np==0){ */
/* cout << "-"; */
/* delete [] data; */
/* return NULL; */
/* } else */
/* filebin.seekg(-8208,ios_base::cur); */
/* return data; */
/* } */
/* memcpy(data+(pn-1)*packetSize, packet, packetSize); */
/* np++; */
/* if (np==nPackets) */
/* break; */
/* if (pn==nPackets) */
/* break; */
/* } */
/* } */
/* } */
/* if (np==0){ */
/* cout << "?"; */
/* delete [] data; */
/* return NULL; */
/* }// else if (np<nPackets) */
/* // cout << "Frame " << fnum << " lost " << nPackets-np << " packets " << endl; */
/* return data; */
/* }; */
/* int getPacketNumber(int x, int y) {return dataMap[y][x]/8208;}; */
/* virtual char *readNextFrame(ifstream &filebin) { */
/* int fnum=-1, np; */
/* return readNextFrame(filebin, fnum, np); */
/* }; */
};
#endif

View File

@ -0,0 +1,294 @@
#ifndef MOENCH04REC10GBDATA_H
#define MOENCH04REC10GBDATA_H
#include "slsDetectorData.h"
//#define VERSION_V2
/**
@short structure for a Detector Packet or Image Header
@li frameNumber is the frame number
@li expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
@li packetNumber is the packet number
@li bunchId is the bunch id from beamline
@li timestamp is the time stamp with 10 MHz clock
@li modId is the unique module id (unique even for left, right, top, bottom)
@li xCoord is the x coordinate in the complete detector system
@li yCoord is the y coordinate in the complete detector system
@li zCoord is the z coordinate in the complete detector system
@li debug is for debugging purposes
@li roundRNumber is the round robin set number
@li detType is the detector type see :: detectorType
@li version is the version number of this structure format
*/
typedef struct {
uint64_t frameNumber; /**< is the frame number */
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
uint32_t packetNumber; /**< is the packet number */
uint64_t bunchId; /**< is the bunch id from beamline */
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
uint32_t debug; /**< is for debugging purposes */
uint16_t roundRNumber; /**< is the round robin set number */
uint8_t detType; /**< is the detector type see :: detectorType */
uint8_t version; /**< is the version number of this structure format */
uint64_t packetCaught[8]; /**< is the version number of this structure format */
} sls_detector_header;
class moench04CtbReceiver10GbData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
int sc_height;
const int aSamples;
const int dSamples;
public:
/**
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
(160x160 pixels, 40 packets 1286 large etc.)
\param c crosstalk parameter for the output buffer
*/
moench04CtbReceiver10GbData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+sizeof(sls_detector_header)+nds*8), aSamples(nas), dSamples(nds) {
int nadc=32;
int sc_width=25;
int sc_height=200;
int adc_nr[32]={9, 8,11,10,13,12,15,14,1,0,3,2,5,4,7,6,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24 };
int row, col;
int isample;
int iadc;
int ix, iy;
int npackets=40;
int i;
int adc4(0);
for (int ip=0; ip<npackets; ip++) {
for (int is=0; is<128; is++) {
for (iadc=0; iadc<nadc; iadc++) {
i=128*ip+is;
adc4=(int)iadc/4;
if (i<sc_width*sc_height) {
// for (int i=0; i<sc_width*sc_height; i++) {
col=(adc_nr[iadc]%16)*sc_width+(i%sc_width);
// if (adc4%2==0) {
if (iadc/16>0) {
row=199-i/sc_width;
} else {
row=200+i/sc_width;
}
if (nds>0)
dataMap[row][col]=sizeof(sls_detector_header)+((nadc+4)*i+iadc)*2;//+16*(ip+1);
else
dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
}
int ipacket;
int ibyte;
int ii=0;
for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){
xmap[ibyte]=-1;
ymap[ibyte]=-1;
}
/* int off=sizeof(sls_detector_header)/2; */
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
/* i=ipacket*8208/2+ibyte; */
/* isample=ii/nadc; */
/* if (isample<nSamples) { */
/* iadc=ii%nadc; */
/* adc4 = (int)iadc/4; */
/* ix=isample%sc_width; */
/* iy=isample/sc_width; */
/* if (adc4%2==0) { */
/* xmap[i+off]=adc_nr[iadc]+ix; */
/* ymap[i+off]=ny/2-1-iy; */
/* } else { */
/* xmap[i+off]=adc_nr[iadc]+ix; */
/* ymap[i+off]=ny/2+iy; */
/* } */
/* } */
/* ii++; */
/* // } */
/* } */
/* } */
iframe=0;
// cout << "data struct created" << endl;
};
/**
Returns the frame number for the given dataset. Purely virtual func.
\param buff pointer to the dataset
\returns frame number
*/
/* class jfrau_packet_header_t { */
/* public: */
/* unsigned char reserved[4]; */
/* unsigned char packetNumber[1]; */
/* unsigned char frameNumber[3]; */
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff){return ((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
/**
Returns the packet number for the given dataset. purely virtual func
\param buff pointer to the dataset
\returns packet number number
*/
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

View File

@ -1,7 +1,8 @@
#ifndef MOENCH03T1ZMQDATA_H
#define MOENCH03T1ZMQDATA_H
#ifndef MOENCH04RECDATA_H
#define MOENCH04RECDATA_H
#include "slsDetectorData.h"
//#define VERSION_V2
/**
@short structure for a Detector Packet or Image Header
@li frameNumber is the frame number
@ -32,12 +33,14 @@
uint16_t roundRNumber; /**< is the round robin set number */
uint8_t detType; /**< is the detector type see :: detectorType */
uint8_t version; /**< is the version number of this structure format */
uint64_t packetCaught[8]; /**< is the version number of this structure format */
} sls_detector_header;
class moench03T1ReceiverData : public slsDetectorData<uint16_t> {
class moench04CtbReceiverData : public slsDetectorData<uint16_t> {
private:
@ -45,8 +48,8 @@ class moench03T1ReceiverData : public slsDetectorData<uint16_t> {
int nadc;
int sc_width;
int sc_height;
const int nPackets; /**<number of UDP packets constituting one frame */
const int packetSize; /**< size of a udp packet */
const int aSamples;
const int dSamples;
public:
@ -60,16 +63,13 @@ class moench03T1ReceiverData : public slsDetectorData<uint16_t> {
\param c crosstalk parameter for the output buffer
*/
moench03T1ReceiverData(int npackets=40, int ps=8192): slsDetectorData<uint16_t>(400, 400, ps*npackets+sizeof(sls_detector_header)), packetSize(ps), nPackets(npackets) {
moench04CtbReceiverData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+sizeof(sls_detector_header)+nds*8), aSamples(nas), dSamples(nds) {
int nadc=32;
int sc_width=25;
int sc_height=200;
int adc_nr[32]={300,325,350,375,300,325,350,375, \
200,225,250,275,200,225,250,275,\
100,125,150,175,100,125,150,175,\
0,25,50,75,0,25,50,75};
int adc_nr[32]={9, 8,11,10,13,12,15,14,1,0,3,2,5,4,7,6,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24 };
int row, col;
@ -77,7 +77,7 @@ class moench03T1ReceiverData : public slsDetectorData<uint16_t> {
int iadc;
int ix, iy;
// int npackets=40;
int npackets=40;
int i;
int adc4(0);
@ -89,14 +89,15 @@ class moench03T1ReceiverData : public slsDetectorData<uint16_t> {
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) {
col=(adc_nr[iadc]%16)*sc_width+(i%sc_width);
// if (adc4%2==0) {
if (iadc/16>0) {
row=199-i/sc_width;
} else {
row=200+i/sc_width;
}
dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
if (dataMap[row][col]<0 || dataMap[row][col]>=8192*40)
if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
@ -110,27 +111,32 @@ class moench03T1ReceiverData : public slsDetectorData<uint16_t> {
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;
iadc=ii%nadc;
adc4 = (int)iadc/4;
ix=isample%sc_width;
iy=isample/sc_width;
if (adc4%2==0) {
xmap[i+off]=adc_nr[iadc]+ix;
ymap[i+off]=ny/2-1-iy;
} else {
xmap[i+off]=adc_nr[iadc]+ix;
ymap[i+off]=ny/2+iy;
}
ii++;
// }
}
}
/* int off=sizeof(sls_detector_header)/2; */
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
/* i=ipacket*8208/2+ibyte; */
/* isample=ii/nadc; */
/* if (isample<nSamples) { */
/* iadc=ii%nadc; */
/* adc4 = (int)iadc/4; */
/* ix=isample%sc_width; */
/* iy=isample/sc_width; */
/* if (adc4%2==0) { */
/* xmap[i+off]=adc_nr[iadc]+ix; */
/* ymap[i+off]=ny/2-1-iy; */
/* } else { */
/* xmap[i+off]=adc_nr[iadc]+ix; */
/* ymap[i+off]=ny/2+iy; */
/* } */
/* } */
/* ii++; */
/* // } */
/* } */
/* } */
iframe=0;
// cout << "data struct created" << endl;
@ -167,7 +173,7 @@ class moench03T1ReceiverData : public slsDetectorData<uint16_t> {
*/
int getPacketNumber(char *buff){((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
/* /\** */
@ -275,7 +281,7 @@ class moench03T1ReceiverData : public slsDetectorData<uint16_t> {
int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
};

View File

@ -0,0 +1,290 @@
#ifndef MOENCH04ZMQ10GBDATA_H
#define MOENCH04ZMQ10GBDATA_H
#include "slsDetectorData.h"
class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
int sc_height;
const int aSamples;
const int dSamples;
public:
/**
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
(160x160 pixels, 40 packets 1286 large etc.)
\param c crosstalk parameter for the output buffer
*/
//moench04CtbZmq10GbData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+nds*8), aSamples(nas), dSamples(nds), nadc(32), sc_width(25), sc_height(200) {
moench04CtbZmq10GbData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, (nas > 0) && (nds>0) ? max(nas,nds)*(32*2+8) : nas*32*2+nds*8), nadc(32), sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) {
/* int ds; */
/* if (nas && nds) */
/* if (nds>nas) */
/* ds=nds*(32*2+8); */
/* else */
/* ds=nas*(32*2+8); */
/* else */
/* ds=nas*32*2+nds*8; */
/* new slsDetectorData<uint16_t>(400, 400, ds); */
int adc_nr[32]={9, 8,11,10,13,12,15,14,1,0,3,2,5,4,7,6,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24 };
int row, col;
//int isample;
int iadc;
// int ix, iy;
// int npackets=40;
int i;
//int adc4(0);
for (int is=0; is<aSamples; is++) {
for (iadc=0; iadc<nadc; iadc++) {
i=is;
// adc4=(int)iadc/4;
if (i<sc_width*sc_height) {
// for (int i=0; i<sc_width*sc_height; i++) {
col=(adc_nr[iadc]%16)*sc_width+(i%sc_width);
// if (adc4%2==0) {
if (iadc<16) {
row=199-i/sc_width;
} else {
row=200+i/sc_width;
}
if (nds>0)
dataMap[row][col]=((nadc+4)*i+iadc)*2;//+16*(ip+1);
else
dataMap[row][col]=(nadc*i+iadc)*2;//+16*(ip+1);
if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
/* for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){ */
/* xmap[ibyte]=-1; */
/* ymap[ibyte]=-1; */
/* } */
/* int off=sizeof(sls_detector_header)/2; */
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
/* i=ipacket*8208/2+ibyte; */
/* isample=ii/nadc; */
/* if (isample<nSamples) { */
/* iadc=ii%nadc; */
/* adc4 = (int)iadc/4; */
/* ix=isample%sc_width; */
/* iy=isample/sc_width; */
/* if (adc4%2==0) { */
/* xmap[i+off]=adc_nr[iadc]+ix; */
/* ymap[i+off]=ny/2-1-iy; */
/* } else { */
/* xmap[i+off]=adc_nr[iadc]+ix; */
/* ymap[i+off]=ny/2+iy; */
/* } */
/* } */
/* ii++; */
/* // } */
/* } */
/* } */
iframe=0;
// cout << "data struct created" << endl;
}
int getGain(char *data, int x, int y) {
// int aoff=aSamples*2*32;
int irow;
int isc=x/sc_width;
int icol=x%sc_width;
if (y<200) irow=sc_height-1-y;
else {
irow=y-sc_height;
isc++;
}
int ibit[32]={-1,-1,-1,-1,-1,-1,1,3,5,7,-1,-1,-1,-1,-1,-1,62,60,58,56,54,52,50,48,63,61,59,57,55,53,51,49};
int isample=irow*sc_width+icol;
uint64_t sample;
char *ptr;
if (isc<0 || isc>=32) return 0;
if (ibit[isc]<0 || ibit[isc]>=64) return 0;
if (dSamples>isample) {
ptr=data+32*(isample+1)+8*isample;
sample=*((uint64_t*)ptr);
cout << isc << " " << ibit[isc] << " " << isample << hex << sample << dec << endl;
if (sample & (1<<ibit[isc]))
return 1;
else
return 0;
} else
return 0;
}
/**
Returns the frame number for the given dataset. Purely virtual func.
\param buff pointer to the dataset
\returns frame number
*/
/* class jfrau_packet_header_t { */
/* public: */
/* unsigned char reserved[4]; */
/* unsigned char packetNumber[1]; */
/* unsigned char frameNumber[3]; */
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff){return iframe;};//((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
/**
Returns the packet number for the given dataset. purely virtual func
\param buff pointer to the dataset
\returns packet number number
*/
//int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
/* /\** */
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
/* \param data pointer to the memory to be analyzed */
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
/* \param dsize size of the memory slot to be analyzed */
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
/* *\/ */
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
/* /\** */
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
/* \param filebin input file stream (binary) */
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
/* *\/ */
/* virtual char *readNextFrame(ifstream &filebin){ */
/* // int afifo_length=0; */
/* uint16_t *afifo_cont; */
/* int ib=0; */
/* if (filebin.is_open()) { */
/* afifo_cont=new uint16_t[dataSize/2]; */
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
/* ib+=2; */
/* if (ib==dataSize) break; */
/* } */
/* if (ib>0) { */
/* iframe++; */
/* // cout << ib << "-" << endl; */
/* return (char*)afifo_cont; */
/* } else { */
/* delete [] afifo_cont; */
/* return NULL; */
/* } */
/* } */
/* return NULL; */
/* }; */
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int &ff) {
int np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
char *data=new char[dataSize];
char *d=readNextFrame(filebin, ff, np, data);
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
// char *retval=0;
// int nd;
// int fnum = -1;
np=0;
//int pn;
// cout << dataSize << endl;
if (ff>=0)
// fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, dataSize) ){
ff=getFrameNumber(data);
// np=getPacketNumber(data);
return data;
}
}
return NULL;
};
/**
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

View File

@ -0,0 +1,276 @@
#ifndef MOENCH04ZMQDATA_H
#define MOENCH04ZMQDATA_H
#include "slsDetectorData.h"
class moench04CtbZmqData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
int sc_height;
const int aSamples;
const int dSamples;
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
*/
moench04CtbZmqData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+nds*8), nadc(32), sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) {
int adc_nr[32]={9, 8,11,10,13,12,15,14,1,0,3,2,5,4,7,6,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24 };
int row, col;
//int isample;
int iadc;
//int ix, iy;
// int npackets=40;
int i;
//int adc4(0);
for (int is=0; is<aSamples; is++) {
for (iadc=0; iadc<nadc; iadc++) {
i=is;
// adc4=(int)iadc/4;
if (i<sc_width*sc_height) {
// for (int i=0; i<sc_width*sc_height; i++) {
col=(adc_nr[iadc]%16)*sc_width+(i%sc_width);
// if (adc4%2==0) {
if (iadc<16) {
row=199-i/sc_width;
} else {
row=200+i/sc_width;
}
dataMap[row][col]=(nadc*i+iadc)*2;//+16*(ip+1);
if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
/* for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){ */
/* xmap[ibyte]=-1; */
/* ymap[ibyte]=-1; */
/* } */
/* int off=sizeof(sls_detector_header)/2; */
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
/* i=ipacket*8208/2+ibyte; */
/* isample=ii/nadc; */
/* if (isample<nSamples) { */
/* iadc=ii%nadc; */
/* adc4 = (int)iadc/4; */
/* ix=isample%sc_width; */
/* iy=isample/sc_width; */
/* if (adc4%2==0) { */
/* xmap[i+off]=adc_nr[iadc]+ix; */
/* ymap[i+off]=ny/2-1-iy; */
/* } else { */
/* xmap[i+off]=adc_nr[iadc]+ix; */
/* ymap[i+off]=ny/2+iy; */
/* } */
/* } */
/* ii++; */
/* // } */
/* } */
/* } */
iframe=0;
// cout << "data struct created" << endl;
}
int getGain(char *data, int x, int y) {
int aoff=aSamples*2*32;
int irow;
int isc=x/sc_width;
int icol=x%sc_width;
if (y<200) irow=sc_height-1-y;
else {
irow=y-sc_height;
isc++;
}
int ibit[32]={-1,-1,-1,-1,-1,-1,1,3,5,7,-1,-1,-1,-1,-1,-1,62,60,58,56,54,52,50,48,63,61,59,57,55,53,51,49};
int isample=irow*sc_width+icol;
uint64_t sample;
char *ptr;
if (isc<0 || isc>=32) return 0;
if (ibit[isc]<0 || ibit[isc]>=64) return 0;
if (dSamples>isample) {
ptr=data+aoff+8*isample;
sample=*((uint64_t*)ptr);
cout << isc << " " << ibit[isc] << " " << isample << hex << sample << dec << endl;
if (sample & (1<<ibit[isc]))
return 1;
else
return 0;
} else
return 0;
}
/**
Returns the frame number for the given dataset. Purely virtual func.
\param buff pointer to the dataset
\returns frame number
*/
/* class jfrau_packet_header_t { */
/* public: */
/* unsigned char reserved[4]; */
/* unsigned char packetNumber[1]; */
/* unsigned char frameNumber[3]; */
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff){return iframe;};//((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
/**
Returns the packet number for the given dataset. purely virtual func
\param buff pointer to the dataset
\returns packet number number
*/
//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

View File

@ -15,9 +15,9 @@ class slsDetectorData {
const int nx; /**< Number of pixels in the x direction */
const int ny; /**< Number of pixels in the y direction */
int dataSize; /**<size of the data constituting one frame */
int **dataMap; /**< Array of size nx*ny storing the pointers to the data in the dataset (as offset)*/
dataType **dataMask; /**< Array of size nx*ny storing the polarity of the data in the dataset (should be 0 if no inversion is required, 0xffffffff is inversion is required) */
int **dataROIMask; /**< Array of size nx*ny 1 if channel is good (or in the ROI), 0 if bad channel (or out of ROI) */
int *dataMap; /**< Array of size nx*ny storing the pointers to the data in the dataset (as offset)*/
dataType *dataMask; /**< Array of size nx*ny storing the polarity of the data in the dataset (should be 0 if no inversion is required, 0xffffffff is inversion is required) */
int *dataROIMask; /**< Array of size nx*ny 1 if channel is good (or in the ROI), 0 if bad channel (or out of ROI) */
int *xmap;
int *ymap;
@ -37,35 +37,25 @@ class slsDetectorData {
\param dROI Array of size nx*ny. The elements are 1s if the channel is good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
*/
slsDetectorData(int npx, int npy, int dsize, int **dMap=NULL, dataType **dMask=NULL, int **dROI=NULL): nx(npx), ny(npy), dataSize(dsize) {
slsDetectorData(int npx, int npy, int dsize, int *dMap=NULL, dataType *dMask=NULL, int *dROI=NULL): nx(npx), ny(npy), dataSize(dsize) {
xmap=new int[dsize/sizeof(dataType)];
ymap=new int[dsize/sizeof(dataType)];
int el=dsize/sizeof(dataType);
xmap=new int[el];
ymap=new int[el];
// if (dataMask==NULL) {
dataMask=new dataType*[ny];
for(int i = 0; i < ny; i++) {
dataMask[i] = new dataType[nx];
}
dataMask=new dataType[ny*nx];
// }
// if (dataMap==NULL) {
dataMap=new int*[ny];
for(int i = 0; i < ny; i++) {
dataMap[i] = new int[nx];
}
dataMap=new int[ny*nx];
// }
// if (dataROIMask==NULL) {
dataROIMask=new int*[ny];
for(int i = 0; i < ny; i++) {
dataROIMask[i] = new int[nx];
for (int j=0; j<nx; j++)
dataROIMask[i][j]=1;
}
dataROIMask=new int [ny*nx];
// }
for (int ip=0; ip<dsize/sizeof(dataType); ip++){
for (int ip=0; ip<el; ip++){
xmap[ip]=-1;
ymap[ip]=-1;
}
@ -77,11 +67,6 @@ class slsDetectorData {
};
virtual ~slsDetectorData() {
for(int i = 0; i < ny; i++) {
delete [] dataMap[i];
delete [] dataMask[i];
delete [] dataROIMask[i];
}
delete [] dataMap;
delete [] dataMask;
delete [] dataROIMask;
@ -94,14 +79,14 @@ class slsDetectorData {
defines the data map (as offset) - no error checking if datasize and offsets are compatible!
\param dMap array of size nx*ny storing the pointers to the data in the dataset (as offset). If NULL (default),the data are arranged as if read out row by row (dataMap[iy][ix]=(iy*nx+ix)*sizeof(dataType);)
*/
void setDataMap(int **dMap=NULL) {
void setDataMap(int *dMap=NULL) {
int ip=0;
int ix, iy;
if (dMap==NULL) {
for (iy=0; iy<ny; iy++) {
for (ix=0; ix<nx; ix++) {
dataMap[iy][ix]=(iy*nx+ix)*sizeof(dataType);
dataMap[iy*nx+ix]=(iy*nx+ix)*sizeof(dataType);
}
}
} else {
@ -109,7 +94,7 @@ class slsDetectorData {
for (iy=0; iy<ny; iy++){
// cout << iy << endl;
for (ix=0; ix<nx; ix++) {
dataMap[iy][ix]=dMap[iy][ix];
dataMap[iy*nx+ix]=dMap[iy*nx+ix];
// cout << ix << " " << iy << endl;
/*ip=dataMap[ix][iy]/sizeof(dataType);
xmap[ip]=ix;
@ -119,7 +104,7 @@ class slsDetectorData {
}
for (iy=0; iy<ny; iy++){
for (ix=0; ix<nx; ix++) {
ip=dataMap[iy][ix]/sizeof(dataType);
ip=dataMap[iy*nx+ix]/sizeof(dataType);
xmap[ip]=ix;
ymap[ip]=iy;
}
@ -135,17 +120,17 @@ class slsDetectorData {
\param dMask Array of size nx*ny storing the polarity of the data in the dataset (should be 0 if no inversion is required, 0xffffffff is inversion is required)
*/
void setDataMask(dataType **dMask=NULL){
void setDataMask(dataType *dMask=NULL){
if (dMask!=NULL) {
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++)
dataMask[iy][ix]=dMask[iy][ix];
dataMask[iy*nx+ix]=dMask[iy*nx+ix];
} else {
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++)
dataMask[iy][ix]=0;
dataMask[iy*nx+ix]=0;
}
};
/**
@ -153,18 +138,18 @@ class slsDetectorData {
\param dROI Array of size nx*ny. The lements are 1s if the channel is good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
*/
void setDataROIMask(int **dROI=NULL){
void setDataROIMask(int *dROI=NULL){
if (dROI!=NULL) {
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++)
dataROIMask[iy][ix]=dROI[iy][ix];
dataROIMask[iy*nx+ix]=dROI[iy*nx+ix];
} else {
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++)
dataROIMask[iy][ix]=1;
dataROIMask[iy*nx+ix]=1;
}
@ -178,14 +163,14 @@ class slsDetectorData {
\param i 1 if pixel is good (or in the roi), 0 if bad
\returns 1 if pixel is good, 0 if it's bad, -1 if pixel is out of range
*/
int setGood(int ix, int iy, int i=1) { if (ix>=0 && ix<nx && iy>=0 && iy<ny) dataROIMask[iy][ix]=i; return isGood(ix,iy);};
int setGood(int ix, int iy, int i=1) { if (ix>=0 && ix<nx && iy>=0 && iy<ny) dataROIMask[iy*nx+ix]=i; return isGood(ix,iy);};
/**
Define bad channel or roi mask for a single channel
\param ix channel x coordinate
\param iy channel y coordinate (1 for strips)
\returns 1 if pixel is good, 0 if it's bad, -1 if pixel is out of range
*/
int isGood(int ix, int iy) { if (ix>=0 && ix<nx && iy>=0 && iy<ny) return dataROIMask[iy][ix]; else return -1;};
int isGood(int ix, int iy) { if (ix>=0 && ix<nx && iy>=0 && iy<ny) return dataROIMask[iy*nx+ix]; else return -1;};
/**
Returns detector size in x,y
@ -204,38 +189,33 @@ class slsDetectorData {
virtual void getPixel(int ip, int &x, int &y) {x=xmap[ip]; y=ymap[ip];};
virtual dataType **getData(char *ptr, int dsize=-1) {
dataType **data;
virtual dataType *getData(char *ptr, int dsize=-1) {
int el=dsize/sizeof(dataType);
dataType *data;
int ix,iy;
data=new dataType*[ny];
for(int i = 0; i < ny; i++) {
data[i]=new dataType[nx];
}
data=new dataType[ny*nx];
if (dsize<=0 || dsize>dataSize) dsize=dataSize;
for (int ip=0; ip<(dsize/sizeof(dataType)); ip++) {
for (int ip=0; ip<(el); ip++) {
getPixel(ip,ix,iy);
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
data[iy][ix]=getChannel(ptr,ix,iy);
data[iy*nx+ix]=getChannel(ptr,ix,iy);
}
}
return data;
};
virtual double **getImage(char *ptr, int dsize=-1) {
virtual double *getImage(char *ptr, int dsize=-1) {
double **data;
double *data;
int ix,iy;
data=new double*[ny];
for(int i = 0; i < ny; i++) {
data[i]=new double[nx];
}
data=new double[ny*nx];
int el=dsize/sizeof(dataType);
if (dsize<=0 || dsize>dataSize) dsize=dataSize;
for (int ip=0; ip<(dsize/sizeof(dataType)); ip++) {
for (int ip=0; ip<el; ip++) {
getPixel(ip,ix,iy);
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
data[iy][ix]=getValue(ptr,ix,iy);
data[iy*nx+ix]=getValue(ptr,ix,iy);
}
}
return data;
@ -251,16 +231,19 @@ class slsDetectorData {
*/
virtual dataType getChannel(char *data, int ix, int iy=0) {
dataType m=0, d=0;
if (ix>=0 && ix<nx && iy>=0 && iy<ny && dataMap[iy][ix]>=0 && dataMap[iy][ix]<dataSize) {
dataType m=0, d=0, *p;
if (ix>=0 && ix<nx && iy>=0 && iy<ny && dataMap[iy*nx+ix]>=0 && dataMap[iy*nx+ix]<dataSize) {
// cout << ix << " " << iy << " " ;
//cout << dataMap[ix][iy] << " " << (void*)data << " " << dataSize<< endl;
m=dataMask[iy][ix];
d=*((dataType*)(data+dataMap[iy][ix]));
m=dataMask[iy*nx+ix];
p=(dataType*)(data+dataMap[iy*nx+ix]);
d=*p;
}
return d^m;
};
virtual int getGain(char *data, int ix, int iy=0){return 0;};
/**
Returns the value of the selected channel for the given dataset. Virtual function, can be overloaded.
@ -331,8 +314,6 @@ class slsDetectorData {
*/
virtual char *readNextFrame(ifstream &filebin)=0;
};

View File

@ -1,534 +0,0 @@
#include "energyCalibration.h"
#ifdef __CINT
#define MYROOT
#endif
#ifdef MYROOT
#include <TMath.h>
#include <TH1F.h>
#include <TH2F.h>
#include <TGraphErrors.h>
#endif
#include <iostream>
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))
#define ELEM_SWAP(a,b) { register int t=(a);(a)=(b);(b)=t; }
using namespace std;
#ifdef MYROOT
Double_t energyCalibrationFunctions::pedestal(Double_t *x, Double_t *par) {
return par[0]-par[1]*sign*x[0];
}
Double_t energyCalibrationFunctions::gaussChargeSharing(Double_t *x, Double_t *par) {
Double_t f, arg=0;
if (par[3]!=0) arg=sign*(x[0]-par[2])/par[3];
f=TMath::Exp(-1*arg*arg/2.);
f=f+par[5]/2.*(TMath::Erfc(arg/(TMath::Sqrt(2.))));
return par[4]*f+pedestal(x,par);
}
Double_t energyCalibrationFunctions::gaussChargeSharingPixel(Double_t *x, Double_t *par) {
Double_t f;
if (par[3]<=0 || par[2]*(*x)<=0 || par[5]<0 || par[4]<=0) return 0;
Double_t pp[3];
pp[0]=0;
pp[1]=par[2];
pp[2]=par[3];
f=(par[5]-par[6]*(TMath::Log(*x/par[2])))*erfBox(x,pp);
f+=par[4]*TMath::Gaus(*x, par[2], par[3], kTRUE);
return f+pedestal(x,par);
}
Double_t energyCalibrationFunctions::erfBox(Double_t *z, Double_t *par) {
Double_t m=par[0];
Double_t M=par[1];
if (par[0]>par[1]) {
m=par[1];
M=par[0];
}
if (m==M)
return 0;
if (par[2]<=0) {
if (*z>=m && *z<=M)
return 1./(M-m);
else
return 0;
}
return (TMath::Erfc((z[0]-M)/par[2])-TMath::Erfc((z[0]-m)/par[2]))*0.5/(M-m);
}
// basic erf function
Double_t energyCalibrationFunctions::erfFunction(Double_t *x, Double_t *par) {
double arg=0;
if (par[1]!=0) arg=(par[0]-x[0])/par[1];
return ((par[2]/2.*(1+TMath::Erf(sign*arg/(TMath::Sqrt(2))))));
};
Double_t energyCalibrationFunctions::erfFunctionChargeSharing(Double_t *x, Double_t *par) {
Double_t f;
f=erfFunction(x, par+2)*(1+par[5]*(par[2]-x[0]))+par[0]-par[1]*x[0]*sign;
return f;
};
Double_t energyCalibrationFunctions::erfFuncFluo(Double_t *x, Double_t *par) {
Double_t f;
f=erfFunctionChargeSharing(x, par)+erfFunction(x, par+6)*(1+par[9]*(par[6]-x[0]));
return f;
};
#endif
double energyCalibrationFunctions::median(double *x, int n){
// sorts x into xmed array and returns median
// n is number of values already in the xmed array
double xmed[n];
int k,i,j;
for (i=0; i<n; i++) {
k=0;
for (j=0; j<n; j++) {
if(*(x+i)>*(x+j))
k++;
if (*(x+i)==*(x+j)) {
if (i>j)
k++;
}
}
xmed[k]=*(x+i);
}
k=n/2;
return xmed[k];
}
int energyCalibrationFunctions::quick_select(int arr[], int n){
int low, high ;
int median;
int middle, ll, hh;
low = 0 ; high = n-1 ; median = (low + high) / 2;
for (;;) {
if (high <= low) /* One element only */
return arr[median] ;
if (high == low + 1) { /* Two elements only */
if (arr[low] > arr[high])
ELEM_SWAP(arr[low], arr[high]) ;
return arr[median] ;
}
/* Find median of low, middle and high items; swap into position low */
middle = (low + high) / 2;
if (arr[middle] > arr[high]) ELEM_SWAP(arr[middle], arr[high]) ;
if (arr[low] > arr[high]) ELEM_SWAP(arr[low], arr[high]) ;
if (arr[middle] > arr[low]) ELEM_SWAP(arr[middle], arr[low]) ;
/* Swap low item (now in position middle) into position (low+1) */
ELEM_SWAP(arr[middle], arr[low+1]) ;
/* Nibble from each end towards middle, swapping items when stuck */
ll = low + 1;
hh = high;
for (;;) {
do ll++; while (arr[low] > arr[ll]) ;
do hh--; while (arr[hh] > arr[low]) ;
if (hh < ll)
break;
ELEM_SWAP(arr[ll], arr[hh]) ;
}
/* Swap middle item (in position low) back into correct position */
ELEM_SWAP(arr[low], arr[hh]) ;
/* Re-set active partition */
if (hh <= median)
low = ll;
if (hh >= median)
high = hh - 1;
}
}
int energyCalibrationFunctions::kth_smallest(int *a, int n, int k){
register int i,j,l,m ;
register double x ;
l=0 ; m=n-1 ;
while (l<m) {
x=a[k] ;
i=l ;
j=m ;
do {
while (a[i]<x) i++ ;
while (x<a[j]) j-- ;
if (i<=j) {
ELEM_SWAP(a[i],a[j]) ;
i++ ; j-- ;
}
} while (i<=j) ;
if (j<k) l=i ;
if (k<i) m=j ;
}
return a[k] ;
}
#ifdef MYROOT
Double_t energyCalibrationFunctions::spectrum(Double_t *x, Double_t *par) {
return gaussChargeSharing(x,par);
}
Double_t energyCalibrationFunctions::spectrumPixel(Double_t *x, Double_t *par) {
return gaussChargeSharingPixel(x,par);
}
Double_t energyCalibrationFunctions::scurve(Double_t *x, Double_t *par) {
return erfFunctionChargeSharing(x,par);
}
Double_t energyCalibrationFunctions::scurveFluo(Double_t *x, Double_t *par) {
return erfFuncFluo(x,par);
}
#endif
energyCalibration::energyCalibration() :
#ifdef MYROOT
fit_min(-1),
fit_max(-1),
bg_offset(-1),
bg_slope(-1),
flex(-1),
noise(-1),
ampl(-1),
cs_slope(-1),
fscurve(NULL),
fspectrum(NULL),
#endif
funcs(NULL),
plot_flag(1), // fit parameters output to screen
cs_flag(1)
{
#ifdef MYROOT
funcs=new energyCalibrationFunctions();
fscurve=new TF1("fscurve",funcs,&energyCalibrationFunctions::scurve,0,1000,6,"energyCalibrationFunctions","scurve");
fscurve->SetParNames("Background Offset","Background Slope","Inflection Point","Noise RMS", "Number of Photons","Charge Sharing Slope");
fspectrum=new TF1("fspectrum",funcs,&energyCalibrationFunctions::spectrum,0,1000,6,"energyCalibrationFunctions","spectrum");
fspectrum->SetParNames("Background Pedestal","Background slope", "Peak position","Noise RMS", "Number of Photons","Charge Sharing Pedestal");
fspixel=new TF1("fspixel",funcs,&energyCalibrationFunctions::spectrumPixel,0,1000,7,"energyCalibrationFunctions","spectrumPixel");
fspixel->SetParNames("Background Pedestal","Background slope", "Peak position","Noise RMS", "Number of Photons","Charge Sharing Pedestal","Corner");
#endif
}
void energyCalibration::fixParameter(int ip, Double_t val){
fscurve->FixParameter(ip, val);
fspectrum->FixParameter(ip, val);
}
void energyCalibration::releaseParameter(int ip){
fscurve->ReleaseParameter(ip);
fspectrum->ReleaseParameter(ip);
}
energyCalibration::~energyCalibration(){
#ifdef MYROOT
delete fscurve;
delete fspectrum;
#endif
}
#ifdef MYROOT
TH1F* energyCalibration::createMedianHistogram(TH2F* h2, int ch0, int nch, int direction) {
if (h2==NULL || nch==0)
return NULL;
double *x=new double[nch];
TH1F *h1=NULL;
double val=-1;
if (direction==0) {
h1=new TH1F("median","Median",h2->GetYaxis()->GetNbins(),h2->GetYaxis()->GetXmin(),h2->GetYaxis()->GetXmax());
for (int ib=0; ib<h1->GetXaxis()->GetNbins(); ib++) {
for (int ich=0; ich<nch; ich++) {
x[ich]=h2->GetBinContent(ch0+ich+1,ib+1);
}
val=energyCalibrationFunctions::median(x, nch);
h1->SetBinContent(ib+1,val);
}
} else if (direction==1) {
h1=new TH1F("median","Median",h2->GetXaxis()->GetNbins(),h2->GetXaxis()->GetXmin(),h2->GetXaxis()->GetXmax());
for (int ib=0; ib<h1->GetYaxis()->GetNbins(); ib++) {
for (int ich=0; ich<nch; ich++) {
x[ich]=h2->GetBinContent(ib+1,ch0+ich+1);
}
val=energyCalibrationFunctions::median(x, nch);
h1->SetBinContent(ib+1,val);
}
}
delete [] x;
return h1;
}
void energyCalibration::setStartParameters(Double_t *par){
bg_offset=par[0];
bg_slope=par[1];
flex=par[2];
noise=par[3];
ampl=par[4];
cs_slope=par[5];
}
void energyCalibration::getStartParameters(Double_t *par){
par[0]=bg_offset;
par[1]=bg_slope;
par[2]=flex;
par[3]=noise;
par[4]=ampl;
par[5]=cs_slope;
}
#endif
int energyCalibration::setChargeSharing(int p) {
if (p>=0) {
cs_flag=p;
#ifdef MYROOT
if (p) {
fscurve->ReleaseParameter(5);
fspectrum->ReleaseParameter(1);
} else {
fscurve->FixParameter(5,0);
fspectrum->FixParameter(1,0);
}
#endif
}
return cs_flag;
}
#ifdef MYROOT
void energyCalibration::initFitFunction(TF1 *fun, TH1 *h1) {
Double_t min=fit_min, max=fit_max;
Double_t mypar[6];
if (max==-1)
max=h1->GetXaxis()->GetXmax();
if (min==-1)
min=h1->GetXaxis()->GetXmin();
if (bg_offset==-1)
mypar[0]=0;
else
mypar[0]=bg_offset;
if (bg_slope==-1)
mypar[1]=0;
else
mypar[1]=bg_slope;
if (flex==-1)
mypar[2]=(min+max)/2.;
else
mypar[2]=flex;
if (noise==-1)
mypar[3]=0.1;
else
mypar[3]=noise;
if (ampl==-1)
mypar[4]=h1->GetBinContent(h1->GetXaxis()->FindBin(0.5*(max+min)));
else
mypar[4]=ampl;
if (cs_slope==-1)
mypar[5]=0;
else
mypar[5]=cs_slope;
fun->SetParameters(mypar);
fun->SetRange(min,max);
}
TF1* energyCalibration::fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar) {
TF1* fitfun;
char fname[100];
strcpy(fname, fun->GetName());
if (plot_flag) {
h1->Fit(fname,"R0Q");
} else
h1->Fit(fname,"R0Q");
fitfun= h1->GetFunction(fname);
fitfun->GetParameters(mypar);
for (int ip=0; ip<6; ip++) {
emypar[ip]=fitfun->GetParError(ip);
}
return fitfun;
}
TF1* energyCalibration::fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar) {
initFitFunction(fscurve,h1);
return fitFunction(fscurve, h1, mypar, emypar);
}
TF1* energyCalibration::fitSpectrum(TH1 *h1, Double_t *mypar, Double_t *emypar) {
initFitFunction(fspectrum,h1);
return fitFunction(fspectrum, h1, mypar, emypar);
}
TF1* energyCalibration::fitSpectrumPixel(TH1 *h1, Double_t *mypar, Double_t *emypar) {
initFitFunction(fspixel,h1);
return fitFunction(fspixel, h1, mypar, emypar);
}
TGraphErrors* energyCalibration::linearCalibration(int nscan, Double_t *en, Double_t *een, Double_t *fl, Double_t *efl, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff) {
TGraphErrors *gr;
Double_t mypar[2];
gr = new TGraphErrors(nscan,en,fl,een,efl);
if (plot_flag) {
gr->Fit("pol1");
gr->SetMarkerStyle(20);
} else
gr->Fit("pol1","0Q");
TF1 *fitfun= gr->GetFunction("pol1");
fitfun->GetParameters(mypar);
egain=fitfun->GetParError(1);
eoff=fitfun->GetParError(0);
gain=funcs->setScanSign()*mypar[1];
off=mypar[0];
return gr;
}
TGraphErrors* energyCalibration::calibrate(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff, int integral) {
TH1F *h;
Double_t mypar[6], emypar[6];
Double_t fl[nscan], efl[nscan];
for (int ien=0; ien<nscan; ien++) {
h=h1[ien];
if (integral)
fitSCurve(h,mypar,emypar);
else
fitSpectrum(h,mypar,emypar);
fl[ien]=mypar[2];
efl[ien]=emypar[2];
}
return linearCalibration(nscan,en,een,fl,efl,gain,off, egain, eoff);
}
#endif

View File

@ -0,0 +1,65 @@
#ifndef GHOSTSUMMATION_H
#define GHOSTSUMMATION_H
#include <cmath>
#include "slsDetectorData.h"
template <class dataType> class ghostSummation {
/** @short virtual calss to handle ghosting*/
public:
/** constructor
\param xt crosstalk
*/
ghostSummation(slsDetectorData<dataType> *d, double xt) : xtalk(xt),det(d), nx(1), ny(1) {
if (det)
det->getDetectorSize(nx,ny);
ghost=new double[nx*ny];
};
ghostSummation(ghostSummation *orig) {
xtalk=orig->xtalk;
det=orig->det;
nx=1;
ny=1;
det->getDetectorSize(nx,ny);
ghost=new double[nx*ny];
}
~ghostSummation() {delete [] ghost;};
virtual ghostSummation *Clone() {
return new ghostSummation(this);
}
double getXTalk(){return xtalk;};
void setXTalk(double g) {xtalk=g;};
virtual double calcGhost(char *data, int ix, int iy=1){ghost[iy*nx+ix]=0; return 0;};
virtual void calcGhost(char *data){
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++)
ghost[iy*nx+ix]=calcGhost(data, ix, iy);
}
virtual double getGhost(int ix, int iy) {
if (ix<0 || ix>=nx || iy<0 || iy>=ny) return 0;
return ghost[iy*nx+ix];
}
protected:
double xtalk;
slsDetectorData<dataType> *det;
double *ghost;
int nx, ny;
};
#endif

View File

@ -1,30 +0,0 @@
#ifndef GOTTHARDDOUBLECOMMONMODESUBTRACTION_H
#define GOTTHARDDOUBLECOMMONMODESUBTRACTION_H
#include "commonModeSubtractionNew.h"
class gotthardDoubleModuleCommonModeSubtraction : public 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
*/
gotthardDoubleModuleCommonModeSubtraction(int ns=3) : commonModeSubtraction(2, ns) {};
/**
gets the common mode ROI for pixel ix, iy
*/
virtual int getROI(int ix, int iy){return ix%2;};
};
#endif

View File

@ -1,22 +0,0 @@
CBFLIBDIR=/afs/psi.ch/project/sls_det_software/CBFlib-0.9.5
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o ../tiffIO.cpp
ZMQLIB=../../slsReceiverSoftware/include
INCDIR=-I.. -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -I../interpolations -I../dataStructures
LIBHDF5=-L$(CBFLIBDIR)/lib/ -lhdf5
LDFLAG= -L/usr/lib64/ -lpthread
#-L../../bin
MAIN=gotthard25umZmqAnalysis.C
#DESTDIR?=../bin
all: gotthard25umOnTheFlyAnalysis gotthard25umZmq
gotthard25umOnTheFlyAnalysis: $(MAIN) $(INCS) clean
g++ -o gotthard25umOnTheAnalysis $(MAIN) -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
gotthard25umZmq: $(MAIN) $(INCS) clean
g++ -o gotthard25umZmq $(MAIN) -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DZMQ -L$(ZMQLIB) -lzmq
clean:
rm -f gotthard25umOnTheFlyAnalysis

View File

@ -0,0 +1,40 @@
detsizechan 2560 1
hostname bchip074+bchip075+
#hostname bchip092+bchip093+
settingsdir settingsdir/gotthard
angdir 1.000000
caldir settingsdir/gotthard
0:extsig:0 trigger_in_rising_edge
0:rx_tcpport 1954
0:rx_udpport 50001
0:vhighvoltage 0
#0:rx_zmqip pc8829
#0:rx_zmqport 30003
#0:zmqip pc8829
#0:zmqport 40003
1:extsig:0 trigger_in_rising_edge
1:rx_tcpport 1955
1:rx_udpport 50002
#1:detectorip 10.1.1.52
1:vhighvoltage 0
#1:rx_zmqip pc8829
#1:rx_zmqport 30004
#1:zmqip pc8829
#1:zmqport 40004
r_readfreq 1
rx_datastream 1
#rx_udpip 10.1.1.100
rx_hostname pc8498
rx_datastream 1
outdir /tmp/
angconv none
threaded 1

View File

@ -1,517 +0,0 @@
#include "sls_receiver_defs.h"
//#ifdef ZMQ
#include "ZmqSocket.h"
//#endif
#include <vector>
#include <string>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
//#include <deque>
//#include <list>
//#include <queue>
#include <fstream>
#include <cstring>
//#define BCHIP074_BCHIP075
#include "gotthardModuleDataNew.h"
#include "gotthardDoubleModuleDataNew.h"
#include "gotthardDoubleModuleCommonModeSubtractionNew.h"
#include "singlePhotonDetector.h"
//#include "interpolatingDetector.h"
//#include "linearInterpolation.h"
#include "multiThreadedAnalogDetector.h"
#include <ctime>
#define NC 1280
#define NR 1
//#include "tiffIO.h"
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
int main(int argc, char *argv[]){
//void *gotthardProcessFrame() {
int fifosize=1000;
int nthreads=1;
int nph, nph1;
int etabins=550;
double etamin=-1, etamax=2;
int nsubpix=1;
float *etah=new float[etabins*etabins];
int *heta, *himage;
int offset=48;
#ifdef ZMQ
offset=0;
#endif
#ifndef ZMQ
offset=48;
#endif
//commonModeSubtraction *cm=NULL;
gotthardDoubleModuleCommonModeSubtraction *cm=new gotthardDoubleModuleCommonModeSubtraction();
gotthardModuleDataNew *decoder=new gotthardModuleDataNew();
gotthardDoubleModuleDataNew *det=new gotthardDoubleModuleDataNew(offset);
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, cm, 1000, 100);
// analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det, 1, cm, 1000);
// analogDetector<uint16_t> *filter_nocm=new analogDetector<uint16_t>(det, 1, NULL, 1000);
filter->setROI(0,2560,0,1);
char *buff;//[2*(48+1280*2)];
char *buff0;
char *buff1;
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
mt->setFrameMode(eFrame);
// mt->setFrameMode(eFrame);
// mt->setFrameMode(ePedestal);
mt->StartThreads();
mt->popFree(buff);
buff0=buff;
buff1=buff+offset*2+1280*2;
int photons[1280*2];
int nf=0;
int ok=0;
std::time_t end_time;
//int16_t dout[1280*2];
int iFrame=-1;
int np=-1;
nph=0;
nph1=0;
//int np;
int iph;
int data_ready=1;
int *image;
int length;
int nnx, nny,nns;
int nix, niy,nis;
// infinite loop
int ix, iy, isx, isy;
filter->getImageSize(nnx, nny,nns);
int16_t *dout=new int16_t [nnx*nny];
#ifdef ZMQ
if (argc < 3 ) {
cprintf(RED, "Help: %s [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n",argv[0]);
return EXIT_FAILURE;
}
// receive parameters
bool send = false;
char* socketip=argv[1];
uint32_t portnum = atoi(argv[2]);
int size = nnx*nny*2;
// 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;
// receive socket
ZmqSocket* zmqsocket0 = new ZmqSocket(socketip,portnum);
if (zmqsocket0->IsError()) {
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
delete zmqsocket0;
return EXIT_FAILURE;
}
ZmqSocket* zmqsocket1 = new ZmqSocket(socketip,portnum+1);
if (zmqsocket1->IsError()) {
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum+1, socketip);
delete zmqsocket1;
delete zmqsocket0;
return EXIT_FAILURE;
}
zmqsocket0->Connect();
printf("Zmq Client 0 at %s\n", zmqsocket0->GetZmqServerAddress());
zmqsocket1->Connect();
printf("Zmq Client 1 at %s\n", zmqsocket1->GetZmqServerAddress());
// send socket
ZmqSocket* zmqsocket2 = 0;
ZmqSocket* zmqsocket3 = 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 zmqsocket1;
delete zmqsocket0;
return EXIT_FAILURE;
}
zmqsocket3 = new ZmqSocket(portnum2+1, socketip2);
if (zmqsocket3->IsError()) {
bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2+1, socketip2);
delete zmqsocket3;
delete zmqsocket2;
delete zmqsocket1;
delete zmqsocket0;
return EXIT_FAILURE;
}
zmqsocket2->Connect();
printf("Zmq Server 0 started at %s\n", zmqsocket2->GetZmqServerAddress());
zmqsocket3->Connect();
printf("Zmq Server 1 started at %s\n", zmqsocket3->GetZmqServerAddress());
}
uint64_t acqIndex1 = -1;
uint64_t frameIndex1 = -1;
uint32_t subframeIndex1 = -1;
uint64_t fileindex1 = -1;
string filename1 = "";
uint64_t acqIndex0 = -1;
uint64_t frameIndex0 = -1;
uint32_t subframeIndex0 = -1;
uint64_t fileindex0 = -1;
string filename0 = "";
int eoa0=0;
int eoa1=0;
#endif
char ofname[10000];
char fn0[10000], fn1[10000];
FILE *fout=NULL;
FILE *fclust=NULL;
for (int i=0; i<nnx; i++)
dout[i]=0;
char fname0[10000], fname1[10000];
int irun;
#ifndef ZMQ
char ff[10000];
if (argc < 6 ) {
cprintf(RED, "Help: %s [indir] [fformat] [runmin] [runmax] [out file format]\n",argv[0]);
return EXIT_FAILURE;
}
char *indir=argv[1];
char *fformat=argv[2];
int runmin=atoi(argv[3]);
int runmax=atoi(argv[4]);
char *outdir=argv[5];
sprintf(ff,"%s/%s",indir,fformat);
// strcpy(fformat,"/external_pool/gotthard_data/datadir_gotthardI/bchip074075/20170731/Xray/xray_15kV_200uA_5us_d%d_f000000000000_0.raw");
// sprintf(fname0,fformat,0,0);
// sprintf(fname1,fformat,1,1);
ifstream filebin0,filebin1;
for (irun=runmin; irun<runmax; irun++) {
sprintf(fname0,ff,0,irun);
sprintf(fname1,ff,1,irun);
sprintf(ofname,outdir,irun);
filebin0.open((const char *)(fname0), ios::in | ios::binary);
filebin1.open((const char *)(fname1), ios::in | ios::binary);
if (filebin0.is_open() && filebin1.is_open()) {
cout << "Opened file " << fname0<< endl;
cout << "Opened file " << fname1<< endl;
nf=0;
iFrame=-1;
while ((decoder->readNextFrame(filebin0, iFrame, np, buff0)) && (decoder->readNextFrame(filebin1, iFrame, np, buff1))) {
#endif
#ifdef ZMQ
int end_of_acquisition;
while(1) {
end_of_acquisition=0;
eoa0=0;
eoa1=0;
// cout << "Receive header " << nf << endl;
if (!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) {
// cout << "************************************************************************** packet0!*****************************"<< endl;
eoa0=1;
end_of_acquisition++;
}
if (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1)) {
//cout << "************************************************************************** packet1!*****************************"<< endl;
eoa1=1;
end_of_acquisition++;
}
// if ((!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) && (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1))){
if (end_of_acquisition==0) {
if (acqIndex0!=acqIndex1)
cout << "different acquisition indexes " << acqIndex0 << " and " << acqIndex1 << endl;
if (frameIndex0!=frameIndex1)
cout << "different frame indexes " << frameIndex0 << " and " << frameIndex1 << endl;
while (frameIndex0<frameIndex1) {
cout << "aligning det 0 " << endl;
length = zmqsocket0->ReceiveData(0, buff0, size/2);
if (!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) {
end_of_acquisition++;
eoa0=1;
break;
}
}
while (frameIndex1<frameIndex0) {
cout << "aligning det 1 " << endl;
length = zmqsocket1->ReceiveData(0, buff1, size/2);
if (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1)) {
end_of_acquisition++;
eoa1=1;
break;
}
}
}
if (eoa0!=eoa1) {
while (eoa0<1) {
length = zmqsocket0->ReceiveData(0, buff0, size/2);
if (!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) {
end_of_acquisition++;
eoa0=1;
}
}
while (eoa1<1) {
length = zmqsocket1->ReceiveData(0, buff1, size/2);
if (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1)) {
end_of_acquisition++;
eoa1=1;
}
}
}
if (end_of_acquisition) {
// cout << "************************************************************************** END OF FRAME" << end_of_acquisition << " !*****************************"<< endl;
// return 0;
sprintf(ofname,"%s_%d.ph",fn0,irun);
while (mt->isBusy()) {;}
image=filter->getImage();
if (image) {
fout=fopen(ofname,"w");
cout << nf << "*****************" << endl;
for (int i=0; i<2560; i++) {
fprintf(fout,"%d %d\n",i,image[i]);
dout[i]=image[i];
if (dout[i]<0)
dout[i]=0;
}
fclose(fout);
}
if (send) {
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fn0, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
zmqsocket3->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fn1, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
zmqsocket2->SendData((char*)dout,size/2);
zmqsocket3->SendData(((char*)dout)+size/2,size/2);
// // cprintf(GREEN, "Sent Data\n");
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
zmqsocket3->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
}
//mt->setFrameMode(eFrame);
filter->clearImage();
// std::time(&end_time);
// cout << std::ctime(&end_time) << " " << nf << endl;
fclose(fclust);
fclust=NULL;
continue;
}
if (fclust==NULL) {
strcpy(fn0,filename0.c_str());
strcpy(fn1,filename1.c_str());
sprintf(ofname,"%s_%d.clust",fn0,irun);
fclust=fopen(ofname,"w");
while (mt->isBusy()) {;}
mt->setFilePointer(fclust);
}
// strcpy(fn0,filename0.c_str());
// strcpy(fn1,filename1.c_str());
// cout << "Receive data " << nf << endl;
length = zmqsocket0->ReceiveData(0, buff0, size/2);
length += zmqsocket1->ReceiveData(0, buff1, size/2);
irun=fileindex0;
// // if (nf>100)
// // mt->setFrameMode(eFrame);
// //filter->clearImage();
#endif
mt->pushData(buff);
mt->nextThread();
// cout << "==" << nf << endl;
// while (mt->isBusy()) {;}
// image=filter->getImage();
// if (image) {
// for (int i=0; i<2560; i++) {
// // if (i<512)
// // fprintf(fout,"%d %d\n",i,image[i]);
// dout[i]=filter->subtractPedestal(buff,i,0,1);//image[i];//filter->getPedestal(i,0);//
// if (dout[i]<0)
// dout[i]=0;
// // cout << i << " " << image[i] << " " << dout[i] << endl;
// }
// }
// if (send) {
// strcpy(fname0,filename0.c_str());
// strcpy(fname1,filename1.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,fname0, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
// zmqsocket3->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname1, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
// zmqsocket2->SendData((char*)dout,size/2);
// zmqsocket3->SendData(((char*)dout)+size/2,size/2);
// // cprintf(GREEN, "Sent Data\n");
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
// // zmqsocket3->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
// // cprintf(RED, "Received %d frames\n", nf);
// }
mt->popFree(buff);
buff0=buff;
buff1=buff+offset*2+1280*2;
nf++;
#ifndef ZMQ
while (mt->isBusy()) {;}
image=filter->getImage();
if (image) {
fout=fopen(ofname,"w");
//cout << nf << "*****************" << endl;
for (int i=0; i<512; i++) {
fprintf(fout,"%d %d\n",i,image[i]);
}
fclose(fout);
}
filter->clearImage();
iFrame=-1;
}
filebin0.close();
filebin1.close();
}
else
cout << "Could not open file " << fname0<< " or " << fname1 << endl;
#endif
}
return NULL;
}

View File

@ -0,0 +1,14 @@
slsReceiver --rx_tcpport 1954 &
slsReceiver --rx_tcpport 1955 &
./gotthard25umZmq pc8829 30003 129.129.202.98 40003 &
slsDetectorGui -f examples/bchip2modules_pc8829.config &
sls_detector_put settings veryhighgain
sls_detector_put exptime 0.000005
sls_detector_put period 0.01
sls_detector_put vhighvoltage 90

View File

@ -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 {
@ -49,22 +46,29 @@ class interpolatingDetector : public singlePhotonDetector {
int sign=1,
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;
int nd=100, int nnx=-1, int nny=-1, double *gm=NULL, ghostSummation<uint16_t> *gs=NULL) :
singlePhotonDetector(d, 3,nsigma,sign, cm, nped, nd, nnx, nny, gm, gs) , interp(inte), id(0) {
//cout << "**"<< xmin << " " << xmax << " " << ymin << " " << ymax << endl;
fi=new pthread_mutex_t ;
if (pthread_mutex_init(fi, NULL) != 0)
{
printf("\n mutex init failed\n");
}
};
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 +76,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 &nsx, int &nsy) {
if (interp)
return interp->getImageSize(nnx, nny, nsx, nsy);
else
return analogDetector<uint16_t>::getImageSize(nnx, nny, nsx, nsy);
};
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 +132,6 @@ class interpolatingDetector : public singlePhotonDetector {
return interp->getInterpolatedImage();
else
return analogDetector<uint16_t>::getImage();
//cout << "null " << endl;
}
#ifdef MYROOT1
@ -120,8 +144,8 @@ class interpolatingDetector : public singlePhotonDetector {
nph=addFrame(data,val,0);
if (interp)
return interp->getInterpolatedImage();
else
singlePhotonDetector::getImage();
//else
return singlePhotonDetector::getImage();
//return NULL;
};
@ -149,505 +173,105 @@ class interpolatingDetector : public singlePhotonDetector {
return NULL;
}
int addFrame(char *data, int *ph=NULL, int ff=0) {
int nph=0;
double val[ny][nx];
int cy=(clusterSizeY+1)/2;
int cs=(clusterSize+1)/2;
int ir, ic;
int addFrame(char *data, int *ph=NULL, int ff=0) {
double int_x,int_y, eta_x, eta_y;
double max=0, tl=0, tr=0, bl=0,br=0, *v, vv;
singlePhotonDetector::processData(data,ph);
int nph=0;
if (ph==NULL)
ph=image;
if (iframe<nDark) {
addToPedestal(data);
return 0;
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);
}
}
pthread_mutex_unlock(fi);
}
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;
}
}
}
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);
}
}
}
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;
};

View File

@ -13,62 +13,31 @@
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];
eta2InterpolationBase(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax) {
#endif
/* if (etamin>=etamax) { */
/* etamin=-1; */
/* etamax=2; */
/* // cout << ":" <<endl; */
/* } */
/* etastep=(etamax-etamin)/nbeta; */
// 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 */ //////////////
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;
double etax=0,etay=0;
int corner;
corner=calcQuad(data, tot, totquad, sDum);
if (nSubPixels>2)
if (nSubPixelsX>2 || nSubPixelsY>2)
calcEta(totquad, sDum, etax, etay);
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
@ -80,11 +49,11 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
{
double sDum[2][2];
double tot, totquad;
double etax,etay;
double etax=0,etay=0;
int corner;
corner=calcQuad(data, tot, totquad, sDum);
if (nSubPixels>2)
if (nSubPixelsX>2 || nSubPixelsY>2 )
calcEta(totquad, sDum, etax, etay);
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
@ -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;
int xoff=0, yoff=0;
switch (quad) {
case BOTTOM_LEFT:
xoff=0;
@ -128,14 +92,15 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
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];
double etax=0, etay=0;
if (nSubPixelsX>2 || nSubPixelsY>2) {
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 +110,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;
int xoff=0, yoff=0;
switch (quad) {
case BOTTOM_LEFT:
@ -171,12 +132,12 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
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];
double etax=0, etay=0;
if (nSubPixelsX>2 || nSubPixelsY>2) {
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);
@ -221,62 +182,48 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
}
if (nSubPixels>2) {
if (nSubPixelsX>2 || nSubPixelsY>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)/etastepX;
ey=(etay-etamin)/etastepY;
if (ex<0) {
cout << "x*"<< ex << endl;
ex=0;
}
if (ex>=nbetaX) {
cout << "x?"<< ex << endl;
ex=nbetaX-1;
}
if (ey<0) {
cout << "y*"<< ey << " " << nbetaY << endl;
ey=0;
}
if (ey>=nbetaY) {
cout << "y?"<< ey << " " << nbetaY << endl;
ey=nbetaY-1;
}
xpos_eta=(((double)hhx[(ey*nbeta+ex)]))+dX ;///((double)nSubPixels);
ypos_eta=(((double)hhy[(ey*nbeta+ex)]))+dY ;///((double)nSubPixels);
//else
//return 0;
#endif
xpos_eta=(((double)hhx[(ey*nbetaX+ex)]))+dX ;///((double)nSubPixels);
ypos_eta=(((double)hhy[(ey*nbetaX+ex)]))+dY ;///((double)nSubPixels);
} 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;
int xoff=0, yoff=0;
switch (quad) {
case BOTTOM_LEFT:
@ -298,17 +245,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 +261,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;
int xoff=0, yoff=0;
switch (quad) {
case BOTTOM_LEFT:
@ -346,10 +283,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; */
@ -372,11 +309,12 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
virtual int addToFlatField(double *cluster, double &etax, double &etay){
double sDum[2][2];
double tot, totquad;
int corner;
corner=calcQuad(cluster, tot, totquad, sDum);
// int corner;
//corner=
calcQuad(cluster, tot, totquad, sDum);
double xpos_eta,ypos_eta;
double dX,dY;
//double xpos_eta,ypos_eta;
//double dX,dY;
calcEta(totquad, sDum, etax, etay);
@ -388,11 +326,12 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
virtual int addToFlatField(int *cluster, double &etax, double &etay){
double sDum[2][2];
double tot, totquad;
int corner;
corner=calcQuad(cluster, tot, totquad, sDum);
//int corner;
//corner=
calcQuad(cluster, tot, totquad, sDum);
double xpos_eta,ypos_eta;
double dX,dY;
// double xpos_eta,ypos_eta;
//double dX,dY;
calcEta(totquad, sDum, etax, etay);
@ -408,14 +347,45 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
#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]++;
ex=(etax-etamin)/etastepX;
ey=(etay-etamin)/etastepY;
if (ey<nbetaY && ex<nbetaX && ex>=0 && ey>=0)
heta[ey*nbetaX+ex]++;
#endif
return 0;
};
virtual int *getInterpolatedImage(){
int ipx, ipy;
// cout << "ff" << endl;
calcDiff(1, hhx, hhy); //get flat
double avg=0;
for (ipx=0; ipx<nSubPixelsX; ipx++)
for (ipy=0; ipy<nSubPixelsY; ipy++)
avg+=flat[ipx+ipy*nSubPixelsX];
avg/=nSubPixelsY*nSubPixelsX;
for (int ibx=0 ; ibx<nSubPixelsX*nPixelsX; ibx++) {
ipx=ibx%nSubPixelsX-nSubPixelsX/2;
if (ipx<0) ipx=nSubPixelsX+ipx;
for (int iby=0 ; iby<nSubPixelsY*nPixelsY; iby++) {
ipy=iby%nSubPixelsY-nSubPixelsY/2;
if (ipy<0) ipy=nSubPixelsY+ipy;
// cout << ipx << " " << ipy << " " << ibx << " " << iby << endl;
if (flat[ipx+ipy*nSubPixelsX]>0)
hintcorr[ibx+iby*nSubPixelsX*nPixelsX]=hint[ibx+iby*nSubPixelsX*nPixelsX]*(avg/flat[ipx+ipy*nSubPixelsX]);
else
hintcorr[ibx+iby*nSubPixelsX*nPixelsX]=hint[ibx+iby*nSubPixelsX*nPixelsX];
}
}
return hintcorr;
};
/* protected: */
/* #ifdef MYROOT1 */

View File

@ -13,41 +13,18 @@
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) {
eta3InterpolationBase(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx, ny, ns, nsy, nb, nby, emin, emax) {
// cout << "e3ib " << nb << " " << emin << " " << emax << endl;
if (nbeta<=0) {
nbeta=nSubPixels*10;
}
if (etamin>=etamax) {
etamin=-1;
etamax=1;
}
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];
#endif
/* if (nbeta<=0) { */
/* nbeta=nSubPixels*10; */
/* } */
// cout << nbeta << " " << etamin << " " << etamax << endl;
};
eta3InterpolationBase(eta3InterpolationBase *orig): etaInterpolationBase(orig){ };
virtual eta3InterpolationBase* Clone()=0;
/* virtual eta3InterpolationBase* Clone()=0; */
@ -59,10 +36,10 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
//////////// /*It return position hit for the event in input */ //////////////
virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y)
{
double tot, totquad;
double tot;
double etax,etay;
int corner=calcEta3(data,etax,etay, totquad);
int corner=calcEta3(data,etax,etay, tot);
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
@ -72,11 +49,11 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y)
{
double sDum[2][2];
double tot, totquad;
//double sDum[2][2];
double tot;
double etax,etay;
int corner=calcEta3(data,etax,etay, totquad);
int corner=calcEta3(data,etax,etay, tot);
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
@ -88,7 +65,7 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
double etax, etay;
if (nSubPixels>2) {
if (nSubPixelsX>2 || nSubPixelsY>2 ) {
calcEta3(cl,etax,etay, totquad);
}
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
@ -101,7 +78,7 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
double etax, etay;
if (nSubPixels>2) {
if (nSubPixelsX>2 || nSubPixelsY>2 ) {
calcEta3(cl,etax,etay, totquad);
}
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
@ -117,38 +94,38 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
double xpos_eta=0,ypos_eta=0;
int ex,ey;
if (nSubPixels>2) {
if (nSubPixelsX>2 || nSubPixelsY>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);
xpos_eta=(hhx->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixelsX);
ypos_eta=(hhy->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixelsY);
#endif
#ifndef MYROOT1
ex=(etax-etamin)/etastep;
ey=(etay-etamin)/etastep;
ex=(etax-etamin)/etastepX;
ey=(etay-etamin)/etastepY;
if (ex<0) {
/* cout << etax << " " << etamin << " "; */
/* cout << "3x*"<< ex << endl; */
ex=0;
}
if (ex>=nbeta) {
if (ex>=nbetaX) {
/* cout << etax << " " << etamin << " "; */
/* cout << "3x?"<< ex << endl; */
ex=nbeta-1;
ex=nbetaX-1;
}
if (ey<0) {
/* cout << etay << " " << etamin << " "; */
/* cout << "3y*"<< ey << endl; */
ey=0;
}
if (ey>=nbeta) {
if (ey>=nbetaY) {
/* cout << etay << " " << etamin << " "; */
/* cout << "3y?"<< ey << endl; */
ey=nbeta-1;
ey=nbetaY-1;
}
xpos_eta=(((double)hhx[(ey*nbeta+ex)]));///((double)nSubPixels);
ypos_eta=(((double)hhy[(ey*nbeta+ex)]));///((double)nSubPixels);
xpos_eta=(((double)hhx[(ey*nbetaX+ex)]));///((double)nSubPixels);
ypos_eta=(((double)hhy[(ey*nbetaX+ex)]));///((double)nSubPixels);
#endif
@ -265,10 +242,10 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
#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]++;
ex=(etax-etamin)/etastepX;
ey=(etay-etamin)/etastepY;
if (ey<nbetaY && ex<nbetaX && ex>=0 && ey>=0)
heta[ey*nbetaX+ex]++;
#endif
return 0;
};

View File

@ -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 {
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 ";
// protected:
private:
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 tot_eta_x=0;
double tot_eta_y=0;
for (int ipy=0; ipy<nSubPixels; ipy++) {
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++) {
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];
}
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];
}
}
ipy=hhy[ibx+iby*nbeta]*nSubPixels;
if (ipy<0) ipy=0;
if (ipy>=nSubPixels) ipy=nSubPixels-1;
hx[ipy][ibx]+=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];
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;
}
// 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 (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; */
/* } */
/* 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 */
// cout << " chi2= " << new_diff << " (rms= " << sqrt(tot_eta) << ")"<<endl;
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;
@ -247,35 +238,48 @@ class etaInterpolationAdaptiveBins : public etaInterpolationPosXY {
hhx=besthhx;
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

View File

@ -7,7 +7,7 @@
#include <TH2D.h>
#include <TH2F.h>
#endif
#include <cmath>
#include "slsInterpolation.h"
#include "tiffIO.h"
@ -15,111 +15,104 @@ class etaInterpolationBase : public slsInterpolation {
public:
etaInterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : slsInterpolation(nx,ny,ns), hhx(NULL), hhy(NULL), heta(NULL), nbeta(nb), etamin(emin), etamax(emax) {
etaInterpolationBase(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : slsInterpolation(nx,ny,ns,nsy), hhx(NULL), hhy(NULL), heta(NULL), nbetaX(nb), nbetaY(nby), etamin(emin), etamax(emax) {
// cout << "eb " << nb << " " << emin << " " << emax << endl;
// cout << nb << " " << etamin << " " << etamax << endl;
if (nbeta<=0) {
cout << "aaa:" <<endl;
nbeta=nSubPixels*10;
if (nbetaX<=0) {
//cout << "aaa:" <<endl;
nbetaX=nSubPixelsX*10;
}
if (nbetaY<=0) {
//cout << "aaa:" <<endl;
nbetaY=nSubPixelsY*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];
etastepX=(etamax-etamin)/nbetaX;
etastepY=(etamax-etamin)/nbetaY;
heta=new int[nbetaX*nbetaY];
hhx=new float[nbetaX*nbetaY];
hhy=new float[nbetaX*nbetaY];
rangeMin=etamin;
rangeMax=etamax;
flat= new double[nSubPixelsX*nSubPixelsY];
hintcorr=new int [nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY];
#endif
//cout << nbeta << " " << etamin << " " << etamax << endl;
};
etaInterpolationBase(etaInterpolationBase *orig): slsInterpolation(orig){
nbeta=orig->nbeta;
nbetaX=orig->nbetaX;
nbetaY=orig->nbetaY;
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
etastepX=(etamax-etamin)/nbetaX;
etastepY=(etamax-etamin)/nbetaY;
heta=new int[nbetaX*nbetaY];
memcpy(heta,orig->heta,nbetaX*nbetaY*sizeof(int));
hhx=new float[nbetaX*nbetaY];
memcpy(hhx,orig->hhx,nbetaX*nbetaY*sizeof(float));
hhy=new float[nbetaX*nbetaY];
memcpy(hhy,orig->hhy,nbetaX*nbetaY*sizeof(float));
hintcorr=new int [nSubPixelsX*nSubPixelsY*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);
};
TH2D *getFlatField(){return setEta(NULL);};
#endif
#ifndef MYROOT1
int *setEta(int *h, int nb=-1, double emin=1, double emax=0)
virtual void resetFlatField() {
for (int ibx=0; ibx<nbetaX*nbetaY; ibx++) {
heta[ibx]=0;
hhx[ibx]=0;
hhy[ibx]=0;
}
};
int *setEta(int *h, int nb=-1, int nby=-1, double emin=1, double emax=0)
{
if (h) {heta=h;
nbeta=nb;
if (nb<=0) nbeta=nSubPixels*10;
if (h) {
if (heta) delete [] heta;
heta=h;
nbetaX=nb;
nbetaY=nby;
if (nbetaX<=0) nbetaX=nSubPixelsX*10;
if (nbetaY<=0) nbetaY=nSubPixelsY*10;
etamin=emin;
etamax=emax;
if (etamin>=etamax) {
etamin=-1;
etamax=2;
}
etastep=(etamax-etamin)/nbeta;
rangeMin=etamin;
rangeMax=etamax;
etastepX=(etamax-etamin)/nbetaX;
etastepY=(etamax-etamin)/nbetaY;
}
return heta;
};
int *setFlatField(int *h, int nb=-1, double emin=1, double emax=0)
int *setFlatField(int *h, int nb=-1, int nby=-1, double emin=1, double emax=0)
{
return setEta(h, nb, emin, emax);
return setEta(h, nb, nby, emin, emax);
};
int *getFlatField(){return setEta(NULL);};
int *getFlatField(int &nb, double &emin, double &emax){
nb=nbeta;
//cout << "igff* ff has " << nb << " bins " << endl;
int *getFlatField(int &nb, int &nby, double &emin, double &emax){
nb=nbetaX;
nby=nbetaY;
emin=etamin;
emax=etamax;
return getFlatField();
@ -128,13 +121,13 @@ class etaInterpolationBase : public slsInterpolation {
void *writeFlatField(const char * imgname) {
float *gm=NULL;
gm=new float[nbeta*nbeta];
for (int ix=0; ix<nbeta; ix++) {
for (int iy=0; iy<nbeta; iy++) {
gm[iy*nbeta+ix]=heta[iy*nbeta+ix];
gm=new float[nbetaX*nbetaY];
for (int ix=0; ix<nbetaX; ix++) {
for (int iy=0; iy<nbetaY; iy++) {
gm[iy*nbetaX+ix]=heta[iy*nbetaX+ix];
}
}
WriteToTiff(gm, imgname, nbeta, nbeta);
WriteToTiff(gm, imgname, nbetaX, nbetaY);
delete [] gm;
return NULL;
};
@ -148,16 +141,18 @@ class etaInterpolationBase : public slsInterpolation {
etamax=2;
}
etastep=(etamax-etamin)/nbeta;
etastepX=(etamax-etamin)/nbetaX;
etastepY=(etamax-etamin)/nbetaY;
uint32 nnx;
uint32 nny;
float *gm=ReadFromTiff(imgname, nnx, nny);
if (nnx!=nny) {
cout << "different number of bins in x " << nnx << " and y " << nny<< " !"<< endl;
cout << "Aborting read"<< endl;
return 0;
}
nbeta=nnx;
/* if (nnx!=nny) { */
/* cout << "different number of bins in x " << nnx << " and y " << nny<< " !"<< endl; */
/* cout << "Aborting read"<< endl; */
/* return 0; */
/* } */
nbetaX=nnx;
nbetaY=nny;
if (gm) {
if (heta) {
delete [] heta;
@ -165,13 +160,13 @@ class etaInterpolationBase : public slsInterpolation {
delete [] hhy;
}
heta=new int[nbeta*nbeta];
hhx=new float[nbeta*nbeta];
hhy=new float[nbeta*nbeta];
heta=new int[nbetaX*nbetaY];
hhx=new float[nbetaX*nbetaY];
hhy=new float[nbetaX*nbetaY];
for (int ix=0; ix<nbeta; ix++) {
for (int iy=0; iy<nbeta; iy++) {
heta[iy*nbeta+ix]=gm[iy*nbeta+ix];
for (int ix=0; ix<nbetaX; ix++) {
for (int iy=0; iy<nbetaY; iy++) {
heta[iy*nbetaX+ix]=gm[iy*nbetaX+ix];
}
}
delete [] gm;
@ -181,29 +176,9 @@ 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 +190,191 @@ 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
ex=(etax-etamin)/etastepX;
ey=(etay-etamin)/etastepY;
if (ey<nbetaY && ex<nbetaX && ex>=0 && ey>=0)
heta[ey*nbetaX+ex]++;
return 0;
};
// virtual void prepareInterpolation(int &ok)=0;
void debugSaveAll(int ind=0) {
int ibx, iby;
char tit[10000];
float tot_eta=0;
float *etah=new float[nbetaX*nbetaY];
// int etabins=nbeta;
int ibb=0;
for (int ii=0; ii<nbetaX*nbetaY; ii++) {
etah[ii]=heta[ii];
tot_eta+=heta[ii];
}
sprintf(tit,"/scratch/eta_%d.tiff",ind);
WriteToTiff(etah, tit, nbetaX, nbetaY);
for (int ii=0; ii<nbetaX*nbetaY; ii++) {
ibb=(hhx[ii]*nSubPixelsX);
etah[ii]=ibb;
}
sprintf(tit,"/scratch/eta_hhx_%d.tiff",ind);
WriteToTiff(etah, tit, nbetaX, nbetaY);
for (int ii=0; ii<nbetaX*nbetaY; ii++) {
ibb=hhy[ii]*nSubPixelsY;
etah[ii]=ibb;
}
sprintf(tit,"/scratch/eta_hhy_%d.tiff",ind);
WriteToTiff(etah, tit, nbetaX, nbetaY);
float *ftest=new float[nSubPixelsX*nSubPixelsY];
for (int ib=0; ib<nSubPixelsX*nSubPixelsY; ib++) ftest[ib]=0;
//int ibx=0, iby=0;
for (int ii=0; ii<nbetaX*nbetaY; ii++) {
ibx=nSubPixelsX*hhx[ii];
iby=nSubPixelsY*hhy[ii];
if (ibx<0) ibx=0;
if (iby<0) iby=0;
if (ibx>=nSubPixelsX) ibx=nSubPixelsX-1;
if (iby>=nSubPixelsY) iby=nSubPixelsY-1;
if (ibx>=0 && ibx<nSubPixelsX && iby>=0 && iby<nSubPixelsY) {
//
// if (ibx>0 && iby>0) cout << ibx << " " << iby << " " << ii << endl;
ftest[ibx+iby*nSubPixelsX]+=heta[ii];
} else
cout << "Bad interpolation "<< ii << " " << ibx << " " << iby<< endl;
}
sprintf(tit,"/scratch/ftest_%d.tiff",ind);
WriteToTiff(ftest, tit, nSubPixelsX, nSubPixelsY);
//int ibx=0, iby=0;
tot_eta/=nSubPixelsX*nSubPixelsY;
int nbad=0;
for (int ii=0; ii<nbetaX*nbetaY; ii++) {
ibx=nSubPixelsX*hhx[ii];
iby=nSubPixelsY*hhy[ii];
if (ftest[ibx+iby*nSubPixelsX]<tot_eta*0.5) {
etah[ii]=1;
nbad++;
} else if(ftest[ibx+iby*nSubPixelsX]>tot_eta*2.){
etah[ii]=2;
nbad++;
} else
etah[ii]=0;
}
sprintf(tit,"/scratch/eta_bad_%d.tiff",ind);
WriteToTiff(etah, tit, nbetaX, nbetaY);
// 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
int *heta;
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[nSubPixelsX], p_tot_y[nSubPixelsY], p_tot[nSubPixelsX*nSubPixelsY];
double maxdiff=0, mindiff=avg*nSubPixelsX*nSubPixelsY;
int ipx, ipy;
for (ipy=0; ipy<nSubPixelsY; ipy++) {
for (ipx=0; ipx<nSubPixelsX; ipx++) {
p_tot[ipx+ipy*nSubPixelsX]=0;
}
p_tot_y[ipy]=0;
p_tot_x[ipy]=0;
}
for (int ibx=0; ibx<nbetaX; ibx++) {
for (int iby=0; iby<nbetaY; iby++) {
ipx=hx[ibx+iby*nbetaX]*nSubPixelsX;
if (ipx<0) ipx=0;
if (ipx>=nSubPixelsX) ipx=nSubPixelsX-1;
ipy=hy[ibx+iby*nbetaX]*nSubPixelsY;
if (ipy<0) ipy=0;
if (ipy>=nSubPixelsY) ipy=nSubPixelsY-1;
p_tot[ipx+ipy*nSubPixelsX]+=heta[ibx+iby*nbetaX];
p_tot_y[ipy]+=heta[ibx+iby*nbetaX];
p_tot_x[ipx]+=heta[ibx+iby*nbetaX];
}
}
// cout << endl << endl;
for (ipy=0; ipy<nSubPixelsY; ipy++) {
cout.width(5);
//flat_y[ipy]=p_tot_y[ipy];//avg/nSubPixels;
for (ipx=0; ipx<nSubPixelsX; ipx++) {
// flat_x[ipx]=p_tot_x[ipx];///avg/nSubPixels;
flat[ipx+nSubPixelsX*ipy]=p_tot[ipx+nSubPixelsX*ipy];///avg;
d=p_tot[ipx+nSubPixelsX*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);
}
float *hhx;
float *hhy;
#endif
int nbeta;
double etamin, etamax, etastep;
int *heta;
int nbetaX, nbetaY;
double etamin, etamax, etastepX, etastepY;
double rangeMin, rangeMax;
double *flat;
int *hintcorr;
};

View File

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

View File

@ -9,160 +9,192 @@
class etaInterpolationPosXY : public virtual etaInterpolationBase{
public:
etaInterpolationPosXY(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){
etaInterpolationPosXY(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax){
// cout << "epxy " << nb << " " << emin << " " << emax << endl; cout << nbeta << " " << etamin << " " << etamax << endl;
};
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)
{
ok=1;
#ifdef MYROOT1
if (hhx) delete hhx;
if (hhy) delete hhy;
hhx=new TH2D("hhx","hhx",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax());
hhy=new TH2D("hhy","hhy",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax());
#endif
///*Eta Distribution Rebinning*///
double bsize=1./nSubPixels; //precision
// double bsize=1./nSubPixels; //precision
// cout<<"nPixelsX = "<<nPixelsX<<" nPixelsY = "<<nPixelsY<<" nSubPixels = "<<nSubPixels<<endl;
double tot_eta=0;
double tot_eta_x=0;
double tot_eta_y=0;
for (int ip=0; ip<nbeta*nbeta; ip++)
for (int ip=0; ip<nbetaX*nbetaY; ip++)
tot_eta+=heta[ip];
cout << "total eta entries is :"<< tot_eta << endl;
if (tot_eta<=0) {ok=0; return;};
double hx[nbeta]; //profile x
double hy[nbeta]; //profile y
double hix[nbeta]; //integral of projection x
double hiy[nbeta]; //integral of projection y
int ii=0;
for (int ib=0; ib<nbeta; ib++) {
double hx[nbetaX]; //profile x
double hy[nbetaY]; //profile y
double hix[nbetaX]; //integral of projection x
double hiy[nbetaY]; //integral of projection y
// int ii=0;
double etax, etay;
for (int ib=0; ib<nbetaX; ib++) {
tot_eta_x=0;
tot_eta_y=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];
for (int iby=0; iby<nbetaY; iby++) {
etay=etamin+iby*etastepY;
//cout << etax << endl;
// tot_eta_x+=hx[iby];
if (etay>=0 && etay<=1)
hy[iby]=heta[ib+iby*nbetaX];
else
hy[iby]=0;
// tot_eta_y+=hy[iby];
}
hix[0]=hx[0];
hiy[0]=hy[0];
for (int iby=1; iby<nbeta; iby++) {
hix[iby]=hix[iby-1]+hx[iby];
for (int iby=1; iby<nbetaY; iby++) {
hiy[iby]=hiy[iby-1]+hy[iby];
}
ii=0;
tot_eta_y=hiy[nbetaY-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;
} 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
}
for (int iby=0; iby<nbetaY; iby++) {
if (tot_eta_y<=0) {
hhy[ib+iby*nbetaX]=-1;
//ii=(ibx*nSubPixels)/nbeta;
} else {
//if (hiy[ibx]>tot_eta_y*(ii+1)/nSubPixels) ii++;
hhy[ib+iby*nbetaX]=hiy[iby]/tot_eta_y;
}
}
/* if (ii!=(nSubPixels-1)) */
/* cout << ib << " x " << tot_eta_x << " " << (ii+1)*tot_eta_x*bsize << " " << ii << " " << hix[nbeta-1]<< endl; */
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
}
}
for (int ib=0; ib<nbetaY; ib++) {
for (int ibx=0; ibx<nbetaX; ibx++) {
etax=etamin+ibx*etastepX;
//cout << etax << endl;
if (etax>=0 && etax<=1)
hx[ibx]=heta[ibx+ib*nbetaX];
else {
hx[ibx]=0;
}
}
/* if (ii!=(nSubPixels-1)) */
/* cout << ib << " y " << tot_eta_y << " " << (ii+1)*tot_eta_y*bsize << " " << ii << " " << hiy[nbeta-1]<< endl; */
hix[0]=hx[0];
for (int ibx=1; ibx<nbetaX; ibx++) {
hix[ibx]=hix[ibx-1]+hx[ibx];
}
tot_eta_x=hix[nbetaX-1]+1;
// cout << "y " << nbeta << " " << (ii+1)*tot_eta_x*bsize << " " << ii << endl;
for (int ibx=0; ibx<nbetaX; ibx++) {
if (tot_eta_x<=0) {
hhx[ibx+ib*nbetaX]=-1;
}
else {
hhx[ibx+ib*nbetaX]=hix[ibx]/tot_eta_x;
}
}
for (int ibx=0; ibx<nbetaX; ibx++) {
if (tot_eta_x<=0) {
hhx[ibx+ib*nbetaX]=-1;
} else {
//if (hix[ibx]>tot_eta_x*(ii+1)/nSubPixels) ii++;
hhx[ibx+ib*nbetaX]=hix[ibx]/tot_eta_x;
}
}
}
#ifdef SAVE_ALL
char tit[10000];
int ibx, iby, ib;
float *etah=new float[nbeta*nbeta];
int etabins=nbeta;
iby=0;
while (hhx[iby*nbetaY+nbetaY/2]<0) iby++;
for (ib=0; ib<iby;ib++) {
for (ibx=0; ibx<nbetaX;ibx++)
hhx[ibx+nbetaX*ib]=hhx[ibx+nbetaX*iby];
}
iby=nbetaY-1;
while (hhx[iby*nbetaY+nbetaY/2]<0) iby--;
for (ib=iby+1; ib<nbetaY;ib++) {
for (ibx=0; ibx<nbetaX;ibx++)
hhx[ibx+nbetaX*ib]=hhx[ibx+nbetaX*iby];
}
iby=0;
while (hhy[nbetaX/2*nbetaX+iby]<0) iby++;
for (ib=0; ib<iby;ib++) {
for (ibx=0; ibx<nbetaY;ibx++)
hhy[ib+nbetaX*ibx]=hhy[iby+nbetaX*ibx];
}
iby=nbetaX-1;
while (hhy[nbetaX/2*nbetaX+iby]<0) iby--;
for (ib=iby+1; ib<nbetaX;ib++) {
for (ibx=0; ibx<nbetaY;ibx++)
hhy[ib+nbetaX*ibx]=hhy[iby+nbetaX*ibx];
}
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;
#ifdef SAVE_ALL
debugSaveAll();
#endif
return ;
}
};
class eta2InterpolationPosXY : public virtual eta2InterpolationBase, public virtual etaInterpolationPosXY {
public:
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){
eta2InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax),eta2InterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax),etaInterpolationPosXY(nx,ny, ns, nsy, nb, nby, 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){
cout << "e3pxy " << nbeta << " " << etamin << " " << etamax << " " << nSubPixels<< endl;
eta3InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax),eta3InterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax), etaInterpolationPosXY(nx,ny, ns, nsy, nb, nby, emin, emax){
// cout << "e3pxy " << nbeta << " " << etamin << " " << etamax << " " << nSubPixels<< endl;
};
eta3InterpolationPosXY(eta3InterpolationPosXY *orig): etaInterpolationBase(orig), etaInterpolationPosXY(orig) {};

View File

@ -0,0 +1,52 @@
#ifndef INTERPOLATION_ETAVEL_H
#define INTERPOLATION_ETAVEL_H
#include <slsInterpolation.h>
#include "EtaVEL.h"
#include "TH2F.h"
//#include "EtaVEL.cpp"
//class EtaVEL;
class interpolation_EtaVEL: public slsInterpolation {
public:
interpolation_EtaVEL(int nx=40, int ny=160, int ns=25, double etamin=-0.02, double etamax=1.02, int p=0);
~interpolation_EtaVEL();
//create eta distribution, eta rebinnining etc.
//returns flat field image
void prepareInterpolation(int &ok){prepareInterpolation(ok,10000);};
void prepareInterpolation(int &ok, int maxit);
//create interpolated image
//returns interpolated image
//return position inside the pixel for the given photon
void getInterpolatedPosition(Int_t x, Int_t y, Double_t *data, Double_t &int_x, Double_t &int_y);
void getInterpolatedBin(Double_t *cluster, Int_t &int_x, Int_t &int_y);
int addToFlatField(Double_t *cluster, Double_t &etax, Double_t &etay);
int addToFlatField(Double_t etax, Double_t etay);
int setPlot(int p=-1) {if (p>=0) plot=p; return plot;};
int WriteH(){newEta->Write("newEta"); heta->Write("heta");};
EtaVEL *setEta(EtaVEL *ev){if (ev) {delete newEta; newEta=ev;} return newEta;};
TH2F *setEta(TH2F *ev){if (ev) {delete heta; heta=ev;} return heta;};
void iterate();
void DrawH();
double getChiSq(){return newEta->getChiSq();};
protected:
EtaVEL *newEta;
TH2F *heta;
int plot;
// ClassDefNV(interpolation_EtaVEL,1);
// #pragma link C++ class interpolation_EtaVEL-;
};
#endif

View File

@ -40,7 +40,21 @@ 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) {
double eta_x, eta_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:
;

View File

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

View File

@ -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
@ -32,44 +29,61 @@ class slsInterpolation
{
public:
slsInterpolation(int nx=400, int ny=400, int ns=25) :nPixelsX(nx), nPixelsY(ny), nSubPixels(ns), id(0) {
slsInterpolation(int nx=400, int ny=400, int ns=25, int nsy=-1) :nPixelsX(nx), nPixelsY(ny), nSubPixelsX(ns), nSubPixelsY(nsy),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
if (nSubPixelsY<=0) nSubPixelsY=nSubPixelsX;
hint=new int[nSubPixelsX*nx*nSubPixelsY*ny];
};
slsInterpolation(slsInterpolation *orig){
nPixelsX=orig->nPixelsX;
nPixelsY=orig->nPixelsY;
nSubPixels=orig->nSubPixels;
#ifdef MYROOT1
hint=(TH2F*)(orig->hint)->Clone("hint");
#endif
nSubPixelsX=orig->nSubPixelsX;
nSubPixelsY=orig->nSubPixelsY;
#ifndef MYROOT1
hint=new int[nSubPixels*nPixelsX*nSubPixels*nPixelsY];
memcpy(hint, orig->hint,nSubPixels*nPixelsX*nSubPixels*nPixelsY*sizeof(int));
#endif
hint=new int[nSubPixelsX*nPixelsX*nSubPixelsY*nPixelsY];
memcpy(hint, orig->hint,nSubPixelsX*nPixelsX*nSubPixelsY*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 getNSubPixelsX() {return nSubPixelsX;};
int getNSubPixelsY() {return nSubPixelsY;};
int getNSubPixels() {if (nSubPixelsX==nSubPixelsY) return nSubPixelsX; else return 0;};
void getNSubPixels(int &nsx, int &nsy) {nsx=nSubPixelsX; nsy=nsx=nSubPixelsY;}
int getImageSize(int &nnx, int &nny, int &ns) {
nnx=nSubPixels*nPixelsX;
nny=nSubPixels*nPixelsY;
ns=nSubPixels;
return nSubPixels*nSubPixels*nPixelsX*nPixelsY;
void setNSubPixels(int ns, int nsy=-1) {
delete [] hint;
nSubPixelsX=ns;
if (nsy>0) nSubPixelsY=nsy;
else nSubPixelsY=ns;
hint=new int[nSubPixelsX*nPixelsX*nSubPixelsY*nPixelsY];
//return nSubPixels;
}
int getImageSize(int &nnx, int &nny, int &nsx, int &nsy) {
nnx=nSubPixelsX*nPixelsX;
nny=nSubPixelsY*nPixelsY;
nsx=nSubPixelsX;
nsy=nSubPixelsY;
return nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY;
};
int getImageSize() {
return nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY;
};
@ -79,13 +93,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,14 +107,15 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
void *writeInterpolatedImage(const char * imgname) {
//cout << "!" <<endl;
float *gm=NULL;
gm=new float[ nSubPixels* nSubPixels* nPixelsX*nPixelsY];
int *dummy=getInterpolatedImage();
gm=new float[ nSubPixelsX* nSubPixelsY* 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];
for (int ix=0; ix<nPixelsX*nSubPixelsX; ix++) {
for (int iy=0; iy<nPixelsY*nSubPixelsY; iy++) {
gm[iy*nPixelsX*nSubPixelsX+ix]=dummy[iy*nPixelsX*nSubPixelsX+ix];
}
}
WriteToTiff(gm, imgname,nSubPixels* nPixelsX ,nSubPixels* nPixelsY);
WriteToTiff(gm, imgname,nSubPixelsY* nPixelsX ,nSubPixelsY* nPixelsY);
delete [] gm;
} else cout << "Could not allocate float image " << endl;
return NULL;
@ -121,16 +136,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;
for (int ix=0; ix<nPixelsX*nSubPixelsX; ix++) {
for (int iy=0; iy<nPixelsY*nSubPixelsY; iy++) {
hint[iy*nPixelsX*nSubPixelsX+ix]=0;
}
}
#endif
};
@ -138,19 +148,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;
int iy=((double)nSubPixelsY)*int_y;
int ix=((double)nSubPixelsX)*int_x;
if (ix>=0 && ix<(nPixelsX*nSubPixelsX) && iy<(nSubPixelsY*nPixelsY) && iy>=0 ){
// cout << int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << " " << hint[ix+iy*nPixelsX*nSubPixels];
(*(hint+ix+iy*nPixelsX*nSubPixelsX))+=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 +168,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 int *getFlatField(int &nb, double &emin, double &emax){nb=0; emin=0; emax=0; return getFlatField();};
#endif
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, int &nby, double &emin, double &emax){nb=0; nby=0; emin=0; emax=0; return getFlatField();};
virtual void resetFlatField()=0;
//virtual void Streamer(TBuffer &b);
@ -187,24 +190,25 @@ 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;
int xoff=0, yoff=0;
#ifndef WRITE_QUAD
double sumBL=0;
double sumTL=0;
double sumBR=0;
double sumTR=0;
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,41 +216,104 @@ 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){
/* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; */
/* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; */
/* #ifdef WRITE_QUAD */
/* /\* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; *\/ */
/* /\* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; *\/ */
/* if (sumTL ==sum) { */
/* #endif */
corner = TOP_LEFT;
totquad=sumTL;
xoff=0;
yoff=1;
/* #ifdef WRITE_QUAD */
/* } */
/* #endif */
}
if(sumBR >= totquad){
/* sDum[0][0] = cluster[0][1]; sDum[1][0] = cluster[1][1]; */
/* sDum[0][1] = cluster[0][2]; sDum[1][1] = cluster[1][2]; */
/* #ifdef WRITE_QUAD */
/* /\* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; *\/ */
/* /\* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; *\/ */
/* if (sumBR ==sum) { */
/* #endif */
corner = BOTTOM_RIGHT;
xoff=1;
yoff=0;
corner = BOTTOM_RIGHT;
totquad=sumBR;
/* #ifdef WRITE_QUAD */
/* } */
/* #endif */
}
if(sumTR >= totquad){
/* #ifdef WRITE_QUAD */
/* /\* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; *\/ */
/* /\* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; *\/ */
/* if (sumTR ==sum) { */
/* #endif */
xoff=1;
yoff=1;
/* sDum[0][0] = cluster[1][1]; sDum[1][0] = cluster[2][1]; */
/* sDum[0][1] = cluster[1][2]; sDum[1][1] = cluster[2][2]; */
corner = TOP_RIGHT;
totquad=sumTR;
/* #ifdef WRITE_QUAD */
/* } */
/* #endif */
}
#endif
#ifdef WRITE_QUAD
double sumB=0;
double sumT=0;
double sumR=0;
double sumL=0;
for (int ix=0; ix<3; ix++) {
for (int iy=0; iy<3; iy++) {
sum+=cl[ix+3*iy];
if (ix<1 ) sumL+=cl[ix+iy*3];
if (ix>1) sumR+=cl[ix+iy*3];
if (iy<1) sumB=cl[ix+iy*3];
if (iy>1) sumT+=cl[ix+iy*3];
}
}
totquad=sum;
if ( sumT==0 && sumR==0) {
corner = BOTTOM_LEFT;
xoff=0;
yoff=0;
} else if ( sumB==0 && sumR==0 ) {
corner = TOP_LEFT;
xoff=0;
yoff=1;
} else if ( sumT==0 && sumL==0) {
corner = BOTTOM_RIGHT;
xoff=1;
yoff=0;
} else if ( sumB==0 && sumL==0) {
xoff=1;
yoff=1;
corner = TOP_RIGHT;
} else
printf("** bad 2x2 cluster!\n");
#endif
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 +435,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 +479,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; */
/* } */
@ -506,15 +573,9 @@ 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 nSubPixelsX, nSubPixelsY;
int id;
int *hint;
};
#endif

View File

@ -1,44 +1,60 @@
#ifndef MOENCH03COMMONMODE_H
#define MOENCH03COMMONMODE_H
#include "commonModeSubtraction.h"
#include "commonModeSubtractionNew.h"
class moench03CommonMode : public commonModeSubtraction {
class commonModeSubtractionColumn: public commonModeSubtraction{
public:
commonModeSubtractionColumn(int nr=200) : commonModeSubtraction(800), rows(nr) {};
virtual int getROI(int ix, int iy){return ix+(iy/200)*400;};
virtual void addToCommonMode(double val, int ix=0, int iy=0) {
if (iy<rows || iy>399-rows) {
int iroi=getROI(ix,iy);
// cout << iy << " " << ix << " " << iroi ;
if (iroi>=0 && iroi<nROI) {
mean[iroi]+=val;
mean2[iroi]+=val*val;
nCm[iroi]++;
if (nCm[iroi]>rows) cout << "Too many pixels added " << nCm[iroi] << endl;
/* if (ix==10 && iy<20) */
/* cout << " ** "<<val << " " << mean[iroi] << " " << nCm[iroi] << " " << getCommonMode(ix, iy) << endl; */
}
}
};
virtual commonModeSubtractionColumn *Clone() {
return new commonModeSubtractionColumn(this->rows);
}
private:
int rows;
};
class commonModeSubtractionSuperColumn: public commonModeSubtraction{
public:
commonModeSubtractionSuperColumn() : commonModeSubtraction(32) {};
virtual int getROI(int ix, int iy){ return ix/25+(iy/200)*16;};
};
class commonModeSubtractionHalf: public commonModeSubtraction{
public:
commonModeSubtractionHalf() : commonModeSubtraction(2) {};
virtual int getROI(int ix, int iy){ (void) ix; return iy/200;};
};
class moench03CommonMode : public commonModeSubtractionColumn {
/** @short class to calculate the common mode noise for moench02 i.e. on 4 supercolumns separately */
public:
/** constructor - initalizes a commonModeSubtraction with 4 different regions of interest
\param nn number of samples for the moving average
*/
moench03CommonMode(int nn=1000) : commonModeSubtraction(nn,32){} ;
moench03CommonMode(int nr=20) : commonModeSubtractionColumn(nr){} ;
/** add value to common mode as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each;
\param val value to add to the common mode
\param ix pixel coordinate in the x direction
\param iy pixel coordinate in the y direction
*/
virtual void addToCommonMode(double val, int ix=0, int iy=0) {
// (void) iy;
int isc=ix/25+(iy/200)*16;
if (isc>=0 && isc<nROI) {
cmPed[isc]+=val;
nCm[isc]++;
}
};
/**returns common mode value as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each;
\param ix pixel coordinate in the x direction
\param iy pixel coordinate in the y direction
\returns common mode value
*/
virtual double getCommonMode(int ix=0, int iy=0) {
(void) iy;
int isc=ix/25+(iy/200)*16;
if (isc>=0 && isc<nROI) {
if (nCm[isc]>0) return cmPed[isc]/nCm[isc]-cmStat[isc].Mean();
}
return 0;
};
};

View File

@ -0,0 +1,64 @@
#ifndef MOENCH03GHOSTSUMMATION_H
#define MOENCH03GHOSTSUMMATION_H
#include "ghostSummation.h"
class moench03GhostSummation : public ghostSummation<uint16_t> {
/** @short virtual calss to handle ghosting*/
public:
/** constructor
\param xt crosstalk
*/
moench03GhostSummation(slsDetectorData<uint16_t> *d, double xt=0.0004) : ghostSummation<uint16_t>(d, xt) {}
virtual void calcGhost(char *data){
for (int iy=0; iy<200; iy++){
for (int ix=0; ix<25; ix++){
calcGhost(data,ix,iy);
}
}
};
moench03GhostSummation(moench03GhostSummation *orig) : ghostSummation(orig) {
}
virtual moench03GhostSummation *Clone() {
return new moench03GhostSummation(this);
}
virtual double calcGhost(char *data, int x, int y=0){
int ix=x%25;
int iy=y;
if (y>=200) iy=399-y;
if (iy<0 || ix<0) return 0;
double val=0;
val=0;
for (int isc=0; isc<16; isc++) {
val+=det->getChannel(data,ix+25*isc,iy);
// cout << val << " " ;
val+=det->getChannel(data,ix+25*isc,399-iy);
// cout << val << " " ;
}
ghost[iy*nx+ix]=xtalk*val;
// if (ix==15 && iy==15) cout << ":" << ghost[iy*nx+ix] << " " << val << endl;
return ghost[iy*nx+ix];
};
virtual double getGhost(int ix, int iy) {
if (iy >=0 && iy<200) return ghost[iy*nx+(ix%25)];
if (iy<400) return ghost[(399-iy)*nx+(ix%25)];
return 0;
};
};
#endif

View File

@ -1,7 +1,7 @@
#ifndef MOENCHCOMMONMODE_H
#define MOENCHCOMMONMODE_H
#include "commonModeSubtraction.h"
#include "commonModeSubtractionNew.h"
class moenchCommonMode : public commonModeSubtraction {
/** @short class to calculate the common mode noise for moench02 i.e. on 4 supercolumns separately */
@ -9,35 +9,36 @@ class moenchCommonMode : public commonModeSubtraction {
/** constructor - initalizes a commonModeSubtraction with 4 different regions of interest
\param nn number of samples for the moving average
*/
moenchCommonMode(int nn=1000) : commonModeSubtraction(nn,4){} ;
moenchCommonMode(int nn=0) : commonModeSubtraction(0){} ;
/** add value to common mode as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each;
\param val value to add to the common mode
\param ix pixel coordinate in the x direction
\param iy pixel coordinate in the y direction
*/
virtual void addToCommonMode(double val, int ix=0, int iy=0) {
(void) iy;
int isc=ix/40;
if (isc>=0 && isc<nROI) {
cmPed[isc]+=val;
nCm[isc]++;
}
};
/**returns common mode value as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each;
\param ix pixel coordinate in the x direction
\param iy pixel coordinate in the y direction
\returns common mode value
*/
virtual double getCommonMode(int ix=0, int iy=0) {
(void) iy;
int isc=ix/40;
if (isc>=0 && isc<nROI) {
if (nCm[isc]>0) return cmPed[isc]/nCm[isc]-cmStat[isc].Mean();
}
return 0;
};
/* /\** add value to common mode as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each; */
/* \param val value to add to the common mode */
/* \param ix pixel coordinate in the x direction */
/* \param iy pixel coordinate in the y direction */
/* *\/ */
/* virtual void addToCommonMode(double val, int ix=0, int iy=0) { */
/* (void) iy; */
/* int isc=ix/40; */
/* if (isc>=0 && isc<nROI) { */
/* cmPed[isc]+=val; */
/* nCm[isc]++; */
/* } */
/* }; */
/* /\**returns common mode value as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each; */
/* \param ix pixel coordinate in the x direction */
/* \param iy pixel coordinate in the y direction */
/* \returns common mode value */
/* *\/ */
/* virtual double getCommonMode(int ix=0, int iy=0) { */
/* (void) iy; */
/* int isc=ix/40; */
/* if (isc>=0 && isc<nROI) { */
/* if (nCm[isc]>0) return cmPed[isc]/nCm[isc]-cmStat[isc].Mean(); */
/* } */
/* return 0; */
/* }; */
};

View File

@ -1,39 +1,61 @@
#module add CBFlib/0.9.5
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/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$(CBFLIBDIR)/include/
#LIBHDF5=
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff
#-L$(ZMQLIB) -lzmq
#-L../../bin
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -pthread -lrt -ltiff -std=c++11 -Wall -O3
#-g3
#-fsanitize=thread -fno-omit-frame-pointer
#-fsanitize=address,undefined,
MAIN=moench03ClusterFinder.cpp
#-lhdf5
#DESTDIR?=../bin
all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
all: moenchClusterFinder moenchMakeEta moenchMakeEta3 moenchInterpolation moenchInterpolation3 moenchNoInterpolation moenchPhotonCounter moenchAnalog moenchPhotonCounterNoThread moenchAnalogNoThread
moenchClusterFinder: $(MAIN) $(INCS) clean
g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DOLDDATA #-DNEWRECEIVER
moenchClusterFinder: moench03ClusterFinder.cpp $(INCS) clean
g++ -o moenchClusterFinder moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER
moenchMakeEta: moench03MakeEta.cpp $(INCS) clean
g++ -o moenchMakeEta moench03MakeEta.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
moenchClusterFinderHighZ: moench03ClusterFinder.cpp $(INCS) clean
g++ -o moenchClusterFinderHighZ moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER -DHIGHZ
moenchMakeEta: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchMakeEta moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF
moenchMakeEta3: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchMakeEta3 moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF -DETA3
moenchInterpolation: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
moenchInterpolation3: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchInterpolation3 moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DETA3
moenchNoInterpolation: moench03NoInterpolation.cpp $(INCS) clean
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
moenchPhotonCounter: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchPhotonCounter moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER
g++ -o moenchPhotonCounter moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER
moenchAnalog: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER -DANALOG
g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG
moenchPhotonCounterHighZ: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchPhotonCounterHighZ moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DHIGHZ
moenchAnalogHighZ: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchAnalogHighZ moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG -DHIGHZ
moenchAnalogNoThread : moenchPhotonCounterNoThread.cpp $(INCS) clean
g++ -o moenchAnalogNoThread moenchPhotonCounterNoThread.cpp $(LDFLAG) $(INCDIR) -DNEWRECEIVER -DANALOG
moenchPhotonCounterNoThread : moenchPhotonCounterNoThread.cpp $(INCS) clean
g++ -o moenchPhotonCounterNoThread moenchPhotonCounterNoThread.cpp $(LDFLAG) $(INCDIR) $ -DNEWRECEIVER
clean:
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog moenchPhotonCounterNoThread moenchAnalogNoThread

View File

@ -0,0 +1,46 @@
#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/
#LIBHDF5=
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -ltiff
#-L$(ZMQLIB) -lzmq -L$(CBFLIBDIR)/lib/
#-L../../bin
MAIN=moench03ClusterFinder.cpp
#-lhdf5
#DESTDIR?=../bin
all: moenchClusterFinderRect moenchMakeEtaRect moenchInterpolationRect moenchNoInterpolationRect moenchPhotonCounterRect moenchAnalogRect moenchMakeEtaRect1 moenchInterpolationRect1
moenchClusterFinderRect: moench03ClusterFinder.cpp $(INCS) clean
g++ -o moenchClusterFinderRect moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) -DSAVE_ALL -DNEWRECEIVER -DRECT
moenchMakeEtaRect: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchMakeEtaRect moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF -DRECT
moenchInterpolationRect: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchInterpolationRect moench03Interpolation.cpp $(LDFLAG) $(INCDIR) -DRECT
moenchNoInterpolationRect: moench03NoInterpolation.cpp $(INCS) clean
g++ -o moenchNoInterpolationRect moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) -DRECT
moenchPhotonCounterRect: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchPhotonCounterRect moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $ -DNEWRECEIVER -DRECT
moenchAnalogRect: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchAnalogRect moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) -DNEWRECEIVER -DANALOG -DRECT
moenchMakeEtaRect1: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchMakeEtaRect1 moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF -DRECT -DRECT1
moenchInterpolationRect1: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchInterpolationRect1 moench03Interpolation.cpp $(LDFLAG) $(INCDIR) -DRECT -DRECT1
clean:
rm -f moenchClusterFinderRect moenchMakeEtaRect moenchInterpolationRect moenchNoInterpolationRect moenchPhotonCounterRect moenchAnalogRect

View File

@ -0,0 +1,39 @@
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/
#LIBHDF5=
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff
#-L$(ZMQLIB) -lzmq
#-L../../bin
MAIN=moench03ClusterFinder.cpp
#-lhdf5
#DESTDIR?=../bin
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

View File

@ -1,20 +0,0 @@
CBFLIBDIR=/afs/psi.ch/project/sls_det_software/CBFlib-0.9.5
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
INCDIR=-IslsDetectorCalibration -I../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -IetaVEL
LIBHDF5=-L$(CBFLIBDIR)/lib/ -lhdf5
LDFLAG= -L/usr/lib64/ -lpthread
#-L../../bin
MAIN=moench03OnTheFlyAnalysis.C
#DESTDIR?=../bin
all: moench03OnTheFlyAnalysis
moench03OnTheFlyAnalysis: $(MAIN) $(INCS) clean
g++ -o moench03OnTheFlyAnalysis $(MAIN) -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
clean:
rm -f moench03OnTheFlyAnalysis

View File

@ -1,23 +0,0 @@
CBFLIBDIR= /home/l_msdetect/CBFlib-0.9.5
ZMQLIB=../slsReceiverSoftware/include
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
INCDIR=-IslsDetectorCalibration -I../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I.
#-IetaVEL
LIBHDF5=
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff -L$(ZMQLIB)
#-L../../bin
MAIN=moench03ClusterFinder.cpp
#DESTDIR?=../bin
all: moench03ClusterFinder
moench03ClusterFinder: $(MAIN) $(INCS) clean
g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
clean:
rm -f moench03ClusterFinder

View File

@ -1,23 +0,0 @@
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/
LIBHDF5=
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff -L$(ZMQLIB)
#-L../../bin
#DESTDIR?=../bin
all: moenchZmqClusterFinder moenchZmqInterpolating
moenchZmqInterpolating: $(MAIN) $(INCS) clean
g++ -o moenchZmqInterpolating moenchZmqInterpolating.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
moenchZmqClusterFinder: $(MAIN) $(INCS) clean
g++ -o moenchZmqClusterFinder moenchZmqClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
clean:
rm -f moench03ZmqOnTheFlyEta moench03ZmqClusterFinder

Some files were not shown because too many files have changed in this diff Show More