Manual

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 26

DownloadManual
Open PDF In BrowserView PDF
Manual number:
Physikpraktikum für Vorgerückte (VP)
vp.phys.ethz.ch

Drift Chamber
Instructions
D. Hits, G. Guyer, M. Setz
rev. D. Hits, October 5, 2018

1

1

Introduction

This manual is contains only brief introduction to the processes occurring in a
drift chamber.In order to gain more complete understanding of the physics of
the drift chamber a references at the end of this manual should be consulted
[1, 2, 3].
Drift chambers belong to the most important measurement devices of
nuclear and particle physics. They are a central aspect of nearly every large
experiment in high energy physics. In this experiment a small drift chamber
is operated and characterized. After that the trajectories of particles from
the cosmic radiation should be reconstructed.
If a charged particle travels through a gas volume, it leaves a trail of
ionized gas atoms and free electrons behind. By applying an electric field
the ions and electrons can be separated and generate an electric signal. This
signal, however, is very small. A high-energy particle with an elementary
charge produces only about 100 electron/ion-pairs by going through one centimeter of air. Single particles are therefore only detectable after amplifying
this signal.
In a detector filled with gas there is a simple way to amplify the signal
inside the detector, even before it is measured on the outside. If the electric
field is sufficiently strong, the free electrons can be accelerated to the energies
large enough to ionize gas atoms and create and avalanche which will result
in an electric signal many times higher than the original one. The required
electric field strengths are easily generated around very thin wires. By using
very thin signal wires, one can therefore easily create a detectable signal.
Hence already a simple structure allows the detection of particle radiation.
Many detectors are based on this principle, from a simple Geiger counter up
to time projection chambers in high energy experiments with several thousand wires.
A drift chamber additionally makes use of the fact, that the amplification
of the signal only occurs, when the free electrons reach the region of strong
fields in the immediate proximity to a wire. Before reaching this point the
electrons simply drift along the electric field lines, without increasing their
numbers. With a known drift velocity and a measured time difference between the arrival of the particle and the detection of the electric signal the
distance between the signal wire and the trajectory of the particle can therefore be calculated. The location can be reconstructed in such a chamber
with a resolution to a fraction of a millimeter. By combining the position
2

measurement of multiple wires, the trajectory of the particle can be reconstructed. Figure 1.1 shows the general structure of a drift chamber. It is
described in more detail in section 5.2.
Figure 1.2 shows traces of particles, which were being generated by a
electron-proton-collision in the H1-Detector at the HERA storage ring. The
paths are curved, because the detector is inside a strong magnetic field. The
curvature is a measure of the charge and momentum of the particles. By
the way the gas inside the H1-Detector is identical to the gas used in our
experiment.

Figure 1.1: General structure of a drift chamber.

3

Run 248070 Event 1808 Class: 4 8 19 28 29

Date 31/03/1100

H1 Eve nt Di s pl ay 1. 17/ 05
E= -27.6 x 920.0 GeV B= 0.0 kG
DSN=[ h1uk. h1] t t f / e pdat a/ 99e +/ e ppot _f 2025. A00
Run date 99/07/28 15:17
BTOF Gl obal , BG, I A = 000
AST =
RST =

0
0

Y
X

Figure 1.2: Particle trajectories in the central drift chamber of the H1 experiment. The drift chamber is cylindrical and the anode wires are parallel to the
cylindrical axis, therefore they are perpendicular to the image plane. Each
point represents a wire which detected a signal. The positions are corrected
by means of drift duration.

4

2

Electron drift

The electrons released by ionization get quickly to thermal equilibrium through
elastic collisions with the gas atoms. The electrons then move in arbitrary,
frequently changing directions. The average kinetic energy is like in an ideal
gas
3
1
(1)
< mv 2 >= kT.
2
2
At room temperature this correlates to a velocity of 120 km s−1 !
Between collisions the electrons get accelerated by the electric field over
and over again. Thus the motion of the electron cloud goes along the field
lines on average.
For a start we look at a group of electrons all traveling with velocity v.
Along a way dx a fraction N σdx of the electrons collide with a gas atom. N
is the number of gas atoms per unit volume and σ the total collision cross
section. Let’s call n(t) the number of electrons, which didn’t collide with a
gas atom in a time t since the last collision. Thus n(t) can be calculated by
v
dn(t) = −N σvdt = − dt.
l

(2)

The quantity l ≡ N σ is called the mean free path of the electrons in the
gas. Integrating (2) yields
N (t) = n0 exp



v
− t .
l


(3)

~ on the path between two
An electron experiences a constant force eE
collisions. Therefore additionally to the free movement the electron covers
the distance
1 eE 2
∆s =
∆t
(4)
2m
~
along the E-field.
The mean drift velocity for electrons with velocity v is thus
v

∆s(t)e− l t dt
vD (v) =
R −v
te l dt
R
v
1 eE t2 e− l t dt
eE l
=
.
=
R −v
2 m te l dt
mv
R

5

In reality not all electrons are moving at the same velocity, but the velocities are distributed corresponding to the Maxwell-Boltzmann distribution.
Thus to get the mean drift velocity for the whole electron cloud, one has to
average over the thermal velocities. The drift velocity of the electron cloud
is therefore
l
eE
eE
< >=
τ.
(5)
vD =
m
v
m
Where τ is the mean time between two collisions of an electron with a gas
atom.
According to this simple calculation one expects the drift velocity to increase proportional to the electric field strength. For small fields this is
normally the case. The proportionality constant is called the mobility.

3

Gas Amplification

If the accelerating electric field is strong enough, the electrons can gain
enough energy between two collisions, to ionize a gas atom. The new free
electrons get accelerated themselves to the point where they can ionize a gas
atom and the total number of free electrons increases rapidly in a snowballing
effect.
In a constant and sufficient high electric field strength the number of
secondary ionizations, which a drifting electron causes, is proportional to the
covered distance. The proportionality factor α is called the first Townsendcoefficient. The factor is dependent on the electric field strength. One finds
an empirical dependency of the form
B
,
α = A exp −
E




(6)

with coefficients A and B, which depend on the gas.
Hence the total number of electrons increases along the way dx by
dn = nαdx.

(7)

Generally the electric field, in which the gas amplification occurs, is inhomogeneous. Thus α becomes dependent on position. If the gas amplification
starts at a distance r0 , the number of electrons which arrive at the signal
wire (radius r2 ) is
Z
n(x) = n0 exp
6

r2

α(x)dx.

r0

(8)

In principle the characteristics of the electric field are dependent on the
form and potentials of all the electrodes. But within immediate distance to
the signal wires, that is for distances which are very much smaller than the
distances to the other electrodes, the field profile is always the same. For a
cylindrical geometry the field strength can be described by:
E(r) =

V
1
r ln(r2 /r1 )

(9)

Where V is the voltage between the wire and the other electrode, which is
located at radius r1 . From this equation one recognizes, that the field goes
like 1/r near the wire and that with small wires one can achieve high field
strengths. The signal wires in our chamber have a diameter of 50 µm.
The gas amplification or specifically the number of electrons in the avalanche
arriving at the wire is therefore

Z r2

M = exp

 r0






r ln(r2 /r1 ) 
A exp−B

V
r1



V
r ln(r2 /r1 ) 
= expA
exp−B
ln(r2 /r1 )
V

r0



= exp





V
α(r2 ) − α(r0 ) 
ln(r2 /r1 )

The Townsend-coefficient α(r0 ) at the start of the avalanche is much
smaller, than the one near the wire. From equation (6 it follows that for high
enough field strengths α tends to a constant value and thus α(r2 ) − α(r0 ) ≈
const. The gas amplification is therefore dependent on the potential of the
signal wires simply by
M ∝ eV .
(10)
The gas amplification increases exponentially with increasing voltage!
However this increase does not go on forever. If the charge of the avalanche
is high enough to affect the electric field, the resulting signal is no longer proportional to the originally released charge.
If the voltage gets too high, electric discharges start to occur, where
permanent gas discharges take place and a very high current flows. The
equipment can be damaged in this process.
7

4

Cosmic Radiation

Particles, in particular protons, coming from the universe and from the sun
constantly impact the earth. The energy of these particles ranges from 109
up to 1020 GeV. The particles loose their energy by colliding with atoms
in the upper atmosphere. In this process they create jets of new particles.
Many of these secondary particles collide with gas atoms themselves and only
a small fraction reaches the surface of the earth.
In the midst of these secondary particles there are also pions, which decay
into muons and neutrinos after only a short amount of time. The neutral
neutrinos only interact via the weak force and are practically undetectable.
The charged muons loose energy due to ionization, but have cross sections
for inelastic collisions with air atoms which are much smaller than the ones
for the strongly interacting protons.
On the earth’s surface the cosmic radiation then consists mostly of muons.

5

Measurement Setup

The mechanism consists of the actual drift chamber, the trigger, the electronics and a computer for data collection. Figure 5.1 shows a logic diagram
of the setup.
The Figures 5.2 through 5.3b shows the physical view of of some of the
elements in Figure 5.1. It contains the both the trigger logic units and power
supplies from left to right the untis in the Figure 5.2 are:
• Lower voltage power supply for the amplifiers of the photomultipliers
(PMTs)
• Discriminator
• Coincidence unit
• Counter/scalar
• Level converter (NIM to TTL)
• High voltage power supply for cathode
• High voltage power supply for anode (positive voltage)
8

Figure 5.1: Logic diagram of the main parts of the measurement setup.
• High voltage power supply for field wires
• Counter/scalar
• Delay unit

5.1

Trigger formation

The even trigger is formed in the following way. The muons crossing the scintillators produce photons in the scintillator. The photons are converted into
9

electrical pulse by the PMTs futher multiplied and fed into the discriminator. The discriminator analyzers the signal and if the amplitude of the signal
crosses the set threshold, it outputs a square NIM pulse. The NIM pulses
from each discriminator are then fed into the coincidence unit. This unit,
when the both inputs are set in an AND mode, analyzes whether or not the
input pulses overlap in time. If they do, it outputs another NIM pulse, which
in turn is fed into two duplicating counters. Each of the counters counts the
pulses fed into it. Another output from the coincidence unit is delayed by
the delay unit and converted to TTL pulse. The TTL pulse is then fed into
the trigger input of the 1st DRS4 board. When the signal arrives there it
gives the board a command to output the signals that are at the moment
on the inputs of the DRS4 board to the computer screen and record them
to hard disc, if the SAVE mode is activated. Another trigger output is fed
into external trigger of an oscilloscope. Where one can observe the signals
of the scintillators before and after they fed trough the discriminators. You
are strongly encouraged to explore the setup yourself by tracing the cables.
Understanding the trigger system is an important part of the lab.
The Figures 5.3a and 5.3b show the front and the back of the high voltage
power supply of the scintillator PMTs. Since the operation voltage of each
PMT differs slightly. The output of the high voltage power supply if fed into
the 1st input of the high voltage distributor (Fig. 5.3b). The 1st and the 2nd
outputs of the distributor are then supply voltage individually to the PMTs.
The each output can be individually down regulated by a corresponding
knob on the front panel of the distributor. IMPORTANT: The power supply
requires a few seconds to warm up before the high voltage can be switched
ON. After turning on the power suplly wait until the yellow/white indicator
light is ON before flipping the high voltage switch to ON.

5.2

Drift Chamber

The drift field inside of our drift chamber is generated by two parallel electrodes, which have a distance of 100 mm. To have a homogeneous electric
field inside the drift chamber, the potential also has to increase linearly from
the cathode to the anode at the edge of the drift chamber. This is approximately achieved with 9 electrodes, which are placed parallel to each other
in a distance of 1 cm and enclose the drift chamber. Their potentials are
linearly graduated with a bleeder chain. The resulting electric field looks
similarly to the electric field in Figure 5.4.
10

Figure 5.2: NIM crate with the main logic and power supplies.
The Figure 5.5 shows a CAD cross section of the drift camera.
The anode wires, which produce the gas amplification, are placed 5 mm in
front of the ground plate. The sensitive region in which the particles can be
detected is between those wires and the cathode and has a length of 9.5 cm.
The 8 wires are arranged parallel to each other and have a distance of
10 mm between each other. Their diameter is only 50 µm, so they can produce
the needed high electric field strengths for the gas amplification. Between the
anode wires there are field wires that make the electric field more even. These
field wires have an own voltage supply, which can be left at zero though.
The anode wires connected to a charge sensitive amplifier powered by
the low voltage power supply, which amplifies the signal coming from the
wire even further. This amplifier is mounted inside the drift chamber, at the
end of each anode wire. The low voltage power supply is connected to the
amplifier by three jacks at the front of the chamber and has to be turned on
in order of being able to detect the signals on the anode wires.
11

(a)

(b)

Figure 5.3: The front (a) and back (b) of the high voltage power supply and
high voltage distributor for the scintillator PMTs.
12

Figure 5.4: Electric field lines and equipotential lines inside the drift chamber.
The electrons drift from left to right, where the signal wires are.
The drift chamber is mounted such that the wires are horizontal and the
plane of the wires is vertical. The drift direction for the electrons is thus
horizontal. A particle which travels vertically through the drift chamber will
therefore induce a signal in all wires. Figure 5.6 shows the interior of the
drift chamber with the electrodes and the signal wires.

5.3

The DRS4 unit

To process the incoming data from the signal wires, the wires are connected
to DRS4 boards. These DRS4 boards were designed at the Paul Scherrer
Institute and are capable of digitizing 4 channels each. Two boards are
linked together to process all 8 channels. The DRS4 boards work like a
13

Figure 5.5: CAD cross section of the drift camera. All the distances shown
are correct. The camera there only 8 anode wires (shown as black dots on
the left side on the picture). On each side of the anode wires the field wires
(empty circles) are located equidistantly from each anode neighboring anode
wire. The cathode plate is 94.3 mm right of the anode wires. About 4 mm
To the left of the anode wires the ground plate is located. On the top and on
the bottom of the drift volume the field plates are position at roughly equal
distances.
digital oscilloscope. For details on the operation of the DRS4 boards please
refer to the DRS4 manual [4].
The DRS4 unit comes with a computer program called drsosc located
in ~/Desktop/drs-5.0.6/. A softlink to the executable is put in the home
14

Figure 5.6: A drawing of the drift chamber. One can observe the anode wires
(the field wires between the anode wires are not shown), the electrodes which
make a more homogeneous field and the cathode and ground plate.
directory. The program can be started from the command line as follows:
1

$ ./ drsosc

It opens a GUI that emulates an oscilloscope interface and can display all
8 channels. The boards have a port for an external trigger which can be connected to the trigger logic. The trigger output of the first board is connected
to the second board, so both boards receive the trigger at approximately the
same time.

6

Measurements

The main goal of this experiment is to familiarize oneself with an operation
of a small drift chamber and observe the tracks of the cosmic muons passing
through it. Additionally you will develop your own data analysis technique
using as a provided data conversion program as a starter. You are advised to
perform the following measurements. Start with finding the working point
of the scintillators. Then study the gas amplification dependence on the
15

anode voltage. Followed by the study of the dependence of the ion drift
velocity on the cathode voltage. Finally, observe a few events and plot the
muon traces. The following sections will give you some hints on how to
perform the measurement. Overall you are encouraged to your own methods
to measure the above parameters. However, if your methods deviate from
the suggested, substantiate them by solid physical arguments.

6.1

Saving and analyzing data

Save data in binary format (remember to add .dat extension to the file name
as it is not there by default) In the directory ~/Software/driftchamber/code/
there is a program which reads the binary datafile and makes numpy arrays
for each event. Please NOTE that the extantions to the analysis code should
be written by you!

6.2

Finding the working point of the scintillators

To get a good trigger signal you first have to find the working point of the
two scintillators. For any given discriminator threshold the scintillator has
a specific voltage, where all incoming signals get detected, but the voltage
isn’t high enough to detect too much background noise. This manifests itself
in a plateau in the counts per second around this working point. You apply
a voltage of about 2 kV on the scintillators and put one of them to "and"
on the coincidence unit. Then you regulate the threshold so that there are
a few counts per second. The threshold voltage can be measured with the
external voltmeter. Now you have to count the triggered signals and calculate
the number of counts per second for different applied voltages from around
1.9 kV to 2.1 kV. Plot the counts per second against the voltage and you will
see a plateau. The working point of the scintillator is the highest voltage
of the plateau. Repeat the measurement for the second scintillator. The
working points of the scintillators do not have to be at the same voltage, but
double check if the plateaus are at the same number of counts per second.

6.3

Purifying the gas

The experiment is performed at an atmospheric pressure. The gas inside
the chamber is a mixture of argon and methane (50:50). It is supplied from
the pressurized gas cylinder marked A on Figure 6.1. The chamber is also
16

connected to a pressure pump (D), which can evacuate the chamber. In order
to evacuate the chamber the valve at the chamber to the pump (B) and the
valve at the pump itself both should be opened. While the valve to the
gas cyllinder (C) should be closed. The filling of the chamber is performed
by closing the valves (B) and (D) and openning valves (A) and (C). Before
starting the experiment it is wise to empty the chamber and fill it up again
several times, to make sure the gas inside the chamber is pure enough. The
pressure inside the chamber should be at or slightly above 1 bar in the end.
IMPORTANT: When you finish purifying the gas inside the chamber make
sure that the valve (A) on the gas cyllinder is closed.

Figure 6.1: To evacuate the chamber turn on the pump under the table
and open valve D and B. Do open valve B gently, such that the pressure
doesn’t decrease too fast otherwise it will start to smell inside the room. To
stop evacuating first close valve B and then D. To fill the chamber with gas,
first open valve A and then gently open valve C until the desired pressure is
achieved. Afterwards close valve C and A.
17

6.4

Gas Amplification

In the next part you want to find the optimum anode voltage amplifies
that provides the maximum amplification while keeping the frequency of
the sparking (electrostatic discharge) inside the chamber low.
In order to have a high enough count rate, a 90 Sr-probe can be put in
the window on top of the drift chamber. This isotope decays in a β-decay
into 90 Y, which is also a β-emitter. The electrons from the β-decays have a
wide spectrum up to a maximum energy of 2.28 MeV. The scintillators and
the metal wall of the drift chamber stop these low-energy electrons, which is
why the source has to be placed on the window and the DRS4 board should
be set to trigger on one of the channels.
Then you have to repeat the measurement for increasing anode voltages
and plot the average pulse amplitude against the anode voltage. Be careful
with increasing the voltage, because the actual voltage follows the adjusted
value with some delay. Increase the voltage only in small steps and wait
until it stabilizes. If you see a breakdown on the oscilloscope, immediately
decrease the anode voltage. Figure 6.2 shows how a typical breakdown looks
like on the oscilloscope. Do not increase the anode voltage over 4 kV.

6.5

Drift Velocity

Now set the anode voltage to the optimal value, which was determined in the
previous task. Because we now want to make a time measurement, the external trigger should be used. The scintillators must be placed above and below
the drift chamber. The scintillators should be positioned exactly vertically
above each other. In oder to find the time electron needs to travel through
the whole chamber (94.3 mm) to the anode wire.The events with the earliest
signals (muon passes next to the anode wire) and the latest signals (muon
passes next to the cathode plate) should be observed. Note that because of
the geometrical acceptance of the scintillator triger, such events have very
low probability. (You are encouraged to estimate this probability). Therefore
a significant ammount of events (∼10000) should be recorded. Since the rate
of the muons is low, this measurements should be run overnight.
With the assumption of a constant velocity you can then derive the drift
velocity. Repeat this measurement for several cathode voltages between
500 V and 4000 V to see how the drift velocity depends on the cathode voltage. The exact ammount of points you chose will depend on your time and
18

Figure 6.2: A picture of a typical display of an oscilloscope at the time of
a breakdown. The anode voltage inside the drift chamber gets too high
and electric discharge occurs, which produces this signal. If a breakdown is
visible or audible inside the chamber, the anode voltage has to be decreased
immediately.
curiousity.

6.6

Muon tracking

Now you have all the data to track the muons. You can either collect a small
ammount data at you favourite settings or use a sample of the data from the
drift velocity measurements. The drift velocity will help you to compute the
distance at which the muon passed the signal wire. Then using the vertical
positions wires plot the trajectories.

References
[1] Luigi Rolandi Walter Blum, Werner Riegler. Particle detection with drift
chambers. Wiley, Berlin, 2008.

19

[2] Gelnn F. Knoll. Radiation detection and measurement. Springer, Hoboken, New Jersey, 2010.
[3] Wikipedia. NIM instrumentation module.
[4] Stefan Ritt. DRS4 evaluation board user’s manual.

20

A

Sample Analysis Code:

The latest analysis code is located at:
https://github.com/dmitryhits/driftchamber/blob/master/code/decode.
py
Note that at the moment this is the only program that works, but you
are encouraged to make others working as well.
1
2
3

4

#! / u s r / b i n / env python
"""
S c r i p t t o c o n v e r t b i n a r y format t o r o o t f o r DRS4 e v a l u a t i o n
boards .
h t t p : / /www. p s i . ch / d r s / e v a l u a t i o n −board

5
6

7
8
9

Jonas Rembser ( rembserj@phys . e t h z . ch ) , 2016−04−15 based on work
by
Gregor Kasieczka , ETHZ, 2014−01−15
based on decode . C by Dmitry H i t s
"""

10
11
12
13
14

15
16

from s y s import argv , e x i t
from ROOT import TFile , TTree , TTimeStamp , AddressOf
from ROOT. s t d import v e c t o r
from numpy import array , u i n t 3 2 , cumsum , r o l l , z e r o s , f l o a t 3 2 ,
arange
from s t r u c t import unpack
import m a t p l o t l i b . p y p l o t a s p l t

17
18
19
20

########################################
# Prepare Input
########################################

21
22
23
24
25
26

i f not l e n ( argv ) == 2 :
p r i n t ( " Wrong number o f arguments ! " )
p r i n t ( " Usage : python decode . py f i l e n a m e . dat " )
print ( " Exiting . . . " )
exit ()

27
28
29

i n p u t _ f i l e n a m e = argv [ 1 ]
f = open ( i n p u t _ f i l e n a m e , " rb " )

30
31
32
33

########################################
# Prepare Output
########################################

34

21

35
36

37

# F i l e and T r e e s
o u t f i l e = T F i l e ( i n p u t _ f i l e n a m e . r e p l a c e ( " . dat " , " . r o o t " ) , ’
recreate ’ )
o u t t r e e = TTree ( ’ t r e e ’ , ’ t r e e ’ )

38
39

40
41

42
43
44
45
46

# C r e a t e board and e v e n t s e r i a l number and d a t e v a r i a b l e s and
add t o t r e e
timestamp = TTimeStamp ( )
o u t t r e e . Branch ( " EventDateTime " , " TTimeStamp " , AddressOf (
timestamp ) )
board_serials = vector ( int ) ()
o u t t r e e . Branch ( " B o a r d S e r i a l s " , b o a r d _ s e r i a l s )
e v e n t _ s e r i a l = a r r a y ( [ 0 ] , dtype=u i n t 3 2 )
o u t t r e e . Branch ( " EventNumber " , e v e n t _ s e r i a l , " EventNumber/ i " )
# more b r a n c h e s w i l l be added d y n a m i c a l l y i n t h e f i r s t w h i l e
loop

47
48
49
50

########################################
# Actual Work
########################################

51
52
53

54

55

"""
Read i n e f f e c t i v e time width b i n s i n ns and c a l c u l a t e t h e
r e l a t i v e time from
t h e e f f e c t i v e time b i n s . This i s j u s t a rough c a l c u l a t i o n b e f o r e
the c o r r e c t i o n
done f u r t h e r down i n t h e code

56
57

58

The s c r i p t a l s o g e t s c h a n n e l number i n f o r m a t i o n from t h i s
s e c t i o n to c r e a t e
t h e a p p r o p r i a t e number o f t r e e b r a n c h e s .

59
60

61
62
63
64

NOTE: t h e c h a n n e l s 0−3 a r e f o r t h e f i r s t board and c h a n n e l s 4−7
a r e f o r t h e s e c o n d board
"""
# To h o l d t o t h e t o t a l number o f c h a n n e l s and b o a r d s
n_ch = 0
n_boards = 0

65
66

67
68

# Empty l i s t s f o r c o n t a i n i n g t h e v a r i a b l e s c o n n e c t e d t o t h e t r e e
branches
channels_t = [ ]
channels_v = [ ]

69
70

# L i s t o f numpy a r r a y s t o s t o r e t h e time b i n i n f o r m a t i o n

22

71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

87

timebins = [ ]
"""
This l o o p e x t r a c t s time i n f o r m a t i o n f o r each DRS4 c e l l
"""
w h i l e True :
header = f . read (4)
# For s k i p p i n g t h e i n i t i a l time h e a d e r
i f h e a d e r == b "TIME" :
continue
e l i f h e a d e r . s t a r t s w i t h ( b "C" ) :
n_ch = n_ch + 1
# Create v a r i a b l e s . . .
c h a n n e l s _ t . append ( z e r o s ( 1 0 2 4 , dtype=f l o a t 3 2 ) )
channels_v . append ( z e r o s ( 1 0 2 4 , dtype=f l o a t 3 2 ) )
# . . And add t o t r e e
o u t t r e e . Branch ( " chn {}_t " . format ( n_ch ) , c h a n n e l s _ t [ − 1 ] , "
chn {}_t [ 1 0 2 4 ] / F" )
o u t t r e e . Branch ( " chn {}_v" . format ( n_ch ) , channels_v [ − 1 ] , "
chn {}_v [ 1 0 2 4 ] / F" )

88
89
90

# Write t i m e b i n s t o numpy a r r a y
t i m e b i n s . append ( a r r a y ( unpack ( ’ f ’ ∗ 1 0 2 4 , f . r e a d ( 4 ∗ 1 0 2 4 ) ) ) )

91
92

93

94
95
96
97

# Increment t h e number o f b o a r d s when s e e i n g a new s e r i a l
number
# and s t o r e t h e s e r i a l numbers i n t h e board s e r i a l numbers
vector
e l i f h e a d e r . s t a r t s w i t h ( b "B#" ) :
b o a r d _ s e r i a l = unpack ( b ’H ’ , h e a d e r [ 2 : ] ) [ 0 ]
b o a r d _ s e r i a l s . push_back ( b o a r d _ s e r i a l )
n_boards = n_boards + 1

98
99
100
101

# End t h e l o o p i f h e a d e r i s not CXX o r a s e r i a l number
e l i f h e a d e r == b "EHDR" :
break

102
103
104

105

106

107

"""
# This i s t h e main l o o p One i t e r a t i o n c o r r e s p o n d s t o r e a d i n g one
channel every
# few c h a n n e l s a new e v e n t can s t a r t We know t h a t t h i s i f t h e
c a s e i f we s e e
# "EHDR" i n s t e a d o f " C00x " ( x = 1 . . 4 ) I f we have a new e v e n t : F i l l
the tree , r e s e t
# t h e branches , i n c r e m e n t e v e n t c o u n t e r The b i n a r y format i s
described in :

23

108

109

110

111
112

# h t t p : / /www. p s i . ch / d r s / DocumentationEN / manual_rev40 . pdf ( page
24)
# What happens when m u l t i p l e b o a r d s a r e d a i s y c h a i n e d : a f t e r t h e
C004 v o l t a g e s o f
# t h e f i r s t board , t h e r e i s t h e s e r i a l number o f t h e next board
before i t starts
# a g a i n with C001 .
"""

113
114
115
116
117
118

current_board = 0
t c e l l = 0 # current trigger c e l l
t_00 = 0 # time i n f i r s t c e l l i n f i r s t c h a n n e l f o r a l i g n m e n t
is_new_event = True

119
120

121

i n f o _ s t r i n g = " Reading i n e v e n t s measurend with {0} c h a n n e l s on
{1} board ( s ) . . . "
p r i n t ( i n f o _ s t r i n g . format ( n_ch , n_boards ) )

122
123
124
125
126
127
128

w h i l e True :
# S t a r t o f Event
i f is_new_event :
e v e n t _ s e r i a l [ 0 ] = unpack ( " I " , f . r e a d ( 4 ) ) [ 0 ]
p r i n t ( " Event : " , e v e n t _ s e r i a l [ 0 ] )
is_new_event = F a l s e

129
130

131
132
133

134

# S e t t h e timestamp , where t h e m i l l i s e c o n d s need t o be
converted to
# n a n o s e c o n d s t o f i t t h e f u n c t i o n arguments
d t _ l i s t = unpack ( "H" ∗ 8 , f . r e a d ( 1 6 ) )
timestamp_args = l i s t ( d t _ l i s t [ : − 2 ] ) + [ d t _ l i s t [ −2]∗ i n t ( 1
e6 ) , 1 , 0 ]
timestamp . S e t ( ∗ timestamp_args )

135
136
137
138
139
140
141

# F l u f f t h e s e r i a l number and r e a d i n t r i g g e r c e l l
f l u f f = f . read (4)
t c e l l = unpack ( ’H ’ , f . r e a d ( 4 ) [ 2 : ] ) [ 0 ]
# Reset c u r r e n t board number
current_board = 0
continue

142
143
144
145
146

# Read t h e
# EHDR −>
# C00x −>
# ""
−>

header , t h i s i s e i t h e r
f i n i s h event
r e a d t h e data
end o f f i l e

24

147

header = f . read (4)

148
149
150
151
152
153

# Handle next board
i f h e a d e r . s t a r t s w i t h ( b "B#" ) :
current_board = current_board + 1
t c e l l = unpack ( b ’H ’ , f . r e a d ( 4 ) [ 2 : ] ) [ 0 ]
continue

154
155
156
157
158
159

# End o f Event
e l i f h e a d e r == b "EHDR" :
# F i l l previous event
outtree . F i l l ()
is_new_event = True

160
161
162
163
164

165
166

# Read and s t o r e data
e l i f h e a d e r . s t a r t s w i t h ( b "C" ) :
# t h e v o l t a g e i n f o i s 1024 f l o a t s with 2−byte p r e c i s i o n
chn_i = i n t ( h e a d e r . decode ( ’ a s c i i ’ ) [ − 1 ] ) + current_board
∗ 4
s c a l e r = unpack ( ’ I ’ , f . r e a d ( 4 ) )
v o l t a g e _ i n t s = unpack ( b ’H ’ ∗ 1 0 2 4 , f . r e a d ( 2 ∗ 1 0 2 4 ) )

167

"""
C a l c u l a t e p r e c i s e t i m i n g u s i n g t h e time b i n s and t r i g g e r

168
169

cell
170
171

172

173

174
175
176

177
178

179
180
181
182
183
184

s e e p . 24 o f t h e DRS4 manual f o r t h e e x p l a n a t i o n
t h e f o l l o w i n g l i n e s sum up t h e t i m e s o f a l l c e l l s
s t a r t i n g from t h e t r i g g e r c e l l
t o t h e i_th c e l l and s e l e c t o n l y even members , b e c a u s e
the amplitude of the adjacent c e l l s are averaged .
The width o f t h e b i n s 1024 −2047 i s i d e n t i c a l t o t h e b i n s
0 −1023 , t h a t i s why t h e a r r a y s a r e s i m p l y extended
b e f o r e p e r f o r m i n g t h e cumsum o p e r a t i o n
"""
t i m e b i n s _ f u l l = l i s t ( r o l l ( t i m e b i n s [ chn_i −1] , − t c e l l ) )+
l i s t ( r o l l ( t i m e b i n s [ chn_i −1] , − t c e l l ) )
t = cumsum ( t i m e b i n s _ f u l l ) [ : : 2 ]
# time o f f i r s t c e l l f o r c o r r e c t i o n , f i n d t h e time o f
t h e f i r s t c e l l f o r each channel ,
# b e c a u s e o n l y t h e s e c e l l s a r e a l i g n e d i n time
t_0 = t [(1024 − t c e l l ) %1024]
i f chn_i % 4 == 1 :
t_00 = t_0
# A l i g n a l l c h a n n e l s with t h e f i r s t c h a n n e l
t = t − ( t_0 − t_00 ) # c o r r e c t i o n

25

# TODO: i t i s a b i t u n c l e a r how t o do t h e c o r r e c t i o n

185

with
186

187

188
189

# TODO: m u l t i p l e boards , s o t h e b o a r d s a r e j u s t
c o r r e c t e d i n d e p e n d e n t l y f o r now
# TODO: f i n d t h e a l i g n m e n t o f t h e b o a r d s by s e n d i n g t h e
same s i g n a l t o both b o a r d s
"""
The f o l l o w i n g l i s t s o f numpy a r r a y s can be p l o t t e d o r
used i n t h e f u r t h e r a n a l y s i s .

190
191

192
193
194
195

NOTE: t h e c h a n n e l s 0−3 a r e f o r t h e f i r s t board and
c h a n n e l s 4−7 a r e f o r t h e s e c o n d board
"""
f o r i , x i n enumerate ( v o l t a g e _ i n t s ) :
channels_v [ chn_i − 1 ] [ i ] = ( ( x / 6 5 5 3 5 . ) − 0 . 5 )
c h a n n e l s _ t [ chn_i − 1 ] [ i ] = t [ i ]

196
197
198
199
200

# End o f F i l e
e l i f h e a d e r == b " " :
outtree . F i l l ()
break

201
202
203
204
205

# Clean up
f . close ()
o u t t r e e . Write ( )
o u t f i l e . Close ()

26



Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.5
Linearized                      : No
Page Count                      : 26
Page Mode                       : UseOutlines
Author                          : 
Title                           : 
Subject                         : 
Creator                         : LaTeX with hyperref package
Producer                        : pdfTeX-1.40.18
Create Date                     : 2018:10:05 12:34:09+02:00
Modify Date                     : 2018:10:05 12:34:09+02:00
Trapped                         : False
PTEX Fullbanner                 : This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) kpathsea version 6.2.3
EXIF Metadata provided by EXIF.tools

Navigation menu