98
99
p r i n t f
(
” R e a d i n g p a c k e t s :
\
n ”
) ;
100
// r e a d 10000 p a c k e t s
101
w h i l e
( (
p a c k e t c o u n t
<
1 0 0 0 0 ) )
102
{
103
// g e t p o i n t e r s t o a c q u i r e d p a c k e t s
104
s t a t u s
=
x t d c 4 r e a d
(
d e v i c e
, &
r e a d c o n f i g
, &
r e a d d a t a
) ;
105
i f
(
s t a t u s
!=
CRONO OK
)
106
{
107
S l e e p
( 1 0 0 ) ;
108
p r i n t f
(
”
−
No d a t a !
−\
n ”
) ;
109
}
110
e l s e
111
{
112
// i t e r a t e o v e r
a l l
p a c k e t s r e c e i v e d w i t h t h e l a s t r e a d
113
c r o n o p a c k e t
*
p
=
r e a d d a t a
.
f i r s t p a c k e t
;
114
w h i l e
(
p
<
=
r e a d d a t a
.
l a s t p a c k e t
)
115
{
116
// do s o m e t h i n g w i t h t h e data , e . g .
c a l c u l a t e c u r r e n t r a t e
117
GroupAbsTime
=
p
−
>
t i m e s t a m p
;
118
i f
(
p a c k e t c o u n t
%
Up dat eCo unt
== 0 )
{
119
double
R a t e
= 1 . / ( (
double
) (
GroupAbsTime
−
G r o u p A b s T i m e o l d
)
*
1
e
←
-
−
9
*
10/6/(
double
)
Up date Cou nt
) ;
120
p r i n t f
(
”
\
r%f kHz ”
,
R a t e
) ;
121
G r o u p A b s T i m e o l d
=
GroupAbsTime
;
122
}
123
124
// . . o r p r i n t
h i t s ( n o t a good i d e a a t h i g h d a t a r a t e s ,
125
// s o l e t
'
s do t h a t o n l y f o r e v e r y 1000 th p a c k e t . . . )
126
// p r i n t p a c k e t i n f o r m a t i o n
127
i f
(
p a c k e t c o u n t
%1000 == 0 )
{
128
p r i n t f
(
” Card %d
−
F l a g s %d
−
L e n g t h %d
−
Type %d
−
TS %l l u
\
n ”
,
p
←
-
−
>
c a r d
,
p
−
>
f l a g s
,
p
−
>
l e n g t h
,
p
−
>
t y p e
,
p
−
>
t i m e s t a m p
) ;
129
130
i n t
h i t c o u n t
= 2
*
(
p
−
>
l e n g t h
) ;
131
i f
( (
p
−
>
f l a g s
& 0
x1
) == 1 )
132
h i t c o u n t
−
= 1 ;
133
134
u i n t 3 2
*
p a c k e t d a t a
= (
u i n t 3 2
*
) (
p
−
>
d a t a
) ;
135
f o r
(
i n t
i
= 0 ;
i
<
h i t c o u n t
;
i
++ )
136
{
137
u i n t 3 2
*
h i t
= (
p a c k e t d a t a
+
i
) ;
138
139
// e x t r a c t c h a n n e l number (A
−
D)
140
c h a r
c h a n n e l
= 65 + (
*
h i t
&0
x f
) ;
141
142
// e x t r a c t h i t
f l a g s
143
i n t
f l a g s
= (
*
h i t
>>
4 & 0
x f
) ;
144
145
// e x t r a c t h i t timestamp
146
i n t
t s o f f s e t
= (
*
h i t
>>
8&0
x f f f f f f
) ;
147
148
// TDC b i n s i z e
i s
1 3 . 0 2 0 8 ps . Convert timestamp t o ns .
149
double
t s o f f s e t n s
=
t s o f f s e t
;
150
t s o f f s e t n s
*
= 0 . 0 1 3 0 2 0 8 ;
151
152
p r i n t f
(
” H i t @Channel %c
−
F l a g s %d
−
O f f s e t %u ( raw ) / %f n s
\
n
←
-
”
,
c h a n n e l
,
f l a g s
,
t s o f f s e t
,
t s o f f s e t n s
) ;
cronologic GmbH & Co. KG
23
xTDC4 User Guide
Содержание xTDC4
Страница 2: ......
Страница 3: ......
Страница 7: ......
Страница 12: ...Figure 2 6 The xTDC4 Carry Chain TDC calibration tool cronologic GmbH Co KG 7 xTDC4 User Guide...
Страница 13: ...cronologic GmbH Co KG 8 xTDC4 User Guide...
Страница 25: ...cronologic GmbH Co KG 20 xTDC4 User Guide...