Skip to content

Commit f4c7375

Browse files
committed
Updated README
Updated and merged the readme from PENScintAnalysis.jl and PENBBControl.jl
1 parent c208ff5 commit f4c7375

File tree

4 files changed

+158
-45
lines changed

4 files changed

+158
-45
lines changed

README.md

+145-33
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
11
# PENScintAnalysis.jl
2-
[WIP] PEN Scintillation Project Signal Analysis
2+
[WIP] PEN Scintillation Project Signal Analysis & Data Taking
3+
34
## Update
4-
`PENAnalysisTools.jl` and `PENAnalysisToolsLuis.jl` have been merged to `PENScintAnalysis.jl`
5+
* `PENAnalysisTools.jl` and `PENAnalysisToolsLuis.jl` have been merged to `PENScintAnalysis.jl`.
6+
* `PENScintAnalysis.jl` and `PENBBControl.jl` have been merged. [06/2022]
7+
* **Dark box control:** so far, the XIMC motorised stages, HV control and Struck data taking are part of the package.
8+
* **Data analysis**: handling Struck raw data, converting to LEGEND HDF5 (read & write)
9+
10+
## Table of contents
11+
- [PENScintAnalysis.jl](#penscintanalysisjl)
12+
- [Update](#update)
13+
- [Table of contents](#table-of-contents)
14+
- [Required packages](#required-packages)
15+
- [Read data from Struck ADC](#read-data-from-struck-adc)
16+
- [Read "old formatted" HDF5 files](#read-old-formatted-hdf5-files)
17+
- [Arguments](#arguments)
18+
- [Example](#example)
19+
- [Store Struck data as HDF5](#store-struck-data-as-hdf5)
20+
- [Take data with the Struck ADC](#take-data-with-the-struck-adc)
21+
- [Arguments](#arguments-1)
22+
- [Example settings](#example-settings)
23+
- [XIMC motorised stages](#ximc-motorised-stages)
24+
- [Example:](#example-1)
25+
- [HV control](#hv-control)
26+
- [BB scans](#bb-scans)
27+
- [Arguments](#arguments-2)
28+
529

630
## Required packages
731
A few packages required for `PENScintAnalysis.jl` are not registered. These can be found here:
@@ -31,34 +55,32 @@ Reads the outdated dataformat. Outdated means **non-LegendHDF5IO compatible**. Y
3155
- `nevents::Int`: Number of events to read in. Default: all events.
3256
- `nsubfiles::Int`: Number of subfiles to read in. Default: all.
3357
- `subfiles`: Array of indices of subfiles to read in. Default: empty = all.
34-
35-
36-
## Store data as HDF5
37-
38-
You can directly convert `*.dat` files to `*.h5` by using:
39-
40-
- `struck_to_h5(filename::String; conv_data_dir="../conv_data/")`
41-
42-
Or you read in the data as before and store it using `writeh5(filename::String, typed_table)` where `typed_table` is your output from `read_data_from_struck()`.
43-
44-
**Please note that you can't store an array of vectors/arrays in HDF5! You have to convert that array with `VectorOfArrays(ARRAY)` first.**
45-
58+
4659
### Example
4760

4861
```julia
4962
filename = "path/to/h5/file.h5"
5063
file_info = get_h5_info_old(filename)
51-
i = 1
52-
i_max = length(file_info["names"])
5364

54-
while i <= i_max
65+
for i in eachindex(file_info["names"])
5566
data = read_old_h5_structure(filename, subfiles=[i])
5667
# Do analysis separate for each subfile to avoid OutOfMemory() issues
57-
i += 1
5868
end
5969
```
6070

6171

72+
## Store Struck data as HDF5
73+
74+
You can directly convert `*.dat` files to `*.h5` by using:
75+
76+
- `struck_to_h5(filename::String; conv_data_dir="../conv_data/")`
77+
78+
Or you read in the data as before and store it using `writeh5(filename::String, tt)` where `tt` is your output from `read_data_from_struck()`.
79+
80+
**Please note that you can't store an array of vectors/arrays in HDF5! You have to convert that array with `VectorOfArrays(ARRAY)` first.**
81+
82+
83+
6284

6385
## Take data with the Struck ADC
6486

@@ -73,20 +95,110 @@ Creates an individual `pmt_daq.scala` file and takes data which are converted to
7395
### Example settings
7496

7597
```julia
76-
settings = (fadc = "gelab-fadc08",
77-
output_basename = "test-measurement",
78-
data_dir = "../data/",
79-
conv_data_dir = "../conv_data/",
80-
measurement_time = 20,
81-
number_of_measurements = 5,
82-
channels = [1,2,3,4,5,6],
83-
trigger_threshold = [55],
84-
trigger_pmt = [5,6],
85-
peakTime = 2,
86-
gapTime = 2,
87-
nPreTrig = 192,
88-
nSamples = 256,
89-
saveEnergy = true,
90-
delete_dat = true
98+
settings = (
99+
fadc = "gelab-fadc08", # Your Struck device
100+
output_basename = "test-measurement",
101+
data_dir = "../data/", # where you want to store the raw data (*.dat)
102+
conv_data_dir = "../conv_data/", # where you want to store the converted data (*.h5)
103+
measurement_time = 20,
104+
number_of_measurements = 5, # rather take more measurements instead of creating huge files
105+
channels = [1,2,3,4,5,6],
106+
trigger_threshold = [55], # in ADC
107+
trigger_pmt = [5,6],
108+
peakTime = 2,
109+
gapTime = 2,
110+
nPreTrig = 192,
111+
nSamples = 256,
112+
saveEnergy = true, # actually not implemented
113+
delete_dat = true # delete the raw data file after converting
91114
)
92115
```
116+
117+
118+
## XIMC motorised stages
119+
120+
To start the connection to the motors, use `motor = mymotor()`. It will automatically save the settings needed for the motors. They will be initialized when starting the connection, but can always be intialized by calling `Initialize(motor)`. This overwrites the settings which might have changed after a power outage.
121+
122+
To calibrate the motors, i.e. to set the 0 to the end of the motor stage at the bottom left of the setup, the functions `CalibrateX` and `CalibrateY` are used.
123+
For example, `CalibrateX(motor)` calibrates the X-motor. If both motors should be calibrated, call `Calibrate(motor)`.
124+
125+
To move the motors, the commands `XMoveMM` and `YMoveMM` are used. These functions take as arguments the position in mm and the motor.
126+
For example `XMoveMM(15,motor)` moves the X-motor to 15mm. This function blocks the program until the final destination is reached.
127+
To avoid the block, call the function with the keyword argument `XMoveMM(15,motor,block_till_arrival = false)`.
128+
129+
To get the position of the motors, call `PosX(motor)` and `PosY(motor)`. They are given in units of mm. To print it to the terminal, `Pos(motor)` can be used. Note that the value at 0 has a negative sign, as the motor stage coordinates are inverted during the conversion to mm.
130+
131+
### Example:
132+
```julia
133+
# Initialize
134+
motor = mymotor()
135+
Calibrate(motor)
136+
137+
# Get current position
138+
pos_x = PosX(motor)
139+
pos_y = PosY(motor)
140+
@info(pos_x, pos_y)
141+
142+
# Move stage to x = 42, y = 24 in units of mm
143+
XMoveMM(42.0,motor)
144+
YMoveMM(24.0,motor)
145+
```
146+
When changing the connection of the motors to the serial hub (or using a different serial hub), please use:
147+
```julia
148+
device = "gelab-serialXX"
149+
ports = [2001, 2011]
150+
motor = mymotor(device, ports)
151+
```
152+
153+
## HV control
154+
The HV supply for the PMTs can be controlled as follows:
155+
156+
Define the login details to establish the connection:
157+
```julia
158+
login_payload = JSON.json(Dict("i"=>"", "t" => "login", "c"=> Dict("l"=>"USERNAME", "p"=>"PASSWORD", "t" => ""), "r" => "websocket"))
159+
ip = "ws://xxx.xxx.xxx.xxx:8080"
160+
```
161+
Basic controls
162+
```julia
163+
# Get all measured voltages
164+
get_measured_HV(ip)
165+
# Get all set voltages (to compare set and measured)
166+
get_set_HV(ip)
167+
# Set voltage (value) to one channel
168+
voltage_goto(ip, channel::Int, value::Real)
169+
# e.g. set channel 2 to -975 V
170+
voltage_goto(ip, 2, -975)
171+
172+
```
173+
174+
175+
176+
177+
## BB scans
178+
To start a scan with the stage you have available 3 options:
179+
`PENBBScan2D(x_start, y_start, step_x, step_y, x_ends, y_ends, HolderName::String, time_per_point)`.
180+
181+
This function can used to perform an automate scan in 2D (x,y axis)
182+
This function requires as input the starting point (x_start,y_start), and the end point (x_ends,y_ends) as well
183+
as the step sizes in both axis(step_x,step_y). All values are in mm. The range specified muss be in the interval `x in [0.0,100.0]`, `y in [0.0,100.0]`
184+
In addition you can specify the name of the holder or sample and time of data taking for each position
185+
PENBBScan2D(x_start, y_start, step_x, step_y, x_ends, y_ends, HolderName::String, time_per_point).
186+
187+
Example: `PENBBScan2D(0.0,0.0,20.0,20.0,40.0,40.0,"small",2)` will do a scan in the rectangle x: 0.0->40 mm; y: 0.0 -> 40 mm with steps of 20. mm in each direction
188+
189+
190+
### Arguments
191+
- `x_start`: intial point in x
192+
- `y_start`: intial point in y
193+
- `step_x`: step size in x
194+
- `step_y`: step size in y
195+
- `x_ends`: final point in x
196+
- `y_ends`: final point in y
197+
- `HolderName::String`: name of the holder of piece you are scanning
198+
- `time_per_point`: time of data taking in each point.
199+
200+
The next funtions will do a 1D scan.
201+
```julia
202+
PENBBScan1DY(x_start, y_start, step_y, y_ends, HolderName::String, time_per_point)
203+
PENBBScan1DX(y_start, x_start, step_x, x_ends, HolderName::String, time_per_point)
204+
```

TODO.md

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
TODO PENScintSignalAnalysis.jl
1+
TODO PENScintAnalysis.jl
22
==============================
33

4-
* Structs SimilarWaveforms and Waveform (both immutable, so they can be a bitstype when using UnsafeArrays).
5-
6-
* Forward functions on waveforms::Waveforms to f(waveforms.samples)
7-
8-
* Write a package to ease creation of custom SOA types ("CustomStructsOfArrays.jl"?).:
9-
10-
* Common super-type "[Abstract]CustomStructOfArrays" for common methods?
11-
* Use generated functions instead of macros? Support for `uview()`?
12-
* Broadcast-like behaviour: Array length one implies same value for all entries.
4+
* Test functionality after merging `PENScintAnalysis.jl` and `PENBBControl.jl`.
5+
* Create tutorial for dark box data taking
6+
* Write documentation

src/HV_control/HV_tools.jl

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# login_payload= JSON.json(Dict("i"=>"", "t" => "login", "c"=> Dict("l"=>"LOGIN", "p"=>"PASSWORD", "t" => ""), "r" => "websocket"))
2-
31
function _construct_request(i, command, item, c = "*", v = "", u = "")
42
return JSON.json(
53
Dict(

src/motor_control/motor_commands.jl

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ function mymotor()::Array{XIMCMotor,1}
88
return m
99
end
1010

11+
function mymotor(device::String, ports)::Array{XIMCMotor,1}
12+
m = [
13+
XIMCMotor(device, ports[1]),
14+
XIMCMotor(device, ports[2])
15+
]
16+
Initialize(m)
17+
return m
18+
end
19+
1120
function _Initialize(motor::XIMCMotor)
1221
fbs1 = motor[Feedback, Settings]
1322
sleep(1)

0 commit comments

Comments
 (0)