mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 11:20:04 +02:00
merge from 4.0.1
This commit is contained in:
commit
ed74e710d6
@ -41,5 +41,5 @@ deploy:
|
|||||||
provider: script
|
provider: script
|
||||||
script: find $HOME/miniconda/conda-bld/${TRAVIS_OS_NAME}-64 -name "*.tar.bz2" -exec anaconda -t $CONDA_TOKEN upload --force {} \;
|
script: find $HOME/miniconda/conda-bld/${TRAVIS_OS_NAME}-64 -name "*.tar.bz2" -exec anaconda -t $CONDA_TOKEN upload --force {} \;
|
||||||
on:
|
on:
|
||||||
branch: 4.0.1-rc
|
branch: developer
|
||||||
|
|
||||||
|
61
examples/bchip2modules.config
Normal file
61
examples/bchip2modules.config
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
detsizechan 2560 1
|
||||||
|
|
||||||
|
hostname bchip074+bchip075+
|
||||||
|
|
||||||
|
#replace my_installation_path
|
||||||
|
settingsdir /my_installation_path/slsDetectorPackage/settingsdir/gotthard
|
||||||
|
caldir /my_installation_path/slsDetectorPackage/settingsdir/gotthard
|
||||||
|
|
||||||
|
0:extsig:0 trigger_in_rising_edge
|
||||||
|
0:rx_tcpport 1954
|
||||||
|
0:rx_udpport 50001
|
||||||
|
0:vhighvoltage 0
|
||||||
|
|
||||||
|
1:extsig:0 trigger_in_rising_edge
|
||||||
|
1:rx_tcpport 1955
|
||||||
|
1:rx_udpport 50002
|
||||||
|
#1:detectorip 10.1.1.52
|
||||||
|
1:vhighvoltage 0
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#########
|
||||||
|
######### Uncomment this part to use the gotthard25umZmq process
|
||||||
|
#########
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# #replace my_receiver_hostname with the hostname of IP of the machine where the receiver runs
|
||||||
|
#0:rx_zmqip my_receiver_hostname
|
||||||
|
#0:rx_zmqport 30003
|
||||||
|
# #replace my_client_hostname with the hostname of IP of the machine where the client/GUI or softIOC runs
|
||||||
|
#0:zmqip my_client_hostname
|
||||||
|
#0:zmqport 40003
|
||||||
|
|
||||||
|
# #replace my_receiver_hostname with the hostname of IP of the machine where the receiver runs
|
||||||
|
#1:rx_zmqip my_receiver_hostname
|
||||||
|
#1:rx_zmqport 30004
|
||||||
|
# #replace my_client_hostname with the hostname of IP of the machine where the client/GUI or softIOC runs
|
||||||
|
#1:zmqip my_client_hostname
|
||||||
|
#1:zmqport 40004
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#########
|
||||||
|
######### until here
|
||||||
|
#########
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
r_readfreq 1
|
||||||
|
rx_datastream 1
|
||||||
|
|
||||||
|
#replace my_receiver_hostname with the hostname of 1Gb IP of the machine where the receiver runs
|
||||||
|
rx_hostname my_receiver_hostname
|
||||||
|
rx_datastream 1
|
||||||
|
outdir /tmp/
|
||||||
|
angconv none
|
||||||
|
threaded 1
|
||||||
|
|
||||||
|
settings veryhighgain
|
||||||
|
exptime 0.000005
|
||||||
|
period 0.0001
|
||||||
|
|
||||||
|
vhighvoltage 90
|
61
examples/bchip2modules_pc8829.config
Normal file
61
examples/bchip2modules_pc8829.config
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
detsizechan 2560 1
|
||||||
|
|
||||||
|
hostname bchip074+bchip075+
|
||||||
|
|
||||||
|
#replace my_installation_path
|
||||||
|
settingsdir /my_installation_path/slsDetectorPackage/settingsdir/gotthard
|
||||||
|
caldir /my_installation_path/slsDetectorPackage/settingsdir/gotthard
|
||||||
|
|
||||||
|
0:extsig:0 trigger_in_rising_edge
|
||||||
|
0:rx_tcpport 1954
|
||||||
|
0:rx_udpport 50001
|
||||||
|
0:vhighvoltage 0
|
||||||
|
|
||||||
|
1:extsig:0 trigger_in_rising_edge
|
||||||
|
1:rx_tcpport 1955
|
||||||
|
1:rx_udpport 50002
|
||||||
|
#1:detectorip 10.1.1.52
|
||||||
|
1:vhighvoltage 0
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#########
|
||||||
|
######### Uncomment this part to use the gotthard25umZmq process
|
||||||
|
#########
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# #replace my_receiver_hostname with the hostname of IP of the machine where the receiver runs
|
||||||
|
#0:rx_zmqip my_receiver_hostname
|
||||||
|
#0:rx_zmqport 30003
|
||||||
|
# #replace my_client_hostname with the hostname of IP of the machine where the client/GUI or softIOC runs
|
||||||
|
#0:zmqip my_client_hostname
|
||||||
|
#0:zmqport 40003
|
||||||
|
|
||||||
|
# #replace my_receiver_hostname with the hostname of IP of the machine where the receiver runs
|
||||||
|
#1:rx_zmqip my_receiver_hostname
|
||||||
|
#1:rx_zmqport 30004
|
||||||
|
# #replace my_client_hostname with the hostname of IP of the machine where the client/GUI or softIOC runs
|
||||||
|
#1:zmqip my_client_hostname
|
||||||
|
#1:zmqport 40004
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#########
|
||||||
|
######### until here
|
||||||
|
#########
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
r_readfreq 1
|
||||||
|
rx_datastream 1
|
||||||
|
|
||||||
|
#replace my_receiver_hostname with the hostname of 1Gb IP of the machine where the receiver runs
|
||||||
|
rx_hostname my_receiver_hostname
|
||||||
|
rx_datastream 1
|
||||||
|
outdir /tmp/
|
||||||
|
angconv none
|
||||||
|
threaded 1
|
||||||
|
|
||||||
|
settings veryhighgain
|
||||||
|
exptime 0.000005
|
||||||
|
period 0.0001
|
||||||
|
|
||||||
|
vhighvoltage 90
|
14
examples/howto_gotthatd_twomodules.txt
Normal file
14
examples/howto_gotthatd_twomodules.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
Turn on the two receivers:
|
||||||
|
slsReceiver --rx_tcpport 1954 &
|
||||||
|
slsReceiver --rx_tcpport 1955 &
|
||||||
|
|
||||||
|
Switch on the photon conversion on the receiver machine (replace my_receiver_hostname):
|
||||||
|
gotthard25umZmq my_receiver_hostname 30003 my_receiver_hostname 40003 &
|
||||||
|
|
||||||
|
Run the configuration file:
|
||||||
|
sls_detector_put config bchip2modules.config
|
||||||
|
|
||||||
|
|
||||||
|
Start your measurements using the command line, the slsDetectorGui or the EPICS driver
|
||||||
|
|
||||||
|
|
489
examples/moench03_T1_lab.config
Normal file
489
examples/moench03_T1_lab.config
Normal file
@ -0,0 +1,489 @@
|
|||||||
|
hostname bchip085+
|
||||||
|
|
||||||
|
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_udpip 10.1.1.102
|
||||||
|
#0:detectorip 10.1.1.19
|
||||||
|
#0:rx_udpport 32410
|
||||||
|
####gui listening to
|
||||||
|
#zmqip 129.129.202.131
|
||||||
|
#zmqport 30001
|
||||||
|
####data streaming out of
|
||||||
|
#rx_zmqip 10.1.2.103
|
||||||
|
#rx_zmqport 30003
|
||||||
|
#0:rx_hostname mpc2011
|
||||||
|
|
||||||
|
####mx-test-1
|
||||||
|
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 30001
|
||||||
|
####data streaming out of
|
||||||
|
rx_zmqip 10.1.1.100
|
||||||
|
rx_zmqport 30003
|
||||||
|
0:rx_hostname pcmoench01
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#turn on datastream from commandline
|
||||||
|
rx_datastream 1
|
||||||
|
|
||||||
|
r_readfreq 1
|
||||||
|
|
||||||
|
#0:configuremac -1
|
||||||
|
rx_datastream 1
|
||||||
|
|
||||||
|
r_readfreq 1
|
||||||
|
|
||||||
|
|
||||||
|
dac:6 800
|
||||||
|
dac:0 1300
|
||||||
|
dac:4 1428
|
||||||
|
dac:1 1000
|
||||||
|
dac:7 900
|
||||||
|
dac:3 680
|
||||||
|
dac:2 1400
|
||||||
|
dac:5 1200
|
||||||
|
adcinvert 4a342593
|
||||||
|
samples 5000
|
||||||
|
adcphase 90
|
||||||
|
adcpipeline 15
|
||||||
|
adcreg 14 40
|
||||||
|
powerchip 1
|
||||||
|
vhighvoltage 90
|
||||||
|
period 0.005
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
frames 100
|
||||||
|
period 0.1
|
||||||
|
outdir /scratch/
|
||||||
|
enablefwrite 0
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
package:
|
package:
|
||||||
name: sls_detector_software
|
name: sls_detector_software
|
||||||
version: 4.0.1
|
version: "developer"
|
||||||
|
|
||||||
source:
|
source:
|
||||||
- path: ..
|
- path: ..
|
||||||
@ -52,14 +52,14 @@ requirements:
|
|||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
- name: sls_detector_lib
|
- name: sls_detector_lib
|
||||||
version: 4.0.1
|
version: "developer"
|
||||||
script: copy_lib.sh
|
script: copy_lib.sh
|
||||||
requirements:
|
requirements:
|
||||||
build:
|
build:
|
||||||
- {{ compiler('c') }}
|
- {{ compiler('c') }}
|
||||||
- {{compiler('cxx')}}
|
- {{compiler('cxx')}}
|
||||||
- name: sls_detector_gui
|
- name: sls_detector_gui
|
||||||
version: 4.0.1
|
version: "developer"
|
||||||
script: copy_gui.sh
|
script: copy_gui.sh
|
||||||
requirements:
|
requirements:
|
||||||
build:
|
build:
|
||||||
@ -84,6 +84,6 @@ outputs:
|
|||||||
- {{ cdt('libxdamage') }} # [linux]
|
- {{ cdt('libxdamage') }} # [linux]
|
||||||
- {{ cdt('libxxf86vm') }} # [linux]
|
- {{ cdt('libxxf86vm') }} # [linux]
|
||||||
run:
|
run:
|
||||||
- sls_detector_lib=4.0.1
|
- sls_detector_lib=developer
|
||||||
- qwt 6.*
|
- qwt 6.*
|
||||||
- qt=4.8.7=7
|
- qt=4.8.7=7
|
||||||
|
45
slsDetectorCalibration/Stat.h
Normal file
45
slsDetectorCalibration/Stat.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
class Stat
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
Stat() : n(0), m(0.), m2(0.) {}
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
n = 0;
|
||||||
|
m=0;
|
||||||
|
m2=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Push(double x)
|
||||||
|
{
|
||||||
|
|
||||||
|
m+=x;
|
||||||
|
m2+=x*x;
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
|
int NumDataValues() const
|
||||||
|
{
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Mean() const
|
||||||
|
{
|
||||||
|
return (n > 0) ? m/n : 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Variance() const
|
||||||
|
{
|
||||||
|
return ( (n >0 ) ? (m2/n-m*m/(n*n)) : 0.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
double StandardDeviation() const
|
||||||
|
{
|
||||||
|
return sqrt( Variance() );
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int n;
|
||||||
|
double m, m2;
|
||||||
|
};
|
@ -8,6 +8,7 @@
|
|||||||
#include "pedestalSubtraction.h"
|
#include "pedestalSubtraction.h"
|
||||||
#include "commonModeSubtraction.h"
|
#include "commonModeSubtraction.h"
|
||||||
#include "tiffIO.h"
|
#include "tiffIO.h"
|
||||||
|
#include "slsInterpolation.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef ROOTSPECTRUM
|
#ifdef ROOTSPECTRUM
|
||||||
@ -29,6 +30,10 @@ using namespace std;
|
|||||||
enum to define the flags of the data set, which are needed to seect the type of processing it should undergo: frame, pedestal, flat
|
enum 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 frameMode { eFrame, ePedestal, eFlat };
|
||||||
|
/**
|
||||||
|
enum to define the detector mode
|
||||||
|
*/
|
||||||
|
enum detectorMode { eAnalog, ePhotonCounting, eInterpolating };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -76,7 +81,6 @@ template <class dataType> class analogDetector {
|
|||||||
fMode=ePedestal;
|
fMode=ePedestal;
|
||||||
thr=0;
|
thr=0;
|
||||||
myFile=NULL;
|
myFile=NULL;
|
||||||
fm=new pthread_mutex_t ;
|
|
||||||
#ifdef ROOTSPECTRUM
|
#ifdef ROOTSPECTRUM
|
||||||
hs=new TH2F("hs","hs",2000,-100,10000,nx*ny,-0.5,nx*ny-0.5);
|
hs=new TH2F("hs","hs",2000,-100,10000,nx*ny,-0.5,nx*ny-0.5);
|
||||||
#ifdef ROOTCLUST
|
#ifdef ROOTCLUST
|
||||||
@ -124,7 +128,6 @@ template <class dataType> class analogDetector {
|
|||||||
// nSigma=orig->nSigma;
|
// nSigma=orig->nSigma;
|
||||||
fMode=orig->fMode;
|
fMode=orig->fMode;
|
||||||
myFile=orig->myFile;
|
myFile=orig->myFile;
|
||||||
fm=orig->fm;
|
|
||||||
|
|
||||||
|
|
||||||
stat=new pedestalSubtraction*[ny];
|
stat=new pedestalSubtraction*[ny];
|
||||||
@ -218,8 +221,8 @@ template <class dataType> class analogDetector {
|
|||||||
if (gm) {
|
if (gm) {
|
||||||
if (gmap) delete [] gmap;
|
if (gmap) delete [] gmap;
|
||||||
gmap=new double[nnx*nny];
|
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];
|
gmap[iy*nnx+ix]=gm[iy*nnx+ix];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,8 +240,8 @@ template <class dataType> class analogDetector {
|
|||||||
void *ret;
|
void *ret;
|
||||||
if (gmap) {
|
if (gmap) {
|
||||||
gm=new float[nx*ny];
|
gm=new float[nx*ny];
|
||||||
for (int ix=0; ix<nx; ix++) {
|
|
||||||
for (int iy=0; iy<ny; iy++) {
|
for (int iy=0; iy<ny; iy++) {
|
||||||
|
for (int ix=0; ix<nx; ix++) {
|
||||||
gm[iy*nx+ix]=gmap[iy*nx+ix];
|
gm[iy*nx+ix]=gmap[iy*nx+ix];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,9 +325,10 @@ template <class dataType> class analogDetector {
|
|||||||
|
|
||||||
virtual void addToCommonMode(char *data){
|
virtual void addToCommonMode(char *data){
|
||||||
if (cmSub) {
|
if (cmSub) {
|
||||||
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 (getNumpedestals(ix,iy)>0)
|
// if (getNumpedestals(ix,iy)>0)
|
||||||
|
if (det->isGood(ix,iy))
|
||||||
addToCommonMode(data, ix, iy);
|
addToCommonMode(data, ix, iy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,9 +387,10 @@ template <class dataType> class analogDetector {
|
|||||||
virtual double* getPedestal(double *ped){
|
virtual double* getPedestal(double *ped){
|
||||||
if (ped==NULL)
|
if (ped==NULL)
|
||||||
ped=new double[nx*ny];
|
ped=new double[nx*ny];
|
||||||
for (int ix=0; ix<nx; ix++) {
|
|
||||||
for (int iy=0; iy<ny; iy++) {
|
for (int iy=0; iy<ny; iy++) {
|
||||||
|
for (int ix=0; ix<nx; ix++) {
|
||||||
ped[iy*nx+ix]=stat[iy][ix].getPedestal();
|
ped[iy*nx+ix]=stat[iy][ix].getPedestal();
|
||||||
|
//cout << ped[iy*nx+ix] << " " ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ped;
|
return ped;
|
||||||
@ -400,8 +405,8 @@ template <class dataType> class analogDetector {
|
|||||||
virtual double* getPedestalRMS(double *ped=NULL){
|
virtual double* getPedestalRMS(double *ped=NULL){
|
||||||
if (ped==NULL)
|
if (ped==NULL)
|
||||||
ped=new double[nx*ny];
|
ped=new double[nx*ny];
|
||||||
for (int ix=0; ix<nx; ix++) {
|
|
||||||
for (int iy=0; iy<ny; iy++) {
|
for (int iy=0; iy<ny; iy++) {
|
||||||
|
for (int ix=0; ix<nx; ix++) {
|
||||||
ped[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
|
ped[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -440,8 +445,8 @@ template <class dataType> class analogDetector {
|
|||||||
*/
|
*/
|
||||||
virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){
|
virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){
|
||||||
double rr=0;
|
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];
|
if (rms) rr=rms[iy*nx+ix];
|
||||||
stat[iy][ix].setPedestal(ped[iy*nx+ix],rr, m);
|
stat[iy][ix].setPedestal(ped[iy*nx+ix],rr, m);
|
||||||
};
|
};
|
||||||
@ -469,8 +474,8 @@ template <class dataType> class analogDetector {
|
|||||||
\param rms pointer to array of pedestal rms
|
\param rms pointer to array of pedestal rms
|
||||||
*/
|
*/
|
||||||
virtual void setPedestalRMS(double *rms){
|
virtual void setPedestalRMS(double *rms){
|
||||||
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++) {
|
||||||
stat[iy][ix].setPedestalRMS(rms[iy*nx+ix]);
|
stat[iy][ix].setPedestalRMS(rms[iy*nx+ix]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -493,8 +498,8 @@ template <class dataType> class analogDetector {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
gm=new float[nx*ny];
|
gm=new float[nx*ny];
|
||||||
for (int ix=0; ix<nx; ix++) {
|
|
||||||
for (int iy=0; iy<ny; iy++) {
|
for (int iy=0; iy<ny; iy++) {
|
||||||
|
for (int ix=0; ix<nx; ix++) {
|
||||||
gm[iy*nx+ix]=image[iy*nx+ix];
|
gm[iy*nx+ix]=image[iy*nx+ix];
|
||||||
#ifdef ROOTSPECTRUM
|
#ifdef ROOTSPECTRUM
|
||||||
hmap->SetBinContent(ix+1, iy+1,image[iy*nx+ix]);
|
hmap->SetBinContent(ix+1, iy+1,image[iy*nx+ix]);
|
||||||
@ -541,8 +546,8 @@ template <class dataType> class analogDetector {
|
|||||||
TH2F *hmap=new TH2F("hmap","hmap",nx, -0.5,nx-0.5, ny, -0.5, ny-0.5);
|
TH2F *hmap=new TH2F("hmap","hmap",nx, -0.5,nx-0.5, ny, -0.5, ny-0.5);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
for (int ix=0; ix<nx; ix++) {
|
|
||||||
for (int iy=0; iy<ny; iy++) {
|
for (int iy=0; iy<ny; iy++) {
|
||||||
|
for (int ix=0; ix<nx; ix++) {
|
||||||
/* if (cmSub) */
|
/* if (cmSub) */
|
||||||
/* gm[iy*nx+ix]=stat[iy][ix].getPedestal()-cmSub->getCommonMode(); */
|
/* gm[iy*nx+ix]=stat[iy][ix].getPedestal()-cmSub->getCommonMode(); */
|
||||||
/* else */
|
/* else */
|
||||||
@ -588,8 +593,8 @@ template <class dataType> class analogDetector {
|
|||||||
|
|
||||||
|
|
||||||
if (gm) {
|
if (gm) {
|
||||||
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++) {
|
||||||
stat[iy][ix].setPedestal(gm[iy*nx+ix],-1,-1);
|
stat[iy][ix].setPedestal(gm[iy*nx+ix],-1,-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -613,8 +618,8 @@ template <class dataType> class analogDetector {
|
|||||||
|
|
||||||
|
|
||||||
if (gm) {
|
if (gm) {
|
||||||
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++) {
|
||||||
image[iy*nx+ix]=gm[iy*nx+ix];
|
image[iy*nx+ix]=gm[iy*nx+ix];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -639,8 +644,8 @@ template <class dataType> class analogDetector {
|
|||||||
float *gm=NULL;
|
float *gm=NULL;
|
||||||
void *ret;
|
void *ret;
|
||||||
gm=new float[nx*ny];
|
gm=new float[nx*ny];
|
||||||
for (int ix=0; ix<nx; ix++) {
|
|
||||||
for (int iy=0; iy<ny; iy++) {
|
for (int iy=0; iy<ny; iy++) {
|
||||||
|
for (int ix=0; ix<nx; ix++) {
|
||||||
gm[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
|
gm[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -661,8 +666,8 @@ template <class dataType> class analogDetector {
|
|||||||
if (nnx>nx) nnx=nx;
|
if (nnx>nx) nnx=nx;
|
||||||
if (nny>ny) nny=ny;
|
if (nny>ny) nny=ny;
|
||||||
if (gm) {
|
if (gm) {
|
||||||
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++) {
|
||||||
stat[iy][ix].setPedestalRMS(gm[iy*nx+ix]);
|
stat[iy][ix].setPedestalRMS(gm[iy*nx+ix]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -682,9 +687,10 @@ template <class dataType> class analogDetector {
|
|||||||
\param data pointer to the data
|
\param data pointer to the data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
virtual void addToPedestal(char *data, int cm=0) {
|
virtual void addToPedestal(char *data, int cm=0) {
|
||||||
|
|
||||||
|
// cout << "add to pedestal " << endl;
|
||||||
newFrame();
|
newFrame();
|
||||||
|
|
||||||
if (cmSub) {
|
if (cmSub) {
|
||||||
@ -693,13 +699,16 @@ template <class dataType> class analogDetector {
|
|||||||
|
|
||||||
//cout << xmin << " " << xmax << endl;
|
//cout << xmin << " " << xmax << endl;
|
||||||
// cout << ymin << " " << ymax << endl;
|
// cout << ymin << " " << ymax << endl;
|
||||||
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 (det->isGood(ix,iy)) {
|
||||||
addToPedestal(data,ix,iy,1);
|
addToPedestal(data,ix,iy,1);
|
||||||
|
//if (ix==10 && iy==10)
|
||||||
|
// cout <<ix << " " << iy << " " << getPedestal(ix,iy)<< endl;
|
||||||
#ifdef ROOTSPECTRUM
|
#ifdef ROOTSPECTRUM
|
||||||
subtractPedestal(data,ix,iy,cm);
|
subtractPedestal(data,ix,iy,cm);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -814,8 +823,9 @@ template <class dataType> class analogDetector {
|
|||||||
if (val==NULL)
|
if (val==NULL)
|
||||||
val=image;//new double[nx*ny];
|
val=image;//new double[nx*ny];
|
||||||
|
|
||||||
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 (det->isGood(ix,iy))
|
||||||
val[iy*nx+ix]+=subtractPedestal(data, ix, iy,cm);
|
val[iy*nx+ix]+=subtractPedestal(data, ix, iy,cm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -941,8 +951,9 @@ template <class dataType> class analogDetector {
|
|||||||
|
|
||||||
addToCommonMode(data);
|
addToCommonMode(data);
|
||||||
|
|
||||||
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 (det->isGood(ix,iy))
|
||||||
nph[iy*nx+ix]+=getNPhotons(data, ix, iy);
|
nph[iy*nx+ix]+=getNPhotons(data, ix, iy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -955,8 +966,8 @@ template <class dataType> class analogDetector {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
virtual void clearImage(){
|
virtual void clearImage(){
|
||||||
for (int ix=0; ix<nx; ix++) {
|
|
||||||
for (int iy=0; iy<ny; iy++) {
|
for (int iy=0; iy<ny; iy++) {
|
||||||
|
for (int ix=0; ix<nx; ix++) {
|
||||||
image[iy*nx+ix]=0;
|
image[iy*nx+ix]=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -986,8 +997,8 @@ template <class dataType> class analogDetector {
|
|||||||
int SetNPedestals(int i=-1) {
|
int SetNPedestals(int i=-1) {
|
||||||
int ix=0, iy=0;
|
int ix=0, iy=0;
|
||||||
if (i>0)
|
if (i>0)
|
||||||
for (ix=0; ix<nx; ix++)
|
|
||||||
for (iy=0; iy<ny; iy++)
|
for (iy=0; iy<ny; iy++)
|
||||||
|
for (ix=0; ix<nx; ix++)
|
||||||
stat[iy][ix].SetNPedestals(i);
|
stat[iy][ix].SetNPedestals(i);
|
||||||
return stat[0][0].SetNPedestals();
|
return stat[0][0].SetNPedestals();
|
||||||
};
|
};
|
||||||
@ -1019,10 +1030,13 @@ template <class dataType> class analogDetector {
|
|||||||
if (ymi<0) ymi=ymin;
|
if (ymi<0) ymi=ymin;
|
||||||
if (yma<0) yma=ymax;
|
if (yma<0) yma=ymax;
|
||||||
|
|
||||||
for (int ix=xmi; ix<xma; ix++)
|
|
||||||
for (int iy=ymi; iy<yma; iy++)
|
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)
|
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
|
||||||
val+=getNPhotons(data, ix, iy);
|
val+=getNPhotons(data, ix, iy);
|
||||||
|
}
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -1039,16 +1053,17 @@ template <class dataType> class analogDetector {
|
|||||||
virtual void processData(char *data,int *val=NULL) {
|
virtual void processData(char *data,int *val=NULL) {
|
||||||
switch(fMode) {
|
switch(fMode) {
|
||||||
case ePedestal:
|
case ePedestal:
|
||||||
// cout << "ped " << endl;
|
//cout << "analog ped " << endl;
|
||||||
addToPedestal(data);
|
addToPedestal(data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
// cout << "analog " << endl;
|
||||||
//subtractPedestal(data);
|
//subtractPedestal(data);
|
||||||
getNPhotons(data);
|
getNPhotons(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual char *getInterpolation(){return NULL;};
|
// virtual char *getInterpolation(){return NULL;};
|
||||||
|
|
||||||
/** sets the current frame mode for the detector
|
/** sets the current frame mode for the detector
|
||||||
\param f frame mode to be set
|
\param f frame mode to be set
|
||||||
@ -1062,6 +1077,21 @@ template <class dataType> class analogDetector {
|
|||||||
*/
|
*/
|
||||||
frameMode getFrameMode() {return fMode;};
|
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
|
/** sets file pointer where to write the clusters to
|
||||||
\param f file pointer
|
\param f file pointer
|
||||||
\returns current file pointer
|
\returns current file pointer
|
||||||
@ -1072,7 +1102,32 @@ FILE *setFilePointer(FILE *f){myFile=f; return myFile;};
|
|||||||
\returns current file pointer
|
\returns current file pointer
|
||||||
*/
|
*/
|
||||||
FILE *getFilePointer(){return myFile;};
|
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:
|
protected:
|
||||||
|
|
||||||
slsDetectorData<dataType> *det; /**< slsDetectorData to be used */
|
slsDetectorData<dataType> *det; /**< slsDetectorData to be used */
|
||||||
@ -1093,6 +1148,7 @@ FILE *getFilePointer(){return myFile;};
|
|||||||
double thr; /**< threshold to be used for conversion into number of photons */
|
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 */
|
// int nSigma; /**< number of sigma to be used for conversion into number of photons if threshold is undefined */
|
||||||
frameMode fMode; /**< current detector frame mode */
|
frameMode fMode; /**< current detector frame mode */
|
||||||
|
detectorMode dMode; /**< current detector frame mode */
|
||||||
FILE *myFile; /**< file pointer to write to */
|
FILE *myFile; /**< file pointer to write to */
|
||||||
#ifdef ROOTSPECTRUM
|
#ifdef ROOTSPECTRUM
|
||||||
TH2F *hs;
|
TH2F *hs;
|
||||||
@ -1103,7 +1159,6 @@ FILE *getFilePointer(){return myFile;};
|
|||||||
TH2F *hs9;
|
TH2F *hs9;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_t *fm;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
116
slsDetectorCalibration/commonModeSubtractionNew.h
Normal file
116
slsDetectorCalibration/commonModeSubtractionNew.h
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
#ifndef COMMONMODESUBTRACTION_H
|
||||||
|
#define COMMONMODESUBTRACTION_H
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
class commonModeSubtraction {
|
||||||
|
|
||||||
|
/** @short class to calculate the common mode of the pedestals based on an approximated moving average*/
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/** constructor
|
||||||
|
\param nn number of samples for the moving average to calculate the average common mode
|
||||||
|
\param iroi number of regions on which one can calculate the common mode separately. Defaults to 1 i.e. whole detector
|
||||||
|
|
||||||
|
*/
|
||||||
|
commonModeSubtraction(int iroi=1, int ns=3) : nROI(iroi), nsigma(ns) {
|
||||||
|
mean=new double[nROI];
|
||||||
|
mean2=new double[nROI];
|
||||||
|
nCm=new double[nROI];
|
||||||
|
};
|
||||||
|
|
||||||
|
/** destructor - deletes the moving average(s) and the sum of pedestals calculator(s) */
|
||||||
|
virtual ~commonModeSubtraction() {delete [] mean; delete [] mean2; delete [] nCm;};
|
||||||
|
|
||||||
|
|
||||||
|
/** clears the moving average and the sum of pedestals calculation - virtual func*/
|
||||||
|
virtual void Clear(){
|
||||||
|
for (int i=0; i<nROI; i++) {
|
||||||
|
mean[i]=0;
|
||||||
|
nCm[i]=0;
|
||||||
|
mean2[i]=0;
|
||||||
|
}};
|
||||||
|
|
||||||
|
/** adds the average of pedestals to the moving average and reinitializes the calculation of the sum of pedestals for all ROIs. - virtual func*/
|
||||||
|
virtual void newFrame(){
|
||||||
|
for (int i=0; i<nROI; i++) {
|
||||||
|
// if (nCm[i]>0) cmStat[i].Calc(cmPed[i]/nCm[i]);
|
||||||
|
nCm[i]=0;
|
||||||
|
mean[i]=0;
|
||||||
|
mean2[i]=0;
|
||||||
|
}};
|
||||||
|
|
||||||
|
/** adds the pixel to the sum of pedestals -- virtual func must be overloaded to define the regions of interest
|
||||||
|
\param val value to add
|
||||||
|
\param ix pixel x coordinate
|
||||||
|
\param iy pixel y coordinate
|
||||||
|
*/
|
||||||
|
virtual void addToCommonMode(double val, int ix=0, int iy=0) {
|
||||||
|
|
||||||
|
int iroi=getROI(ix,iy);
|
||||||
|
// if (iroi==0) val=100;
|
||||||
|
// else val=-100;
|
||||||
|
// if (isc>=0 && isc<nROI) {
|
||||||
|
if (iroi>=0 && iroi<nROI) {
|
||||||
|
mean[iroi]+=val;
|
||||||
|
mean2[iroi]+=val*val;
|
||||||
|
nCm[iroi]++;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** gets the common mode i.e. the difference between the current average sum of pedestals mode and the average pedestal
|
||||||
|
\param ix pixel x coordinate
|
||||||
|
\param iy pixel y coordinate
|
||||||
|
\return the difference between the current average sum of pedestals and the average pedestal
|
||||||
|
*/
|
||||||
|
virtual double getCommonMode(int ix=0, int iy=0) {
|
||||||
|
int iroi=getROI(ix,iy);
|
||||||
|
/* if (iroi==0) */
|
||||||
|
/* return 100; */
|
||||||
|
/* else */
|
||||||
|
/* return -100; */
|
||||||
|
|
||||||
|
if (iroi>=0 && iroi<nROI) {
|
||||||
|
if (nCm[iroi]>0)
|
||||||
|
return mean[iroi]/nCm[iroi];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** gets the common mode i.e. the difference between the current average sum of pedestals mode and the average pedestal
|
||||||
|
\param ix pixel x coordinate
|
||||||
|
\param iy pixel y coordinate
|
||||||
|
\return the difference between the current average sum of pedestals and the average pedestal
|
||||||
|
*/
|
||||||
|
virtual double getCommonModeRMS(int ix=0, int iy=0) {
|
||||||
|
int iroi=getROI(ix,iy);
|
||||||
|
if (iroi>=0 && iroi<nROI) {
|
||||||
|
if (nCm[iroi]>0)
|
||||||
|
return sqrt(mean2[iroi]/nCm[iroi]-(mean[iroi]/nCm[iroi])*(mean[iroi]/nCm[iroi]));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
gets the common mode ROI for pixel ix, iy -should be overloaded!
|
||||||
|
*/
|
||||||
|
virtual int getROI(int ix, int iy){ (void) ix; (void) iy; return 0;};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
double *mean; /**<array of moving average of the pedestal average per region of interest */
|
||||||
|
double *mean2; /**< array storing the sum of pedestals per region of interest */
|
||||||
|
double *nCm; /**< array storing the number of pixels currently contributing to the pedestals */
|
||||||
|
int nsigma; /** number of rms above which the pedestal should be considered as a photon */
|
||||||
|
const int nROI; /**< constant parameter for number of regions on which the common mode should be calculated separately e.g. supercolumns */
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -74,7 +74,7 @@ class mythen3_01_jctbData : public slsDetectorData<short unsigned int> {
|
|||||||
for (ib=0; ib<nb; ib++) {
|
for (ib=0; ib<nb; ib++) {
|
||||||
if (word&(1<<bit[ib])) {
|
if (word&(1<<bit[ib])) {
|
||||||
cout << "+" ;
|
cout << "+" ;
|
||||||
val[iw+nch*(ib/nb)]|=(1<<idr);
|
val[iw+nch/nb*(ib)]|=(1<<idr);
|
||||||
} else {
|
} else {
|
||||||
cout << "-" ;
|
cout << "-" ;
|
||||||
}
|
}
|
||||||
@ -96,8 +96,8 @@ class mythen3_01_jctbData : public slsDetectorData<short unsigned int> {
|
|||||||
ii++;
|
ii++;
|
||||||
}//end for
|
}//end for
|
||||||
|
|
||||||
cout << "Decoded "<<ii << " samples"<< endl;
|
cout << "M3.01 Decoded "<<ii << " samples"<< endl;
|
||||||
cout << "Should be "<< nch/nb*dr+off << " samples"<< endl;
|
cout << "M3.01 Should be "<< nch/nb*dr+off << " samples"<< endl;
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
@ -57,8 +57,9 @@ class mythen3_02_jctbData : public mythen3_01_jctbData {
|
|||||||
int ioff=0;
|
int ioff=0;
|
||||||
int idr=0;
|
int idr=0;
|
||||||
int ib=0;
|
int ib=0;
|
||||||
int iw=0;
|
int ich=0;
|
||||||
int ii=0;
|
int ii=0;
|
||||||
|
int iw=0;
|
||||||
bit[0]=17;//19;
|
bit[0]=17;//19;
|
||||||
bit[1]=6;//8;
|
bit[1]=6;//8;
|
||||||
idr=0;
|
idr=0;
|
||||||
@ -68,7 +69,8 @@ class mythen3_02_jctbData : public mythen3_01_jctbData {
|
|||||||
wp=(int64_t*)ptr;
|
wp=(int64_t*)ptr;
|
||||||
|
|
||||||
for (iw=0; iw<nch/nb; iw) {
|
for (iw=0; iw<nch/nb; iw) {
|
||||||
word=*wp;;
|
word=*wp;
|
||||||
|
|
||||||
if (ioff<off) {
|
if (ioff<off) {
|
||||||
ioff++;
|
ioff++;
|
||||||
cout <<"*";
|
cout <<"*";
|
||||||
@ -78,10 +80,11 @@ class mythen3_02_jctbData : public mythen3_01_jctbData {
|
|||||||
for (ib=0; ib<nb; ib++) {
|
for (ib=0; ib<nb; ib++) {
|
||||||
if (word&(1<<bit[ib])) {
|
if (word&(1<<bit[ib])) {
|
||||||
cout << "+" ;
|
cout << "+" ;
|
||||||
val[iw+nch*(ib/nb)]|=(1<<idr);
|
val[iw+nch/nb*(ib)]|=(1<<idr);
|
||||||
} else {
|
} else {
|
||||||
cout << "-" ;
|
cout << "-" ;
|
||||||
}
|
}
|
||||||
|
// cout << iw+nch/nb*(ib)<< " " ;
|
||||||
}//end for()
|
}//end for()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,8 +103,8 @@ class mythen3_02_jctbData : public mythen3_01_jctbData {
|
|||||||
ii++;
|
ii++;
|
||||||
}//end for
|
}//end for
|
||||||
|
|
||||||
cout << "Decoded "<<ii << " samples"<< endl;
|
cout << "M3.02 Decoded "<<ii << " samples"<< endl;
|
||||||
cout << "Should be "<< nch/nb*dr+off << " samples"<< endl;
|
cout << "M3.02 Should be "<< nch/nb*dr+off << " samples"<< endl;
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,23 @@ class jungfrau10ModuleData : public slsDetectorData<uint16_t> {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint64_t frameNumber; /**< is the frame number */
|
||||||
|
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
|
||||||
|
uint32_t packetNumber; /**< is the packet number */
|
||||||
|
uint64_t bunchId; /**< is the bunch id from beamline */
|
||||||
|
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||||
|
uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
|
||||||
|
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||||
|
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||||
|
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||||
|
uint32_t debug; /**< is for debugging purposes */
|
||||||
|
uint16_t roundRNumber; /**< is the round robin set number */
|
||||||
|
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||||
|
uint8_t version; /**< is the version number of this structure format */
|
||||||
|
} sls_detector_header;
|
||||||
|
|
||||||
|
|
||||||
int iframe;
|
int iframe;
|
||||||
int nadc;
|
int nadc;
|
||||||
int sc_width;
|
int sc_width;
|
||||||
@ -25,7 +42,7 @@ class jungfrau10ModuleData : public slsDetectorData<uint16_t> {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
jungfrau10ModuleData(int ns=16384): slsDetectorData<uint16_t>(256*4, 256*2, 256*256*8*2, NULL, NULL, NULL) , iframe(0), nadc(32), sc_width(64), sc_height(256) {
|
jungfrau10ModuleData(int ns=16384): slsDetectorData<uint16_t>(256*4, 256*2, 256*256*8*2+48, NULL, NULL, NULL) , iframe(0) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -38,43 +55,51 @@ class jungfrau10ModuleData : public slsDetectorData<uint16_t> {
|
|||||||
int ichip;
|
int ichip;
|
||||||
|
|
||||||
// cout << sizeof(uint16_t) << endl;
|
// cout << sizeof(uint16_t) << endl;
|
||||||
|
int ip=0;
|
||||||
for (iadc=0; iadc<nadc; iadc++) {
|
for (int iy=0; iy<256*2; iy++) {
|
||||||
ichip=iadc/4;
|
for (int ix=0; ix<256*4; ix++){
|
||||||
|
dataMap[iy][ix]=ip*2+48;
|
||||||
for (int i=0; i<sc_width*sc_height; i++) {
|
ip++;
|
||||||
|
}
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* for (iadc=0; iadc<nadc; iadc++) { */
|
||||||
|
/* ichip=iadc/4; */
|
||||||
|
|
||||||
/* if (iadc<nadc/2) { */
|
/* for (int i=0; i<sc_width*sc_height; i++) { */
|
||||||
|
|
||||||
|
/* if (ichip%2==0) { */
|
||||||
/* row=sc_height+i/sc_width; */
|
/* row=sc_height+i/sc_width; */
|
||||||
/* col=iadc*sc_width+(i%sc_width); */
|
/* col=(ichip/2)*256+iadc%4*sc_width+(i%sc_width); */
|
||||||
/* } else { */
|
/* } else { */
|
||||||
/* row=sc_height-1-i/sc_width; */
|
/* row=sc_height-1-i/sc_width; */
|
||||||
/* col=(nx-1)-((iadc-16)*sc_width)-(i%sc_width); */
|
/* col=((ichip/2)*256+iadc%4*sc_width)+sc_width-(i%sc_width)-1; */
|
||||||
/* } */
|
/* } */
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
/* /\* if (iadc<nadc/2) { *\/ */
|
||||||
|
/* /\* row=sc_height+i/sc_width; *\/ */
|
||||||
|
/* /\* col=iadc*sc_width+(i%sc_width); *\/ */
|
||||||
|
/* /\* } else { *\/ */
|
||||||
|
/* /\* row=sc_height-1-i/sc_width; *\/ */
|
||||||
|
/* /\* col=(nx-1)-((iadc-16)*sc_width)-(i%sc_width); *\/ */
|
||||||
|
/* /\* } *\/ */
|
||||||
|
/* if (row<0 || row>=ny || col<0 || col>=nx) { */
|
||||||
|
/* cout << "Wrong row, column " << row << " " << col << " " << iadc << " " << i << endl; */
|
||||||
|
/* } else */
|
||||||
|
/* dataMap[row][col]=(nadc*i+iadc)*2; */
|
||||||
|
/* if (dataMap[row][col]<0 || dataMap[row][col]>=dataSize) */
|
||||||
|
/* cout << "Error: pointer " << dataMap[row][col] << " out of range " << row << " " << col <<" " << iadc << " " << i << endl; */
|
||||||
|
/* else { */
|
||||||
|
/* xmap[nadc*i+iadc]=col; */
|
||||||
|
/* ymap[nadc*i+iadc]=row; */
|
||||||
|
|
||||||
|
/* } */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -91,7 +116,7 @@ class jungfrau10ModuleData : public slsDetectorData<uint16_t> {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
int getFrameNumber(char *buff){(void)buff; return iframe;};
|
int getFrameNumber(return (sls_detector_header*)buff)->frameNumber;};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@ -123,28 +148,65 @@ class jungfrau10ModuleData : public slsDetectorData<uint16_t> {
|
|||||||
\returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete
|
\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){
|
virtual char *readNextFrame(ifstream &filebin) {
|
||||||
// int afifo_length=0;
|
int ff=-1, np=-1;
|
||||||
uint16_t *afifo_cont;
|
return readNextFrame(filebin, ff, np);
|
||||||
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=-1;
|
||||||
|
return readNextFrame(filebin, ff, np);
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||||
|
char *data=new char[dataSize];
|
||||||
|
char *d=readNextFrame(filebin, ff, np, data);
|
||||||
|
if (d==NULL) {delete [] data; data=NULL;}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||||
|
// char *readNextFrame(ifstream &filebin){
|
||||||
|
// int afifo_length=0;
|
||||||
|
/* uint16_t *afifo_cont; */
|
||||||
|
/* int ib=0; */
|
||||||
|
/* if (filebin.is_open()) { */
|
||||||
|
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||||
|
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||||
|
/* ib+=2; */
|
||||||
|
/* if (ib==dataSize) break; */
|
||||||
|
/* } */
|
||||||
|
/* if (ib>0) { */
|
||||||
|
/* iframe++; */
|
||||||
|
/* // cout << ib << "-" << endl; */
|
||||||
|
/* return (char*)afifo_cont; */
|
||||||
|
/* } else { */
|
||||||
|
/* delete [] afifo_cont; */
|
||||||
|
/* return NULL; */
|
||||||
|
/* } */
|
||||||
|
/* } */
|
||||||
|
/* return NULL; */
|
||||||
|
/* }; */
|
||||||
|
|
||||||
|
char *retval=0;
|
||||||
|
int nd;
|
||||||
|
int fnum = -1;
|
||||||
|
np=0;
|
||||||
|
int pn;
|
||||||
|
|
||||||
|
// cout << dataSize << endl;
|
||||||
|
if (ff>=0)
|
||||||
|
fnum=ff;
|
||||||
|
|
||||||
|
if (filebin.is_open()) {
|
||||||
|
if (filebin.read(data, dataSize) ){
|
||||||
|
ff=getFrameNumber(data);
|
||||||
|
np=getPacketNumber(data);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
|
|||||||
moench02CtbData(int ns=6400): slsDetectorData<uint16_t>(160, 160, ns*2*32, NULL, NULL) , nadc(32), sc_width(40), sc_height(160) {
|
moench02CtbData(int ns=6400): slsDetectorData<uint16_t>(160, 160, ns*2*32, NULL, NULL) , nadc(32), sc_width(40), sc_height(160) {
|
||||||
|
|
||||||
|
|
||||||
int adc_off[4]={0,40,80,120};
|
int adc_off[4]={40,0,120,80};
|
||||||
int adc_nr[4]={8,10,20,23};
|
int adc_nr[4]={8,10,20,22};
|
||||||
int row, col;
|
int row, col;
|
||||||
|
|
||||||
int isample;
|
int isample;
|
||||||
@ -86,10 +86,10 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
|
|||||||
if(ip>=0 && ip<maplength){
|
if(ip>=0 && ip<maplength){
|
||||||
x=xmap[ip];
|
x=xmap[ip];
|
||||||
y=ymap[ip];
|
y=ymap[ip];
|
||||||
}else{
|
}/*else{
|
||||||
cerr<<"WRONG ARRAY LENGTH"<<endl;
|
cerr<<"WRONG ARRAY LENGTH"<<endl;
|
||||||
cerr<<"Trying to access the "<<ip<<"-th element"<<endl;
|
cerr<<"Trying to access the "<<ip<<"-th element"<<endl;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
187
slsDetectorCalibration/dataStructures/moench02CtbDataDGS.h
Normal file
187
slsDetectorCalibration/dataStructures/moench02CtbDataDGS.h
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
#ifndef MOENCH02CTBDATADGS_H
|
||||||
|
#define MOENCH02CTBDATADGS_H
|
||||||
|
#include "slsDetectorData.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class moench02CtbData : public slsDetectorData<uint16_t> {
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
int iframe;
|
||||||
|
// int *xmap, *ymap;
|
||||||
|
//int nadc;
|
||||||
|
int sc_width;
|
||||||
|
int sc_height;
|
||||||
|
|
||||||
|
int maplength;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||||
|
(160x160 pixels, 40 packets 1286 large etc.)
|
||||||
|
\param c crosstalk parameter for the output buffer
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
moench02CtbDataDGS(int ns=6400): slsDetectorData<uint16_t>(160, 160, ns*(2*32+8), NULL, NULL) , sc_width(40), sc_height(160) {
|
||||||
|
|
||||||
|
|
||||||
|
int adc_off[4]={40,0,120,80};
|
||||||
|
int adc_nr[4]={8,10,20,23};
|
||||||
|
int row, col;
|
||||||
|
|
||||||
|
int isample;
|
||||||
|
int iadc, iiadc;
|
||||||
|
int ix, iy;
|
||||||
|
maplength=this->getDataSize()/2;
|
||||||
|
//cout << maplength << endl;
|
||||||
|
|
||||||
|
for (iiadc=0; iiadc<4; iiadc++) {
|
||||||
|
|
||||||
|
iadc=adc_nr[iiadc];
|
||||||
|
//cout << iiadc << endl;
|
||||||
|
for (int i=0; i<sc_width*sc_height; i++) {
|
||||||
|
col=adc_off[iiadc]+(i%sc_width);
|
||||||
|
row=i/sc_width;
|
||||||
|
dataMap[row][col]=(32*i+iadc)*2;
|
||||||
|
if (dataMap[row][col]<0 || dataMap[row][col]>=dataSize) {
|
||||||
|
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0; i<maplength; i++) {
|
||||||
|
//cout << i << endl;
|
||||||
|
isample=i/32;
|
||||||
|
iiadc=i%32;
|
||||||
|
iadc=-1;
|
||||||
|
for (int iii=0; iii<4; iii++) {
|
||||||
|
if (iiadc==adc_nr[iii]) iadc=iii;
|
||||||
|
}
|
||||||
|
ix=isample%sc_width;
|
||||||
|
iy=isample/sc_width;
|
||||||
|
if(iadc>=0){
|
||||||
|
xmap[i]=adc_off[iadc]+ix;
|
||||||
|
ymap[i]=iy;
|
||||||
|
}else{
|
||||||
|
xmap[i]=-1;
|
||||||
|
ymap[i]=-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
iframe=0;
|
||||||
|
cout << "data struct created" << endl;
|
||||||
|
};
|
||||||
|
|
||||||
|
void getPixel(int ip, int &x, int &y) {
|
||||||
|
if(ip>=0 && ip<maplength){
|
||||||
|
x=xmap[ip];
|
||||||
|
y=ymap[ip];
|
||||||
|
}/*else{
|
||||||
|
cerr<<"WRONG ARRAY LENGTH"<<endl;
|
||||||
|
cerr<<"Trying to access the "<<ip<<"-th element"<<endl;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the gain for the selected pixel (at the moemnt only 3rd supercolumn)
|
||||||
|
\param buff pointer to the dataset
|
||||||
|
\param ix x coordinate
|
||||||
|
\param iy y coordinate
|
||||||
|
\returns gain value
|
||||||
|
*/
|
||||||
|
|
||||||
|
int getGain(char *buff, int ix, int iy) {
|
||||||
|
int isample=iy*sc_width+iy;
|
||||||
|
if (ix<sc_width) return 0; //first supercolumn no gain switching - could return the static gain if wished
|
||||||
|
if (ix<2*sc_width) return 0; //second supercolumn no gain switching - could return the static gain if wished
|
||||||
|
if (ix<3*sc_width){
|
||||||
|
if(*((long*)(buff+(32*2*isample+8*(isample-1)))&(1>>31)) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 0; //not yet implemented for 4th supercolumn
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
Returns the frame number for the given dataset. Purely virtual func.
|
||||||
|
\param buff pointer to the dataset
|
||||||
|
\returns frame number
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
virtual int getFrameNumber(char *buff){(void)buff; return iframe;};
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
Returns the packet number for the given dataset. purely virtual func
|
||||||
|
\param buff pointer to the dataset
|
||||||
|
\returns packet number number
|
||||||
|
|
||||||
|
|
||||||
|
virtual int getPacketNumber(char *buff)=0;
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||||
|
\param data pointer to the memory to be analyzed
|
||||||
|
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||||
|
\param dsize size of the memory slot to be analyzed
|
||||||
|
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||||
|
|
||||||
|
*/
|
||||||
|
virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
|
||||||
|
\param filebin input file stream (binary)
|
||||||
|
\returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete
|
||||||
|
|
||||||
|
*/
|
||||||
|
virtual char *readNextFrame(ifstream &filebin){
|
||||||
|
// int afifo_length=0;
|
||||||
|
uint16_t *afifo_cont;
|
||||||
|
int ib=0;
|
||||||
|
if (filebin.is_open()) {
|
||||||
|
afifo_cont=new uint16_t[dataSize/2];
|
||||||
|
while (filebin.read(((char*)afifo_cont)+ib,2)) {
|
||||||
|
ib+=2;
|
||||||
|
if (ib==dataSize) break;
|
||||||
|
}
|
||||||
|
if (ib>0) {
|
||||||
|
iframe++;
|
||||||
|
//cout << ib/2 << "-" << endl;
|
||||||
|
//for (int i=0; i<ib/2; i++)
|
||||||
|
//cout << i << " " << afifo_cont[i] << endl;
|
||||||
|
return (char*)afifo_cont;
|
||||||
|
} else {
|
||||||
|
delete [] afifo_cont;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -121,6 +121,7 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// int getFrameNumber(char *buff){return *((int*)buff)&0xffffffff;};
|
||||||
int getFrameNumber(char *buff){return *((int*)(buff+5))&0xffffff;};
|
int getFrameNumber(char *buff){return *((int*)(buff+5))&0xffffff;};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -199,7 +200,7 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
|||||||
int nd;
|
int nd;
|
||||||
int fnum = -1;
|
int fnum = -1;
|
||||||
np=0;
|
np=0;
|
||||||
int pn;
|
int pn, po=0;
|
||||||
char aa[8224];
|
char aa[8224];
|
||||||
char *packet=(char *)aa;
|
char *packet=(char *)aa;
|
||||||
// cout << packetSize*nPackets << endl;
|
// cout << packetSize*nPackets << endl;
|
||||||
@ -219,13 +220,14 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
|||||||
|
|
||||||
// cout << "fn: " << fnum << "\t pn: " << pn << endl;
|
// cout << "fn: " << fnum << "\t pn: " << pn << endl;
|
||||||
if (fnum>=0) {
|
if (fnum>=0) {
|
||||||
if (getFrameNumber(packet) !=fnum) {
|
if (getFrameNumber(packet) !=fnum || pn<po) {
|
||||||
|
|
||||||
if (np==0){
|
if (np==0){
|
||||||
// delete [] data;
|
// delete [] data;
|
||||||
return NULL;
|
return NULL;
|
||||||
} else
|
} else
|
||||||
filebin.seekg(-8208,ios_base::cur);
|
filebin.seekg(-8208,ios_base::cur);
|
||||||
|
po =pn;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
if (pn>nPackets) {
|
if (pn>nPackets) {
|
||||||
@ -234,6 +236,7 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
|||||||
|
|
||||||
memcpy(data+(pn-1)*packetSize, packet, packetSize);
|
memcpy(data+(pn-1)*packetSize, packet, packetSize);
|
||||||
np++;
|
np++;
|
||||||
|
po =pn;
|
||||||
|
|
||||||
if (np==nPackets)
|
if (np==nPackets)
|
||||||
break;
|
break;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define MOENCH03T1RECDATANEW_H
|
#define MOENCH03T1RECDATANEW_H
|
||||||
#include "slsDetectorData.h"
|
#include "slsDetectorData.h"
|
||||||
|
|
||||||
|
#define VERSION_V2
|
||||||
/**
|
/**
|
||||||
@short structure for a Detector Packet or Image Header
|
@short structure for a Detector Packet or Image Header
|
||||||
@li frameNumber is the frame number
|
@li frameNumber is the frame number
|
||||||
@ -32,6 +33,10 @@
|
|||||||
uint16_t roundRNumber; /**< is the round robin set number */
|
uint16_t roundRNumber; /**< is the round robin set number */
|
||||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||||
uint8_t version; /**< is the version number of this structure format */
|
uint8_t version; /**< is the version number of this structure format */
|
||||||
|
#ifdef VERSION_V2
|
||||||
|
uint64_t packetCaught[8]; /**< is the version number of this structure format */
|
||||||
|
#endif
|
||||||
|
|
||||||
} sls_detector_header;
|
} sls_detector_header;
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,321 @@
|
|||||||
|
#ifndef MOENCH03T1RECDATANEWRECT_H
|
||||||
|
#define MOENCH03T1RECDATANEWRECT_H
|
||||||
|
#include "slsDetectorData.h"
|
||||||
|
|
||||||
|
#define VERT 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short structure for a Detector Packet or Image Header
|
||||||
|
@li frameNumber is the frame number
|
||||||
|
@li expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||||
|
@li packetNumber is the packet number
|
||||||
|
@li bunchId is the bunch id from beamline
|
||||||
|
@li timestamp is the time stamp with 10 MHz clock
|
||||||
|
@li modId is the unique module id (unique even for left, right, top, bottom)
|
||||||
|
@li xCoord is the x coordinate in the complete detector system
|
||||||
|
@li yCoord is the y coordinate in the complete detector system
|
||||||
|
@li zCoord is the z coordinate in the complete detector system
|
||||||
|
@li debug is for debugging purposes
|
||||||
|
@li roundRNumber is the round robin set number
|
||||||
|
@li detType is the detector type see :: detectorType
|
||||||
|
@li version is the version number of this structure format
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint64_t frameNumber; /**< is the frame number */
|
||||||
|
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
|
||||||
|
uint32_t packetNumber; /**< is the packet number */
|
||||||
|
uint64_t bunchId; /**< is the bunch id from beamline */
|
||||||
|
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||||
|
uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
|
||||||
|
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||||
|
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||||
|
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||||
|
uint32_t debug; /**< is for debugging purposes */
|
||||||
|
uint16_t roundRNumber; /**< is the round robin set number */
|
||||||
|
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||||
|
uint8_t version; /**< is the version number of this structure format */
|
||||||
|
} sls_detector_header;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
int iframe;
|
||||||
|
int nadc;
|
||||||
|
int sc_width;
|
||||||
|
int sc_height;
|
||||||
|
const int nSamples;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||||
|
(160x160 pixels, 40 packets 1286 large etc.)
|
||||||
|
\param c crosstalk parameter for the output buffer
|
||||||
|
|
||||||
|
*/
|
||||||
|
#ifdef HOR
|
||||||
|
moench03T1ReceiverDataNew(int ns=5000): slsDetectorData<uint16_t>(800, 200, ns*2*32+sizeof(sls_detector_header)), nSamples(ns) {
|
||||||
|
#endif
|
||||||
|
#ifdef VERT
|
||||||
|
moench03T1ReceiverDataNew(int ns=5000): slsDetectorData<uint16_t>(200, 800, ns*2*32+sizeof(sls_detector_header)), nSamples(ns) {
|
||||||
|
#endif
|
||||||
|
int nadc=32;
|
||||||
|
int sc_width=25;
|
||||||
|
int sc_height=200;
|
||||||
|
|
||||||
|
int adc_nr[32]={300,325,350,375,300,325,350,375, \
|
||||||
|
200,225,250,275,200,225,250,275,\
|
||||||
|
100,125,150,175,100,125,150,175,\
|
||||||
|
0,25,50,75,0,25,50,75};
|
||||||
|
|
||||||
|
int row, col;
|
||||||
|
|
||||||
|
int isample;
|
||||||
|
int iadc;
|
||||||
|
int ix, iy;
|
||||||
|
|
||||||
|
int npackets=40;
|
||||||
|
int i;
|
||||||
|
int adc4(0);
|
||||||
|
int pix;
|
||||||
|
|
||||||
|
|
||||||
|
int off=0;
|
||||||
|
#ifdef OFF_1
|
||||||
|
off=1;
|
||||||
|
#endif
|
||||||
|
cout << "This is a MOENCH with rectangular pixels!" << endl;
|
||||||
|
|
||||||
|
for (int ip=0; ip<npackets; ip++) {
|
||||||
|
for (int is=0; is<128; is++) {
|
||||||
|
|
||||||
|
for (iadc=0; iadc<nadc; iadc++) {
|
||||||
|
i=128*ip+is;
|
||||||
|
adc4=(int)iadc/4;
|
||||||
|
if (i<sc_width*sc_height) {
|
||||||
|
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||||
|
col=adc_nr[iadc]+(i%sc_width);
|
||||||
|
if (adc4%2==0) {
|
||||||
|
row=199-i/sc_width;
|
||||||
|
} else {
|
||||||
|
row=200+i/sc_width;
|
||||||
|
}
|
||||||
|
pix=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
|
||||||
|
if (pix<0 || pix>=nSamples*2*32+sizeof(sls_detector_header))
|
||||||
|
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||||
|
ix=col;
|
||||||
|
iy=row;
|
||||||
|
#ifdef HOR
|
||||||
|
if (row%2==off) {
|
||||||
|
ix=2*col;
|
||||||
|
iy=row/2;
|
||||||
|
} else {
|
||||||
|
ix=2*col+1;
|
||||||
|
iy=row/2;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef VERT
|
||||||
|
if (col%2==off) {
|
||||||
|
ix=col/2;
|
||||||
|
iy=row*2+1;
|
||||||
|
} else {
|
||||||
|
ix=col/2;
|
||||||
|
iy=row*2;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
dataMap[iy][ix]=pix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* int ipacket; */
|
||||||
|
/* int ibyte; */
|
||||||
|
/* int ii=0; */
|
||||||
|
/* for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){ */
|
||||||
|
/* xmap[ibyte]=-1; */
|
||||||
|
/* ymap[ibyte]=-1; */
|
||||||
|
/* } */
|
||||||
|
/* int off=sizeof(sls_detector_header)/2; */
|
||||||
|
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
|
||||||
|
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
|
||||||
|
/* i=ipacket*8208/2+ibyte; */
|
||||||
|
/* isample=ii/nadc; */
|
||||||
|
/* if (isample<nSamples) { */
|
||||||
|
/* iadc=ii%nadc; */
|
||||||
|
/* adc4 = (int)iadc/4; */
|
||||||
|
/* ix=isample%sc_width; */
|
||||||
|
/* iy=isample/sc_width; */
|
||||||
|
/* if (adc4%2==0) { */
|
||||||
|
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||||
|
/* ymap[i+off]=ny/2-1-iy; */
|
||||||
|
/* } else { */
|
||||||
|
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||||
|
/* ymap[i+off]=ny/2+iy; */
|
||||||
|
/* } */
|
||||||
|
/* } */
|
||||||
|
/* ii++; */
|
||||||
|
/* // } */
|
||||||
|
/* } */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
iframe=0;
|
||||||
|
// cout << "data struct created" << endl;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
Returns the frame number for the given dataset. Purely virtual func.
|
||||||
|
\param buff pointer to the dataset
|
||||||
|
\returns frame number
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* class jfrau_packet_header_t { */
|
||||||
|
/* public: */
|
||||||
|
/* unsigned char reserved[4]; */
|
||||||
|
/* unsigned char packetNumber[1]; */
|
||||||
|
/* unsigned char frameNumber[3]; */
|
||||||
|
/* unsigned char bunchid[8]; */
|
||||||
|
/* }; */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int getFrameNumber(char *buff){return ((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
Returns the packet number for the given dataset. purely virtual func
|
||||||
|
\param buff pointer to the dataset
|
||||||
|
\returns packet number number
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||||
|
|
||||||
|
/* /\** */
|
||||||
|
|
||||||
|
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||||
|
/* \param data pointer to the memory to be analyzed */
|
||||||
|
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||||
|
/* \param dsize size of the memory slot to be analyzed */
|
||||||
|
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||||
|
|
||||||
|
/* *\/ */
|
||||||
|
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||||
|
|
||||||
|
|
||||||
|
/* /\** */
|
||||||
|
|
||||||
|
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||||
|
/* \param filebin input file stream (binary) */
|
||||||
|
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||||
|
|
||||||
|
/* *\/ */
|
||||||
|
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||||
|
/* // int afifo_length=0; */
|
||||||
|
/* uint16_t *afifo_cont; */
|
||||||
|
/* int ib=0; */
|
||||||
|
/* if (filebin.is_open()) { */
|
||||||
|
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||||
|
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||||
|
/* ib+=2; */
|
||||||
|
/* if (ib==dataSize) break; */
|
||||||
|
/* } */
|
||||||
|
/* if (ib>0) { */
|
||||||
|
/* iframe++; */
|
||||||
|
/* // cout << ib << "-" << endl; */
|
||||||
|
/* return (char*)afifo_cont; */
|
||||||
|
/* } else { */
|
||||||
|
/* delete [] afifo_cont; */
|
||||||
|
/* return NULL; */
|
||||||
|
/* } */
|
||||||
|
/* } */
|
||||||
|
/* return NULL; */
|
||||||
|
/* }; */
|
||||||
|
|
||||||
|
|
||||||
|
virtual char *readNextFrame(ifstream &filebin) {
|
||||||
|
int ff=-1, np=-1;
|
||||||
|
return readNextFrame(filebin, ff, np);
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||||
|
int np=-1;
|
||||||
|
return readNextFrame(filebin, ff, np);
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||||
|
char *data=new char[dataSize];
|
||||||
|
char *d=readNextFrame(filebin, ff, np, data);
|
||||||
|
if (d==NULL) {delete [] data; data=NULL;}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||||
|
char *retval=0;
|
||||||
|
int nd;
|
||||||
|
int fnum = -1;
|
||||||
|
np=0;
|
||||||
|
int pn;
|
||||||
|
|
||||||
|
// cout << dataSize << endl;
|
||||||
|
if (ff>=0)
|
||||||
|
fnum=ff;
|
||||||
|
|
||||||
|
if (filebin.is_open()) {
|
||||||
|
if (filebin.read(data, dataSize) ){
|
||||||
|
ff=getFrameNumber(data);
|
||||||
|
np=getPacketNumber(data);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||||
|
\param data pointer to the memory to be analyzed
|
||||||
|
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||||
|
\param dsize size of the memory slot to be analyzed
|
||||||
|
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||||
|
|
||||||
|
*/
|
||||||
|
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||||
|
if (dsize<dataSize) ndata=dsize;
|
||||||
|
else ndata=dataSize;
|
||||||
|
return data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -3,16 +3,16 @@
|
|||||||
#include "slsDetectorData.h"
|
#include "slsDetectorData.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int iframe;
|
// int iframe;
|
||||||
int nadc;
|
int nadc;
|
||||||
int sc_width;
|
int sc_width;
|
||||||
int sc_height;
|
int sc_height;
|
||||||
const int nSamples;
|
const int nSamples;
|
||||||
|
const int offset;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
|||||||
\param c crosstalk parameter for the output buffer
|
\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 nadc=32;
|
||||||
int sc_width=25;
|
int sc_width=25;
|
||||||
@ -60,25 +60,23 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
|||||||
} else {
|
} else {
|
||||||
row=200+i/sc_width;
|
row=200+i/sc_width;
|
||||||
}
|
}
|
||||||
dataMap[row][col]=(nadc*i+iadc)*2;//+16*(ip+1);
|
dataMap[row][col]=(nadc*i+iadc)*2+offset;//+16*(ip+1);
|
||||||
if (dataMap[row][col]<0 || dataMap[row][col]>=nSamples*2*32)
|
if (dataMap[row][col]<0 || dataMap[row][col]>=dataSize)
|
||||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ipacket;
|
|
||||||
int ibyte;
|
|
||||||
int ii=0;
|
int ii=0;
|
||||||
for (int ipacket=0; ipacket<npackets; ipacket++) {
|
|
||||||
for (int ibyte=0; ibyte< 8192/2; ibyte++) {
|
for (i=0; i< dataSize; i++) {
|
||||||
i=ipacket*8208/2+ibyte;
|
if (i<offset) {
|
||||||
/* if (ibyte<8) { */
|
//header! */
|
||||||
/* //header! */
|
xmap[i]=-1;
|
||||||
/* xmap[i]=-1; */
|
ymap[i]=-1;
|
||||||
/* ymap[i]=-1; */
|
} else {
|
||||||
/* } else { */
|
|
||||||
// ii=ibyte+128*32*ipacket;
|
// ii=ibyte+128*32*ipacket;
|
||||||
isample=ii/nadc;
|
isample=ii/nadc;
|
||||||
if (isample<nSamples) {
|
if (isample<nSamples) {
|
||||||
@ -96,14 +94,14 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ii++;
|
ii++;
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
iframe=0;
|
// iframe=0;
|
||||||
// cout << "data struct created" << endl;
|
// cout << "data struct created" << endl;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -127,7 +125,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int getFrameNumber(char *buff){return iframe;};//*((int*)(buff+5))&0xffffff;};
|
int getFrameNumber(char *buff){return *((int*)buff);};//*((int*)(buff+5))&0xffffff;};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@ -215,8 +213,8 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
|||||||
|
|
||||||
if (filebin.is_open()) {
|
if (filebin.is_open()) {
|
||||||
if (filebin.read(data, 32*2*nSamples) ){
|
if (filebin.read(data, 32*2*nSamples) ){
|
||||||
iframe++;
|
// iframe++;
|
||||||
ff=iframe;
|
//ff=iframe;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,6 +247,8 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// virtual int setFrameNumber(int ff){iframe=ff};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,19 +49,21 @@ class interpolatingDetector : public singlePhotonDetector {
|
|||||||
int nd=100, int nnx=-1, int nny=-1) :
|
int nd=100, int nnx=-1, int nny=-1) :
|
||||||
singlePhotonDetector(d, 3,nsigma,sign, cm, nped, nd, nnx, nny) , interp(inte), id(0) {
|
singlePhotonDetector(d, 3,nsigma,sign, cm, nped, nd, nnx, nny) , interp(inte), id(0) {
|
||||||
//cout << "**"<< xmin << " " << xmax << " " << ymin << " " << ymax << endl;
|
//cout << "**"<< xmin << " " << xmax << " " << ymin << " " << ymax << endl;
|
||||||
|
fi=new pthread_mutex_t ;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
interpolatingDetector(interpolatingDetector *orig) : singlePhotonDetector(orig) {
|
interpolatingDetector(interpolatingDetector *orig) : singlePhotonDetector(orig) {
|
||||||
interp=(orig->interp)->Clone();
|
// if (orig->interp)
|
||||||
id=orig->id;
|
// interp=(orig->interp)->Clone();
|
||||||
/* xmin=orig->xmin; */
|
// else
|
||||||
/* xmax=orig->xmax; */
|
|
||||||
/* ymin=orig->ymin; */
|
|
||||||
/* ymax=orig->ymax; */
|
|
||||||
|
|
||||||
|
interp=orig->interp;
|
||||||
|
|
||||||
|
id=orig->id;
|
||||||
|
fi=orig->fi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -69,29 +71,50 @@ class interpolatingDetector : public singlePhotonDetector {
|
|||||||
return new interpolatingDetector(this);
|
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) {
|
virtual void prepareInterpolation(int &ok) {
|
||||||
cout << "*"<< endl;
|
/* cout << "*"<< endl; */
|
||||||
#ifdef SAVE_ALL
|
/* #ifdef SAVE_ALL */
|
||||||
char tit[1000];
|
/* char tit[1000]; */
|
||||||
sprintf(tit,"/scratch/ped_%d.tiff",id);
|
/* sprintf(tit,"/scratch/ped_%d.tiff",id); */
|
||||||
writePedestals(tit);
|
/* writePedestals(tit); */
|
||||||
sprintf(tit,"/scratch/ped_rms_%d.tiff",id);
|
/* sprintf(tit,"/scratch/ped_rms_%d.tiff",id); */
|
||||||
writePedestalRMS(tit);
|
/* writePedestalRMS(tit); */
|
||||||
if (gmap) {
|
/* if (gmap) { */
|
||||||
sprintf(tit,"/scratch/gmap_%d.tiff",id);
|
/* sprintf(tit,"/scratch/gmap_%d.tiff",id); */
|
||||||
writeGainMap(tit);
|
/* writeGainMap(tit); */
|
||||||
}
|
/* } */
|
||||||
#endif
|
/* #endif */
|
||||||
if (interp)
|
if (interp){
|
||||||
|
pthread_mutex_lock(fi);
|
||||||
interp->prepareInterpolation(ok);
|
interp->prepareInterpolation(ok);
|
||||||
|
pthread_mutex_unlock(fi);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void clearImage() {if (interp) interp->clearInterpolatedImage(); else singlePhotonDetector::clearImage();};
|
void clearImage() {
|
||||||
|
if (interp) {
|
||||||
|
pthread_mutex_lock(fi);
|
||||||
|
interp->clearInterpolatedImage();
|
||||||
|
pthread_mutex_unlock(fi);
|
||||||
|
} else
|
||||||
|
singlePhotonDetector::clearImage();
|
||||||
|
};
|
||||||
|
|
||||||
|
int getImageSize(int &nnx, int &nny, int &ns) {
|
||||||
|
if (interp)
|
||||||
|
return interp->getImageSize(nnx, nny, ns);
|
||||||
|
else
|
||||||
|
return analogDetector<uint16_t>::getImageSize(nnx, nny, ns);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
int getImageSize(int &nnx, int &nny, int &ns) {if (interp) return interp->getImageSize(nnx, nny, ns); else return analogDetector<uint16_t>::getImageSize(nnx, nny, ns);};
|
|
||||||
#ifdef MYROOT1
|
#ifdef MYROOT1
|
||||||
virtual TH2F *getImage()
|
virtual TH2F *getImage()
|
||||||
#endif
|
#endif
|
||||||
@ -104,7 +127,6 @@ class interpolatingDetector : public singlePhotonDetector {
|
|||||||
return interp->getInterpolatedImage();
|
return interp->getInterpolatedImage();
|
||||||
else
|
else
|
||||||
return analogDetector<uint16_t>::getImage();
|
return analogDetector<uint16_t>::getImage();
|
||||||
//cout << "null " << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MYROOT1
|
#ifdef MYROOT1
|
||||||
@ -146,504 +168,104 @@ class interpolatingDetector : public singlePhotonDetector {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int addFrame(char *data, int *ph=NULL, int ff=0) {
|
int addFrame(char *data, int *ph=NULL, int ff=0) {
|
||||||
|
|
||||||
|
singlePhotonDetector::processData(data,ph);
|
||||||
int nph=0;
|
int nph=0;
|
||||||
double val[ny][nx];
|
|
||||||
int cy=(clusterSizeY+1)/2;
|
|
||||||
int cs=(clusterSize+1)/2;
|
|
||||||
int ir, ic;
|
|
||||||
double rms;
|
|
||||||
double int_x,int_y, eta_x, eta_y;
|
|
||||||
double max=0, tl=0, tr=0, bl=0,br=0, *v, vv;
|
|
||||||
// cout << "********** Add frame "<< iframe << endl;
|
|
||||||
if (ph==NULL)
|
|
||||||
ph=image;
|
|
||||||
|
|
||||||
if (iframe<nDark) {
|
|
||||||
addToPedestal(data);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
newFrame();
|
|
||||||
// cout << "********** Data "<< endl;
|
|
||||||
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;
|
|
||||||
|
|
||||||
rms=getPedestalRMS(ix,iy);
|
|
||||||
(clusters+nph)->rms=rms;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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*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*rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
double int_x, int_y;
|
||||||
|
double eta_x, eta_y;
|
||||||
if (interp) {
|
if (interp) {
|
||||||
|
// cout << "int" << endl;
|
||||||
|
pthread_mutex_lock(fi);
|
||||||
|
for (nph=0; nph<nphFrame; nph++) {
|
||||||
if (ff) {
|
if (ff) {
|
||||||
interp->addToFlatField((clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),eta_x, eta_y);
|
interp->addToFlatField((clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),eta_x, eta_y);
|
||||||
} else {
|
} else {
|
||||||
interp->getInterpolatedPosition(ix, iy, (clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),int_x, int_y);
|
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);
|
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) {
|
pthread_mutex_unlock(fi);
|
||||||
addToPedestal(data,ix,iy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nphFrame=nph;
|
|
||||||
nphTot+=nph;
|
|
||||||
//cout << nphFrame << endl;
|
|
||||||
// cout <<"**********************************"<< endl;
|
|
||||||
writeClusters();
|
|
||||||
return nphFrame;
|
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) {
|
virtual void processData(char *data, int *val=NULL) {
|
||||||
if (interp){
|
switch (dMode) {
|
||||||
|
case eAnalog:
|
||||||
|
// cout << "an" << endl;
|
||||||
|
analogDetector<uint16_t>::processData(data,val);
|
||||||
|
break;
|
||||||
|
case ePhotonCounting:
|
||||||
|
// cout << "spc" << endl;
|
||||||
|
singlePhotonDetector::processData(data,val);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//cout << "int" << endl;
|
||||||
switch(fMode) {
|
switch(fMode) {
|
||||||
case ePedestal:
|
case ePedestal:
|
||||||
addToPedestal(data);
|
addToPedestal(data);
|
||||||
break;
|
break;
|
||||||
case eFlat:
|
case eFlat:
|
||||||
|
if (interp)
|
||||||
addFrame(data,val,1);
|
addFrame(data,val,1);
|
||||||
|
else
|
||||||
|
singlePhotonDetector::processData(data,val);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if (interp)
|
||||||
addFrame(data,val,0);
|
addFrame(data,val,0);
|
||||||
}
|
else
|
||||||
} else
|
|
||||||
singlePhotonDetector::processData(data,val);
|
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:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
slsInterpolation *interp;
|
slsInterpolation *interp;
|
||||||
int id;
|
int id;
|
||||||
|
pthread_mutex_t *fi;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,49 +14,18 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
|||||||
|
|
||||||
public:
|
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) {
|
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) {
|
/* if (etamin>=etamax) { */
|
||||||
nbeta=nSubPixels*10;
|
/* etamin=-1; */
|
||||||
}
|
/* etamax=2; */
|
||||||
if (etamin>=etamax) {
|
/* // cout << ":" <<endl; */
|
||||||
etamin=-1;
|
/* } */
|
||||||
etamax=2;
|
/* etastep=(etamax-etamin)/nbeta; */
|
||||||
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];
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// cout << nbeta << " " << etamin << " " << etamax << endl;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
eta2InterpolationBase(eta2InterpolationBase *orig): etaInterpolationBase(orig){ };
|
eta2InterpolationBase(eta2InterpolationBase *orig): etaInterpolationBase(orig){ };
|
||||||
|
|
||||||
virtual eta2InterpolationBase* Clone()=0;/* {
|
|
||||||
|
|
||||||
return new eta2InterpolationBase(this);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//////////// /*It return position hit for the event in input */ //////////////
|
//////////// /*It return position hit for the event in input */ //////////////
|
||||||
@ -102,12 +71,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
|||||||
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) {
|
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) {
|
||||||
|
|
||||||
double cc[2][2];
|
double cc[2][2];
|
||||||
double *cluster[3];
|
|
||||||
int xoff, yoff;
|
int xoff, yoff;
|
||||||
cluster[0]=cl;
|
|
||||||
cluster[1]=cl+3;
|
|
||||||
cluster[2]=cl+6;
|
|
||||||
|
|
||||||
switch (quad) {
|
switch (quad) {
|
||||||
case BOTTOM_LEFT:
|
case BOTTOM_LEFT:
|
||||||
xoff=0;
|
xoff=0;
|
||||||
@ -130,10 +94,10 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
|||||||
}
|
}
|
||||||
double etax, etay;
|
double etax, etay;
|
||||||
if (nSubPixels>2) {
|
if (nSubPixels>2) {
|
||||||
cc[0][0]=cluster[yoff][xoff];
|
cc[0][0]=cl[xoff+3*yoff];
|
||||||
cc[1][0]=cluster[yoff+1][xoff];
|
cc[1][0]=cl[xoff+3*(yoff+1)];
|
||||||
cc[0][1]=cluster[yoff][xoff+1];
|
cc[0][1]=cl[xoff+1+3*yoff];
|
||||||
cc[1][1]=cluster[yoff+1][xoff+1];
|
cc[1][1]=cl[xoff+1+3*(yoff+1)];
|
||||||
calcEta(totquad,cc,etax,etay);
|
calcEta(totquad,cc,etax,etay);
|
||||||
}
|
}
|
||||||
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
|
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
|
||||||
@ -145,11 +109,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
|||||||
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) {
|
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) {
|
||||||
|
|
||||||
double cc[2][2];
|
double cc[2][2];
|
||||||
int *cluster[3];
|
|
||||||
int xoff, yoff;
|
int xoff, yoff;
|
||||||
cluster[0]=cl;
|
|
||||||
cluster[1]=cl+3;
|
|
||||||
cluster[2]=cl+6;
|
|
||||||
|
|
||||||
switch (quad) {
|
switch (quad) {
|
||||||
case BOTTOM_LEFT:
|
case BOTTOM_LEFT:
|
||||||
@ -173,10 +133,10 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
|||||||
}
|
}
|
||||||
double etax, etay;
|
double etax, etay;
|
||||||
if (nSubPixels>2) {
|
if (nSubPixels>2) {
|
||||||
cc[0][0]=cluster[yoff][xoff];
|
cc[0][0]=cl[xoff+3*yoff];
|
||||||
cc[1][0]=cluster[yoff+1][xoff];
|
cc[1][0]=cl[xoff+3*(yoff+1)];
|
||||||
cc[0][1]=cluster[yoff][xoff+1];
|
cc[0][1]=cl[xoff+1+3*yoff];
|
||||||
cc[1][1]=cluster[yoff+1][xoff+1];
|
cc[1][1]=cl[xoff+1+3*(xoff+1)];
|
||||||
calcEta(totquad,cc,etax,etay);
|
calcEta(totquad,cc,etax,etay);
|
||||||
}
|
}
|
||||||
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
|
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
|
||||||
@ -223,11 +183,6 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
|||||||
|
|
||||||
if (nSubPixels>2) {
|
if (nSubPixels>2) {
|
||||||
|
|
||||||
#ifdef MYROOT1
|
|
||||||
xpos_eta=(hhx->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels);
|
|
||||||
ypos_eta=(hhy->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels);
|
|
||||||
#endif
|
|
||||||
#ifndef MYROOT1
|
|
||||||
ex=(etax-etamin)/etastep;
|
ex=(etax-etamin)/etastep;
|
||||||
ey=(etay-etamin)/etastep;
|
ey=(etay-etamin)/etastep;
|
||||||
if (ex<0) {
|
if (ex<0) {
|
||||||
@ -237,7 +192,6 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
|||||||
if (ex>=nbeta) {
|
if (ex>=nbeta) {
|
||||||
cout << "x?"<< ex << endl;
|
cout << "x?"<< ex << endl;
|
||||||
ex=nbeta-1;
|
ex=nbeta-1;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (ey<0) {
|
if (ey<0) {
|
||||||
cout << "y*"<< ey << endl;
|
cout << "y*"<< ey << endl;
|
||||||
@ -246,17 +200,13 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
|||||||
if (ey>=nbeta) {
|
if (ey>=nbeta) {
|
||||||
cout << "y?"<< ey << endl;
|
cout << "y?"<< ey << endl;
|
||||||
ey=nbeta-1;
|
ey=nbeta-1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
xpos_eta=(((double)hhx[(ey*nbeta+ex)]))+dX ;///((double)nSubPixels);
|
xpos_eta=(((double)hhx[(ey*nbeta+ex)]))+dX ;///((double)nSubPixels);
|
||||||
ypos_eta=(((double)hhy[(ey*nbeta+ex)]))+dY ;///((double)nSubPixels);
|
ypos_eta=(((double)hhy[(ey*nbeta+ex)]))+dY ;///((double)nSubPixels);
|
||||||
//else
|
|
||||||
//return 0;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
xpos_eta=0.5*dX+0.25;
|
xpos_eta=0.5*dX+0.25;
|
||||||
ypos_eta=0.5*dY+0.25;
|
ypos_eta=0.5*dY+0.25;
|
||||||
@ -272,11 +222,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
|||||||
|
|
||||||
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];
|
double cc[2][2];
|
||||||
int *cluster[3];
|
|
||||||
int xoff, yoff;
|
int xoff, yoff;
|
||||||
cluster[0]=cl;
|
|
||||||
cluster[1]=cl+3;
|
|
||||||
cluster[2]=cl+6;
|
|
||||||
|
|
||||||
switch (quad) {
|
switch (quad) {
|
||||||
case BOTTOM_LEFT:
|
case BOTTOM_LEFT:
|
||||||
@ -298,17 +244,11 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
|||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
cc[0][0]=cluster[yoff][xoff];
|
cc[0][0]=cl[xoff+3*yoff];
|
||||||
cc[1][0]=cluster[yoff+1][xoff];
|
cc[1][0]=cl[xoff+3*(yoff+1)];
|
||||||
cc[0][1]=cluster[yoff][xoff+1];
|
cc[0][1]=cl[xoff+1+3*yoff];
|
||||||
cc[1][1]=cluster[yoff+1][xoff+1];
|
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);
|
//calcMyEta(totquad,quad,cl,etax, etay);
|
||||||
calcEta(totquad, cc,etax, etay);
|
calcEta(totquad, cc,etax, etay);
|
||||||
|
|
||||||
@ -320,11 +260,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
|||||||
|
|
||||||
virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) {
|
virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) {
|
||||||
double cc[2][2];
|
double cc[2][2];
|
||||||
double *cluster[3];
|
|
||||||
int xoff, yoff;
|
int xoff, yoff;
|
||||||
cluster[0]=cl;
|
|
||||||
cluster[1]=cl+3;
|
|
||||||
cluster[2]=cl+6;
|
|
||||||
|
|
||||||
switch (quad) {
|
switch (quad) {
|
||||||
case BOTTOM_LEFT:
|
case BOTTOM_LEFT:
|
||||||
@ -346,10 +282,10 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
|||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
cc[0][0]=cluster[yoff][xoff];
|
cc[0][0]=cl[xoff+3*yoff];
|
||||||
cc[1][0]=cluster[yoff+1][xoff];
|
cc[1][0]=cl[(yoff+1)*3+xoff];
|
||||||
cc[0][1]=cluster[yoff][xoff+1];
|
cc[0][1]=cl[yoff*3+xoff+1];
|
||||||
cc[1][1]=cluster[yoff+1][xoff+1];
|
cc[1][1]=cl[(yoff+1)*3+xoff+1];
|
||||||
|
|
||||||
/* cout << cl[0] << " " << cl[1] << " " << cl[2] << endl; */
|
/* cout << cl[0] << " " << cl[1] << " " << cl[2] << endl; */
|
||||||
/* cout << cl[3] << " " << cl[4] << " " << cl[5] << endl; */
|
/* cout << cl[3] << " " << cl[4] << " " << cl[5] << endl; */
|
||||||
@ -416,6 +352,37 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
virtual int *getInterpolatedImage(){
|
||||||
|
int ipx, ipy;
|
||||||
|
// cout << "ff" << endl;
|
||||||
|
calcDiff(1, hhx, hhy); //get flat
|
||||||
|
double avg=0;
|
||||||
|
for (ipx=0; ipx<nSubPixels; ipx++)
|
||||||
|
for (ipy=0; ipy<nSubPixels; ipy++)
|
||||||
|
avg+=flat[ipx+ipy*nSubPixels];
|
||||||
|
avg/=nSubPixels*nSubPixels;
|
||||||
|
|
||||||
|
for (int ibx=0 ; ibx<nSubPixels*nPixelsX; ibx++) {
|
||||||
|
ipx=ibx%nSubPixels-nSubPixels/2;
|
||||||
|
if (ipx<0) ipx=nSubPixels+ipx;
|
||||||
|
for (int iby=0 ; iby<nSubPixels*nPixelsY; iby++) {
|
||||||
|
ipy=iby%nSubPixels-nSubPixels/2;
|
||||||
|
if (ipy<0) ipy=nSubPixels+ipy;
|
||||||
|
// cout << ipx << " " << ipy << " " << ibx << " " << iby << endl;
|
||||||
|
if (flat[ipx+ipy*nSubPixels]>0)
|
||||||
|
hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX]*(avg/flat[ipx+ipy*nSubPixels]);
|
||||||
|
else
|
||||||
|
hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return hintcorr;
|
||||||
|
};
|
||||||
|
|
||||||
/* protected: */
|
/* protected: */
|
||||||
|
|
||||||
/* #ifdef MYROOT1 */
|
/* #ifdef MYROOT1 */
|
||||||
|
@ -15,9 +15,9 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
|
|||||||
public:
|
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 nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx, ny, ns, nb, emin, emax) {
|
||||||
// cout << "e3ib " << nb << " " << emin << " " << emax << endl;
|
// cout << "e3ib " << nb << " " << emin << " " << emax << endl;
|
||||||
if (nbeta<=0) {
|
/* if (nbeta<=0) { */
|
||||||
nbeta=nSubPixels*10;
|
/* nbeta=nSubPixels*10; */
|
||||||
}
|
/* } */
|
||||||
if (etamin>=etamax) {
|
if (etamin>=etamax) {
|
||||||
etamin=-1;
|
etamin=-1;
|
||||||
etamax=1;
|
etamax=1;
|
||||||
@ -33,13 +33,13 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
|
|||||||
hhy=new TH2D("hhy","hhy",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
hhy=new TH2D("hhy","hhy",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||||
#endif
|
#endif
|
||||||
#ifndef MYROOT1
|
#ifndef MYROOT1
|
||||||
delete [] heta;
|
/* delete [] heta; */
|
||||||
delete [] hhx;
|
/* delete [] hhx; */
|
||||||
delete [] hhy;
|
/* delete [] hhy; */
|
||||||
|
|
||||||
heta=new int[nbeta*nbeta];
|
/* heta=new int[nbeta*nbeta]; */
|
||||||
hhx=new float[nbeta*nbeta];
|
/* hhx=new float[nbeta*nbeta]; */
|
||||||
hhy=new float[nbeta*nbeta];
|
/* hhy=new float[nbeta*nbeta]; */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// cout << nbeta << " " << etamin << " " << etamax << endl;
|
// cout << nbeta << " " << etamin << " " << etamax << endl;
|
||||||
@ -47,7 +47,7 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
|
|||||||
|
|
||||||
eta3InterpolationBase(eta3InterpolationBase *orig): etaInterpolationBase(orig){ };
|
eta3InterpolationBase(eta3InterpolationBase *orig): etaInterpolationBase(orig){ };
|
||||||
|
|
||||||
virtual eta3InterpolationBase* Clone()=0;
|
/* virtual eta3InterpolationBase* Clone()=0; */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,131 +1,137 @@
|
|||||||
#ifndef ETA_INTERPOLATION_ADAPTIVEBINS_H
|
#ifndef ETA_INTERPOLATION_ADAPTIVEBINS_H
|
||||||
#define ETA_INTERPOLATION_ADAPTIVEBINS_H
|
#define ETA_INTERPOLATION_ADAPTIVEBINS_H
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include "tiffIO.h"
|
#include "tiffIO.h"
|
||||||
//#include "etaInterpolationBase.h"
|
//#include "etaInterpolationBase.h"
|
||||||
#include "etaInterpolationPosXY.h"
|
#include "etaInterpolationPosXY.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class etaInterpolationAdaptiveBins : public etaInterpolationPosXY {
|
class etaInterpolationAdaptiveBins : public etaInterpolationPosXY {
|
||||||
|
|
||||||
|
// protected:
|
||||||
|
|
||||||
|
|
||||||
private:
|
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++) {
|
virtual void iterate(float *newhhx, float *newhhy) {
|
||||||
for (int ipy=0; ipy<nSubPixels; ipy++) {
|
|
||||||
p_tot=0;
|
|
||||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
|
||||||
for (int iby=0; iby<nbeta; iby++) {
|
|
||||||
if ( hx[ibx+iby*nbeta]>=((ipx)*bsize) && hx[ibx+iby*nbeta]<((ipx+1)*bsize) && hy[ibx+iby*nbeta]>=((ipy)*bsize) && hy[ibx+iby*nbeta]<((ipy+1)*bsize)) {
|
|
||||||
p_tot+=heta[ibx+iby*nbeta];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cout << p_tot << " \t ";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
diff+=(p_tot-avg)*(p_tot-avg);
|
|
||||||
|
|
||||||
}
|
|
||||||
cout << "\n";
|
|
||||||
}
|
|
||||||
return diff;
|
|
||||||
}
|
|
||||||
|
|
||||||
void iterate(float *newhhx, float *newhhy) {
|
|
||||||
|
|
||||||
double bsize=1./nSubPixels;
|
double bsize=1./nSubPixels;
|
||||||
|
|
||||||
double hy[nbeta]; //profile y
|
double hy[nSubPixels][nbeta]; //profile y
|
||||||
double hx[nbeta]; //profile x
|
double hx[nSubPixels][nbeta]; //profile x
|
||||||
double hix[nbeta]; //integral of projection x
|
double hix[nSubPixels][nbeta]; //integral of projection x
|
||||||
double hiy[nbeta]; //integral of projection y
|
double hiy[nSubPixels][nbeta]; //integral of projection y
|
||||||
|
int ipy, ipx;
|
||||||
double tot_eta_x=0;
|
double tot_eta_x[nSubPixels];
|
||||||
double tot_eta_y=0;
|
double tot_eta_y[nSubPixels];
|
||||||
for (int ipy=0; ipy<nSubPixels; ipy++) {
|
//for (int ipy=0; ipy<nSubPixels; ipy++) {
|
||||||
|
|
||||||
|
for (ipy=0; ipy<nSubPixels; ipy++) {
|
||||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||||
hx[ibx]=0;
|
hx[ipy][ibx]=0;
|
||||||
hy[ibx]=0;
|
hy[ipy][ibx]=0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tot_eta_x=0;
|
|
||||||
tot_eta_y=0;
|
|
||||||
// cout << ipy << " " << ((ipy)*bsize) << " " << ((ipy+1)*bsize) << endl;
|
// cout << ipy << " " << ((ipy)*bsize) << " " << ((ipy+1)*bsize) << endl;
|
||||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||||
for (int iby=0; iby<nbeta; iby++) {
|
for (int iby=0; iby<nbeta; iby++) {
|
||||||
|
ipy=hhy[ibx+iby*nbeta]*nSubPixels;
|
||||||
if (hhy[ibx+iby*nbeta]>=((ipy)*bsize) && hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
if (ipy<0) ipy=0;
|
||||||
hx[ibx]+=heta[ibx+iby*nbeta];
|
if (ipy>=nSubPixels) ipy=nSubPixels-1;
|
||||||
tot_eta_x+=heta[ibx+iby*nbeta];
|
hx[ipy][ibx]+=heta[ibx+iby*nbeta];
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (hhx[ibx+iby*nbeta]>=((ipy)*bsize) && hhx[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
ipx=hhx[ibx+iby*nbeta]*nSubPixels;
|
||||||
hy[iby]+=heta[ibx+iby*nbeta];
|
if (ipx<0) ipx=0;
|
||||||
tot_eta_y+=heta[ibx+iby*nbeta];
|
if (ipx>=nSubPixels) ipx=nSubPixels-1;
|
||||||
}
|
hy[ipx][iby]+=heta[ibx+iby*nbeta];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
hix[0]=hx[0];
|
|
||||||
hiy[0]=hy[0];
|
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++) {
|
for (int ib=1; ib<nbeta; ib++) {
|
||||||
hix[ib]=hix[ib-1]+hx[ib];
|
hix[ipy][ib]=hix[ipy][ib-1]+hx[ipy][ib];
|
||||||
hiy[ib]=hiy[ib-1]+hy[ib];
|
hiy[ipy][ib]=hiy[ipy][ib-1]+hy[ipy][ib];
|
||||||
}
|
}
|
||||||
// tot_eta_x=hix[nbeta-1];
|
tot_eta_x[ipy]=hix[ipy][nbeta-1]+1;
|
||||||
// tot_eta_y=hiy[nbeta-1];
|
tot_eta_y[ipy]=hiy[ipy][nbeta-1]+1;
|
||||||
/* cout << "ipx " << ipy << " x: " << tot_eta_x << " " << hix[10]<< " " << hix[nbeta-1] << endl; */
|
// cout << ipy << " " << tot_eta_x[ipy] << " " << tot_eta_y[ipy] << 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 ibx=0; ibx<nbeta; ibx++) {
|
||||||
for (int iby=0; iby<nbeta; iby++) {
|
for (int iby=0; iby<nbeta; iby++) {
|
||||||
|
|
||||||
if ( hhy[ibx+iby*nbeta]>=((ipy)*bsize) && hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
// if ( hhy[ibx+iby*nbeta]>=((ipy)*bsize) && hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
||||||
newhhx[ibx+iby*nbeta]=hix[ibx]/((double)tot_eta_x);
|
ipy=hhy[ibx+iby*nbeta]*nSubPixels;
|
||||||
if (newhhx[ibx+iby*nbeta]>1) cout << "***"<< ibx << " " << iby << newhhx[ibx+iby*nbeta] << endl;
|
|
||||||
|
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 (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)) {
|
ipy=hhx[ibx+iby*nbeta]*nSubPixels;
|
||||||
newhhy[ibx+iby*nbeta]=hiy[iby]/((double)tot_eta_y);
|
//if (hhx[ibx+iby*nbeta]>=((ipy)*bsize) && hhx[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
||||||
if (newhhy[ibx+iby*nbeta]>1) cout << "***"<< ibx << " " << iby << newhhy[ibx+iby*nbeta] << endl;
|
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;
|
// if (ipy==3 && iby==10) cout << newhhy[ibx+iby*nbeta] << " " << hiy[iby] << " " << ibx+iby*nbeta << endl;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public:
|
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];
|
||||||
etaInterpolationAdaptiveBins(etaInterpolationAdaptiveBins *orig): etaInterpolationPosXY(orig){};
|
// flat=new double[nSubPixels*nSubPixels];
|
||||||
|
|
||||||
virtual etaInterpolationAdaptiveBins* Clone() {
|
|
||||||
|
|
||||||
return new etaInterpolationAdaptiveBins(this);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
etaInterpolationAdaptiveBins(etaInterpolationAdaptiveBins *orig): etaInterpolationPosXY(orig){hintcorr=new int[nPixelsX*nPixelsY*nSubPixels];};
|
||||||
|
|
||||||
|
virtual etaInterpolationAdaptiveBins* Clone()=0;
|
||||||
|
|
||||||
|
/* 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;
|
ok=1;
|
||||||
cout << "Adaptive bins" << endl;
|
|
||||||
|
|
||||||
///*Eta Distribution Rebinning*///
|
///*Eta Distribution Rebinning*///
|
||||||
double bsize=1./nSubPixels; //precision
|
double bsize=1./nSubPixels; //precision
|
||||||
@ -155,63 +161,34 @@ 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 thr=1./((double)nSubPixels);
|
||||||
double avg=tot_eta/((double)(nSubPixels*nSubPixels));
|
double avg=tot_eta/((double)(nSubPixels*nSubPixels));
|
||||||
cout << "total eta entries is :"<< tot_eta << " avg: "<< avg << endl;
|
double rms=sqrt(tot_eta);
|
||||||
cout << "Start " << endl;
|
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;
|
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;
|
int iint=0;
|
||||||
float *newhhx=new float[nbeta*nbeta]; //profile x
|
float *newhhx=new float[nbeta*nbeta]; //profile x
|
||||||
float *newhhy=new float[nbeta*nbeta]; //profile y
|
float *newhhy=new float[nbeta*nbeta]; //profile y
|
||||||
float *besthhx=hhx; //profile x
|
float *besthhx=hhx; //profile x
|
||||||
float *besthhy=hhy; //profile y
|
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);
|
iterate(newhhx,newhhy);
|
||||||
new_diff=calcDiff(avg, newhhx, newhhy);
|
new_diff=calcDiff(avg, newhhx, newhhy);
|
||||||
cout << " diff= " << new_diff << endl;
|
// cout << " chi2= " << new_diff << " (rms= " << sqrt(tot_eta) << ")"<<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 */
|
|
||||||
if (new_diff<best_diff) {
|
if (new_diff<best_diff) {
|
||||||
best_diff=new_diff;
|
best_diff=new_diff;
|
||||||
besthhx=newhhx;
|
besthhx=newhhx;
|
||||||
@ -225,16 +202,30 @@ class etaInterpolationAdaptiveBins : public etaInterpolationPosXY {
|
|||||||
|
|
||||||
hhx=newhhx;
|
hhx=newhhx;
|
||||||
hhy=newhhy;
|
hhy=newhhy;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef SAVE_ALL
|
||||||
|
if (new_diff<=best_diff) {
|
||||||
|
debugSaveAll(iint);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
newhhx=new float[nbeta*nbeta]; //profile x
|
newhhx=new float[nbeta*nbeta]; //profile x
|
||||||
newhhy=new float[nbeta*nbeta]; //profile y
|
newhhy=new float[nbeta*nbeta]; //profile y
|
||||||
|
|
||||||
|
|
||||||
|
/* 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;
|
old_diff=new_diff;
|
||||||
//} /* else { */
|
|
||||||
/* cout << "Difference not decreasing after "<< iint << " iterations (" << old_diff << " < " << new_diff << ")"<< endl; */
|
|
||||||
/* break; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
iint++;
|
iint++;
|
||||||
|
cout << "Iteration "<< iint << " Chi2: " << new_diff << endl; //" Best: "<< best_diff << " RMS: "<< rms<< endl;
|
||||||
}
|
}
|
||||||
delete [] newhhx;
|
delete [] newhhx;
|
||||||
delete [] newhhy;
|
delete [] newhhy;
|
||||||
@ -248,34 +239,47 @@ class etaInterpolationAdaptiveBins : public etaInterpolationPosXY {
|
|||||||
hhy=besthhy;
|
hhy=besthhy;
|
||||||
|
|
||||||
|
|
||||||
|
cout << "Iteration "<< iint << " Chi2: " << best_diff << endl; //" Best: "<< best_diff << " RMS: "<< rms<< endl;
|
||||||
|
|
||||||
|
|
||||||
#ifdef SAVE_ALL
|
#ifdef SAVE_ALL
|
||||||
|
debugSaveAll(iint);
|
||||||
|
|
||||||
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;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ;
|
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
|
#endif
|
||||||
|
@ -19,82 +19,57 @@ class etaInterpolationBase : public slsInterpolation {
|
|||||||
// cout << "eb " << nb << " " << emin << " " << emax << endl;
|
// cout << "eb " << nb << " " << emin << " " << emax << endl;
|
||||||
// cout << nb << " " << etamin << " " << etamax << endl;
|
// cout << nb << " " << etamin << " " << etamax << endl;
|
||||||
if (nbeta<=0) {
|
if (nbeta<=0) {
|
||||||
cout << "aaa:" <<endl;
|
//cout << "aaa:" <<endl;
|
||||||
nbeta=nSubPixels*10;
|
nbeta=nSubPixels*10;
|
||||||
}
|
}
|
||||||
if (etamin>=etamax) {
|
if (etamin>=etamax) {
|
||||||
cout << "aaa:" <<endl;
|
|
||||||
etamin=-1;
|
etamin=-1;
|
||||||
etamax=2;
|
etamax=2;
|
||||||
}
|
}
|
||||||
etastep=(etamax-etamin)/nbeta;
|
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];
|
heta=new int[nbeta*nbeta];
|
||||||
hhx=new float[nbeta*nbeta];
|
hhx=new float[nbeta*nbeta];
|
||||||
hhy=new float[nbeta*nbeta];
|
hhy=new float[nbeta*nbeta];
|
||||||
|
rangeMin=etamin;
|
||||||
|
rangeMax=etamax;
|
||||||
|
flat= new double[nSubPixels*nSubPixels];
|
||||||
|
hintcorr=new int [nSubPixels*nSubPixels*nPixelsX*nPixelsY];
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//cout << nbeta << " " << etamin << " " << etamax << endl;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
etaInterpolationBase(etaInterpolationBase *orig): slsInterpolation(orig){
|
etaInterpolationBase(etaInterpolationBase *orig): slsInterpolation(orig){
|
||||||
nbeta=orig->nbeta;
|
nbeta=orig->nbeta;
|
||||||
etamin=orig->etamin;
|
etamin=orig->etamin;
|
||||||
etamax=orig->etamax;
|
etamax=orig->etamax;
|
||||||
|
rangeMin=orig->rangeMin;
|
||||||
|
rangeMax=orig->rangeMax;
|
||||||
|
|
||||||
|
|
||||||
etastep=(etamax-etamin)/nbeta;
|
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];
|
heta=new int[nbeta*nbeta];
|
||||||
memcpy(heta,orig->heta,nbeta*nbeta*sizeof(int));
|
memcpy(heta,orig->heta,nbeta*nbeta*sizeof(int));
|
||||||
hhx=new float[nbeta*nbeta];
|
hhx=new float[nbeta*nbeta];
|
||||||
memcpy(hhx,orig->hhx,nbeta*nbeta*sizeof(float));
|
memcpy(hhx,orig->hhx,nbeta*nbeta*sizeof(float));
|
||||||
hhy=new float[nbeta*nbeta];
|
hhy=new float[nbeta*nbeta];
|
||||||
memcpy(hhy,orig->hhy,nbeta*nbeta*sizeof(float));
|
memcpy(hhy,orig->hhy,nbeta*nbeta*sizeof(float));
|
||||||
|
hintcorr=new int [nSubPixels*nSubPixels*nPixelsX*nPixelsY];
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual etaInterpolationBase* Clone()=0;/*{
|
|
||||||
return new etaInterpolationBase(this);
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MYROOT1
|
|
||||||
TH2D *setEta(TH2D *h, int nb=-1, double emin=1, double emax=0)
|
virtual void resetFlatField() {
|
||||||
{
|
for (int ibx=0; ibx<nbeta*nbeta; ibx++) {
|
||||||
if (h) { heta=h;
|
heta[ibx]=0;
|
||||||
nbeta=heta->GetNbinsX();
|
hhx[ibx]=0;
|
||||||
etamin=heta->GetXaxis()->GetXmin();
|
hhy[ibx]=0;
|
||||||
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)
|
int *setEta(int *h, int nb=-1, double emin=1, double emax=0)
|
||||||
{
|
{
|
||||||
if (h) {
|
if (h) {
|
||||||
@ -108,6 +83,8 @@ class etaInterpolationBase : public slsInterpolation {
|
|||||||
etamin=-1;
|
etamin=-1;
|
||||||
etamax=2;
|
etamax=2;
|
||||||
}
|
}
|
||||||
|
rangeMin=etamin;
|
||||||
|
rangeMax=etamax;
|
||||||
etastep=(etamax-etamin)/nbeta;
|
etastep=(etamax-etamin)/nbeta;
|
||||||
}
|
}
|
||||||
return heta;
|
return heta;
|
||||||
@ -117,11 +94,13 @@ class etaInterpolationBase : public slsInterpolation {
|
|||||||
{
|
{
|
||||||
return setEta(h, nb, emin, emax);
|
return setEta(h, nb, emin, emax);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int *getFlatField(){return setEta(NULL);};
|
int *getFlatField(){return setEta(NULL);};
|
||||||
|
|
||||||
int *getFlatField(int &nb, double &emin, double &emax){
|
int *getFlatField(int &nb, double &emin, double &emax){
|
||||||
nb=nbeta;
|
nb=nbeta;
|
||||||
//cout << "igff* ff has " << nb << " bins " << endl;
|
|
||||||
emin=etamin;
|
emin=etamin;
|
||||||
emax=etamax;
|
emax=etamax;
|
||||||
return getFlatField();
|
return getFlatField();
|
||||||
@ -185,27 +164,7 @@ class etaInterpolationBase : public slsInterpolation {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ////////////////////////////////////////////////////////////////////////////// */
|
|
||||||
|
|
||||||
#ifdef MYROOT1
|
|
||||||
TH2D *gethhx()
|
|
||||||
{
|
|
||||||
hhx->Scale((double)nSubPixels);
|
|
||||||
return hhx;
|
|
||||||
};
|
|
||||||
|
|
||||||
TH2D *gethhy()
|
|
||||||
{
|
|
||||||
hhy->Scale((double)nSubPixels);
|
|
||||||
return hhy;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MYROOT1
|
|
||||||
float *gethhx()
|
float *gethhx()
|
||||||
{
|
{
|
||||||
// hhx->Scale((double)nSubPixels);
|
// hhx->Scale((double)nSubPixels);
|
||||||
@ -217,53 +176,193 @@ float *gethhx()
|
|||||||
// hhy->Scale((double)nSubPixels);
|
// hhy->Scale((double)nSubPixels);
|
||||||
return hhy;
|
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){
|
virtual int addToFlatField(double etax, double etay){
|
||||||
#ifdef MYROOT1
|
|
||||||
heta->Fill(etax,etay);
|
|
||||||
#endif
|
|
||||||
#ifndef MYROOT1
|
|
||||||
int ex,ey;
|
int ex,ey;
|
||||||
ex=(etax-etamin)/etastep;
|
ex=(etax-etamin)/etastep;
|
||||||
ey=(etay-etamin)/etastep;
|
ey=(etay-etamin)/etastep;
|
||||||
if (ey<nbeta && ex<nbeta && ex>=0 && ey>=0)
|
if (ey<nbeta && ex<nbeta && ex>=0 && ey>=0)
|
||||||
heta[ey*nbeta+ex]++;
|
heta[ey*nbeta+ex]++;
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// virtual void prepareInterpolation(int &ok)=0;
|
// virtual void prepareInterpolation(int &ok)=0;
|
||||||
|
|
||||||
|
|
||||||
|
void debugSaveAll(int ind=0) {
|
||||||
|
int ib, ibx, iby;
|
||||||
|
char tit[10000];
|
||||||
|
|
||||||
|
float tot_eta=0;
|
||||||
|
|
||||||
|
float *etah=new float[nbeta*nbeta];
|
||||||
|
int etabins=nbeta;
|
||||||
|
int ibb=0;
|
||||||
|
|
||||||
|
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||||
|
|
||||||
|
etah[ii]=heta[ii];
|
||||||
|
tot_eta+=heta[ii];
|
||||||
|
}
|
||||||
|
sprintf(tit,"/scratch/eta.tiff",ind);
|
||||||
|
WriteToTiff(etah, tit, etabins, etabins);
|
||||||
|
|
||||||
|
|
||||||
|
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||||
|
ibb=(hhx[ii]*nSubPixels);
|
||||||
|
etah[ii]=ibb;
|
||||||
|
}
|
||||||
|
sprintf(tit,"/scratch/eta_hhx_%d.tiff",ind);
|
||||||
|
WriteToTiff(etah, tit, etabins, etabins);
|
||||||
|
|
||||||
|
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||||
|
ibb=hhy[ii]*nSubPixels;
|
||||||
|
etah[ii]=ibb;
|
||||||
|
}
|
||||||
|
sprintf(tit,"/scratch/eta_hhy_%d.tiff",ind);
|
||||||
|
WriteToTiff(etah, tit, etabins, etabins);
|
||||||
|
|
||||||
|
|
||||||
|
float *ftest=new float[nSubPixels*nSubPixels];
|
||||||
|
|
||||||
|
for (int ib=0; ib<nSubPixels*nSubPixels; ib++) ftest[ib]=0;
|
||||||
|
|
||||||
|
|
||||||
|
//int ibx=0, iby=0;
|
||||||
|
|
||||||
|
for (int ii=0; ii<nbeta*nbeta; ii++) {
|
||||||
|
|
||||||
|
ibx=nSubPixels*hhx[ii];
|
||||||
|
iby=nSubPixels*hhy[ii];
|
||||||
|
if (ibx<0) ibx=0;
|
||||||
|
if (iby<0) iby=0;
|
||||||
|
if (ibx>=nSubPixels) ibx=nSubPixels-1;
|
||||||
|
if (iby>=nSubPixels) iby=nSubPixels-1;
|
||||||
|
|
||||||
|
|
||||||
|
if (ibx>=0 && ibx<nSubPixels && iby>=0 && iby<nSubPixels) {
|
||||||
|
//
|
||||||
|
// if (ibx>0 && iby>0) cout << ibx << " " << iby << " " << ii << endl;
|
||||||
|
ftest[ibx+iby*nSubPixels]+=heta[ii];
|
||||||
|
} else
|
||||||
|
cout << "Bad interpolation "<< ii << " " << ibx << " " << iby<< endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(tit,"/scratch/ftest_%d.tiff",ind);
|
||||||
|
WriteToTiff(ftest, tit, nSubPixels, nSubPixels);
|
||||||
|
|
||||||
|
//int ibx=0, iby=0;
|
||||||
|
tot_eta/=nSubPixels*nSubPixels;
|
||||||
|
int nbad=0;
|
||||||
|
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||||
|
ibx=nSubPixels*hhx[ii];
|
||||||
|
iby=nSubPixels*hhy[ii];
|
||||||
|
if (ftest[ibx+iby*nSubPixels]<tot_eta*0.5) {
|
||||||
|
etah[ii]=1;
|
||||||
|
nbad++;
|
||||||
|
} else if(ftest[ibx+iby*nSubPixels]>tot_eta*2.){
|
||||||
|
etah[ii]=2;
|
||||||
|
nbad++;
|
||||||
|
} else
|
||||||
|
etah[ii]=0;
|
||||||
|
}
|
||||||
|
sprintf(tit,"/scratch/eta_bad_%d.tiff",ind);
|
||||||
|
WriteToTiff(etah, tit, etabins, etabins);
|
||||||
|
// cout << "Index: " << ind << "\t Bad bins: "<< nbad << endl;
|
||||||
|
//int ibx=0, iby=0;
|
||||||
|
|
||||||
|
delete [] ftest;
|
||||||
|
delete [] etah;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
#ifdef MYROOT1
|
|
||||||
TH2D *heta;
|
double calcDiff(double avg, float *hx, float *hy) {
|
||||||
TH2D *hhx;
|
//double p_tot=0;
|
||||||
TH2D *hhy;
|
double diff=0, d;
|
||||||
#endif
|
double bsize=1./nSubPixels;
|
||||||
#ifndef MYROOT1
|
int nbad=0;
|
||||||
|
double p_tot_x[nSubPixels], p_tot_y[nSubPixels], p_tot[nSubPixels*nSubPixels];
|
||||||
|
double maxdiff=0, mindiff=avg*nSubPixels*nSubPixels;
|
||||||
|
|
||||||
|
int ipx, ipy;
|
||||||
|
for (ipy=0; ipy<nSubPixels; ipy++) {
|
||||||
|
for (ipx=0; ipx<nSubPixels; ipx++) {
|
||||||
|
p_tot[ipx+ipy*nSubPixels]=0;
|
||||||
|
}
|
||||||
|
p_tot_y[ipy]=0;
|
||||||
|
p_tot_x[ipy]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||||
|
for (int iby=0; iby<nbeta; iby++) {
|
||||||
|
ipx=hx[ibx+iby*nbeta]*nSubPixels;
|
||||||
|
if (ipx<0) ipx=0;
|
||||||
|
if (ipx>=nSubPixels) ipx=nSubPixels-1;
|
||||||
|
|
||||||
|
ipy=hy[ibx+iby*nbeta]*nSubPixels;
|
||||||
|
if (ipy<0) ipy=0;
|
||||||
|
if (ipy>=nSubPixels) ipy=nSubPixels-1;
|
||||||
|
|
||||||
|
p_tot[ipx+ipy*nSubPixels]+=heta[ibx+iby*nbeta];
|
||||||
|
p_tot_y[ipy]+=heta[ibx+iby*nbeta];
|
||||||
|
p_tot_x[ipx]+=heta[ibx+iby*nbeta];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// cout << endl << endl;
|
||||||
|
for (ipy=0; ipy<nSubPixels; ipy++) {
|
||||||
|
cout.width(5);
|
||||||
|
//flat_y[ipy]=p_tot_y[ipy];//avg/nSubPixels;
|
||||||
|
for (ipx=0; ipx<nSubPixels; ipx++) {
|
||||||
|
|
||||||
|
// flat_x[ipx]=p_tot_x[ipx];///avg/nSubPixels;
|
||||||
|
flat[ipx+nSubPixels*ipy]=p_tot[ipx+nSubPixels*ipy];///avg;
|
||||||
|
d=p_tot[ipx+nSubPixels*ipy]-avg;
|
||||||
|
if (d<0) d*=-1.;
|
||||||
|
if (d>5*sqrt(avg) )
|
||||||
|
nbad++;
|
||||||
|
diff+=d*d;
|
||||||
|
if (d<mindiff) mindiff=d;
|
||||||
|
if (d>maxdiff) maxdiff=d;
|
||||||
|
// cout << setprecision(4) << p_tot[ipx+nSubPixels*ipy] << " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* cout << "** " << setprecision(4) << flat_y[ipy]; */
|
||||||
|
//cout << "\n";
|
||||||
|
}
|
||||||
|
/* cout << "**" << endl; cout.width(5); */
|
||||||
|
/* for (ipx=0; ipx<nSubPixels; ipx++) { */
|
||||||
|
/* cout << setprecision(4) << flat_x[ipx] << " "; */
|
||||||
|
/* } */
|
||||||
|
//cout << "**" << endl; cout.width(5);
|
||||||
|
//cout << "Min diff: " << mindiff/sqrt(avg) << " Max diff: " << maxdiff/sqrt(avg) << " Nbad: " << nbad << endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// cout << "Bad pixels: " << 100.*(float)nbad/((float)(nSubPixels*nSubPixels)) << " %" << endl;
|
||||||
|
return sqrt(diff);
|
||||||
|
}
|
||||||
|
|
||||||
int *heta;
|
int *heta;
|
||||||
float *hhx;
|
float *hhx;
|
||||||
float *hhy;
|
float *hhy;
|
||||||
#endif
|
|
||||||
int nbeta;
|
int nbeta;
|
||||||
double etamin, etamax, etastep;
|
double etamin, etamax, etastep;
|
||||||
|
double rangeMin, rangeMax;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
double *flat;
|
||||||
|
int *hintcorr;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -0,0 +1,263 @@
|
|||||||
|
#ifndef ETA_INTERPOLATION_CLEVER_ADAPTIVEBINS_H
|
||||||
|
#define ETA_INTERPOLATION_CLEVER_ADAPTIVEBINS_H
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include "tiffIO.h"
|
||||||
|
//#include "etaInterpolationBase.h"
|
||||||
|
#include "etaInterpolationAdaptiveBins.h"
|
||||||
|
|
||||||
|
|
||||||
|
//#define HSIZE 1
|
||||||
|
|
||||||
|
|
||||||
|
class etaInterpolationCleverAdaptiveBins : public etaInterpolationAdaptiveBins {
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
// double *gradientX, *gradientY, *gradientXY;
|
||||||
|
|
||||||
|
|
||||||
|
virtual void iterate(float *newhhx, float *newhhy) {
|
||||||
|
|
||||||
|
double bsize=1./nSubPixels;
|
||||||
|
|
||||||
|
/* double hy[nSubPixels*HSIZE][nbeta]; //profile y */
|
||||||
|
/* double hx[nSubPixels*HSIZE][nbeta]; //profile x */
|
||||||
|
// double hix[nSubPixels*HSIZE][nbeta]; //integral of projection x
|
||||||
|
// double hiy[nSubPixels*HSIZE][nbeta]; //integral of projection y
|
||||||
|
int ipy, ipx, ippx, ippy;
|
||||||
|
// double tot_eta_x[nSubPixels*HSIZE];
|
||||||
|
//double tot_eta_y[nSubPixels*HSIZE];
|
||||||
|
|
||||||
|
double mean=0;
|
||||||
|
double maxflat=0, minflat=0, maxgradX=0, mingradX=0, maxgradY=0, mingradY=0, maxgr=0, mingr=0;
|
||||||
|
|
||||||
|
int ix_maxflat, iy_maxflat, ix_minflat, iy_minflat, ix_maxgrX, iy_maxgrX, ix_mingrX, iy_mingrX,ix_maxgrY, iy_maxgrY, ix_mingrY, iy_mingrY, ix_mingr, iy_mingr, ix_maxgr, iy_maxgr;
|
||||||
|
int maskMin[nSubPixels*nSubPixels], maskMax[nSubPixels*nSubPixels];
|
||||||
|
|
||||||
|
|
||||||
|
//for (int ipy=0; ipy<nSubPixels; ipy++) {
|
||||||
|
|
||||||
|
for (ipy=0; ipy<nSubPixels; ipy++) {
|
||||||
|
for (ipx=0; ipx<nSubPixels; ipx++) {
|
||||||
|
// cout << ipx << " " << ipy << endl;
|
||||||
|
mean+=flat[ipx+nSubPixels*ipy]/((double)(nSubPixels*nSubPixels));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// cout << "Mean is " << mean << endl;
|
||||||
|
|
||||||
|
/*** Find local minima and maxima within the staistical uncertainty **/
|
||||||
|
for (ipy=0; ipy<nSubPixels; ipy++) {
|
||||||
|
for (ipx=0; ipx<nSubPixels; ipx++) {
|
||||||
|
if (flat[ipx+nSubPixels*ipy]<mean-3.*sqrt(mean))maskMin[ipx+nSubPixels*ipy]=1; else maskMin[ipx+nSubPixels*ipy]=0;
|
||||||
|
if (flat[ipx+nSubPixels*ipy]>mean+3.*sqrt(mean)) maskMax[ipx+nSubPixels*ipy]=1; else maskMax[ipx+nSubPixels*ipy]=0;
|
||||||
|
if (ipx>0 && ipy>0) {
|
||||||
|
if (flat[ipx+nSubPixels*ipy]<flat[ipx-1+nSubPixels*(ipy-1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||||
|
if (flat[ipx+nSubPixels*ipy]>flat[ipx-1+nSubPixels*(ipy-1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||||
|
}
|
||||||
|
if (ipx>0 && ipy<nSubPixels-1) {
|
||||||
|
if (flat[ipx+nSubPixels*ipy]<flat[ipx-1+nSubPixels*(ipy+1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||||
|
if (flat[ipx+nSubPixels*ipy]>flat[ipx-1+nSubPixels*(ipy+1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||||
|
}
|
||||||
|
if (ipy>0 && ipx<nSubPixels-1) {
|
||||||
|
if (flat[ipx+nSubPixels*ipy]<flat[ipx+1+nSubPixels*(ipy-1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||||
|
if (flat[ipx+nSubPixels*ipy]>flat[ipx+1+nSubPixels*(ipy-1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||||
|
}
|
||||||
|
if (ipy<nSubPixels-1 && ipx<nSubPixels-1) {
|
||||||
|
if (flat[ipx+nSubPixels*ipy]<flat[ipx+1+nSubPixels*(ipy+1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||||
|
if (flat[ipx+nSubPixels*ipy]>flat[ipx+1+nSubPixels*(ipy+1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||||
|
}
|
||||||
|
if (ipy<nSubPixels-1 ) {
|
||||||
|
if (flat[ipx+nSubPixels*ipy]<flat[ipx+nSubPixels*(ipy+1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||||
|
if (flat[ipx+nSubPixels*ipy]>flat[ipx+nSubPixels*(ipy+1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||||
|
}
|
||||||
|
if (ipx<nSubPixels-1) {
|
||||||
|
if (flat[ipx+nSubPixels*ipy]<flat[ipx+1+nSubPixels*(ipy)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||||
|
if (flat[ipx+nSubPixels*ipy]>flat[ipx+1+nSubPixels*(ipy)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ipy>0 ) {
|
||||||
|
if (flat[ipx+nSubPixels*ipy]<flat[ipx+nSubPixels*(ipy-1)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||||
|
if (flat[ipx+nSubPixels*ipy]>flat[ipx+nSubPixels*(ipy-1)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ipx>0 ) {
|
||||||
|
if (flat[ipx+nSubPixels*ipy]<flat[ipx-1+nSubPixels*(ipy)]) maskMax[ipx+nSubPixels*ipy]=0;
|
||||||
|
if (flat[ipx+nSubPixels*ipy]>flat[ipx-1+nSubPixels*(ipy)]) maskMin[ipx+nSubPixels*ipy]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (maskMin[ipx+nSubPixels*ipy]) cout << ipx << " " << ipy << " is a local minimum " << flat[ipx+nSubPixels*ipy] << endl;
|
||||||
|
// if (maskMax[ipx+nSubPixels*ipy]) cout << ipx << " " << ipy << " is a local maximum "<< flat[ipx+nSubPixels*ipy] << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int is_a_border=0;
|
||||||
|
|
||||||
|
//initialize the new partition to the previous one
|
||||||
|
// int ibx_p, iby_p, ibx_n, iby_n;
|
||||||
|
int ibbx, ibby;
|
||||||
|
|
||||||
|
|
||||||
|
memcpy(newhhx,hhx,nbeta*nbeta*sizeof(float));
|
||||||
|
memcpy(newhhy,hhy,nbeta*nbeta*sizeof(float));
|
||||||
|
|
||||||
|
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||||
|
for (int iby=0; iby<nbeta; iby++) {
|
||||||
|
|
||||||
|
ippy=hhy[ibx+iby*nbeta]*nSubPixels;
|
||||||
|
ippx=hhx[ibx+iby*nbeta]*nSubPixels;
|
||||||
|
|
||||||
|
|
||||||
|
is_a_border=0;
|
||||||
|
|
||||||
|
if (maskMin[ippx+nSubPixels*ippy] || maskMax[ippx+nSubPixels*ippy]) {
|
||||||
|
|
||||||
|
|
||||||
|
for (int ix=-1; ix<2; ix++) {
|
||||||
|
ibbx=ibx+ix;
|
||||||
|
if (ibbx<0) ibbx=0;
|
||||||
|
if (ibbx>nbeta-1) ibbx=nbeta-1;
|
||||||
|
for (int iy=-1; iy<2; iy++) {
|
||||||
|
ibby=iby+iy;
|
||||||
|
if (ibby<0) ibby=0;
|
||||||
|
if (ibby>nbeta-1) ibby=nbeta-1;
|
||||||
|
|
||||||
|
|
||||||
|
ipy=hhy[ibbx+ibby*nbeta]*nSubPixels;
|
||||||
|
ipx=hhx[ibbx+ibby*nbeta]*nSubPixels;
|
||||||
|
|
||||||
|
|
||||||
|
if (ipx!=ippx || ipy!=ippy) {
|
||||||
|
is_a_border=1;
|
||||||
|
if (maskMin[ippx+nSubPixels*ippy]) {
|
||||||
|
//increase the region
|
||||||
|
newhhx[ibbx+ibby*nbeta]=((double)ippx+0.5)/((double)nSubPixels);
|
||||||
|
newhhy[ibbx+ibby*nbeta]=((double)ippy+0.5)/((double)nSubPixels);
|
||||||
|
}
|
||||||
|
if (maskMax[ippx+nSubPixels*ippy]) {
|
||||||
|
//reduce the region
|
||||||
|
newhhx[ibx+iby*nbeta]=((double)ipx+0.5)/((double)nSubPixels);
|
||||||
|
newhhy[ibx+iby*nbeta]=((double)ipy+0.5)/((double)nSubPixels);
|
||||||
|
}
|
||||||
|
|
||||||
|
// cout << ippx << " " << ippy << " " << ibx << " " << iby << " * " << ipx << " " << ipy << " " << ibbx << " " << ibby << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Check that the resulting histograms are monotonic and they don't have holes!
|
||||||
|
|
||||||
|
for (int ibx=0; ibx<nbeta-1; ibx++) {
|
||||||
|
for (int iby=0; iby<nbeta-1; iby++) {
|
||||||
|
|
||||||
|
ippy=newhhy[ibx+iby*nbeta]*nSubPixels;
|
||||||
|
ippx=newhhx[ibx+iby*nbeta]*nSubPixels;
|
||||||
|
|
||||||
|
ipy=newhhy[ibx+(iby+1)*nbeta]*nSubPixels;
|
||||||
|
ipx=newhhx[ibx+1+iby*nbeta]*nSubPixels;
|
||||||
|
|
||||||
|
if ( ippx>ipx)
|
||||||
|
newhhx[ibx+1+iby*nbeta]=newhhx[ibx+iby*nbeta];
|
||||||
|
else if (ipx >ippx+1)
|
||||||
|
newhhx[ibx+1+iby*nbeta]=((double)(ippx+1+0.5))/((double)nSubPixels);
|
||||||
|
|
||||||
|
if ( ippy>ipy)
|
||||||
|
newhhy[ibx+(iby+1)*nbeta]=newhhy[ibx+iby*nbeta];
|
||||||
|
else if (ipy >ippy+1)
|
||||||
|
newhhy[ibx+(iby+1)*nbeta]=((double)(ippy+1+0.5))/((double)nSubPixels);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
etaInterpolationCleverAdaptiveBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationAdaptiveBins(nx,ny,ns, nb, emin,emax){
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
etaInterpolationCleverAdaptiveBins(etaInterpolationCleverAdaptiveBins *orig): etaInterpolationAdaptiveBins(orig){};
|
||||||
|
|
||||||
|
virtual etaInterpolationCleverAdaptiveBins* Clone()=0;
|
||||||
|
|
||||||
|
/* return new etaInterpolationCleverAdaptiveBins(this); */
|
||||||
|
|
||||||
|
/* }; */
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class eta2InterpolationCleverAdaptiveBins : public virtual eta2InterpolationBase, public virtual etaInterpolationCleverAdaptiveBins {
|
||||||
|
public:
|
||||||
|
eta2InterpolationCleverAdaptiveBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax),eta2InterpolationBase(nx,ny,ns, nb, emin,emax),etaInterpolationCleverAdaptiveBins(nx,ny,ns, nb, emin,emax){
|
||||||
|
};
|
||||||
|
|
||||||
|
eta2InterpolationCleverAdaptiveBins(eta2InterpolationCleverAdaptiveBins *orig): etaInterpolationBase(orig), etaInterpolationCleverAdaptiveBins(orig) {};
|
||||||
|
|
||||||
|
virtual eta2InterpolationCleverAdaptiveBins* Clone() { return new eta2InterpolationCleverAdaptiveBins(this);};
|
||||||
|
|
||||||
|
// virtual int *getInterpolatedImage(){return eta2InterpolationBase::getInterpolatedImage();};
|
||||||
|
|
||||||
|
/* virtual int *getInterpolatedImage(){ */
|
||||||
|
/* int ipx, ipy; */
|
||||||
|
/* cout << "ff" << endl; */
|
||||||
|
/* calcDiff(1, hhx, hhy); //get flat */
|
||||||
|
/* double avg=0; */
|
||||||
|
/* for (ipx=0; ipx<nSubPixels; ipx++) */
|
||||||
|
/* for (ipy=0; ipy<nSubPixels; ipy++) */
|
||||||
|
/* avg+=flat[ipx+ipy*nSubPixels]; */
|
||||||
|
/* avg/=nSubPixels*nSubPixels; */
|
||||||
|
|
||||||
|
/* for (int ibx=0 ; ibx<nSubPixels*nPixelsX; ibx++) { */
|
||||||
|
/* ipx=ibx%nSubPixels-nSubPixels; */
|
||||||
|
/* if (ipx<0) ipx=nSubPixels+ipx; */
|
||||||
|
/* for (int iby=0 ; iby<nSubPixels*nPixelsY; iby++) { */
|
||||||
|
/* ipy=iby%nSubPixels-nSubPixels; */
|
||||||
|
/* if (ipy<0) ipy=nSubPixels+ipy; */
|
||||||
|
|
||||||
|
/* if (flat[ipx+ipy*nSubPixels]>0) */
|
||||||
|
/* hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX]*(avg/flat[ipx+ipy*nSubPixels]); */
|
||||||
|
/* else */
|
||||||
|
/* hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX]; */
|
||||||
|
|
||||||
|
|
||||||
|
/* } */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* return hintcorr; */
|
||||||
|
/* }; */
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class eta3InterpolationCleverAdaptiveBins : public virtual eta3InterpolationBase, public virtual etaInterpolationCleverAdaptiveBins {
|
||||||
|
public:
|
||||||
|
eta3InterpolationCleverAdaptiveBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax),eta3InterpolationBase(nx,ny,ns, nb, emin,emax), etaInterpolationCleverAdaptiveBins(nx,ny,ns, nb, emin,emax){
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
eta3InterpolationCleverAdaptiveBins(eta3InterpolationCleverAdaptiveBins *orig): etaInterpolationBase(orig), etaInterpolationCleverAdaptiveBins(orig) {};
|
||||||
|
|
||||||
|
virtual eta3InterpolationCleverAdaptiveBins* Clone() { return new eta3InterpolationCleverAdaptiveBins(this);};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -51,16 +51,26 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
|||||||
double hix[nbeta]; //integral of projection x
|
double hix[nbeta]; //integral of projection x
|
||||||
double hiy[nbeta]; //integral of projection y
|
double hiy[nbeta]; //integral of projection y
|
||||||
int ii=0;
|
int ii=0;
|
||||||
|
double etax, etay;
|
||||||
for (int ib=0; ib<nbeta; ib++) {
|
for (int ib=0; ib<nbeta; ib++) {
|
||||||
|
|
||||||
tot_eta_x=0;
|
tot_eta_x=0;
|
||||||
tot_eta_y=0;
|
tot_eta_y=0;
|
||||||
|
|
||||||
for (int iby=0; iby<nbeta; iby++) {
|
for (int iby=0; iby<nbeta; iby++) {
|
||||||
|
etax=etamin+iby*etastep;
|
||||||
|
//cout << etax << endl;
|
||||||
|
if (etax>=0 && etax<=1)
|
||||||
hx[iby]=heta[iby+ib*nbeta];
|
hx[iby]=heta[iby+ib*nbeta];
|
||||||
tot_eta_x+=hx[iby];
|
else {
|
||||||
|
hx[iby]=0;
|
||||||
|
}
|
||||||
|
// tot_eta_x+=hx[iby];
|
||||||
|
if (etax>=0 && etax<=1)
|
||||||
hy[iby]=heta[ib+iby*nbeta];
|
hy[iby]=heta[ib+iby*nbeta];
|
||||||
tot_eta_y+=hy[iby];
|
else
|
||||||
|
hy[iby]=0;
|
||||||
|
// tot_eta_y+=hy[iby];
|
||||||
}
|
}
|
||||||
|
|
||||||
hix[0]=hx[0];
|
hix[0]=hx[0];
|
||||||
@ -72,22 +82,17 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
ii=0;
|
ii=0;
|
||||||
|
tot_eta_x=hix[nbeta-1]+1;
|
||||||
|
tot_eta_y=hiy[nbeta-1]+1;
|
||||||
|
|
||||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||||
if (tot_eta_x==0) {
|
if (tot_eta_x<=0) {
|
||||||
hhx[ibx+ib*nbeta]=((float)ibx)/((float)nbeta);
|
hhx[ibx+ib*nbeta]=-1;
|
||||||
ii=(ibx)/nbeta;
|
//ii=(ibx)/nbeta;
|
||||||
} else //if (hix[ibx]>(ii+1)*tot_eta_x*bsize)
|
} else //if (hix[ibx]>(ii+1)*tot_eta_x*bsize)
|
||||||
{
|
{
|
||||||
//ii++;
|
//if (hix[ibx]>tot_eta_x*(ii+1)/nSubPixels) ii++;
|
||||||
// cout << ib << " x " << ibx << " " << tot_eta_x << " " << (ii)*tot_eta_x*bsize << " " << ii << endl;
|
hhx[ibx+ib*nbeta]=hix[ibx]/tot_eta_x;
|
||||||
// }
|
|
||||||
#ifdef MYROOT1
|
|
||||||
hhx->SetBinContent(ibx+1,ib+1,ii);
|
|
||||||
#endif
|
|
||||||
#ifndef MYROOT1
|
|
||||||
hhx[ibx+ib*nbeta]=hix[ibx]/((float)tot_eta_x);//ii;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* if (ii!=(nSubPixels-1)) */
|
/* if (ii!=(nSubPixels-1)) */
|
||||||
@ -96,53 +101,55 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
|||||||
ii=0;
|
ii=0;
|
||||||
|
|
||||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||||
if (tot_eta_y==0) {
|
if (tot_eta_y<=0) {
|
||||||
hhx[ibx+ib*nbeta]=((float)ibx)/((float)nbeta);
|
hhy[ib+ibx*nbeta]=-1;
|
||||||
ii=(ibx*nSubPixels)/nbeta;
|
//ii=(ibx*nSubPixels)/nbeta;
|
||||||
} else //if (hiy[ibx]>(ii+1)*tot_eta_y*bsize)
|
} else {
|
||||||
{
|
//if (hiy[ibx]>tot_eta_y*(ii+1)/nSubPixels) ii++;
|
||||||
//ii++;
|
hhy[ib+ibx*nbeta]=hiy[ibx]/tot_eta_y;
|
||||||
//cout << ib << " y " << ibx << " " << tot_eta_y << " "<< (ii)*tot_eta_y*bsize << " " << ii << endl;
|
}
|
||||||
//}
|
|
||||||
#ifdef MYROOT1
|
|
||||||
hhy->SetBinContent(ib+1,ibx+1,ii);
|
|
||||||
#endif
|
|
||||||
#ifndef MYROOT1
|
|
||||||
hhy[ib+ibx*nbeta]=hiy[ibx]/((float)tot_eta_y);//ii;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* if (ii!=(nSubPixels-1)) */
|
|
||||||
/* cout << ib << " y " << tot_eta_y << " " << (ii+1)*tot_eta_y*bsize << " " << ii << " " << hiy[nbeta-1]<< endl; */
|
|
||||||
|
|
||||||
// cout << "y " << nbeta << " " << (ii+1)*tot_eta_x*bsize << " " << ii << endl;
|
|
||||||
|
|
||||||
|
int ibx, iby, ib;
|
||||||
|
|
||||||
|
iby=0;
|
||||||
|
while (hhx[iby*nbeta+nbeta/2]<0) iby++;
|
||||||
|
for (ib=0; ib<iby;ib++) {
|
||||||
|
for (ibx=0; ibx<nbeta;ibx++)
|
||||||
|
hhx[ibx+nbeta*ib]=hhx[ibx+nbeta*iby];
|
||||||
}
|
}
|
||||||
|
iby=nbeta-1;
|
||||||
|
|
||||||
|
while (hhx[iby*nbeta+nbeta/2]<0) iby--;
|
||||||
|
for (ib=iby+1; ib<nbeta;ib++) {
|
||||||
|
for (ibx=0; ibx<nbeta;ibx++)
|
||||||
|
hhx[ibx+nbeta*ib]=hhx[ibx+nbeta*iby];
|
||||||
|
}
|
||||||
|
|
||||||
|
iby=0;
|
||||||
|
while (hhy[nbeta/2*nbeta+iby]<0) iby++;
|
||||||
|
for (ib=0; ib<iby;ib++) {
|
||||||
|
for (ibx=0; ibx<nbeta;ibx++)
|
||||||
|
hhy[ib+nbeta*ibx]=hhy[iby+nbeta*ibx];
|
||||||
|
}
|
||||||
|
iby=nbeta-1;
|
||||||
|
|
||||||
|
while (hhy[nbeta/2*nbeta+iby]<0) iby--;
|
||||||
|
for (ib=iby+1; ib<nbeta;ib++) {
|
||||||
|
for (ibx=0; ibx<nbeta;ibx++)
|
||||||
|
hhy[ib+nbeta*ibx]=hhy[iby+nbeta*ibx];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SAVE_ALL
|
#ifdef SAVE_ALL
|
||||||
char tit[10000];
|
debugSaveAll();
|
||||||
|
|
||||||
float *etah=new float[nbeta*nbeta];
|
|
||||||
int etabins=nbeta;
|
|
||||||
|
|
||||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
|
||||||
etah[ii]=hhx[ii];
|
|
||||||
}
|
|
||||||
sprintf(tit,"/scratch/eta_hhx_%d.tiff",id);
|
|
||||||
WriteToTiff(etah, tit, etabins, etabins);
|
|
||||||
|
|
||||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
|
||||||
etah[ii]=hhy[ii];
|
|
||||||
}
|
|
||||||
sprintf(tit,"/scratch/eta_hhy_%d.tiff",id);
|
|
||||||
WriteToTiff(etah, tit, etabins, etabins);
|
|
||||||
|
|
||||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
|
||||||
etah[ii]=heta[ii];
|
|
||||||
}
|
|
||||||
sprintf(tit,"/scratch/eta_%d.tiff",id);
|
|
||||||
WriteToTiff(etah, tit, etabins, etabins);
|
|
||||||
delete [] etah;
|
|
||||||
#endif
|
#endif
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
@ -154,11 +161,15 @@ class eta2InterpolationPosXY : public virtual eta2InterpolationBase, public virt
|
|||||||
eta2InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax),eta2InterpolationBase(nx,ny,ns, nb, emin,emax),etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){
|
eta2InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax),eta2InterpolationBase(nx,ny,ns, nb, emin,emax),etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){
|
||||||
// cout << "e2pxy " << nb << " " << emin << " " << emax << endl;
|
// cout << "e2pxy " << nb << " " << emin << " " << emax << endl;
|
||||||
};
|
};
|
||||||
|
|
||||||
eta2InterpolationPosXY(eta2InterpolationPosXY *orig): etaInterpolationBase(orig), etaInterpolationPosXY(orig) {};
|
eta2InterpolationPosXY(eta2InterpolationPosXY *orig): etaInterpolationBase(orig), etaInterpolationPosXY(orig) {};
|
||||||
|
|
||||||
virtual eta2InterpolationPosXY* Clone() { return new eta2InterpolationPosXY(this);};
|
virtual eta2InterpolationPosXY* Clone() { return new eta2InterpolationPosXY(this);};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class eta3InterpolationPosXY : public virtual eta3InterpolationBase, public virtual etaInterpolationPosXY {
|
class eta3InterpolationPosXY : public virtual eta3InterpolationBase, public virtual etaInterpolationPosXY {
|
||||||
public:
|
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){
|
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){
|
||||||
|
@ -93,7 +93,7 @@ class noInterpolation : public slsInterpolation{
|
|||||||
|
|
||||||
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay){return 0;};
|
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay){return 0;};
|
||||||
|
|
||||||
|
virtual void resetFlatField(){};
|
||||||
protected:
|
protected:
|
||||||
;
|
;
|
||||||
// TRandom *eventGenerator;
|
// TRandom *eventGenerator;
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
#ifndef SLS_INTERPOLATION_H
|
#ifndef SLS_INTERPOLATION_H
|
||||||
#define SLS_INTERPOLATION_H
|
#define SLS_INTERPOLATION_H
|
||||||
|
|
||||||
#ifdef MYROOT1
|
|
||||||
#include <TObject.h>
|
|
||||||
#include <TTree.h>
|
|
||||||
#include <TH2F.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#ifndef MY_TIFF_IO_H
|
#ifndef MY_TIFF_IO_H
|
||||||
#include "tiffIO.h"
|
#include "tiffIO.h"
|
||||||
@ -37,13 +31,7 @@ class slsInterpolation
|
|||||||
public:
|
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) :nPixelsX(nx), nPixelsY(ny), nSubPixels(ns), id(0) {
|
||||||
|
|
||||||
#ifdef MYROOT1
|
|
||||||
hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MYROOT1
|
|
||||||
hint=new int[ns*nx*ns*ny];
|
hint=new int[ns*nx*ns*ny];
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -51,23 +39,30 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
|||||||
nPixelsX=orig->nPixelsX;
|
nPixelsX=orig->nPixelsX;
|
||||||
nPixelsY=orig->nPixelsY;
|
nPixelsY=orig->nPixelsY;
|
||||||
nSubPixels=orig->nSubPixels;
|
nSubPixels=orig->nSubPixels;
|
||||||
#ifdef MYROOT1
|
|
||||||
hint=(TH2F*)(orig->hint)->Clone("hint");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MYROOT1
|
|
||||||
hint=new int[nSubPixels*nPixelsX*nSubPixels*nPixelsY];
|
hint=new int[nSubPixels*nPixelsX*nSubPixels*nPixelsY];
|
||||||
memcpy(hint, orig->hint,nSubPixels*nPixelsX*nSubPixels*nPixelsY*sizeof(int));
|
memcpy(hint, orig->hint,nSubPixels*nPixelsX*nSubPixels*nPixelsY*sizeof(int));
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual int setId(int i) {id=i; return id;};
|
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 getNSubPixels() {return nSubPixels;};
|
||||||
|
|
||||||
|
|
||||||
|
int setNSubPixels(int ns) {
|
||||||
|
if (ns>0 && ns!=nSubPixels) {
|
||||||
|
delete [] hint;
|
||||||
|
nSubPixels=ns;
|
||||||
|
hint=new int[nSubPixels*nPixelsX*nSubPixels*nPixelsY];
|
||||||
|
}
|
||||||
|
return nSubPixels;
|
||||||
|
}
|
||||||
|
|
||||||
int getImageSize(int &nnx, int &nny, int &ns) {
|
int getImageSize(int &nnx, int &nny, int &ns) {
|
||||||
nnx=nSubPixels*nPixelsX;
|
nnx=nSubPixels*nPixelsX;
|
||||||
nny=nSubPixels*nPixelsY;
|
nny=nSubPixels*nPixelsY;
|
||||||
@ -82,11 +77,6 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
|||||||
|
|
||||||
//create interpolated image
|
//create interpolated image
|
||||||
//returns interpolated image
|
//returns interpolated image
|
||||||
#ifdef MYROOT1
|
|
||||||
virtual TH2F *getInterpolatedImage(){return hint;};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MYROOT1
|
|
||||||
virtual int *getInterpolatedImage(){
|
virtual int *getInterpolatedImage(){
|
||||||
// cout << "return interpolated image " << endl;
|
// cout << "return interpolated image " << endl;
|
||||||
/* for (int i=0; i<nSubPixels* nSubPixels* nPixelsX*nPixelsY; i++) { */
|
/* for (int i=0; i<nSubPixels* nSubPixels* nPixelsX*nPixelsY; i++) { */
|
||||||
@ -94,7 +84,6 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
|||||||
/* } */
|
/* } */
|
||||||
return hint;
|
return hint;
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -102,11 +91,12 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
|||||||
void *writeInterpolatedImage(const char * imgname) {
|
void *writeInterpolatedImage(const char * imgname) {
|
||||||
//cout << "!" <<endl;
|
//cout << "!" <<endl;
|
||||||
float *gm=NULL;
|
float *gm=NULL;
|
||||||
|
int *dummy=getInterpolatedImage();
|
||||||
gm=new float[ nSubPixels* nSubPixels* nPixelsX*nPixelsY];
|
gm=new float[ nSubPixels* nSubPixels* nPixelsX*nPixelsY];
|
||||||
if (gm) {
|
if (gm) {
|
||||||
for (int ix=0; ix<nPixelsX*nSubPixels; ix++) {
|
for (int ix=0; ix<nPixelsX*nSubPixels; ix++) {
|
||||||
for (int iy=0; iy<nPixelsY*nSubPixels; iy++) {
|
for (int iy=0; iy<nPixelsY*nSubPixels; iy++) {
|
||||||
gm[iy*nPixelsX*nSubPixels+ix]=hint[iy*nPixelsX*nSubPixels+ix];
|
gm[iy*nPixelsX*nSubPixels+ix]=dummy[iy*nPixelsX*nSubPixels+ix];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WriteToTiff(gm, imgname,nSubPixels* nPixelsX ,nSubPixels* nPixelsY);
|
WriteToTiff(gm, imgname,nSubPixels* nPixelsX ,nSubPixels* nPixelsY);
|
||||||
@ -130,16 +120,11 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
|||||||
virtual void clearInterpolatedImage() {
|
virtual void clearInterpolatedImage() {
|
||||||
|
|
||||||
|
|
||||||
#ifdef MYROOT1
|
|
||||||
hint->Reset();
|
|
||||||
#endif
|
|
||||||
#ifndef MYROOT1
|
|
||||||
for (int ix=0; ix<nPixelsX*nSubPixels; ix++) {
|
for (int ix=0; ix<nPixelsX*nSubPixels; ix++) {
|
||||||
for (int iy=0; iy<nPixelsY*nSubPixels; iy++) {
|
for (int iy=0; iy<nPixelsY*nSubPixels; iy++) {
|
||||||
hint[iy*nPixelsX*nSubPixels+ix]=0;
|
hint[iy*nPixelsX*nSubPixels+ix]=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -147,11 +132,6 @@ 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){
|
virtual int *addToImage(double int_x, double int_y){
|
||||||
int iy=((double)nSubPixels)*int_y;
|
int iy=((double)nSubPixels)*int_y;
|
||||||
int ix=((double)nSubPixels)*int_x;
|
int ix=((double)nSubPixels)*int_x;
|
||||||
@ -164,7 +144,6 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
|||||||
|
|
||||||
return hint;
|
return hint;
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
virtual int addToFlatField(double *cluster, double &etax, double &etay)=0;
|
virtual int addToFlatField(double *cluster, double &etax, double &etay)=0;
|
||||||
@ -173,19 +152,13 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
|||||||
virtual int addToFlatField(double totquad,int quad,double *cluster,double &etax, double &etay)=0;
|
virtual int addToFlatField(double totquad,int quad,double *cluster,double &etax, double &etay)=0;
|
||||||
virtual int addToFlatField(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 *getFlatField(){return NULL;};
|
||||||
virtual int *setFlatField(int *h, int nb=-1, double emin=-1, double emax=-1){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;};
|
virtual void *writeFlatField(const char * imgname){return NULL;};
|
||||||
void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){return NULL;};
|
virtual void *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();};
|
virtual int *getFlatField(int &nb, double &emin, double &emax){nb=0; emin=0; emax=0; return getFlatField();};
|
||||||
#endif
|
|
||||||
|
virtual void resetFlatField()=0;
|
||||||
|
|
||||||
//virtual void Streamer(TBuffer &b);
|
//virtual void Streamer(TBuffer &b);
|
||||||
|
|
||||||
@ -201,10 +174,10 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
|||||||
static int calcQuad(double *cl, double &sum, double &totquad, double sDum[2][2]){
|
static int calcQuad(double *cl, double &sum, double &totquad, double sDum[2][2]){
|
||||||
|
|
||||||
int corner = UNDEFINED_QUADRANT;
|
int corner = UNDEFINED_QUADRANT;
|
||||||
double *cluster[3];
|
/* double *cluster[3]; */
|
||||||
cluster[0]=cl;
|
/* cluster[0]=cl; */
|
||||||
cluster[1]=cl+3;
|
/* cluster[1]=cl+3; */
|
||||||
cluster[2]=cl+6;
|
/* cluster[2]=cl+6; */
|
||||||
|
|
||||||
sum=0;
|
sum=0;
|
||||||
double sumBL=0;
|
double sumBL=0;
|
||||||
@ -214,11 +187,11 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
|||||||
int xoff=0, yoff=0;
|
int xoff=0, yoff=0;
|
||||||
for (int ix=0; ix<3; ix++) {
|
for (int ix=0; ix<3; ix++) {
|
||||||
for (int iy=0; iy<3; iy++) {
|
for (int iy=0; iy<3; iy++) {
|
||||||
sum+=cluster[iy][ix];
|
sum+=cl[ix+3*iy];
|
||||||
if (ix<=1 && iy<=1) sumBL+=cluster[iy][ix];
|
if (ix<=1 && iy<=1) sumBL+=cl[ix+iy*3];
|
||||||
if (ix<=1 && iy>=1) sumTL+=cluster[iy][ix];
|
if (ix<=1 && iy>=1) sumTL+=cl[ix+iy*3];
|
||||||
if (ix>=1 && iy<=1) sumBR+=cluster[iy][ix];
|
if (ix>=1 && iy<=1) sumBR+=cl[ix+iy*3];
|
||||||
if (ix>=1 && iy>=1) sumTR+=cluster[iy][ix];
|
if (ix>=1 && iy>=1) sumTR+=cl[ix+iy*3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,6 +199,8 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
|||||||
/* sDum[0][1] = cluster[0][1]; sDum[1][1] = cluster[1][1]; */
|
/* sDum[0][1] = cluster[0][1]; sDum[1][1] = cluster[1][1]; */
|
||||||
corner = BOTTOM_LEFT;
|
corner = BOTTOM_LEFT;
|
||||||
totquad=sumBL;
|
totquad=sumBL;
|
||||||
|
xoff=0;
|
||||||
|
yoff=0;
|
||||||
|
|
||||||
|
|
||||||
if(sumTL >= totquad){
|
if(sumTL >= totquad){
|
||||||
@ -260,7 +235,7 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
|||||||
|
|
||||||
for (int ix=0; ix<2; ix++) {
|
for (int ix=0; ix<2; ix++) {
|
||||||
for (int iy=0; iy<2; iy++) {
|
for (int iy=0; iy<2; iy++) {
|
||||||
sDum[iy][ix] = cluster[iy+yoff][ix+xoff];
|
sDum[iy][ix] = cl[ix+xoff+(iy+yoff)*3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,7 +357,7 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
|||||||
// int quad;
|
// int quad;
|
||||||
for (int ix=0; ix<3; ix++) {
|
for (int ix=0; ix<3; ix++) {
|
||||||
for (int iy=0; iy<3; iy++) {
|
for (int iy=0; iy<3; iy++) {
|
||||||
val=cl[iy+3*ix];
|
val=cl[ix+3*iy];
|
||||||
sum+=val;
|
sum+=val;
|
||||||
if (iy==0) l+=val;
|
if (iy==0) l+=val;
|
||||||
if (iy==2) r+=val;
|
if (iy==2) r+=val;
|
||||||
@ -426,92 +401,92 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int calcMyEta(double totquad, int quad, double *cl, double &etax, double &etay) {
|
/* static int calcMyEta(double totquad, int quad, double *cl, double &etax, double &etay) { */
|
||||||
double l,r,t,b, sum;
|
/* double l,r,t,b, sum; */
|
||||||
int yoff;
|
/* int yoff; */
|
||||||
switch (quad) {
|
/* switch (quad) { */
|
||||||
case BOTTOM_LEFT:
|
/* case BOTTOM_LEFT: */
|
||||||
case BOTTOM_RIGHT:
|
/* case BOTTOM_RIGHT: */
|
||||||
yoff=0;
|
/* yoff=0; */
|
||||||
break;
|
/* break; */
|
||||||
case TOP_LEFT:
|
/* case TOP_LEFT: */
|
||||||
case TOP_RIGHT:
|
/* case TOP_RIGHT: */
|
||||||
yoff=1;
|
/* yoff=1; */
|
||||||
break;
|
/* break; */
|
||||||
default:
|
/* default: */
|
||||||
;
|
/* ; */
|
||||||
}
|
/* } */
|
||||||
l=cl[0+yoff*3]+cl[0+yoff*3+3];
|
/* l=cl[0+yoff*3]+cl[0+yoff*3+3]; */
|
||||||
r=cl[2+yoff*3]+cl[2+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];
|
/* 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];
|
/* t=cl[0+yoff*3+3]+cl[1+yoff*3+3]*cl[0+yoff*3+3]; */
|
||||||
sum=t+b;
|
/* sum=t+b; */
|
||||||
if (sum>0) {
|
/* if (sum>0) { */
|
||||||
etax=(-l+r)/sum;
|
/* etax=(-l+r)/sum; */
|
||||||
etay=(+t)/sum;
|
/* etay=(+t)/sum; */
|
||||||
}
|
/* } */
|
||||||
|
|
||||||
return -1;
|
/* return -1; */
|
||||||
}
|
/* } */
|
||||||
|
|
||||||
static int calcMyEta(double totquad, int quad, int *cl, double &etax, double &etay) {
|
/* static int calcMyEta(double totquad, int quad, int *cl, double &etax, double &etay) { */
|
||||||
double l,r,t,b, sum;
|
/* double l,r,t,b, sum; */
|
||||||
int yoff;
|
/* int yoff; */
|
||||||
switch (quad) {
|
/* switch (quad) { */
|
||||||
case BOTTOM_LEFT:
|
/* case BOTTOM_LEFT: */
|
||||||
case BOTTOM_RIGHT:
|
/* case BOTTOM_RIGHT: */
|
||||||
yoff=0;
|
/* yoff=0; */
|
||||||
break;
|
/* break; */
|
||||||
case TOP_LEFT:
|
/* case TOP_LEFT: */
|
||||||
case TOP_RIGHT:
|
/* case TOP_RIGHT: */
|
||||||
yoff=1;
|
/* yoff=1; */
|
||||||
break;
|
/* break; */
|
||||||
default:
|
/* default: */
|
||||||
;
|
/* ; */
|
||||||
}
|
/* } */
|
||||||
l=cl[0+yoff*3]+cl[0+yoff*3+3];
|
/* l=cl[0+yoff*3]+cl[0+yoff*3+3]; */
|
||||||
r=cl[2+yoff*3]+cl[2+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];
|
/* 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];
|
/* t=cl[0+yoff*3+3]+cl[1+yoff*3+3]*cl[0+yoff*3+3]; */
|
||||||
sum=t+b;
|
/* sum=t+b; */
|
||||||
if (sum>0) {
|
/* if (sum>0) { */
|
||||||
etax=(-l+r)/sum;
|
/* etax=(-l+r)/sum; */
|
||||||
etay=(+t)/sum;
|
/* etay=(+t)/sum; */
|
||||||
}
|
/* } */
|
||||||
|
|
||||||
return -1;
|
/* return -1; */
|
||||||
}
|
/* } */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int calcEta3X(double *cl, double &etax, double &etay, double &sum) {
|
/* static int calcEta3X(double *cl, double &etax, double &etay, double &sum) { */
|
||||||
double l,r,t,b;
|
/* double l,r,t,b; */
|
||||||
sum=cl[0]+cl[1]+cl[2]+cl[3]+cl[4]+cl[5]+cl[6]+cl[7]+cl[8];
|
/* sum=cl[0]+cl[1]+cl[2]+cl[3]+cl[4]+cl[5]+cl[6]+cl[7]+cl[8]; */
|
||||||
if (sum>0) {
|
/* if (sum>0) { */
|
||||||
l=cl[3];
|
/* l=cl[3]; */
|
||||||
r=cl[5];
|
/* r=cl[5]; */
|
||||||
b=cl[1];
|
/* b=cl[1]; */
|
||||||
t=cl[7];
|
/* t=cl[7]; */
|
||||||
etax=(-l+r)/sum;
|
/* etax=(-l+r)/sum; */
|
||||||
etay=(-b+t)/sum;
|
/* etay=(-b+t)/sum; */
|
||||||
}
|
/* } */
|
||||||
return -1;
|
/* return -1; */
|
||||||
}
|
/* } */
|
||||||
|
|
||||||
|
|
||||||
static int calcEta3X(int *cl, double &etax, double &etay, double &sum) {
|
/* static int calcEta3X(int *cl, double &etax, double &etay, double &sum) { */
|
||||||
double l,r,t,b;
|
/* double l,r,t,b; */
|
||||||
sum=cl[0]+cl[1]+cl[2]+cl[3]+cl[4]+cl[5]+cl[6]+cl[7]+cl[8];
|
/* sum=cl[0]+cl[1]+cl[2]+cl[3]+cl[4]+cl[5]+cl[6]+cl[7]+cl[8]; */
|
||||||
if (sum>0) {
|
/* if (sum>0) { */
|
||||||
l=cl[3];
|
/* l=cl[3]; */
|
||||||
r=cl[5];
|
/* r=cl[5]; */
|
||||||
b=cl[1];
|
/* b=cl[1]; */
|
||||||
t=cl[7];
|
/* t=cl[7]; */
|
||||||
etax=(-l+r)/sum;
|
/* etax=(-l+r)/sum; */
|
||||||
etay=(-b+t)/sum;
|
/* etay=(-b+t)/sum; */
|
||||||
}
|
/* } */
|
||||||
return -1;
|
/* return -1; */
|
||||||
}
|
/* } */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -521,14 +496,8 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
|||||||
protected:
|
protected:
|
||||||
int nPixelsX, nPixelsY;
|
int nPixelsX, nPixelsY;
|
||||||
int nSubPixels;
|
int nSubPixels;
|
||||||
#ifdef MYROOT1
|
|
||||||
TH2F *hint;
|
|
||||||
#endif
|
|
||||||
#ifndef MYROOT1
|
|
||||||
int *hint;
|
|
||||||
#endif
|
|
||||||
int id;
|
int id;
|
||||||
|
int *hint;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
#module add CBFlib/0.9.5
|
||||||
|
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include
|
||||||
|
|
||||||
|
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -pthread -lrt -ltiff -O3
|
||||||
|
|
||||||
|
MAIN=moench03ClusterFinder.cpp
|
||||||
|
|
||||||
|
|
||||||
|
all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
moenchClusterFinder: moench03ClusterFinder.cpp $(INCS) clean
|
||||||
|
g++ -o moenchClusterFinder moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER
|
||||||
|
|
||||||
|
moenchMakeEta: moench03Interpolation.cpp $(INCS) clean
|
||||||
|
g++ -o moenchMakeEta moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF
|
||||||
|
|
||||||
|
moenchInterpolation: moench03Interpolation.cpp $(INCS) clean
|
||||||
|
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
|
||||||
|
|
||||||
|
moenchNoInterpolation: moench03NoInterpolation.cpp $(INCS) clean
|
||||||
|
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
|
||||||
|
|
||||||
|
moenchPhotonCounter: moenchPhotonCounter.cpp $(INCS) clean
|
||||||
|
g++ -o moenchPhotonCounter moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER
|
||||||
|
|
||||||
|
moenchAnalog: moenchPhotonCounter.cpp $(INCS) clean
|
||||||
|
g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
|
||||||
|
|
||||||
|
|
@ -5,13 +5,17 @@ LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
|||||||
INCDIR=-I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/
|
INCDIR=-I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/
|
||||||
LIBHDF5=
|
LIBHDF5=
|
||||||
#-I../interpolations/etaVEL
|
#-I../interpolations/etaVEL
|
||||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -lhdf5 -ltiff -L$(ZMQLIB) -L$(CBFLIBDIR)/lib/
|
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -lhdf5 -ltiff -L$(ZMQLIB) -L$(CBFLIBDIR)/lib/ -O3
|
||||||
#-L../../bin
|
#-L../../bin
|
||||||
|
|
||||||
#DESTDIR?=../bin
|
#DESTDIR?=../bin
|
||||||
|
|
||||||
|
aaa: moenchZmqProcess
|
||||||
|
|
||||||
all: moenchZmqClusterFinder moenchZmqInterpolating moenchZmqAnalog
|
all: moenchZmqClusterFinder moenchZmqInterpolating moenchZmqAnalog
|
||||||
|
|
||||||
|
moenchZmqProcess: moenchZmqProcess.cpp $(INCS) clean
|
||||||
|
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ
|
||||||
|
|
||||||
moenchZmqInterpolating: $(MAIN) $(INCS) clean
|
moenchZmqInterpolating: $(MAIN) $(INCS) clean
|
||||||
g++ -o moenchZmqInterpolating moenchZmqInterpolating.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
g++ -o moenchZmqInterpolating moenchZmqInterpolating.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||||
@ -23,6 +27,6 @@ moenchZmqAnalog: $(MAIN) $(INCS) clean
|
|||||||
g++ -o moenchZmqAnalog moenchZmqAnalog.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
g++ -o moenchZmqAnalog moenchZmqAnalog.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f moench03ZmqInterpolating moench03ZmqClusterFinder moenchZmqAnalog
|
rm -f moench03ZmqInterpolating moench03ZmqClusterFinder moenchZmqAnalog moenchZmqProcess
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
ZMQLIB=../../slsReceiverSoftware/include
|
||||||
|
INCDIR= -I$(ZMQLIB) -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/
|
||||||
|
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -L$(ZMQLIB) -O3 -g
|
||||||
|
#-L../../bin -lhdf5 -L.
|
||||||
|
|
||||||
|
#DESTDIR?=../bin
|
||||||
|
|
||||||
|
all: moenchZmqProcess
|
||||||
|
|
||||||
|
moenchZmqProcess: moenchZmqProcess.cpp clean
|
||||||
|
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f moenchZmqProcess
|
||||||
|
|
||||||
|
|
@ -2,11 +2,19 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#include "moench03T1ZmqData.h"
|
//#include "moench03T1ZmqData.h"
|
||||||
#ifdef NEWRECEIVER
|
#ifdef NEWRECEIVER
|
||||||
|
#ifndef RECT
|
||||||
#include "moench03T1ReceiverDataNew.h"
|
#include "moench03T1ReceiverDataNew.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef RECT
|
||||||
|
#include "moench03T1ReceiverDataNewRect.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef CSAXS_FP
|
#ifdef CSAXS_FP
|
||||||
#include "moench03T1ReceiverData.h"
|
#include "moench03T1ReceiverData.h"
|
||||||
#endif
|
#endif
|
||||||
@ -40,7 +48,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
int p=10000;
|
int p=10000;
|
||||||
int fifosize=1000;
|
int fifosize=1000;
|
||||||
int nthreads=1;
|
int nthreads=24;
|
||||||
int nsubpix=25;
|
int nsubpix=25;
|
||||||
int etabins=nsubpix*10;
|
int etabins=nsubpix*10;
|
||||||
double etamin=-1, etamax=2;
|
double etamin=-1, etamax=2;
|
||||||
@ -58,6 +66,9 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
|
|
||||||
#ifdef NEWRECEIVER
|
#ifdef NEWRECEIVER
|
||||||
|
#ifdef RECT
|
||||||
|
cout << "Should be rectangular!" <<endl;
|
||||||
|
#endif
|
||||||
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
|
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
|
||||||
cout << "RECEIVER DATA WITH ONE HEADER!"<<endl;
|
cout << "RECEIVER DATA WITH ONE HEADER!"<<endl;
|
||||||
#endif
|
#endif
|
||||||
@ -135,6 +146,7 @@ int main(int argc, char *argv[]) {
|
|||||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||||
|
|
||||||
|
|
||||||
|
mt->setDetectorMode(ePhotonCounting);
|
||||||
mt->setFrameMode(eFrame);
|
mt->setFrameMode(eFrame);
|
||||||
mt->StartThreads();
|
mt->StartThreads();
|
||||||
mt->popFree(buff);
|
mt->popFree(buff);
|
||||||
|
@ -14,39 +14,61 @@
|
|||||||
#include "single_photon_hit.h"
|
#include "single_photon_hit.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "etaInterpolationPosXY.h"
|
//#include "etaInterpolationPosXY.h"
|
||||||
#include "noInterpolation.h"
|
#include "noInterpolation.h"
|
||||||
//#include "etaInterpolationAdaptiveBins.h"
|
#include "etaInterpolationCleverAdaptiveBins.h"
|
||||||
//#include "etaInterpolationRandomBins.h"
|
//#include "etaInterpolationRandomBins.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
#define NC 400
|
#define NC 400
|
||||||
#define NR 400
|
#define NR 400
|
||||||
|
#define MAX_ITERATIONS (nSubPixels*100)
|
||||||
|
|
||||||
#define XTALK
|
#define XTALK
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
/**
|
|
||||||
* trial.o [socket ip] [starting port number] [outfname]
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
#ifndef FF
|
||||||
if (argc<9) {
|
if (argc<9) {
|
||||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " etafile outfile runmin runmax ns cmin cmax" << endl;
|
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile outfile runmin runmax ns cmin cmax" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef FF
|
||||||
|
if (argc<7) {
|
||||||
|
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile runmin runmax cmin cmax" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
int iarg=4;
|
||||||
char infname[10000];
|
char infname[10000];
|
||||||
char fname[10000];
|
char fname[10000];
|
||||||
char outfname[10000];
|
char outfname[10000];
|
||||||
int runmin=atoi(argv[4]);
|
#ifndef FF
|
||||||
int runmax=atoi(argv[5]);
|
iarg=4;
|
||||||
int nsubpix=atoi(argv[6]);
|
#endif
|
||||||
float cmin=atof(argv[7]);
|
|
||||||
float cmax=atof(argv[8]);
|
|
||||||
|
|
||||||
|
#ifdef FF
|
||||||
|
iarg=3;
|
||||||
|
#endif
|
||||||
|
int runmin=atoi(argv[iarg++]);
|
||||||
|
int runmax=atoi(argv[iarg++]);
|
||||||
|
cout << "Run min: " << runmin << endl;
|
||||||
|
cout << "Run max: " << runmax << endl;
|
||||||
|
|
||||||
|
int nsubpix=4;
|
||||||
|
#ifndef FF
|
||||||
|
nsubpix=atoi(argv[iarg++]);
|
||||||
|
cout << "Subpix: " << nsubpix << endl;
|
||||||
|
#endif
|
||||||
|
float cmin=atof(argv[iarg++]);
|
||||||
|
float cmax=atof(argv[iarg++]);
|
||||||
|
cout << "Energy min: " << cmin << endl;
|
||||||
|
cout << "Energy max: " << cmax << endl;
|
||||||
|
//int etabins=500;
|
||||||
int etabins=1000;//nsubpix*2*100;
|
int etabins=1000;//nsubpix*2*100;
|
||||||
double etamin=-1, etamax=2;
|
double etamin=-1, etamax=2;
|
||||||
|
//double etamin=-0.1, etamax=1.1;
|
||||||
double eta3min=-2, eta3max=2;
|
double eta3min=-2, eta3max=2;
|
||||||
int quad;
|
int quad;
|
||||||
double sum, totquad;
|
double sum, totquad;
|
||||||
@ -58,9 +80,6 @@ int main(int argc, char *argv[]) {
|
|||||||
int ix, iy, isx, isy;
|
int ix, iy, isx, isy;
|
||||||
int nframes=0, lastframe=-1;
|
int nframes=0, lastframe=-1;
|
||||||
double d_x, d_y, res=5, xx, yy;
|
double d_x, d_y, res=5, xx, yy;
|
||||||
#ifdef MANYFILES
|
|
||||||
int ff=1000;
|
|
||||||
#endif
|
|
||||||
int nph=0, badph=0, totph=0;
|
int nph=0, badph=0, totph=0;
|
||||||
FILE *f=NULL;
|
FILE *f=NULL;
|
||||||
|
|
||||||
@ -72,32 +91,29 @@ int main(int argc, char *argv[]) {
|
|||||||
single_photon_hit cl(3,3);
|
single_photon_hit cl(3,3);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XTALK
|
int nSubPixels=nsubpix;
|
||||||
int old_val[3][3];
|
#ifndef NOINTERPOLATION
|
||||||
int new_val[3][3];
|
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||||
double xcorr=0.04;
|
//eta2InterpolationCleverAdaptiveBins *interp=new eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||||
|
#endif
|
||||||
// int ix=0;
|
#ifdef NOINTERPOLATION
|
||||||
|
noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
|
|
||||||
eta3InterpolationPosXY *interp3=new eta3InterpolationPosXY(NC, NR, nsubpix, etabins, eta3min, eta3max);
|
|
||||||
noInterpolation *dummy=new noInterpolation(NC, NR, nsubpix);
|
|
||||||
noInterpolation *nointerp=new noInterpolation(NC, NR, nsubpix);
|
|
||||||
noInterpolation *mult=new noInterpolation(NC, NR, nsubpix);
|
|
||||||
//etaInterpolationAdaptiveBins *interp=new etaInterpolationAdaptiveBins (NC, NR, nsubpix, etabins, etamin, etamax);
|
|
||||||
//etaInterpolationRandomBins *interp=new etaInterpolationRandomBins (NC, NR, nsubpix, etabins, etamin, etamax);
|
|
||||||
//#ifndef FF
|
|
||||||
cout << "read ff " << argv[2] << endl;
|
|
||||||
sprintf(fname,"%s_eta2.tiff",argv[2]);
|
|
||||||
interp->readFlatField(fname);
|
|
||||||
interp->prepareInterpolation(ok);
|
|
||||||
|
|
||||||
sprintf(fname,"%s_eta3.tiff",argv[2]);
|
#ifndef FF
|
||||||
interp3->readFlatField(fname);
|
#ifndef NOINTERPOLATION
|
||||||
interp3->prepareInterpolation(ok);
|
cout << "read ff " << argv[2] << endl;
|
||||||
//#endif
|
sprintf(fname,"%s",argv[2]);
|
||||||
|
interp->readFlatField(fname);
|
||||||
|
interp->prepareInterpolation(ok);//, MAX_ITERATIONS);
|
||||||
|
#endif
|
||||||
|
// return 0;
|
||||||
|
#endif
|
||||||
|
#ifdef FF
|
||||||
|
cout << "Will write eta file " << argv[2] << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
int *img;
|
int *img;
|
||||||
float *totimg=new float[NC*NR*nsubpix*nsubpix];
|
float *totimg=new float[NC*NR*nsubpix*nsubpix];
|
||||||
@ -110,20 +126,18 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FF
|
#ifdef FF
|
||||||
|
sprintf(outfname,argv[2]);
|
||||||
float ff[nsubpix*nsubpix];
|
|
||||||
float *ffimg=new float[NC*NR*nsubpix*nsubpix];
|
|
||||||
float totff=0;
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int irun;
|
int irun;
|
||||||
for (irun=runmin; irun<runmax; irun++) {
|
for (irun=runmin; irun<runmax; irun++) {
|
||||||
sprintf(infname,argv[1],irun);
|
sprintf(infname,argv[1],irun);
|
||||||
#ifndef MANYFILES
|
#ifndef FF
|
||||||
sprintf(outfname,argv[3],irun);
|
sprintf(outfname,argv[3],irun);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
f=fopen(infname,"r");
|
f=fopen(infname,"r");
|
||||||
if (f) {
|
if (f) {
|
||||||
cout << infname << endl;
|
cout << infname << endl;
|
||||||
@ -138,157 +152,71 @@ int main(int argc, char *argv[]) {
|
|||||||
// f0=cl.iframe;
|
// f0=cl.iframe;
|
||||||
if (nframes==0) f0=lastframe;
|
if (nframes==0) f0=lastframe;
|
||||||
nframes++;
|
nframes++;
|
||||||
#ifdef MANYFILES
|
|
||||||
if (nframes%ff==0) {
|
|
||||||
sprintf(outfname,argv[3],irun,nframes-ff);
|
|
||||||
cout << outfname << endl;
|
|
||||||
interp->writeInterpolatedImage(outfname);
|
|
||||||
interp->clearInterpolatedImage();
|
|
||||||
}
|
}
|
||||||
#endif
|
//quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
||||||
|
quad=interp->calcEta(cl.get_cluster(), etax, etay, sum, totquad, sDum);
|
||||||
}
|
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && sum<cmax ) {
|
||||||
#ifdef XTALK
|
|
||||||
if ((cl.x+1)%25!=0) {
|
|
||||||
for (int ix=-1; ix<2; ix++) {
|
|
||||||
for (int iy=-1; iy<2; iy++) {
|
|
||||||
old_val[iy+1][ix+1]=cl.get_data(ix,iy);
|
|
||||||
if (ix>=0) {
|
|
||||||
new_val[iy+1][ix+1]=old_val[iy+1][ix+1]-old_val[iy+1][ix]*xcorr;
|
|
||||||
cl.set_data(new_val[iy+1][ix+1],ix,iy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
|
||||||
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && totquad<cmax && quad<cmax) {
|
|
||||||
nph++;
|
nph++;
|
||||||
// if (sum>200 && sum<580) {
|
// if (sum>200 && sum<580) {
|
||||||
// interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y);
|
// interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y);
|
||||||
interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
|
// #ifdef SOLEIL
|
||||||
|
// if (cl.x>210 && cl.x<240 && cl.y>210 && cl.y<240) {
|
||||||
|
// #endif
|
||||||
|
#ifndef FF
|
||||||
|
// interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
|
||||||
|
interp->getInterpolatedPosition(cl.x,cl.y, etax, etay, quad,int_x, int_y);
|
||||||
|
// cout <<"**************"<< endl;
|
||||||
|
// cout << cl.x << " " << cl.y << " " << sum << endl;
|
||||||
|
// cl.print();
|
||||||
|
// cout << int_x << " " << int_y << endl;
|
||||||
|
// cout <<"**************"<< endl;
|
||||||
|
// if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
|
||||||
interp->addToImage(int_x, int_y);
|
interp->addToImage(int_x, int_y);
|
||||||
interp3->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int3_x, int3_y);
|
if (int_x<0 || int_y<0 || int_x>400 || int_y>400) {
|
||||||
interp3->addToImage(int3_x, int3_y);
|
cout <<"**************"<< endl;
|
||||||
nointerp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),noint_x, noint_y);
|
cout << cl.x << " " << cl.y << " " << sum << endl;
|
||||||
nointerp->addToImage(noint_x, noint_y);
|
cl.print();
|
||||||
|
cout << int_x << " " << int_y << endl;
|
||||||
|
cout <<"**************"<< endl;
|
||||||
d_x= (int_x-int3_x)*25.;
|
|
||||||
d_y= (int_y-int3_y)*25.;
|
|
||||||
dummy->calcEta(totquad, sDum, etax, etay);
|
|
||||||
xx=int_x;
|
|
||||||
yy=int_y;
|
|
||||||
if (etax<0.1 || etax>0.9) xx=int3_x;
|
|
||||||
if (etay<0.1 || etay>0.9) yy=int3_y;
|
|
||||||
dummy->addToImage(xx,yy);
|
|
||||||
|
|
||||||
if (d_x>res || d_x<-res || d_y>res || d_y<-res) {
|
|
||||||
badph++;
|
|
||||||
// cout << "delta (um): "<< d_x << " " << d_y << " " << cl.x << " " << cl.y << endl;
|
|
||||||
// cout << sum << " " << totquad << " " << etax << " "<< etay << endl;
|
|
||||||
// //cout<< int_x << " " << int_y << " " << int3_x << " " << int3_y << endl;
|
|
||||||
}
|
}
|
||||||
mult->addToImage(noint_x, noint_y);
|
#endif
|
||||||
|
#ifdef FF
|
||||||
|
// interp->addToFlatField(cl.get_cluster(), etax, etay);
|
||||||
|
// #ifdef UCL
|
||||||
|
// if (cl.x>50)
|
||||||
|
// #endif
|
||||||
|
// if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
|
||||||
|
interp->addToFlatField(etax, etay);
|
||||||
|
// if (etax==0 || etay==0) cout << cl.x << " " << cl.y << endl;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
// #ifdef SOLEIL
|
||||||
|
// }
|
||||||
|
// #endif
|
||||||
|
|
||||||
if (nph%1000000==0) cout << nph << endl;
|
if (nph%1000000==0) cout << nph << endl;
|
||||||
if (nph%100000000==0) {
|
if (nph%10000000==0) {
|
||||||
sprintf(outfname,"%s_inteta2.tiff", argv[3]);
|
#ifndef FF
|
||||||
interp->writeInterpolatedImage(outfname);
|
interp->writeInterpolatedImage(outfname);
|
||||||
sprintf(outfname,"%s_inteta3.tiff", argv[3]);
|
#endif
|
||||||
interp3->writeInterpolatedImage(outfname);
|
#ifdef FF
|
||||||
sprintf(outfname,"%s_mix.tiff", argv[3]);
|
interp->writeFlatField(outfname);
|
||||||
dummy->writeInterpolatedImage(outfname);
|
#endif
|
||||||
sprintf(outfname,"%s_noint.tiff", argv[3]);
|
|
||||||
nointerp->writeInterpolatedImage(outfname);
|
}
|
||||||
sprintf(outfname,"%s_mult.tiff", argv[3]);
|
|
||||||
mult->writeInterpolatedImage(outfname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
mult->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
|
|
||||||
for (int imult=0; imult<2.*sum/(cmax+cmin); imult++) mult->addToImage(int_x, int_y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
#ifdef FF
|
#ifdef FF
|
||||||
img=interp->getInterpolatedImage();
|
interp->writeFlatField(outfname);
|
||||||
for (isx=0; isx<nsubpix; isx++) {
|
|
||||||
for (isy=0; isy<nsubpix; isy++) {
|
|
||||||
ff[isy*nsubpix+isx]=0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
totff=0;
|
|
||||||
for (ix=0; ix<NC; ix++) {
|
|
||||||
for (iy=0; iy<NR-100; iy++) {
|
|
||||||
for (isx=0; isx<nsubpix; isx++) {
|
|
||||||
for (isy=0; isy<nsubpix; isy++) {
|
|
||||||
ff[isy*nsubpix+isx]+=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (isx=0; isx<nsubpix; isx++) {
|
|
||||||
for (isy=0; isy<nsubpix; isy++) {
|
|
||||||
totff+=ff[isy*nsubpix+isx];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
totff/=nsubpix*nsubpix;
|
|
||||||
|
|
||||||
|
|
||||||
if (totff) {
|
|
||||||
|
|
||||||
cout << "ff: " << totff << endl;
|
|
||||||
|
|
||||||
for (isx=0; isx<nsubpix; isx++) {
|
|
||||||
for (isy=0; isy<nsubpix; isy++) {
|
|
||||||
ff[isy*nsubpix+isx]/=totff;
|
|
||||||
cout << ff[isy*nsubpix+isx] << "\t";
|
|
||||||
}
|
|
||||||
cout << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (ix=0; ix<NC; ix++) {
|
|
||||||
for (iy=0; iy<NR; iy++) {
|
|
||||||
for (isx=0; isx<nsubpix; isx++) {
|
|
||||||
for (isy=0; isy<nsubpix; isy++) {
|
|
||||||
ffimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]/ff[isy*nsubpix+isx];
|
|
||||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]+=ffimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cout << "writing eta!" << endl;
|
|
||||||
WriteToTiff(ffimg, outfname,NC*nsubpix,NR*nsubpix);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FF
|
#ifndef FF
|
||||||
|
|
||||||
#ifdef MANYFILES
|
|
||||||
sprintf(outfname,argv[3],irun,nframes-ff);
|
|
||||||
cout << outfname << endl;
|
|
||||||
#endif
|
|
||||||
sprintf(outfname,"%s_inteta2.tiff", argv[3]);
|
|
||||||
interp->writeInterpolatedImage(outfname);
|
interp->writeInterpolatedImage(outfname);
|
||||||
sprintf(outfname,"%s_inteta3.tiff", argv[3]);
|
|
||||||
interp3->writeInterpolatedImage(outfname);
|
|
||||||
sprintf(outfname,"%s_mix.tiff", argv[3]);
|
|
||||||
dummy->writeInterpolatedImage(outfname);
|
|
||||||
sprintf(outfname,"%s_mult.tiff", argv[3]);
|
|
||||||
mult->writeInterpolatedImage(outfname);
|
|
||||||
|
|
||||||
#ifndef MANYFILES
|
|
||||||
img=interp->getInterpolatedImage();
|
img=interp->getInterpolatedImage();
|
||||||
for (ix=0; ix<NC; ix++) {
|
for (ix=0; ix<NC; ix++) {
|
||||||
for (iy=0; iy<NR; iy++) {
|
for (iy=0; iy<NR; iy++) {
|
||||||
@ -299,24 +227,23 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
cout << "Read " << nframes << " frames (first frame: " << f0 << " last frame: " << lastframe << " delta:" << lastframe-f0 << ") nph="<< nph <<endl;
|
||||||
|
|
||||||
#endif
|
|
||||||
cout << "Read " << nframes << " frames (first frame: " << f0 << " last frame: " << lastframe << " delta:" << lastframe-f0 << ")"<<endl;
|
|
||||||
interp->clearInterpolatedImage();
|
interp->clearInterpolatedImage();
|
||||||
interp3->clearInterpolatedImage();
|
#endif
|
||||||
dummy->clearInterpolatedImage();
|
|
||||||
mult->clearInterpolatedImage();
|
|
||||||
|
|
||||||
} else
|
} else
|
||||||
cout << "could not open file " << infname << endl;
|
cout << "could not open file " << infname << endl;
|
||||||
}
|
}
|
||||||
cout << irun << " " << runmax << endl;
|
#ifndef FF
|
||||||
#ifndef MANYFILES
|
|
||||||
sprintf(outfname,argv[3],11111);
|
sprintf(outfname,argv[3],11111);
|
||||||
WriteToTiff(totimg, outfname,NC*nsubpix,NR*nsubpix);
|
WriteToTiff(totimg, outfname,NC*nsubpix,NR*nsubpix);
|
||||||
#endif
|
#endif
|
||||||
cout << "Filled " << nph << " (/"<< totph <<") of which " << badph << " badly interpolated " << endl;
|
|
||||||
|
#ifdef FF
|
||||||
|
interp->writeFlatField(outfname);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cout << "Filled " << nph << " (/"<< totph <<") " << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,269 @@
|
|||||||
|
|
||||||
|
#include "ansi.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
//#include "moench03T1ZmqData.h"
|
||||||
|
//#define DOUBLE_SPH
|
||||||
|
//#define MANYFILES
|
||||||
|
|
||||||
|
#ifdef DOUBLE_SPH
|
||||||
|
#include "single_photon_hit_double.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DOUBLE_SPH
|
||||||
|
#include "single_photon_hit.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//#include "etaInterpolationPosXY.h"
|
||||||
|
#include "noInterpolation.h"
|
||||||
|
#include "etaInterpolationCleverAdaptiveBins.h"
|
||||||
|
//#include "etaInterpolationRandomBins.h"
|
||||||
|
using namespace std;
|
||||||
|
#define NC 400
|
||||||
|
#define NR 400
|
||||||
|
#define MAX_ITERATIONS (nSubPixels*100)
|
||||||
|
#define MAX_EBINS 100
|
||||||
|
#define XTALK
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
|
#ifndef FF
|
||||||
|
if (argc<9) {
|
||||||
|
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile outfile runmin runmax ns cmin cmax" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef FF
|
||||||
|
if (argc<7) {
|
||||||
|
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile runmin runmax cmin cmax" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
int iarg=4;
|
||||||
|
char infname[10000];
|
||||||
|
char fname[10000];
|
||||||
|
char outfname[10000];
|
||||||
|
#ifndef FF
|
||||||
|
iarg=4;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef FF
|
||||||
|
iarg=3;
|
||||||
|
#endif
|
||||||
|
int runmin=atoi(argv[iarg++]);
|
||||||
|
int runmax=atoi(argv[iarg++]);
|
||||||
|
cout << "Run min: " << runmin << endl;
|
||||||
|
cout << "Run max: " << runmax << endl;
|
||||||
|
|
||||||
|
int nsubpix=4;
|
||||||
|
#ifndef FF
|
||||||
|
nsubpix=atoi(argv[iarg++]);
|
||||||
|
cout << "Subpix: " << nsubpix << endl;
|
||||||
|
#endif
|
||||||
|
float cmin=atof(argv[iarg++]);
|
||||||
|
float cmax=atof(argv[iarg++]);
|
||||||
|
cout << "Energy min: " << cmin << endl;
|
||||||
|
cout << "Energy max: " << cmax << endl;
|
||||||
|
int n_ebins=1;
|
||||||
|
if (argc>iarg)
|
||||||
|
n_ebins=atoi(argv[iarg++]);
|
||||||
|
//int etabins=500;
|
||||||
|
int etabins=1000;//nsubpix*2*100;
|
||||||
|
double etamin=-1, etamax=2;
|
||||||
|
//double etamin=-0.1, etamax=1.1;
|
||||||
|
double eta3min=-2, eta3max=2;
|
||||||
|
int quad;
|
||||||
|
double sum, totquad;
|
||||||
|
double sDum[2][2];
|
||||||
|
double etax, etay, int_x, int_y;
|
||||||
|
double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y;
|
||||||
|
int ok;
|
||||||
|
int f0=-1;
|
||||||
|
int ix, iy, isx, isy;
|
||||||
|
int nframes=0, lastframe=-1;
|
||||||
|
double d_x, d_y, res=5, xx, yy;
|
||||||
|
int nph=0, badph=0, totph=0;
|
||||||
|
FILE *f=NULL;
|
||||||
|
|
||||||
|
#ifdef DOUBLE_SPH
|
||||||
|
single_photon_hit_double cl(3,3);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DOUBLE_SPH
|
||||||
|
single_photon_hit cl(3,3);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int nSubPixels=nsubpix;
|
||||||
|
|
||||||
|
int iebin=0;
|
||||||
|
double eb_size=(cmax-cmin)/n_ebins;
|
||||||
|
#ifndef NOINTERPOLATION
|
||||||
|
// eta2InterpolationPosXY *interp[MAX_EBINS];
|
||||||
|
eta2InterpolationCleverAdaptiveBins *interp[MAX_EBINS];
|
||||||
|
for (int i=0; i< n_ebins; i++) {
|
||||||
|
//interp[i]=new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||||
|
interp[i]=new eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef NOINTERPOLATION
|
||||||
|
noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FF
|
||||||
|
#ifndef NOINTERPOLATION
|
||||||
|
cout << "read ff " << argv[2] << endl;
|
||||||
|
for (int i=0; i< n_ebins; i++) {
|
||||||
|
sprintf(fname,argv[2],i);
|
||||||
|
interp[i]->readFlatField(fname);
|
||||||
|
interp[i]->prepareInterpolation(ok);//, MAX_ITERATIONS);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
// return 0;
|
||||||
|
#endif
|
||||||
|
#ifdef FF
|
||||||
|
cout << "Will write eta file " << argv[2] << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int *img;
|
||||||
|
float *totimg=new float[NC*NR*nsubpix*nsubpix];
|
||||||
|
for (ix=0; ix<NC; ix++) {
|
||||||
|
for (iy=0; iy<NR; iy++) {
|
||||||
|
for (isx=0; isx<nsubpix; isx++) {
|
||||||
|
for (isy=0; isy<nsubpix; isy++) {
|
||||||
|
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef FF
|
||||||
|
sprintf(outfname,argv[2]);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int irun;
|
||||||
|
for (irun=runmin; irun<runmax; irun++) {
|
||||||
|
sprintf(infname,argv[1],irun);
|
||||||
|
#ifndef FF
|
||||||
|
sprintf(outfname,argv[3],irun);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
f=fopen(infname,"r");
|
||||||
|
if (f) {
|
||||||
|
cout << infname << endl;
|
||||||
|
nframes=0;
|
||||||
|
f0=-1;
|
||||||
|
|
||||||
|
while (cl.read(f)) {
|
||||||
|
totph++;
|
||||||
|
if (lastframe!=cl.iframe) {
|
||||||
|
lastframe=cl.iframe;
|
||||||
|
// cout << cl.iframe << endl;
|
||||||
|
// f0=cl.iframe;
|
||||||
|
if (nframes==0) f0=lastframe;
|
||||||
|
nframes++;
|
||||||
|
}
|
||||||
|
//quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
||||||
|
quad=interp[0]->calcEta(cl.get_cluster(), etax, etay, sum, totquad, sDum);
|
||||||
|
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && sum<cmax ) {
|
||||||
|
nph++;
|
||||||
|
iebin=(sum-cmin)/eb_size;
|
||||||
|
if (iebin>=0 && iebin<n_ebins) {
|
||||||
|
// if (sum>200 && sum<580) {
|
||||||
|
// interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y);
|
||||||
|
// #ifdef SOLEIL
|
||||||
|
// if (cl.x>210 && cl.x<240 && cl.y>210 && cl.y<240) {
|
||||||
|
// #endif
|
||||||
|
#ifndef FF
|
||||||
|
// interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
|
||||||
|
interp[iebin]->getInterpolatedPosition(cl.x,cl.y, etax, etay, quad,int_x, int_y);
|
||||||
|
// cout <<"**************"<< endl;
|
||||||
|
// cout << cl.x << " " << cl.y << " " << sum << endl;
|
||||||
|
// cl.print();
|
||||||
|
// cout << int_x << " " << int_y << endl;
|
||||||
|
// cout <<"**************"<< endl;
|
||||||
|
if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
|
||||||
|
interp[iebin]->addToImage(int_x, int_y);
|
||||||
|
#endif
|
||||||
|
#ifdef FF
|
||||||
|
// interp->addToFlatField(cl.get_cluster(), etax, etay);
|
||||||
|
#ifdef UCL
|
||||||
|
if (cl.x>50)
|
||||||
|
#endif
|
||||||
|
if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
|
||||||
|
interp[iebin]->addToFlatField(etax, etay);
|
||||||
|
// if (etax==0 || etay==0) cout << cl.x << " " << cl.y << endl;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
// #ifdef SOLEIL
|
||||||
|
// }
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
if (nph%1000000==0) cout << nph << endl;
|
||||||
|
if (nph%10000000==0) {
|
||||||
|
#ifndef FF
|
||||||
|
for (int i=0; i<n_ebins; i++) {
|
||||||
|
sprintf(outfname,argv[3],i);
|
||||||
|
interp[i]->writeInterpolatedImage(outfname);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef FF
|
||||||
|
for (int i=0; i<n_ebins; i++) {
|
||||||
|
sprintf(outfname,argv[2],i);
|
||||||
|
cout << outfname << " " << argv[2] << " " << i << endl;
|
||||||
|
interp[i]->writeFlatField(outfname);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
#ifdef FF
|
||||||
|
for (int i=0; i<n_ebins; i++) {
|
||||||
|
sprintf(outfname,argv[2],i);
|
||||||
|
cout << outfname << " " << argv[2] << " " << i << endl;
|
||||||
|
interp[i]->writeFlatField(outfname);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FF
|
||||||
|
for (int i=0; i<n_ebins; i++) {
|
||||||
|
sprintf(outfname,argv[3],i,irun);
|
||||||
|
interp[i]->writeInterpolatedImage(outfname);
|
||||||
|
img=interp[i]->getInterpolatedImage();
|
||||||
|
for (ix=0; ix<NC; ix++) {
|
||||||
|
for (iy=0; iy<NR; iy++) {
|
||||||
|
for (isx=0; isx<nsubpix; isx++) {
|
||||||
|
for (isy=0; isy<nsubpix; isy++) {
|
||||||
|
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]+=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//interp[i]->clearInterpolatedImage();
|
||||||
|
}
|
||||||
|
cout << "Read " << nframes << " frames (first frame: " << f0 << " last frame: " << lastframe << " delta:" << lastframe-f0 << ")"<<endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} else
|
||||||
|
cout << "could not open file " << infname << endl;
|
||||||
|
}
|
||||||
|
#ifndef FF
|
||||||
|
sprintf(outfname,argv[3], 11111);
|
||||||
|
WriteToTiff(totimg, outfname,NC*nsubpix,NR*nsubpix);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef FF
|
||||||
|
interp[iebin]->writeFlatField(outfname);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cout << "Filled " << nph << " (/"<< totph <<") " << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
242
slsDetectorCalibration/moenchExecutables/moenchAnalog.cpp
Normal file
242
slsDetectorCalibration/moenchExecutables/moenchAnalog.cpp
Normal file
@ -0,0 +1,242 @@
|
|||||||
|
//#include "ansi.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#include "moench03T1ZmqData.h"
|
||||||
|
#ifdef NEWRECEIVER
|
||||||
|
#include "moench03T1ReceiverDataNew.h"
|
||||||
|
#endif
|
||||||
|
#ifdef CSAXS_FP
|
||||||
|
#include "moench03T1ReceiverData.h"
|
||||||
|
#endif
|
||||||
|
#ifdef OLDDATA
|
||||||
|
#include "moench03Ctb10GbT1Data.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// #include "interpolatingDetector.h"
|
||||||
|
//#include "etaInterpolationPosXY.h"
|
||||||
|
// #include "linearInterpolation.h"
|
||||||
|
// #include "noInterpolation.h"
|
||||||
|
#include "multiThreadedAnalogDetector.h"
|
||||||
|
#include "singlePhotonDetector.h"
|
||||||
|
//#include "interpolatingDetector.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <map>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
|
|
||||||
|
if (argc<4) {
|
||||||
|
cout << "Usage is " << argv[0] << "indir outdir fname [pedfile] [threshold]" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int p=10000;
|
||||||
|
int fifosize=1000;
|
||||||
|
int nthreads=8;
|
||||||
|
int nsubpix=25;
|
||||||
|
int etabins=nsubpix*10;
|
||||||
|
double etamin=-1, etamax=2;
|
||||||
|
int csize=3;
|
||||||
|
int nx=400, ny=400;
|
||||||
|
int save=1;
|
||||||
|
int nsigma=5;
|
||||||
|
int nped=1000;
|
||||||
|
int ndark=100;
|
||||||
|
int ok;
|
||||||
|
int iprog=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef NEWRECEIVER
|
||||||
|
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
|
||||||
|
cout << "RECEIVER DATA WITH ONE HEADER!"<<endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CSAXS_FP
|
||||||
|
moench03T1ReceiverData *decoder=new moench03T1ReceiverData();
|
||||||
|
cout << "RECEIVER DATA WITH ALL HEADERS!"<<endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef OLDDATA
|
||||||
|
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
|
||||||
|
cout << "OLD RECEIVER DATA!"<<endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ANALOG
|
||||||
|
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||||
|
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
|
||||||
|
// char tit[10000];
|
||||||
|
cout << "filter " << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ANALOG
|
||||||
|
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||||
|
analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(decoder, 1, 0, nped);
|
||||||
|
// char tit[10000];
|
||||||
|
cout << "filter " << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||||
|
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||||
|
// cout << "filter "<< endl;
|
||||||
|
|
||||||
|
|
||||||
|
int size = 327680;////atoi(argv[3]);
|
||||||
|
|
||||||
|
int* image;
|
||||||
|
//int* image =new int[327680/sizeof(int)];
|
||||||
|
filter->newDataSet();
|
||||||
|
|
||||||
|
|
||||||
|
int ff, np;
|
||||||
|
int dsize=decoder->getDataSize();
|
||||||
|
cout << " data size is " << dsize;
|
||||||
|
|
||||||
|
|
||||||
|
char data[dsize];
|
||||||
|
|
||||||
|
ifstream filebin;
|
||||||
|
char *indir=argv[1];
|
||||||
|
char *outdir=argv[2];
|
||||||
|
char *fformat=argv[3];
|
||||||
|
char *pedfile=NULL;
|
||||||
|
if (argc>=5) {
|
||||||
|
pedfile=argv[4];
|
||||||
|
}
|
||||||
|
double thr=0;
|
||||||
|
if (argc>=6) {
|
||||||
|
thr=atoi(argv[5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char fname[10000];
|
||||||
|
char imgfname[10000];
|
||||||
|
// strcpy(pedfname,argv[6]);
|
||||||
|
char fn[10000];
|
||||||
|
|
||||||
|
std::time_t end_time;
|
||||||
|
|
||||||
|
FILE *of=NULL;
|
||||||
|
cout << "input directory is " << indir << endl;
|
||||||
|
cout << "output directory is " << outdir << endl;
|
||||||
|
cout << "input file is " << fformat << endl;
|
||||||
|
if (pedfile)
|
||||||
|
cout << "pedestal file is " << pedfile << endl;
|
||||||
|
if (thr>0) {
|
||||||
|
cout << "threshold is " << thr << endl;
|
||||||
|
filter->setThreshold(thr);
|
||||||
|
}
|
||||||
|
|
||||||
|
filter->setROI(0,150,0,150);
|
||||||
|
|
||||||
|
std::time(&end_time);
|
||||||
|
cout << std::ctime(&end_time) << endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
char* buff;
|
||||||
|
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||||
|
|
||||||
|
|
||||||
|
mt->StartThreads();
|
||||||
|
mt->popFree(buff);
|
||||||
|
|
||||||
|
|
||||||
|
cout << "mt " << endl;
|
||||||
|
|
||||||
|
int ifr=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (int irun=0; irun<2; irun++) {
|
||||||
|
if (irun>0) {
|
||||||
|
mt->setFrameMode(eFrame);
|
||||||
|
// sprintf(fn,fformat,irun);
|
||||||
|
sprintf(fname,"%s/%s.raw",indir,fformat);
|
||||||
|
// sprintf(outfname,"%s/%s.clust",outdir,fn);
|
||||||
|
sprintf(imgfname,"%s/%s.tiff",outdir,fformat);
|
||||||
|
} else {
|
||||||
|
mt->setFrameMode(ePedestal);
|
||||||
|
// sprintf(fn,fformat,irun);
|
||||||
|
sprintf(fname,"%s/%s.raw",indir,pedfile);
|
||||||
|
// sprintf(outfname,"%s/%s.clust",outdir,fn);
|
||||||
|
// sprintf(imgfname,"%s/%s.tiff",outdir,fn);
|
||||||
|
}
|
||||||
|
cout << fname << endl;
|
||||||
|
std::time(&end_time);
|
||||||
|
cout << std::ctime(&end_time) << endl;
|
||||||
|
// cout << fname << " " << outfname << " " << imgfname << endl;
|
||||||
|
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||||
|
// //open file
|
||||||
|
if (filebin.is_open()){
|
||||||
|
// of=fopen(outfname,"w");
|
||||||
|
// if (of) {
|
||||||
|
// mt->setFilePointer(of);
|
||||||
|
// // cout << "file pointer set " << endl;
|
||||||
|
// } else {
|
||||||
|
// cout << "Could not open "<< outfname << " for writing " << endl;
|
||||||
|
// mt->setFilePointer(NULL);
|
||||||
|
// return 1;
|
||||||
|
// }
|
||||||
|
// //while read frame
|
||||||
|
ff=-1;
|
||||||
|
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||||
|
// cout << "*"<<ifr++<<"*"<<ff<< endl;
|
||||||
|
// cout << ff << " " << np << endl;
|
||||||
|
// //push
|
||||||
|
mt->pushData(buff);
|
||||||
|
// // //pop
|
||||||
|
mt->nextThread();
|
||||||
|
// // // cout << " " << (void*)buff;
|
||||||
|
mt->popFree(buff);
|
||||||
|
ifr++;
|
||||||
|
if (ifr%10000==0) cout << ifr << " " << ff << endl;
|
||||||
|
ff=-1;
|
||||||
|
}
|
||||||
|
cout << "--" << endl;
|
||||||
|
filebin.close();
|
||||||
|
// //close file
|
||||||
|
// //join threads
|
||||||
|
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||||
|
// if (of)
|
||||||
|
// fclose(of);
|
||||||
|
if (irun>0) {
|
||||||
|
cout << "Writing tiff to " << imgfname << endl;
|
||||||
|
mt->writeImage(imgfname);
|
||||||
|
// mt->clearImage();
|
||||||
|
}
|
||||||
|
std::time(&end_time);
|
||||||
|
cout << std::ctime(&end_time) << endl;
|
||||||
|
|
||||||
|
} else
|
||||||
|
cout << "Could not open "<< fname << " for reading " << endl;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
347
slsDetectorCalibration/moenchExecutables/moenchPhotonCounter.cpp
Normal file
347
slsDetectorCalibration/moenchExecutables/moenchPhotonCounter.cpp
Normal file
@ -0,0 +1,347 @@
|
|||||||
|
//#include "ansi.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#include "moench03T1ZmqData.h"
|
||||||
|
#ifdef NEWRECEIVER
|
||||||
|
#ifndef RECT
|
||||||
|
#include "moench03T1ReceiverDataNew.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef RECT
|
||||||
|
#include "moench03T1ReceiverDataNewRect.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CSAXS_FP
|
||||||
|
#include "moench03T1ReceiverData.h"
|
||||||
|
#endif
|
||||||
|
#ifdef OLDDATA
|
||||||
|
#include "moench03Ctb10GbT1Data.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// #include "interpolatingDetector.h"
|
||||||
|
//#include "etaInterpolationPosXY.h"
|
||||||
|
// #include "linearInterpolation.h"
|
||||||
|
// #include "noInterpolation.h"
|
||||||
|
#include "multiThreadedAnalogDetector.h"
|
||||||
|
#include "singlePhotonDetector.h"
|
||||||
|
//#include "interpolatingDetector.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <map>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
|
|
||||||
|
if (argc<4) {
|
||||||
|
cout << "Usage is " << argv[0] << "indir outdir fname [runmin] [runmax] [pedfile] [threshold] [nframes] [xmin xmax ymin ymax]" << endl;
|
||||||
|
cout << "threshold <0 means analog; threshold=0 means cluster finder; threshold>0 means photon counting" << endl;
|
||||||
|
cout << "nframes <0 means sum everything; nframes=0 means one file per run; nframes>0 means one file every nframes" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int p=10000;
|
||||||
|
int fifosize=1000;
|
||||||
|
int nthreads=8;
|
||||||
|
int nsubpix=25;
|
||||||
|
int etabins=nsubpix*10;
|
||||||
|
double etamin=-1, etamax=2;
|
||||||
|
int csize=3;
|
||||||
|
int save=1;
|
||||||
|
int nsigma=5;
|
||||||
|
int nped=1000;
|
||||||
|
int ndark=100;
|
||||||
|
int ok;
|
||||||
|
int iprog=0;
|
||||||
|
|
||||||
|
int cf=0;
|
||||||
|
|
||||||
|
#ifdef NEWRECEIVER
|
||||||
|
#ifdef RECT
|
||||||
|
cout << "Should be rectangular!" <<endl;
|
||||||
|
#endif
|
||||||
|
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
|
||||||
|
cout << "RECEIVER DATA WITH ONE HEADER!"<<endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CSAXS_FP
|
||||||
|
moench03T1ReceiverData *decoder=new moench03T1ReceiverData();
|
||||||
|
cout << "RECEIVER DATA WITH ALL HEADERS!"<<endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef OLDDATA
|
||||||
|
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
|
||||||
|
cout << "OLD RECEIVER DATA!"<<endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int nx=400, ny=400;
|
||||||
|
|
||||||
|
decoder->getDetectorSize(nx,ny);
|
||||||
|
|
||||||
|
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
|
||||||
|
|
||||||
|
int size = 327680;////atoi(argv[3]);
|
||||||
|
|
||||||
|
int* image;
|
||||||
|
//int* image =new int[327680/sizeof(int)];
|
||||||
|
filter->newDataSet();
|
||||||
|
|
||||||
|
|
||||||
|
int ff, np;
|
||||||
|
int dsize=decoder->getDataSize();
|
||||||
|
//cout << " data size is " << dsize;
|
||||||
|
|
||||||
|
|
||||||
|
char data[dsize];
|
||||||
|
|
||||||
|
ifstream filebin;
|
||||||
|
char *indir=argv[1];
|
||||||
|
char *outdir=argv[2];
|
||||||
|
char *fformat=argv[3];
|
||||||
|
int runmin=0;
|
||||||
|
|
||||||
|
// cout << "argc is " << argc << endl;
|
||||||
|
if (argc>=5) {
|
||||||
|
runmin=atoi(argv[4]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int runmax=runmin;
|
||||||
|
|
||||||
|
if (argc>=6) {
|
||||||
|
runmax=atoi(argv[5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *pedfile=NULL;
|
||||||
|
if (argc>=7) {
|
||||||
|
pedfile=argv[6];
|
||||||
|
}
|
||||||
|
double thr=0;
|
||||||
|
double thr1=1;
|
||||||
|
|
||||||
|
if (argc>=8) {
|
||||||
|
thr=atoi(argv[7]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int nframes=0;
|
||||||
|
|
||||||
|
if (argc>=9) {
|
||||||
|
nframes=atoi(argv[8]);
|
||||||
|
}
|
||||||
|
int xmin=0, xmax=nx, ymin=0, ymax=ny;
|
||||||
|
if (argc>=13) {
|
||||||
|
xmin=atoi(argv[9]);
|
||||||
|
xmax=atoi(argv[10]);
|
||||||
|
ymin=atoi(argv[11]);
|
||||||
|
ymax=atoi(argv[12]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
char ffname[10000];
|
||||||
|
char fname[10000];
|
||||||
|
char imgfname[10000];
|
||||||
|
char cfname[10000];
|
||||||
|
char fn[10000];
|
||||||
|
|
||||||
|
std::time_t end_time;
|
||||||
|
|
||||||
|
FILE *of=NULL;
|
||||||
|
cout << "input directory is " << indir << endl;
|
||||||
|
cout << "output directory is " << outdir << endl;
|
||||||
|
cout << "input file is " << fformat << endl;
|
||||||
|
cout << "runmin is " << runmin << endl;
|
||||||
|
cout << "runmax is " << runmax << endl;
|
||||||
|
if (pedfile)
|
||||||
|
cout << "pedestal file is " << pedfile << endl;
|
||||||
|
//#ifndef ANALOG
|
||||||
|
if (thr>0) {
|
||||||
|
cout << "threshold is " << thr << endl;
|
||||||
|
filter->setThreshold(thr);
|
||||||
|
} else
|
||||||
|
cf=1;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
|
filter->setROI(xmin,xmax,ymin,ymax);
|
||||||
|
#ifdef SOLEIL
|
||||||
|
filter->setROI(150,210,170,230);
|
||||||
|
nframes=-1;
|
||||||
|
#endif
|
||||||
|
std::time(&end_time);
|
||||||
|
cout << std::ctime(&end_time) << endl;
|
||||||
|
|
||||||
|
char* buff;
|
||||||
|
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||||
|
#ifndef ANALOG
|
||||||
|
mt->setDetectorMode(ePhotonCounting);
|
||||||
|
cout << "Counting!" << endl;
|
||||||
|
if (thr>0) {
|
||||||
|
cf=0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
//{
|
||||||
|
#ifdef ANALOG
|
||||||
|
mt->setDetectorMode(eAnalog);
|
||||||
|
cout << "Analog!" << endl;
|
||||||
|
cf=0;
|
||||||
|
// #ifdef ANALOG
|
||||||
|
// thr1=thr;
|
||||||
|
#endif
|
||||||
|
// }
|
||||||
|
|
||||||
|
mt->StartThreads();
|
||||||
|
mt->popFree(buff);
|
||||||
|
|
||||||
|
|
||||||
|
// cout << "mt " << endl;
|
||||||
|
|
||||||
|
int ifr=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (pedfile) {
|
||||||
|
cout << "PEDESTAL " ;
|
||||||
|
sprintf(fname,"%s.raw",pedfile);
|
||||||
|
cout << fname << endl ;
|
||||||
|
sprintf(imgfname,"%s/pedestals.tiff",outdir,fformat);
|
||||||
|
std::time(&end_time);
|
||||||
|
cout << "aaa" << std::ctime(&end_time) << endl;
|
||||||
|
|
||||||
|
|
||||||
|
mt->setFrameMode(ePedestal);
|
||||||
|
// sprintf(fn,fformat,irun);
|
||||||
|
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||||
|
// //open file
|
||||||
|
if (filebin.is_open()){
|
||||||
|
ff=-1;
|
||||||
|
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||||
|
mt->pushData(buff);
|
||||||
|
mt->nextThread();
|
||||||
|
mt->popFree(buff);
|
||||||
|
ifr++;
|
||||||
|
if (ifr%10000==0)
|
||||||
|
cout << ifr << " " << ff << " " << np << endl;
|
||||||
|
ff=-1;
|
||||||
|
}
|
||||||
|
filebin.close();
|
||||||
|
while (mt->isBusy()) {;}
|
||||||
|
mt->writePedestal(imgfname);
|
||||||
|
std::time(&end_time);
|
||||||
|
cout << std::ctime(&end_time) << endl;
|
||||||
|
|
||||||
|
} else
|
||||||
|
cout << "Could not open "<< fname << " for reading " << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ifr=0;
|
||||||
|
int ifile=0;
|
||||||
|
|
||||||
|
for (int irun=runmin; irun<=runmax; irun++) {
|
||||||
|
cout << "DATA " ;
|
||||||
|
mt->setFrameMode(eFrame);
|
||||||
|
// sprintf(fn,fformat,irun);
|
||||||
|
sprintf(ffname,"%s/%s.raw",indir,fformat);
|
||||||
|
sprintf(fname,ffname,irun);
|
||||||
|
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
|
||||||
|
sprintf(imgfname,ffname,irun);
|
||||||
|
sprintf(ffname,"%s/%s.clust",outdir,fformat);
|
||||||
|
sprintf(cfname,ffname,irun);
|
||||||
|
cout << fname << " " ;
|
||||||
|
cout << imgfname << endl;
|
||||||
|
std::time(&end_time);
|
||||||
|
cout << std::ctime(&end_time) << endl;
|
||||||
|
// cout << fname << " " << outfname << " " << imgfname << endl;
|
||||||
|
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||||
|
// //open file
|
||||||
|
ifile=0;
|
||||||
|
if (filebin.is_open()){
|
||||||
|
if (thr<=0) {
|
||||||
|
if (cf) {
|
||||||
|
if (of==NULL) {
|
||||||
|
of=fopen(cfname,"w");
|
||||||
|
if (of) {
|
||||||
|
mt->setFilePointer(of);
|
||||||
|
cout << "file pointer set " << endl;
|
||||||
|
} else {
|
||||||
|
cout << "Could not open "<< cfname << " for writing " << endl;
|
||||||
|
mt->setFilePointer(NULL);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// //while read frame
|
||||||
|
ff=-1;
|
||||||
|
ifr=0;
|
||||||
|
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||||
|
// cout << "*"<<ifr++<<"*"<<ff<< endl;
|
||||||
|
// cout << ff << " " << np << endl;
|
||||||
|
// //push
|
||||||
|
mt->pushData(buff);
|
||||||
|
// // //pop
|
||||||
|
mt->nextThread();
|
||||||
|
// // // cout << " " << (void*)buff;
|
||||||
|
mt->popFree(buff);
|
||||||
|
ifr++;
|
||||||
|
if (ifr%1000==0) cout << ifr << " " << ff << endl;
|
||||||
|
if (nframes>0) {
|
||||||
|
if (ifr%nframes==0) {
|
||||||
|
//The name has an additional "_fXXXXX" at the end, where "XXXXX" is the initial frame number of the image (0,1000,2000...)
|
||||||
|
|
||||||
|
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
|
||||||
|
sprintf(imgfname,ffname,irun);
|
||||||
|
//cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
|
||||||
|
mt->writeImage(imgfname, thr1);
|
||||||
|
mt->clearImage();
|
||||||
|
ifile++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ff=-1;
|
||||||
|
}
|
||||||
|
cout << "--" << endl;
|
||||||
|
filebin.close();
|
||||||
|
// //close file
|
||||||
|
// //join threads
|
||||||
|
while (mt->isBusy()) {;}
|
||||||
|
if (nframes>=0) {
|
||||||
|
if (nframes>0) {
|
||||||
|
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
|
||||||
|
sprintf(imgfname,ffname,irun);
|
||||||
|
}
|
||||||
|
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
|
||||||
|
sprintf(imgfname,ffname,irun);
|
||||||
|
cout << "Writing tiff to " << imgfname << " " << thr1 <<endl;
|
||||||
|
mt->writeImage(imgfname, thr1);
|
||||||
|
mt->clearImage();
|
||||||
|
if (of) {
|
||||||
|
fclose(of);
|
||||||
|
of=NULL;
|
||||||
|
mt->setFilePointer(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::time(&end_time);
|
||||||
|
cout << std::ctime(&end_time) << endl;
|
||||||
|
} else
|
||||||
|
cout << "Could not open "<< fname << " for reading " << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -8,6 +8,12 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "tiffIO.h"
|
#include "tiffIO.h"
|
||||||
|
|
||||||
|
|
||||||
|
//#define NEWZMQ
|
||||||
|
#ifdef NEWZMQ
|
||||||
|
#include <rapidjson/document.h> //json header in zmq stream
|
||||||
|
#endif
|
||||||
|
|
||||||
#include<iostream>
|
#include<iostream>
|
||||||
|
|
||||||
//#include "analogDetector.h"
|
//#include "analogDetector.h"
|
||||||
@ -39,8 +45,9 @@ int main(int argc, char *argv[]) {
|
|||||||
bool send = false;
|
bool send = false;
|
||||||
char* socketip=argv[1];
|
char* socketip=argv[1];
|
||||||
uint32_t portnum = atoi(argv[2]);
|
uint32_t portnum = atoi(argv[2]);
|
||||||
int size = 32*2*5000;//atoi(argv[3]);
|
int maxSize = 32*2*8192;//5000;//atoi(argv[3]);
|
||||||
|
int size= 32*2*5000;
|
||||||
|
int multisize=size;
|
||||||
// send parameters if any
|
// send parameters if any
|
||||||
char* socketip2 = 0;
|
char* socketip2 = 0;
|
||||||
uint32_t portnum2 = 0;
|
uint32_t portnum2 = 0;
|
||||||
@ -70,47 +77,88 @@ int main(int argc, char *argv[]) {
|
|||||||
mt->popFree(buff);
|
mt->popFree(buff);
|
||||||
|
|
||||||
|
|
||||||
|
ZmqSocket* zmqsocket=NULL;
|
||||||
|
|
||||||
|
#ifdef NEWZMQ
|
||||||
|
|
||||||
// receive socket
|
// receive socket
|
||||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
try{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
zmqsocket = new ZmqSocket(socketip,portnum);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef NEWZMQ
|
||||||
|
} catch (...) {
|
||||||
|
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||||
|
delete zmqsocket;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NEWZMQ
|
||||||
if (zmqsocket->IsError()) {
|
if (zmqsocket->IsError()) {
|
||||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||||
delete zmqsocket;
|
delete zmqsocket;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
zmqsocket->Connect();
|
#endif
|
||||||
|
if (zmqsocket->Connect()) {
|
||||||
|
cprintf(RED, "Error: Could not connect to socket %s\n",
|
||||||
|
zmqsocket->GetZmqServerAddress());
|
||||||
|
delete zmqsocket;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
} else
|
||||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||||
|
|
||||||
// send socket
|
// send socket
|
||||||
ZmqSocket* zmqsocket2 = 0;
|
ZmqSocket* zmqsocket2 = 0;
|
||||||
cout << "zmq2 " << endl;
|
cout << "zmq2 " << endl;
|
||||||
if (send) {
|
if (send) {
|
||||||
|
#ifdef NEWZMQ
|
||||||
|
// receive socket
|
||||||
|
try{
|
||||||
|
#endif
|
||||||
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
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);
|
|
||||||
|
|
||||||
|
#ifdef NEWZMQ
|
||||||
|
} catch (...) {
|
||||||
|
cprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||||
delete zmqsocket2;
|
delete zmqsocket2;
|
||||||
delete zmqsocket;
|
delete zmqsocket;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
zmqsocket2->Connect();
|
#endif
|
||||||
printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
|
||||||
|
#ifndef NEWZMQ
|
||||||
|
if (zmqsocket2->IsError()) {
|
||||||
|
cprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||||
|
delete zmqsocket2;
|
||||||
|
delete zmqsocket;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (zmqsocket2->Connect()) {
|
||||||
|
cprintf(RED, "Error: Could not connect to socket %s\n",
|
||||||
|
zmqsocket2->GetZmqServerAddress());
|
||||||
|
delete zmqsocket2;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
} else
|
||||||
|
printf("Zmq Client at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// header variables
|
// header variables
|
||||||
uint64_t acqIndex = -1;
|
uint64_t acqIndex = -1;
|
||||||
uint64_t frameIndex = -1;
|
uint64_t frameIndex = -1;
|
||||||
uint32_t subframeIndex = -1;
|
uint32_t subFrameIndex = -1;
|
||||||
uint64_t fileindex = -1;
|
uint64_t fileindex = -1;
|
||||||
string filename = "";
|
string filename = "";
|
||||||
char* image = new char[size];
|
// char* image = new char[size];
|
||||||
//int* image = new int[(size/sizeof(int))]();
|
//int* image = new int[(size/sizeof(int))]();
|
||||||
|
uint32_t flippedDataX = -1;
|
||||||
int *nph;
|
int *nph;
|
||||||
int iframe=0;
|
int iframe=0;
|
||||||
char ofname[10000];
|
char ofname[10000];
|
||||||
@ -119,17 +167,57 @@ int main(int argc, char *argv[]) {
|
|||||||
int length;
|
int length;
|
||||||
int *detimage;
|
int *detimage;
|
||||||
int nnx, nny,nns;
|
int nnx, nny,nns;
|
||||||
|
uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0;
|
||||||
filter->getImageSize(nnx, nny,nns);
|
filter->getImageSize(nnx, nny,nns);
|
||||||
int16_t *dout=new int16_t [nnx*nny];
|
int16_t *dout=new int16_t [nnx*nny];
|
||||||
// infinite loop
|
// infinite loop
|
||||||
|
uint32_t packetNumber = 0;
|
||||||
|
uint64_t bunchId = 0;
|
||||||
|
uint64_t timestamp = 0;
|
||||||
|
int16_t modId = 0;
|
||||||
|
uint16_t xCoord = 0;
|
||||||
|
uint16_t yCoord = 0;
|
||||||
|
uint16_t zCoord = 0;
|
||||||
|
uint32_t debug = 0;
|
||||||
|
uint32_t dr = 16;
|
||||||
|
uint16_t roundRNumber = 0;
|
||||||
|
uint8_t detType = 0;
|
||||||
|
uint8_t version = 0;
|
||||||
|
int* flippedData = 0;
|
||||||
|
char* additionalJsonHeader = 0;
|
||||||
|
|
||||||
|
uint32_t threshold=0;
|
||||||
|
|
||||||
|
uint32_t xmin=0, xmax=400, ymin=0, ymax=400;
|
||||||
|
|
||||||
|
string frameMode_s, detectorMode_s;
|
||||||
|
|
||||||
|
int emin, emax;
|
||||||
|
|
||||||
|
|
||||||
|
int newFrame=1;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
|
|
||||||
|
|
||||||
// cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
|
// cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
|
||||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||||
|
#ifndef NEWZMQ
|
||||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){
|
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NEWZMQ
|
||||||
|
rapidjson::Document doc;
|
||||||
|
if (!zmqsocket->ReceiveHeader(0, doc, SLS_DETECTOR_JSON_HEADER_VERSION)) {
|
||||||
|
zmqsocket->CloseHeaderMessage();
|
||||||
|
|
||||||
|
#endif
|
||||||
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
|
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
|
||||||
cprintf(RED, "Got Dummy\n");
|
cprintf(RED, "Got Dummy\n");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||||
|
|
||||||
|
|
||||||
@ -142,8 +230,18 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
if (send) {
|
if (send) {
|
||||||
strcpy(fname,filename.c_str());
|
strcpy(fname,filename.c_str());
|
||||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,16,fileindex,400,400,400*400, acqIndex,frameIndex,fname, acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
#ifdef NEWZMQ
|
||||||
|
//zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dynamicRange, fileindex,
|
||||||
|
// nnx, nny, nns*dynamicRange/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
|
||||||
|
|
||||||
|
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex,
|
||||||
|
nnx, nny, nns*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NEWZMQ
|
||||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||||
|
#endif
|
||||||
|
|
||||||
zmqsocket2->SendData((char*)dout,length);
|
zmqsocket2->SendData((char*)dout,length);
|
||||||
cprintf(GREEN, "Sent Data\n");
|
cprintf(GREEN, "Sent Data\n");
|
||||||
@ -161,9 +259,112 @@ int main(int argc, char *argv[]) {
|
|||||||
of=NULL;
|
of=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newFrame=1;
|
||||||
continue; //continue to not get out
|
continue; //continue to not get out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NEWZMQ
|
||||||
|
if (newFrame) {
|
||||||
|
// acqIndex, frameIndex, subframeIndex, filename, fileindex
|
||||||
|
size = doc["size"].GetUint();
|
||||||
|
multisize = size;// * zmqsocket->size();
|
||||||
|
dynamicRange = doc["bitmode"].GetUint();
|
||||||
|
nPixelsX = doc["shape"][0].GetUint();
|
||||||
|
nPixelsY = doc["shape"][1].GetUint();
|
||||||
|
filename = doc["fname"].GetString();
|
||||||
|
acqIndex = doc["acqIndex"].GetUint64();
|
||||||
|
frameIndex = doc["fIndex"].GetUint64();
|
||||||
|
fileindex = doc["fileIndex"].GetUint64();
|
||||||
|
subFrameIndex = doc["expLength"].GetUint();
|
||||||
|
xCoord = doc["xCoord"].GetUint();
|
||||||
|
yCoord = doc["yCoord"].GetUint();
|
||||||
|
zCoord = doc["zCoord"].GetUint();
|
||||||
|
flippedDataX=doc["flippedDataX"].GetUint();
|
||||||
|
packetNumber=doc["packetNumber"].GetUint();
|
||||||
|
bunchId=doc["bunchId"].GetUint();
|
||||||
|
timestamp=doc["timestamp"].GetUint();
|
||||||
|
modId=doc["modId"].GetUint();
|
||||||
|
debug=doc["debug"].GetUint();
|
||||||
|
roundRNumber=doc["roundRNumber"].GetUint();
|
||||||
|
detType=doc["detType"].GetUint();
|
||||||
|
version=doc["version"].GetUint();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cprintf(BLUE, "Header Info:\n"
|
||||||
|
"size: %u\n"
|
||||||
|
"multisize: %u\n"
|
||||||
|
"dynamicRange: %u\n"
|
||||||
|
"nPixelsX: %u\n"
|
||||||
|
"nPixelsY: %u\n"
|
||||||
|
"currentFileName: %s\n"
|
||||||
|
"currentAcquisitionIndex: %lu\n"
|
||||||
|
"currentFrameIndex: %lu\n"
|
||||||
|
"currentFileIndex: %lu\n"
|
||||||
|
"currentSubFrameIndex: %u\n"
|
||||||
|
"xCoordX: %u\n"
|
||||||
|
"yCoordY: %u\n"
|
||||||
|
"zCoordZ: %u\n"
|
||||||
|
"flippedDataX: %u\n"
|
||||||
|
"packetNumber: %u\n"
|
||||||
|
"bunchId: %u\n"
|
||||||
|
"timestamp: %u\n"
|
||||||
|
"modId: %u\n"
|
||||||
|
"debug: %u\n"
|
||||||
|
"roundRNumber: %u\n"
|
||||||
|
"detType: %u\n"
|
||||||
|
"version: %u\n",
|
||||||
|
size, multisize, dynamicRange, nPixelsX, nPixelsY,
|
||||||
|
filename.c_str(), acqIndex,
|
||||||
|
frameIndex, fileindex, subFrameIndex,
|
||||||
|
xCoord, yCoord,zCoord,
|
||||||
|
flippedDataX, packetNumber, bunchId, timestamp, modId, debug, roundRNumber, detType, version);
|
||||||
|
|
||||||
|
|
||||||
|
if (doc.HasMember("threshold")) {
|
||||||
|
version=doc["threshold"].GetUint();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc.HasMember("roi")) {
|
||||||
|
xmin=doc["roi"][0].GetUint();
|
||||||
|
xmax=doc["roi"][1].GetUint();
|
||||||
|
ymin=doc["roi"][2].GetUint();
|
||||||
|
ymax=doc["roi"][3].GetUint();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc.HasMember("frameMode")) {
|
||||||
|
frameMode_s=doc["frameMode"].GetString();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc.HasMember("detectorMode")) {
|
||||||
|
detectorMode_s=doc["detectorMode"].GetString();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc.HasMember("energyRange")) {
|
||||||
|
emin=doc["energyRange"][0].GetUint();
|
||||||
|
emax=doc["energyRange"][0].GetUint();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (doc.HasMember("dynamicRange")) {
|
||||||
|
dr=doc["dynamicRange"].GetUint();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc.HasMember("nSubPixels")) {
|
||||||
|
nsubPixels=doc["nSubPixels"].GetUint();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
newFrame=0;
|
||||||
|
zmqsocket->CloseHeaderMessage();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (of==NULL) {
|
if (of==NULL) {
|
||||||
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
|
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
|
||||||
|
710
slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp
Normal file
710
slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp
Normal file
@ -0,0 +1,710 @@
|
|||||||
|
#define WRITE_QUAD
|
||||||
|
|
||||||
|
#include "sls_receiver_defs.h"
|
||||||
|
#include "ZmqSocket.h"
|
||||||
|
#include "moench03T1ZmqDataNew.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <fstream>
|
||||||
|
#include "tiffIO.h"
|
||||||
|
|
||||||
|
//#define NEWZMQ
|
||||||
|
#ifdef NEWZMQ
|
||||||
|
#include <rapidjson/document.h> //json header in zmq stream
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include<iostream>
|
||||||
|
|
||||||
|
//#include "analogDetector.h"
|
||||||
|
//#include "multiThreadedAnalogDetector.h"
|
||||||
|
//#include "singlePhotonDetector.h"
|
||||||
|
//#include "interpolatingDetector.h"
|
||||||
|
//#include "multiThreadedCountingDetector.h"
|
||||||
|
#include "multiThreadedInterpolatingDetector.h"
|
||||||
|
#include "etaInterpolationPosXY.h"
|
||||||
|
#include "ansi.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
//#include <chrono>
|
||||||
|
#include <ctime> // time_t
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
//using namespace std::chrono;
|
||||||
|
|
||||||
|
//#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||||
|
|
||||||
|
// myDet->setNetworkParameter(ADDITIONAL_JSON_HEADER, " \"what\":\"nothing\" ");
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
/**
|
||||||
|
* trial.o [socket ip] [starting port number] [send_socket ip] [send port number]
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
FILE *of=NULL;
|
||||||
|
int fifosize=5000;
|
||||||
|
int etabins=1000;//nsubpix*2*100;
|
||||||
|
double etamin=-1, etamax=2;
|
||||||
|
// help
|
||||||
|
if (argc < 3 ) {
|
||||||
|
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number] [nthreads] [nsubpix] [etafile]\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// receive parameters
|
||||||
|
bool send = false;
|
||||||
|
char* socketip=argv[1];
|
||||||
|
uint32_t portnum = atoi(argv[2]);
|
||||||
|
// send parameters if any
|
||||||
|
char* socketip2 = 0;
|
||||||
|
uint32_t portnum2 = 0;
|
||||||
|
|
||||||
|
|
||||||
|
int ok;
|
||||||
|
|
||||||
|
// high_resolution_clock::time_point t1;
|
||||||
|
// high_resolution_clock::time_point t2 ;
|
||||||
|
time_t begin,end,finished;
|
||||||
|
|
||||||
|
|
||||||
|
if (argc > 4) {
|
||||||
|
socketip2 = argv[3];
|
||||||
|
portnum2 = atoi(argv[4]);
|
||||||
|
if (portnum2>0)
|
||||||
|
send = true;
|
||||||
|
}
|
||||||
|
cout << "\nrx socket ip : " << socketip <<
|
||||||
|
"\nrx port num : " << portnum ;
|
||||||
|
if (send) {
|
||||||
|
cout << "\ntx socket ip : " << socketip2 <<
|
||||||
|
"\ntx port num : " << portnum2;
|
||||||
|
}
|
||||||
|
int nthreads=5;
|
||||||
|
if (argc>5)
|
||||||
|
nthreads=atoi(argv[5]);
|
||||||
|
|
||||||
|
cout << "Number of threads is: " << nthreads << endl;
|
||||||
|
int nSubPixels=2;
|
||||||
|
if (argc>6)
|
||||||
|
nSubPixels=atoi(argv[6]);
|
||||||
|
cout << "Number of subpixels is: " << nSubPixels << endl;
|
||||||
|
|
||||||
|
char *etafname=NULL;
|
||||||
|
if (argc>7) {
|
||||||
|
etafname=argv[7];
|
||||||
|
cout << "Eta file name is: " << etafname << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||||
|
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||||
|
cout << endl << " det" <<endl;
|
||||||
|
int npx, npy;
|
||||||
|
det->getDetectorSize(npx, npy);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int maxSize = npx*npy*2;//32*2*8192;//5000;//atoi(argv[3]);
|
||||||
|
int size= maxSize;//32*2*5000;
|
||||||
|
int multisize=size;
|
||||||
|
int dataSize=size;
|
||||||
|
|
||||||
|
char dummybuff[size];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
||||||
|
#ifndef INTERP
|
||||||
|
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10);
|
||||||
|
|
||||||
|
multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
|
||||||
|
|
||||||
|
// multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||||
|
#endif
|
||||||
|
#ifdef INTERP
|
||||||
|
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(npx, npy, nSubPixels, etabins, etamin, etamax);
|
||||||
|
|
||||||
|
if (etafname) interp->readFlatField(etafname);
|
||||||
|
|
||||||
|
interpolatingDetector *filter=new interpolatingDetector(det,interp, 5, 1, 0, 1000, 10);
|
||||||
|
multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
char* buff;
|
||||||
|
mt->setFrameMode(eFrame);
|
||||||
|
mt->StartThreads();
|
||||||
|
mt->popFree(buff);
|
||||||
|
|
||||||
|
ZmqSocket* zmqsocket=NULL;
|
||||||
|
|
||||||
|
#ifdef NEWZMQ
|
||||||
|
// receive socket
|
||||||
|
try{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
zmqsocket = new ZmqSocket(socketip,portnum);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef NEWZMQ
|
||||||
|
} catch (...) {
|
||||||
|
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||||
|
delete zmqsocket;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NEWZMQ
|
||||||
|
if (zmqsocket->IsError()) {
|
||||||
|
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||||
|
delete zmqsocket;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (zmqsocket->Connect()) {
|
||||||
|
cprintf(RED, "Error: Could not connect to socket %s\n",
|
||||||
|
zmqsocket->GetZmqServerAddress());
|
||||||
|
delete zmqsocket;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
} else
|
||||||
|
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||||
|
|
||||||
|
// send socket
|
||||||
|
ZmqSocket* zmqsocket2 = 0;
|
||||||
|
// cout << "zmq2 " << endl;
|
||||||
|
if (send) {
|
||||||
|
#ifdef NEWZMQ
|
||||||
|
// receive socket
|
||||||
|
try{
|
||||||
|
#endif
|
||||||
|
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef NEWZMQ
|
||||||
|
} catch (...) {
|
||||||
|
cprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||||
|
// delete zmqsocket2;
|
||||||
|
// zmqsocket2=NULL;
|
||||||
|
// delete zmqsocket;
|
||||||
|
// return EXIT_FAILURE;
|
||||||
|
send = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NEWZMQ
|
||||||
|
if (zmqsocket2->IsError()) {
|
||||||
|
cprintf(RED, "AAA Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||||
|
// delete zmqsocket2;
|
||||||
|
//delete zmqsocket;
|
||||||
|
// return EXIT_FAILURE;
|
||||||
|
send = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (zmqsocket2->Connect()) {
|
||||||
|
cprintf(RED, "BBB Error: Could not connect to socket %s\n",
|
||||||
|
zmqsocket2->GetZmqServerAddress());
|
||||||
|
// delete zmqsocket2;
|
||||||
|
send = false;
|
||||||
|
// return EXIT_FAILURE;
|
||||||
|
} else
|
||||||
|
printf("Zmq Client at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// header variables
|
||||||
|
uint64_t acqIndex = -1;
|
||||||
|
uint64_t frameIndex = -1;
|
||||||
|
uint32_t subFrameIndex = -1;
|
||||||
|
uint64_t fileindex = -1;
|
||||||
|
string filename = "";
|
||||||
|
// char* image = new char[size];
|
||||||
|
//int* image = new int[(size/sizeof(int))]();
|
||||||
|
uint32_t flippedDataX = -1;
|
||||||
|
int *nph;
|
||||||
|
int iframe=0;
|
||||||
|
char ofname[10000];
|
||||||
|
|
||||||
|
char fname[10000];
|
||||||
|
int length;
|
||||||
|
int *detimage;
|
||||||
|
int nnx, nny,nns;
|
||||||
|
uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0;
|
||||||
|
// infinite loop
|
||||||
|
uint32_t packetNumber = 0;
|
||||||
|
uint64_t bunchId = 0;
|
||||||
|
uint64_t timestamp = 0;
|
||||||
|
int16_t modId = 0;
|
||||||
|
uint16_t xCoord = 0;
|
||||||
|
uint16_t yCoord = 0;
|
||||||
|
uint16_t zCoord = 0;
|
||||||
|
uint32_t debug = 0;
|
||||||
|
//uint32_t dr = 16;
|
||||||
|
//int16_t *dout;//=new int16_t [nnx*nny];
|
||||||
|
uint32_t dr = 32;
|
||||||
|
int32_t *dout=NULL;//=new int32_t [nnx*nny];
|
||||||
|
uint32_t nSigma=5;
|
||||||
|
uint16_t roundRNumber = 0;
|
||||||
|
uint8_t detType = 0;
|
||||||
|
uint8_t version = 0;
|
||||||
|
int* flippedData = 0;
|
||||||
|
char* additionalJsonHeader = 0;
|
||||||
|
|
||||||
|
int32_t threshold=0;
|
||||||
|
|
||||||
|
int32_t xmin=0, xmax=400, ymin=0, ymax=400;
|
||||||
|
|
||||||
|
string frameMode_s, detectorMode_s, intMode_s;
|
||||||
|
|
||||||
|
int emin, emax;
|
||||||
|
int resetFlat=0;
|
||||||
|
int resetPed=0;
|
||||||
|
int nsubPixels=1;
|
||||||
|
int isPedestal;
|
||||||
|
int isFlat=0;
|
||||||
|
int newFrame=1;
|
||||||
|
detectorMode dMode;
|
||||||
|
frameMode fMode;
|
||||||
|
double *ped;
|
||||||
|
|
||||||
|
filter->getImageSize(nnx, nny,nns);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
|
||||||
|
|
||||||
|
// cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
|
||||||
|
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||||
|
#ifndef NEWZMQ
|
||||||
|
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NEWZMQ
|
||||||
|
rapidjson::Document doc;
|
||||||
|
if (!zmqsocket->ReceiveHeader(0, doc, SLS_DETECTOR_JSON_HEADER_VERSION)) {
|
||||||
|
/* zmqsocket->CloseHeaderMessage();*/
|
||||||
|
|
||||||
|
#endif
|
||||||
|
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
|
||||||
|
// cprintf(RED, "Got Dummy\n");
|
||||||
|
// t1=high_resolution_clock::now();
|
||||||
|
time(&end);
|
||||||
|
|
||||||
|
|
||||||
|
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||||
|
|
||||||
|
if (of) {
|
||||||
|
fclose(of);
|
||||||
|
of=NULL;
|
||||||
|
}
|
||||||
|
if (newFrame>0) {
|
||||||
|
cprintf(RED,"DIDn't receive any data!\n");
|
||||||
|
if (send) {
|
||||||
|
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||||
|
cprintf(RED, "Sent Dummy\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (fMode==ePedestal) {
|
||||||
|
sprintf(ofname,"%s_%d_ped.tiff",fname,fileindex);
|
||||||
|
mt->writePedestal(ofname);
|
||||||
|
cout << "Writing pedestal to " << ofname << endl;
|
||||||
|
}
|
||||||
|
#ifdef INTERP
|
||||||
|
else if (fMode==eFlat) {
|
||||||
|
mt->prepareInterpolation(ok);
|
||||||
|
sprintf(ofname,"%s_%d_eta.tiff",fname,fileindex);
|
||||||
|
mt->writeFlatField(ofname);
|
||||||
|
cout << "Writing eta to " << ofname << endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else {
|
||||||
|
sprintf(ofname,"%s_%d.tiff",fname,fileindex);
|
||||||
|
mt->writeImage(ofname);
|
||||||
|
cout << "Writing image to " << ofname << endl;
|
||||||
|
}
|
||||||
|
// cout << nns*nnx*nny*nns*dr/8 << " " << length << endl;
|
||||||
|
|
||||||
|
if (send) {
|
||||||
|
|
||||||
|
if (fMode==ePedestal) {
|
||||||
|
cprintf(MAGENTA,"Get pedestal!\n");
|
||||||
|
nns=1;
|
||||||
|
nnx=npx;
|
||||||
|
nny=npy;
|
||||||
|
//dout= new int16_t[nnx*nny*nns*nns];
|
||||||
|
dout= new int32_t[nnx*nny*nns*nns];
|
||||||
|
// cout << "get pedestal " << endl;
|
||||||
|
ped=mt->getPedestal();
|
||||||
|
// cout << "got pedestal " << endl;
|
||||||
|
for (int ix=0; ix<nnx*nny; ix++) {
|
||||||
|
|
||||||
|
dout[ix]=ped[ix];
|
||||||
|
// if (ix<100*400)
|
||||||
|
// cout << ix << " " << ped[ix] << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#ifdef INTERP
|
||||||
|
else if (fMode==eFlat) {
|
||||||
|
int nb;
|
||||||
|
double emi, ema;
|
||||||
|
int *ff=mt->getFlatField(nb, emi, ema);
|
||||||
|
nnx=nb;
|
||||||
|
nny=nb;
|
||||||
|
dout= new int32_t[nb*nb];
|
||||||
|
for (int ix=0; ix<nb*nb; ix++) {
|
||||||
|
dout[ix]=ff[ix];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else {
|
||||||
|
detimage=mt->getImage(nnx,nny,nns);
|
||||||
|
cprintf(MAGENTA,"Get image!\n");
|
||||||
|
cout << nnx << " " << nny << " " << nns << endl;
|
||||||
|
// nns=1;
|
||||||
|
// nnx=npx;
|
||||||
|
// nny=npy;
|
||||||
|
// nnx=nnx*nns;
|
||||||
|
//nny=nny*nns;
|
||||||
|
dout= new int32_t[nnx*nny];
|
||||||
|
for (int ix=0; ix<nnx*nny; ix++) {
|
||||||
|
// for (int iy=0; iy<nny*nns; iy++) {
|
||||||
|
// for (int isx=0; isx<nns; isx++) {
|
||||||
|
// for (int isy=0; isy<nns; isy++) {
|
||||||
|
// if (isx==0 && isy==0)
|
||||||
|
// dout[iy*nnx+ix]=detimage[(iy+isy)*nnx*nns+ix+isx];
|
||||||
|
// else
|
||||||
|
// dout[iy*nnx+ix]+=detimage[(iy+isy)*nnx*nns+ix+isx];
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
dout[ix]=detimage[ix];
|
||||||
|
if (dout[ix]<0) dout[ix]=0;
|
||||||
|
// cout << ix << " " << dout[ix] << endl;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef NEWZMQ
|
||||||
|
cout << "Sending image size " << nnx << " " << nny << endl;
|
||||||
|
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NEWZMQ
|
||||||
|
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
|
||||||
|
cprintf(GREEN, "Sent Data\n");
|
||||||
|
|
||||||
|
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||||
|
cprintf(RED, "Sent Dummy\n");
|
||||||
|
if (dout)
|
||||||
|
delete [] dout;
|
||||||
|
dout=NULL;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mt->clearImage();
|
||||||
|
|
||||||
|
newFrame=1;
|
||||||
|
//t2 = high_resolution_clock::now();
|
||||||
|
|
||||||
|
time(&finished);
|
||||||
|
// auto meas_duration = duration_cast<microseconds>( t2 - t0 ).count();
|
||||||
|
// auto real_duration = duration_cast<microseconds>( t2 - t1 ).count();
|
||||||
|
|
||||||
|
cout << "Measurement lasted " << difftime(end,begin) << endl;
|
||||||
|
cout << "Processing lasted " << difftime(finished,begin) << endl;
|
||||||
|
continue; //continue to not get out
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef NEWZMQ
|
||||||
|
if (newFrame) {
|
||||||
|
time(&begin);
|
||||||
|
// t0 = high_resolution_clock::now();
|
||||||
|
//cout <<"new frame" << endl;
|
||||||
|
|
||||||
|
// acqIndex, frameIndex, subframeIndex, filename, fileindex
|
||||||
|
size = doc["size"].GetUint();
|
||||||
|
// multisize = size;// * zmqsocket->size();
|
||||||
|
dynamicRange = doc["bitmode"].GetUint();
|
||||||
|
// nPixelsX = doc["shape"][0].GetUint();
|
||||||
|
// nPixelsY = doc["shape"][1].GetUint();
|
||||||
|
filename = doc["fname"].GetString();
|
||||||
|
//acqIndex = doc["acqIndex"].GetUint64();
|
||||||
|
//frameIndex = doc["fIndex"].GetUint64();
|
||||||
|
fileindex = doc["fileIndex"].GetUint64();
|
||||||
|
//subFrameIndex = doc["expLength"].GetUint();
|
||||||
|
//packetNumber=doc["packetNumber"].GetUint();
|
||||||
|
//bunchId=doc["bunchId"].GetUint();
|
||||||
|
//timestamp=doc["timestamp"].GetUint();
|
||||||
|
//modId=doc["modId"].GetUint();
|
||||||
|
//debug=doc["debug"].GetUint();
|
||||||
|
//roundRNumber=doc["roundRNumber"].GetUint();
|
||||||
|
//detType=doc["detType"].GetUint();
|
||||||
|
//version=doc["version"].GetUint();
|
||||||
|
|
||||||
|
dataSize=size;
|
||||||
|
|
||||||
|
strcpy(fname,filename.c_str());
|
||||||
|
|
||||||
|
// cprintf(BLUE, "Header Info:\n"
|
||||||
|
// "size: %u\n"
|
||||||
|
// "multisize: %u\n"
|
||||||
|
// "dynamicRange: %u\n"
|
||||||
|
// "nPixelsX: %u\n"
|
||||||
|
// "nPixelsY: %u\n"
|
||||||
|
// "currentFileName: %s\n"
|
||||||
|
// "currentAcquisitionIndex: %lu\n"
|
||||||
|
// "currentFrameIndex: %lu\n"
|
||||||
|
// "currentFileIndex: %lu\n"
|
||||||
|
// "currentSubFrameIndex: %u\n"
|
||||||
|
// "xCoordX: %u\n"
|
||||||
|
// "yCoordY: %u\n"
|
||||||
|
// "zCoordZ: %u\n"
|
||||||
|
// "flippedDataX: %u\n"
|
||||||
|
// "packetNumber: %u\n"
|
||||||
|
// "bunchId: %u\n"
|
||||||
|
// "timestamp: %u\n"
|
||||||
|
// "modId: %u\n"
|
||||||
|
// "debug: %u\n"
|
||||||
|
// "roundRNumber: %u\n"
|
||||||
|
// "detType: %u\n"
|
||||||
|
// "version: %u\n",
|
||||||
|
// size, multisize, dynamicRange, nPixelsX, nPixelsY,
|
||||||
|
// filename.c_str(), acqIndex,
|
||||||
|
// frameIndex, fileindex, subFrameIndex,
|
||||||
|
// xCoord, yCoord,zCoord,
|
||||||
|
// flippedDataX, packetNumber, bunchId, timestamp, modId, debug, roundRNumber, detType, version);
|
||||||
|
|
||||||
|
/* Analog detector commands */
|
||||||
|
isPedestal=0;
|
||||||
|
isFlat=0;
|
||||||
|
fMode=eFrame;
|
||||||
|
frameMode_s="frame";
|
||||||
|
cprintf(MAGENTA, "Frame mode: ");
|
||||||
|
if (doc.HasMember("frameMode")) {
|
||||||
|
if (doc["frameMode"].IsString()) {
|
||||||
|
frameMode_s=doc["frameMode"].GetString();
|
||||||
|
if (frameMode_s == "pedestal"){
|
||||||
|
fMode=ePedestal;
|
||||||
|
isPedestal=1;
|
||||||
|
} else if (frameMode_s == "newPedestal"){
|
||||||
|
mt->newDataSet(); //resets pedestal
|
||||||
|
// cprintf(MAGENTA, "Resetting pedestal\n");
|
||||||
|
fMode=ePedestal;
|
||||||
|
isPedestal=1;
|
||||||
|
}
|
||||||
|
#ifdef INTERP
|
||||||
|
else if (frameMode_s == "flatfield") {
|
||||||
|
fMode=eFlat;
|
||||||
|
isFlat=1;
|
||||||
|
} else if (frameMode_s == "newFlatfield") {
|
||||||
|
mt->resetFlatField();
|
||||||
|
isFlat=1;
|
||||||
|
cprintf(MAGENTA, "Resetting flatfield\n");
|
||||||
|
fMode=eFlat;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else {
|
||||||
|
fMode=eFrame;
|
||||||
|
isPedestal=0;
|
||||||
|
isFlat=0;
|
||||||
|
fMode=eFrame;
|
||||||
|
frameMode_s="frame";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cprintf(MAGENTA, "%s\n" , frameMode_s.c_str());
|
||||||
|
mt->setFrameMode(fMode);
|
||||||
|
|
||||||
|
// threshold=0;
|
||||||
|
cprintf(MAGENTA, "Threshold: ");
|
||||||
|
if (doc.HasMember("threshold")) {
|
||||||
|
if (doc["threshold"].IsInt()) {
|
||||||
|
threshold=doc["threshold"].GetInt();
|
||||||
|
mt->setThreshold(threshold);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cprintf(MAGENTA, "%d\n", threshold);
|
||||||
|
|
||||||
|
xmin=0;
|
||||||
|
xmax=npx;
|
||||||
|
ymin=0;
|
||||||
|
ymax=npy;
|
||||||
|
cprintf(MAGENTA, "ROI: ");
|
||||||
|
if (doc.HasMember("roi")) {
|
||||||
|
if (doc["roi"].IsArray()) {
|
||||||
|
if (doc["roi"].Size() > 0 )
|
||||||
|
if (doc["roi"][0].IsInt())
|
||||||
|
xmin=doc["roi"][0].GetInt();
|
||||||
|
|
||||||
|
if (doc["roi"].Size() > 1 )
|
||||||
|
if (doc["roi"][1].IsInt())
|
||||||
|
xmax=doc["roi"][1].GetInt();
|
||||||
|
|
||||||
|
if (doc["roi"].Size() > 2 )
|
||||||
|
if (doc["roi"][2].IsInt())
|
||||||
|
ymin=doc["roi"][2].GetInt();
|
||||||
|
|
||||||
|
if (doc["roi"].Size() > 3 )
|
||||||
|
if (doc["roi"][3].IsInt())
|
||||||
|
ymax=doc["roi"][3].GetInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cprintf(MAGENTA, "%d %d %d %d\n", xmin, xmax, ymin, ymax);
|
||||||
|
mt->setROI(xmin, xmax, ymin, ymax);
|
||||||
|
|
||||||
|
if (doc.HasMember("dynamicRange")) {
|
||||||
|
dr=doc["dynamicRange"].GetUint();
|
||||||
|
dr=32;
|
||||||
|
}
|
||||||
|
|
||||||
|
dMode=eAnalog;
|
||||||
|
detectorMode_s="analog";
|
||||||
|
cprintf(MAGENTA, "Detector mode: ");
|
||||||
|
if (doc.HasMember("detectorMode")) {
|
||||||
|
if (doc["detectorMode"].IsString()) {
|
||||||
|
detectorMode_s=doc["detectorMode"].GetString();
|
||||||
|
#ifdef INTERP
|
||||||
|
if (detectorMode_s == "interpolating"){
|
||||||
|
dMode=eInterpolating;
|
||||||
|
mt->setInterpolation(interp);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
if (detectorMode_s == "counting"){
|
||||||
|
dMode=ePhotonCounting;
|
||||||
|
#ifdef INTERP
|
||||||
|
mt->setInterpolation(NULL);
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
dMode=eAnalog;
|
||||||
|
#ifdef INTERP
|
||||||
|
mt->setInterpolation(NULL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
mt->setDetectorMode(dMode);
|
||||||
|
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
|
||||||
|
|
||||||
|
// cout << "done " << endl;
|
||||||
|
|
||||||
|
// /* Single Photon Detector commands */
|
||||||
|
// nSigma=5;
|
||||||
|
// if (doc.HasMember("nSigma")) {
|
||||||
|
// if (doc["nSigma"].IsInt())
|
||||||
|
// nSigma=doc["nSigma"].GetInt();
|
||||||
|
// mt->setNSigma(nSigma);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// emin=-1;
|
||||||
|
// emax=-1;
|
||||||
|
// if (doc.HasMember("energyRange")) {
|
||||||
|
// if (doc["energyRange"].IsArray()) {
|
||||||
|
// if (doc["energyRange"].Size() > 0 )
|
||||||
|
// if (doc["energyRange"][0].IsInt())
|
||||||
|
// emin=doc["energyRange"][0].GetInt();
|
||||||
|
|
||||||
|
// if (doc["energyRange"].Size() > 1 )
|
||||||
|
// if (doc["energyRange"][1].IsInt())
|
||||||
|
// emax=doc["energyRange"][1].GetUint();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (doc.HasMember("eMin")) {
|
||||||
|
// if (doc["eMin"][1].IsInt())
|
||||||
|
// emin=doc["eMin"].GetInt();
|
||||||
|
// }
|
||||||
|
// if (doc.HasMember("eMax")) {
|
||||||
|
// if (doc["eMax"][1].IsInt())
|
||||||
|
// emin=doc["eMax"].GetInt();
|
||||||
|
// }
|
||||||
|
// mt->setEnergyRange(emin,emax);
|
||||||
|
|
||||||
|
// /* interpolating detector commands */
|
||||||
|
|
||||||
|
// if (doc.HasMember("nSubPixels")) {
|
||||||
|
// if (doc["nSubPixels"].IsUint())
|
||||||
|
// nSubPixels=doc["nSubPixels"].GetUint();
|
||||||
|
// mt->setNSubPixels(nSubPixels);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
newFrame=0;
|
||||||
|
/* zmqsocket->CloseHeaderMessage();*/
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// cout << "file" << endl;
|
||||||
|
// cout << "data " << endl;
|
||||||
|
if (of==NULL) {
|
||||||
|
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
|
||||||
|
of=fopen(ofname,"w");
|
||||||
|
if (of) {
|
||||||
|
mt->setFilePointer(of);
|
||||||
|
}else {
|
||||||
|
cout << "Could not open "<< ofname << " for writing " << endl;
|
||||||
|
mt->setFilePointer(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// cout << "data" << endl;
|
||||||
|
// get data
|
||||||
|
// acqIndex = doc["acqIndex"].GetUint64();
|
||||||
|
frameIndex = doc["fIndex"].GetUint64();
|
||||||
|
// subFrameIndex = doc["expLength"].GetUint();
|
||||||
|
|
||||||
|
// bunchId=doc["bunchId"].GetUint();
|
||||||
|
// timestamp=doc["timestamp"].GetUint();
|
||||||
|
packetNumber=doc["packetNumber"].GetUint();
|
||||||
|
// cout << acqIndex << " " << frameIndex << " " << subFrameIndex << " "<< bunchId << " " << timestamp << " " << packetNumber << endl;
|
||||||
|
if (packetNumber>=40) {
|
||||||
|
//*((int*)buff)=frameIndex;
|
||||||
|
memcpy(buff,&frameIndex,sizeof(int));
|
||||||
|
length = zmqsocket->ReceiveData(0, buff+sizeof(int), size);
|
||||||
|
mt->pushData(buff);
|
||||||
|
mt->nextThread();
|
||||||
|
mt->popFree(buff);
|
||||||
|
} else {
|
||||||
|
cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber);
|
||||||
|
length = zmqsocket->ReceiveData(0, dummybuff, size);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
iframe++;
|
||||||
|
|
||||||
|
} // exiting infinite loop
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
delete zmqsocket;
|
||||||
|
if (send)
|
||||||
|
delete zmqsocket2;
|
||||||
|
|
||||||
|
|
||||||
|
cout<<"Goodbye"<< endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef MULTITHREADED_ANALOG_DETECTOR_H
|
#ifndef MULTITHREADED_ANALOG_DETECTOR_H
|
||||||
#define MULTITHREADED_ANALOG_DETECTOR_H
|
#define MULTITHREADED_ANALOG_DETECTOR_H
|
||||||
|
|
||||||
|
#define MAXTHREADS 1000
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -14,11 +16,8 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
//#include "analogDetector.h"
|
#include "analogDetector.h"
|
||||||
#include "singlePhotonDetector.h"
|
|
||||||
//#include "interpolatingDetector.h"
|
|
||||||
#include "circularFifo.h"
|
#include "circularFifo.h"
|
||||||
#include "slsInterpolation.h"
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -28,6 +27,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class threadedAnalogDetector
|
class threadedAnalogDetector
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -36,12 +36,25 @@ public:
|
|||||||
det=d;
|
det=d;
|
||||||
fifoFree=new CircularFifo<char>(fs);
|
fifoFree=new CircularFifo<char>(fs);
|
||||||
fifoData=new CircularFifo<char>(fs);
|
fifoData=new CircularFifo<char>(fs);
|
||||||
mem=(char*)malloc(fs*det->getDataSize());
|
|
||||||
// cout << "data size is " << det->getDataSize()*fs << endl;
|
/* mem=(char*)calloc(fs, det->getDataSize()); */
|
||||||
for (int i=0; i<fs; i++) {
|
/* if (mem) */
|
||||||
mm=mem+i*det->getDataSize();
|
/* memset(mem,0, fs*det->getDataSize()); */
|
||||||
|
int i;
|
||||||
|
for (i=0; i<fs; i++) {
|
||||||
|
//
|
||||||
|
// mm=mem+i*det->getDataSize();
|
||||||
|
// cout << i << endl;
|
||||||
|
mm=(char*)calloc(1, det->getDataSize());
|
||||||
|
if (mm) {
|
||||||
|
//memset(mm,0, det->getDataSize());
|
||||||
fifoFree->push(mm);
|
fifoFree->push(mm);
|
||||||
|
} else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
if (i<fs) cout << "Could allocate only "<< i <<" frames";
|
||||||
|
|
||||||
|
|
||||||
busy=0;
|
busy=0;
|
||||||
stop=1;
|
stop=1;
|
||||||
fMode=eFrame;
|
fMode=eFrame;
|
||||||
@ -49,7 +62,26 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual int setFrameMode(int fm) {fMode=fm; if (fMode>=0) det->setFrameMode((frameMode)fMode);};
|
virtual int setFrameMode(int fm) {
|
||||||
|
if (fm>=0) {
|
||||||
|
det->setFrameMode((frameMode)fm);
|
||||||
|
fMode=fm;
|
||||||
|
}
|
||||||
|
return fMode;
|
||||||
|
};
|
||||||
|
virtual double setThreshold(double th) {return det->setThreshold(th);};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
virtual void setROI(int xmin, int xmax, int ymin, int ymax) {det->setROI(xmin,xmax,ymin,ymax);};
|
||||||
|
virtual int setDetectorMode(int dm) {
|
||||||
|
if (dm>=0) {
|
||||||
|
det->setDetectorMode((detectorMode)dm);
|
||||||
|
dMode=dm;
|
||||||
|
}
|
||||||
|
return dMode;
|
||||||
|
};
|
||||||
|
|
||||||
virtual void newDataSet(){det->newDataSet();};
|
virtual void newDataSet(){det->newDataSet();};
|
||||||
//fMode=fm; return fMode;}
|
//fMode=fm; return fMode;}
|
||||||
|
|
||||||
@ -91,46 +123,10 @@ public:
|
|||||||
//protected:
|
//protected:
|
||||||
/** Implement this method in your subclass with the code you want your thread to run. */
|
/** Implement this method in your subclass with the code you want your thread to run. */
|
||||||
//virtual void InternalThreadEntry() = 0;
|
//virtual void InternalThreadEntry() = 0;
|
||||||
virtual void *writeImage(const char * imgname) {cout << "a" <<endl; return det->writeImage(imgname);};
|
virtual void *writeImage(const char * imgname) {return det->writeImage(imgname);};
|
||||||
|
|
||||||
virtual void clearImage(){det->clearImage();};
|
virtual void clearImage(){det->clearImage();};
|
||||||
|
|
||||||
virtual void prepareInterpolation(int &ok){
|
|
||||||
slsInterpolation *interp=(slsInterpolation*)det->getInterpolation();
|
|
||||||
if (interp)
|
|
||||||
interp->prepareInterpolation(ok);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int *getFlatField(){
|
|
||||||
slsInterpolation *interp=(slsInterpolation*)det->getInterpolation();
|
|
||||||
if (interp)
|
|
||||||
return interp->getFlatField();
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int *setFlatField(int *ff, int nb, double emin, double emax){
|
|
||||||
slsInterpolation *interp=(slsInterpolation*)det->getInterpolation();
|
|
||||||
if (interp)
|
|
||||||
return interp->setFlatField(ff, nb, emin, emax);
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int *getFlatField(int &nb, double emi, double ema){
|
|
||||||
slsInterpolation *interp=(slsInterpolation*)det->getInterpolation();
|
|
||||||
int *ff;
|
|
||||||
if (interp) {
|
|
||||||
ff=interp->getFlatField(nb,emi,ema);
|
|
||||||
// cout << "tdgff* ff has " << nb << " bins " << endl;
|
|
||||||
return ff;
|
|
||||||
} else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual char *getInterpolation() {
|
|
||||||
return det->getInterpolation();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){det->setPedestal(ped,rms,m);};
|
virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){det->setPedestal(ped,rms,m);};
|
||||||
|
|
||||||
@ -157,11 +153,79 @@ public:
|
|||||||
FILE *getFilePointer(){return det->getFilePointer();};
|
FILE *getFilePointer(){return det->getFilePointer();};
|
||||||
|
|
||||||
|
|
||||||
void setMutex(pthread_mutex_t *fmutex){det->setMutex(fmutex);};
|
|
||||||
|
|
||||||
private:
|
virtual double setNSigma(double n) {return det->setNSigma(n);};
|
||||||
|
virtual void setEnergyRange(double emi, double ema) {det->setEnergyRange(emi,ema);};
|
||||||
|
|
||||||
|
|
||||||
|
virtual void prepareInterpolation(int &ok){
|
||||||
|
slsInterpolation *interp=det->getInterpolation();
|
||||||
|
if (interp)
|
||||||
|
interp->prepareInterpolation(ok);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int *getFlatField(){
|
||||||
|
slsInterpolation *interp=(det)->getInterpolation();
|
||||||
|
if (interp)
|
||||||
|
return interp->getFlatField();
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int *setFlatField(int *ff, int nb, double emin, double emax){
|
||||||
|
slsInterpolation *interp=(det)->getInterpolation();
|
||||||
|
if (interp)
|
||||||
|
return interp->setFlatField(ff, nb, emin, emax);
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *writeFlatField(const char * imgname) {
|
||||||
|
slsInterpolation *interp=(det)->getInterpolation();
|
||||||
|
cout << "interp " << interp << endl;
|
||||||
|
if (interp) {
|
||||||
|
cout << imgname << endl;
|
||||||
|
interp->writeFlatField(imgname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){
|
||||||
|
slsInterpolation *interp=(det)->getInterpolation();
|
||||||
|
if (interp)
|
||||||
|
interp->readFlatField(imgname, nb, emin, emax);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int *getFlatField(int &nb, double emi, double ema){
|
||||||
|
slsInterpolation *interp=(det)->getInterpolation();
|
||||||
|
int *ff=NULL;
|
||||||
|
if (interp) {
|
||||||
|
ff=interp->getFlatField(nb,emi,ema);
|
||||||
|
}
|
||||||
|
return ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual slsInterpolation *getInterpolation() {
|
||||||
|
return (det)->getInterpolation();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void resetFlatField() {
|
||||||
|
slsInterpolation *interp=(det)->getInterpolation();
|
||||||
|
if (interp) interp->resetFlatField();//((interpolatingDetector*)det)->resetFlatField();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual int setNSubPixels(int ns) {
|
||||||
|
slsInterpolation *interp=(det)->getInterpolation();
|
||||||
|
if (interp) return interp->setNSubPixels(ns);
|
||||||
|
else return 1;};
|
||||||
|
|
||||||
|
|
||||||
|
virtual slsInterpolation *setInterpolation(slsInterpolation *f){
|
||||||
|
return (det)->setInterpolation(f);
|
||||||
|
};
|
||||||
|
protected:
|
||||||
analogDetector<uint16_t> *det;
|
analogDetector<uint16_t> *det;
|
||||||
int fMode;
|
int fMode;
|
||||||
|
int dMode;
|
||||||
int *dataSize;
|
int *dataSize;
|
||||||
pthread_t _thread;
|
pthread_t _thread;
|
||||||
char *mem;
|
char *mem;
|
||||||
@ -176,6 +240,7 @@ private:
|
|||||||
threadedAnalogDetector *This=((threadedAnalogDetector *)ptr);
|
threadedAnalogDetector *This=((threadedAnalogDetector *)ptr);
|
||||||
return This->processData();
|
return This->processData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void * processData() {
|
void * processData() {
|
||||||
busy=1;
|
busy=1;
|
||||||
while (!stop) {
|
while (!stop) {
|
||||||
@ -201,7 +266,7 @@ private:
|
|||||||
class multiThreadedAnalogDetector
|
class multiThreadedAnalogDetector
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
multiThreadedAnalogDetector(analogDetector<uint16_t> *d, int n, int fs=1000) : nThreads(n), ithread(0) {
|
multiThreadedAnalogDetector(analogDetector<uint16_t> *d, int n, int fs=1000) : stop(0), nThreads(n), ithread(0) {
|
||||||
dd[0]=d;
|
dd[0]=d;
|
||||||
if (nThreads==1)
|
if (nThreads==1)
|
||||||
dd[0]->setId(100);
|
dd[0]->setId(100);
|
||||||
@ -213,14 +278,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<nThreads; i++) {
|
for (int i=0; i<nThreads; i++) {
|
||||||
|
cout << "**" << i << endl;
|
||||||
dets[i]=new threadedAnalogDetector(dd[i], fs);
|
dets[i]=new threadedAnalogDetector(dd[i], fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nnx, nny, ns;
|
image=NULL;
|
||||||
int nn=dets[0]->getImageSize(nnx, nny,ns);
|
|
||||||
image=new int[nn];
|
|
||||||
ff=NULL;
|
ff=NULL;
|
||||||
ped=NULL;
|
ped=NULL;
|
||||||
|
cout << "Ithread is " << ithread << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
~multiThreadedAnalogDetector() {
|
~multiThreadedAnalogDetector() {
|
||||||
@ -229,17 +294,29 @@ public:
|
|||||||
delete dets[i];
|
delete dets[i];
|
||||||
for (int i=1; i<nThreads; i++)
|
for (int i=1; i<nThreads; i++)
|
||||||
delete dd[i];
|
delete dd[i];
|
||||||
delete [] image;
|
//delete [] image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int setFrameMode(int fm) { int ret; for (int i=0; i<nThreads; i++) ret=dets[i]->setFrameMode(fm); return ret;};
|
virtual int setFrameMode(int fm) { int ret; for (int i=0; i<nThreads; i++) { ret=dets[i]->setFrameMode(fm);} return ret;};
|
||||||
|
virtual double setThreshold(int fm) { double ret; for (int i=0; i<nThreads; i++) ret=dets[i]->setThreshold(fm); return ret;};
|
||||||
|
virtual int setDetectorMode(int dm) { int ret; for (int i=0; i<nThreads; i++) ret=dets[i]->setDetectorMode(dm); return ret;};
|
||||||
|
virtual void setROI(int xmin, int xmax, int ymin, int ymax) { for (int i=0; i<nThreads; i++) dets[i]->setROI(xmin, xmax,ymin,ymax);};
|
||||||
|
|
||||||
void newDataSet(){for (int i=0; i<nThreads; i++) dets[i]->newDataSet();};
|
|
||||||
int *getImage(int &nnx, int &nny, int &ns) {
|
virtual void newDataSet(){for (int i=0; i<nThreads; i++) dets[i]->newDataSet();};
|
||||||
|
|
||||||
|
virtual int *getImage(int &nnx, int &nny, int &ns) {
|
||||||
int *img;
|
int *img;
|
||||||
// int nnx, nny, ns;
|
// int nnx, nny, ns;
|
||||||
|
// int nnx, nny, ns;
|
||||||
int nn=dets[0]->getImageSize(nnx, nny,ns);
|
int nn=dets[0]->getImageSize(nnx, nny,ns);
|
||||||
|
if (image) {
|
||||||
|
delete image;
|
||||||
|
image=NULL;
|
||||||
|
}
|
||||||
|
image=new int[nn];
|
||||||
|
//int nn=dets[0]->getImageSize(nnx, nny, ns);
|
||||||
//for (i=0; i<nn; i++) image[i]=0;
|
//for (i=0; i<nn; i++) image[i]=0;
|
||||||
|
|
||||||
for (int ii=0; ii<nThreads; ii++) {
|
for (int ii=0; ii<nThreads; ii++) {
|
||||||
@ -259,7 +336,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void clearImage() {
|
virtual void clearImage() {
|
||||||
|
|
||||||
for (int ii=0; ii<nThreads; ii++) {
|
for (int ii=0; ii<nThreads; ii++) {
|
||||||
dets[ii]->clearImage();
|
dets[ii]->clearImage();
|
||||||
@ -267,7 +344,7 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void *writeImage(const char * imgname) {
|
virtual void *writeImage(const char * imgname, double t=1) {
|
||||||
/* #ifdef SAVE_ALL */
|
/* #ifdef SAVE_ALL */
|
||||||
/* for (int ii=0; ii<nThreads; ii++) { */
|
/* for (int ii=0; ii<nThreads; ii++) { */
|
||||||
/* char tit[10000];cout << "m" <<endl; */
|
/* char tit[10000];cout << "m" <<endl; */
|
||||||
@ -282,7 +359,11 @@ public:
|
|||||||
float *gm=new float[nn];
|
float *gm=new float[nn];
|
||||||
if (gm) {
|
if (gm) {
|
||||||
for (int ix=0; ix<nn; ix++) {
|
for (int ix=0; ix<nn; ix++) {
|
||||||
|
if (t)
|
||||||
|
gm[ix]=(image[ix])/t;
|
||||||
|
else
|
||||||
gm[ix]=image[ix];
|
gm[ix]=image[ix];
|
||||||
|
|
||||||
//if (image[ix]>0 && ix/nnx<350) cout << ix/nnx << " " << ix%nnx << " " << image[ix]<< " " << gm[ix] << endl;
|
//if (image[ix]>0 && ix/nnx<350) cout << ix/nnx << " " << ix%nnx << " " << image[ix]<< " " << gm[ix] << endl;
|
||||||
}
|
}
|
||||||
//cout << "image " << nnx << " " << nny << endl;
|
//cout << "image " << nnx << " " << nny << endl;
|
||||||
@ -294,8 +375,9 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
virtual void StartThreads() {
|
virtual void StartThreads() {
|
||||||
for (int i=0; i<nThreads; i++)
|
for (int i=0; i<nThreads; i++) {
|
||||||
dets[i]->StartThread();
|
dets[i]->StartThread();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +390,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int isBusy() {
|
virtual int isBusy() {
|
||||||
int ret=0, ret1;
|
int ret=0, ret1;
|
||||||
for (int i=0; i<nThreads; i++) {
|
for (int i=0; i<nThreads; i++) {
|
||||||
ret1=dets[i]->isBusy();
|
ret1=dets[i]->isBusy();
|
||||||
@ -319,125 +401,21 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool pushData(char* &ptr) {
|
virtual bool pushData(char* &ptr) {
|
||||||
dets[ithread]->pushData(ptr);
|
dets[ithread]->pushData(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool popFree(char* &ptr) {
|
virtual bool popFree(char* &ptr) {
|
||||||
|
// cout << ithread << endl;
|
||||||
dets[ithread]->popFree(ptr);
|
dets[ithread]->popFree(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nextThread() {
|
virtual int nextThread() {
|
||||||
ithread++;
|
ithread++;
|
||||||
if (ithread==nThreads) ithread=0;
|
if (ithread==nThreads) ithread=0;
|
||||||
return ithread;
|
return ithread;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void prepareInterpolation(int &ok){
|
|
||||||
getFlatField(); //sum up all etas
|
|
||||||
setFlatField(); //set etas to all detectors
|
|
||||||
for (int i=0; i<nThreads; i++) {
|
|
||||||
dets[i]->prepareInterpolation(ok);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int *getFlatField(){
|
|
||||||
int nb=0;
|
|
||||||
double emi, ema;
|
|
||||||
int *f0;
|
|
||||||
slsInterpolation* inte=(slsInterpolation*)dets[0]->getInterpolation();
|
|
||||||
if (inte) {
|
|
||||||
if (inte->getFlatField(nb,emi,ema)) {
|
|
||||||
if (ff) delete [] ff;
|
|
||||||
ff=new int[nb*nb];
|
|
||||||
for (int i=0; i<nThreads; i++) {
|
|
||||||
// cout << "mtgff* ff has " << nb << " bins " << endl;
|
|
||||||
inte=(slsInterpolation*)dets[i]->getInterpolation();
|
|
||||||
f0=inte->getFlatField();
|
|
||||||
if (f0) {
|
|
||||||
// cout << "ff " << i << endl;
|
|
||||||
for (int ib=0; ib<nb*nb; ib++) {
|
|
||||||
if (i==0)
|
|
||||||
ff[ib]=f0[ib];
|
|
||||||
else
|
|
||||||
ff[ib]+=f0[ib];
|
|
||||||
/* if (i==0 && f0[ib]>0) */
|
|
||||||
/* cout << i << " " << ib << " " << f0[ib] << " " << ff[ib] << endl; */
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
virtual int *setFlatField(int *h=NULL, int nb=-1, double emin=1, double emax=0){
|
|
||||||
//int nb=0;
|
|
||||||
double emi, ema;
|
|
||||||
slsInterpolation* inte=(slsInterpolation*)dets[0]->getFlatField(nb,emi,ema);
|
|
||||||
if (inte) {
|
|
||||||
if (h==NULL) h=ff;
|
|
||||||
for (int i=0; i<nThreads; i++) {
|
|
||||||
dets[i]->setFlatField(h, nb, emin, emax);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
};
|
|
||||||
|
|
||||||
void *writeFlatField(const char * imgname){
|
|
||||||
|
|
||||||
int nb=0;
|
|
||||||
double emi, ema;
|
|
||||||
slsInterpolation* inte=(slsInterpolation*)dets[0]->getFlatField(nb,emi,ema);
|
|
||||||
if (inte) {
|
|
||||||
if (getFlatField()) {
|
|
||||||
// cout << "mtwff* ff has " << nb << " bins " << endl;
|
|
||||||
float *gm=new float[nb*nb];
|
|
||||||
if (gm) {
|
|
||||||
for (int ix=0; ix<nb*nb; ix++) {
|
|
||||||
gm[ix]=ff[ix];
|
|
||||||
}
|
|
||||||
WriteToTiff(gm,imgname ,nb, nb);
|
|
||||||
delete [] gm;
|
|
||||||
} else cout << "Could not allocate float image " << endl;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
cout << "Detector without flat field! " << endl;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){
|
|
||||||
|
|
||||||
int* inte=(int*)dets[0]->getFlatField(nb,emin,emax);
|
|
||||||
if (inte) {
|
|
||||||
uint32 nnx;
|
|
||||||
uint32 nny;
|
|
||||||
float *gm=ReadFromTiff(imgname, nnx, nny);
|
|
||||||
if (ff) delete [] ff;
|
|
||||||
if (nnx>nb) nb=nnx;
|
|
||||||
if (nny>nb) nb=nny;
|
|
||||||
ff=new int[nb*nb];
|
|
||||||
|
|
||||||
for (int ix=0; ix<nb*nb; ix++) {
|
|
||||||
ff[ix]=gm[ix];
|
|
||||||
}
|
|
||||||
delete [] gm;
|
|
||||||
return setFlatField(ff,nb,emin,emax);
|
|
||||||
} else
|
|
||||||
cout << "Not interpolating detector! " << endl;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual double *getPedestal(){
|
virtual double *getPedestal(){
|
||||||
int nx, ny;
|
int nx, ny;
|
||||||
@ -448,15 +426,25 @@ public:
|
|||||||
|
|
||||||
for (int i=0; i<nThreads; i++) {
|
for (int i=0; i<nThreads; i++) {
|
||||||
//inte=(slsInterpolation*)dets[i]->getInterpolation(nb,emi,ema);
|
//inte=(slsInterpolation*)dets[i]->getInterpolation(nb,emi,ema);
|
||||||
|
// cout << i << endl;
|
||||||
p0=dets[i]->getPedestal(p0);
|
p0=dets[i]->getPedestal(p0);
|
||||||
if (p0) {
|
if (p0) {
|
||||||
|
if (i==0) {
|
||||||
|
|
||||||
|
for (int ib=0; ib<nx*ny; ib++) {
|
||||||
|
ped[ib]=p0[ib]/((double)nThreads);
|
||||||
|
// cout << p0[ib] << " ";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (int ib=0; ib<nx*ny; ib++) {
|
for (int ib=0; ib<nx*ny; ib++) {
|
||||||
ped[ib]+=p0[ib]/((double)nThreads);
|
ped[ib]+=p0[ib]/((double)nThreads);
|
||||||
|
// cout << p0[ib] << " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] p0;
|
|
||||||
}
|
}
|
||||||
|
delete [] p0;
|
||||||
return ped;
|
return ped;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -477,7 +465,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void *writePedestal(const char * imgname){
|
virtual void *writePedestal(const char * imgname){
|
||||||
|
|
||||||
int nx, ny;
|
int nx, ny;
|
||||||
dets[0]->getDetectorSize(nx,ny);
|
dets[0]->getDetectorSize(nx,ny);
|
||||||
@ -497,7 +485,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void *readPedestal(const char * imgname, int nb=-1, double emin=1, double emax=0){
|
virtual void *readPedestal(const char * imgname, int nb=-1, double emin=1, double emax=0){
|
||||||
|
|
||||||
int nx, ny;
|
int nx, ny;
|
||||||
dets[0]->getDetectorSize(nx,ny);
|
dets[0]->getDetectorSize(nx,ny);
|
||||||
@ -526,7 +514,7 @@ public:
|
|||||||
\param f file pointer
|
\param f file pointer
|
||||||
\returns current file pointer
|
\returns current file pointer
|
||||||
*/
|
*/
|
||||||
FILE *setFilePointer(FILE *f){
|
virtual FILE *setFilePointer(FILE *f){
|
||||||
for (int i=0; i<nThreads; i++) {
|
for (int i=0; i<nThreads; i++) {
|
||||||
dets[i]->setFilePointer(f);
|
dets[i]->setFilePointer(f);
|
||||||
//dets[i]->setMutex(&fmutex);
|
//dets[i]->setMutex(&fmutex);
|
||||||
@ -537,15 +525,15 @@ public:
|
|||||||
/** gets file pointer where to write the clusters to
|
/** gets file pointer where to write the clusters to
|
||||||
\returns current file pointer
|
\returns current file pointer
|
||||||
*/
|
*/
|
||||||
FILE *getFilePointer(){return dets[0]->getFilePointer();};
|
virtual FILE *getFilePointer(){return dets[0]->getFilePointer();};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
bool stop;
|
bool stop;
|
||||||
const int nThreads;
|
const int nThreads;
|
||||||
threadedAnalogDetector *dets[20];
|
threadedAnalogDetector *dets[MAXTHREADS];
|
||||||
analogDetector<uint16_t> *dd[20];
|
analogDetector<uint16_t> *dd[MAXTHREADS];
|
||||||
int ithread;
|
int ithread;
|
||||||
int *image;
|
int *image;
|
||||||
int *ff;
|
int *ff;
|
||||||
|
51
slsDetectorCalibration/multiThreadedCountingDetector.h
Normal file
51
slsDetectorCalibration/multiThreadedCountingDetector.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#ifndef MULTITHREADED_COUNTING_DETECTOR_H
|
||||||
|
#define MULTITHREADED_COUNTING_DETECTOR_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "singlePhotonDetector.h"
|
||||||
|
#include "multiThreadedAnalogDetector.h"
|
||||||
|
//#include <mutex>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
/* class threadedCountingDetector : public threadedAnalogDetector */
|
||||||
|
/* { */
|
||||||
|
/* public: */
|
||||||
|
/* threadedCountingDetector(singlePhotonDetector *d, int fs=10000) : threadedAnalogDetector(d,fs) {}; */
|
||||||
|
|
||||||
|
|
||||||
|
/* }; */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class multiThreadedCountingDetector : public multiThreadedAnalogDetector
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
multiThreadedCountingDetector(singlePhotonDetector *d, int n, int fs=1000) : multiThreadedAnalogDetector(d,n,fs) { };
|
||||||
|
|
||||||
|
virtual double setNSigma(double n) {double ret; for (int i=0; i<nThreads; i++) ret=(dets[i])->setNSigma(n); return ret;};
|
||||||
|
virtual void setEnergyRange(double emi, double ema) {for (int i=0; i<nThreads; i++) (dets[i])->setEnergyRange(emi,ema);};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
112
slsDetectorCalibration/multiThreadedInterpolatingDetector.h
Normal file
112
slsDetectorCalibration/multiThreadedInterpolatingDetector.h
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
#ifndef MULTITHREADED_INTERPOLATING_DETECTOR_H
|
||||||
|
#define MULTITHREADED_INTERPOLATING_DETECTOR_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "interpolatingDetector.h"
|
||||||
|
#include "multiThreadedCountingDetector.h"
|
||||||
|
//#include <mutex>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class multiThreadedInterpolatingDetector : public multiThreadedCountingDetector
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
multiThreadedInterpolatingDetector(interpolatingDetector *d, int n, int fs=1000) : multiThreadedCountingDetector(d,n,fs) { };
|
||||||
|
|
||||||
|
virtual void prepareInterpolation(int &ok){
|
||||||
|
/* getFlatField(); //sum up all etas */
|
||||||
|
/* setFlatField(); //set etas to all detectors */
|
||||||
|
/* for (int i=0; i<nThreads; i++) { */
|
||||||
|
(dets[0])->prepareInterpolation(ok);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int *getFlatField(){
|
||||||
|
return (dets[0])->getFlatField();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int *getFlatField(int &nb, double emi, double ema){
|
||||||
|
return (dets[0])->getFlatField(nb,emi,ema);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int *setFlatField(int *h=NULL, int nb=-1, double emin=1, double emax=0){
|
||||||
|
return (dets[0])->setFlatField(h,nb,emin,emax);
|
||||||
|
};
|
||||||
|
|
||||||
|
void *writeFlatField(const char * imgname){
|
||||||
|
dets[0]->writeFlatField(imgname);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){
|
||||||
|
(dets[0])->readFlatField(imgname, nb, emin, emax);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
virtual int setNSubPixels(int ns) { return (dets[0])->setNSubPixels(ns);};
|
||||||
|
|
||||||
|
virtual void resetFlatField() {(dets[0])->resetFlatField();};
|
||||||
|
|
||||||
|
|
||||||
|
/** sets file pointer where to write the clusters to
|
||||||
|
\param f file pointer
|
||||||
|
\returns current file pointer
|
||||||
|
*/
|
||||||
|
virtual slsInterpolation *setInterpolation(slsInterpolation *f){
|
||||||
|
int ok;
|
||||||
|
for (int i=0; i<nThreads; i++)
|
||||||
|
(dets[i])->setInterpolation(f);
|
||||||
|
return (dets[0])->getInterpolation();
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual slsInterpolation *getInterpolation(){
|
||||||
|
|
||||||
|
return (dets[0])->getInterpolation();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
virtual int *getImage(int &nnx, int &nny, int &ns) {
|
||||||
|
if (getInterpolation()==NULL) return multiThreadedAnalogDetector::getImage(nnx,nny,ns);
|
||||||
|
//if one interpolates, the whole image is stored in detector 0;
|
||||||
|
int *img;
|
||||||
|
// int nnx, nny, ns;
|
||||||
|
// int nnx, nny, ns;
|
||||||
|
int nn=dets[0]->getImageSize(nnx, nny,ns);
|
||||||
|
if (image) {
|
||||||
|
delete image;
|
||||||
|
image=NULL;
|
||||||
|
}
|
||||||
|
image=new int[nn];
|
||||||
|
img=dets[0]->getImage();
|
||||||
|
for (int i=0; i<nn; i++) {
|
||||||
|
image[i]=img[i];
|
||||||
|
}
|
||||||
|
return image;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -58,11 +58,13 @@ public analogDetector<uint16_t> {
|
|||||||
int sign=1,
|
int sign=1,
|
||||||
commonModeSubtraction *cm=NULL,
|
commonModeSubtraction *cm=NULL,
|
||||||
int nped=1000,
|
int nped=1000,
|
||||||
int nd=100, int nnx=-1, int nny=-1, double *gm=NULL) : analogDetector<uint16_t>(d, sign, cm, nped, nnx, nny, gm), nDark(nd), eventMask(NULL),nSigma (nsigma), clusterSize(csize), clusterSizeY(csize), clusters(NULL), quad(UNDEFINED_QUADRANT), tot(0), quadTot(0) {
|
int nd=100, int nnx=-1, int nny=-1, double *gm=NULL) : analogDetector<uint16_t>(d, sign, cm, nped, nnx, nny, gm), nDark(nd), eventMask(NULL),nSigma (nsigma), clusterSize(csize), clusterSizeY(csize), clusters(NULL), quad(UNDEFINED_QUADRANT), tot(0), quadTot(0), eMin(-1), eMax(-1) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fm=new pthread_mutex_t ;
|
||||||
|
|
||||||
eventMask=new eventType*[ny];
|
eventMask=new eventType*[ny];
|
||||||
for (int i=0; i<ny; i++) {
|
for (int i=0; i<ny; i++) {
|
||||||
eventMask[i]=new eventType[nx];
|
eventMask[i]=new eventType[nx];
|
||||||
@ -101,6 +103,8 @@ public analogDetector<uint16_t> {
|
|||||||
for (int i=0; i<ny; i++) {
|
for (int i=0; i<ny; i++) {
|
||||||
eventMask[i]=new eventType[nx];
|
eventMask[i]=new eventType[nx];
|
||||||
}
|
}
|
||||||
|
eMin=orig->eMin;
|
||||||
|
eMax=orig->eMax;
|
||||||
|
|
||||||
|
|
||||||
nSigma=orig->nSigma;
|
nSigma=orig->nSigma;
|
||||||
@ -112,6 +116,7 @@ public analogDetector<uint16_t> {
|
|||||||
// cluster=clusters;
|
// cluster=clusters;
|
||||||
|
|
||||||
setClusterSize(clusterSize);
|
setClusterSize(clusterSize);
|
||||||
|
fm=orig->fm;
|
||||||
|
|
||||||
quad=UNDEFINED_QUADRANT;
|
quad=UNDEFINED_QUADRANT;
|
||||||
tot=0;
|
tot=0;
|
||||||
@ -136,7 +141,7 @@ public analogDetector<uint16_t> {
|
|||||||
\param n number of sigma to be set (0 or negative gets)
|
\param n number of sigma to be set (0 or negative gets)
|
||||||
\returns actual number of sigma parameter
|
\returns actual number of sigma parameter
|
||||||
*/
|
*/
|
||||||
double setNSigma(double n=-1){if (n>0) nSigma=n; return nSigma;}
|
double setNSigma(double n=-1){if (n>=0) nSigma=n; return nSigma;}
|
||||||
|
|
||||||
/** sets/gets cluster size
|
/** sets/gets cluster size
|
||||||
\param n cluster size to be set, (0 or negative gets). If even is incremented by 1.
|
\param n cluster size to be set, (0 or negative gets). If even is incremented by 1.
|
||||||
@ -178,11 +183,11 @@ public analogDetector<uint16_t> {
|
|||||||
//nph=new int[nx*ny];
|
//nph=new int[nx*ny];
|
||||||
|
|
||||||
double rest[ny][nx];
|
double rest[ny][nx];
|
||||||
int cy=(clusterSizeY+1)/2;
|
int cy=(clusterSizeY+1)/2; //quad size
|
||||||
int cs=(clusterSize+1)/2;
|
int cs=(clusterSize+1)/2; //quad size
|
||||||
|
|
||||||
int ccs=clusterSize;
|
int ccs=clusterSize; //cluster size
|
||||||
int ccy=clusterSizeY;
|
int ccy=clusterSizeY; //cluster size
|
||||||
|
|
||||||
double g=1.;
|
double g=1.;
|
||||||
|
|
||||||
@ -210,27 +215,31 @@ public analogDetector<uint16_t> {
|
|||||||
if (thr>0) {
|
if (thr>0) {
|
||||||
newFrame();
|
newFrame();
|
||||||
if (cmSub) {
|
if (cmSub) {
|
||||||
|
cout << "add to common mode?"<< endl;
|
||||||
addToCommonMode(data);
|
addToCommonMode(data);
|
||||||
}
|
}
|
||||||
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 (det->isGood(ix,iy)) {
|
||||||
val=subtractPedestal(data,ix,iy, cm);
|
val=subtractPedestal(data,ix,iy, cm);
|
||||||
|
|
||||||
nn=val/tthr;//analogDetector<uint16_t>::getNPhotons(data,ix,iy);
|
nn=analogDetector<uint16_t>::getNPhotons(data,ix,iy);//val/thr;//
|
||||||
|
if (nn>0) {
|
||||||
nph[ix+nx*iy]+=nn;
|
nph[ix+nx*iy]+=nn;
|
||||||
rest[iy][ix]=(val-nn*tthr);
|
rest[iy][ix]=(val-nn*thr);//?+0.5*thr
|
||||||
|
|
||||||
nphFrame+=nn;
|
nphFrame+=nn;
|
||||||
nphTot+=nn;
|
nphTot+=nn;
|
||||||
}
|
} else
|
||||||
}
|
rest[iy][ix]=val;
|
||||||
// }
|
|
||||||
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++) {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int iy=ymin; iy<ymax; iy++) {
|
||||||
|
for (int ix=xmin; ix<xmax; ix++) {
|
||||||
|
|
||||||
|
if (det->isGood(ix,iy)) {
|
||||||
eventMask[iy][ix]=PEDESTAL;
|
eventMask[iy][ix]=PEDESTAL;
|
||||||
max=0;
|
max=0;
|
||||||
tl=0;
|
tl=0;
|
||||||
@ -240,7 +249,7 @@ public analogDetector<uint16_t> {
|
|||||||
tot=0;
|
tot=0;
|
||||||
quadTot=0;
|
quadTot=0;
|
||||||
|
|
||||||
if (rest[iy][ix]>0.25*tthr) {
|
if (rest[iy][ix]>0.25*thr) {
|
||||||
eventMask[iy][ix]=NEIGHBOUR;
|
eventMask[iy][ix]=NEIGHBOUR;
|
||||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||||
@ -267,7 +276,6 @@ public analogDetector<uint16_t> {
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (rest[iy][ix]>=max) {
|
if (rest[iy][ix]>=max) {
|
||||||
if (bl>=br && bl>=tl && bl>=tr) {
|
if (bl>=br && bl>=tl && bl>=tr) {
|
||||||
@ -283,14 +291,30 @@ public analogDetector<uint16_t> {
|
|||||||
quad=TOP_RIGHT;
|
quad=TOP_RIGHT;
|
||||||
quadTot=tr;
|
quadTot=tr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nSigma==0) {
|
||||||
|
tthr=thr;
|
||||||
|
tthr1=thr;
|
||||||
|
tthr2=thr;
|
||||||
|
} else {
|
||||||
|
|
||||||
rms=getPedestalRMS(ix,iy);
|
rms=getPedestalRMS(ix,iy);
|
||||||
tthr1=tthr-sqrt(ccy*ccs)*rms;
|
tthr=nSigma*rms;
|
||||||
tthr2=tthr-sqrt(cy*cs)*rms;
|
|
||||||
if (tthr>sqrt(ccy*ccs)*rms) tthr1=tthr-sqrt(ccy*ccs)*rms; else tthr1=sqrt(ccy*ccs)*rms;
|
tthr1=nSigma*sqrt(clusterSize*clusterSizeY)*rms;
|
||||||
if (tthr>sqrt(cy*cs)*rms) tthr2=tthr-sqrt(cy*cs)*rms; else tthr2=sqrt(cy*cs)*rms;
|
tthr2=nSigma*sqrt((clusterSize+1)/2.*((clusterSizeY+1)/2.))*rms;
|
||||||
if (tot>tthr1 || quadTot>tthr2) {
|
|
||||||
|
|
||||||
|
if (thr>2*tthr) tthr=thr-tthr;
|
||||||
|
if (thr>2*tthr1) tthr1=tthr-tthr1;
|
||||||
|
if (thr>2*tthr2) tthr2=tthr-tthr2;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tot>tthr1 || quadTot>tthr2 || max>tthr) {
|
||||||
eventMask[iy][ix]=PHOTON;
|
eventMask[iy][ix]=PHOTON;
|
||||||
nph[ix+nx*iy]++;
|
nph[ix+nx*iy]++;
|
||||||
|
rest[iy][ix]-=thr;
|
||||||
nphFrame++;
|
nphFrame++;
|
||||||
nphTot++;
|
nphTot++;
|
||||||
|
|
||||||
@ -299,121 +323,14 @@ public analogDetector<uint16_t> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// cout << iframe << " " << nphFrame << " " << nphTot << endl;
|
}
|
||||||
//cout << iframe << " " << nph << endl;
|
}
|
||||||
} else return getClusters(data, nph);
|
} else return getClusters(data, nph);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** finds event type for pixel and fills cluster structure. The algorithm loops only if the evenMask for this pixel is still undefined.
|
|
||||||
if pixel or cluster around it are above threshold (nsigma*pedestalRMS) cluster is filled and pixel mask is PHOTON_MAX (if maximum in cluster) or NEIGHBOUR; If PHOTON_MAX, the elements of the cluster are also set as NEIGHBOURs in order to speed up the looping
|
|
||||||
if below threshold the pixel is either marked as PEDESTAL (and added to the pedestal calculator) or NEGATIVE_PEDESTAL is case it's lower than -threshold, otherwise the pedestal average would drift to negative values while it should be 0.
|
|
||||||
|
|
||||||
/param data pointer to the data
|
|
||||||
/param ix pixel x coordinate
|
|
||||||
/param iy pixel y coordinate
|
|
||||||
/param cm enable(1)/disable(0) common mode subtraction (if defined).
|
|
||||||
/returns event type for the given pixel
|
|
||||||
*/
|
|
||||||
eventType getEventType(char *data, int ix, int iy, int cm=0) {
|
|
||||||
|
|
||||||
// eventType ret=PEDESTAL;
|
|
||||||
double max=0, tl=0, tr=0, bl=0,br=0, v;
|
|
||||||
// cout << iframe << endl;
|
|
||||||
|
|
||||||
int cy=(clusterSizeY+1)/2;
|
|
||||||
int cs=(clusterSize+1)/2;
|
|
||||||
double val;
|
|
||||||
tot=0;
|
|
||||||
quadTot=0;
|
|
||||||
quad=UNDEFINED_QUADRANT;
|
|
||||||
|
|
||||||
if (iframe<nDark) {
|
|
||||||
addToPedestal(data, ix,iy);
|
|
||||||
return UNDEFINED_EVENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if (eventMask[iy][ix]==UNDEFINED) {
|
|
||||||
|
|
||||||
eventMask[iy][ix]=PEDESTAL;
|
|
||||||
|
|
||||||
|
|
||||||
clusters->x=ix;
|
|
||||||
clusters->y=iy;
|
|
||||||
clusters->rms=getPedestalRMS(ix,iy);
|
|
||||||
clusters->ped=getPedestal(ix,iy, cm);
|
|
||||||
|
|
||||||
|
|
||||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
|
||||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
|
||||||
if ((iy+ir)>=0 && (iy+ir)<ny && (ix+ic)>=0 && (ix+ic)<nx) {
|
|
||||||
|
|
||||||
v=subtractPedestal(data, ix+ic, iy+ir);
|
|
||||||
|
|
||||||
clusters->set_data(v, ic, ir);
|
|
||||||
// v=clusters->get_data(ic,ir);
|
|
||||||
tot+=v;
|
|
||||||
if (ir<=0 && ic<=0)
|
|
||||||
bl+=v;
|
|
||||||
if (ir<=0 && ic>=0)
|
|
||||||
br+=v;
|
|
||||||
if (ir>=0 && ic<=0)
|
|
||||||
tl+=v;
|
|
||||||
if (ir>=0 && ic>=0)
|
|
||||||
tr+=v;
|
|
||||||
|
|
||||||
if (v>max) {
|
|
||||||
max=v;
|
|
||||||
}
|
|
||||||
if (ir==0 && ic==0) {
|
|
||||||
if (v<-nSigma*clusters->rms)
|
|
||||||
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bl>=br && bl>=tl && bl>=tr) {
|
|
||||||
quad=BOTTOM_LEFT;
|
|
||||||
quadTot=bl;
|
|
||||||
} else if (br>=bl && br>=tl && br>=tr) {
|
|
||||||
quad=BOTTOM_RIGHT;
|
|
||||||
quadTot=br;
|
|
||||||
} else if (tl>=br && tl>=bl && tl>=tr) {
|
|
||||||
quad=TOP_LEFT;
|
|
||||||
quadTot=tl;
|
|
||||||
} else if (tr>=bl && tr>=tl && tr>=br) {
|
|
||||||
quad=TOP_RIGHT;
|
|
||||||
quadTot=tr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (max>nSigma*clusters->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*clusters->rms || quadTot>cy*cs*nSigma*clusters->rms) {
|
|
||||||
if (clusters->get_data(0,0)>=max) {
|
|
||||||
eventMask[iy][ix]=PHOTON_MAX;
|
|
||||||
} else {
|
|
||||||
eventMask[iy][ix]=PHOTON;
|
|
||||||
}
|
|
||||||
} else if (eventMask[iy][ix]==PEDESTAL) {
|
|
||||||
if (cm==0) {
|
|
||||||
if (det)
|
|
||||||
val=dataSign*det->getValue(data, ix, iy);
|
|
||||||
else
|
|
||||||
val=((double**)data)[iy][ix];
|
|
||||||
addToPedestal(val,ix,iy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return eventMask[iy][ix];
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -436,6 +353,7 @@ int *getClusters(char *data, int *ph=NULL) {
|
|||||||
|
|
||||||
double max=0, tl=0, tr=0, bl=0,br=0, *v, vv;
|
double max=0, tl=0, tr=0, bl=0,br=0, *v, vv;
|
||||||
int cm=0;
|
int cm=0;
|
||||||
|
int good=1;
|
||||||
if (cmSub) cm=1;
|
if (cmSub) cm=1;
|
||||||
if (ph==NULL)
|
if (ph==NULL)
|
||||||
ph=image;
|
ph=image;
|
||||||
@ -452,9 +370,9 @@ int *getClusters(char *data, int *ph=NULL) {
|
|||||||
addToCommonMode(data);
|
addToCommonMode(data);
|
||||||
|
|
||||||
|
|
||||||
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 (det->isGood(ix,iy)) {
|
||||||
max=0;
|
max=0;
|
||||||
tl=0;
|
tl=0;
|
||||||
tr=0;
|
tr=0;
|
||||||
@ -498,10 +416,14 @@ int *getClusters(char *data, int *ph=NULL) {
|
|||||||
if (ir==0 && ic==0) {
|
if (ir==0 && ic==0) {
|
||||||
if (*v<-nSigma*(clusters+nph)->rms)
|
if (*v<-nSigma*(clusters+nph)->rms)
|
||||||
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
|
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
|
||||||
|
else if (*v>nSigma*(clusters+nph)->rms)
|
||||||
|
eventMask[iy][ix]=PHOTON;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (eventMask[iy][ix]==PHOTON && val[iy][ix]<max)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (bl>=br && bl>=tl && bl>=tr) {
|
if (bl>=br && bl>=tl && bl>=tr) {
|
||||||
(clusters+nph)->quad=BOTTOM_LEFT;
|
(clusters+nph)->quad=BOTTOM_LEFT;
|
||||||
@ -523,16 +445,22 @@ int *getClusters(char *data, int *ph=NULL) {
|
|||||||
(clusters+nph)->tot=tot;
|
(clusters+nph)->tot=tot;
|
||||||
(clusters+nph)->x=ix;
|
(clusters+nph)->x=ix;
|
||||||
(clusters+nph)->y=iy;
|
(clusters+nph)->y=iy;
|
||||||
(clusters+nph)->iframe=det->getFrameNumber(data);
|
// (clusters+nph)->iframe=det->getFrameNumber(data);
|
||||||
|
// cout << det->getFrameNumber(data) << " " << (clusters+nph)->iframe << endl;
|
||||||
(clusters+nph)->ped=getPedestal(ix,iy,0);
|
(clusters+nph)->ped=getPedestal(ix,iy,0);
|
||||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||||
(clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir);
|
(clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// cout << (clusters+nph)->iframe << " " << ix << " " << nph << " " << tot << " " << (clusters+nph)->quadTot << endl;
|
good=1;
|
||||||
|
if (eMin>0 && tot<eMin) good=0;
|
||||||
|
if (eMax>0 && tot>eMax) good=0;
|
||||||
|
if (good) {
|
||||||
nph++;
|
nph++;
|
||||||
image[iy*nx+ix]++;
|
image[iy*nx+ix]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
eventMask[iy][ix]=PHOTON;
|
eventMask[iy][ix]=PHOTON;
|
||||||
@ -540,15 +468,14 @@ int *getClusters(char *data, int *ph=NULL) {
|
|||||||
} else if (eventMask[iy][ix]==PEDESTAL) {
|
} else if (eventMask[iy][ix]==PEDESTAL) {
|
||||||
addToPedestal(data,ix,iy,cm);
|
addToPedestal(data,ix,iy,cm);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nphFrame=nph;
|
nphFrame=nph;
|
||||||
nphTot+=nph;
|
nphTot+=nph;
|
||||||
//cout << nphFrame << endl;
|
//cout << nphFrame << endl;
|
||||||
// cout <<"**********************************"<< endl;
|
// cout <<"**********************************"<< det->getFrameNumber(data) << " " << nphFrame << endl;
|
||||||
writeClusters();
|
writeClusters(det->getFrameNumber(data));
|
||||||
return image;
|
return image;
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -633,13 +560,27 @@ int *getClusters(char *data, int *ph=NULL) {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void writeClusters(FILE *f, single_photon_hit *clusters, int nph){for (int i=0; i<nph; i++) (clusters+i)->write(f);};
|
static void writeClusters(FILE *f, single_photon_hit *cl, int nph, int fn=0){
|
||||||
void writeClusters(FILE *f){for (int i=0; i<nphFrame; i++) (clusters+i)->write(f);};
|
|
||||||
void writeClusters(){if (myFile) {
|
/* #ifndef OLDFORMAT */
|
||||||
|
/* if (fwrite((void*)&fn, 1, sizeof(int), f)) */
|
||||||
|
/* if (fwrite((void*)&nph, 1, sizeof(int), f)) */
|
||||||
|
/* #endif */
|
||||||
|
for (int i=0; i<nph; i++) (cl+i)->write(f);
|
||||||
|
};
|
||||||
|
void writeClusters(FILE *f, int fn=0){
|
||||||
|
writeClusters(f,clusters,nphFrame, fn);
|
||||||
|
//for (int i=0; i<nphFrame; i++)
|
||||||
|
//(clusters+i)->write(f);
|
||||||
|
};
|
||||||
|
void writeClusters(int fn){
|
||||||
|
if (myFile) {
|
||||||
//cout << "++" << endl;
|
//cout << "++" << endl;
|
||||||
pthread_mutex_lock(fm);
|
pthread_mutex_lock(fm);
|
||||||
for (int i=0; i<nphFrame; i++)
|
// cout <<"**********************************"<< fn << " " << nphFrame << endl;
|
||||||
(clusters+i)->write(myFile);
|
writeClusters(myFile,clusters,nphFrame, fn);
|
||||||
|
// for (int i=0; i<nphFrame; i++)
|
||||||
|
// (clusters+i)->write(myFile);
|
||||||
pthread_mutex_unlock(fm);
|
pthread_mutex_unlock(fm);
|
||||||
//cout << "--" << endl;
|
//cout << "--" << endl;
|
||||||
}
|
}
|
||||||
@ -650,21 +591,36 @@ void writeClusters(FILE *f){for (int i=0; i<nphFrame; i++) (clusters+i)->write(f
|
|||||||
// cout << "sp" << endl;
|
// cout << "sp" << endl;
|
||||||
switch(fMode) {
|
switch(fMode) {
|
||||||
case ePedestal:
|
case ePedestal:
|
||||||
|
//cout <<"spc add to ped " << endl;
|
||||||
addToPedestal(data);
|
addToPedestal(data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
switch (dMode) {
|
||||||
|
case eAnalog:
|
||||||
|
analogDetector<uint16_t>::processData(data,val);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// cout <<"spc " << endl;
|
||||||
getNPhotons(data,val);
|
getNPhotons(data,val);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
iframe++;
|
iframe++;
|
||||||
// cout << "done" << endl;
|
// cout << "done" << endl;
|
||||||
};
|
};
|
||||||
int getPhFrame(){return nphFrame;};
|
int getPhFrame(){return nphFrame;};
|
||||||
int getPhTot(){return nphTot;};
|
int getPhTot(){return nphTot;};
|
||||||
|
|
||||||
|
void setEnergyRange(double emi, double ema){eMin=emi; eMax=ema;};
|
||||||
|
void getEnergyRange(double &emi, double &ema){emi=eMin; ema=eMax;};
|
||||||
|
|
||||||
|
void setMutex(pthread_mutex_t *m){fm=m;};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
int nDark; /**< number of frames to be used at the beginning of the dataset to calculate pedestal without applying photon discrimination */
|
int nDark; /**< number of frames to be used at the beginning of the dataset to calculate pedestal without applying photon discrimination */
|
||||||
eventType **eventMask; /**< matrix of event type or each pixel */
|
eventType **eventMask; /**< matrix of event type or each pixel */
|
||||||
double nSigma; /**< number of sigma parameter for photon discrimination */
|
double nSigma; /**< number of sigma parameter for photon discrimination */
|
||||||
|
double eMin, eMax;
|
||||||
int clusterSize; /**< cluster size in the x direction */
|
int clusterSize; /**< cluster size in the x direction */
|
||||||
int clusterSizeY; /**< cluster size in the y direction i.e. 1 for strips, clusterSize for pixels */
|
int clusterSizeY; /**< cluster size in the y direction i.e. 1 for strips, clusterSize for pixels */
|
||||||
// single_photon_hit *cluster; /**< single photon hit data structure */
|
// single_photon_hit *cluster; /**< single photon hit data structure */
|
||||||
@ -675,6 +631,7 @@ void writeClusters(FILE *f){for (int i=0; i<nphFrame; i++) (clusters+i)->write(f
|
|||||||
int nphTot;
|
int nphTot;
|
||||||
int nphFrame;
|
int nphFrame;
|
||||||
|
|
||||||
|
pthread_mutex_t *fm;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,8 +38,62 @@ class single_photon_hit {
|
|||||||
size_t write(FILE *myFile) {
|
size_t write(FILE *myFile) {
|
||||||
//fwrite((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile);
|
//fwrite((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile);
|
||||||
|
|
||||||
if (fwrite((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile))
|
// if (fwrite((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile))
|
||||||
|
//#ifdef OLDFORMAT
|
||||||
|
if (fwrite((void*)&iframe, 1, sizeof(int), myFile)) {};
|
||||||
|
//#endif
|
||||||
|
#ifndef WRITE_QUAD
|
||||||
|
//printf("no quad ");
|
||||||
|
if (fwrite((void*)&x, 2, sizeof(int16_t), myFile))
|
||||||
return fwrite((void*)data, 1, dx*dy*sizeof(int), myFile);
|
return fwrite((void*)data, 1, dx*dy*sizeof(int), myFile);
|
||||||
|
#endif
|
||||||
|
#ifdef WRITE_QUAD
|
||||||
|
// printf("quad ");
|
||||||
|
int qq[4];
|
||||||
|
switch(quad) {
|
||||||
|
case TOP_LEFT:
|
||||||
|
qq[0]=data[3];
|
||||||
|
qq[1]=data[4];
|
||||||
|
qq[2]=data[6];
|
||||||
|
qq[3]=data[7];
|
||||||
|
x=x-1;
|
||||||
|
y=y;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TOP_RIGHT:
|
||||||
|
qq[0]=data[4];
|
||||||
|
qq[1]=data[5];
|
||||||
|
qq[2]=data[7];
|
||||||
|
qq[3]=data[8];
|
||||||
|
x=x;
|
||||||
|
y=y;
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case BOTTOM_LEFT:
|
||||||
|
qq[0]=data[0];
|
||||||
|
qq[1]=data[1];
|
||||||
|
qq[2]=data[3];
|
||||||
|
qq[3]=data[4];
|
||||||
|
x=x-1;
|
||||||
|
y=y-1;
|
||||||
|
break;
|
||||||
|
case BOTTOM_RIGHT:
|
||||||
|
qq[0]=data[1];
|
||||||
|
qq[1]=data[2];
|
||||||
|
qq[2]=data[4];
|
||||||
|
qq[3]=data[5];
|
||||||
|
x=x;
|
||||||
|
y=y-1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
if (fwrite((void*)&x, 2, sizeof(int16_t), myFile))
|
||||||
|
return fwrite((void*)qq, 1, 4*sizeof(int), myFile);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -50,11 +104,126 @@ class single_photon_hit {
|
|||||||
size_t read(FILE *myFile) {
|
size_t read(FILE *myFile) {
|
||||||
//fread((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile);
|
//fread((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile);
|
||||||
|
|
||||||
if (fread((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile))
|
//#ifdef OLDFORMAT
|
||||||
|
if (fread((void*)&iframe, 1, sizeof(int), myFile)) {}
|
||||||
|
//#endif
|
||||||
|
#ifndef WRITE_QUAD
|
||||||
|
// printf( "no quad \n");
|
||||||
|
if (fread((void*)&x, 2, sizeof(int16_t), myFile))
|
||||||
return fread((void*)data, 1, dx*dy*sizeof(int), myFile);
|
return fread((void*)data, 1, dx*dy*sizeof(int), myFile);
|
||||||
|
#endif
|
||||||
|
#ifdef WRITE_QUAD
|
||||||
|
int qq[4];
|
||||||
|
// printf( "quad \n");
|
||||||
|
if (fread((void*)&x, 2, sizeof(int16_t), myFile))
|
||||||
|
if (fread((void*)qq, 1, 4*sizeof(int), myFile)) {
|
||||||
|
|
||||||
|
quad=TOP_RIGHT;
|
||||||
|
int mm=qq[0];
|
||||||
|
for (int i=1; i<4; i++) {
|
||||||
|
if (qq[i]<mm) {
|
||||||
|
switch (i) {
|
||||||
|
case 1:
|
||||||
|
quad=TOP_LEFT;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
quad=BOTTOM_RIGHT;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
quad=BOTTOM_LEFT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
switch(quad) {
|
||||||
|
case TOP_LEFT:
|
||||||
|
data[0]=0;
|
||||||
|
data[1]=0;
|
||||||
|
data[2]=0;
|
||||||
|
data[3]=qq[0];
|
||||||
|
data[4]=qq[1];
|
||||||
|
data[5]=0;
|
||||||
|
data[6]=qq[2];
|
||||||
|
data[7]=qq[3];
|
||||||
|
data[8]=0;
|
||||||
|
x=x+1;
|
||||||
|
y=y;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TOP_RIGHT:
|
||||||
|
data[0]=0;
|
||||||
|
data[1]=0;
|
||||||
|
data[2]=0;
|
||||||
|
data[3]=0;
|
||||||
|
data[4]=qq[0];
|
||||||
|
data[5]=qq[1];
|
||||||
|
data[6]=0;
|
||||||
|
data[7]=qq[2];
|
||||||
|
data[8]=qq[3];
|
||||||
|
x=x;
|
||||||
|
y=y;
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case BOTTOM_LEFT:
|
||||||
|
data[0]=qq[0];
|
||||||
|
data[1]=qq[1];
|
||||||
|
data[2]=0;
|
||||||
|
data[3]=qq[2];
|
||||||
|
data[4]=qq[3];
|
||||||
|
data[5]=0;
|
||||||
|
data[6]=0;
|
||||||
|
data[7]=0;
|
||||||
|
data[8]=0;
|
||||||
|
x=x+1;
|
||||||
|
y=y+1;
|
||||||
|
break;
|
||||||
|
case BOTTOM_RIGHT:
|
||||||
|
data[0]=0;
|
||||||
|
data[1]=qq[0];
|
||||||
|
data[2]=qq[1];
|
||||||
|
data[3]=0;
|
||||||
|
data[4]=qq[2];
|
||||||
|
data[5]=qq[3];
|
||||||
|
data[6]=0;
|
||||||
|
data[7]=0;
|
||||||
|
data[8]=0;
|
||||||
|
x=x;
|
||||||
|
y=y+1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void print() {
|
||||||
|
|
||||||
|
int ix, iy;
|
||||||
|
|
||||||
|
for (int iy=0; iy<dy; iy++) {
|
||||||
|
for (int ix=0; ix<dx; ix++) {
|
||||||
|
printf("%d \t",data[ix+iy*dx]);
|
||||||
|
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
assign the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0)
|
assign the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0)
|
||||||
\param v value to be set
|
\param v value to be set
|
||||||
|
@ -331,8 +331,6 @@ class slsDetectorData {
|
|||||||
*/
|
*/
|
||||||
virtual char *readNextFrame(ifstream &filebin)=0;
|
virtual char *readNextFrame(ifstream &filebin)=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ void *WriteToTiff(float * imgData, const char * imgname, int nrow, int ncol){
|
|||||||
int sampleperpixel=1;
|
int sampleperpixel=1;
|
||||||
// unsigned char * buff=NULL;
|
// unsigned char * buff=NULL;
|
||||||
tsize_t linebytes;
|
tsize_t linebytes;
|
||||||
cout << "--" <<endl;
|
// cout << "--" <<endl;
|
||||||
TIFF * tif = TIFFOpen(imgname,"w");
|
TIFF * tif = TIFFOpen(imgname,"w");
|
||||||
if (tif) {
|
if (tif) {
|
||||||
TIFFSetField(tif,TIFFTAG_IMAGEWIDTH,ncol);
|
TIFFSetField(tif,TIFFTAG_IMAGEWIDTH,ncol);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
Path: slsDetectorsPackage/slsDetectorGui
|
Path: slsDetectorsPackage/slsDetectorGui
|
||||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||||
Repsitory UUID: 3c774478681813e451df683e2bc8403b37490323
|
Repsitory UUID: 907d1655d1f6cf2bb8cf6ccd7e91e82f479dd2ca
|
||||||
Revision: 524
|
Revision: 525
|
||||||
Branch: 4.0.1
|
Branch: developer
|
||||||
Last Changed Author: Dhanya_Thattil
|
Last Changed Author: Dhanya_Thattil
|
||||||
Last Changed Rev: 4084
|
Last Changed Rev: 4101
|
||||||
Last Changed Date: 2019-02-07 18:05:28.000000002 +0100 ./src/qTabSettings.cpp
|
Last Changed Date: 2019-02-07 18:05:28.000000002 +0100 ./src/qTabSettings.cpp
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||||
#define GITREPUUID "3c774478681813e451df683e2bc8403b37490323"
|
#define GITREPUUID "907d1655d1f6cf2bb8cf6ccd7e91e82f479dd2ca"
|
||||||
#define GITAUTH "Dhanya_Thattil"
|
#define GITAUTH "Dhanya_Thattil"
|
||||||
#define GITREV 0x4084
|
#define GITREV 0x4101
|
||||||
#define GITDATE 0x20190207
|
#define GITDATE 0x20190207
|
||||||
#define GITBRANCH "4.0.1"
|
#define GITBRANCH "developer"
|
||||||
|
@ -31,6 +31,9 @@ int myport=-1;
|
|||||||
//struct sockaddr_in address;
|
//struct sockaddr_in address;
|
||||||
//#define VERBOSE
|
//#define VERBOSE
|
||||||
|
|
||||||
|
#define BLACKFIN_DRVR_SND_LMT (30000) // rough limit
|
||||||
|
#define BLACKFIN_RSND_PCKT_LOOP (10)
|
||||||
|
#define BLACKFIN_RSND_WAIT_US (1)
|
||||||
|
|
||||||
int bindSocket(unsigned short int port_number) {
|
int bindSocket(unsigned short int port_number) {
|
||||||
int i;
|
int i;
|
||||||
@ -314,13 +317,46 @@ int receiveData(int file_des, void* buf,int length, intType itype){
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int sendDataOnly(int file_des, void* buf,int length) {
|
int sendDataOnly(int file_des, void* buf,int length) {
|
||||||
if (!length)
|
if (!length)
|
||||||
return 0;
|
return 0;
|
||||||
int ret = write(file_des, buf, length); //value of -1 is other end socket crash as sigpipe is ignored
|
|
||||||
if (ret < 0) cprintf(BG_RED, "Error writing to socket. Possible socket crash\n");
|
|
||||||
return ret;
|
int bytesSent = 0;
|
||||||
|
int retry = 0; // retry index when buffer is blocked (write returns 0)
|
||||||
|
while (bytesSent < length) {
|
||||||
|
|
||||||
|
// setting a max packet size for blackfin driver (and network driver does not do a check if packets sent)
|
||||||
|
int bytesToSend = length - bytesSent;
|
||||||
|
if (bytesToSend > BLACKFIN_DRVR_SND_LMT)
|
||||||
|
bytesToSend = BLACKFIN_DRVR_SND_LMT;
|
||||||
|
|
||||||
|
// send
|
||||||
|
int rc = write(file_des, (char*)((char*)buf + bytesSent), bytesToSend);
|
||||||
|
// error
|
||||||
|
if (rc < 0) {
|
||||||
|
cprintf(BG_RED, "Error writing to socket. Possible socket crash: left=%d rc=%d length=%d sent=%d\n", bytesToSend, rc, length, bytesSent);
|
||||||
|
return bytesSent;
|
||||||
|
}
|
||||||
|
// also error, wrote nothing, buffer blocked up, too fast sending for client
|
||||||
|
if (rc == 0) {
|
||||||
|
cprintf(RED, "Error writing to socket. Buffer full. Retry: %d\n", retry);
|
||||||
|
++retry;
|
||||||
|
// wrote nothing for many loops
|
||||||
|
if (retry >= BLACKFIN_RSND_PCKT_LOOP) {
|
||||||
|
cprintf(BG_RED, "Error writing to socket. Buffer full! Too fast! No more.\n");
|
||||||
|
return bytesSent;
|
||||||
|
}
|
||||||
|
usleep(BLACKFIN_RSND_WAIT_US);
|
||||||
|
}
|
||||||
|
// wrote something, reset retry
|
||||||
|
else {
|
||||||
|
retry = 0;
|
||||||
|
}
|
||||||
|
bytesSent += rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bytesSent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -378,6 +378,8 @@ enum dacIndex {
|
|||||||
M_vIbiasSh, /**< mythen 3 >*/
|
M_vIbiasSh, /**< mythen 3 >*/
|
||||||
M_vIcin, /**< mythen 3 >*/
|
M_vIcin, /**< mythen 3 >*/
|
||||||
M_vIpreOut, /**< mythen 3 >*/
|
M_vIpreOut, /**< mythen 3 >*/
|
||||||
|
ZMQ_emin, /**< ZMQ */
|
||||||
|
ZMQ_emax,/**< ZMQ */
|
||||||
V_POWER_A = 100, /**new chiptest board */
|
V_POWER_A = 100, /**new chiptest board */
|
||||||
V_POWER_B = 101, /**new chiptest board */
|
V_POWER_B = 101, /**new chiptest board */
|
||||||
V_POWER_C = 102, /**new chiptest board */
|
V_POWER_C = 102, /**new chiptest board */
|
||||||
@ -473,13 +475,28 @@ enum readOutFlags {
|
|||||||
READ_HITS=0x2, /**< return only the number of the channel which counted ate least one */
|
READ_HITS=0x2, /**< return only the number of the channel which counted ate least one */
|
||||||
ZERO_COMPRESSION=0x4,/**< returned data are 0-compressed */
|
ZERO_COMPRESSION=0x4,/**< returned data are 0-compressed */
|
||||||
PUMP_PROBE_MODE=0x8,/**<pump-probe mode */
|
PUMP_PROBE_MODE=0x8,/**<pump-probe mode */
|
||||||
|
|
||||||
|
PEDESTAL=0x10,/**< frame mode set to pedestal */
|
||||||
|
FLAT=0x20,/**< frame mode set to flat */
|
||||||
|
NEWPEDESTAL=0x40,/**< frame mode set to pedestal and reset */
|
||||||
|
NEWFLAT=0x80,/**< frame mode set to flat and reset */
|
||||||
|
|
||||||
|
FRAME=0x100, /**< frame mode set to normal frame */
|
||||||
|
ANALOG=0x200, /**<detector working in analog mode */
|
||||||
|
COUNTING=0x400, /**<detector working in counting mode */
|
||||||
|
INTERPOLATING=0x800, /**<detector working in interpolating mode */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BACKGROUND_CORRECTIONS=0x1000, /**<background corrections */
|
BACKGROUND_CORRECTIONS=0x1000, /**<background corrections */
|
||||||
TOT_MODE=0x2000,/**< pump-probe mode */
|
TOT_MODE=0x2000,/**< pump-probe mode */
|
||||||
CONTINOUS_RO=0x4000,/**< pump-probe mode */
|
CONTINOUS_RO=0x4000,/**< pump-probe mode */
|
||||||
|
|
||||||
PARALLEL=0x10000,/**< eiger parallel mode */
|
PARALLEL=0x10000,/**< eiger parallel mode */
|
||||||
NONPARALLEL=0x20000,/**< eiger serial mode */
|
NONPARALLEL=0x20000,/**< eiger serial mode */
|
||||||
SAFE=0x40000/**< eiger safe mode */,
|
SAFE=0x40000/**< eiger safe mode */,
|
||||||
DIGITAL_ONLY=0x80000, /** chiptest board read only digital bits (not adc values)*/
|
DIGITAL_ONLY=0x80000, /** chiptest board read only digital bits (not adc values)*/
|
||||||
|
|
||||||
ANALOG_AND_DIGITAL=0x100000, /** chiptest board read adc values and digital bits digital bits */
|
ANALOG_AND_DIGITAL=0x100000, /** chiptest board read adc values and digital bits digital bits */
|
||||||
DUT_CLK=0x200000, /** chiptest board fifo clock comes from device under test */
|
DUT_CLK=0x200000, /** chiptest board fifo clock comes from device under test */
|
||||||
SHOW_OVERFLOW=0x400000, /** eiger 32 bit mode, show saturated for overflow of single subframes */
|
SHOW_OVERFLOW=0x400000, /** eiger 32 bit mode, show saturated for overflow of single subframes */
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
Path: slsDetectorsPackage/slsDetectorSoftware
|
Path: slsDetectorsPackage/slsDetectorSoftware
|
||||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||||
Repsitory UUID: 3c774478681813e451df683e2bc8403b37490323
|
Repsitory UUID: 907d1655d1f6cf2bb8cf6ccd7e91e82f479dd2ca
|
||||||
Revision: 2071
|
Revision: 2076
|
||||||
Branch: 4.0.1
|
Branch: developer
|
||||||
Last Changed Author: Dhanya_Thattil
|
Last Changed Author: Dhanya_Thattil
|
||||||
Last Changed Rev: 4084
|
Last Changed Rev: 4101
|
||||||
Last Changed Date: 2019-02-08 17:25:57.000000002 +0100 ./threadFiles/ThreadPool.o
|
Last Changed Date: 2019-02-11 14:35:41.000000002 +0100 ./threadFiles/ThreadPool.o
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
CROSS = bfin-uclinux-
|
CROSS = bfin-uclinux-
|
||||||
CC = $(CROSS)gcc
|
CC = $(CROSS)gcc
|
||||||
|
|
||||||
CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DV1 -DCTB -DOLDVERSION #-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER
|
CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DV1 -DCTB
|
||||||
|
|
||||||
|
|
||||||
PROGS= jctbDetectorServer
|
PROGS= jctbDetectorServer
|
||||||
@ -24,22 +24,18 @@ OBJS = $(SRCS:%.c=%.o)
|
|||||||
|
|
||||||
all: clean versioning $(PROGS)
|
all: clean versioning $(PROGS)
|
||||||
|
|
||||||
test: clean jungfrauADCTEst
|
test: clean jungfrauADCTest
|
||||||
|
|
||||||
boot: $(OBJS)
|
boot: $(OBJS)
|
||||||
|
|
||||||
versioning:
|
versioning:
|
||||||
@echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;`
|
@echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;`
|
||||||
|
|
||||||
jctbDetectorServerNew: $(OBJS)
|
jctbDetectorServer: $(OBJS)
|
||||||
echo $(OBJS)
|
echo $(OBJS)
|
||||||
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
|
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
|
||||||
|
|
||||||
jctbDetectorServer: $(OBJS)
|
jungfrauADCTest: $(OBJS)
|
||||||
echo $(OBJS)
|
|
||||||
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@) -DOLDVERSION
|
|
||||||
|
|
||||||
jungfrauADCTEst: $(OBJS)
|
|
||||||
echo $(OBJS)
|
echo $(OBJS)
|
||||||
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@) -DTESTADC
|
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@) -DTESTADC
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "registers_m.h"
|
#include "registers_m.h"
|
||||||
|
|
||||||
//for memory mapping
|
//for memory mapping
|
||||||
u_int32_t CSP0BASE;
|
u_int64_t CSP0BASE;
|
||||||
|
|
||||||
u_int16_t volatile *values;
|
u_int16_t volatile *values;
|
||||||
|
|
||||||
@ -43,8 +43,8 @@ int mapCSP0(void) {
|
|||||||
}
|
}
|
||||||
printf("/dev/mem opened\n");
|
printf("/dev/mem opened\n");
|
||||||
|
|
||||||
CSP0BASE = (u_int32_t)mmap(0, MEM_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, CSP0);
|
CSP0BASE = mmap(0, MEM_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, CSP0);
|
||||||
if (CSP0BASE == (u_int32_t)MAP_FAILED) {
|
if (CSP0BASE == MAP_FAILED) {
|
||||||
printf("\nCan't map memmory area!!\n");
|
printf("\nCan't map memmory area!!\n");
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -61,8 +61,8 @@ int mapCSP0(void) {
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
printf("CSPObase is 0x%08x \n",CSP0BASE);
|
printf("CSPObase is 0x%08llx \n",CSP0BASE);
|
||||||
printf("CSPOBASE=from %08x to %08x\n",CSP0BASE,CSP0BASE+MEM_SIZE);
|
printf("CSPOBASE=from %08llx to %08llx\n",CSP0BASE,CSP0BASE+MEM_SIZE);
|
||||||
|
|
||||||
u_int32_t address;
|
u_int32_t address;
|
||||||
address = FIFO_DATA_REG;//_OFF;
|
address = FIFO_DATA_REG;//_OFF;
|
||||||
@ -73,12 +73,24 @@ int mapCSP0(void) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int16_t bus_r16(u_int32_t offset){
|
|
||||||
|
|
||||||
|
|
||||||
|
u_int16_t a_bus_r16(u_int32_t offset){
|
||||||
volatile u_int16_t *ptr1;
|
volatile u_int16_t *ptr1;
|
||||||
ptr1=(u_int16_t*)(CSP0BASE+offset*2);
|
ptr1=(u_int16_t*)(CSP0BASE+offset*2);
|
||||||
return *ptr1;
|
return *ptr1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u_int16_t bus_r16(u_int32_t offset){
|
||||||
|
u_int16_t r= a_bus_r16(offset);
|
||||||
|
/* #ifndef OLDVERSION */
|
||||||
|
/* while (r!=a_bus_r16(offset)) */
|
||||||
|
/* r=a_bus_r16(offset); */
|
||||||
|
/* #endif */
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
u_int16_t bus_w16(u_int32_t offset, u_int16_t data) {
|
u_int16_t bus_w16(u_int32_t offset, u_int16_t data) {
|
||||||
volatile u_int16_t *ptr1;
|
volatile u_int16_t *ptr1;
|
||||||
ptr1=(u_int16_t*)(CSP0BASE+offset*2);
|
ptr1=(u_int16_t*)(CSP0BASE+offset*2);
|
||||||
@ -97,12 +109,21 @@ u_int32_t bus_w(u_int32_t offset, u_int32_t data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
u_int32_t bus_r(u_int32_t offset) {
|
u_int32_t a_bus_r(u_int32_t offset) {
|
||||||
volatile u_int32_t *ptr1;
|
volatile u_int32_t *ptr1;
|
||||||
ptr1=(u_int32_t*)(CSP0BASE+offset*2);
|
ptr1=(u_int32_t*)(CSP0BASE+offset*2);
|
||||||
return *ptr1;
|
return *ptr1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u_int32_t bus_r(u_int32_t offset){
|
||||||
|
u_int32_t r= a_bus_r(offset);
|
||||||
|
/* #ifndef OLDVERSION */
|
||||||
|
/* while (r!=a_bus_r(offset)) */
|
||||||
|
/* r=a_bus_r(offset); */
|
||||||
|
/* #endif */
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
// program dacq settings
|
// program dacq settings
|
||||||
|
|
||||||
int64_t set64BitReg(int64_t value, int aLSB, int aMSB){
|
int64_t set64BitReg(int64_t value, int aLSB, int aMSB){
|
||||||
|
@ -75,7 +75,8 @@ typedef struct ip_header_struct {
|
|||||||
|
|
||||||
struct timeval tss,tse,tsss; //for timing
|
struct timeval tss,tse,tsss; //for timing
|
||||||
|
|
||||||
|
#define MAXDAC 32
|
||||||
|
u_int32_t dac[MAXDAC];
|
||||||
|
|
||||||
FILE *debugfp, *datafp;
|
FILE *debugfp, *datafp;
|
||||||
|
|
||||||
@ -890,107 +891,33 @@ int setTiming(int ti) {
|
|||||||
|
|
||||||
|
|
||||||
int ret=GET_EXTERNAL_COMMUNICATION_MODE;
|
int ret=GET_EXTERNAL_COMMUNICATION_MODE;
|
||||||
|
int val;
|
||||||
int g=-1, t=-1, rot=-1;
|
int g=-1, t=-1, rot=-1;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
val=bus_r(EXT_SIGNAL_REG);
|
||||||
switch (ti) {
|
switch (ti) {
|
||||||
case AUTO_TIMING:
|
case AUTO_TIMING:
|
||||||
timingMode=ti;
|
bus_w(EXT_SIGNAL_REG,val&~(0x1));
|
||||||
// disable all gates/triggers in except if used for master/slave synchronization
|
|
||||||
for (i=0; i<4; i++) {
|
|
||||||
if (getFPGASignal(i)>0 && getFPGASignal(i)<GATE_OUT_ACTIVE_HIGH && signals[i]!=MASTER_SLAVE_SYNCHRONIZATION)
|
|
||||||
setFPGASignal(i,SIGNAL_OFF);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TRIGGER_EXPOSURE:
|
case TRIGGER_EXPOSURE:
|
||||||
timingMode=ti;
|
bus_w(EXT_SIGNAL_REG,val|(0x1));
|
||||||
// if one of the signals is configured to be trigger, set it and unset possible gates
|
|
||||||
for (i=0; i<4; i++) {
|
|
||||||
if (signals[i]==TRIGGER_IN_RISING_EDGE || signals[i]==TRIGGER_IN_FALLING_EDGE)
|
|
||||||
setFPGASignal(i,signals[i]);
|
|
||||||
else if (signals[i]==GATE_IN_ACTIVE_HIGH || signals[i]==GATE_IN_ACTIVE_LOW)
|
|
||||||
setFPGASignal(i,SIGNAL_OFF);
|
|
||||||
else if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
|
||||||
setFPGASignal(i,SIGNAL_OFF);
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case TRIGGER_READOUT:
|
|
||||||
timingMode=ti;
|
|
||||||
// if one of the signals is configured to be trigger, set it and unset possible gates
|
|
||||||
for (i=0; i<4; i++) {
|
|
||||||
if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
|
||||||
setFPGASignal(i,signals[i]);
|
|
||||||
else if (signals[i]==GATE_IN_ACTIVE_HIGH || signals[i]==GATE_IN_ACTIVE_LOW)
|
|
||||||
setFPGASignal(i,SIGNAL_OFF);
|
|
||||||
else if (signals[i]==TRIGGER_IN_RISING_EDGE || signals[i]==TRIGGER_IN_FALLING_EDGE)
|
|
||||||
setFPGASignal(i,SIGNAL_OFF);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GATE_FIX_NUMBER:
|
|
||||||
timingMode=ti;
|
|
||||||
// if one of the signals is configured to be trigger, set it and unset possible gates
|
|
||||||
for (i=0; i<4; i++) {
|
|
||||||
if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
|
||||||
setFPGASignal(i,SIGNAL_OFF);
|
|
||||||
else if (signals[i]==GATE_IN_ACTIVE_HIGH || signals[i]==GATE_IN_ACTIVE_LOW)
|
|
||||||
setFPGASignal(i,signals[i]);
|
|
||||||
else if (signals[i]==TRIGGER_IN_RISING_EDGE || signals[i]==TRIGGER_IN_FALLING_EDGE)
|
|
||||||
setFPGASignal(i,SIGNAL_OFF);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case GATE_WITH_START_TRIGGER:
|
|
||||||
timingMode=ti;
|
|
||||||
for (i=0; i<4; i++) {
|
|
||||||
if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
|
||||||
setFPGASignal(i,SIGNAL_OFF);
|
|
||||||
else if (signals[i]==GATE_IN_ACTIVE_HIGH || signals[i]==GATE_IN_ACTIVE_LOW)
|
|
||||||
setFPGASignal(i,signals[i]);
|
|
||||||
else if (signals[i]==TRIGGER_IN_RISING_EDGE || signals[i]==TRIGGER_IN_FALLING_EDGE)
|
|
||||||
setFPGASignal(i,signals[i]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bus_r(EXT_SIGNAL_REG)&0x1)
|
||||||
|
|
||||||
for (i=0; i<4; i++) {
|
|
||||||
if (signals[i]!=MASTER_SLAVE_SYNCHRONIZATION) {
|
|
||||||
if (getFPGASignal(i)==RO_TRIGGER_IN_RISING_EDGE || getFPGASignal(i)==RO_TRIGGER_IN_FALLING_EDGE)
|
|
||||||
rot=i;
|
|
||||||
else if (getFPGASignal(i)==GATE_IN_ACTIVE_HIGH || getFPGASignal(i)==GATE_IN_ACTIVE_LOW)
|
|
||||||
g=i;
|
|
||||||
else if (getFPGASignal(i)==TRIGGER_IN_RISING_EDGE || getFPGASignal(i)==TRIGGER_IN_FALLING_EDGE)
|
|
||||||
t=i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (g>=0 && t>=0 && rot<0) {
|
|
||||||
ret=GATE_WITH_START_TRIGGER;
|
|
||||||
} else if (g<0 && t>=0 && rot<0) {
|
|
||||||
ret=TRIGGER_EXPOSURE;
|
ret=TRIGGER_EXPOSURE;
|
||||||
} else if (g>=0 && t<0 && rot<0) {
|
else
|
||||||
ret=GATE_FIX_NUMBER;
|
|
||||||
} else if (g<0 && t<0 && rot>0) {
|
|
||||||
ret=TRIGGER_READOUT;
|
|
||||||
} else if (g<0 && t<0 && rot<0) {
|
|
||||||
ret=AUTO_TIMING;
|
ret=AUTO_TIMING;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// timingMode=ret;
|
// timingMode=ret;
|
||||||
|
|
||||||
@ -1671,9 +1598,11 @@ int initHighVoltage(int val, int imod){
|
|||||||
codata=((dacvalue)&0xff);
|
codata=((dacvalue)&0xff);
|
||||||
|
|
||||||
|
|
||||||
valw=bus_r(offw)&0x7fff; //switch off HV
|
valw=(bus_r(offw) & 0x7fff) | 0x00ff;
|
||||||
|
|
||||||
bus_w(offw,(valw)); // start point
|
bus_w(offw,(valw)); // start point
|
||||||
valw=((valw&(~(0x1<<csdx))));bus_w(offw,valw); //chip sel bar down
|
valw=((valw&(~(0x1<<csdx))));bus_w(offw,valw); //chip sel bar down
|
||||||
|
|
||||||
for (i=0;i<8;i++) {
|
for (i=0;i<8;i++) {
|
||||||
valw=(valw&(~(0x1<<cdx)));bus_w(offw,valw); //cldwn
|
valw=(valw&(~(0x1<<cdx)));bus_w(offw,valw); //cldwn
|
||||||
valw=((valw&(~(0x1<<ddx)))+(((codata>>(7-i))&0x1)<<ddx));bus_w(offw,valw);//write data (i)
|
valw=((valw&(~(0x1<<ddx)))+(((codata>>(7-i))&0x1)<<ddx));bus_w(offw,valw);//write data (i)
|
||||||
@ -1683,10 +1612,14 @@ int initHighVoltage(int val, int imod){
|
|||||||
|
|
||||||
valw=(valw&(~(0x1<<cdx)));bus_w(offw,valw); //cldwn
|
valw=(valw&(~(0x1<<cdx)));bus_w(offw,valw); //cldwn
|
||||||
|
|
||||||
if (dacvalue>=0) {
|
|
||||||
valw=bus_r(offw)|0xff00;; //switch on HV
|
|
||||||
|
if (val>=0) {
|
||||||
|
valw=bus_r(offw) | 0x8000;; //switch on HV
|
||||||
|
printf("switch on HV in CTB4 %x\n");
|
||||||
} else {
|
} else {
|
||||||
valw=bus_r(offw) & 0x7fff;//switch off HV
|
valw=bus_r(offw) & 0x7fff;//switch off HV
|
||||||
|
printf("switch off HV in CTB4\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1695,6 +1628,22 @@ int initHighVoltage(int val, int imod){
|
|||||||
|
|
||||||
bus_w(HV_REG,val);
|
bus_w(HV_REG,val);
|
||||||
|
|
||||||
|
|
||||||
|
//added for CTB5!
|
||||||
|
|
||||||
|
// valw=bus_r(POWER_ON_REG);
|
||||||
|
if (val>=0) {
|
||||||
|
i=bus_r(POWER_ON_REG) | 0x80000000;; //switch on HV
|
||||||
|
printf("switch on HV in CTB5 %08x\n", i);
|
||||||
|
} else {
|
||||||
|
i=bus_r(POWER_ON_REG) & 0x7fffffff;//switch off HV
|
||||||
|
printf("switch off HV in CTB5 %08x\n", i);
|
||||||
|
}
|
||||||
|
|
||||||
|
bus_w(POWER_ON_REG,i);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2003,7 +1952,7 @@ int startStateMachine(){
|
|||||||
bus_w16(CONTROL_REG, FIFO_RESET_BIT);
|
bus_w16(CONTROL_REG, FIFO_RESET_BIT);
|
||||||
bus_w16(CONTROL_REG, 0x0);
|
bus_w16(CONTROL_REG, 0x0);
|
||||||
bus_w16(CONTROL_REG, START_ACQ_BIT | START_EXPOSURE_BIT);
|
bus_w16(CONTROL_REG, START_ACQ_BIT | START_EXPOSURE_BIT);
|
||||||
// usleep(20);
|
usleep(20);
|
||||||
bus_w16(CONTROL_REG, 0x0);
|
bus_w16(CONTROL_REG, 0x0);
|
||||||
//verify
|
//verify
|
||||||
/* if(bus_r(STATUS_REG) & RUN_BUSY_BIT) */
|
/* if(bus_r(STATUS_REG) & RUN_BUSY_BIT) */
|
||||||
@ -2128,6 +2077,7 @@ u_int16_t* fifo_read_event(int ns)
|
|||||||
a=bus_r16(LOOK_AT_ME_REG);
|
a=bus_r16(LOOK_AT_ME_REG);
|
||||||
while(a==0) {
|
while(a==0) {
|
||||||
if (runBusy()==0) {
|
if (runBusy()==0) {
|
||||||
|
usleep(100);
|
||||||
a = bus_r(LOOK_AT_ME_REG);
|
a = bus_r(LOOK_AT_ME_REG);
|
||||||
if (a==0) {
|
if (a==0) {
|
||||||
printf("no frame found and acquisition finished - exiting\n");
|
printf("no frame found and acquisition finished - exiting\n");
|
||||||
@ -2137,36 +2087,29 @@ u_int16_t* fifo_read_event(int ns)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a = bus_r(LOOK_AT_ME_REG);
|
a = bus_r16(LOOK_AT_ME_REG);
|
||||||
//#ifdef VERBOSE
|
|
||||||
//printf(".");
|
|
||||||
//#endif
|
|
||||||
}
|
|
||||||
/* #ifdef TIMEDBG */
|
|
||||||
/* // tsss=tss; */
|
|
||||||
/* gettimeofday(&tss,NULL); */
|
|
||||||
/* printf("look for data = %ld usec\n", (tss.tv_usec) - (tse.tv_usec)); */
|
|
||||||
|
|
||||||
/* #endif */
|
|
||||||
|
|
||||||
// printf("LAM: %08x\n",a);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf(".");
|
}
|
||||||
a = bus_r(LOOK_AT_ME_REG);
|
//a = bus_r16(LOOK_AT_ME_REG);
|
||||||
|
|
||||||
if (analogEnable) {
|
if (analogEnable) {
|
||||||
printf("*");
|
// printf("*");
|
||||||
bus_w16(DUMMY_REG,1<<8); // read strobe to all fifos
|
bus_w16(DUMMY_REG,1<<8); // read strobe to all fifos
|
||||||
bus_w16(DUMMY_REG,0);
|
bus_w16(DUMMY_REG,0);
|
||||||
for (i=0; i<32; i++) {
|
for (i=0; i<32; i++) {
|
||||||
if (~(mask&adcDisableMask)) {
|
if (~(mask&adcDisableMask)) {
|
||||||
*((u_int16_t*)now_ptr)=*values;//bus_r16(FIFO_DATA_REG);
|
*((u_int16_t*)now_ptr)=bus_r16(FIFO_DATA_REG);
|
||||||
if (i!=0 || ns!=0) {
|
/* if (i!=0 || ns!=0) { */
|
||||||
a=0;
|
/* a=0; */
|
||||||
while (*((u_int16_t*)now_ptr)==*((u_int16_t*)(now_ptr)-1) && a++<10) {
|
/* while (*((u_int16_t*)now_ptr)==*((u_int16_t*)(now_ptr)-1) && a++<10 && *((u_int16_t*)now_ptr)!=0 && *((u_int16_t*)now_ptr)!=0x3ff) { */
|
||||||
*((u_int16_t*)now_ptr)=*values;
|
/* printf("%d .",i); */
|
||||||
}
|
/* *((u_int16_t*)now_ptr)=bus_r16(FIFO_DATA_REG);//\*values; */
|
||||||
|
/* } */
|
||||||
|
/* } */
|
||||||
|
while (*((u_int16_t*)now_ptr)!=bus_r16(FIFO_DATA_REG)) {
|
||||||
|
printf("%d ,",i);
|
||||||
|
*((u_int16_t*)now_ptr)=bus_r16(FIFO_DATA_REG);
|
||||||
}
|
}
|
||||||
now_ptr+=2;
|
now_ptr+=2;
|
||||||
}
|
}
|
||||||
@ -2213,8 +2156,10 @@ u_int16_t* fifo_read_frame()
|
|||||||
now_ptr=(char*)ram_values;
|
now_ptr=(char*)ram_values;
|
||||||
while(ns<nSamples && fifo_read_event(ns)) {
|
while(ns<nSamples && fifo_read_event(ns)) {
|
||||||
// now_ptr+=dataBytes;
|
// now_ptr+=dataBytes;
|
||||||
|
// printf("%d %x\n",ns,bus_r16(LOOK_AT_ME_REG));
|
||||||
ns++;
|
ns++;
|
||||||
}
|
}
|
||||||
|
// printf("Data in fifo %x\n",bus_r16(LOOK_AT_ME_REG));
|
||||||
#ifdef TIMEDBG
|
#ifdef TIMEDBG
|
||||||
// usleep(10);
|
// usleep(10);
|
||||||
gettimeofday(&tss,NULL);
|
gettimeofday(&tss,NULL);
|
||||||
@ -3216,12 +3161,22 @@ int setDacRegister(int dacnum,int dacvalue) {
|
|||||||
/* printf("Dac register %x wrote %08x\n",(DAC_REG_OFF+dacnum/2)<<11,val); */
|
/* printf("Dac register %x wrote %08x\n",(DAC_REG_OFF+dacnum/2)<<11,val); */
|
||||||
/* bus_w((DAC_REG_OFF+dacnum/2)<<11, val); */
|
/* bus_w((DAC_REG_OFF+dacnum/2)<<11, val); */
|
||||||
|
|
||||||
|
#ifdef CTB4
|
||||||
bus_w(DAC_NUM_REG, dacnum);
|
bus_w(DAC_NUM_REG, dacnum);
|
||||||
bus_w(DAC_VAL_REG, dacvalue);
|
bus_w(DAC_VAL_REG, dacvalue);
|
||||||
bus_w(DAC_NUM_REG, dacnum | (1<<16));
|
bus_w(DAC_NUM_REG, dacnum | (1<<16));
|
||||||
bus_w(DAC_NUM_REG, dacnum);
|
bus_w(DAC_NUM_REG, dacnum);
|
||||||
printf("Wrote dac register value %d address %d\n",bus_r(DAC_VAL_REG),bus_r(DAC_NUM_REG)) ;
|
printf("Wrote dac register value %d address %d\n",bus_r(DAC_VAL_REG),bus_r(DAC_NUM_REG)) ;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CTB4
|
||||||
|
|
||||||
|
if (dacnum<MAXDAC) {
|
||||||
|
printf("dac variable %d set to value %d\n",dacnum, dacvalue) ;
|
||||||
|
dac[dacnum]=dacvalue;
|
||||||
|
} else
|
||||||
|
printf("Bad dac index %d\n", dacnum);
|
||||||
|
#endif
|
||||||
return getDacRegister(dacnum);
|
return getDacRegister(dacnum);
|
||||||
|
|
||||||
|
|
||||||
@ -3229,9 +3184,22 @@ int setDacRegister(int dacnum,int dacvalue) {
|
|||||||
int getDacRegister(int dacnum) {
|
int getDacRegister(int dacnum) {
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CTB4
|
||||||
bus_w(DAC_NUM_REG, dacnum);
|
bus_w(DAC_NUM_REG, dacnum);
|
||||||
printf("READ dac register value %d address %d\n",(int16_t)bus_r(DAC_VAL_OUT_REG),bus_r(DAC_NUM_REG)) ;
|
printf("READ dac register value %d address %d\n",(int16_t)bus_r(DAC_VAL_OUT_REG),bus_r(DAC_NUM_REG)) ;
|
||||||
return (int16_t)bus_r(DAC_VAL_OUT_REG);
|
return (int16_t)bus_r(DAC_VAL_OUT_REG);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CTB4
|
||||||
|
if (dacnum<MAXDAC) {
|
||||||
|
printf("dac variable %d is %d\n",dacnum,dac[dacnum]) ;
|
||||||
|
return dac[dacnum];
|
||||||
|
}else
|
||||||
|
printf("Bad dac index %d\n", dacnum);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
|
||||||
/* #define DAC_VAL_REG 121<<11 */
|
/* #define DAC_VAL_REG 121<<11 */
|
||||||
/* #define DAC_NUM_REG 122<<11 */
|
/* #define DAC_NUM_REG 122<<11 */
|
||||||
/* #define DAC_VAL_OUT_REG 42<<11 */
|
/* #define DAC_VAL_OUT_REG 42<<11 */
|
||||||
@ -3537,6 +3505,7 @@ int powerChip(int arg) {
|
|||||||
|
|
||||||
u_int32_t preg=bus_r(POWER_ON_REG);
|
u_int32_t preg=bus_r(POWER_ON_REG);
|
||||||
if (myDetectorType!=JUNGFRAUCTB) {
|
if (myDetectorType!=JUNGFRAUCTB) {
|
||||||
|
printf("This is not a JCTB!\n");
|
||||||
if (arg>=0) {
|
if (arg>=0) {
|
||||||
if (arg)
|
if (arg)
|
||||||
bus_w(POWER_ON_REG,preg|0xffff0000);
|
bus_w(POWER_ON_REG,preg|0xffff0000);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
Path: slsDetectorsPackage/slsDetectorSoftware/jctbDetectorServer
|
Path: slsDetectorsPackage/slsDetectorSoftware/jctbDetectorServer
|
||||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||||
Repsitory UUID: 9ae128961675230ad322ff2867f1862dbe8566a7
|
Repsitory UUID: 9e5ec6a57bf206fe9384260fc4040867a9bbd71c
|
||||||
Revision: 25
|
Revision: 33
|
||||||
Branch: developer
|
Branch: developer
|
||||||
Last Changed Author: Anna_Bergamaschi
|
Last Changed Author: Erik_Frojdh
|
||||||
Last Changed Rev: 3764
|
Last Changed Rev: 4065
|
||||||
Last Changed Date: 2018-05-07 14:30:14.000000002 +0200 ./Makefile
|
Last Changed Date: 2019-01-30 17:38:35.000000002 +0100 ./firmware_funcs.c
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||||
#define GITREPUUID "9ae128961675230ad322ff2867f1862dbe8566a7"
|
#define GITREPUUID "9e5ec6a57bf206fe9384260fc4040867a9bbd71c"
|
||||||
#define GITAUTH "Anna_Bergamaschi"
|
#define GITAUTH "Erik_Frojdh"
|
||||||
#define GITREV 0x3764
|
#define GITREV 0x4065
|
||||||
#define GITDATE 0x20180507
|
#define GITDATE 0x20190130
|
||||||
#define GITBRANCH "developer"
|
#define GITBRANCH "developer"
|
||||||
|
Binary file not shown.
@ -70,6 +70,8 @@ int N_CHANS=NCHANS;
|
|||||||
int init_detector(int b, int checkType) {
|
int init_detector(int b, int checkType) {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
int ret;
|
||||||
|
int ii;
|
||||||
if (mapCSP0()==FAIL) { printf("Could not map memory\n");
|
if (mapCSP0()==FAIL) { printf("Could not map memory\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -81,8 +83,18 @@ int init_detector(int b, int checkType) {
|
|||||||
for (i=0; i<1000000; i++) {
|
for (i=0; i<1000000; i++) {
|
||||||
bus_w(SET_DELAY_LSB_REG, i*100);
|
bus_w(SET_DELAY_LSB_REG, i*100);
|
||||||
bus_r(FPGA_VERSION_REG);
|
bus_r(FPGA_VERSION_REG);
|
||||||
if (i*100!=bus_r(SET_DELAY_LSB_REG))
|
//usleep(100);
|
||||||
printf("ERROR: wrote 0x%x, read 0x%x\n",i*100,bus_r(SET_DELAY_LSB_REG));
|
ii=0;
|
||||||
|
// usleep(100);
|
||||||
|
//usleep(100);
|
||||||
|
|
||||||
|
// ret=bus_r(SET_DELAY_LSB_REG);
|
||||||
|
ret=bus_r(SET_DELAY_LSB_REG);
|
||||||
|
while (ret!=i*100 && ii<100) {
|
||||||
|
//if (i*100!=ret)
|
||||||
|
printf("ERROR %d: wrote 0x%x, read 0x%x\n",i, i*100,ret);
|
||||||
|
ret=bus_r(SET_DELAY_LSB_REG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("Finished\n");
|
printf("Finished\n");
|
||||||
}else
|
}else
|
||||||
@ -1865,6 +1877,7 @@ int start_acquisition(int file_des) {
|
|||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||||
} else {
|
} else {
|
||||||
|
nframes = 0;
|
||||||
ret=startStateMachine();
|
ret=startStateMachine();
|
||||||
}
|
}
|
||||||
if (ret==FAIL)
|
if (ret==FAIL)
|
||||||
@ -2045,7 +2058,7 @@ int read_frame(int file_des) {
|
|||||||
printf("sending pointer %x of size %d\n",(unsigned int)(dataretval),dataBytes);
|
printf("sending pointer %x of size %d\n",(unsigned int)(dataretval),dataBytes);
|
||||||
#endif
|
#endif
|
||||||
n=sendDataOnly(file_des,dataretval,dataBytes);
|
n=sendDataOnly(file_des,dataretval,dataBytes);
|
||||||
printf("Sent %d bytes\n",n);
|
printf("Frame %d, Sent %d bytes\n", nframes, n);
|
||||||
} else {
|
} else {
|
||||||
if (getFrames()>-1) {
|
if (getFrames()>-1) {
|
||||||
dataret=FAIL;
|
dataret=FAIL;
|
||||||
@ -2110,7 +2123,7 @@ int start_and_read_all(int file_des) {
|
|||||||
return dataret;
|
return dataret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
nframes = 0;
|
||||||
startStateMachine();
|
startStateMachine();
|
||||||
|
|
||||||
/* ret=startStateMachine();
|
/* ret=startStateMachine();
|
||||||
|
@ -2382,7 +2382,7 @@ int* multiSlsDetector::startAndReadAll() {
|
|||||||
while ((retval = getDataFromDetector())) {
|
while ((retval = getDataFromDetector())) {
|
||||||
++i;
|
++i;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << i << std::endl;
|
std::cout << i << " " retval << std::endl;
|
||||||
#endif
|
#endif
|
||||||
dataQueue.push(retval);
|
dataQueue.push(retval);
|
||||||
}
|
}
|
||||||
@ -2460,7 +2460,7 @@ int* multiSlsDetector::getDataFromDetector() {
|
|||||||
int nodatadet = -1;
|
int nodatadet = -1;
|
||||||
int nodatadetectortype = false;
|
int nodatadetectortype = false;
|
||||||
detectorType types = getDetectorsType();
|
detectorType types = getDetectorsType();
|
||||||
if (types == EIGER || types == JUNGFRAU || GOTTHARD || PROPIX) {
|
if (types == EIGER || types == JUNGFRAU || types == GOTTHARD || types == PROPIX) {
|
||||||
nodatadetectortype = true;
|
nodatadetectortype = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3280,6 +3280,7 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[], int imod) {
|
|||||||
if ((n < 0) || (roiLimits == NULL))
|
if ((n < 0) || (roiLimits == NULL))
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
|
// cout << "Setting ROI for " << n << "rois:" << endl;
|
||||||
//ensures min < max
|
//ensures min < max
|
||||||
verifyMinMaxROI(n, roiLimits);
|
verifyMinMaxROI(n, roiLimits);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -3294,7 +3295,7 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[], int imod) {
|
|||||||
xmax = roiLimits[i].xmax;
|
xmax = roiLimits[i].xmax;
|
||||||
ymin = roiLimits[i].ymin;
|
ymin = roiLimits[i].ymin;
|
||||||
ymax = roiLimits[i].ymax;
|
ymax = roiLimits[i].ymax;
|
||||||
|
if (getDetectorsType() != JUNGFRAUCTB) {
|
||||||
//check roi max values
|
//check roi max values
|
||||||
idet = decodeNChannel(xmax, ymax, channelX, channelY);
|
idet = decodeNChannel(xmax, ymax, channelX, channelY);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -3302,6 +3303,7 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[], int imod) {
|
|||||||
cout << "det:" << idet << "\t" << xmax << "\t" << ymax << "\t"
|
cout << "det:" << idet << "\t" << xmax << "\t" << ymax << "\t"
|
||||||
<< channelX << "\t" << channelY << endl;
|
<< channelX << "\t" << channelY << endl;
|
||||||
#endif
|
#endif
|
||||||
|
//std::cout << getDetectorsType() << endl;
|
||||||
if (idet == -1 ) {
|
if (idet == -1 ) {
|
||||||
cout << "invalid roi" << endl;
|
cout << "invalid roi" << endl;
|
||||||
continue;
|
continue;
|
||||||
@ -3367,6 +3369,17 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[], int imod) {
|
|||||||
if ((lastChannelX + offsetX) == xmax)
|
if ((lastChannelX + offsetX) == xmax)
|
||||||
xmin = xmax + 1;
|
xmin = xmax + 1;
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
idet=0;
|
||||||
|
nroi[idet]=n;
|
||||||
|
index = 0;
|
||||||
|
allroi[idet][index].xmin = xmin;
|
||||||
|
allroi[idet][index].xmax = xmax;
|
||||||
|
allroi[idet][index].ymin = ymin;
|
||||||
|
allroi[idet][index].ymax = ymax;
|
||||||
|
// nroi[idet] = nroi[idet] + 1;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -3415,6 +3428,7 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int& n, int imod) {
|
|||||||
//get each detector's roi array
|
//get each detector's roi array
|
||||||
for (unsigned i = 0; i < detectors.size(); ++i) {
|
for (unsigned i = 0; i < detectors.size(); ++i) {
|
||||||
temp = detectors[i]->getROI(index);
|
temp = detectors[i]->getROI(index);
|
||||||
|
// cout << index << endl;
|
||||||
if (detectors[i]->getErrorMask())
|
if (detectors[i]->getErrorMask())
|
||||||
setErrorMask(getErrorMask() | (1 << i));
|
setErrorMask(getErrorMask() | (1 << i));
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||||
#define GITREPUUID "3c774478681813e451df683e2bc8403b37490323"
|
#define GITREPUUID "907d1655d1f6cf2bb8cf6ccd7e91e82f479dd2ca"
|
||||||
#define GITAUTH "Dhanya_Thattil"
|
#define GITAUTH "Dhanya_Thattil"
|
||||||
#define GITREV 0x4084
|
#define GITREV 0x4101
|
||||||
#define GITDATE 0x20190208
|
#define GITDATE 0x20190211
|
||||||
#define GITBRANCH "4.0.1"
|
#define GITBRANCH "developer"
|
||||||
|
@ -145,7 +145,7 @@ double* slsDetector::decodeData(int *datain, int &nn, double *fdata) {
|
|||||||
dataout[ichan]=*((u_int16_t*)ptr);
|
dataout[ichan]=*((u_int16_t*)ptr);
|
||||||
ptr+=2;
|
ptr+=2;
|
||||||
}
|
}
|
||||||
std::cout<< "decoded "<< ichan << " channels" << std::endl;
|
//std::cout<< "decoded "<< ichan << " channels" << std::endl;
|
||||||
} else {
|
} else {
|
||||||
switch (nbits) {
|
switch (nbits) {
|
||||||
case 1:
|
case 1:
|
||||||
@ -1061,14 +1061,18 @@ void slsDetector::disconnectControl() {
|
|||||||
|
|
||||||
|
|
||||||
int slsDetector::connectData() {
|
int slsDetector::connectData() {
|
||||||
|
//cout << "connect" << endl;
|
||||||
if (dataSocket){
|
if (dataSocket){
|
||||||
if (dataSocket->Connect() >= 0)
|
if (dataSocket->Connect() >= 0) {
|
||||||
|
//cout << "ok" << endl;
|
||||||
return OK;
|
return OK;
|
||||||
else{
|
} else{
|
||||||
std::cout << "cannot connect to receiver" << endl;
|
std::cout << "cannot connect to receiver" << endl;
|
||||||
setErrorMask((getErrorMask())|(CANNOT_CONNECT_TO_RECEIVER));
|
setErrorMask((getErrorMask())|(CANNOT_CONNECT_TO_RECEIVER));
|
||||||
|
//cout << "fail" << endl;
|
||||||
return FAIL;}
|
return FAIL;}
|
||||||
}
|
}
|
||||||
|
//cout << "undefined" << endl;
|
||||||
return UNDEFINED;
|
return UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2938,6 +2942,30 @@ int slsDetector::getThresholdEnergy(int imod) {
|
|||||||
updateDetector();
|
updateDetector();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(thisDetector->myDetectorType==JUNGFRAUCTB) {
|
||||||
|
|
||||||
|
|
||||||
|
int en=-1;
|
||||||
|
|
||||||
|
string header=getNetworkParameter(ADDITIONAL_JSON_HEADER);
|
||||||
|
|
||||||
|
|
||||||
|
std::cout<< "Json header: " << header << std::endl;
|
||||||
|
|
||||||
|
//must be in the format '\"label1\":\"value1\",\"label2\":\"value2\"' etc."
|
||||||
|
//
|
||||||
|
size_t pos0;
|
||||||
|
pos0=header.find("\"threshold\"");
|
||||||
|
if (pos0!=std::string::npos) {
|
||||||
|
if (sscanf(header.substr(pos0).c_str(),"\"threshold\":%d", &en))
|
||||||
|
thisDetector->currentThresholdEV=en;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return thisDetector->currentThresholdEV;
|
return thisDetector->currentThresholdEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2981,6 +3009,62 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti
|
|||||||
} else {
|
} else {
|
||||||
thisDetector->currentThresholdEV=e_eV;
|
thisDetector->currentThresholdEV=e_eV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* add threshold to zmq header */
|
||||||
|
|
||||||
|
string header=getNetworkParameter(ADDITIONAL_JSON_HEADER);
|
||||||
|
|
||||||
|
std::cout<< "Old json header: " << header << std::endl;
|
||||||
|
//must be in the format '\"label1\":\"value1\",\"label2\":\"value2\"' etc."
|
||||||
|
//
|
||||||
|
size_t pos0;
|
||||||
|
pos0=header.find(",\"threshold\"");
|
||||||
|
if (pos0==std::string::npos) {
|
||||||
|
pos0=header.find("\"threshold\"");
|
||||||
|
}
|
||||||
|
if (pos0!=std::string::npos) {
|
||||||
|
// remove old roi
|
||||||
|
// std::cout<< header.substr(0,pos) << std::endl;
|
||||||
|
// size_t pos0=header.find_last_of(",",0,pos);
|
||||||
|
// if (pos0==std::string::npos) {
|
||||||
|
// pos0=pos;
|
||||||
|
// } else
|
||||||
|
// std::cout<< header.substr(pos0) << std::endl;
|
||||||
|
size_t pos1=header.find_first_of(",",pos0+1);
|
||||||
|
// std::cout << pos0 << " " << pos1 << std::endl;
|
||||||
|
std::cout<< "Replacing old threshold: " << header.substr(pos0,pos1-pos0) << std::endl;
|
||||||
|
// if (pos1!=std::string::npos)
|
||||||
|
header.erase(pos0,pos1-pos0);
|
||||||
|
// else
|
||||||
|
// header.erase(pos0);
|
||||||
|
}
|
||||||
|
if (header.length()>0) {
|
||||||
|
if (header.at(0)==',')
|
||||||
|
header.erase(0,1);
|
||||||
|
if (header.length()>0)
|
||||||
|
header.append(",");
|
||||||
|
}
|
||||||
|
// std::cout<< "Left: " << header << std::endl;
|
||||||
|
char h[1000];
|
||||||
|
sprintf(h,"\"threshold\":%d",e_eV);
|
||||||
|
// std::cout<< "new ROI: " << h << std::endl;
|
||||||
|
|
||||||
|
header.append(h);
|
||||||
|
std::cout<< "New json header: " << header << std::endl;
|
||||||
|
setReceiverOnline(ONLINE_FLAG);
|
||||||
|
setNetworkParameter(ADDITIONAL_JSON_HEADER, header);
|
||||||
|
/***** END FOR ZMQ HEADER */
|
||||||
|
ret=OK;
|
||||||
|
|
||||||
|
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
|
||||||
|
thisDetector->currentThresholdEV=e_eV;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return thisDetector->currentThresholdEV;
|
return thisDetector->currentThresholdEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3739,8 +3823,8 @@ int* slsDetector::startAndReadAll() {
|
|||||||
//#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
int i=0;
|
int i=0;
|
||||||
#endif
|
|
||||||
//#endif
|
//#endif
|
||||||
|
#endif
|
||||||
if(thisDetector->myDetectorType == EIGER) {
|
if(thisDetector->myDetectorType == EIGER) {
|
||||||
if (prepareAcquisition() == FAIL)
|
if (prepareAcquisition() == FAIL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -3752,13 +3836,13 @@ int* slsDetector::startAndReadAll() {
|
|||||||
while ((retval=getDataFromDetector())){
|
while ((retval=getDataFromDetector())){
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
++i;
|
++i;
|
||||||
std::cout<< i << std::endl;
|
// std::cout<< i << std::endl;
|
||||||
//#else
|
//#else
|
||||||
//std::cout<< "-" << flush;
|
//std::cout<< "-" << flush;
|
||||||
#endif
|
#endif
|
||||||
dataQueue.push(retval);
|
dataQueue.push(retval);
|
||||||
|
|
||||||
//std::cout<< "pushed" << std::endl;
|
// std::cout<< "pushed" << retval << std::endl;
|
||||||
}
|
}
|
||||||
disconnectControl();
|
disconnectControl();
|
||||||
|
|
||||||
@ -3810,10 +3894,13 @@ int* slsDetector::getDataFromDetector(int *retval) {
|
|||||||
|
|
||||||
int nodatadetectortype = false;
|
int nodatadetectortype = false;
|
||||||
detectorType types = getDetectorsType();
|
detectorType types = getDetectorsType();
|
||||||
if(types == EIGER || types == JUNGFRAU || GOTTHARD || PROPIX){
|
// cout << types << endl;
|
||||||
|
|
||||||
|
if(types == EIGER || types == JUNGFRAU || types == GOTTHARD || types == PROPIX){
|
||||||
nodatadetectortype = true;
|
nodatadetectortype = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//cout << "nodata det" << nodatadetectortype << endl;
|
||||||
|
|
||||||
if (!nodatadetectortype && retval==NULL)
|
if (!nodatadetectortype && retval==NULL)
|
||||||
retval=new int[nel];
|
retval=new int[nel];
|
||||||
@ -3845,7 +3932,7 @@ int* slsDetector::getDataFromDetector(int *retval) {
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
} else if (!nodatadetectortype){
|
} else if (!nodatadetectortype){
|
||||||
|
// cout <<"??" << endl;
|
||||||
n=controlSocket->ReceiveDataOnly(retval,thisDetector->dataBytes);
|
n=controlSocket->ReceiveDataOnly(retval,thisDetector->dataBytes);
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -3866,7 +3953,8 @@ int* slsDetector::getDataFromDetector(int *retval) {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// cout << "get data returning " << endl;
|
|
||||||
|
// cout << "get data returning " << retval << endl;
|
||||||
// cout << endl;
|
// cout << endl;
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
@ -4556,10 +4644,10 @@ int slsDetector::getDataBytesInclGapPixels() {
|
|||||||
|
|
||||||
dacs_t slsDetector::setDAC(dacs_t val, dacIndex index, int mV, int imod) {
|
dacs_t slsDetector::setDAC(dacs_t val, dacIndex index, int mV, int imod) {
|
||||||
|
|
||||||
|
|
||||||
dacs_t retval[2];
|
dacs_t retval[2];
|
||||||
retval[0] = -1;
|
retval[0] = -1;
|
||||||
retval[1] = -1;
|
retval[1] = -1;
|
||||||
|
if (index!=ZMQ_emin && index!=ZMQ_emax) {
|
||||||
int fnum=F_SET_DAC;
|
int fnum=F_SET_DAC;
|
||||||
int ret=FAIL;
|
int ret=FAIL;
|
||||||
char mess[MAX_STR_LENGTH]="";
|
char mess[MAX_STR_LENGTH]="";
|
||||||
@ -4620,6 +4708,89 @@ dacs_t slsDetector::setDAC(dacs_t val, dacIndex index, int mV, int imod) {
|
|||||||
}
|
}
|
||||||
if(mV)
|
if(mV)
|
||||||
return retval[1];
|
return retval[1];
|
||||||
|
} else if(thisDetector->myDetectorType==JUNGFRAUCTB) {
|
||||||
|
|
||||||
|
string header=getNetworkParameter(ADDITIONAL_JSON_HEADER);
|
||||||
|
|
||||||
|
std::cout<< "Old json header: " << header << std::endl;
|
||||||
|
|
||||||
|
if (index==ZMQ_emin) {
|
||||||
|
|
||||||
|
size_t pos0, pos1;
|
||||||
|
pos0=header.find(",\"eMin\"");
|
||||||
|
if (pos0==std::string::npos) {
|
||||||
|
pos0=header.find("\"eMin\"");
|
||||||
|
} else pos0++;
|
||||||
|
if (pos0!=std::string::npos) {
|
||||||
|
pos1=header.find_first_of(",",pos0);
|
||||||
|
// std::cout << pos0 << " " << pos1 << std::endl;
|
||||||
|
std::cout<< "Replacing old eMin: " << header.substr(pos0,pos1-pos0) << std::endl;
|
||||||
|
// if (pos1!=std::string::npos)
|
||||||
|
if (val>=0)
|
||||||
|
header.erase(pos0,pos1-pos0);
|
||||||
|
// else
|
||||||
|
// header.erase(pos0);
|
||||||
|
}
|
||||||
|
if (val>=0) {
|
||||||
|
if (header.length()>0) {
|
||||||
|
if (header.at(0)==',')
|
||||||
|
header.erase(0,1);
|
||||||
|
if (header.length()>0)
|
||||||
|
header.append(",");
|
||||||
|
}
|
||||||
|
// std::cout<< "Left: " << header << std::endl;
|
||||||
|
char h[1000];
|
||||||
|
sprintf(h,"\"eMin\":%d",val);
|
||||||
|
// std::cout<< "new ROI: " << h << std::endl;
|
||||||
|
|
||||||
|
header.append(h);
|
||||||
|
} else {
|
||||||
|
sscanf(header.substr(pos0,pos1-pos0).c_str(),"\"eMin\":%d",&val);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (index==ZMQ_emax) {
|
||||||
|
|
||||||
|
|
||||||
|
size_t pos0, pos1;
|
||||||
|
pos0=header.find(",\"eMax\"");
|
||||||
|
if (pos0==std::string::npos) {
|
||||||
|
pos0=header.find("\"eMax\"");
|
||||||
|
} else pos0++;
|
||||||
|
if (pos0!=std::string::npos) {
|
||||||
|
pos1=header.find_first_of(",",pos0);
|
||||||
|
// std::cout << pos0 << " " << pos1 << std::endl;
|
||||||
|
std::cout<< "Replacing old eMax: " << header.substr(pos0,pos1-pos0) << std::endl;
|
||||||
|
// if (pos1!=std::string::npos)
|
||||||
|
if (val>=0)
|
||||||
|
header.erase(pos0,pos1-pos0);
|
||||||
|
// else
|
||||||
|
// header.erase(pos0);
|
||||||
|
}
|
||||||
|
if (val>=0) {
|
||||||
|
if (header.length()>0) {
|
||||||
|
if (header.at(0)==',')
|
||||||
|
header.erase(0,1);
|
||||||
|
if (header.length()>0)
|
||||||
|
header.append(",");
|
||||||
|
}
|
||||||
|
// std::cout<< "Left: " << header << std::endl;
|
||||||
|
char h[1000];
|
||||||
|
sprintf(h,"\"eMax\":%d",val);
|
||||||
|
// std::cout<< "new ROI: " << h << std::endl;
|
||||||
|
|
||||||
|
header.append(h);
|
||||||
|
} else {
|
||||||
|
sscanf(header.substr(pos0,pos1-pos0).c_str(),"\"eMax\":%d",&val);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout<< "New json header: " << header << std::endl;
|
||||||
|
setReceiverOnline(ONLINE_FLAG);
|
||||||
|
setNetworkParameter(ADDITIONAL_JSON_HEADER, header);
|
||||||
|
/***** END FOR ZMQ HEADER */
|
||||||
|
retval[0]=val;
|
||||||
|
}
|
||||||
|
|
||||||
return retval[0];
|
return retval[0];
|
||||||
}
|
}
|
||||||
@ -4792,13 +4963,14 @@ int slsDetector::setReadOutFlags(readOutFlags flag) {
|
|||||||
|
|
||||||
|
|
||||||
int fnum=F_SET_READOUT_FLAGS;
|
int fnum=F_SET_READOUT_FLAGS;
|
||||||
readOutFlags retval;
|
//readOutFlags retval;
|
||||||
|
int retval;
|
||||||
char mess[MAX_STR_LENGTH]="";
|
char mess[MAX_STR_LENGTH]="";
|
||||||
int ret=OK;
|
int ret=OK;
|
||||||
|
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
std::cout<< "Setting readout flags to "<< flag << std::endl;
|
std::cout<< "Setting readout flags to "<< hex << flag << dec << std::endl;
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
if (connectControl() == OK){
|
if (connectControl() == OK){
|
||||||
@ -4811,10 +4983,11 @@ int slsDetector::setReadOutFlags(readOutFlags flag) {
|
|||||||
setErrorMask((getErrorMask())|(COULD_NOT_SET_READOUT_FLAGS));
|
setErrorMask((getErrorMask())|(COULD_NOT_SET_READOUT_FLAGS));
|
||||||
} else {
|
} else {
|
||||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||||
thisDetector->roFlags=retval;
|
thisDetector->roFlags=(readOutFlags)retval;
|
||||||
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
|
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
|
||||||
|
|
||||||
getTotalNumberOfChannels();
|
int nn=getTotalNumberOfChannels();
|
||||||
|
cout << "Total number of channels is " << nn << endl;
|
||||||
//thisDetector->dataBytes=getTotalNumberOfChannels()*
|
//thisDetector->dataBytes=getTotalNumberOfChannels()*
|
||||||
//thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB];
|
//thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB];
|
||||||
}
|
}
|
||||||
@ -4828,6 +5001,150 @@ int slsDetector::setReadOutFlags(readOutFlags flag) {
|
|||||||
thisDetector->roFlags=flag;
|
thisDetector->roFlags=flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// std::cout<< "***ZMQ: " << hex<< flag << std::endl;
|
||||||
|
|
||||||
|
if (flag & (PEDESTAL | NEWPEDESTAL | NEWFLAT | FLAT | FRAME)) {
|
||||||
|
|
||||||
|
std::cout<< "***frameMode: " << std::endl;
|
||||||
|
string header=getNetworkParameter(ADDITIONAL_JSON_HEADER);
|
||||||
|
|
||||||
|
std::cout<< "Old json header: " << header << std::endl;
|
||||||
|
//must be in the format '\"label1\":\"value1\",\"label2\":\"value2\"' etc."
|
||||||
|
//
|
||||||
|
size_t pos0;
|
||||||
|
pos0=header.find(",\"frameMode\"");
|
||||||
|
if (pos0==std::string::npos) {
|
||||||
|
pos0=header.find("\"frameMode\"");
|
||||||
|
}
|
||||||
|
if (pos0!=std::string::npos) {
|
||||||
|
size_t pos1=header.find_first_of(",",pos0+1);
|
||||||
|
// if (pos1!=std::string::npos)
|
||||||
|
if (flag!=GET_READOUT_FLAGS) {
|
||||||
|
cout << dec<< pos0 << " " << pos1 << endl;
|
||||||
|
std::cout<< "Replacing frame Mode: " << header.substr(pos0,pos1-pos0) << std::endl;
|
||||||
|
header.erase(pos0,pos1-pos0);
|
||||||
|
}
|
||||||
|
else if (header.substr(pos0,pos1+pos0)=="\"frameMode\":\"pedestal\"")
|
||||||
|
retval|=PEDESTAL;
|
||||||
|
else if (header.substr(pos0,pos1+pos0)=="\"frameMode\":\"newPedestal\"")
|
||||||
|
retval|=NEWPEDESTAL;
|
||||||
|
else if (header.substr(pos0,pos1+pos0)=="\"frameMode\":\"flatfield\"")
|
||||||
|
retval|=FLAT;
|
||||||
|
else if (header.substr(pos0,pos1+pos0)=="\"frameMode\":\"newFlatfield\"")
|
||||||
|
retval|=NEWFLAT;
|
||||||
|
else
|
||||||
|
retval|=FRAME;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
char h[1000];
|
||||||
|
switch (flag) {
|
||||||
|
case PEDESTAL:
|
||||||
|
retval|=PEDESTAL;
|
||||||
|
strcpy(h,"\"frameMode\":\"pedestal\"");
|
||||||
|
break;
|
||||||
|
case NEWPEDESTAL:
|
||||||
|
retval|=NEWPEDESTAL;
|
||||||
|
strcpy(h,"\"frameMode\":\"newPedestal\"");
|
||||||
|
break;
|
||||||
|
case FLAT:
|
||||||
|
retval|=FLAT;
|
||||||
|
strcpy(h,"\"frameMode\":\"flatfield\"");
|
||||||
|
break;
|
||||||
|
case NEWFLAT:
|
||||||
|
retval|=NEWFLAT;
|
||||||
|
strcpy(h,"\"frameMode\":\"newFlatfield\"");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
retval|=FRAME;
|
||||||
|
strcpy(h,"\"frameMode\":\"frame\"");
|
||||||
|
}
|
||||||
|
if (flag!=GET_READOUT_FLAGS) {
|
||||||
|
if (header.length()>0) {
|
||||||
|
if (header.at(0)==',')
|
||||||
|
header.erase(0,1);
|
||||||
|
if (header.length()>0)
|
||||||
|
header.append(",");
|
||||||
|
}
|
||||||
|
header.append(h);
|
||||||
|
setReceiverOnline(ONLINE_FLAG);
|
||||||
|
setNetworkParameter(ADDITIONAL_JSON_HEADER, header);
|
||||||
|
}
|
||||||
|
std::cout<< "New json header: " << header << std::endl;
|
||||||
|
/***** END FOR ZMQ HEADER */
|
||||||
|
ret=OK;
|
||||||
|
// retval=flag;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag & (COUNTING | INTERPOLATING | ANALOG)) {
|
||||||
|
|
||||||
|
std::cout<< "***detectorMode: " << std::endl;
|
||||||
|
|
||||||
|
string header=getNetworkParameter(ADDITIONAL_JSON_HEADER);
|
||||||
|
|
||||||
|
std::cout<< "Old json header: " << header << std::endl;
|
||||||
|
//must be in the format '\"label1\":\"value1\",\"label2\":\"value2\"' etc."
|
||||||
|
//
|
||||||
|
size_t pos0;
|
||||||
|
pos0=header.find(",\"detectorMode\"");
|
||||||
|
if (pos0==std::string::npos) {
|
||||||
|
pos0=header.find("\"detectorMode\"");
|
||||||
|
}
|
||||||
|
if (pos0!=std::string::npos) {
|
||||||
|
size_t pos1=header.find_first_of(",",pos0+1);
|
||||||
|
// if (pos1!=std::string::npos)
|
||||||
|
if (flag!=GET_READOUT_FLAGS) {
|
||||||
|
cout << dec<< pos0 << " " << pos1 << endl;
|
||||||
|
std::cout<< "Replacing detector Mode: " << header.substr(pos0,pos1-pos0) << std::endl;
|
||||||
|
header.erase(pos0,pos1-pos0);
|
||||||
|
}
|
||||||
|
else if (header.substr(pos0,pos1+pos0)=="\"detectorMode\":\"counting\"")
|
||||||
|
retval|=COUNTING;
|
||||||
|
else if (header.substr(pos0,pos1+pos0)=="\"detectorMode\":\"interpolating\"")
|
||||||
|
retval|=INTERPOLATING;
|
||||||
|
else
|
||||||
|
retval|=ANALOG;
|
||||||
|
}
|
||||||
|
char h[1000];
|
||||||
|
switch (flag) {
|
||||||
|
case COUNTING:
|
||||||
|
strcpy(h,"\"detectorMode\":\"counting\"");
|
||||||
|
retval|=COUNTING;
|
||||||
|
break;
|
||||||
|
case INTERPOLATING:
|
||||||
|
retval|=INTERPOLATING;
|
||||||
|
strcpy(h,"\"detectorMode\":\"interpolating\"");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
retval|=ANALOG;
|
||||||
|
strcpy(h,"\"detectorMode\":\"analog\"");
|
||||||
|
}
|
||||||
|
if (flag!=GET_READOUT_FLAGS) {
|
||||||
|
if (header.length()>0) {
|
||||||
|
if (header.at(0)==',')
|
||||||
|
header.erase(0,1);
|
||||||
|
if (header.length()>0)
|
||||||
|
header.append(",");
|
||||||
|
}
|
||||||
|
header.append(h);
|
||||||
|
setReceiverOnline(ONLINE_FLAG);
|
||||||
|
setNetworkParameter(ADDITIONAL_JSON_HEADER, header);
|
||||||
|
/***** END FOR ZMQ HEADER */
|
||||||
|
// retval=flag;
|
||||||
|
}
|
||||||
|
std::cout<< "New json header: " << header << std::endl;
|
||||||
|
ret=OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (ret==OK) {
|
||||||
|
|
||||||
|
// thisDetector->roFlags=flag;
|
||||||
|
thisDetector->roFlags=(readOutFlags)retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout<< retval << std::endl;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "Readout flag set to "<< retval << std::endl;
|
std::cout<< "Readout flag set to "<< retval << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -5571,10 +5888,12 @@ string slsDetector::setAdditionalJsonHeader(string jsonheader) {
|
|||||||
strcpy(arg, jsonheader.c_str());
|
strcpy(arg, jsonheader.c_str());
|
||||||
|
|
||||||
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
std::cout << "Sending additional json header " << arg << std::endl;
|
// std::cout << "* Sending additional json header " << arg << std::endl;
|
||||||
#endif
|
//#endif
|
||||||
if (connectData() == OK){
|
if (connectData() == OK){
|
||||||
|
|
||||||
|
// std::cout << "** Sending additional json header " << arg << std::endl;
|
||||||
ret=thisReceiver->sendString(fnum,retval,arg);
|
ret=thisReceiver->sendString(fnum,retval,arg);
|
||||||
disconnectData();
|
disconnectData();
|
||||||
}
|
}
|
||||||
@ -6027,6 +6346,70 @@ int slsDetector::setROI(int n,ROI roiLimits[], int imod) {
|
|||||||
//sort ascending order
|
//sort ascending order
|
||||||
int temp;
|
int temp;
|
||||||
|
|
||||||
|
/***** NEW PART FOR ZMQ HEADER */
|
||||||
|
//std::cout<< "******* ROI" << std::endl;
|
||||||
|
|
||||||
|
// char header[1000];
|
||||||
|
string header=getNetworkParameter(ADDITIONAL_JSON_HEADER);
|
||||||
|
|
||||||
|
std::cout<< "Old json header: " << header << std::endl;
|
||||||
|
//must be in the format '\"label1\":\"value1\",\"label2\":\"value2\"' etc."
|
||||||
|
//
|
||||||
|
size_t pos0;
|
||||||
|
pos0=header.find(",\"roi\"");
|
||||||
|
if (pos0==std::string::npos) {
|
||||||
|
pos0=header.find("\"roi\"");
|
||||||
|
}
|
||||||
|
if (pos0!=std::string::npos) {
|
||||||
|
// remove old roi
|
||||||
|
// std::cout<< header.substr(0,pos) << std::endl;
|
||||||
|
// size_t pos0=header.find_last_of(",",0,pos);
|
||||||
|
// if (pos0==std::string::npos) {
|
||||||
|
// pos0=pos;
|
||||||
|
// } else
|
||||||
|
// std::cout<< header.substr(pos0) << std::endl;
|
||||||
|
size_t pos1=header.find_first_of("]",pos0+1);
|
||||||
|
// std::cout << pos0 << " " << pos1 << std::endl;
|
||||||
|
std::cout<< "Replacing old ROI: " << header.substr(pos0,pos1-pos0+1) << std::endl;
|
||||||
|
// if (pos1!=std::string::npos)
|
||||||
|
header.erase(pos0,pos1-pos0+1);
|
||||||
|
// else
|
||||||
|
// header.erase(pos0);
|
||||||
|
}
|
||||||
|
if (header.length()>0) {
|
||||||
|
if (header.at(0)==',')
|
||||||
|
header.erase(0,1);
|
||||||
|
if (header.length()>0)
|
||||||
|
header.append(",");
|
||||||
|
}
|
||||||
|
// std::cout<< "Left: " << header << std::endl;
|
||||||
|
char h[1000];
|
||||||
|
if (n) {
|
||||||
|
sprintf(h,"\"roi\":[%d, %d, %d, %d]",roiLimits[0].xmin, roiLimits[0].xmax, roiLimits[0].ymin, roiLimits[0].ymax);
|
||||||
|
// std::cout<< "new ROI: " << h << std::endl;
|
||||||
|
} else {
|
||||||
|
sprintf(h,"\"roi\":[%d, %d, %d, %d]",-1, -1, -1, -1);
|
||||||
|
}
|
||||||
|
header.append(h);
|
||||||
|
std::cout<< "New json header: " << header << std::endl;
|
||||||
|
setReceiverOnline(ONLINE_FLAG);
|
||||||
|
setNetworkParameter(ADDITIONAL_JSON_HEADER, header);
|
||||||
|
/***** END FOR ZMQ HEADER */
|
||||||
|
ret=OK;
|
||||||
|
|
||||||
|
if(thisDetector->myDetectorType==JUNGFRAUCTB) {
|
||||||
|
|
||||||
|
thisDetector->nROI = n;
|
||||||
|
thisDetector->roiLimits[0].xmin=roiLimits[0].xmin;
|
||||||
|
thisDetector->roiLimits[0].xmax=roiLimits[0].xmax;
|
||||||
|
thisDetector->roiLimits[0].ymin=roiLimits[0].ymin;
|
||||||
|
thisDetector->roiLimits[0].ymax=roiLimits[0].ymax;
|
||||||
|
// std::cout << "** " << thisDetector->nROI << endl;
|
||||||
|
getTotalNumberOfChannels();
|
||||||
|
// std::cout << "*** " << thisDetector->nROI << endl;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
// if(thisDetector->myDetectorType==JUNGFRAUCTB)
|
||||||
for(int i=0;i<n;++i){
|
for(int i=0;i<n;++i){
|
||||||
|
|
||||||
// cout << "*** ROI "<< i << " xmin " << roiLimits[i].xmin << " xmax "
|
// cout << "*** ROI "<< i << " xmin " << roiLimits[i].xmin << " xmax "
|
||||||
@ -6052,6 +6435,9 @@ int slsDetector::setROI(int n,ROI roiLimits[], int imod) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = sendROI(n,roiLimits);
|
ret = sendROI(n,roiLimits);
|
||||||
|
if(ret==FAIL)
|
||||||
|
setErrorMask((getErrorMask())|(COULDNOT_SET_ROI));
|
||||||
|
|
||||||
|
|
||||||
if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels();
|
if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels();
|
||||||
return ret;
|
return ret;
|
||||||
@ -6059,9 +6445,41 @@ int slsDetector::setROI(int n,ROI roiLimits[], int imod) {
|
|||||||
|
|
||||||
|
|
||||||
slsDetectorDefs::ROI* slsDetector::getROI(int &n, int imod) {
|
slsDetectorDefs::ROI* slsDetector::getROI(int &n, int imod) {
|
||||||
|
if(thisDetector->myDetectorType==JUNGFRAUCTB) {
|
||||||
|
|
||||||
|
|
||||||
|
int xmin, xmax, ymin, ymax;
|
||||||
|
|
||||||
|
string header=getNetworkParameter(ADDITIONAL_JSON_HEADER);
|
||||||
|
|
||||||
|
|
||||||
|
std::cout<< "Json header: " << header << std::endl;
|
||||||
|
|
||||||
|
//must be in the format '\"label1\":\"value1\",\"label2\":\"value2\"' etc."
|
||||||
|
//
|
||||||
|
size_t pos0;
|
||||||
|
pos0=header.find("\"roi\"");
|
||||||
|
if (pos0!=std::string::npos) {
|
||||||
|
sscanf(header.substr(pos0).c_str(),"\"roi\":[%d, %d, %d, %d]", &xmin, &xmax, &ymin, &ymax);
|
||||||
|
if (xmin<0 && xmax<0 && ymin<0 && ymax<0)
|
||||||
|
thisDetector->nROI=0;
|
||||||
|
else {
|
||||||
|
thisDetector->nROI=1;
|
||||||
|
thisDetector->roiLimits[0].xmin=xmin;
|
||||||
|
thisDetector->roiLimits[0].xmax=xmax;
|
||||||
|
thisDetector->roiLimits[0].ymin=ymin;
|
||||||
|
thisDetector->roiLimits[0].ymax=ymax;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
thisDetector->nROI=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cout << thisDetector->nROI << endl;
|
||||||
|
getTotalNumberOfChannels();
|
||||||
|
} else {
|
||||||
sendROI(-1,NULL);
|
sendROI(-1,NULL);
|
||||||
n=thisDetector->nROI;
|
n=thisDetector->nROI;
|
||||||
if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels();
|
}
|
||||||
return thisDetector->roiLimits;
|
return thisDetector->roiLimits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +177,7 @@ int slsDetectorActions::setScan(int iscan, string script, int nvalues, double *v
|
|||||||
strcpy(scanParameter[iscan],par.c_str());
|
strcpy(scanParameter[iscan],par.c_str());
|
||||||
|
|
||||||
if (nvalues>=0) {
|
if (nvalues>=0) {
|
||||||
|
// cout << "nvalues " << nvalues << endl;
|
||||||
if (nvalues==0)
|
if (nvalues==0)
|
||||||
scanMode[iscan]=noScan;
|
scanMode[iscan]=noScan;
|
||||||
else {
|
else {
|
||||||
@ -189,6 +190,7 @@ int slsDetectorActions::setScan(int iscan, string script, int nvalues, double *v
|
|||||||
if (values && scanMode[iscan]>0 ) {
|
if (values && scanMode[iscan]>0 ) {
|
||||||
for (int iv=0; iv<nScanSteps[iscan]; iv++) {
|
for (int iv=0; iv<nScanSteps[iscan]; iv++) {
|
||||||
scanSteps[iscan][iv]=values[iv];
|
scanSteps[iscan][iv]=values[iv];
|
||||||
|
// cout << values[iv] << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1011,9 +1011,12 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
|||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdImage;
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdImage;
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
|
/*! \page data
|
||||||
|
- <b>gainimage fn</b> Loads the gain image to the detector from file fn (gain map for translation into number of photons of an analog detector). Cannot get.
|
||||||
|
*/
|
||||||
|
descrToFuncMap[i].m_pFuncName="flatimage"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdImage;
|
||||||
|
++i;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1123,7 +1126,19 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
|||||||
\section settingsdacs DACs
|
\section settingsdacs DACs
|
||||||
commands to configure DACs of detector
|
commands to configure DACs of detector
|
||||||
*/
|
*/
|
||||||
|
/*! \page settings
|
||||||
|
- <b>emin [i] </b> Sets/gets detector minimum energy threshold for the CTB (soft setting)
|
||||||
|
*/
|
||||||
|
descrToFuncMap[i].m_pFuncName="emin"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
|
||||||
|
++i;
|
||||||
|
|
||||||
|
/*! \page settings
|
||||||
|
- <b>emax [i] </b> Sets/gets detector maximum energy threshold for the CTB (soft setting)
|
||||||
|
*/
|
||||||
|
descrToFuncMap[i].m_pFuncName="emax"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
|
||||||
|
++i;
|
||||||
/*! \page settings
|
/*! \page settings
|
||||||
- <b>vthreshold [i] [mv]</b> Sets/gets detector threshold voltage for single photon counters. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
|
- <b>vthreshold [i] [mv]</b> Sets/gets detector threshold voltage for single photon counters. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
|
||||||
*/
|
*/
|
||||||
@ -4098,7 +4113,6 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio
|
|||||||
t=ADDITIONAL_JSON_HEADER;
|
t=ADDITIONAL_JSON_HEADER;
|
||||||
}
|
}
|
||||||
else return ("unknown network parameter")+cmd;
|
else return ("unknown network parameter")+cmd;
|
||||||
|
|
||||||
if (action==PUT_ACTION) {
|
if (action==PUT_ACTION) {
|
||||||
myDet->setNetworkParameter(t, args[1]);
|
myDet->setNetworkParameter(t, args[1]);
|
||||||
// switch it back on, if it had been switched on
|
// switch it back on, if it had been switched on
|
||||||
@ -4475,6 +4489,7 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) {
|
|||||||
if ((val<0) || (narg!=((val*4)+2)) )
|
if ((val<0) || (narg!=((val*4)+2)) )
|
||||||
return helpDetectorSize(narg,args,action);
|
return helpDetectorSize(narg,args,action);
|
||||||
ROI allroi[val];
|
ROI allroi[val];
|
||||||
|
// pos=1;
|
||||||
pos=2;
|
pos=2;
|
||||||
for(i=0;i<val;++i){
|
for(i=0;i<val;++i){
|
||||||
if ((!sscanf(args[pos++],"%d",&allroi[i].xmin)) ||
|
if ((!sscanf(args[pos++],"%d",&allroi[i].xmin)) ||
|
||||||
@ -5248,6 +5263,10 @@ string slsDetectorCommand::cmdDAC(int narg, char *args[], int action) {
|
|||||||
dac=M_vIbiasSh;
|
dac=M_vIbiasSh;
|
||||||
else if (cmd== "vIpreOut")
|
else if (cmd== "vIpreOut")
|
||||||
dac=M_vIpreOut;
|
dac=M_vIpreOut;
|
||||||
|
else if (cmd== "emin")
|
||||||
|
dac=ZMQ_emin;
|
||||||
|
else if (cmd== "emax")
|
||||||
|
dac=ZMQ_emax;
|
||||||
|
|
||||||
else
|
else
|
||||||
return string("cannot decode dac ")+cmd;
|
return string("cannot decode dac ")+cmd;
|
||||||
@ -6006,6 +6025,22 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
|
|||||||
flag=SHOW_OVERFLOW;
|
flag=SHOW_OVERFLOW;
|
||||||
else if (sval=="nooverflow")
|
else if (sval=="nooverflow")
|
||||||
flag=NOOVERFLOW;
|
flag=NOOVERFLOW;
|
||||||
|
else if (sval=="pedestal")
|
||||||
|
flag=PEDESTAL;
|
||||||
|
else if (sval=="flatfield")
|
||||||
|
flag=FLAT;
|
||||||
|
else if (sval=="newpedestal")
|
||||||
|
flag=NEWPEDESTAL;
|
||||||
|
else if (sval=="newflatfield")
|
||||||
|
flag=NEWFLAT;
|
||||||
|
else if (sval=="frame")
|
||||||
|
flag=FRAME;
|
||||||
|
else if (sval=="analog")
|
||||||
|
flag=ANALOG;
|
||||||
|
else if (sval=="counting")
|
||||||
|
flag=COUNTING;
|
||||||
|
else if (sval=="interpolating")
|
||||||
|
flag=INTERPOLATING;
|
||||||
else
|
else
|
||||||
return string("could not scan flag ")+string(args[1]);
|
return string("could not scan flag ")+string(args[1]);
|
||||||
}
|
}
|
||||||
@ -6038,6 +6073,22 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
|
|||||||
strcat(answer,"overflow ");
|
strcat(answer,"overflow ");
|
||||||
if (retval & NOOVERFLOW)
|
if (retval & NOOVERFLOW)
|
||||||
strcat(answer,"nooverflow ");
|
strcat(answer,"nooverflow ");
|
||||||
|
if (retval & PEDESTAL)
|
||||||
|
strcat(answer,"pedestal ");
|
||||||
|
if (retval & NEWPEDESTAL)
|
||||||
|
strcat(answer,"newpedestal ");
|
||||||
|
if (retval & NEWFLAT)
|
||||||
|
strcat(answer,"newflat ");
|
||||||
|
if (retval & FLAT)
|
||||||
|
strcat(answer,"flatfield ");
|
||||||
|
if (retval & FRAME)
|
||||||
|
strcat(answer,"frame ");
|
||||||
|
if (retval & ANALOG)
|
||||||
|
strcat(answer,"analog ");
|
||||||
|
if (retval & COUNTING)
|
||||||
|
strcat(answer,"counting ");
|
||||||
|
if (retval & INTERPOLATING)
|
||||||
|
strcat(answer,"interpolating ");
|
||||||
if(strlen(answer))
|
if(strlen(answer))
|
||||||
return string(answer);
|
return string(answer);
|
||||||
|
|
||||||
@ -6994,7 +7045,6 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
|||||||
if (myDet->isMultiSlsDetectorClass() && aa != NULL)
|
if (myDet->isMultiSlsDetectorClass() && aa != NULL)
|
||||||
delete [] aa;
|
delete [] aa;
|
||||||
|
|
||||||
|
|
||||||
//os <<" "<< hex << myDet->readRegister(120) << dec;
|
//os <<" "<< hex << myDet->readRegister(120) << dec;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ class slsDetectorUsers
|
|||||||
int getPositions(double *pos=NULL);
|
int getPositions(double *pos=NULL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@short sets the detector size (only 1 ROI)
|
@short sets the detector size (only 1 ROI) (not Mythen supported anymore)
|
||||||
\param x0 horizontal position origin in channel number (-1 unchanged)
|
\param x0 horizontal position origin in channel number (-1 unchanged)
|
||||||
\param y0 vertical position origin in channel number (-1 unchanged)
|
\param y0 vertical position origin in channel number (-1 unchanged)
|
||||||
\param nx number of channels in horiziontal (-1 unchanged)
|
\param nx number of channels in horiziontal (-1 unchanged)
|
||||||
@ -259,7 +259,7 @@ class slsDetectorUsers
|
|||||||
int setDetectorSize(int x0=-1, int y0=-1, int nx=-1, int ny=-1);
|
int setDetectorSize(int x0=-1, int y0=-1, int nx=-1, int ny=-1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@short gets detector size (roi size if only one roi)
|
@short gets detector size (roi size if only one roi) (not Mythen supported anymore)
|
||||||
\param x0 horizontal position origin in channel number
|
\param x0 horizontal position origin in channel number
|
||||||
\param y0 vertical position origin in channel number
|
\param y0 vertical position origin in channel number
|
||||||
\param nx number of channels in horiziontal
|
\param nx number of channels in horiziontal
|
||||||
|
@ -125,7 +125,7 @@ int fileIO::writeDataFile(void *data, int iframe) {
|
|||||||
|
|
||||||
|
|
||||||
int fileIO::closeDataFile() {
|
int fileIO::closeDataFile() {
|
||||||
cout << "close file...." << endl;
|
// cout << "close file...." << endl;
|
||||||
if (filefd)
|
if (filefd)
|
||||||
fclose(filefd);
|
fclose(filefd);
|
||||||
filefd=NULL;
|
filefd=NULL;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
Path: slsDetectorsPackage/slsReceiverSoftware
|
Path: slsDetectorsPackage/slsReceiverSoftware
|
||||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||||
Repsitory UUID: 3c774478681813e451df683e2bc8403b37490323
|
Repsitory UUID: 907d1655d1f6cf2bb8cf6ccd7e91e82f479dd2ca
|
||||||
Revision: 858
|
Revision: 859
|
||||||
Branch: 4.0.1
|
Branch: developer
|
||||||
Last Changed Author: Dhanya_Thattil
|
Last Changed Author: Dhanya_Thattil
|
||||||
Last Changed Rev: 4084
|
Last Changed Rev: 4101
|
||||||
Last Changed Date: 2019-02-08 16:44:46.000000002 +0100 ./src/Listener.cpp
|
Last Changed Date: 2019-02-11 14:04:47.000000002 +0100 ./src/slsReceiverTCPIPInterface.cpp
|
||||||
|
@ -666,7 +666,9 @@ public:
|
|||||||
if (tcpfd<0) return -1;
|
if (tcpfd<0) return -1;
|
||||||
while(length>0){
|
while(length>0){
|
||||||
nsending = (length>packet_size) ? packet_size:length;
|
nsending = (length>packet_size) ? packet_size:length;
|
||||||
|
// std::cout << "*"<<nsending << std::endl;
|
||||||
nsent = read(tcpfd,(char*)buf+total_sent,nsending);
|
nsent = read(tcpfd,(char*)buf+total_sent,nsending);
|
||||||
|
// std::cout << "+"<<nsent << std::endl;
|
||||||
if(!nsent) {
|
if(!nsent) {
|
||||||
if(!total_sent) {
|
if(!total_sent) {
|
||||||
return -1; //to handle it
|
return -1; //to handle it
|
||||||
@ -675,6 +677,7 @@ public:
|
|||||||
}
|
}
|
||||||
length-=nsent;
|
length-=nsent;
|
||||||
total_sent+=nsent;
|
total_sent+=nsent;
|
||||||
|
// std::cout << "+"<< length << " " << total_sent << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (total_sent>0)
|
if (total_sent>0)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||||
#define GITREPUUID "3c774478681813e451df683e2bc8403b37490323"
|
#define GITREPUUID "907d1655d1f6cf2bb8cf6ccd7e91e82f479dd2ca"
|
||||||
#define GITAUTH "Dhanya_Thattil"
|
#define GITAUTH "Dhanya_Thattil"
|
||||||
#define GITREV 0x4084
|
#define GITREV 0x4101
|
||||||
#define GITDATE 0x20190208
|
#define GITDATE 0x20190211
|
||||||
#define GITBRANCH "4.0.1"
|
#define GITBRANCH "developer"
|
||||||
|
@ -568,14 +568,20 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
|||||||
lastCaughtFrameIndex = fnum;
|
lastCaughtFrameIndex = fnum;
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
//if (!index)
|
//if (!index)
|
||||||
cprintf(GREEN,"Listening %d: currentfindex:%lu, fnum:%lu, pnum:%u numpackets:%u\n",
|
cprintf(GREEN,"Listening %d: currentfindex:%lu, fnum:%lu, pnum:%u numpackets:%u\n",
|
||||||
index,currentFrameIndex, fnum, pnum, numpackets);
|
index,currentFrameIndex, fnum, pnum, numpackets);
|
||||||
#endif
|
//#endif
|
||||||
if (!measurementStartedFlag)
|
if (!measurementStartedFlag)
|
||||||
RecordFirstIndices(fnum);
|
RecordFirstIndices(fnum);
|
||||||
|
|
||||||
|
if (pnum >= pperFrame ) {
|
||||||
|
cprintf(RED,"bad packet, throwing away. packets caught so far: %d\n", numpackets);
|
||||||
|
|
||||||
|
return 0; // bad packet
|
||||||
|
}
|
||||||
|
|
||||||
//future packet by looking at image number (all other detectors)
|
//future packet by looking at image number (all other detectors)
|
||||||
if (fnum != currentFrameIndex) {
|
if (fnum != currentFrameIndex) {
|
||||||
//cprintf(RED,"setting carry over flag to true num:%llu nump:%u\n",fnum, numpackets );
|
//cprintf(RED,"setting carry over flag to true num:%llu nump:%u\n",fnum, numpackets );
|
||||||
@ -611,6 +617,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
|||||||
memcpy(buf + fifohsize + (pnum * dsize) - 2, listeningPacket + hsize, dsize+2);
|
memcpy(buf + fifohsize + (pnum * dsize) - 2, listeningPacket + hsize, dsize+2);
|
||||||
break;
|
break;
|
||||||
case JUNGFRAUCTB:
|
case JUNGFRAUCTB:
|
||||||
|
|
||||||
if (pnum == (pperFrame-1))
|
if (pnum == (pperFrame-1))
|
||||||
memcpy(buf + fifohsize + (pnum * dsize), listeningPacket + hsize, corrected_dsize);
|
memcpy(buf + fifohsize + (pnum * dsize), listeningPacket + hsize, corrected_dsize);
|
||||||
else
|
else
|
||||||
|
@ -158,6 +158,7 @@ void slsReceiverTCPIPInterface::startTCPServer(){
|
|||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
FILE_LOG(logDEBUG5) << "Conenction accepted";
|
FILE_LOG(logDEBUG5) << "Conenction accepted";
|
||||||
#endif
|
#endif
|
||||||
|
// std::cout << "connected" << std::endl;
|
||||||
v = decode_function();
|
v = decode_function();
|
||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
FILE_LOG(logDEBUG5) << "function executed";
|
FILE_LOG(logDEBUG5) << "function executed";
|
||||||
@ -2580,11 +2581,12 @@ int slsReceiverTCPIPInterface::set_additional_json_header() {
|
|||||||
char arg[MAX_STR_LENGTH];
|
char arg[MAX_STR_LENGTH];
|
||||||
memset(arg, 0, sizeof(arg));
|
memset(arg, 0, sizeof(arg));
|
||||||
char* retval=NULL;
|
char* retval=NULL;
|
||||||
|
// std::cout << "set additional json header" << std::endl;
|
||||||
// receive arguments
|
// receive arguments
|
||||||
if (mySock->ReceiveDataOnly(arg,MAX_STR_LENGTH) < 0 )
|
if (mySock->ReceiveDataOnly(arg,MAX_STR_LENGTH) < 0 )
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
|
|
||||||
|
// std::cout << arg << endl;
|
||||||
// execute action
|
// execute action
|
||||||
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
||||||
if (receiverBase == NULL)
|
if (receiverBase == NULL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user