Compare commits

..

86 Commits

Author SHA1 Message Date
6126780660 Merge branch 'main-rc' into b3.0.1 2020-11-30 16:45:00 +01:00
9b7f9b1be1 Merge branch 'main-rc' into b3.0.0 2020-11-30 16:42:35 +01:00
26c829d766 Merge branch 'main-rc' into b2.3.4 2020-11-30 16:38:04 +01:00
3fde5c5b55 Merge branch 'main-rc' into b2.3.3 2020-11-30 16:36:24 +01:00
3e5f546ebe Merge branch 'main-rc' into b2.3.2 2020-11-30 16:26:44 +01:00
9833a7d330 Merge branch 'main-rc' into b2.3.1 2020-11-30 16:25:23 +01:00
8f9155e578 Merge branch 'main-rc' into b2.3.0 2020-11-30 16:23:50 +01:00
9df1eac3c1 Merge branch 'main-rc' into b2.2.0 2020-11-30 15:46:45 +01:00
5ededf9be4 Merge branch 'main-rc' into b2.1.1 2020-11-30 15:16:57 +01:00
3e8774798a Merge branch 'main-rc' into b2.1.0 2020-11-30 15:13:43 +01:00
834794ad98 gotthard renamed binaries 2017-12-19 18:04:44 +01:00
56c504abbb Merge remote branch 'slsDetectorCalibration/2.3.4' into 2.3.4 2017-12-12 11:14:19 +01:00
4d6346e678 Merge remote branch 'slsDetectorCalibration/2.3.3' into 2.3.3 2017-12-12 11:14:15 +01:00
dc7e448759 Merge remote branch 'slsDetectorCalibration/2.3.2' into 2.3.2 2017-12-12 11:14:12 +01:00
e658cbacda Merge remote branch 'slsDetectorCalibration/2.3.1' into 2.3.1 2017-12-12 11:14:08 +01:00
1e6c6dea71 Merge remote branch 'slsDetectorCalibration/2.3' into 2.3 2017-12-12 11:14:05 +01:00
0e5d4d1d8e Merge remote branch 'slsDetectorCalibration/2.2' into 2.2 2017-12-12 11:14:01 +01:00
a2986784d3 Merge remote branch 'slsDetectorCalibration/2.1.1' into 2.1.1 2017-12-12 11:13:34 +01:00
975cbb576e Merge remote branch 'slsDetectorCalibration/2.1' into 2.1 2017-12-12 11:06:15 +01:00
e48a92d9cd Merge remote branch 'slsDetectorCalibration/2.0.5' into 2.0.5 2017-12-12 11:02:57 +01:00
befdcf7f36 Merge remote branch 'slsDetectorGui/2.3.4' into 2.3.4 2017-12-04 16:48:01 +01:00
02f5c472a8 Merge remote branch 'slsReceiverSoftware/2.3.4' into 2.3.4 2017-12-04 16:48:00 +01:00
75ed2cd2e4 Merge remote branch 'slsDetectorSoftware/2.3.4' into 2.3.4 2017-12-04 16:47:59 +01:00
3be045f9b6 Merge remote branch 'slsDetectorGui/2.3.3' into 2.3.3 2017-12-04 16:47:54 +01:00
8fae982802 Merge remote branch 'slsReceiverSoftware/2.3.3' into 2.3.3 2017-12-04 16:47:54 +01:00
128ec88b5f Merge remote branch 'slsDetectorSoftware/2.3.3' into 2.3.3 2017-12-04 16:47:52 +01:00
d5fc158330 Merge remote branch 'slsDetectorGui/2.3.2' into 2.3.2 2017-12-04 16:47:47 +01:00
864e6e4c81 Merge remote branch 'slsReceiverSoftware/2.3.2' into 2.3.2 2017-12-04 16:47:47 +01:00
343d96ff16 Merge remote branch 'slsDetectorSoftware/2.3.2' into 2.3.2 2017-12-04 16:47:46 +01:00
4142328437 Merge remote branch 'slsDetectorGui/2.3.1' into 2.3.1 2017-12-04 16:47:41 +01:00
6c797988c7 Merge remote branch 'slsReceiverSoftware/2.3.1' into 2.3.1 2017-12-04 16:47:41 +01:00
215c262981 Merge remote branch 'slsDetectorSoftware/2.3.1' into 2.3.1 2017-12-04 16:47:39 +01:00
081b809078 Merge remote branch 'slsDetectorGui/2.3' into 2.3 2017-12-04 16:47:35 +01:00
9263567cd8 Merge remote branch 'slsReceiverSoftware/2.3' into 2.3 2017-12-04 16:47:34 +01:00
58e90a85be Merge remote branch 'slsDetectorSoftware/2.3' into 2.3 2017-12-04 16:47:33 +01:00
025c836e25 Merge remote branch 'slsDetectorGui/2.2' into 2.2 2017-12-04 16:47:28 +01:00
5d5abae3f4 Merge remote branch 'slsReceiverSoftware/2.2' into 2.2 2017-12-04 16:47:28 +01:00
e2ad46386e Merge remote branch 'slsDetectorSoftware/2.2' into 2.2 2017-12-04 16:47:26 +01:00
308d44e452 Merge remote branch 'slsDetectorGui/2.1.1' into 2.1.1 2017-12-04 16:47:22 +01:00
69da61b1fb Merge remote branch 'slsReceiverSoftware/2.1.1' into 2.1.1 2017-12-04 16:47:22 +01:00
460168ce04 Merge remote branch 'slsDetectorSoftware/2.1.1' into 2.1.1 2017-12-04 16:47:21 +01:00
4e429c0d77 Merge remote branch 'slsDetectorGui/2.1' into 2.1 2017-12-04 16:45:34 +01:00
bf4fab549d Merge remote branch 'slsReceiverSoftware/2.1' into 2.1 2017-12-04 16:45:34 +01:00
f7705eb1da Merge remote branch 'slsDetectorSoftware/2.1' into 2.1 2017-12-04 16:45:32 +01:00
a2217e2066 Merge remote branch 'slsReceiverSoftware/2.0.5' into 2.0.5 2017-12-04 15:33:33 +01:00
aaa02706fc Merge remote branch 'slsDetectorSoftware/2.0.5' into 2.0.5 2017-12-04 15:31:52 +01:00
6a80bc5b54 new feature, set threshold without uploading trimbits 2017-06-27 13:00:38 +02:00
b9275646ad crazy amount of changes, both necessary and unnecessary;need to narrow down the real change later 2017-04-27 14:05:04 +02:00
9e2f2697c7 crazy amount of changes, both necessary and unnecessary;need to narrow down the real change later 2017-04-27 13:58:25 +02:00
b6b0df62b6 updaterev 2017-04-20 08:26:29 +02:00
0ba537e479 removed headersize compile error 2017-04-20 08:26:16 +02:00
75ddf535dc updaterev 2017-04-19 17:59:53 +02:00
b1de501bef updaterev 2017-04-19 17:59:46 +02:00
0f3a63f101 changed zmq default port starting at 40001 to be able to view in wireshark and removed headersize for warning 2017-04-19 17:42:38 +02:00
3b4b2d707f changes without ostringstream done 2017-04-19 10:17:39 +02:00
f405aa1733 split zmq_msg_t so its not reused 2017-04-19 10:17:30 +02:00
df0fdb7ecb changes without ostringstream done 2017-04-19 10:16:45 +02:00
91b7a87557 just started changin frm ostringstream 2017-04-18 15:32:01 +02:00
9468b9ca1e updaterev 2017-04-11 13:39:59 +02:00
d7982e178e updaterev 2017-04-11 13:39:53 +02:00
9cf5714a5b removing warnings shown from esrf debian 2017-04-11 13:39:35 +02:00
0c9ac8911a removing warnings shown from esrf debian 2017-04-11 13:39:28 +02:00
4730c8c0a9 updaterev 2017-04-11 13:31:49 +02:00
43efb8acfd removing warnings shown from esrf debian 2017-04-11 13:31:32 +02:00
6ecca8fcb0 updaterev 2017-04-11 09:03:26 +02:00
17cb63a57f updaterev 2017-04-11 09:03:19 +02:00
4f83fcb001 updaterev 2017-04-11 09:02:10 +02:00
ab94af6d29 removed verbose etc 2017-04-07 15:08:40 +02:00
7c725cc69b .c_str() must not access global variables from thread 2017-04-07 14:57:19 +02:00
f0198d2d2e alejandro's changes from ESRF 2017-04-07 14:50:17 +02:00
5ddccbdee4 changed all -lpthread to -pthread 2017-04-07 14:28:00 +02:00
8fb39b8c7e changed all -lpthread to -pthread 2017-04-07 14:27:27 +02:00
bd5293f4b1 changed all -lpthread to -pthread 2017-04-07 14:26:09 +02:00
b91180f5b2 changed all -lpthread to -pthread 2017-04-07 14:26:03 +02:00
7c3b5065a5 changed all -lpthread to -pthread 2017-04-07 14:25:09 +02:00
9aef802bea changed all -lpthread to -pthread 2017-04-07 14:24:49 +02:00
f7d85231f2 solved warnings except sscanf for uint64_t 2017-04-07 14:12:21 +02:00
5b3a911e8d solved warnings except sscanf for uint64_t 2017-04-07 14:11:34 +02:00
65f5e1c1ab strtok is not thread safe..used to set receiver udp ip etc to detector, fixed 2017-04-06 15:04:33 +02:00
839896c7e6 fixed the print file packet loss progress bug 2016-10-19 15:53:26 +02:00
4a7e246604 removed asking only 1 for framescaugh 2016-10-19 10:21:29 +02:00
7f293115c4 moved f_activate to receiver funcs from detectors funcs 2016-10-10 08:43:18 +02:00
f59f40a659 ask only 1 for frames caught for 9m 2016-10-10 08:41:03 +02:00
64fd82f92c fixed bug in gui that overwrites the individual sls file path values with the multi value, included a febl and febr temp read 2016-10-10 08:39:46 +02:00
cd232fd732 fixed bug in gui that overwrites the individual sls file path values with the multi value 2016-10-10 08:17:34 +02:00
172fa66b1f hotfix for memory leak in server 2016-08-18 11:57:36 +02:00
299 changed files with 14321 additions and 16928 deletions

View File

@ -1,13 +1,10 @@
### Documentation
Detailed documentation can be found on the [official site.](https://www.psi.ch/detectors/users-support)
### Binaries
Documentation to obtain the binaries via the conda package is available [here.](https://github.com/slsdetectorgroup/sls_detector_software)
### Source code
One can also obtain the source code from this repository and compile while realizing the setup dependencies as required.
```
git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git
git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git --branch 3.0.1
```
#### Setup dependencies
@ -44,9 +41,6 @@ Usage: [-c] [-b] [-h] [-d HDF5 directory] [-j]<br>
* -g: Build/Rebuilds only gui<br>
* -j: Number of threads to compile through<br>
Basic Option:
./cmk.sh -b
For only make:
./cmk.sh

View File

@ -1,31 +1,37 @@
SLS Detector Package 3.1.1 released on 2018-03-12
SLS Detector Package 3.0.1 released on 2018-02-12
=================================================
INTRODUCTION
This document describes the differences between 3.1.0 and 3.1.0 releases.
This document describes the differences between 3.0.0 and 3.0.1 release.
The conda package of the binaries can be downloaded from
https://github.com/slsdetectorgroup/sls_detector_software.git
https://github.com/erikfrojdh/sls_detector_software.git
The Python interface to the software package (including the package) is at
The conda package of the python API wrap-around to the software package is at
https://github.com/slsdetectorgroup/sls_detector.git
Manual (both HTML and pdf versions) are provided in
manual/docs/
Documentation from Source Code can be found for the Command Line and for the API in
Documentation from Source Code can be found for the Command Line and C++ API in
html:
manual/docs/html/slsDetectorClientDocs/index.html
manual/docs/html/slsDetectorUsersDocs/index.html
pdf:
manual/docs/pdf/slsDetectorClientDocs.pdf
manual/docs/pdf/slsDetectorUsersDocs.pdf
Documentation to the python API is available at
https://slsdetectorgroup.github.io/sls_detector/
Example including binaries for detector and receiver user classes can be found in
manual/manual-api
@ -57,53 +63,284 @@ CONTENTS
Firmware Requirements
=====================
Please refer to the link below for more details on the firmware versions.
https://www.psi.ch/detectors/firmware.
Please refer to the link below for more details on the firmware versions.
https://www.psi.ch/detectors/firmware.
Gotthard
========
Minimum compatible version : 11.01.2013
Latest version : 08.02.2018 (50um and 25um Master)
09.02.2018 (25 um Slave)
Gotthard
========
Minimum compatible version : old one
Latest version : 08.02.2018 (50um and 25um Master)
09.02.2018 (25 um Slave)
-Can not be upgraded remotely.
Eiger
=====
Minimum compatible version : 16
Latest version : 20
Eiger
=====
Minimum compatible version : 16
Latest version : 21
-Can be upgraded remotely via bit files.
-Can be upgraded remotely via bit files.
Jungfrau
========
Minimum compatible version : 13.11.2017
Latest version : 13.11.2017
Jungfrau
========
Minimum compatible version : 13.11.2017
Latest version : 13.11.2017
-Can be upgraded remotely via sls_detector_put programfpga <pof>.
-Can be upgraded remotely via sls_detector_put programfpga <pof>.
Changes in User Interface
=========================
Client
------
1. Additional functions added for advanced users in users class:
(setSpeed, setClockDivider, setReadOutFlags, setDac, getADC,
setAllTrimbits, startReceiver, stopReceiver,
startAcquisition non blocking, setReceiverSilentMode, setHighVoltage,
enableDataStreamingToClient, enableDataStreamingFromReceiver,
setReceiverDataStreamingOutPort, setClientDataStreamingInPort)
2. Zmq set up for client and receiver are separated.
zmqport for client and rx_zmqport for receiver. By default, they are the
same for the slsDetectorGui to work.
3. Users example also works without config file, where detector already
configured in shared memory.
4. Use "sls_detector_get busy 0" to clear acquiring flag in shared memory
caused due to an earlier interrupted acquisition from Ctrl+C"
5. Set bit, clear bit, read register and write register cannot give -1 for
inconsistent values from multiple detectors. One has to check error from
API or read the values individually.
6. multiSlsDetector::char* getSettingsFile() function signature has been
changed to string getSettingsFile().
Receiver
--------
7. Modified the help manaual/main-api/mainReceiver.cpp to make it more
robust (handling child process exit) and flexible to determine upon
start up the number of receivers (child processes), the start TCP port
and whether to call back data.
detReceiver is now executed with [start tcp port] [number of receivers]
[1 for call back, 0 for none] as arguments.
By default, start tcp port is 1954, number of receivers is 1, and call
back is initiated.
8. rx_datastream to enable/disable data streaming in receiver. Using the GUI
or registering data call back in client automatically enables zmq in
receiver and client. "externalgui" is removed from the command line. Use
this command instead.
9. Rx_tcpport argument to the slsReceiver can be given using -t.
Eg. slsReceiver -t1955
New Features
============
Package
-------
1. In addition to the C++ API, the Python API is also now provided.
2. CMAKE now with debug flag and rpath, show warnings, compile only certain
components (such as receiver or gui)
3. One repository for entire package and made available at github.
4. One can do --version or -v to all the binaries to find out the release
version of the particular executable.
5. All the software version numbers have only date in format YYMMDD.
Client
------
6. Parallelized more commands to detector. Beneficial for large detectors.
(setTimer, setFileIndex, setOnline, setReceiverOnline, getReceiverStatus,
resetFramesCaught, setFrameIndex, setFileName, getFramesCaughtByReceiver,
setDynamicRange, setRateCorrection)
Option to also use "sls_detector_put threaded 0" to improve speed by
eliminating progress display during acquisition. Effective only for
large detectors.
Detector Server
---------------
7. (Eiger) Virtual class to execute on pc.
8. One can now read temperatures during acquisition. It goes via the stop
server.
9. (Jungfrau) One can start server in "debug" mode and then program the
new firmware via software command "sls_detector_put programfpga xx.pof".
10. (Jungfrau) Server can exit on start up if either the firmware or the
server is incompatible with each other.
11. (Jungfrau) One is able to set transmission delay (ms) of image for each
individual detector using "txndelay_frame" command. Beneficial for
large detectors.
12. (Jungfrau) One can set a threshold temperature (temp_threshold) and
enable the temperature control feature (temp_control). When the
temperature (temp_fpga) overshoots the threshold temperature, it will
set the temperature event (temp_event) and power off the chip. One must
then switch off the detector and check cooling. Switching back on starts
with defaults.
13. (25um Gotthard) Added start acquisition delay to master module.
14. (Gotthard) New constraints include minimum exposure time is 186 ns and
minimum period is 1278 ns + current exposure time.
Receiver
--------
14. The detectorip and rx_udpip does not have to be in the same subnet anymore.
Add the following commands after rx_hostname in config file to overwrite
mac configuration:
rx_udpmac [router mac]
configuremac 0
15. Added silent mode to receiver using command r_silent [i] from client.
It might be beneficial for max frame rate applications.
16. Receiver print out can handle black or white backgrounds.
17. zmq package included updated to v4.0.8.
18. Zmq streaming from receiver also sends file index in json header.
Gui
---
18. If acquisition is done, but "stop dummy packet" to the gui was lost in
the network, stop acquisition command will restream it so that the gui
doesnt hang forever. This is used only for very fast detectors like
Moench.
Resolved Issues
===============
Client
------
1. gethostbyname used in connecting to sockets was not thread safe for
multiple detectors. Using getaddrinfo for stability in multi threaded
environment.
2. Updated writing content of config and parameter dump into files.
3. More locking to handle main and processing threads using the threadpool.
Removing unlock twice, which is undefined behavior.
Detector Server
---------------
4. (Eiger) The hardware MAC of the detector is used during configuration
and relayed back to client. Similarly, hardware IP for 1 Gbe data mode.
5. (Eiger) Status will return error if there was the unlikely trouble
reading status register in the front end board. Earlier, it would only
return idle.
6. (Jungfrau) patch server v3.0.0.6.3
Able to set settings, high voltage now correctly reads 0 when
switched off, dacs are properly set.
7. (Jungfrau) FPGA reset and programming FPGA firmware via software is done
properly
8. (Gotthard) patch server v3.0.0.5.1
Able to read temperature properly.
9. (Gotthard) butst mode if set too fast had unwanted behavior such as
sending same image continuously. Now it is handled to display error
and stop acquisition.
10. (Gotthard) completely removed the possibility to set timing modes
other than auto and trigger as they are not implemented anyway. Also
signal index 1, 2 and 3 are reserved and hence, cannot be configured for
an external trigger.
11. Non Mythen and non Eiger detectors can also now get settings file from
board.
12. (Gotthard) Did not get first few images initially after configuring MAC
of detector. Fixed.
Receiver
--------
12. Made it easier to disable the standard receiver and fixing bugs related
to the use of a custom one.
13. (Jungfrau) HDF5 dimensions (npixelsY) required for mapping fixed.
14. patch2-v3.0.0-slsReceiverSoftware.patch
x, y and z coordinates in the call backs and the files are hardcoded
for this release.
15. Rest implementation (not used by standard receiver) removed.
Gui
---
16. patch1-v3.0.0-slsDetectorGui.patch
(Eiger) In expert mode and in advanced tab, when trimbits
loaded are different for every pixel, the gui complains and sets
all trimbits to zero. This has been resolved. Now, the "Set All
Trimbits" field is just set to -1.
17. Fixed segmentation fault of xputsn properly.
18. Upon clicking on "Start", clears acquiring flag in shared memory
caused due to an earlier interrupted acquisition from Ctrl+C"
19. Fixed plotting twice caused due to unzooming the first time.
20. Removed option for compression in Gui as it is not available currently.
21. Can also show Jungfrau multi detector in x direction in gui.
22. Switching tabs sometimes results in delay and gates fields being incorrectly
enabled. Fixed.
Known Issues
============
Client
------
1. File name prefix can only be done at multi deector level. Changing at
individual detector level will not include scan or position variables.
Detector Server
---------------
2. Standard header fills x-coord in 1D. y-coord and z-coord is not
implemented (3D).
Receiver
--------
3. HDF5 compression and filters are not implemented yet.

View File

@ -0,0 +1,13 @@
No implementation found for style `graphicx'
No implementation found for style `eucal'
No implementation found for style `amsxtra'
No implementation found for style `upref'
No implementation found for style `layout'
No implementation found for style `calc'
No implementation found for style `framed'
? brace missing for \
Substitution of arg to newlabelxx delayed.
? brace missing for \textit

View File

@ -0,0 +1,101 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 2008 (1.71)
original version by: Nikos Drakos, CBLU, University of Leeds
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>Footnotes</TITLE>
<META NAME="description" CONTENT="Footnotes">
<META NAME="keywords" CONTENT="slsDetectors-FAQ">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="LaTeX2HTML v2008">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="STYLESHEET" HREF="slsDetectors-FAQ.css">
</HEAD>
<BODY >
<DL>
<DT><A NAME="foot1316">... tab&nbsp;</A><A
HREF="MYTHEN.html#tex2html20"><SUP>3.1</SUP></A></DT>
<DD>The default name of the calibrated trimfiles is <I>trimbits/beamline/</I><I>settings</I><I>/noise.snxxx</I> where <I>settings</I> is the chosen settings. You can change it in <I>src/qDetector.h</I> and then recompile the acquisition program as described in&nbsp;<A HREF="#sec:installation"><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
SRC="file:/usr/share/latex2html/icons/crossref.png"></A>.
<PRE>.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
</PRE>
</DD>
<DT><A NAME="foot1317">....snxxx&nbsp;</A><A
HREF="MYTHEN.html#tex2html21"><SUP>3.2</SUP></A></DT>
<DD>The default name of the calibration file <I>calibration/</I><I>settings</I><I>.snxxx</I> where <I>settings</I> is the chosen settings. You can change it in <I>src/qDetector.h</I> and then recompile the acquisition program.
<PRE>.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
</PRE>
</DD>
</DL>
</BODY>
</HTML>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 682 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -0,0 +1,41 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 2008 (1.71)
original version by: Nikos Drakos, CBLU, University of Leeds
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>SLS Detectors
Frequently Asked Questions</TITLE>
<META NAME="description" CONTENT="SLS Detectors
Frequently Asked Questions">
<META NAME="keywords" CONTENT="slsDetectors-FAQ">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="LaTeX2HTML v2008">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="STYLESHEET" HREF="slsDetectors-FAQ.css">
</HEAD>
<BODY >
<P>
<H1 ALIGN=CENTER>SLS Detectors
<BR>
Frequently Asked Questions</H1>
<P ALIGN=CENTER><STRONG>Anna Bergamaschi</STRONG>
</P>
<BR><P ALIGN=CENTER><B>Date:</B> February 27, 2018</P>
<HR>
<BR><HR>
</BODY>
</HTML>

View File

@ -0,0 +1,134 @@
# LaTeX2HTML 2008 (1.71)
# Associate internals original text with physical files.
$key = q/sec:usersFunc/;
$ref_files{$key} = "$dir".q|How_can_detector_movement_p.html|;
$noresave{$key} = "$nosave";
$key = q/sec:merging/;
$ref_files{$key} = "$dir".q|How_are_different_positions.html|;
$noresave{$key} = "$nosave";
$key = q/sec:timing/;
$ref_files{$key} = "$dir".q|How_can_I_synchronize_my.html|;
$noresave{$key} = "$nosave";
$key = q/fig:gating/;
$ref_files{$key} = "$dir".q|How_can_I_synchronize_my.html|;
$noresave{$key} = "$nosave";
$key = q/sec:improvetrimming/;
$ref_files{$key} = "$dir".q|MYTHEN.html|;
$noresave{$key} = "$nosave";
$key = q/fig:multidet/;
$ref_files{$key} = "$dir".q|How_can_I_control_many.html|;
$noresave{$key} = "$nosave";
$key = q/eq:acqflow/;
$ref_files{$key} = "$dir".q|Which_is_sequence_acquisiti.html|;
$noresave{$key} = "$nosave";
$key = q/fig:autotiming/;
$ref_files{$key} = "$dir".q|How_can_I_synchronize_my.html|;
$noresave{$key} = "$nosave";
$key = q/sec:3/;
$ref_files{$key} = "$dir".q|Scaling_Poisson_variates.html|;
$noresave{$key} = "$nosave";
$key = q/fig:samplefluo/;
$ref_files{$key} = "$dir".q|How_do_I_chose_comparator.html|;
$noresave{$key} = "$nosave";
$key = q/fig:settings/;
$ref_files{$key} = "$dir".q|MYTHEN.html|;
$noresave{$key} = "$nosave";
$key = q/sec:2/;
$ref_files{$key} = "$dir".q|Advanced_binning.html|;
$noresave{$key} = "$nosave";
$key = q/fig:effidet/;
$ref_files{$key} = "$dir".q|Sensors.html|;
$noresave{$key} = "$nosave";
$key = q/sec:11/;
$ref_files{$key} = "$dir".q|Basic_binning.html|;
$noresave{$key} = "$nosave";
$key = q/fig:thrscanfluo/;
$ref_files{$key} = "$dir".q|How_do_I_chose_comparator.html|;
$noresave{$key} = "$nosave";
$key = q/sec:dataFormat/;
$ref_files{$key} = "$dir".q|In_which_data_format_are.html|;
$noresave{$key} = "$nosave";
$key = q/fig:mythensett/;
$ref_files{$key} = "$dir".q|Frontend_electronics.html|;
$noresave{$key} = "$nosave";
$key = q/sec:sync/;
$ref_files{$key} = "$dir".q|How_can_several_controllers.html|;
$noresave{$key} = "$nosave";
$key = q/fig:badff/;
$ref_files{$key} = "$dir".q|Why_isn_t_my_flat_field_fla.html|;
$noresave{$key} = "$nosave";
$key = q/fig:datareceiver/;
$ref_files{$key} = "$dir".q|How_can_I_configure_data.html|;
$noresave{$key} = "$nosave";
$key = q/fig:effiback/;
$ref_files{$key} = "$dir".q|Sensors.html|;
$noresave{$key} = "$nosave";
$key = q/fig:trig/;
$ref_files{$key} = "$dir".q|How_can_I_synchronize_my.html|;
$noresave{$key} = "$nosave";
$key = q/fig:ffsetup/;
$ref_files{$key} = "$dir".q|Dynamic_acquisition_flat_fi.html|;
$noresave{$key} = "$nosave";
$key = q/fig:thresholdscanuntrimmed/;
$ref_files{$key} = "$dir".q|MYTHEN.html|;
$noresave{$key} = "$nosave";
$key = q/fig:trimdistribution/;
$ref_files{$key} = "$dir".q|MYTHEN.html|;
$noresave{$key} = "$nosave";
$key = q/sec:angcal/;
$ref_files{$key} = "$dir".q|How_is_channel_number_cover.html|;
$noresave{$key} = "$nosave";
$key = q/sec:trimdir/;
$ref_files{$key} = "$dir".q|What_are_settings_calibrati.html|;
$noresave{$key} = "$nosave";
$key = q/fig:trimplot/;
$ref_files{$key} = "$dir".q|MYTHEN.html|;
$noresave{$key} = "$nosave";
$key = q/fig:thresholdscantrimmed/;
$ref_files{$key} = "$dir".q|MYTHEN.html|;
$noresave{$key} = "$nosave";
$key = q/sec:noisetrim/;
$ref_files{$key} = "$dir".q|MYTHEN.html|;
$noresave{$key} = "$nosave";
$key = q/sec:encal/;
$ref_files{$key} = "$dir".q|In_what_consists_energy_cal.html|;
$noresave{$key} = "$nosave";
$key = q/fig:thrscan/;
$ref_files{$key} = "$dir".q|How_do_I_chose_comparator.html|;
$noresave{$key} = "$nosave";
1;

View File

@ -0,0 +1,269 @@
# LaTeX2HTML 2008 (1.71)
# Associate labels original text with physical files.
$key = q/sec:usersFunc/;
$external_labels{$key} = "$URL/" . q|How_can_detector_movement_p.html|;
$noresave{$key} = "$nosave";
$key = q/sec:merging/;
$external_labels{$key} = "$URL/" . q|How_are_different_positions.html|;
$noresave{$key} = "$nosave";
$key = q/sec:timing/;
$external_labels{$key} = "$URL/" . q|How_can_I_synchronize_my.html|;
$noresave{$key} = "$nosave";
$key = q/fig:gating/;
$external_labels{$key} = "$URL/" . q|How_can_I_synchronize_my.html|;
$noresave{$key} = "$nosave";
$key = q/sec:improvetrimming/;
$external_labels{$key} = "$URL/" . q|MYTHEN.html|;
$noresave{$key} = "$nosave";
$key = q/fig:multidet/;
$external_labels{$key} = "$URL/" . q|How_can_I_control_many.html|;
$noresave{$key} = "$nosave";
$key = q/eq:acqflow/;
$external_labels{$key} = "$URL/" . q|Which_is_sequence_acquisiti.html|;
$noresave{$key} = "$nosave";
$key = q/fig:autotiming/;
$external_labels{$key} = "$URL/" . q|How_can_I_synchronize_my.html|;
$noresave{$key} = "$nosave";
$key = q/sec:3/;
$external_labels{$key} = "$URL/" . q|Scaling_Poisson_variates.html|;
$noresave{$key} = "$nosave";
$key = q/fig:samplefluo/;
$external_labels{$key} = "$URL/" . q|How_do_I_chose_comparator.html|;
$noresave{$key} = "$nosave";
$key = q/fig:settings/;
$external_labels{$key} = "$URL/" . q|MYTHEN.html|;
$noresave{$key} = "$nosave";
$key = q/sec:2/;
$external_labels{$key} = "$URL/" . q|Advanced_binning.html|;
$noresave{$key} = "$nosave";
$key = q/fig:effidet/;
$external_labels{$key} = "$URL/" . q|Sensors.html|;
$noresave{$key} = "$nosave";
$key = q/sec:11/;
$external_labels{$key} = "$URL/" . q|Basic_binning.html|;
$noresave{$key} = "$nosave";
$key = q/fig:thrscanfluo/;
$external_labels{$key} = "$URL/" . q|How_do_I_chose_comparator.html|;
$noresave{$key} = "$nosave";
$key = q/sec:dataFormat/;
$external_labels{$key} = "$URL/" . q|In_which_data_format_are.html|;
$noresave{$key} = "$nosave";
$key = q/fig:mythensett/;
$external_labels{$key} = "$URL/" . q|Frontend_electronics.html|;
$noresave{$key} = "$nosave";
$key = q/sec:sync/;
$external_labels{$key} = "$URL/" . q|How_can_several_controllers.html|;
$noresave{$key} = "$nosave";
$key = q/fig:badff/;
$external_labels{$key} = "$URL/" . q|Why_isn_t_my_flat_field_fla.html|;
$noresave{$key} = "$nosave";
$key = q/fig:datareceiver/;
$external_labels{$key} = "$URL/" . q|How_can_I_configure_data.html|;
$noresave{$key} = "$nosave";
$key = q/fig:effiback/;
$external_labels{$key} = "$URL/" . q|Sensors.html|;
$noresave{$key} = "$nosave";
$key = q/fig:trig/;
$external_labels{$key} = "$URL/" . q|How_can_I_synchronize_my.html|;
$noresave{$key} = "$nosave";
$key = q/fig:ffsetup/;
$external_labels{$key} = "$URL/" . q|Dynamic_acquisition_flat_fi.html|;
$noresave{$key} = "$nosave";
$key = q/fig:thresholdscanuntrimmed/;
$external_labels{$key} = "$URL/" . q|MYTHEN.html|;
$noresave{$key} = "$nosave";
$key = q/fig:trimdistribution/;
$external_labels{$key} = "$URL/" . q|MYTHEN.html|;
$noresave{$key} = "$nosave";
$key = q/sec:angcal/;
$external_labels{$key} = "$URL/" . q|How_is_channel_number_cover.html|;
$noresave{$key} = "$nosave";
$key = q/sec:trimdir/;
$external_labels{$key} = "$URL/" . q|What_are_settings_calibrati.html|;
$noresave{$key} = "$nosave";
$key = q/fig:trimplot/;
$external_labels{$key} = "$URL/" . q|MYTHEN.html|;
$noresave{$key} = "$nosave";
$key = q/fig:thresholdscantrimmed/;
$external_labels{$key} = "$URL/" . q|MYTHEN.html|;
$noresave{$key} = "$nosave";
$key = q/sec:noisetrim/;
$external_labels{$key} = "$URL/" . q|MYTHEN.html|;
$noresave{$key} = "$nosave";
$key = q/sec:encal/;
$external_labels{$key} = "$URL/" . q|In_what_consists_energy_cal.html|;
$noresave{$key} = "$nosave";
$key = q/fig:thrscan/;
$external_labels{$key} = "$URL/" . q|How_do_I_chose_comparator.html|;
$noresave{$key} = "$nosave";
1;
# LaTeX2HTML 2008 (1.71)
# labels from external_latex_labels array.
$key = q/sec:usersFunc/;
$external_latex_labels{$key} = q|1.10|;
$noresave{$key} = "$nosave";
$key = q/sec:merging/;
$external_latex_labels{$key} = q|5.2|;
$noresave{$key} = "$nosave";
$key = q/sec:timing/;
$external_latex_labels{$key} = q|1.8|;
$noresave{$key} = "$nosave";
$key = q/fig:gating/;
$external_latex_labels{$key} = q|1.4|;
$noresave{$key} = "$nosave";
$key = q/sec:improvetrimming/;
$external_latex_labels{$key} = q|3.4.1|;
$noresave{$key} = "$nosave";
$key = q/fig:multidet/;
$external_latex_labels{$key} = q|1.1|;
$noresave{$key} = "$nosave";
$key = q/eq:acqflow/;
$external_latex_labels{$key} = q|1.7|;
$noresave{$key} = "$nosave";
$key = q/fig:autotiming/;
$external_latex_labels{$key} = q|1.3|;
$noresave{$key} = "$nosave";
$key = q/sec:3/;
$external_latex_labels{$key} = q|5.2.6|;
$noresave{$key} = "$nosave";
$key = q/fig:samplefluo/;
$external_latex_labels{$key} = q|3.4|;
$noresave{$key} = "$nosave";
$key = q/fig:settings/;
$external_latex_labels{$key} = q|3.1|;
$noresave{$key} = "$nosave";
$key = q/sec:2/;
$external_latex_labels{$key} = q|5.2.3|;
$noresave{$key} = "$nosave";
$key = q/fig:effidet/;
$external_latex_labels{$key} = q|2.1|;
$noresave{$key} = "$nosave";
$key = q/sec:11/;
$external_latex_labels{$key} = q|5.2.2|;
$noresave{$key} = "$nosave";
$key = q/fig:thrscanfluo/;
$external_latex_labels{$key} = q|3.3|;
$noresave{$key} = "$nosave";
$key = q/sec:dataFormat/;
$external_latex_labels{$key} = q|1.11|;
$noresave{$key} = "$nosave";
$key = q/fig:mythensett/;
$external_latex_labels{$key} = q|2.3|;
$noresave{$key} = "$nosave";
$key = q/sec:sync/;
$external_latex_labels{$key} = q|1.9|;
$noresave{$key} = "$nosave";
$key = q/fig:badff/;
$external_latex_labels{$key} = q|3.5|;
$noresave{$key} = "$nosave";
$key = q/fig:datareceiver/;
$external_latex_labels{$key} = q|1.2|;
$noresave{$key} = "$nosave";
$key = q/fig:effiback/;
$external_latex_labels{$key} = q|2.2|;
$noresave{$key} = "$nosave";
$key = q/fig:trig/;
$external_latex_labels{$key} = q|1.6|;
$noresave{$key} = "$nosave";
$key = q/fig:ffsetup/;
$external_latex_labels{$key} = q|3.6|;
$noresave{$key} = "$nosave";
$key = q/fig:thresholdscanuntrimmed/;
$external_latex_labels{$key} = q|3.7|;
$noresave{$key} = "$nosave";
$key = q/fig:trimdistribution/;
$external_latex_labels{$key} = q|3.8|;
$noresave{$key} = "$nosave";
$key = q/sec:angcal/;
$external_latex_labels{$key} = q|5.1|;
$noresave{$key} = "$nosave";
$key = q/sec:trimdir/;
$external_latex_labels{$key} = q|1.4|;
$noresave{$key} = "$nosave";
$key = q/fig:trimplot/;
$external_latex_labels{$key} = q|3.9|;
$noresave{$key} = "$nosave";
$key = q/fig:thresholdscantrimmed/;
$external_latex_labels{$key} = q|3.10|;
$noresave{$key} = "$nosave";
$key = q/sec:noisetrim/;
$external_latex_labels{$key} = q|3.4.1|;
$noresave{$key} = "$nosave";
$key = q/sec:encal/;
$external_latex_labels{$key} = q|3.5|;
$noresave{$key} = "$nosave";
$key = q/fig:thrscan/;
$external_latex_labels{$key} = q|3.2|;
$noresave{$key} = "$nosave";
1;

View File

@ -0,0 +1,30 @@
/* Century Schoolbook font is very similar to Computer Modern Math: cmmi */
.MATH { font-family: "Century Schoolbook", serif; }
.MATH I { font-family: "Century Schoolbook", serif; font-style: italic }
.BOLDMATH { font-family: "Century Schoolbook", serif; font-weight: bold }
/* implement both fixed-size and relative sizes */
SMALL.XTINY { font-size : xx-small }
SMALL.TINY { font-size : x-small }
SMALL.SCRIPTSIZE { font-size : smaller }
SMALL.FOOTNOTESIZE { font-size : small }
SMALL.SMALL { }
BIG.LARGE { }
BIG.XLARGE { font-size : large }
BIG.XXLARGE { font-size : x-large }
BIG.HUGE { font-size : larger }
BIG.XHUGE { font-size : xx-large }
/* heading styles */
H1 { }
H2 { }
H3 { }
H4 { }
H5 { }
/* mathematics styles */
DIV.displaymath { } /* math displays */
TD.eqno { } /* equation-number cells */
/* document-specific styles come next */

View File

@ -0,0 +1,41 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 2008 (1.71)
original version by: Nikos Drakos, CBLU, University of Leeds
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>SLS Detectors
Frequently Asked Questions</TITLE>
<META NAME="description" CONTENT="SLS Detectors
Frequently Asked Questions">
<META NAME="keywords" CONTENT="slsDetectors-FAQ">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="LaTeX2HTML v2008">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="STYLESHEET" HREF="slsDetectors-FAQ.css">
</HEAD>
<BODY >
<P>
<H1 ALIGN=CENTER>SLS Detectors
<BR>
Frequently Asked Questions</H1>
<P ALIGN=CENTER><STRONG>Anna Bergamaschi</STRONG>
</P>
<BR><P ALIGN=CENTER><B>Date:</B> February 27, 2018</P>
<HR>
<BR><HR>
</BODY>
</HTML>

Binary file not shown.

Binary file not shown.

View File

@ -77,6 +77,7 @@ int main(int argc, char **argv) {
pDetector->enableDataStreamingToClient(1);
/** - ensuring detector status is idle before starting acquisition. exiting if not idle */
int status = pDetector->getDetectorStatus();
if (status != 0){
@ -93,7 +94,7 @@ int main(int argc, char **argv) {
/** - start measurement */
pDetector->startMeasurement();
std::cout << "measurement finished" << std::endl; usleep(1*1000*1000);
std::cout << "measurement finished" << std::endl;
/** - returning when acquisition is finished or data are avilable */

View File

@ -4,46 +4,31 @@ DESTDIR=../docs
TEX=latex
MAINTEXS2= slsDetectorInstall.tex
MAINTEXS=slsDetectors-FAQ.tex
MAINTEXS= slsDetectorInstall.tex slsDetectors-FAQ.tex
TEXS=slsDetector-softFAQ.tex singlePhotonCounting-FAQ.tex angConv-FAQ.tex generalDet-FAQ.tex
DVIS = $(MAINTEXS:.tex=.dvi)
PSS = $(MAINTEXS:.tex=.ps)
PDFS = $(MAINTEXS:.tex=.pdf)
PDFS2 = $(MAINTEXS2:.tex=.pdf)
HTMLS = $(MAINTEXS:%.tex=%)
HTMLS2 = $(MAINTEXS2:%.tex=%)
all: pdf html
echo $(PWD)
echo $(PDFS)
echo $(PDFS2)
echo $(HTMLS)
echo $(HTMLS2)
pdf: $(PDFS) $(PDFS2)
pdf: $(PDFS)
$(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR))
$(shell test -d $(DESTDIR)/pdf || mkdir -p $(DESTDIR)/pdf)
mv $(PDFS) $(DESTDIR)/pdf
mv $(PDFS2) $(DESTDIR)/pdf
mv $(PDFS) $(DESTDIR)/pdf
html: $(HTMLS) $(HTMLS2)
html: $(HTMLS)
$(HTMLS): $(TEXS) $(MAINTEXS)
$(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR))
$(shell test -d $(DESTDIR)/html || mkdir -p $(DESTDIR)/html)
$(shell test -d $(DESTDIR)/html/$@ && rm -fr $(DESTDIR)/html/$@)
echo "***************************** $@"
latex $@.tex
latex2html $@.tex
mv $@ $(DESTDIR)/html
$(HTMLS2): $(MAINTEXS2)
$(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR))
$(shell test -d $(DESTDIR)/html || mkdir -p $(DESTDIR)/html)
$(shell test -d $(DESTDIR)/html/$@ && rm -fr $(DESTDIR)/html/$@)
@ -68,7 +53,7 @@ $(HTMLS2): $(MAINTEXS2)
clean:
rm -rf *.aux *.log *.toc *.out $(DVIS) $(PSS) $(PDFS) $(PDFS2) $(HTMLS) $(HTMLS2)
rm -rf *.aux *.log *.toc *.out $(DVIS) $(PSS) $(PDFS) $(HTMLS)
rm -rf $(DESTDIR)/html/slsDetectors-FAQ
rm -rf $(DESTDIR)/html/slsDetectorInstall
rm -rf $(DESTDIR)/pdf/slsDetectors-FAQ.pdf

View File

@ -28,10 +28,9 @@
The SLS detectors software is intended to control the detectors developed by
the SLS Detectors group. The detectors currently supported are:
\indent MYTHEN, GOTTHARD, EIGER and JUNGFRAU.
MYTHEN, GOTTHARD, EIGER and JUNGFRAU.\bigskip
The package provides software for the distributed system that comprises of
\noindent The package provides software for the distributed system that comprises of
detectors, data receivers (to process detector data), and the client (to control
or monitor the system). The client and data receivers can be embedded in
the user's acquisitions system. Furthermore, the package also provides some
@ -79,28 +78,18 @@ However, only control commands work, not the data acquisition itself.
\section{Install Binaries via Conda}
This section is useful only if one wants to download only the binaries for
specific distribution and use the package via command line. Please refer later
sections to download source code and compile them.
sections to download source code and compile them.\bigskip
\noindent One can download and install Miniconda via
One can download and install Miniconda via
\url{https://conda.io/miniconda.html} \bigskip
\url{https://conda.io/miniconda.html}
The conda package uses Travis CI for continuous integration with
\noindent The conda package uses Travis CI for continuous integration with
automatic deployment to Anaconda Cloud. One can download only the package or the
package including the python interface.
package including the python interface. \bigskip
\noindent After the installation, the binaries will be available in your path.
After the installation, the binaries will be available in your path.
Please remember to clear shared memory after installation.
\begin{verbatim}
#displays list of shared memeory segments
ipcs -m
#remove segments that have nattach equal to zero. They key is the first column
ipcrm -M [key]
\end{verbatim}
\begin{itemize}
\item Only the package
@ -113,10 +102,10 @@ conda config --add channels slsdetectorgroup
conda install sls_detector_software
#Install specific release (GLIBC2.14)
conda install sls_detector_software=3.1.0
conda install sls_detector_software=3.0.1
#Scientific Linux 6 version (GLIBC2.12)
conda install sls_detector_software=SL6_3.1.0
conda install sls_detector_software=SL6_3.0.1
\end{verbatim}
\item The package including Python interface
\begin{verbatim}
@ -128,10 +117,10 @@ conda config --add channels sls_detector
conda install sls_detector
#Install specific release (GLIBC2.14)
conda install sls_detector=3.1.0
conda install sls_detector=3.0.1
#Scientific Linux 6 version (GLIBC2.12)
conda install sls_detector=SL6_3.1.0
conda install sls_detector=SL6_3.0.1
\end{verbatim}
\end{itemize}
@ -148,13 +137,13 @@ acquisition system, or if one wants to download the source code and compile.
\begin{verbatim}
#Clone source code with specific release
git clone https://github.com/slsdetectorgroup/slsDetectorPackage.git --branch
3.1.0
3.0.1
\end{verbatim}
\item The package including Python interface
\begin{verbatim}
#Clone source code with specific release
git clone https://github.com/slsdetectorgroup/sls_detector.git --branch
3.1.0
3.0.1
\end{verbatim}
\end{itemize}
@ -205,10 +194,9 @@ required. One can install it:
\item via download from:\\
\url{
https://download.qt.io/archive/qt/4.8/4.8.2/qt-everywhere-opensource-src-4.8.2.t
ar.gz}
ar.gz} \bigskip
To install:
\noindent To install:
\begin{verbatim}
> gunzip qt-everywhere-opensource-src-4.8.2.tar.gz
> tar xvf qt-everywhere-opensource-src-4.8.2.tar
@ -219,17 +207,14 @@ To install:
By default Qt4 will be installed in /usr/local/Trolltech/Qt-4.8.2/.
\end{itemize}
\noindent \textbf{Setup Environment}
\textbf{Setup Environment}
One has to ensure that \verb=PATH= and \verb=LD_LIBRARY_PATH= have
\noindent One has to ensure that \verb=PATH= and \verb=LD_LIBRARY_PATH= have
been updated to include Qt4 install path, binaries and libraries.
Confirm by executing \verb=qmake -v= and ensuring the result points to Qt4 (not
Qt3 or Qt5).
Qt3 or Qt5). \bigskip
If the environment is not set up, one can add the libraries and
\noindent If the environment is not set up, one can add the libraries and
executables to the .bashrc by adding
\verb=LD_LIBRARY_PATH= and \verb=PATH=:
\begin{verbatim}
@ -243,10 +228,9 @@ export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
Before installing Qwt, one must install Qt
and ensure that \verb=QTDIR=, \verb=LD_LIBRARY_PATH= and \verb=PATH= point to
the correct Qt4
version.
version. \bigskip
A Qwt version equal or higher than 6 is required. One can
\noindent A Qwt version equal or higher than 6 is required. One can
install it:
\begin{itemize}
\item via YUM:
@ -256,9 +240,9 @@ install it:
\item via download from:\\
\url{
https://sourceforge.net/projects/qwt/files/qwt/6.0.0/qwt-6.0.0.zip/download}
\bigskip
To install:
\noindent To install:
\begin{verbatim}
> cd qwt-6.0.0
> qmake
@ -268,14 +252,12 @@ To install:
By default Qwt will be installed int /usr/local/qwt-6.0.0
\end{itemize}
\textbf{Setup Environment}
\noindent \textbf{Setup Environment}
\noindent One has to ensure that \verb=QWTDIR= and \verb=LD_LIBRARY_PATH= have
been updated to include Qwt install path and libraries. \bigskip
One has to ensure that \verb=QWTDIR= and \verb=LD_LIBRARY_PATH= have
been updated to include Qwt install path and libraries.
If the environment is not set up, one can add the libraries to the
\noindent If the environment is not set up, one can add the libraries to the
.bashrc by adding \verb=LD_LIBRARY_PATH=:
\begin{verbatim}
export QWTDIR=/usr/local/qwt-6.0.0/
@ -342,8 +324,6 @@ Usage: [-c] [-b] [-h] [-d HDF5 directory] [-j]
Some example options for compilation:
Most basic option: \verb=./cmk.sh -b=
For only make: \verb=./cmk.sh=
For make clean;make: \verb=./cmk.sh -c=
@ -387,69 +367,10 @@ sls_detector_help sls_detector_put slsReceiver
\subsection{Setting environment variables}
One can set up the environment variables in the following ways.
\subsubsection{Using .bashrc file}
\begin{enumerate}
\item \verb=emacs ~/.bashrc=
\item Add the following function \verb=setup_slsdet= and replace \verb=path=
with absolute path of installed directory
\begin{verbatim}
function setup_slsdet
{
export PKGPATH=[path]
export LD_LIBRARY_PATH=$PKGPATH/slsDetectorPackage/build/bin:$LD_LIBRARY_PATH
export PATH=$PKGPATH/slsDetectorPackage/build/bin:$PATH
cd $PKGPATH/slsDetectorPackage/build/bin
}
\end{verbatim}
\item \verb=source ~/.bashrc=
\item Next time, just run \verb=setup_slsdet= to load the environment
variables.
\end{enumerate}
One can also add the GUI environment variables if installed locally by adding
the following in the function \verb=setup_sldet= \\
\begin{verbatim}
export QTDIR=/path-where-it-is/Qt-4.8.2
export QWTDIR=/path-where-it-is/qwt-6.0.1
export QWT3D=/path-where-it-is/qwtplot3d
export QMAKESPEC=$QTDIR/mkspecs/linux-g++
export LD_LIBRARY_PATH=$QTDIR/lib:$QWTDIR/lib:$QWT3D/lib:$LD_LIBRARY _PATH
export PATH=$QTDIR/bin:$PATH
\end{verbatim}
\subsubsection{Without .bashrc file}
Go to binaries folder slsDetectorPackage/build/bin and execute the following:
\begin{verbatim}
export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH
export PATH=$PWD:$PATH
\end{verbatim}
\subsection{Clean Shared Memory}
It is very crucial to clean the shared memory, before using a new version of
the SLS Detector Package or a different detector type.
One can use the \verb=cleansharedmemory.sh= script available under the
slsDetector Package.
One can also just use the following commands to clean the shared memory
segments one by one.
\begin{verbatim}
#displays list of shared memeory segments
ipcs -m
#remove segments that have nattach equal to zero. They key is the first column
ipcrm -M [key]
\end{verbatim}
\section{Software Upgrade}
The upgrade of the package could require an upgrade of the on-board detector
server and/or firmware running on the detector as well.
server and/or firmware running on the detector as well.
\subsection{MYTHEN}
@ -458,7 +379,7 @@ themselves (which would require dedicated softwares) but only to download on the
detector board the programming files and/or software package provided by
the SLS Detectors group.
\subsubsection{MYTHEN Firmware}
\subsubsection{Firmware}
To upgrade the firmware you need either a working version of the Altera
Quartus software or of the Quartus programmer, which can easily be downloaded
@ -468,10 +389,9 @@ from: \\
\noindent Normally, installation of the software and of the driver for the
USB-Blaster (provided together with the MYTHEN detector) are simpler under
Windows.
Windows. \bigskip
Under Windows, the first time that you connect the USB-Blaster to one
\noindent Under Windows, the first time that you connect the USB-Blaster to one
of your USB ports, you will be asked to install new hardware. Set the path to
search for the driver to:
\verb=C:\altera\80sp1\qprogrammer\drivers\usb-blasterp= (where
@ -494,7 +414,7 @@ your cable (pin1 corresponds) and that you have selected the correct programming
connector.
\end{enumerate}
\subsubsection{MYTHEN On-board Software}
\subsubsection{On-board Software}
\begin{enumerate}
\item Connect to the board using telnet:
\begin{verbatim}
@ -534,297 +454,6 @@ acqusition program correctly start.
\end{enumerate}
\subsection{GOTTHARD}
In such cases, the users are not expected to compile the software
themselves (which would require dedicated softwares) but only to download on the
detector board the programming files and/or software package provided by
the SLS Detectors group.
\subsubsection{GOTTHARD Firmware}
\textit{For SLS Detector Package v3.1.0} \\
\indent Minimum compatible version: \\
\indent \indent 11.01.2013 \\
\indent Latest version: \\
\indent \indent 08.02.2018 (50um and 25um Master) \\
\indent \indent 09.02.2018 (25 um Slave) \\
Normally, the firmware will be upgraded by us as it requires programming the
FPGA via the USB-Blaster.
To upgrade the firmware you need either a working version of the Altera
Quartus software or of the Quartus programmer, which can easily be downloaded
from: \\
\url{https://www.altera.com/download/programming/quartus2/pq2-index.jsp}
Normally, installation of the software and of the driver for the
USB-Blaster (provided together with the MYTHEN detector) are simpler under
Windows.
Under Windows, the first time that you connect the USB-Blaster to one
of your USB ports, you will be asked to install new hardware. Set the path to
search for the driver to:
\verb=C:\altera\80sp1\qprogrammer\drivers\usb-blasterp= (where
\verb=C:\altera\80sp1\qprogrammer\= is assumed to be ther path where your
Quartus version is installed).
\begin{enumerate}
\item After starting the Quartus programmer, click on Hardware Setup and in the
"Currently selected hardware" window select USB-Blaster.
\item In the Mode combo box select "Active Serial Programming".
\item Plug the end of your USB-Blaster WITH THE ADAPTER PROVIDED in the
connector ASMI on the MCS board taking care that pin1 corresponds to the one
indexed and with the rectangualr pad.
\item Click on add file and from select the programming file provided when
the upgrade has been reccomended.
\item Check "Program/Configure" and "Verify".
\item Push the start button and wait until the programming process is
finished (progress bar top left).
\item In case the programmer gives you error messages, check the polarity of
your cable (pin1 corresponds) and that you have selected the correct programming
connector.
\end{enumerate}
\subsubsection{GOTTHARD On-board Software}
Every SLS Detector package release will have its coresponding matching on-board
server under \textbf{slsDetectorPackage/serverBin}.
\begin{enumerate}
\item Install tftp if the pc does not have it.
\item Copy the server from serverBin folder to /tftpboot (or equivalent tftp
folder) of the pc
\item Copy the server to the detector by:
\begin{enumerate}
\item Connect to the blackfin on the detector\\
\verb=telnet bchipxxx=
\item Prevent existing on-board server from respawning by:
\begin{enumerate}
\item Edit \verb=/etc/inittab=
\item Comment out the line
\verb=#ttyS0::respawn:/gotthardDetectorServervxxx=
\item Reboot blackfin using \verb=reboot=
\item Run \verb=ps= to ensure no gotthardDetectorServers are running
\end{enumerate}
\item Copy new on-board server from pc to the blackfin using: \\
\verb=tftp pcxxx -r gotthardDetectorServerxxx -g=
\item Respawn the new server (server starts at detector statup):
\begin{enumerate}
\item Edit \verb=/etc/inittab=
\item Uncomment out the line
\verb=ttyS0::respawn:/gotthardDetectorServervxxx=
\item Reboot blackfin using \verb=reboot=
\item Run \verb=ps= to ensure that both the gotthardDetectorServers are
running.\\
\verb=gotthardDetectorServerxxx= \\
\verb=gotthardDetectorServerxxx 1953=
\end{enumerate}
\end{enumerate}
\end{enumerate}
\subsection{EIGER}
In such cases, the users are not expected to compile the software
themselves (which would require dedicated softwares) but only to download on the
detector board the programming files and/or software package provided by
the SLS Detectors group.
\subsubsection{EIGER Firmware}
\textit{For SLS Detector Package v3.1.0} \\
\indent Minimum compatible version: 16 \\
\indent Latest version: 20 \\
\begin{enumerate}
\item One must get the latest package's corresponding bit files from the SLS
Detector Group.
\item If one does not have the bcp script, that should also be obtained from
the SLS Detector Group. It is required to program the bit files and requires
that tftp be installed on the pc.
\item Run the following to update firmware
\begin{verbatim}
#update back end fpga
bcp download.bit bebxxx:/fw0
#update front left fpga
bcp download.bit bebxxx:/febl
#update front right fpga
bcp download.bit bebxxx:/febr
#update kernel
bcp download.bit bebxxx:/kernel
\end{verbatim}
Please update bit files with great caution as it could make your board
inaccessible, if done incorrectly.
\end{enumerate}
\subsubsection{EIGER On-board Software}
Every SLS Detector package release will have its coresponding matching on-board
server under \textbf{slsDetectorPackage/serverBin}.
Update the on-board software without connecting to the detector
\begin{verbatim}
#password for the boards: root
#Kill existing servers that are running on the detector
ssh root@beb031 killall eigerDetectorServer;
#Copy on-board server to detector inside executables folder
scp ~/path-where-it-is/eigerDetectorServerxxx root@bebxxx:~/executables;
#Overwrite the actual eigerDetectorServer on board
scp ~/path-where-it-is/eigerDetectorServerxxx
root@bebxxx:~/executables/eigerDetectorServer;
#sync
ssh root@bebxxx sync;
#reboot the eiger board
\end{verbatim}
\bigskip One can connect to the detector by:
\begin{verbatim}
ssh root@bebxxx
password: root
\end{verbatim}
The on-board server is in ~/executables folder and respawned at startup in \\
\verb=/etc/rc5.d/S50board_com.sh=
\subsection{JUNGFRAU}
In such cases, the users are not expected to compile the software
themselves (which would require dedicated softwares) but only to download on the
detector board the programming files and/or software package provided by
the SLS Detectors group.
\subsubsection{JUNGFRAU Firmware}
\textit{For SLS Detector Package v3.1.0} \\
\indent Minimum compatible version: 13.11.2017 \\
\indent Latest version: 13.11.2017 \\
At times, one has to update the firmware, which then also requires updating the
on-board software.
\textbf{\textit{Jungfrau firmware can be upgraded via the SLS Detector Package
binaries from the command line.}}
\begin{enumerate}
\item One must get the latest package's corresponding POF file from the SLS
Detector Group.
\item Update the latest SLS Detector package installed.
\item Update the on-board software as per the instructions in the next
section.
\item Start the on-board server in debug mode:
\begin{enumerate}
\item Connect to the blackfin on the detector\\
\verb=telnet bchipxxx=
\item Prevent existing on-board server from respawning by:
\begin{enumerate}
\item Edit \verb=/etc/inittab=
\item Comment out the line
\verb=#ttyS0::respawn:/jungfrauDetectorServervxxx=
\item Reboot blackfin using \verb=reboot=
\item Run \verb=ps= to ensure no gotthardDetectorServers are running
\end{enumerate}
\item Start the server in debug mode using: \\
\verb=./jungfrauDetectorServerxxx -debug= \\
Leave this console on to come back to it later.
\end{enumerate}
\item From the command line of the pc, clear shared memory \\
\verb=./sls_detector_get free= \\
If one gets shmget error, please clean the shared memory properly using the
script in \verb=slsDetectorPackage/cleansharedmemory.sh=
\item Add the detector to shared memory using \\
\verb=./sls_detector_put hostname bchipxxx=
\item Program the FPGA using \\
\verb=./sls_detector_put programfpga xxx.pof=
\item Once the programming is done:
\begin{enumerate}
\item Switch to the console that has the debug server running and kill it
using Ctrl+C and ensure no jungfrauDetectorServers are
running
\item Restart the new server to see if it runs with the new firmware \\
\verb=./jungfrauDetectorServerxxx= \\
If the server didn't start properly, please contact us with the error message
shown when starting the server up, else continue with the following steps.
\item Respawn the new server (server starts at detector statup):
\begin{enumerate}
\item Edit \verb=/etc/inittab=
\item Uncomment out the line
\verb=ttyS0::respawn:/jungfrauDetectorServervxxx=
\item Reboot blackfin using \verb=reboot=
\item Run \verb=ps= to ensure that both the gotthardDetectorServers are
running.\\
\verb=jungfrauDetectorServervxxx= \\
\verb=jungfrauDetectorServervxxx 1953=
\end{enumerate}
\end{enumerate}
\end{enumerate}
\subsubsection{JUNGFRAU On-board Software}
Every SLS Detector package release will have its coresponding matching on-board
server under \textbf{slsDetectorPackage/serverBin}.
\begin{enumerate}
\item Install tftp if the pc does not have it.
\item Copy the server from serverBin folder to /tftpboot (or equivalent tftp
folder) of the pc
\item Copy the server to the detector by:
\begin{enumerate}
\item Connect to the blackfin on the detector\\
\verb=telnet bchipxxx=
\item Prevent existing on-board server from respawning by:
\begin{enumerate}
\item Edit \verb=/etc/inittab=
\item Comment out the line
\verb=#ttyS0::respawn:/jungfrauDetectorServervxxx=
\item Reboot blackfin using \verb=reboot=
\item Run \verb=ps= to ensure no gotthardDetectorServers are running
\end{enumerate}
\item Copy new on-board server from pc to the blackfin using: \\
\verb=tftp pcxxx -r jungfrauDetectorServervxxx -g=
\item Respawn the new server (server starts at detector statup):
\begin{enumerate}
\item Edit \verb=/etc/inittab=
\item Uncomment out the line
\verb=ttyS0::respawn:/jungfrauDetectorServervxxx=
\item Reboot blackfin using \verb=reboot=
\item Run \verb=ps= to ensure that both the gotthardDetectorServers are
running.\\
\verb=jungfrauDetectorServervxxx= \\
\verb=jungfrauDetectorServervxxx 1953=
\end{enumerate}
\end{enumerate}
\end{enumerate}
\begin{comment}
\section{Detector system architecture}

View File

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

View File

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

View File

@ -0,0 +1 @@
../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.0.0.16.10

View File

@ -1 +0,0 @@
../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.1.0.16.1

View File

@ -1 +0,0 @@
../slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.1.0.21.0

View File

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

View File

@ -0,0 +1 @@
../slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServerv3.0.0.6

View File

@ -1 +0,0 @@
../slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServerv3.1.0.1

View File

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

View File

@ -1 +0,0 @@
../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.0.0.12

View File

@ -0,0 +1 @@
../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.0.0.6.3

View File

@ -1 +0,0 @@
../slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServerv3.1.0.2

View File

@ -0,0 +1 @@
../slsDetectorSoftware/moenchDetectorServer/moenchDetectorServerv2.0.3

View File

@ -0,0 +1,113 @@
#ifndef INTMAP_H
#define INTMAP_H
#define N 60
#include <stdio.h>
#include <math.h>
class IntMap{
public:
IntMap(){};
~IntMap(){};
void Init(){
//lookup table of the output intensity for IR laser
//measurements performed by Dominic april 2014
//intensity[59]=intensity with 0 Optical Density
//intensity[0]=intensity with 5.9 Optical Density
intensity[0]=29;//5.9
intensity[1]=21;//5.8
intensity[2]=31;//5.7
intensity[3]=43;//5.6
intensity[4]=60;//5.5
intensity[5]=91;//5.4
intensity[6]=69;//5.3
intensity[7]=102;//5.2
intensity[8]=136;//5.1
intensity[9]=196;//5.0
intensity[10]=425;//4.9
intensity[11]=311;//4.8
intensity[12]=462;//4.7
intensity[13]=653;//4.6
intensity[14]=926;//4.5
intensity[15]=1423;//4.4
intensity[16]=1072;//4.3
intensity[17]=1592;//4.2
intensity[18]=2142;//4.1
intensity[19]=3085;//4.0
intensity[20]=729;//3.9
intensity[21]=533;//3.8
intensity[22]=793;//3.7
intensity[23]=1121;//3.6
intensity[24]=1588;//3.5
intensity[25]=2439;//3.4
intensity[26]=1842;//3.3
intensity[27]=2730;//3.2
intensity[28]=3663;//3.1
intensity[29]=5271;//3.0
intensity[30]=8102;//2.9
intensity[31]=5933;//2.8
intensity[32]=8789;//2.7
intensity[33]=12350;//2.6
intensity[34]=17358;//2.5
intensity[35]=26300;//2.4
intensity[36]=20029;//2.3
intensity[37]=29414;//2.2
intensity[38]=39202;//2.1
intensity[39]=55724;//2.0
intensity[40]=15697;//1.9
intensity[41]=11541;//1.8
intensity[42]=16976;//1.7
intensity[43]=23866;//1.6
intensity[44]=33478;//1.5
intensity[45]=50567;//1.4
intensity[46]=38552;//1.3
intensity[47]=56394;//1.2
intensity[48]=74897;//1.1
intensity[49]=106023;//1.0
intensity[50]=157384;//0.9
intensity[51]=117677;//0.8
intensity[52]=171101;//0.7
intensity[53]=236386;//0.6
intensity[54]=327248;//0.5
intensity[55]=492781;//0.4
intensity[56]=379641;//0.3
intensity[57]=546927;//0.2
intensity[58]=717203;//0.1
intensity[59]=1000000;//0.
return;
};
//_od is the total Optical Density
int getIntensity(float _od){
int _int(-1);
//these lines are to take into account rounding errors with floats
float hun_od = 100.*_od;
int Ihun_od = (int)round(hun_od);
float R_od =(float) Ihun_od/10.;
int I_od = (int)R_od;
if(I_od >-1 && I_od <60){
int index=59-I_od;
cerr<<index<<endl;
_int=intensity[index];
}else{
cerr<<"Optical density out of range!"<<endl;
}
return _int;
};
private:
int intensity[N];
};
#endif

View File

@ -29,41 +29,28 @@ class MovingStat
/**
clears the moving average number of samples parameter, mean and standard deviation
*/
void Set(double val, double rms=0, int m=-1)
void Set(double val, double rms=0)
{
if (m>=0) m_n = m; else m_n = n;
m_newM=val*m_n;
SetRMS(rms);
}
/**
clears the moving average number of samples parameter, mean and standard deviation
*/
void SetRMS(double rms)
{
if (rms<=0) {
m_newM2=m_newM*m_newM/n;
m_n=0;
} else {
if (m_n>0)
m_newM2=(m_n*rms*rms+m_newM*m_newM/m_n);
else {
m_newM2=(m_n*rms*rms+m_newM*m_newM/n);
m_n=0;
}
}
m_n = n;
m_newM=val*n;
if (rms<=0)
m_newM2=val*val*n;
else
m_newM2=(n*rms*rms+m_newM*m_newM/n);
}
/** sets number of samples parameter
\param i number of samples parameter to be set
*/
int SetN(int i) {if (i>=1) n=i; return n;};
void SetN(int i) {if (i>=1) n=i;};
/**
gets number of samples parameter
\returns actual number of samples parameter
*/
int GetN() {return m_n;};
int GetN() {return n;};
/** calculates the moving average i.e. adds if number of elements is lower than number of samples parameter, pushes otherwise
\param x value to calculate the moving average

View File

@ -0,0 +1,194 @@
#include "moench03ReadData.C"
/************************************************************************/
TH2F *readExactImage(char *fname, int iframe=0, int frperfile,TH2F *hped=NULL) {
ifstream filebin;
filebin.open((const char *)(fname), ios::in | ios::binary);
TH2F *h2=new TH2F("h2","",400,0,400,400,0,400);
int framen(0);
moench03CtbData *decoder=new moench03CtbData();
char *buff=decoder->readNextFrame(filebin);
framen=decoder->getFrameNumber(buff);
int counter(0);
while(framen<iframe && counter<frperfile){
buff=decoder->readNextFrame(filebin);
framen=decoder->getFrameNumber(buff);
cerr<<"...";
if(framen%1000==0) cerr<<framen;
counter++;
}
if(counter<frperfile){
h2->SetName(Form("frame_%d",framen));
h2->SetTitle(Form("frame_%d",framen));
cout << "==" << endl;
for (int ix=0; ix<400; ix++) {
for (int iy=0; iy<400; iy++) {
// cout << decoder->getDataSize() << " " << decoder->getValue(buff,ix,iy)<< endl;
h2->SetBinContent(ix+1,iy+1,decoder->getValue(buff,ix,iy));
// h1->SetBinContent(++ip,decoder->getValue(buff,ix,iy));
}
}
if (hped) h2->Add(hped,-1);
}else{
cerr<<"frame number not found"<<endl;
}
return h2;
}
/************************************************************/
//fnamein filename: ..._f0_%d.raw
//runmin, runmax to calculate pedestals
//framen0, framen1 first and last frame you want to add to the gif
//frperfile number of frames per file
void PlotRawFrameGif(char * fnamein, int runmin, int runmax, int framen0,int framen1, int frperfile){
cerr<<"/***********************************/"<<endl;
cerr<<"calculating pedestals"<<endl;
TH2F * hp = calcPedestal(fnamein,runmin,runmax);
int filen = (int)(framen0/frperfile);
char fname[1000];
sprintf(fname,fnamein,filen);
cerr<<"/***********************************/"<<endl;
cerr<<"retrieving frame from"<<fname<<endl;
int fileframe0 = framen0%frperfile;
int fileframe1 = framen1%frperfile;
TImage * img = NULL;
TH2F * hf = NULL;
TCanvas * c1 =NULL;
for(int fileframe=fileframe0; fileframe<fileframe1; fileframe++){
hf=readExactImage(fname, fileframe,frperfile,hp);
delete img;
delete c1;
c1 = new TCanvas("c1","",800,600);
c1->cd();
hf->SetTitle(Form("Frame_%d",fileframe+framen0));
hf->SetName(Form("Frame_%d",fileframe+framen0));
hf->GetXaxis()->SetRangeUser(0,50);
hf->GetXaxis()->SetTitle("Column");
hf->GetYaxis()->SetRangeUser(240,290);
hf->GetYaxis()->SetTitle("Row");
hf->GetZaxis()->SetRangeUser(-50.,1300.);
hf->SetStats(kFALSE);
// c1->SetLogz();
hf->Draw("colz");
c1->Print(Form("/afs/psi/project/mythen/Marco/Pics/Fe_Raw3_%d.png",fileframe));
img = TImage::Open(Form("/afs/psi/project/mythen/Marco/Pics/Fe_Raw3_%d.png",fileframe));
if(fileframe<fileframe1-1){
img->WriteImage(Form("/afs/psi/project/mythen/Marco/Pics/Fe_Raw3_%d.gif+200",fileframe1-fileframe0));
}else{
img->WriteImage(Form("/afs/psi/project/mythen/Marco/Pics/Fe_Raw3_%d.gif++200++",fileframe1-fileframe0));
}
}
return;
}
/*********************************************************************/
TProfile2D * GetHitMap(TTree * treein, int framen,double zlow, double zup){
TProfile2D* map = new TProfile2D("map","",400,-0.5,399.5,400,-0.5,399.5,zlow,zup);
int x, y, iFrame;
double data[9];
TBranch * b_x = (TBranch*)treein->GetBranch("x");
TBranch * b_y = (TBranch*)treein->GetBranch("y");
TBranch * b_data = (TBranch*)treein->GetBranch("data");
TBranch * b_iFrame = (TBranch*)treein->GetBranch("iFrame");
b_x->SetAddress(&x);
b_y->SetAddress(&y);
b_data->SetAddress(data);
b_iFrame->SetAddress(&iFrame);
Int_t nEnt=treein->GetEntries();
for(Int_t i=0; i<nEnt; i++){
b_iFrame->GetEntry(i);
if(iFrame==framen){
b_x->GetEntry(i);
b_y->GetEntry(i);
b_data->GetEntry(i);
map->SetBinEntries(map->FindFixBin(x-1,y-1),1);
map->SetBinEntries(map->FindFixBin(x,y-1),1);
map->SetBinEntries(map->FindFixBin(x+1,y-1),1);
map->SetBinEntries(map->FindFixBin(x-1,y),1);
map->SetBinEntries(map->FindFixBin(x,y),1);
map->SetBinEntries(map->FindFixBin(x+1,y),1);
map->SetBinEntries(map->FindFixBin(x-1,y+1),1);
map->SetBinEntries(map->FindFixBin(x,y+1),1);
map->SetBinEntries(map->FindFixBin(x+1,y+1),1);
map->SetBinContent(map->FindFixBin(x-1,y-1),data[0]);
map->SetBinContent(map->FindFixBin(x,y-1),data[1]);
map->SetBinContent(map->FindFixBin(x+1,y-1),data[2]);
map->SetBinContent(map->FindFixBin(x-1,y),data[3]);
map->SetBinContent(map->FindFixBin(x,y),data[4]);
map->SetBinContent(map->FindFixBin(x+1,y),data[5]);
map->SetBinContent(map->FindFixBin(x-1,y+1),data[6]);
map->SetBinContent(map->FindFixBin(x,y+1),data[7]);
map->SetBinContent(map->FindFixBin(x+1,y+1),data[8]);
}
}
return map;
}
/*********************************************************/
/** creates an infinitely looping gif from clustered data
**/
void PlotClusterHitMapGif(std::string filename, std::string treename,int framen0,int framen1){
TFile * fin = new TFile(filename.c_str(),"read");
TTree * treein = (TTree*)fin->Get(treename.c_str());
TCanvas * c1 = NULL;
TProfile2D* hmap = NULL;
TImage * img = NULL;
for(int framen=framen0; framen<framen1; framen++){
delete c1;
c1 = new TCanvas("c1","",800,600);
c1->cd();
// c1->SetLogz();
hmap=GetHitMap(treein,framen,-50.,1300.);
hmap->SetName(Form("Frame_%d",framen));
hmap->SetTitle(Form("Frame_%d",framen));
hmap->GetXaxis()->SetRangeUser(0,50);
hmap->GetXaxis()->SetTitle("Column");
hmap->GetYaxis()->SetRangeUser(240,290);
hmap->GetYaxis()->SetTitle("Row");
hmap->GetZaxis()->SetRangeUser(-50.,1300.);
hmap->SetStats(kFALSE);
hmap->Draw("colz");
c1->Print(Form("/afs/psi/project/mythen/Marco/Pics/Fe_Cluster3_%d.png",framen));
img = TImage::Open(Form("/afs/psi/project/mythen/Marco/Pics/Fe_Cluster3_%d.png",framen));
if(framen<framen1-1){
img->WriteImage(Form("/afs/psi/project/mythen/Marco/Pics/Fe_Cluster3_%d.gif+200",framen1-framen0));
}else{
img->WriteImage(Form("/afs/psi/project/mythen/Marco/Pics/Fe_Cluster3_%d.gif++200++",framen1-framen0));
}
}
return;
}

View File

@ -1,866 +0,0 @@
#ifndef ANALOGDETECTOR_H
#define ANALOGDETECTOR_H
//#include <mutex>
#include <pthread.h>
#include "slsDetectorData.h"
#include "pedestalSubtraction.h"
#include "commonModeSubtraction.h"
#include "tiffIO.h"
using namespace std;
#ifndef FRAMEMODE_DEF
#define FRAMEMODE_DEF
/**
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 };
#endif
template <class dataType> class analogDetector {
/** @short class to perform pedestal subtraction etc. for an analog detector */
public:
/**
Constructor (no error checking if datasize and offsets are compatible!)
\param d detector data structure to be used - if null it is assumed that the data are in ordered ip=iy*nx+ix
\param sign is the sign of the data
\param nped number of samples for pedestal averaging
\param cm common mode subtraction algorithm, if any. Defaults to NULL i.e. none
\param nnx detector size in x - must be specified if no data structure is defined, otherwise defaults to the size of the data structure.
\param nny detector size in y - must be specified if no data structure is defined, otherwise defaults to the size of the data structure.
\param gm pointer to tha gain map matrix
*/
analogDetector(slsDetectorData<dataType> *d, int sign=1,
commonModeSubtraction *cm=NULL, int nped=1000, int nnx=-1, int nny=-1, double *gm=NULL) : det(d), nx(nnx), ny(nny), stat(NULL), cmSub(cm), iframe(-1), dataSign(sign), gmap(gm), id(0) {
if (det)
det->getDetectorSize(nx,ny);
stat=new pedestalSubtraction*[ny];
for (int i=0; i<ny; i++) {
stat[i]=new pedestalSubtraction[nx];
for (int ix=0; ix<nx; ix++) {
stat[i][ix].SetNPedestals(nped);
}
}
image=new int[nx*ny];
xmin=0;
xmax=nx;
ymin=0;
ymax=ny;
fMode=ePedestal;
thr=0;
myFile=NULL;
fm=new pthread_mutex_t ;
};
/**
destructor. Deletes the pdestalSubtraction array and the image
*/
virtual ~analogDetector() {for (int i=0; i<ny; i++) delete [] stat[i]; delete [] stat; delete [] image;};
/**
constructor cloning another analog detector
\param orig analog Detector structure to be cloned
*/
analogDetector(analogDetector* orig) {
/* copy construction from orig*/
det=orig->det;
nx=orig->nx;
ny=orig->ny;
dataSign=orig->dataSign;
iframe=orig->iframe;
gmap=orig->gmap;
cmSub=orig->cmSub;
id=orig->id;
xmin=orig->xmin;
xmax=orig->xmax;
ymin=orig->ymin;
ymax=orig->ymax;
thr=orig->thr;
// nSigma=orig->nSigma;
fMode=orig->fMode;
myFile=orig->myFile;
fm=orig->fm;
stat=new pedestalSubtraction*[ny];
for (int i=0; i<ny; i++) {
stat[i]=new pedestalSubtraction[nx];
}
int nped=orig->SetNPedestals();
//cout << nped << " " << orig->getPedestal(ix,iy) << orig->getPedestalRMS(ix,iy) << endl;
for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) {
stat[iy][ix].SetNPedestals(nped);
setPedestal(ix,iy,orig->getPedestal(ix,iy),orig->getPedestalRMS(ix,iy),orig->GetNPedestals(ix,iy));
}
}
image=new int[nx*ny];
}
/**
clone. Must be virtual!
\returns a clone of the original analog detector
*/
virtual analogDetector *Clone() {
return new analogDetector(this);
}
/**
Gives an id to the structure. For debugging purposes in case of multithreading.
\param i is to be set
\returns current id
*/
int setId(int i){id=i; return id;};
/**
Returns id of the structure. For debugging purposes in case of multithreading.
\returns current id
*/
int getId() {return id; };
/**
Returns data size of the detector data structure
\returns data size of the detector data structurein bytes
*/
int getDataSize(){return det->getDataSize();};
/**
Returns data size of the detector image matrix
\param nnx reference to image size in x
\param nny reference to image size in y
\param nns reference to number of subpixels for interpolating detector, will always be 1 in this case
\returns number of pixels of the detector image
*/
virtual int getImageSize(int &nnx, int &nny, int &nns){nnx=nx; nny=ny; nns=1; return nx*ny;};
/**
Returns data size of the detector image matrix
\param nnx reference to pixel size in x
\param nny reference to pixel size in y
\returns number of pixels of the detector image
*/
virtual int getDetectorSize(int &nnx, int &nny){nnx=nx; nny=ny; return nx*ny;};
/**
set gain map
\param gm pointer to gain map matrix to be set - NULL unsets
\returns pointer to current gain map
*/
double *setGainMap(double *gm) {gmap=gm; return gmap;};
/**
return gain map
\returns pointer to current gain map
*/
double *getGainMap() {return gmap;};
/**
reads a 32 bit tiff file of the size of the detector and sets its values as gain map for the detector. If file does not exist returns NULL, but does not change gainmap compared to previous settings.
\param imgname complete name of the file containing the gain map data
\returns pointer to current gain map is file reading succeeded, NULL is file reading didn't work.
*/
double *readGainMap(const char * imgname) {
uint32 nnx, nny;
float *gm=ReadFromTiff( imgname, nny, nnx);
if (gm) {
if (gmap) delete [] gmap;
gmap=new double[nnx*nny];
for (int ix=0; ix<nnx; ix++) {
for (int iy=0; iy<nny; iy++) {
gmap[iy*nnx+ix]=gm[iy*nnx+ix];
}
}
return gmap;
}
return NULL;
}
/**
writes a 32 bit tiff file of the size of the detector and contaning the gain map value, if any. If file doesn'e exist or gainmap is undefined, does not do anything.
\param imgname complete name of the file to be written
\returns NULL if file writing didn't succeed, else a pointer
*/
void *writeGainMap(const char * imgname) {
float *gm=NULL;
void *ret;
if (gmap) {
gm=new float[nx*ny];
for (int ix=0; ix<nx; ix++) {
for (int iy=0; iy<ny; iy++) {
gm[iy*nx+ix]=gmap[iy*nx+ix];
}
}
ret=WriteToTiff(gm, imgname, ny, nx);
delete [] gm;
}
return ret;
}
/** resets the pedestalSubtraction array, the commonModeSubtraction and the image data*/
virtual void newDataSet(){
iframe=-1;
for (int iy=0; iy<ny; iy++)
for (int ix=0; ix<nx; ix++) {
stat[iy][ix].Clear();
image[iy*nx+ix]=0;
}
if (cmSub) cmSub->Clear();
};
/** resets the commonModeSubtraction and increases the frame index */
virtual void newFrame(){iframe++; if (cmSub) cmSub->newFrame();};
/** sets the commonModeSubtraction algorithm to be used
\param cm commonModeSubtraction algorithm to be used (NULL unsets)
\returns pointer to the actual common mode subtraction algorithm
*/
commonModeSubtraction *setCommonModeSubtraction(commonModeSubtraction *cm) {cmSub=cm; return cmSub;};
/**
gets the commonModeSubtraction algorithm to be used
\returns pointer to the actual common mode subtraction algorithm
*/
commonModeSubtraction *getCommonModeSubtraction() {return cmSub;};
/**
sets the sign of the data
\param sign 1 means positive values for photons, -1 negative, 0 gets
\returns current sign for the data
*/
int setDataSign(int sign=0) {if (sign==1 || sign==-1) dataSign=sign; return dataSign;};
/**
adds value to pedestal (and common mode) for the given pixel
\param val value to be added
\param ix pixel x coordinate
\param iy pixel y coordinate
\param cm 1 adds the value to common mod, 0 skips it. Defaults to 0. - not properly implemented
*/
virtual void addToPedestal(double val, int ix, int iy=0){
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
stat[iy][ix].addToPedestal(val);
if (cmSub) {
if (det) if (det->isGood(ix, iy)==0) return;
cmSub->addToCommonMode(val, ix, iy);
};
};
}
/**
gets pedestal (and common mode)
\param ix pixel x coordinate
\param iy pixel y coordinate
\param cm 0 (default) without common mode subtraction, 1 with common mode subtraction (if defined)
\returns pedestal value
*/
virtual double getPedestal(int ix, int iy, int cm=0){if (ix>=0 && ix<nx && iy>=0 && iy<ny) if (cmSub && cm>0) return stat[iy][ix].getPedestal()-cmSub->getCommonMode(); else return stat[iy][ix].getPedestal(); else return -1;};
/**
gets pedestal rms (i.e. noise)
\param ix pixel x coordinate
\param iy pixel y coordinate
\returns pedestal rms
*/
virtual double getPedestalRMS(int ix, int iy){if (ix>=0 && ix<nx && iy>=0 && iy<ny) return stat[iy][ix].getPedestalRMS();else return -1;};
/**
gets pedestal (and common mode)
\param ix pixel x coordinate
\param iy pixel y coordinate
\param cm 0 (default) without common mode subtraction, 1 with common mode subtraction (if defined)
\returns pedestal value
*/
virtual double* getPedestal(double *ped){
if (ped==NULL)
ped=new double[nx*ny];
for (int ix=0; ix<nx; ix++) {
for (int iy=0; iy<ny; iy++) {
ped[iy*nx+ix]=stat[iy][ix].getPedestal();
}
}
return ped;
};
/**
gets pedestal rms (i.e. noise)
\param ix pixel x coordinate
\param iy pixel y coordinate
\returns pedestal rms
*/
virtual double* getPedestalRMS(double *ped=NULL){
if (ped==NULL)
ped=new double[nx*ny];
for (int ix=0; ix<nx; ix++) {
for (int iy=0; iy<ny; iy++) {
ped[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
}
}
return ped;
};
/**
sets pedestal
\param ix pixel x coordinate
\param iy pixel y coordinate
\param val value to set
\param rms rms to be set if any, defaults to 0
\param m number of pedestal samples to be set or the moving stat structure is any, defaults to 0
*/
virtual void setPedestal(int ix, int iy, double val, double rms=0, int m=-1){if (ix>=0 && ix<nx && iy>=0 && iy<ny) stat[iy][ix].setPedestal(val,rms, m);};
/**
sets pedestal
\param ix pixel x coordinate
\param iy pixel y coordinate
\param val value to set
\param rms rms to be set if any, defaults to 0
\param m number of pedestal samples to be set or the moving stat structure is any, defaults to 0
*/
virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){
double rr=0;
for (int ix=xmin; ix<xmax; ix++) {
for (int iy=ymin; iy<ymax; iy++) {
if (rms) rr=rms[iy*nx+ix];
stat[iy][ix].setPedestal(ped[iy*nx+ix],rr, m);
};
};
}
/**
sets pedestal rms
\param ix pixel x coordinate
\param iy pixel y coordinate
\param rms value to set
*/
virtual void setPedestalRMS(int ix, int iy, double rms=0){if (ix>=0 && ix<nx && iy>=0 && iy<ny) stat[iy][ix].setPedestalRMS(rms);};
/**
sets pedestal rms for all pixels
\param rms pointer to array of pedestal rms
*/
virtual void setPedestalRMS(double *rms){
for (int ix=xmin; ix<xmax; ix++) {
for (int iy=ymin; iy<ymax; iy++) {
stat[iy][ix].setPedestalRMS(rms[iy*nx+ix]);
};
};
}
/**
write 32bit tiff file with detector image data
\param imgname file name to be written
\returns NULL if file writing didn't succed, otherwise a pointer
*/
virtual void *writeImage(const char * imgname) {
float *gm=NULL;
void *ret;
gm=new float[nx*ny];
for (int ix=0; ix<nx; ix++) {
for (int iy=0; iy<ny; iy++) {
gm[iy*nx+ix]=image[iy*nx+ix];
}
}
ret=WriteToTiff(gm, imgname, ny, nx);
delete [] gm;
return ret;
}
/**
write 32bit tiff file containing the pedestals
\param imgname file name to be written
\returns NULL if file writing didn't succed, otherwise a pointer
*/
virtual void *writePedestals(const char * imgname) {
float *gm=NULL;
void *ret;
gm=new float[nx*ny];
for (int ix=0; ix<nx; ix++) {
for (int iy=0; iy<ny; iy++) {
if (cmSub)
gm[iy*nx+ix]=stat[iy][ix].getPedestal()-cmSub->getCommonMode();
else
gm[iy*nx+ix]=stat[iy][ix].getPedestal();
}
}
ret=WriteToTiff(gm, imgname, ny, nx);
delete [] gm;
return ret;
}
/**
read 32bit tiff file containing the pedestals
\param imgname file name to be read
\returns 0 if file reading didn't succed, otherwise 1
*/
int readPedestals(const char * imgname) {
uint32 nnx, nny;
float *gm=ReadFromTiff( imgname, nny, nnx);
if (nnx>nx) nnx=nx;
if (nny>ny) nny=ny;
if (gm) {
for (int ix=0; ix<nnx; ix++) {
for (int iy=0; iy<nny; iy++) {
stat[iy][ix].setPedestal(gm[iy*nx+ix],-1,-1);
}
}
delete [] gm;
return 1;
}
return NULL;
}
/**
read 32bit tiff file containing the image data
\param imgname file name to be read
\returns 0 if file reading didn't succed, otherwise 1
*/
int readImage(const char * imgname) {
uint32 nnx, nny;
float *gm=ReadFromTiff( imgname, nny, nnx);
if (nnx>nx) nnx=nx;
if (nny>ny) nny=ny;
if (gm) {
for (int ix=0; ix<nnx; ix++) {
for (int iy=0; iy<nny; iy++) {
image[iy*nx+ix]=gm[iy*nx+ix];
}
}
delete [] gm;
return 1;
}
return NULL;
}
/**
returns pointer to image data
\returns pointer to image data
*/
virtual int *getImage(){return image;};
/**
write 32bit tiff file containing the pedestals RMS
\param imgname file name to be written
\returns NULL if file writing didn't succed, otherwise a pointer
*/
void *writePedestalRMS(const char * imgname) {
float *gm=NULL;
void *ret;
gm=new float[nx*ny];
for (int ix=0; ix<nx; ix++) {
for (int iy=0; iy<ny; iy++) {
gm[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
}
}
ret=WriteToTiff(gm, imgname, ny, nx);
delete [] gm;
return ret;
}
/**
read 32bit tiff file containing the pedestals RMS
\param imgname file name to be read
\returns 0 if file reading didn't succed, otherwise 1
*/
int readPedestalRMS(const char * imgname) {
uint32 nnx, nny;
float *gm=ReadFromTiff( imgname, nny, nnx);
if (nnx>nx) nnx=nx;
if (nny>ny) nny=ny;
if (gm) {
for (int ix=0; ix<nnx; ix++) {
for (int iy=0; iy<nny; iy++) {
stat[iy][ix].setPedestalRMS(gm[iy*nx+ix]);
}
}
delete [] gm;
return 1;
}
return 0;
}
/**
Adds all the data for each pixels in the selected region of interest to the pedestal
\param data pointer to the data
*/
virtual void addToPedestal(char *data) {
newFrame();
for (int ix=xmin; ix<xmax; ix++) {
for (int iy=ymin; iy<ymax; iy++) {
addToPedestal(data,ix,iy);
}
}
return ;
};
/**
Sets region of interest in which data should be processed
\param xmi minimum x. if -1 or out of range remains unchanged
\param xma maximum x. if -1 or out of range remains unchanged
\param ymi minimum y. if -1 or out of range remains unchanged
\param yma maximum y. if -1 or out of range remains unchanged
*/
void setROI(int xmi=-1, int xma=-1, int ymi=-1, int yma=-1) {
if (xmi>=0 && xmi<=nx) xmin=xmi;
if (xma>=0 && xma<=nx) xmax=xma;
if (xmax<xmin) {
xmi=xmin;
xmin=xmax;
xmax=xmi;
}
if (ymi>=0 && ymi<=ny) ymin=ymi;
if (yma>=0 && yma<=ny) ymax=yma;
if (ymax<ymin) {
ymi=ymin;
ymin=ymax;
ymax=ymi;
}
};
/**
Gets region of interest in which data are processed
\param xmi reference to minimum x.
\param xma reference to maximum x.
\param ymi reference to minimum y.
\param yma reference to maximum y.
*/
void getROI(int &xmi, int &xma, int &ymi, int &yma) {xmi=xmin; xma=xmax; ymi=ymin; yma=ymax;};
/**
Adds all the data for the selected pixel to the pedestal
\param data pointer to the data
\param ix pixel x coordinate
\param iy pixel y coordinate
*/
virtual void addToPedestal(char *data, int ix, int iy=0) {
double val;
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
if (det)
val=dataSign*det->getValue(data, ix, iy);
else
val=((double*)data)[iy*nx+ix];
addToPedestal(val,ix,iy);
}
return ;
};
/**
Subtracts pedestal from the data array in the region of interest
\param data pointer to the data
\param val pointer where the pedestal subtracted data should be added. If NULL, the internal image is used
\returns pointer to the pedestal subtracted data
*/
virtual double *subtractPedestal(char *data, double *val=NULL) {
newFrame();
if (val==NULL)
val=new double[nx*ny];
for (int ix=xmin; ix<xmax; ix++) {
for (int iy=ymin; iy<ymax; iy++) {
val[iy*nx+ix]+=subtractPedestal(data, ix, iy);
}
}
return val;
};
/**
Subtracts pedestal from the data for a selected pixel
\param data pointer to the data
\param ix pixel x coordinate
\param iy pixel y coordinate
\returns pedestal subtracted value
*/
virtual double subtractPedestal(char *data, int ix, int iy=0) {
double g=1.;
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
if (gmap) {
g=gmap[iy*nx+ix];
if (g==0) g=-1.;
}
if (det)
return (dataSign*det->getValue(data, ix, iy)-getPedestal(ix,iy))/g;
else
return (((double*)data)[iy*nx+ix]-getPedestal(ix,iy))/g;
}
};
/**
sets threshold value for conversion into number of photons
\param t threshold to be set
\returns threshold value
*/
double setThreshold(double t){thr=t; return thr;};
/**
gets threshold value for conversion into number of photons
\returns threshold value
*/
double getThreshold(){return thr;};
/**
converts the data into number of photons for the selected pixel
\param data pointer to the data
\param ix pixel x coordinate
\param iy pixel y coordinate
\returns converted number of photons. If no threshold is set, returns gain converted pedestal subtracted data.
*/
virtual int getNPhotons(char *data, int ix, int iy=0) {
int nph=0;
double v;
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
v=subtractPedestal(data,ix,iy);
if (thr>0) {
v+=0.5*thr;
nph=v/thr;
return nph;
} else
return v;
}
return 0;
};
/**
converts the data into number of photons for all pixels
\param data pointer to the data
\param nph pointer where the photons should added. If NULL,the internal image is used
\returns pointer to array containing the number of photons
*/
int *getNPhotons(char *data, int *nph=NULL) {
double val;
if (nph==NULL)
nph=image;
newFrame();
for (int ix=xmin; ix<xmax; ix++) {
for (int iy=ymin; iy<ymax; iy++) {
nph[iy*nx+ix]+=getNPhotons(data, ix, iy);
}
}
return nph;
}
/**
clears the image array
*/
virtual void clearImage(){
for (int ix=0; ix<nx; ix++) {
for (int iy=0; iy<ny; iy++) {
image[iy*nx+ix]=0;
}
}
};
/** sets/gets number of samples for moving average pedestal calculation
\param i number of samples to be set (0 or negative gets)
\returns actual number of samples
*/
int SetNPedestals(int i=-1) {
int ix=0, iy=0;
if (i>0)
for (ix=0; ix<nx; ix++)
for (iy=0; iy<ny; iy++)
stat[iy][ix].SetNPedestals(i);
return stat[0][0].SetNPedestals();
};
/** gets number of samples for moving average pedestal calculation
\returns actual number of samples
*/
int GetNPedestals(int ix, int iy) {
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
return stat[iy][ix].GetNPedestals();
else
return -1;
};
/** calculates the sum of photons in the specified region of interest.
\param data pointer to the data
\param xmi minimum x for the calculation. If -1 the minimum x of the predefined region of interest is used
\param xma maximum x for the calculation. If -1 the maximum x of the predefined region of interest is used
\param ymi minimum y for the calculation. If -1 the minimum y of the predefined region of interest is used
\param yma maximum y for the calculation. If -1 the maximum y of the predefined region of interest is used
\returns total number of photons in
*/
virtual int getTotalNumberOfPhotons(char *data, int xmi=-1, int xma=-1, int ymi=-1, int yma=-1) {
int val=0;
if (xmi<0) xmi=xmin;
if (xma<0) xma=xmax;
if (ymi<0) ymi=ymin;
if (yma<0) yma=ymax;
for (int ix=xmi; ix<xma; ix++)
for (int iy=ymi; iy<yma; iy++)
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
val+=getNPhotons(data, ix, iy);
return val;
};
/**
calculates the image converted into number of photons. If the frame mode is pedestal, it also it to the pdedestal subtraction.
\param data pointer to the data to be processed
\param val pointer of the data to be added to. If NULL, the internal image will be used
\param pointer to the processed data
\returns
*/
virtual void processData(char *data,int *val=NULL) {
switch(fMode) {
case ePedestal:
addToPedestal(data);
break;
default:
getNPhotons(data,val);
}
};
virtual char *getInterpolation(){return NULL;};
/** sets the current frame mode for the detector
\param f frame mode to be set
\returns current frame mode
*/
frameMode setFrameMode(frameMode f) {fMode=f; return fMode;};
/** gets the current frame mode for the detector
\returns current frame mode
*/
frameMode getFrameMode() {return fMode;};
/** sets file pointer where to write the clusters to
\param f file pointer
\returns current file pointer
*/
FILE *setFilePointer(FILE *f){myFile=f; return myFile;};
/** gets file pointer where to write the clusters to
\returns current file pointer
*/
FILE *getFilePointer(){return myFile;};
void setMutex(pthread_mutex_t *m){fm=m;};
protected:
slsDetectorData<dataType> *det; /**< slsDetectorData to be used */
int nx; /**< Size of the detector in x direction */
int ny; /**< Size of the detector in y direction */
pedestalSubtraction **stat; /**< pedestalSubtraction class */
commonModeSubtraction *cmSub;/**< commonModeSubtraction class */
int dataSign; /**< sign of the data i.e. 1 if photon is positive, -1 if negative */
int iframe; /**< frame number (not from file but incremented within the dataset every time newFrame is called */
double *gmap;
int *image;
int id;
//int xmin, xmax, ymin, ymax; int xmin; /**< minimum x of the region of interest */
int xmin; /**< minimum x of the region of interest */
int xmax; /**< maximum x of the region of interest */
int ymin;/**< minimum y of the region of interest */
int ymax;/**< maximum y of the region of interest */
double thr; /**< threshold to be used for conversion into number of photons */
// int nSigma; /**< number of sigma to be used for conversion into number of photons if threshold is undefined */
frameMode fMode; /**< current detector frame mode */
FILE *myFile; /**< file pointer to write to */
pthread_mutex_t *fm;
};
#endif

View File

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

View File

@ -1,170 +0,0 @@
#ifndef GOTTHARDMODULEDATANEW_H
#define GOTTHARDMODULEDATANEW_H
#include "slsDetectorData.h"
typedef struct {
uint64_t frameNumber; /**< is the frame number */
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
uint32_t packetNumber; /**< is the packet number */
uint64_t bunchId; /**< is the bunch id from beamline */
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
uint32_t debug; /**< is for debugging purposes */
uint16_t roundRNumber; /**< is the round robin set number */
uint8_t detType; /**< is the detector type see :: detectorType */
uint8_t version; /**< is the version number of this structure format */
} sls_detector_header;
class gotthardModuleDataNew : public slsDetectorData<uint16_t> {
private:
int iframe;
const int offset;
public:
/**
Implements the slsReceiverData structure for the gotthard read out by a module i.e. using the slsReceiver
(1x1280 pixels, 2 packets 1286 large etc.)
\param c crosstalk parameter for the output buffer
*/
gotthardModuleDataNew(int off=24*2, int nch=1280): slsDetectorData<uint16_t>(nch, 1, nch*2+off), offset(off) {
uint16_t **dMask;
int **dMap;
int ix, iy;
int ypixels=1;
int xpixels=nch;
dMask=new uint16_t*[1];
dMap=new int*[1];
dMap[0] = new int[nch];
dMask[0] = new uint16_t[nch];
for(int ix=0; ix<xpixels; ix++) {
dMap[0][ix] = 2*ix+offset;
dMask[0][ix] = 0x0;
}
setDataMap(dMap);
setDataMask(dMask);
};
/**
Returns the frame number for the given dataset.
\param buff pointer to the dataset
\returns frame number
*/
int getFrameNumber(char *buff){if (offset>=sizeof(sls_detector_header)) return ((sls_detector_header*)buff)->frameNumber; return iframe;};//*((int*)(buff+5))&0xffffff;};
/**
gets the packets number (last packet is labelled with 0 and is replaced with 40)
\param buff pointer to the memory
\returns packet number
*/
int getPacketNumber(char *buff){if (offset>=sizeof(sls_detector_header))return ((sls_detector_header*)buff)->packetNumber;};
/**
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
\param data pointer to the memory to be analyzed
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
\param dsize size of the memory slot to be analyzed
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
*/
virtual char *findNextFrame(char *data, int &ndata, int dsize){
if (dsize<dataSize) ndata=dsize;
else ndata=dataSize;
return data;
}
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int &ff) {
int np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
char *data=new char[dataSize];
char *d=readNextFrame(filebin, ff, np, data);
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
np=0;
int pn;
// cout << dataSize << endl;
if (ff>=0)
fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, dataSize) ){
ff=getFrameNumber(data);
np=getPacketNumber(data);
return data;
}
}
return NULL;
};
};
#endif

View File

@ -1,158 +0,0 @@
#ifndef MOENCH03T1CTBDATA_H
#define MOENCH03T1CTBDATA_H
#include "slsDetectorData.h"
class moench03T1CtbData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
int sc_height;
public:
/**
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
(160x160 pixels, 40 packets 1286 large etc.)
\param c crosstalk parameter for the output buffer
*/
moench03T1CtbData(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*2*32, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) {
int adc_nr[32]={300,325,350,375,300,325,350,375, \
200,225,250,275,200,225,250,275,\
100,125,150,175,100,125,150,175,\
0,25,50,75,0,25,50,75};
int row, col;
int isample;
int iadc;
int ix, iy;
for (iadc=0; iadc<nadc; iadc++) {
for (int i=0; i<sc_width*sc_height; i++) {
col=adc_nr[iadc]+(i%sc_width);
if (iadc<16) {
row=199-i/sc_width;
} else {
row=200+i/sc_width;
}
dataMap[row][col]=(nadc*i+iadc)*2;
if (dataMap[row][col]<0 || dataMap[row][col]>=2*400*400)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
int adc4;
for (int i=0; i<nx*ny; i++) {
isample=i/nadc;
iadc=i%nadc;
ix=isample%sc_width;
iy=isample/sc_width;
adc4 = (int)iadc/4;
// if (iadc<(nadc/2)) {
if (adc4%2==0) {
xmap[i]=adc_nr[iadc]+ix;
ymap[i]=ny/2-1-iy;
} else {
xmap[i]=adc_nr[iadc]+ix;
ymap[i]=ny/2+iy;
}
}
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
*/
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 << "-" << endl;
return (char*)afifo_cont;
} else {
delete [] afifo_cont;
return NULL;
}
}
return NULL;
};
};
#endif

View File

@ -1,285 +0,0 @@
#ifndef MOENCH03T1ZMQDATA_H
#define MOENCH03T1ZMQDATA_H
#include "slsDetectorData.h"
/**
@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 moench03T1ReceiverData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
int sc_height;
const int nPackets; /**<number of UDP packets constituting one frame */
const int packetSize; /**< size of a udp packet */
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
*/
moench03T1ReceiverData(int npackets=40, int ps=8192): slsDetectorData<uint16_t>(400, 400, ps*npackets+sizeof(sls_detector_header)), packetSize(ps), nPackets(npackets) {
int nadc=32;
int sc_width=25;
int sc_height=200;
int adc_nr[32]={300,325,350,375,300,325,350,375, \
200,225,250,275,200,225,250,275,\
100,125,150,175,100,125,150,175,\
0,25,50,75,0,25,50,75};
int row, col;
int isample;
int iadc;
int ix, iy;
// int npackets=40;
int i;
int adc4(0);
for (int ip=0; ip<npackets; ip++) {
for (int is=0; is<128; is++) {
for (iadc=0; iadc<nadc; iadc++) {
i=128*ip+is;
adc4=(int)iadc/4;
if (i<sc_width*sc_height) {
// for (int i=0; i<sc_width*sc_height; i++) {
col=adc_nr[iadc]+(i%sc_width);
if (adc4%2==0) {
row=199-i/sc_width;
} else {
row=200+i/sc_width;
}
dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
if (dataMap[row][col]<0 || dataMap[row][col]>=8192*40)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
}
int ipacket;
int ibyte;
int ii=0;
for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){
xmap[ibyte]=-1;
ymap[ibyte]=-1;
}
int off=sizeof(sls_detector_header)/2;
for (ipacket=0; ipacket<npackets; ipacket++) {
for (ibyte=0; ibyte< 8192/2; ibyte++) {
i=ipacket*8208/2+ibyte;
isample=ii/nadc;
iadc=ii%nadc;
adc4 = (int)iadc/4;
ix=isample%sc_width;
iy=isample/sc_width;
if (adc4%2==0) {
xmap[i+off]=adc_nr[iadc]+ix;
ymap[i+off]=ny/2-1-iy;
} else {
xmap[i+off]=adc_nr[iadc]+ix;
ymap[i+off]=ny/2+iy;
}
ii++;
// }
}
}
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){((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
/* /\** */
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
/* \param data pointer to the memory to be analyzed */
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
/* \param dsize size of the memory slot to be analyzed */
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
/* *\/ */
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
/* /\** */
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
/* \param filebin input file stream (binary) */
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
/* *\/ */
/* virtual char *readNextFrame(ifstream &filebin){ */
/* // int afifo_length=0; */
/* uint16_t *afifo_cont; */
/* int ib=0; */
/* if (filebin.is_open()) { */
/* afifo_cont=new uint16_t[dataSize/2]; */
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
/* ib+=2; */
/* if (ib==dataSize) break; */
/* } */
/* if (ib>0) { */
/* iframe++; */
/* // cout << ib << "-" << endl; */
/* return (char*)afifo_cont; */
/* } else { */
/* delete [] afifo_cont; */
/* return NULL; */
/* } */
/* } */
/* return NULL; */
/* }; */
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int &ff) {
int np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
char *data=new char[dataSize];
char *d=readNextFrame(filebin, ff, np, data);
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
np=0;
int pn;
// cout << dataSize << endl;
if (ff>=0)
fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, dataSize) ){
ff=getFrameNumber(data);
np=getPacketNumber(data);
return data;
}
}
return NULL;
};
/**
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
\param data pointer to the memory to be analyzed
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
\param dsize size of the memory slot to be analyzed
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
*/
virtual char *findNextFrame(char *data, int &ndata, int dsize){
if (dsize<dataSize) ndata=dsize;
else ndata=dataSize;
return data;
}
int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
};
#endif

View File

@ -1,285 +0,0 @@
#ifndef MOENCH03T1RECDATANEW_H
#define MOENCH03T1RECDATANEW_H
#include "slsDetectorData.h"
/**
@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
*/
moench03T1ReceiverDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*2*32+sizeof(sls_detector_header)), nSamples(ns) {
int nadc=32;
int sc_width=25;
int sc_height=200;
int adc_nr[32]={300,325,350,375,300,325,350,375, \
200,225,250,275,200,225,250,275,\
100,125,150,175,100,125,150,175,\
0,25,50,75,0,25,50,75};
int row, col;
int isample;
int iadc;
int ix, iy;
int npackets=40;
int i;
int adc4(0);
for (int ip=0; ip<npackets; ip++) {
for (int is=0; is<128; is++) {
for (iadc=0; iadc<nadc; iadc++) {
i=128*ip+is;
adc4=(int)iadc/4;
if (i<sc_width*sc_height) {
// for (int i=0; i<sc_width*sc_height; i++) {
col=adc_nr[iadc]+(i%sc_width);
if (adc4%2==0) {
row=199-i/sc_width;
} else {
row=200+i/sc_width;
}
dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
if (dataMap[row][col]<0 || dataMap[row][col]>=nSamples*2*32)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
}
int ipacket;
int ibyte;
int ii=0;
for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){
xmap[ibyte]=-1;
ymap[ibyte]=-1;
}
int off=sizeof(sls_detector_header)/2;
for (ipacket=0; ipacket<npackets; ipacket++) {
for (ibyte=0; ibyte< 8192/2; ibyte++) {
i=ipacket*8208/2+ibyte;
isample=ii/nadc;
if (isample<nSamples) {
iadc=ii%nadc;
adc4 = (int)iadc/4;
ix=isample%sc_width;
iy=isample/sc_width;
if (adc4%2==0) {
xmap[i+off]=adc_nr[iadc]+ix;
ymap[i+off]=ny/2-1-iy;
} else {
xmap[i+off]=adc_nr[iadc]+ix;
ymap[i+off]=ny/2+iy;
}
}
ii++;
// }
}
}
iframe=0;
// cout << "data struct created" << endl;
};
/**
Returns the frame number for the given dataset. Purely virtual func.
\param buff pointer to the dataset
\returns frame number
*/
/* class jfrau_packet_header_t { */
/* public: */
/* unsigned char reserved[4]; */
/* unsigned char packetNumber[1]; */
/* unsigned char frameNumber[3]; */
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff){return ((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
/**
Returns the packet number for the given dataset. purely virtual func
\param buff pointer to the dataset
\returns packet number number
*/
int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
/* /\** */
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
/* \param data pointer to the memory to be analyzed */
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
/* \param dsize size of the memory slot to be analyzed */
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
/* *\/ */
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
/* /\** */
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
/* \param filebin input file stream (binary) */
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
/* *\/ */
/* virtual char *readNextFrame(ifstream &filebin){ */
/* // int afifo_length=0; */
/* uint16_t *afifo_cont; */
/* int ib=0; */
/* if (filebin.is_open()) { */
/* afifo_cont=new uint16_t[dataSize/2]; */
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
/* ib+=2; */
/* if (ib==dataSize) break; */
/* } */
/* if (ib>0) { */
/* iframe++; */
/* // cout << ib << "-" << endl; */
/* return (char*)afifo_cont; */
/* } else { */
/* delete [] afifo_cont; */
/* return NULL; */
/* } */
/* } */
/* return NULL; */
/* }; */
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int &ff) {
int np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
char *data=new char[dataSize];
char *d=readNextFrame(filebin, ff, np, data);
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
np=0;
int pn;
// cout << dataSize << endl;
if (ff>=0)
fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, dataSize) ){
ff=getFrameNumber(data);
np=getPacketNumber(data);
return data;
}
}
return NULL;
};
/**
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
\param data pointer to the memory to be analyzed
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
\param dsize size of the memory slot to be analyzed
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
*/
virtual char *findNextFrame(char *data, int &ndata, int dsize){
if (dsize<dataSize) ndata=dsize;
else ndata=dataSize;
return data;
}
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
};
#endif

View File

@ -1,268 +0,0 @@
#ifndef MOENCH03T1ZMQDATA_H
#define MOENCH03T1ZMQDATA_H
#include "slsDetectorData.h"
class moench03T1ZmqData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
int sc_height;
const int nPackets; /**<number of UDP packets constituting one frame */
const int packetSize; /**< size of a udp packet */
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
*/
moench03T1ZmqData(int npackets=40, int ps=8192): slsDetectorData<uint16_t>(400, 400, ps*npackets), packetSize(ps), nPackets(npackets) {
int nadc=32;
int sc_width=25;
int sc_height=200;
int adc_nr[32]={300,325,350,375,300,325,350,375, \
200,225,250,275,200,225,250,275,\
100,125,150,175,100,125,150,175,\
0,25,50,75,0,25,50,75};
int row, col;
int isample;
int iadc;
int ix, iy;
// int npackets=40;
int i;
int adc4(0);
for (int ip=0; ip<npackets; ip++) {
for (int is=0; is<128; is++) {
for (iadc=0; iadc<nadc; iadc++) {
i=128*ip+is;
adc4=(int)iadc/4;
if (i<sc_width*sc_height) {
// for (int i=0; i<sc_width*sc_height; i++) {
col=adc_nr[iadc]+(i%sc_width);
if (adc4%2==0) {
row=199-i/sc_width;
} else {
row=200+i/sc_width;
}
dataMap[row][col]=(nadc*i+iadc)*2;//+16*(ip+1);
if (dataMap[row][col]<0 || dataMap[row][col]>=8192*40)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
}
int ipacket;
int ibyte;
int ii=0;
for (int ipacket=0; ipacket<npackets; ipacket++) {
for (int ibyte=0; ibyte< 8192/2; ibyte++) {
i=ipacket*8208/2+ibyte;
/* if (ibyte<8) { */
/* //header! */
/* xmap[i]=-1; */
/* ymap[i]=-1; */
/* } else { */
// ii=ibyte+128*32*ipacket;
isample=ii/nadc;
iadc=ii%nadc;
adc4 = (int)iadc/4;
ix=isample%sc_width;
iy=isample/sc_width;
if (adc4%2==0) {
xmap[i]=adc_nr[iadc]+ix;
ymap[i]=ny/2-1-iy;
} else {
xmap[i]=adc_nr[iadc]+ix;
ymap[i]=ny/2+iy;
}
ii++;
// }
}
}
iframe=0;
// 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 iframe;};//*((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 0;}//((*(((int*)(buff+4))))&0xff)+1;};
/* /\** */
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
/* \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[packetSize*nPackets];
char *d=readNextFrame(filebin, ff, np, data);
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
np=0;
int pn;
if (ff>=0)
fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, packetSize*nPackets) ){
iframe++;
ff=iframe;
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<packetSize*nPackets) ndata=dsize;
else ndata=packetSize*nPackets;
return data;
}
int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
};
#endif

View File

@ -1,268 +0,0 @@
#ifndef MOENCH03T1ZMQDATANEW_H
#define MOENCH03T1ZMQDATANEW_H
#include "slsDetectorData.h"
class moench03T1ZmqDataNew : 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
*/
moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2), nSamples(ns) {
int nadc=32;
int sc_width=25;
int sc_height=200;
int adc_nr[32]={300,325,350,375,300,325,350,375, \
200,225,250,275,200,225,250,275,\
100,125,150,175,100,125,150,175,\
0,25,50,75,0,25,50,75};
int row, col;
int isample;
int iadc;
int ix, iy;
int npackets=40;
int i;
int adc4(0);
for (int ip=0; ip<npackets; ip++) {
for (int is=0; is<128; is++) {
for (iadc=0; iadc<nadc; iadc++) {
i=128*ip+is;
adc4=(int)iadc/4;
if (i<sc_width*sc_height) {
// for (int i=0; i<sc_width*sc_height; i++) {
col=adc_nr[iadc]+(i%sc_width);
if (adc4%2==0) {
row=199-i/sc_width;
} else {
row=200+i/sc_width;
}
dataMap[row][col]=(nadc*i+iadc)*2;//+16*(ip+1);
if (dataMap[row][col]<0 || dataMap[row][col]>=nSamples*2*32)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
}
int ipacket;
int ibyte;
int ii=0;
for (int ipacket=0; ipacket<npackets; ipacket++) {
for (int ibyte=0; ibyte< 8192/2; ibyte++) {
i=ipacket*8208/2+ibyte;
/* if (ibyte<8) { */
/* //header! */
/* xmap[i]=-1; */
/* ymap[i]=-1; */
/* } else { */
// ii=ibyte+128*32*ipacket;
isample=ii/nadc;
if (isample<nSamples) {
iadc=ii%nadc;
adc4 = (int)iadc/4;
ix=isample%sc_width;
iy=isample/sc_width;
if (adc4%2==0) {
xmap[i]=adc_nr[iadc]+ix;
ymap[i]=ny/2-1-iy;
} else {
xmap[i]=adc_nr[iadc]+ix;
ymap[i]=ny/2+iy;
}
}
ii++;
// }
}
}
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 iframe;};//*((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 0;}//((*(((int*)(buff+4))))&0xff)+1;};
/* /\** */
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
/* \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[32*2*nSamples];
char *d=readNextFrame(filebin, ff, np, data);
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
np=0;
int pn;
if (ff>=0)
fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, 32*2*nSamples) ){
iframe++;
ff=iframe;
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<32*2*nSamples) ndata=dsize;
else ndata=32*2*nSamples;
return data;
}
int getPacketNumber(int x, int y) {return 0;};
};
#endif

View File

@ -0,0 +1,31 @@
{
//.L moenchReadData.C
TFile *fout;
THStack *hs2N;
fout=new TFile("/scratch/outfile.root","RECREATE");
hs2N=moenchReadData("/data/moench_xbox_20140113/MoTarget_45kV_0_8mA_12us_120V_cds_g4_f00000%04d000_0.raw","dum",0,20,1500,-500,2500,1,0.,1,159,1,159, 0,1);
hs2N->SetName("cds_g4");
hs2N->SetTitle("cds_g4");
(TH2F*)(hs2N->GetHists()->At(0))->Write();
(TH2F*)(hs2N->GetHists()->At(1))->Write();
(TH2F*)(hs2N->GetHists()->At(2))->Write();
(TH2F*)(hs2N->GetHists()->At(3))->Write();
(TH2F*)(hs2N->GetHists()->At(4))->Write();
fout->Close();
}

View File

@ -2,19 +2,19 @@
#include <iomanip>
// ClassImp(EtaVEL);
ClassImp(EtaVEL);
// double Median(const TH1D * histo1) {
double Median(const TH1D * histo1) {
// int numBins = histo1->GetXaxis()->GetNbins();
// Double_t *x = new Double_t[numBins];
// Double_t* y = new Double_t[numBins];
// for (int i = 0; i < numBins; i++) {
// x[i] = histo1->GetBinCenter(i);
// y[i] = histo1->GetBinContent(i);
// }
// return TMath::Median(numBins, x, y);
// }
int numBins = histo1->GetXaxis()->GetNbins();
Double_t *x = new Double_t[numBins];
Double_t* y = new Double_t[numBins];
for (int i = 0; i < numBins; i++) {
x[i] = histo1->GetBinCenter(i);
y[i] = histo1->GetBinContent(i);
}
return TMath::Median(numBins, x, y);
}
double *EtaVEL::getPixelCorners(int x, int y){

View File

@ -0,0 +1,457 @@
TH2D *imageMacro(char *name) {
//TH2D *makeNorm(){
//TFile ff("/local_zfs_raid/tomcat_20160528/trees/img_blank_eta_gmap.root");
//TH2D *hff=(TH2D*)ff.Get("imgHR");
TFile *ff=new TFile("/mnt/moench_data/tomcat_20160528_img/img_blank_eta_nb25.root");
// TFile ff("/local_zfs_raid/tomcat_20160528/trees/img_blank_eta_gcorr_nb25.root");
TH2D *hff=(TH2D*)ff->Get("blankHR");
hff->SetName("imgBlank");
TH2D *hpixel=new TH2D("hpixel","hpixel",25,0,25,25,0,25);
for (int ibx=10*25; ibx<hff->GetNbinsX()-10*25; ibx++) {
for (int iby=20*25; iby<hff->GetNbinsY()-20*25; iby++) {
hpixel->Fill((ibx-12)%25,(iby-12)%25,hff->GetBinContent(ibx+1,iby+1));
}
}
hpixel->Scale(1./hpixel->GetBinContent(13,13));
// new TCanvas();
// hpixel->Draw("colz");
// TH2D *hraw=(TH2D*)hff->Clone("hraw");
TH2D *hpix=(TH2D*)hff->Clone("hpix");
for (int ibx=0; ibx<hff->GetNbinsX(); ibx++) {
for (int iby=0; iby<hff->GetNbinsY(); iby++) {
hpix->SetBinContent(ibx+1,iby+1,hpixel->GetBinContent(hpixel->GetXaxis()->FindBin((ibx-12)%25),hpixel->GetXaxis()->FindBin((iby-12)%25)));
}
}
// return hpix;
//}
//void imageMacro(char *name,TH2D *hpix=NULL){
// hff->Divide(hpix);
// new TCanvas();
// hff->Draw("colz");
// if (hpix==NULL)
// hpix=makeNorm();
TH2D *hg;
char nn[1000];
if (strcmp(name,"blank")==NULL) {
hg=hff;
} else {
sprintf(nn,"/mnt/moench_data/tomcat_20160528_img/img_%s_eta_nb25.root", name);
// if (strcmp(name,"blank"))
TFile *fg=new TFile(nn);
// else
// TFile fg=gDirectory;
//TFile fg("/local_zfs_raid/tomcat_20160528/trees/img_grating_1d_eta_gmap.root");
//TH2D *hg=(TH2D*)fg.Get("imgHR");
// TFile fg("/local_zfs_raid/tomcat_20160528/trees/img_grating_1d_eta_nb25.root");
// TFile fg("/local_zfs_raid/tomcat_20160528/trees/img_sample_eta_nb25.root");
// TFile fg("/local_zfs_raid/tomcat_20160528/trees/img_grating_1d_eta_gcorr_nb25.root");
sprintf(nn,"%sHR",name);
TH2D *hg=(TH2D*)fg->Get(nn);
// hg->SetName("imgGrating");
//hg->Divide(hff);
}
if (hpix)
hg->Divide(hpix);
new TCanvas();
hg->Draw("colz");
return hg;
}
void imageMacro(TH2D *hg){
Double_t imageData[200*400*25*25];
const int nsigma=5.;
int ip=0;
int max=0;
Double_t avg=0, rms=0;
for (int iby=0; iby<hg->GetNbinsY(); iby++) {
for (int ibx=0; ibx<hg->GetNbinsX(); ibx++) {
imageData[ip]=hg->GetBinContent(ibx+1,iby+1);
if (imageData[ip]>max) max=imageData[ip];
// if (imageData[ip]>3000) imageData[ip]=3000.;
avg+=((Double_t)imageData[ip])/(hg->GetNbinsY()*hg->GetNbinsX());
rms+=((Double_t)imageData[ip])*((Double_t)imageData[ip])/(hg->GetNbinsY()*hg->GetNbinsX());
ip++;
}
}
rms=TMath::Sqrt(rms-avg*avg);
ip=0;
for (int iby=0; iby<hg->GetNbinsY(); iby++) {
for (int ibx=0; ibx<hg->GetNbinsX(); ibx++) {
if (imageData[ip]>avg+nsigma*rms) imageData[ip]=avg+nsigma*rms;
// if (imageData[ip]>3000) imageData[ip]=3000.;
ip++;
}
}
cout << "MAXIMUM IS "<< max << endl;
cout << "AVERAGE IS "<< avg << endl;
cout << "RMS IS "<< rms << endl;
int nbx=hg->GetNbinsX();
int nby=hg->GetNbinsY();
Short_t *buffer=new Short_t[nbx];
// // cout << "Size of short int is "<<sizeof(char)<< endl;
// // cout << "width is "<<nbx<< endl;
// // cout << "height is "<<nby<< endl;
sprintf(nn,"%s_HR.bin", name);
ofstream myFile (nn, ios::out | ios::binary);
ip=0;
for (int iy=0; iy<nby; iy++) {
for (int ix=0; ix<nbx; ix++) {
buffer[ix]=imageData[ip]*65535/nsigma/avg;
ip++;
}
myFile.write((char*)buffer, nbx*sizeof(Short_t));
}
myFile.close();
TASImage *img=new TASImage ( "img",imageData, 400*25, 200*25);// TImagePalette * palette = 0
new TCanvas();
img->SetImageCompression(0);
img->SetImageQuality(TAttImage::kImgBest);
// img->Gray(kTRUE);
img->Draw();
sprintf(nn,"%s_HR.tiff", name);
img->WriteImage(nn, TImage::kTiff);
// new TCanvas();
// hg->SetMaximum(3000);
// hg->DrawCopy("colz");
hg->Rebin2D(25,25);
Double_t imageDataLR[200*400];
ip=0; max=0;avg=0; rms=0;
for (int iby=0; iby<hg->GetNbinsY(); iby++) {
for (int ibx=0; ibx<hg->GetNbinsX(); ibx++) {
imageDataLR[ip]=hg->GetBinContent(ibx+1,iby+1);
if (imageDataLR[ip]>max) max=imageDataLR[ip];
avg+=((Double_t)imageDataLR[ip])/(hg->GetNbinsY()*hg->GetNbinsX());
rms+=((Double_t)imageDataLR[ip])*((Double_t)imageDataLR[ip])/(hg->GetNbinsY()*hg->GetNbinsX());
ip++;
}
}
rms=TMath::Sqrt(rms-avg*avg);
ip=0;
for (int iby=0; iby<hg->GetNbinsY(); iby++) {
for (int ibx=0; ibx<hg->GetNbinsX(); ibx++) {
if (imageDataLR[ip]>avg+nsigma*rms) imageDataLR[ip]=avg+nsigma*rms;
// if (imageData[ip]>3000) imageData[ip]=3000.;
ip++;
}
}
cout << "MAXIMUM IS "<< max << endl;
cout << "AVERAGE IS "<< avg << endl;
cout << "RMS IS "<< rms << endl;
TASImage *imgLR=new TASImage ( "imgLR",imageDataLR, 400, 200);// TImagePalette * palette = 0
new TCanvas();
imgLR->SetImageCompression(0);
imgLR->SetImageQuality(TAttImage::kImgBest);
// imgLR->Gray(kTRUE);
imgLR->Draw();
sprintf(nn,"%s_LR.tiff", name);
imgLR->WriteImage(nn, TImage::kTiff);
int nbx1=hg->GetNbinsX();
int nby1=hg->GetNbinsY();
Short_t *buffer1=new Short_t[nbx1];
// // cout << "Size of short int is "<<sizeof(char)<< endl;
// // cout << "width is "<<nbx<< endl;
// // cout << "height is "<<nby<< endl;
sprintf(nn,"%s_LR.bin", name);
ofstream myFile1 (nn, ios::out | ios::binary);
ip=0;
for (int iy=0; iy<nby1; iy++) {
for (int ix=0; ix<nbx1; ix++) {
buffer1[ix]=imageDataLR[ip]*256/nsigma/avg;
ip++;
}
myFile1.write((char*)buffer1, nbx1*sizeof(Short_t));
}
myFile1.close();
cout << sizeof(Short_t) << endl;
//for grating2D the gratings are in the pixels (150-260)x(80-190)
// // hg->Draw("colz");
// int off=13;
// // hg->Divide(hpix);
// int ix,iy, sbx, sby, ibx2, iby2, sbx2, sby2;
// TH2F *hh13b=new TH2F("hh13b","hh13b",400*24,0,400,200*24,100,300);
// TH2F *hh13=new TH2F("hh13","hh13",400*23,0,400,200*23,100,300);
// TH2F *hh=new TH2F("hh","hh",400*21,0,400,200*21,100,300);
// TH2F *h1=new TH2F("h1","h1",400*23,0,400,200*23,100,300);
// for (int ibx=0; ibx<hg->GetNbinsX(); ibx++) {
// for (int iby=0; iby<hg->GetNbinsY(); iby++) {
// ix=(ibx-off)/25;
// iy=(iby-off)/25;
// sbx=(ibx-off)%25;
// sby=(iby-off)%25;
// sbx2=sbx-1;
// sby2=sby-1;
// if (sbx2<0) sbx2=0;
// if (sby2<0) sby2=0;
// if (sbx2>22) sbx2=22;
// if (sby2>22) sby2=22;
// ibx2=ix*23+(sbx2+off);
// iby2=iy*23+(sby2+off);
// hh13->Fill(hh13->GetXaxis()->GetBinCenter(ibx2+1),hh13->GetYaxis()->GetBinCenter(iby2+1),hg->GetBinContent(ibx+1,iby+1));
// // h1->Fill(h1->GetXaxis()->GetBinCenter(ibx2+1),h1->GetYaxis()->GetBinCenter(iby2+1),hpix->GetBinContent(ibx+1,iby+1));
// off=13;
// ix=(ibx-off)/25;
// iy=(iby-off)/25;
// sbx=(ibx-off)%25;
// sby=(iby-off)%25;
// sbx2=sbx-1;
// sby2=sby-1;
// // if (sbx2<0) sbx2=0;
// // if (sby2<0) sby2=0;
// ibx2=ix*24+(sbx2+off);
// iby2=iy*24+(sby2+off);
// if (sbx2<0 && sby2>=0) {
// ibx2=ix*24+(sbx2+off);
// hh13b->Fill(hh13b->GetXaxis()->GetBinCenter(ibx2+1),hh13b->GetYaxis()->GetBinCenter(iby2+1),0.5*hg->GetBinContent(ibx+1,iby+1));
// ibx2=ix*24+(sbx2+off)+1;
// hh13b->Fill(hh13b->GetXaxis()->GetBinCenter(ibx2+1),hh13b->GetYaxis()->GetBinCenter(iby2+1),0.5*hg->GetBinContent(ibx+1,iby+1));
// } else if (sby2<0 && sbx2>=0){
// iby2=iy*24+(sby2+off);
// hh13b->Fill(hh13b->GetXaxis()->GetBinCenter(ibx2+1),hh13b->GetYaxis()->GetBinCenter(iby2+1),0.5*hg->GetBinContent(ibx+1,iby+1));
// iby2=iy*24+(sby2+off)+1;
// hh13b->Fill(hh13b->GetXaxis()->GetBinCenter(ibx2+1),hh13b->GetYaxis()->GetBinCenter(iby2+1),0.5*hg->GetBinContent(ibx+1,iby+1));
// } else if (sby2<0 && sbx2<0){
// iby2=iy*24+(sby2+off);
// ibx2=ix*24+(sbx2+off);
// hh13b->Fill(hh13b->GetXaxis()->GetBinCenter(ibx2+1),hh13b->GetYaxis()->GetBinCenter(iby2+1),0.25*hg->GetBinContent(ibx+1,iby+1));
// iby2=iy*24+(sby2+off)+1;
// ibx2=ix*24+(sbx2+off);
// hh13b->Fill(hh13b->GetXaxis()->GetBinCenter(ibx2+1),hh13b->GetYaxis()->GetBinCenter(iby2+1),0.25*hg->GetBinContent(ibx+1,iby+1));
// iby2=iy*24+(sby2+off);
// ibx2=ix*24+(sbx2+off)+1;
// hh13b->Fill(hh13b->GetXaxis()->GetBinCenter(ibx2+1),hh13b->GetYaxis()->GetBinCenter(iby2+1),0.25*hg->GetBinContent(ibx+1,iby+1));
// iby2=iy*24+(sby2+off)+1;
// ibx2=ix*24+(sbx2+off)+1;
// hh13b->Fill(hh13b->GetXaxis()->GetBinCenter(ibx2+1),hh13b->GetYaxis()->GetBinCenter(iby2+1),0.25*hg->GetBinContent(ibx+1,iby+1));
// }else {
// hh13b->Fill(hh13b->GetXaxis()->GetBinCenter(ibx2+1),hh13b->GetYaxis()->GetBinCenter(iby2+1),hg->GetBinContent(ibx+1,iby+1));
// }
// ix=(ibx-off)/25;
// iy=(iby-off)/25;
// sbx=(ibx-off)%25;
// sby=(iby-off)%25;
// sbx2=sbx-2;
// sby2=sby-2;
// if (sbx2<0) sbx2=-1;
// if (sby2<0) sby2=-1;
// if (sbx2>20) sbx2=-1;
// if (sby2>20) sby2=-1;
// ibx2=ix*21+(sbx2+off);
// iby2=iy*21+(sby2+off);
// if (sbx2>=0 && sby2>=0) hh->Fill(hh->GetXaxis()->GetBinCenter(ibx2+1),hh->GetYaxis()->GetBinCenter(iby2+1),hg->GetBinContent(ibx+1,iby+1));
// }
// }
// new TCanvas();
// hg->GetXaxis()->SetRangeUser(84,87);
// hg->GetYaxis()->SetRangeUser(120,124);
// hg->Draw("colz");
// new TCanvas();
// // hh->Divide(h1);
// hh->GetXaxis()->SetRangeUser(84,87);
// hh->GetYaxis()->SetRangeUser(120,124);
// hh->Draw("colz");
// new TCanvas();
// // hh->Divide(h1);
// hh13b->GetXaxis()->SetRangeUser(84,87);
// hh13b->GetYaxis()->SetRangeUser(120,124);
// hh13b->Draw("colz");
// new TCanvas();
// // hh->Divide(h1);
// hh13->GetXaxis()->SetRangeUser(84,87);
// hh13->GetYaxis()->SetRangeUser(120,124);
// hh13->Draw("colz");
// // //TFile fsg("/local_zfs_raid/tomcat_20160528/trees/img_sample_grating_1d_eta_gmap.root");
// // //TH2D *hsg=(TH2D*)fsg.Get("sample_grating_1dHR");
// // TFile fsg("/local_zfs_raid/tomcat_20160528/trees/img_sample_grating_1d_eta.root");
// // TH2D *hsg=(TH2D*)fsg.Get("imgHR");
// // hsg->SetName("imgGratingSample");
// // hsg->Divide(hpix);
// // Double_t nf=hff->Integral(100,hff->GetNbinsX()-100,hff->GetYaxis()->FindBin(130), hff->GetYaxis()->FindBin(140))/((hff->GetNbinsX()-200)*250);
// // hff->Scale(1./nf);
// // // hg->Divide(hff);
// // //hsg->Divide(hff);
// // Double_t ng=hg->Integral(100,hg->GetNbinsX()-100,hg->GetYaxis()->FindBin(130), hg->GetYaxis()->FindBin(140))/((hg->GetNbinsX()-200)*250);
// // Double_t nsg=hsg->Integral(100,hsg->GetNbinsX()-100,hsg->GetYaxis()->FindBin(130), hsg->GetYaxis()->FindBin(140))/((hsg->GetNbinsX()-200)*250);
// // hg->Scale(1/ng);
// // hsg->Scale(1/nsg);
// // // new TCanvas();
// // // hg->SetMaximum(1.);
// // // hg->Draw("colz");
// // // new TCanvas();
// // // hsg->SetMaximum(1.);
// // // hsg->Draw("colz");
// // // TH1D *pg=hg->ProjectionX("pg",hg->GetYaxis()->FindBin(174.5)+1,hg->GetYaxis()->FindBin(175.5));
// // // TH1D *psg=hsg->ProjectionX("psg",hsg->GetYaxis()->FindBin(174.5)+1,hsg->GetYaxis()->FindBin(175.5));
// // // psg->SetLineColor(2);
// // // new TCanvas();
// // // pg->Draw("l");
// // // psg->Draw("l same");
// // int nbx=hg->GetNbinsX();
// // int nby=hg->GetNbinsY();
// // char buffer[nbx];
// // cout << "Size of short int is "<<sizeof(char)<< endl;
// // cout << "width is "<<nbx<< endl;
// // cout << "height is "<<nby<< endl;
// // ofstream myFile ("grating_1d.bin", ios::out | ios::binary);
// // for (int iy=0; iy<nby; iy++) {
// // for (int ix=0; ix<nbx; ix++) {
// // buffer[ix]=hg->GetBinContent(ix+1,iy+1);
// // }
// // myFile.write((char*)buffer, nbx*sizeof(char));
// // }
// // myFile.close();
// // nbx=hsg->GetNbinsX();
// // nby=hsg->GetNbinsY();
// // cout << "Size of short int is "<<sizeof(char)<< endl;
// // cout << "width is "<<nbx<< endl;
// // cout << "height is "<<nby<< endl;
// // ofstream myFile1 ("sample_grating_1d.bin", ios::out | ios::binary);
// // for (int iy=0; iy<nby; iy++) {
// // for (int ix=0; ix<nbx; ix++) {
// // buffer[ix]=hsg->GetBinContent(ix+1,iy+1);
// // }
// // myFile1.write((char*)buffer, nbx*sizeof(char));
// // }
// // myFile1.close();
// // NAME
// // raw2tiff - create a TIFF file from a raw data
// // SYNOPSIS
// // raw2tiff [ options ] input.raw output.tif
// // DESCRIPTION
// // raw2tiff converts a raw byte sequence into TIFF. By default, the TIFF image is created with data samples packed (PlanarConfiguration=1), compressed with the PackBits algorithm (Compression=32773),
// // and with each strip no more than 8 kilobytes. These characteristics can overridden, or explicitly specified with the options described below.
// // OPTIONS
// // -H number
// // size of input image file header in bytes (0 by default). This amount of data just will be skipped from the start of file while reading.
// // -w number
// // width of input image in pixels (can be guessed, see GUESSING THE IMAGE GEOMETRY below).
// // -l number
// // length of input image in lines (can be guessed, see GUESSING THE IMAGE GEOMETRY below).
// // -b number
// // number of bands in input image (1 by default).
// // -d data_type
// // type of samples in input image, where data_type may be:
// // byte 8-bit unsigned integer (default),
// // short 16-bit unsigned integer,
// // long 32-bit unsigned integer,
// // sbyte 8-bit signed integer,
// // sshort 16-bit signed integer,
// // slong 32-bit signed integer,
// // float 32-bit IEEE floating point,
// // double 64-bit IEEE floating point.
// // -i config
// // type of samples interleaving in input image, where config may be:
// // pixel pixel interleaved data (default),
// // band band interleaved data.
// // -p photo
// // photometric interpretation (color space) of the input image, where photo may be:
// // miniswhite white color represented with 0 value,
// // minisblack black color represented with 0 value (default),
// // rgb image has RGB color model,
// // cmyk image has CMYK (separated) color model,
// // ycbcr image has YCbCr color model,
// // cielab image has CIE L*a*b color model,
// // icclab image has ICC L*a*b color model,
// // itulab image has ITU L*a*b color model.
// // -s swap bytes fetched from the input file.
// // -L input data has LSB2MSB bit order (default).
// // -M input data has MSB2LSB bit order.
// // -c Specify a compression scheme to use when writing image data: -c none for no compression, -c packbits for the PackBits compression algorithm (the default), -c jpeg for the baseline JPEG compres-
// // sion algorithm, -c zip for the Deflate compression algorithm, and -c lzw for Lempel-Ziv & Welch.
// // -r number
// // Write data with a specified number of rows per strip; by default the number of rows/strip is selected so that each strip is approximately 8 kilobytes.
// //width is 10000
// //height is 5000
}

View File

@ -0,0 +1,185 @@
{
TColor::InitializeColors();
const Int_t NRGBs = 5;
const Int_t NCont = 255;//90;
Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
Double_t gray[NRGBs] = { 1., 0.34, 0.61, 0.84, 1.00};
Double_t zero[NRGBs] = { 0., 0.0,0.0, 0.0, 0.00};
//TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
TColor::CreateGradientColorTable(NRGBs, stops, gray, gray, gray, NCont);
gStyle->SetNumberContours(NCont);
gStyle->SetPadTopMargin(0);
gStyle->SetPadRightMargin(0);
gStyle->SetPadBottomMargin(0);
gStyle->SetPadLeftMargin(0);
gROOT->ForceStyle();
// TFile ff("/local_zfs_raid/tomcat_20160528/trees/img_blank_eta.root");
// TH2D *hff=(TH2D*)ff.Get("imgHR");
TFile ff("/mnt/moench_data/tomcat_20160528_img/img_blank_eta_nb25.root");
TH2D *hff=(TH2D*)ff.Get("blankHR");
hff->SetName("imgBlank");
TH2D *hpixel=new TH2D("hpixel","hpixel",25,0,25,25,0,25);
for (int ibx=10*25; ibx<hff->GetNbinsX()-10*25; ibx++) {
for (int iby=20*25; iby<hff->GetNbinsY()-20*25; iby++) {
hpixel->Fill((ibx-12)%25,(iby-12)%25,hff->GetBinContent(ibx+1,iby+1));
}
}
hpixel->Scale(1./hpixel->GetBinContent(13,13));
// new TCanvas();
// hpixel->Draw("colz");
TH2D *hraw=(TH2D*)hff->Clone("hraw");
TH2D *hpix=(TH2D*)hff->Clone("hpix");
for (int ibx=0; ibx<hff->GetNbinsX(); ibx++) {
for (int iby=0; iby<hff->GetNbinsY(); iby++) {
hpix->SetBinContent(ibx+1,iby+1,hpixel->GetBinContent(hpixel->GetXaxis()->FindBin((ibx-12)%25),hpixel->GetXaxis()->FindBin((iby-12)%25)));
}
}
hff->Divide(hpix);
// new TCanvas();
// hff->Draw("colz");
// TFile fg("/local_zfs_raid/tomcat_20160528/trees/img_grating_2d_eta.root");
// TH2D *hg=(TH2D*)fg.Get("imgHR");
TFile fg("/mnt/moench_data/tomcat_20160528_img/img_grating_2d_eta_nb25.root");
TH2D *hg=(TH2D*)fg.Get("grating_2dHR");
hg->SetName("imgGrating");
hg->Divide(hpix);
Double_t nf=hff->Integral(100,hff->GetNbinsX()-100,hff->GetYaxis()->FindBin(130), hff->GetYaxis()->FindBin(140))/((hff->GetNbinsX()-200)*250);
hff->Scale(1./nf);
// hg->Divide(hff);
//hsg->Divide(hff);
Double_t ng=hg->Integral(100,hg->GetNbinsX()-100,hg->GetYaxis()->FindBin(130), hg->GetYaxis()->FindBin(140))/((hg->GetNbinsX()-200)*250);
hg->Scale(1/ng);
new TCanvas("c1","c1",800,800);
hg->SetMaximum(2.);
Double_t xmin=hg->GetXaxis()->GetXmin();
Double_t xmax=hg->GetXaxis()->GetXmax();
Double_t ymin=hg->GetYaxis()->GetXmin();
Double_t ymax=hg->GetYaxis()->GetXmax();
hg->SetTitle(";mm;mm;Normalized intensity (a.u.)");
hg->GetXaxis()->Set(hg->GetXaxis()->GetNbins(),xmin*0.025-180.*0.025+0.1,xmax*0.025-180.*0.025+0.1);
hg->GetYaxis()->Set(hg->GetYaxis()->GetNbins(),ymin*0.025-180.*0.025-1.5,ymax*0.025-180*0.025-1.5);
hg->GetXaxis()->SetRangeUser(0,0.5);
hg->GetYaxis()->SetRangeUser(0,0.5);
hg->Draw("col");
hg->SetStats(kFALSE);
// new TCanvas();
// hsg->SetMaximum(1.);
// hsg->Draw("colz");
// TH1D *pg=hg->ProjectionX("pg",hg->GetYaxis()->FindBin(174.5)+1,hg->GetYaxis()->FindBin(175.5));
// TH1D *psg=hsg->ProjectionX("psg",hsg->GetYaxis()->FindBin(174.5)+1,hsg->GetYaxis()->FindBin(175.5));
// psg->SetLineColor(2);
// new TCanvas();
// pg->Draw("l");
// psg->Draw("l same");
int nbx=hg->GetNbinsX();
int nby=hg->GetNbinsY();
char buffer[nbx];
cout << "Size of short int is "<<sizeof(char)<< endl;
cout << "width is "<<nbx<< endl;
cout << "height is "<<nby<< endl;
ofstream myFile ("grating_2d.bin", ios::out | ios::binary);
for (int iy=0; iy<nby; iy++) {
for (int ix=0; ix<nbx; ix++) {
buffer[ix]=hg->GetBinContent(ix+1,iy+1);
}
myFile.write((char*)buffer, nbx*sizeof(char));
}
myFile.close();
// NAME
// raw2tiff - create a TIFF file from a raw data
// SYNOPSIS
// raw2tiff [ options ] input.raw output.tif
// DESCRIPTION
// raw2tiff converts a raw byte sequence into TIFF. By default, the TIFF image is created with data samples packed (PlanarConfiguration=1), compressed with the PackBits algorithm (Compression=32773),
// and with each strip no more than 8 kilobytes. These characteristics can overridden, or explicitly specified with the options described below.
// OPTIONS
// -H number
// size of input image file header in bytes (0 by default). This amount of data just will be skipped from the start of file while reading.
// -w number
// width of input image in pixels (can be guessed, see GUESSING THE IMAGE GEOMETRY below).
// -l number
// length of input image in lines (can be guessed, see GUESSING THE IMAGE GEOMETRY below).
// -b number
// number of bands in input image (1 by default).
// -d data_type
// type of samples in input image, where data_type may be:
// byte 8-bit unsigned integer (default),
// short 16-bit unsigned integer,
// long 32-bit unsigned integer,
// sbyte 8-bit signed integer,
// sshort 16-bit signed integer,
// slong 32-bit signed integer,
// float 32-bit IEEE floating point,
// double 64-bit IEEE floating point.
// -i config
// type of samples interleaving in input image, where config may be:
// pixel pixel interleaved data (default),
// band band interleaved data.
// -p photo
// photometric interpretation (color space) of the input image, where photo may be:
// miniswhite white color represented with 0 value,
// minisblack black color represented with 0 value (default),
// rgb image has RGB color model,
// cmyk image has CMYK (separated) color model,
// ycbcr image has YCbCr color model,
// cielab image has CIE L*a*b color model,
// icclab image has ICC L*a*b color model,
// itulab image has ITU L*a*b color model.
// -s swap bytes fetched from the input file.
// -L input data has LSB2MSB bit order (default).
// -M input data has MSB2LSB bit order.
// -c Specify a compression scheme to use when writing image data: -c none for no compression, -c packbits for the PackBits compression algorithm (the default), -c jpeg for the baseline JPEG compres-
// sion algorithm, -c zip for the Deflate compression algorithm, and -c lzw for Lempel-Ziv & Welch.
// -r number
// Write data with a specified number of rows per strip; by default the number of rows/strip is selected so that each strip is approximately 8 kilobytes.
//width is 10000
//height is 5000
}

View File

@ -0,0 +1,173 @@
{
// TFile ff("/local_zfs_raid/tomcat_20160528/trees/img_blank_eta.root");
// TH2D *hff=(TH2D*)ff.Get("imgHR");
// TFile ff("/local_zfs_raid/tomcat_20160528/trees/img_blank_eta_gmap_v2.root");
// TH2D *hff=(TH2D*)ff.Get("blankHR");
// hff->SetName("imgBlank");
// TH2D *hpixel=new TH2D("hpixel","hpixel",25,0,25,25,0,25);
// for (int ibx=10*25; ibx<hff->GetNbinsX()-10*25; ibx++) {
// for (int iby=20*25; iby<hff->GetNbinsY()-20*25; iby++) {
// hpixel->Fill((ibx-12)%25,(iby-12)%25,hff->GetBinContent(ibx+1,iby+1));
// }
// }
// hpixel->Scale(1./hpixel->GetBinContent(13,13));
// // new TCanvas();
// // hpixel->Draw("colz");
// TH2D *hraw=(TH2D*)hff->Clone("hraw");
// TH2D *hpix=(TH2D*)hff->Clone("hpix");
// for (int ibx=0; ibx<hff->GetNbinsX(); ibx++) {
// for (int iby=0; iby<hff->GetNbinsY(); iby++) {
// hpix->SetBinContent(ibx+1,iby+1,hpixel->GetBinContent(hpixel->GetXaxis()->FindBin((ibx-12)%25),hpixel->GetXaxis()->FindBin((iby-12)%25)));
// }
// }
// hff->Divide(hpix);
// Double_t nf=hff->Integral(100,hff->GetNbinsX()-100,hff->GetYaxis()->FindBin(130), hff->GetYaxis()->FindBin(140))/((hff->GetNbinsX()-200)*250);
// hff->Scale(1./nf);
// new TCanvas();
// hff->Draw("colz");
// TFile fg("/local_zfs_raid/tomcat_20160528/trees/img_grating_2d_eta.root");
// TH2D *hg=(TH2D*)fg.Get("imgHR");
TFile fg("/mnt/moench_data/tomcat_20160528_img/img_sample_eta_gmap_v2.root");
TH2D *hg=(TH2D*)fg.Get("sampleHR");
hg->SetName("imgSample");
// hg->Divide(hpix);
// hg->Divide(hff);
//hsg->Divide(hff);
Double_t ng=hg->Integral(100,hg->GetNbinsX()-100,hg->GetYaxis()->FindBin(130), hg->GetYaxis()->FindBin(140))/((hg->GetNbinsX()-200)*250);
hg->Scale(1/ng);
// new TCanvas();
// hsg->SetMaximum(1.);
// hsg->Draw("colz");
// TH1D *pg=hg->ProjectionX("pg",hg->GetYaxis()->FindBin(174.5)+1,hg->GetYaxis()->FindBin(175.5));
// TH1D *psg=hsg->ProjectionX("psg",hsg->GetYaxis()->FindBin(174.5)+1,hsg->GetYaxis()->FindBin(175.5));
// psg->SetLineColor(2);
// new TCanvas();
// pg->Draw("l");
// psg->Draw("l same");
TH2D *hpixel1=new TH2D("hpixel1","hpixel1",25,0,25,25,0,25);
for (int ibx=10*25; ibx<35*25; ibx++) {
for (int iby=25*25; iby<50*25; iby++) {
hpixel1->Fill((ibx-12)%25,(iby-12)%25,hg->GetBinContent(ibx+1,iby+1));
}
}
hpixel1->Scale(1./hpixel1->GetBinContent(13,13));
// new TCanvas();
// hpixel->Draw("colz");
TH2D *hpix1=(TH2D*)hg->Clone("hpix1");
for (int ibx=0; ibx<hg->GetNbinsX(); ibx++) {
for (int iby=0; iby<hg->GetNbinsY(); iby++) {
hpix1->SetBinContent(ibx+1,iby+1,hpixel1->GetBinContent(hpixel1->GetXaxis()->FindBin((ibx-12)%25),hpixel1->GetXaxis()->FindBin((iby-12)%25)));
}
}
hg->Divide(hpix1);
new TCanvas();
hg->SetMaximum(4);
hg->SetMinimum(0.5);
hg->Draw("colz");
int nbx=hg->GetNbinsX();
int nby=hg->GetNbinsY();
char buffer[nbx];
cout << "Size of short int is "<<sizeof(char)<< endl;
cout << "width is "<<nbx<< endl;
cout << "height is "<<nby<< endl;
ofstream myFile ("sample.bin", ios::out | ios::binary);
for (int iy=0; iy<nby; iy++) {
for (int ix=0; ix<nbx; ix++) {
buffer[ix]=hg->GetBinContent(ix+1,iy+1);
}
myFile.write((char*)buffer, nbx*sizeof(char));
}
myFile.close();
// NAME
// raw2tiff - create a TIFF file from a raw data
// SYNOPSIS
// raw2tiff [ options ] input.raw output.tif
// DESCRIPTION
// raw2tiff converts a raw byte sequence into TIFF. By default, the TIFF image is created with data samples packed (PlanarConfiguration=1), compressed with the PackBits algorithm (Compression=32773),
// and with each strip no more than 8 kilobytes. These characteristics can overridden, or explicitly specified with the options described below.
// OPTIONS
// -H number
// size of input image file header in bytes (0 by default). This amount of data just will be skipped from the start of file while reading.
// -w number
// width of input image in pixels (can be guessed, see GUESSING THE IMAGE GEOMETRY below).
// -l number
// length of input image in lines (can be guessed, see GUESSING THE IMAGE GEOMETRY below).
// -b number
// number of bands in input image (1 by default).
// -d data_type
// type of samples in input image, where data_type may be:
// byte 8-bit unsigned integer (default),
// short 16-bit unsigned integer,
// long 32-bit unsigned integer,
// sbyte 8-bit signed integer,
// sshort 16-bit signed integer,
// slong 32-bit signed integer,
// float 32-bit IEEE floating point,
// double 64-bit IEEE floating point.
// -i config
// type of samples interleaving in input image, where config may be:
// pixel pixel interleaved data (default),
// band band interleaved data.
// -p photo
// photometric interpretation (color space) of the input image, where photo may be:
// miniswhite white color represented with 0 value,
// minisblack black color represented with 0 value (default),
// rgb image has RGB color model,
// cmyk image has CMYK (separated) color model,
// ycbcr image has YCbCr color model,
// cielab image has CIE L*a*b color model,
// icclab image has ICC L*a*b color model,
// itulab image has ITU L*a*b color model.
// -s swap bytes fetched from the input file.
// -L input data has LSB2MSB bit order (default).
// -M input data has MSB2LSB bit order.
// -c Specify a compression scheme to use when writing image data: -c none for no compression, -c packbits for the PackBits compression algorithm (the default), -c jpeg for the baseline JPEG compres-
// sion algorithm, -c zip for the Deflate compression algorithm, and -c lzw for Lempel-Ziv & Welch.
// -r number
// Write data with a specified number of rows per strip; by default the number of rows/strip is selected so that each strip is approximately 8 kilobytes.
//width is 10000
//height is 5000
}

File diff suppressed because it is too large Load Diff

View File

@ -3,11 +3,11 @@
#include <slsInterpolation.h>
#include "EtaVEL.h"
//#include "TH2F.h"
#include "TH2F.h"
//#include "EtaVEL.cpp"
//class EtaVEL;
class etaVELInterpolation: public etaInterpolationBase {
class interpolation_EtaVEL: public slsInterpolation {
public:
interpolation_EtaVEL(int nx=40, int ny=160, int ns=25, double etamin=-0.02, double etamax=1.02, int p=0);
@ -31,21 +31,18 @@ class etaVELInterpolation: public etaInterpolationBase {
int addToFlatField(Double_t *cluster, Double_t &etax, Double_t &etay);
int addToFlatField(Double_t etax, Double_t etay);
int setPlot(int p=-1) {if (p>=0) plot=p; return plot;};
// int WriteH(){newEta->Write("newEta"); heta->Write("heta");};
int WriteH(){newEta->Write("newEta"); heta->Write("heta");};
EtaVEL *setEta(EtaVEL *ev){if (ev) {delete newEta; newEta=ev;} return newEta;};
// TH2F *setEta(TH2F *ev){if (ev) {delete heta; heta=ev;} return heta;};
TH2F *setEta(TH2F *ev){if (ev) {delete heta; heta=ev;} return heta;};
void iterate();
// void DrawH();
void DrawH();
double getChiSq(){return newEta->getChiSq();};
protected:
EtaVEL *newEta;
// TH2F *heta;
TH2F *heta;
int plot;
// ClassDefNV(interpolation_EtaVEL,1);

View File

@ -0,0 +1,224 @@
#ifndef SLS_INTERPOLATION_H
#define SLS_INTERPOLATION_H
#include <TObject.h>
#include <TTree.h>
#include <TH2F.h>
#ifndef DEF_QUAD
#define DEF_QUAD
enum quadrant {
TOP_LEFT=0,
TOP_RIGHT=1,
BOTTOM_LEFT=2,
BOTTOM_RIGHT=3,
UNDEFINED_QUADRANT=-1
};
#endif
class slsInterpolation : public TObject{
public:
slsInterpolation(int nx=40, int ny=160, int ns=25) :nPixelsX(nx), nPixelsY(ny), nSubPixels(ns) {hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);};
//create eta distribution, eta rebinnining etc.
//returns flat field image
virtual void prepareInterpolation(int &ok)=0;
//create interpolated image
//returns interpolated image
virtual TH2F *getInterpolatedImage(){return hint;};
//return position inside the pixel for the given photon
virtual void getInterpolatedPosition(Int_t x, Int_t y, Double_t *data, Double_t &int_x, Double_t &int_y)=0;
TH2F *addToImage(Double_t int_x, Double_t int_y){hint->Fill(int_x, int_y); return hint;};
virtual int addToFlatField(Double_t *cluster, Double_t &etax, Double_t &etay)=0;
virtual int addToFlatField(Double_t etax, Double_t etay)=0;
//virtual void Streamer(TBuffer &b);
static int calcQuad(Double_t *cl, Double_t &sum, Double_t &totquad, Double_t sDum[2][2]){
int corner = UNDEFINED_QUADRANT;
Double_t *cluster[3];
cluster[0]=cl;
cluster[1]=cl+3;
cluster[2]=cl+6;
sum = cluster[0][0] + cluster[1][0] + cluster[2][0] + cluster[0][1] + cluster[1][1] + cluster[2][1] + cluster[0][2] + cluster[1][2] + cluster[2][2];
double sumBL = cluster[0][0] + cluster[1][0] + cluster[0][1] + cluster[1][1]; //2 ->BL
double sumTL = cluster[1][0] + cluster[2][0] + cluster[2][1] + cluster[1][1]; //0 ->TL
double sumBR = cluster[0][1] + cluster[0][2] + cluster[1][2] + cluster[1][1]; //3 ->BR
double sumTR = cluster[1][2] + cluster[2][1] + cluster[2][2] + cluster[1][1]; //1 ->TR
double sumMax = 0;
double t, r;
// if(sumTL >= sumMax){
sDum[0][0] = cluster[0][0]; sDum[1][0] = cluster[1][0];
sDum[0][1] = cluster[0][1]; sDum[1][1] = cluster[1][1];
corner = BOTTOM_LEFT;
sumMax=sumBL;
// }
if(sumTL >= sumMax){
sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0];
sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1];
corner = TOP_LEFT;
sumMax=sumTL;
}
if(sumBR >= sumMax){
sDum[0][0] = cluster[0][1]; sDum[1][0] = cluster[1][1];
sDum[0][1] = cluster[0][2]; sDum[1][1] = cluster[1][2];
corner = BOTTOM_RIGHT;
sumMax=sumBR;
}
if(sumTR >= sumMax){
sDum[0][0] = cluster[1][1]; sDum[1][0] = cluster[2][1];
sDum[0][1] = cluster[1][2]; sDum[1][1] = cluster[2][2];
corner = TOP_RIGHT;
sumMax=sumTR;
}
totquad=sumMax;
return corner;
}
static int calcEta(Double_t totquad, Double_t sDum[2][2], Double_t &etax, Double_t &etay){
Double_t t,r;
if (totquad>0) {
t = sDum[1][0] + sDum[1][1];
r = sDum[0][1] + sDum[1][1];
etax=r/totquad;
etay=t/totquad;
}
return 0;
}
static int calcEta(Double_t *cl, Double_t &etax, Double_t &etay, Double_t &sum, Double_t &totquad, Double_t sDum[2][2]) {
int corner = calcQuad(cl,sum,totquad,sDum);
calcEta(totquad, sDum, etax, etay);
return corner;
}
static int calcEtaL(Double_t totquad, int corner, Double_t sDum[2][2], Double_t &etax, Double_t &etay){
Double_t t,r, toth, totv;
if (totquad>0) {
switch(corner) {
case TOP_LEFT:
t = sDum[1][1] ;
r = sDum[0][1] ;
toth=sDum[1][1]+sDum[1][0];
totv=sDum[0][1]+sDum[1][1];
break;
case TOP_RIGHT:
t = sDum[1][0] ;
r = sDum[0][1] ;
toth=sDum[0][0]+t;
totv=sDum[0][0]+r;
break;
case BOTTOM_LEFT:
r = sDum[1][1] ;
t = sDum[1][1] ;
toth=sDum[1][0]+t;
totv=sDum[0][1]+r;
break;
case BOTTOM_RIGHT:
t = sDum[1][0] ;
r = sDum[1][1] ;
toth=sDum[1][1]+t;
totv=sDum[0][1]+r;
break;
default:
etax=-1;
etay=-1;
return 0;
}
etax=r/totv;
etay=t/toth;
}
return 0;
}
static int calcEtaL(Double_t *cl, Double_t &etax, Double_t &etay, Double_t &sum, Double_t &totquad, Double_t sDum[2][2]) {
int corner = calcQuad(cl,sum,totquad,sDum);
calcEtaL(totquad, corner, sDum, etax, etay);
return corner;
}
static int calcEtaC3(Double_t *cl, Double_t &etax, Double_t &etay, Double_t &sum, Double_t &totquad, Double_t sDum[2][2]){
int corner = calcQuad(cl,sum,totquad,sDum);
calcEta(sum, sDum, etax, etay);
return corner;
}
static int calcEta3(Double_t *cl, Double_t &etax, Double_t &etay, Double_t &sum) {
Double_t l,r,t,b;
sum=cl[0]+cl[1]+cl[2]+cl[3]+cl[4]+cl[5]+cl[6]+cl[7]+cl[8];
if (sum>0) {
l=cl[0]+cl[3]+cl[6];
r=cl[2]+cl[5]+cl[8];
b=cl[0]+cl[1]+cl[2];
t=cl[6]+cl[7]+cl[8];
etax=(-l+r)/sum;
etay=(-b+t)/sum;
}
return -1;
}
static int calcEta3X(Double_t *cl, Double_t &etax, Double_t &etay, Double_t &sum) {
Double_t l,r,t,b;
sum=cl[0]+cl[1]+cl[2]+cl[3]+cl[4]+cl[5]+cl[6]+cl[7]+cl[8];
if (sum>0) {
l=cl[3];
r=cl[5];
b=cl[1];
t=cl[7];
etax=(-l+r)/sum;
etay=(-b+t)/sum;
}
return -1;
}
protected:
int nPixelsX, nPixelsY;
int nSubPixels;
TH2F *hint;
// ClassDefNV(slsInterpolation,1);
// #pragma link C++ class slsInterpolation-;
};
#endif

View File

@ -0,0 +1,11 @@
{
//.L energyCalibration.cpp+
//.L gainMap.C+
TFile fin("/data/moench_xbox_20140113/MoTarget_45kV_0_8mA_120V_cds_g4.root");
TH2F *h2=fin.Get("h2");
TH2F *gMap=gainMap(h2,4);
gMap->Draw("colz");
}

View File

@ -0,0 +1,228 @@
#define MYROOT
#include <TH2F.h>
#include <TSpectrum.h>
#include <TH1D.h>
#include <TFile.h>
#include <TList.h>
#include <TPolyMarker.h>
#include <THStack.h>
#include <TF1.h>
#include <TGraphErrors.h>
#include <iostream>
#include <energyCalibration.h>
using namespace std;
#define FOPT "0"
TH2F *gainMap(TH2F *h2, float g) {
// int npx, npy;
int npx=160, npy=160;
// det->getDetectorSize(npx, npy);
TH2F *gMap=new TH2F("gmap",h2->GetTitle(), npx, -0.5, npx-0.5, npy, -0.5, npy-0.5);
Double_t ens[3]={0,8,17.5}, eens[3]={0.,0.1,0.1};
Double_t peaks[3], epeaks[3];
int ibin;
TH1D *px;
energyCalibration *enCal=new energyCalibration();
enCal->setPlotFlag(0);
// enCal->setChargeSharing(0);
enCal->setScanSign(1);
Double_t gain, off, egain, eoff;
TList *functions;
TPolyMarker *pm ;
Double_t *peakX, *peakY;
TSpectrum *s=new TSpectrum();
Double_t mypar[10], emypar[10];
Double_t prms, np;
int iit=0;
TGraph *glin;
Double_t peakdum, hpeakdum;
for (int ix=1; ix<npx-1; ix++) {
for (int iy=1; iy<npy-1; iy++) {
// cout << ix << " " << iy << " " << ibin << endl;
ibin=ix*npy+iy;
px=h2->ProjectionX("px",ibin+1,ibin+1);
prms=10*g;
iit=0;
np=s->Search(px,prms,"",0.2);
while (np !=2) {
if (np>2)
prms+=0.5*prms;
else
prms-=0.5*prms;
iit++;
if (iit>=10)
break;
np=s->Search(px,prms,"",0.2);
}
if (np!=2)
cout << "peak search could not converge " << ibin << endl;
if (np==2) {
pm=NULL;
functions=px->GetListOfFunctions();
if (functions)
pm = (TPolyMarker*)functions->FindObject("TPolyMarker");
if (pm) {
peakX=pm->GetX();
peakY=pm->GetY();
if (peakX[0]>peakX[1]) {
peakdum=peakX[0];
hpeakdum=peakY[0];
peakX[0]= peakX[1];
peakY[0]= peakY[1];
peakX[1]= peakdum;
peakY[1]= hpeakdum;
}
cout << "("<< ix << "," << iy << ") " << endl;
for (int ip=0; ip<np; ip++) {
// cout << ip << " " << peakX[ip] << " " << peakY[ip] << endl;
enCal->setFitRange(peakX[ip]-10*g,peakX[ip]+10*g);
mypar[0]=0;
mypar[1]=0;
mypar[2]=peakX[ip];
mypar[3]=g*10;
mypar[4]=peakY[ip];
mypar[5]=0;
enCal->setStartParameters(mypar);
enCal->fitSpectrum(px,mypar,emypar);
peaks[ip+1]=mypar[2];
epeaks[ip+1]=emypar[2];
}
peaks[0]=0;
epeaks[0]=1;
// for (int i=0; i<3; i++) cout << i << " " << ens[i] << " " << eens[i]<< " "<< peaks[i]<< " " << epeaks[i] << endl;
glin= enCal->linearCalibration(3,ens,eens,peaks,epeaks,gain,off,egain,eoff);
// cout << "Gain " << gain << " off " << off << endl;
if (off>-10 && off<10) {
gMap->SetBinContent(ix+1,iy+1,gain);
gMap->SetBinError(ix+1,iy+1,egain);
}
if (glin)
delete glin;
}
}
}
}
return gMap;
}
TH2F *noiseMap(TH2F *h2) {
// int npx, npy;
int npx=160, npy=160;
// det->getDetectorSize(npx, npy);
TH2F *nMap=new TH2F("nmap",h2->GetTitle(), npx, -0.5, npx-0.5, npy, -0.5, npy-0.5);
int ibin;
TH1D *px;
for (int ix=0; ix<npx; ix++) {
for (int iy=0; iy<npy; iy++) {
cout << ix << " " << iy << " " << ibin << endl;
ibin=ix*npy+iy;
px=h2->ProjectionX("px",ibin+1,ibin+1);
px->Fit("gaus", FOPT);
if (px->GetFunction("gaus")) {
nMap->SetBinContent(ix+1,iy+1,px->GetFunction("gaus")->GetParameter(2));
}
// delete px;
}
}
return nMap;
}
THStack *noiseHistos(char *tit) {
char fname[10000];
sprintf(fname,"/data/moench_xbox_20140116/noise_map_%s.root",tit);
TFile *fn=new TFile(fname);
TH2F *nmap=(TH2F*)fn->Get("nmap");
if (nmap==NULL) {
cout << "No noise map in file " << fname << endl;
return NULL;
}
sprintf(fname,"/data/moench_xbox_20140113/gain_map_%s.root",tit);
TFile *fg=new TFile(fname);
TH2F *gmap=(TH2F*)fg->Get("gmap");
if (gmap==NULL) {
cout << "No gain map in file " << fname << endl;
return NULL;
}
nmap->Divide(gmap);
nmap->Scale(1000./3.6);
THStack *hs=new THStack(tit,tit);
hs->SetTitle(tit);
TH1F *h;
char hname[100];
cout << tit << endl;
for (int is=0; is<4; is++) {
sprintf(hname,"h%ds",is+1);
h=new TH1F(hname,tit,500,0,500);
hs->Add(h);
// cout << hs->GetHists()->GetEntries() << endl;
for (int ix=40*is+2; ix<40*(is+1)-2; ix++) {
for (int iy=2; iy<158; iy++) {
if (ix<100 || ix>120)
h->Fill(nmap->GetBinContent(ix+1,iy+1));
}
}
cout << is+1 << "SC: " << "" << h->GetMean() << "+-" << h->GetRMS();
h->Fit("gaus","0Q");
h->SetLineColor(is+1);
if (h->GetFunction("gaus")) {
h->GetFunction("gaus")->SetLineColor(is+1);
cout << " or " << h->GetFunction("gaus")->GetParameter(1) << "+-" << h->GetFunction("gaus")->GetParError(1);
}
cout << endl;
}
// cout << hs->GetHists()->GetEntries() << endl;
return hs;
}

View File

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

View File

@ -1,215 +0,0 @@
#include <vector>
#include <string>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
//#include <deque>
//#include <list>
//#include <queue>
#include <fstream>
#include <cstring>
#include "gotthardModuleDataNew.h"
#include "gotthardDoubleModuleDataNew.h"
#include "singlePhotonDetector.h"
//#include "interpolatingDetector.h"
//#include "linearInterpolation.h"
#include "multiThreadedAnalogDetector.h"
#include <ctime>
#define NC 1280
#define NR 1
#include "tiffIO.h"
void *gotthardProcessFrame() {
if (argc < 3 ) {
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n");
return EXIT_FAILURE;
}
// receive parameters
bool send = false;
char* socketip=argv[1];
uint32_t portnum = atoi(argv[2]);
int size = 32*2*5000;//atoi(argv[3]);
// send parameters if any
char* socketip2 = 0;
uint32_t portnum2 = 0;
if (argc > 3) {
send = true;
socketip2 = argv[3];
portnum2 = atoi(argv[4]);
}
cout << "\nrx socket ip : " << socketip <<
"\nrx port num : " << portnum ;
if (send) {
cout << "\nsd socket ip : " << socketip2 <<
"\nsd port num : " << portnum2;
}
cout << endl;
char fname0[10000], fname1[10000];
char fformat[10000];
int fifosize=1000;
strcpy(fformat,"/external_pool/gotthard_data/datadir_gotthardI/bchip074075/20170731/Xray/xray_15kV_200uA_5us_d%d_f000000000000_0.raw");
sprintf(fname0,fformat,0,0);
sprintf(fname1,fformat,1,1);
int nthreads=3;
int nph, nph1;
// single_photon_hit clusters[NR*NC];
// cout << "hits "<< endl;
int etabins=550;
double etamin=-1, etamax=2;
int nsubpix=1;
float *etah=new float[etabins*etabins];
// cout << "etah "<< endl;
cout << "image size "<< nsubpix*nsubpix*NC*NR << endl;
int *heta, *himage;
gotthardModuleDataNew *decoder=new gotthardModuleDataNew();
gotthardDoubleModuleDataNew *det=new gotthardDoubleModuleDataNew();
// cout << "decoder "<< endl;
// etaInterpolationPosXY *interp=new etaInterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
// cout << "interp "<< endl;
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
// interpolatingDetector *filter0=new interpolatingDetector(decoder,interp, 5, 1, 0, 1000, 10);
// interpolatingDetector *filter1=new interpolatingDetector(decoder,interp, 5, 1, 0, 1000, 10);
//filter->readPedestals("/scratch/ped_100.tiff");
//cout << "filter "<< endl;
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 200);
filter->setFrameMode(eFrame);
char *buff;//[2*(48+1280*2)];
char *buff0;
char *buff1;
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
mt->setFrameMode(eFrame);
mt->StartThreads();
mt->popFree(buff);
buff0=buff;
buff1=buff+48+1280*2;
int photons[1280*2];
int nf=0;
int ok=0;
ifstream filebin0,filebin1;
std::time_t end_time;
int16_t dout[1280*2];
int iFrame=-1;
int np=-1;
nph=0;
nph1=0;
//int np;
int iph;
int data_ready=1;
int *image;
// filter->setROI(0,512,0,1);
filebin0.open((const char *)(fname0), ios::in | ios::binary);
filebin1.open((const char *)(fname1), ios::in | ios::binary);
if (filebin0.is_open() && filebin1.is_open()) {
cout << "Opened file " << fname0<< endl;
cout << "Opened file " << fname1<< endl;
// mt->setFrameMode(eFrame);
// mt->prepareInterpolation(ok);
// mt->StartThreads();
// mt->popFree(buff);
nf=0;
iFrame=-1;
while ((decoder->readNextFrame(filebin0, iFrame, np, buff0)) && (decoder->readNextFrame(filebin1, iFrame, np, buff1))) {
//filter->processData(buff, photons);
// cout << nf << " " << decoder->getFrameNumber(buff0) << " " << decoder->getFrameNumber(buff1) << " " << filter->getPhFrame() << " " << filter->getPhTot() << endl;
// for (int i=0; i<1280*2; i++) {
// filter->addToPedestal(buff,i,0);
// dout[i]=filter->subtractPedestal(buff,i,0);
// if (nf>10 && i<512)
// if (i%2)
// cout << nf << " " << i << " " << filter->getPedestal(i,0) << " " << det->getValue(buff,i,0) << " " << decoder->getValue(buff1,1280-1-i/2,0)<< " " << dout[i] << endl;
// else
// cout << nf << " " << i << " " << filter->getPedestal(i,0) << " " << det->getValue(buff,i,0) << " " << decoder->getValue(buff0,i/2,0)<< " " << dout[i] << endl;
// }
mt->pushData(buff);
mt->nextThread();
mt->popFree(buff);
buff0=buff;
buff1=buff+48+1280*2;
nf++;
// cout << id << " " << nf << endl;
if (nf%10000==0) {
while (mt->isBusy()) {;}
image=filter->getImage();
if (image) {
cout << nf << "*****************" << endl;
for (int i=0; i<512; i++) {
cout << image[i] << "\t";
}
cout << endl;
}
filter->clearImage();
std::time(&end_time);
cout << std::ctime(&end_time) << " " << nf << endl;
}
iFrame=-1;
}
filebin0.close();
filebin1.close();
}
else
cout << "Could not open file " << fname0<< " or " << fname1 << endl;
return NULL;
}
int main(int argc, char *argv[]){
gotthardProcessFrame();
}

View File

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

View File

@ -1,657 +0,0 @@
#ifndef INTERPOLATINGDETECTOR_H
#define INTERPOLATINGDETECTOR_H
#include "singlePhotonDetector.h"
#include "slsInterpolation.h"
#define M015
#ifdef MYROOT1
#include <TTree.h>
#endif
#include <iostream>
using namespace std;
#define XMIN 350/2
#define XMAX 600/2
#define YMIN 0
#define YMAX 400
class interpolatingDetector : public singlePhotonDetector {
/** @short class to perform pedestal subtraction etc. and find single photon clusters for an analog detector */
public:
/**
Constructor (no error checking if datasize and offsets are compatible!)
\param d detector data structure to be used
\param csize cluster size (should be an odd number). Defaults to 3
\param nsigma number of rms to discriminate from the noise. Defaults to 5
\param sign 1 if photons are positive, -1 if negative
\param cm common mode subtraction algorithm, if any. Defaults to NULL i.e. none
\param nped number of samples for pedestal averaging
\param nd number of dark frames to average as pedestals without photon discrimination at the beginning of the measurement
*/
interpolatingDetector(slsDetectorData<uint16_t> *d, slsInterpolation *inte,
double nsigma=5,
int sign=1,
commonModeSubtraction *cm=NULL,
int nped=1000,
int nd=100, int nnx=-1, int nny=-1) :
singlePhotonDetector(d, 3,nsigma,sign, cm, nped, nd, nnx, nny) , interp(inte), id(0), xmin(XMIN), xmax(XMAX), ymin(YMIN), ymax(YMAX) {
cout << "**"<< xmin << " " << xmax << " " << ymin << " " << ymax << endl;
};
interpolatingDetector(interpolatingDetector *orig) : singlePhotonDetector(orig) {
interp=(orig->interp)->Clone();
id=orig->id;
xmin=orig->xmin;
xmax=orig->xmax;
ymin=orig->ymin;
ymax=orig->ymax;
}
virtual interpolatingDetector *Clone() {
return new interpolatingDetector(this);
}
virtual int setId(int i) {id=i; interp->setId(id); return id;};
virtual void prepareInterpolation(int &ok) {
cout << "*"<< endl;
#ifdef SAVE_ALL
char tit[1000];
sprintf(tit,"/scratch/ped_%d.tiff",id);
writePedestals(tit);
sprintf(tit,"/scratch/ped_rms_%d.tiff",id);
writePedestalRMS(tit);
if (gmap) {
sprintf(tit,"/scratch/gmap_%d.tiff",id);
writeGainMap(tit);
}
#endif
if (interp)
interp->prepareInterpolation(ok);
}
void clearImage() {if (interp) interp->clearInterpolatedImage(); 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);};
#ifdef MYROOT1
virtual TH2F *getImage()
#endif
#ifndef MYROOT1
virtual int *getImage()
#endif
{
// cout << "image " << endl;
if (interp)
return interp->getInterpolatedImage();
else
return analogDetector<uint16_t>::getImage();
//cout << "null " << endl;
}
#ifdef MYROOT1
virtual TH2F *addToInterpolatedImage(char *data, int *val, int &nph)
#endif
#ifndef MYROOT1
virtual int *addToInterpolatedImage(char *data, int *val, int &nph)
#endif
{
nph=addFrame(data,val,0);
if (interp)
return interp->getInterpolatedImage();
else
singlePhotonDetector::getImage();
//return NULL;
};
#ifdef MYROOT1
virtual TH2F *addToFlatField(char *data, int *val, int &nph)
#endif
#ifndef MYROOT1
virtual int *addToFlatField(char *data, int *val, int &nph)
#endif
{
nph=addFrame(data,val,1);
if (interp)
return interp->getFlatField();
else
return NULL;
};
void *writeImage(const char * imgname) {
// cout << id << "=" << imgname<< endl;
if (interp)
interp->writeInterpolatedImage(imgname);
else
analogDetector<uint16_t>::writeImage(imgname);
return NULL;
}
int addFrame(char *data, int *ph=NULL, int ff=0) {
int nph=0;
double val[ny][nx];
int cy=(clusterSizeY+1)/2;
int cs=(clusterSize+1)/2;
int ir, ic;
double int_x,int_y, eta_x, eta_y;
double max=0, tl=0, tr=0, bl=0,br=0, *v, vv;
if (ph==NULL)
ph=image;
if (iframe<nDark) {
addToPedestal(data);
return 0;
}
newFrame();
for (int ix=xmin; ix<xmax; ix++) {
for (int iy=ymin; iy<ymax; iy++) {
max=0;
tl=0;
tr=0;
bl=0;
br=0;
tot=0;
quadTot=0;
quad=UNDEFINED_QUADRANT;
eventMask[iy][ix]=PEDESTAL;
(clusters+nph)->rms=getPedestalRMS(ix,iy);
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
if ((iy+ir)>=iy && (iy+ir)<ny && (ix+ic)>=ix && (ix+ic)<nx) {
val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir);
}
v=&(val[iy+ir][ix+ic]);
tot+=*v;
if (ir<=0 && ic<=0)
bl+=*v;
if (ir<=0 && ic>=0)
br+=*v;
if (ir>=0 && ic<=0)
tl+=*v;
if (ir>=0 && ic>=0)
tr+=*v;
if (*v>max) {
max=*v;
}
if (ir==0 && ic==0) {
if (*v<-nSigma*cluster->rms)
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
}
}
}
if (bl>=br && bl>=tl && bl>=tr) {
(clusters+nph)->quad=BOTTOM_LEFT;
(clusters+nph)->quadTot=bl;
} else if (br>=bl && br>=tl && br>=tr) {
(clusters+nph)->quad=BOTTOM_RIGHT;
(clusters+nph)->quadTot=br;
} else if (tl>=br && tl>=bl && tl>=tr) {
(clusters+nph)->quad=TOP_LEFT;
(clusters+nph)->quadTot=tl;
} else if (tr>=bl && tr>=tl && tr>=br) {
(clusters+nph)->quad=TOP_RIGHT;
(clusters+nph)->quadTot=tr;
}
if (max>nSigma*cluster->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*cluster->rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*cluster->rms) {
if (val[iy][ix]>=max) {
eventMask[iy][ix]=PHOTON_MAX;
(clusters+nph)->tot=tot;
(clusters+nph)->x=ix;
(clusters+nph)->y=iy;
(clusters+nph)->iframe=det->getFrameNumber(data);
(clusters+nph)->ped=getPedestal(ix,iy,0);
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
(clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir);
}
}
if (interp) {
if (ff) {
interp->addToFlatField((clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),eta_x, eta_y);
} else {
interp->getInterpolatedPosition(ix, iy, (clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),int_x, int_y);
interp->addToImage(int_x, int_y);
}
} else
image[ix+nx*iy]++;
nph++;
image[iy*nx+ix]++;
} else {
eventMask[iy][ix]=PHOTON;
}
} else if (eventMask[iy][ix]==PEDESTAL) {
addToPedestal(data,ix,iy);
}
}
}
nphFrame=nph;
nphTot+=nph;
//cout << nphFrame << endl;
// cout <<"**********************************"<< endl;
writeClusters();
return nphFrame;
};
/*********************************************************
int addFrame(char *data, int ff=0) {
double g=1;
single_photon_hit *cl;
single_photon_hit clust;
if (clusters)
cl=clusters;
else
cl=&clust;
int ccs=clusterSize;
int ccy=clusterSizeY;
double int_x,int_y, eta_x, eta_y;
int nph=0;
double rest[ny][nx];
int cy=(clusterSizeY+1)/2;
int cs=(clusterSize+1)/2;
int ir, ic;
double cc[2][2];
double max=0, tl=0, tr=0, bl=0,br=0, v, vv;
int xoff,yoff;
int skip=0;
// cout <<"fr"<< endl;
double tthr;
if (iframe<nDark) {
//cout << iframe << "+"<< nDark <<endl;
addToPedestal(data);
return 0;
}
newFrame();
// cout << xmin << " " << xmax << " " << ymin << " " << ymax << endl;
for (int ix=xmin; ix<xmax; ix++) {
for (int iy=ymin; iy<ymax; iy++) {
// for (int ix=clusterSize/2; ix<clusterSize/2-1; ix++) {
// for (int iy=clusterSizeY/2; iy<ny-clusterSizeY/2; iy++) {
// cout << ix << " " << iy << endl;
eventMask[iy][ix]=PEDESTAL;
tthr=nSigma*getPedestalRMS(ix,iy)/g;
if (ix==xmin || iy==ymin)
rest[iy][ix]=subtractPedestal(data,ix,iy);
max=0;
tl=0;
tr=0;
bl=0;
br=0;
tot=0;
quadTot=0;
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
if ((iy+ir)>=ymin && (iy+ir)<ymax && (ix+ic)>=xmin && (ix+ic)<xmax) {
//cluster->set_data(rest[iy+ir][ix+ic], ic, ir);
if (ir>=0 && ic>=0 )
rest[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir);
v=rest[iy+ir][ix+ic];//cluster->get_data(ic,ir);
tot+=v;
if (ir<=0 && ic<=0)
bl+=v;
if (ir<=0 && ic>=0)
br+=v;
if (ir>=0 && ic<=0)
tl+=v;
if (ir>=0 && ic>=0)
tr+=v;
if (v>max) {
max=v;
}
// if (ir==0 && ic==0) {
if (v>tthr) {
eventMask[iy][ix]=NEIGHBOUR;
}
//}
}
}
}
if (rest[iy][ix]<=-tthr) {
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
//if (cluster->get_data(0,0)>=max) {
} else if (max>tthr || tot>sqrt(ccy*ccs)*tthr || quadTot>sqrt(cy*cs)*tthr) {
if (rest[iy][ix]>=max) {
if (bl>=br && bl>=tl && bl>=tr) {
cl->quad=BOTTOM_LEFT;
cl->quadTot=bl;
} else if (br>=bl && br>=tl && br>=tr) {
cl->quad=BOTTOM_RIGHT;
cl->quadTot=br;
} else if (tl>=br && tl>=bl && tl>=tr) {
cl->quad=TOP_LEFT;
cl->quadTot=tl;
} else if (tr>=bl && tr>=tl && tr>=br) {
cl->quad=TOP_RIGHT;
cl->quadTot=tr;
}
eventMask[iy][ix]=PHOTON_MAX;
cl->tot=tot;
cl->x=ix;
cl->y=iy;
cl->ped=getPedestal(ix,iy, 0);
cl->rms=getPedestalRMS(ix,iy);
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
if ((iy+ir)>=ymin && (iy+ir)<ymax && (ix+ic)>=xmin && (ix+ic)<xmax) {
cl->set_data(rest[iy+ir][ix+ic],ic,ir);
}
}
}
if (interp) {
if (ff) {
#ifdef M015
if (iy>100)
#endif
interp->addToFlatField(cl->quadTot,cl->quad,cl->get_cluster(),eta_x, eta_y);
// if ((eta_x<0.1 || eta_x>0.9)&&(eta_y<0.1 || eta_y>0.9))
// cout << ix << " " << iy << " " << eta_x <<" " << eta_y << endl;
} else {
interp->getInterpolatedPosition(ix, iy, cl->quadTot,cl->quad,cl->get_cluster(),int_x, int_y);
interp->addToImage(int_x, int_y);
}
} else
image[ix+nx*iy]++;
nph++;
if (clusters) cl=(clusters+nph);
// rest[iy][ix]-=tthr;
} else
eventMask[iy][ix]=PHOTON;
//else if (thr<=0 ) {
//addToPedestal(data,ix,iy);
// }
}
if (eventMask[iy][ix]==PEDESTAL) {
addToPedestal(data,ix,iy);
}
}
}
return nph;
}
******************************************/
/* for (int ix=0; ix<nx; ix++) { */
/* for (int iy=0; iy<ny; iy++) { */
/* skip=0; */
/* max=0; */
/* tl=0; */
/* tr=0; */
/* bl=0; */
/* br=0; */
/* tot=0; */
/* quadTot=0; */
/* quad=UNDEFINED_QUADRANT; */
/* cl->rms=getPedestalRMS(ix,iy); */
/* //(clusters+nph)->rms=getPedestalRMS(ix,iy); */
/* // cout << iframe << " " << nph << " " << ix << " " << iy << endl; */
/* if (ix==0 || iy==0) */
/* val[iy][ix]=subtractPedestal(data,ix,iy); */
/* if (val[iy][ix]<-nSigma*cl->rms) { */
/* eventMask[iy][ix]=NEGATIVE_PEDESTAL; */
/* // cout << "neg ped" << endl; */
/* } else { */
/* for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { */
/* for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { */
/* if ((iy+ir)>=0 && (iy+ir)<ny && (ix+ic)>=0 && (ix+ic)<nx) { */
/* if (ir>=0 && ic>=0) { */
/* val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir); */
/* eventMask[iy+ir][ix+ic]=PEDESTAL; */
/* } */
/* // cout << ir << " " << ic << " " << val[iy+ir][ix+ic] << endl; */
/* v=&(val[iy+ir][ix+ic]); */
/* // if (skip==0) { */
/* tot+=*v; */
/* if (ir<=0 && ic<=0) */
/* bl+=*v; */
/* if (ir<=0 && ic>=0) */
/* br+=*v; */
/* if (ir>=0 && ic<=0) */
/* tl+=*v; */
/* if (ir>=0 && ic>=0) */
/* tr+=*v; */
/* if (*v>max) { */
/* max=*v; */
/* } */
/* } */
/* } */
/* } */
/* if (bl>=br && bl>=tl && bl>=tr) { */
/* cl->quad=BOTTOM_LEFT; */
/* cl->quadTot=bl; */
/* } else if (br>=bl && br>=tl && br>=tr) { */
/* cl->quad=BOTTOM_RIGHT; */
/* cl->quadTot=br; */
/* } else if (tl>=br && tl>=bl && tl>=tr) { */
/* cl->quad=TOP_LEFT; */
/* cl->quadTot=tl; */
/* } else if (tr>=bl && tr>=tl && tr>=br) { */
/* cl->quad=TOP_RIGHT; */
/* cl->quadTot=tr; */
/* } */
/* if (max>nSigma*cl->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*cl->rms || (cl->quadTot)>sqrt(cy*cs)*nSigma*cl->rms) { */
/* if (val[iy][ix]>=max) { */
/* eventMask[iy][ix]=PHOTON_MAX; */
/* cl->tot=tot; */
/* cl->x=ix; */
/* cl->y=iy; */
/* cl->ped=getPedestal(ix,iy, 0); */
/* if (interp) { */
/* if (ff) { */
/* interp->addToFlatField(cl->quadTot,cl->quad,cl->get_cluster(),eta_x, eta_y); */
/* // if ((eta_x<0.1 || eta_x>0.9)&&(eta_y<0.1 || eta_y>0.9)) */
/* // cout << ix << " " << iy << " " << eta_x <<" " << eta_y << endl; */
/* } else { */
/* interp->getInterpolatedPosition(ix, iy, cl->quadTot,cl->quad,cl->get_cluster(),int_x, int_y); */
/* interp->addToImage(int_x, int_y); */
/* } */
/* } else */
/* image[ix+nx*iy]++; */
/* if (clusters) cl=(clusters+nph); */
/* nph++; */
/* } else { */
/* eventMask[iy][ix]=PHOTON; */
/* } */
/* } else if (eventMask[iy][ix]==PEDESTAL) { */
/* addToPedestal(data,ix,iy); */
/* } */
/* } */
/* } */
/* } */
/* return nph; */
/* }; */
virtual void processData(char *data, int *val=NULL) {
if (interp){
switch(fMode) {
case ePedestal:
addToPedestal(data);
break;
case eFlat:
addFrame(data,val,1);
break;
default:
addFrame(data,val,0);
}
} else
singlePhotonDetector::processData(data,val);
};
virtual char *getInterpolation(){return (char*)interp;};
protected:
slsInterpolation *interp;
int id;
//should put it to analogDetector
int xmin, xmax, ymin, ymax;
};
#endif

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