Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Lst
lst-data-process-128
Commits
df9e4afc
Commit
df9e4afc
authored
Nov 23, 2018
by
ics
Browse files
Implemented lst version 2 for timestamps, data and flags
parent
54185eda
Changes
10
Hide whitespace changes
Inline
Side-by-side
configure.ac
View file @
df9e4afc
...
...
@@ -2,7 +2,7 @@
# This configure.ac script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
AC_INIT([lstdataprocess128], [1.
2.1
-dev])
AC_INIT([lstdataprocess128], [1.
3.0
-dev])
LIBRARY_VERSION=1:2:1
...
...
src/lstdpp128/CrateBoard.cpp
View file @
df9e4afc
...
...
@@ -61,8 +61,8 @@ std::string writeListModeContextToBinary(const ListModeContext & listModeContext
// Allocate the data.
uint32_t
buffer
[
4
+
boardSize
];
buffer
[
0
]
=
FORMAT_VERSION
;
buffer
[
1
]
=
TIME_BASE
;
buffer
[
0
]
=
listModeContext
.
version
;
buffer
[
1
]
=
listModeContext
.
timeBase
;
buffer
[
2
]
=
listModeContext
.
nbEvents
;
buffer
[
3
]
=
boardSize
;
...
...
src/lstdpp128/CrateBoard.h
View file @
df9e4afc
...
...
@@ -36,8 +36,9 @@ static const int EVENT_SIZE_8 = 16;
/**
* Version of the file.
* Version 2 : unify boards to have the same timestamp format.
*/
static
const
int
FORMAT_VERSION
=
1
;
static
const
int
FORMAT_VERSION
=
2
;
/**
* Time base.
...
...
@@ -50,24 +51,17 @@ static const int TIME_BASE = 9;
enum
BoardType
{
CFD
=
0
,
C1751_PSD
=
1
,
C1724_PHA
_RT
=
2
,
C1730_PSD
_RT
=
3
,
C1730_PHA
_RT
=
4
,
C1724_PHA
=
2
,
C1730_PSD
=
3
,
C1730_PHA
=
4
,
C1740_QDC
=
5
,
C1740_QDIV
=
6
,
C1725_PHA_RT
=
7
,
C1725_PHA
=
7
,
C1725_PSD
=
8
,
GGPICKUP
=
20
,
MCC
=
21
,
CAMERA
=
22
,
C1751_WAVEFORM
=
31
,
C1724_WAVEFORM_RT
=
32
,
C1730_WAVEFORM_RT
=
33
,
C1725_WAVEFORM_RT
=
34
,
C1740_WAVEFORM
=
35
,
C1740_QDIV_WAVEFORM
=
36
};
/**
...
...
@@ -76,35 +70,25 @@ enum BoardType {
static
const
char
*
BoardTypeName
[]
=
{
"CFD"
,
// 0
"1751 PSD"
,
// 1
"1724 PHA
RT"
,
// 2
"1730 PSD
RT"
,
// 3
"1730 PHA
RT"
,
// 4
"1724 PHA
"
,
// 2
"1730 PSD
"
,
// 3
"1730 PHA
"
,
// 4
"1740 QDC"
,
// 5
"1740 QDIV"
,
// 6
"1725 PHA RT"
,
// 7
"1725 PHA"
,
// 7
"1725 PSD"
,
// 8
//
8
... 19
"8?"
,
"9?"
,
"10?"
,
"11?"
,
"12?"
,
"13?"
,
"14?"
,
"15?"
,
"16?"
,
"17?"
,
"18?"
,
"19?"
,
//
9
... 19
"9?"
,
"10?"
,
"11?"
,
"12?"
,
"13?"
,
"14?"
,
"15?"
,
"16?"
,
"17?"
,
"18?"
,
"19?"
,
"GGPICKUP"
,
// 20
"MCC"
,
// 21
"CAMERA"
,
// 22
// 23 ... 30
"23?"
,
"24?"
,
"25?"
,
"26?"
,
"27?"
,
"28?"
,
"29?"
,
"30?"
,
"1751 WAVEFORM"
,
// 31
"1724 WAVEFORM RT"
,
// 32
"1730 WAVEFORM RT"
,
// 33
"1725 WAVEFORM RT"
,
// 34
"1740 WAVEFORM"
,
// 35
"1740 QDIV WAVEFORM"
// 36
"CAMERA"
// 22
};
/**
* The time relativity of the boards.
* Only used for lst v1 files.
*/
static
int
BoardRelativeTime
[]
=
{
0
,
// 0
...
...
@@ -115,25 +99,14 @@ static int BoardRelativeTime[] = {
0
,
// 5
0
,
// 6
1
,
// 7
0
,
// 8
//
8
.. 19
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
//
9
.. 19
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
// 20
0
,
// 21
0
,
// 22
// 23.. 30
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
// 31
1
,
// 32
1
,
// 33
1
,
// 34
0
,
// 35
0
// 36
0
// 22
};
/**
...
...
@@ -148,25 +121,14 @@ static uint32_t BoardTimeResolution[] = {
16
,
// 5
16
,
// 6
4
,
// 7
4
,
// 8
//
8
.. 19
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
//
9
.. 19
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
10
,
// 20
10
,
// 21
0
,
// 22
// 23.. 30
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
// 31
10
,
// 32
2
,
// 33
4
,
// 34
16
,
// 35
16
// 36
0
// 22
};
/**
...
...
src/lstdpp128/Event.cpp
View file @
df9e4afc
...
...
@@ -109,26 +109,7 @@ std::ostream& operator<< (std::ostream& os, EventBlock const & b) {
return
os
<<
b
.
id
<<
" : "
<<
b
.
minTime
()
<<
" - "
<<
b
.
maxTime
()
<<
" ("
<<
b
.
events
.
size
()
<<
")"
;
}
bool
readEvent
(
Event
&
event
,
int32_t
*
buffer
)
{
// Read crate, board, channel.
uint8_t
crate
=
(
uint8_t
)((
*
buffer
>>
28
)
&
0xF
);
uint8_t
board
=
(
uint8_t
)((
*
buffer
>>
22
)
&
0x3F
);
if
(
crate
>=
listModeContext
.
crateBoard
.
nbCrates
)
{
// No output because the log file can be very large.
return
false
;
}
if
(
board
>=
listModeContext
.
crateBoard
.
crates
[
event
.
crate
].
nbBoards
)
{
// No output because the log file can be very large.
return
false
;
}
event
.
crate
=
crate
;
event
.
board
=
board
;
event
.
channel
=
(
uint8_t
)((
*
buffer
>>
16
)
&
0x3F
);
event
.
rollover
=
(
uint16_t
)(
*
buffer
&
0xFFFF
);
void
readEventV1
(
Event
&
event
,
int32_t
*
buffer
)
{
BoardType
boardType
=
event
.
boardType
();
...
...
@@ -136,11 +117,11 @@ bool readEvent(Event & event, int32_t * buffer) {
int
numberOfBitsOfTimestamp
=
32
;
// In case of 1724 PHA, the number of bits for timestamp is 30.
if
(
boardType
==
C1724_PHA
_RT
)
{
if
(
boardType
==
C1724_PHA
)
{
numberOfBitsOfTimestamp
=
30
;
event
.
timestamp
=
(
uint32_t
)(
*
(
buffer
+
1
)
&
0x3FFFFFFF
);
}
else
if
(
boardType
==
C1725_PHA
_RT
)
{
else
if
(
boardType
==
C1725_PHA
)
{
numberOfBitsOfTimestamp
=
31
;
event
.
timestamp
=
(
uint32_t
)(
*
(
buffer
+
1
)
&
0x7FFFFFFF
);
}
...
...
@@ -172,11 +153,62 @@ bool readEvent(Event & event, int32_t * buffer) {
// We can set the absolute time that changes the rollover and timestamp.
event
.
setTime
(
absoluteTime
);
}
}
void
readEventV2
(
Event
&
event
,
int32_t
*
buffer
)
{
BoardType
boardType
=
event
.
boardType
();
// The number of bits for timestamp.
int
numberOfBitsOfTimestamp
=
32
;
event
.
timestamp
=
(
uint32_t
)(
*
(
buffer
+
1
)
&
0xFFFFFFFF
);
// Copy data.
memcpy
(
reinterpret_cast
<
void
*>
(
event
.
data
),
reinterpret_cast
<
const
void
*>
(
buffer
+
2
),
8
);
// Use printBinary(buffer) to debug if necessary.
// Calculate the absolute time.
time_type
absoluteTime
=
(((
int64_t
)
event
.
rollover
<<
numberOfBitsOfTimestamp
)
|
event
.
timestamp
);
// We can set the absolute time that changes the rollover and timestamp.
event
.
setTime
(
absoluteTime
);
}
bool
readEvent
(
Event
&
event
,
int32_t
*
buffer
)
{
// Read crate, board, channel.
uint8_t
crate
=
(
uint8_t
)((
*
buffer
>>
28
)
&
0xF
);
uint8_t
board
=
(
uint8_t
)((
*
buffer
>>
22
)
&
0x3F
);
if
(
crate
>=
listModeContext
.
crateBoard
.
nbCrates
)
{
// No output because the log file can be very large.
return
false
;
}
if
(
board
>=
listModeContext
.
crateBoard
.
crates
[
event
.
crate
].
nbBoards
)
{
// No output because the log file can be very large.
return
false
;
}
event
.
crate
=
crate
;
event
.
board
=
board
;
event
.
channel
=
(
uint8_t
)((
*
buffer
>>
16
)
&
0x3F
);
event
.
rollover
=
(
uint16_t
)(
*
buffer
&
0xFFFF
);
// Check the lst version to read the event.
if
(
listModeContext
.
version
==
1
)
{
readEventV1
(
event
,
buffer
);
}
else
{
readEventV2
(
event
,
buffer
);
}
return
true
;
}
void
writeEvent
(
Event
const
&
event
,
int32_t
*
buffer
)
{
void
writeEvent
V1
(
Event
const
&
event
,
int32_t
*
buffer
)
{
Event
relativeTimeEvent
(
event
);
...
...
@@ -197,7 +229,7 @@ void writeEvent(Event const & event, int32_t * buffer) {
BoardType
boardType
=
relativeTimeEvent
.
boardType
();
if
(
boardType
==
C1724_PHA
_RT
)
{
if
(
boardType
==
C1724_PHA
)
{
// The card timestamp is on 30bits with 2 bits of zero.
// The rollover is calculated by taking the 2 bits of the actual timestamp (>> 30 for 32 bits = 2 bits).
...
...
@@ -209,7 +241,6 @@ void writeEvent(Event const & event, int32_t * buffer) {
}
else
{
*
buffer
|=
(
relativeTimeEvent
.
rollover
&
0xFFFF
);
*
(
buffer
+
1
)
=
relativeTimeEvent
.
timestamp
;
}
...
...
@@ -219,4 +250,35 @@ void writeEvent(Event const & event, int32_t * buffer) {
// Use printBinary(buffer) to debug if necessary.
}
void
writeEventV2
(
Event
const
&
event
,
int32_t
*
buffer
)
{
Event
relativeTimeEvent
(
event
);
*
buffer
=
0
;
*
buffer
|=
((
relativeTimeEvent
.
crate
&
0xF
)
<<
28
);
*
buffer
|=
((
relativeTimeEvent
.
board
&
0x3F
)
<<
22
);
*
buffer
|=
((
relativeTimeEvent
.
channel
&
0x3F
)
<<
16
);
BoardType
boardType
=
relativeTimeEvent
.
boardType
();
*
buffer
|=
(
relativeTimeEvent
.
rollover
&
0xFFFF
);
*
(
buffer
+
1
)
=
relativeTimeEvent
.
timestamp
;
// Copy data.
memcpy
(
buffer
+
2
,
reinterpret_cast
<
const
void
*>
(
&
relativeTimeEvent
.
data
),
8
);
// Use printBinary(buffer) to debug if necessary.
}
void
writeEvent
(
Event
const
&
event
,
int32_t
*
buffer
)
{
// Check the lst version to write the event.
if
(
listModeContext
.
version
==
1
)
{
writeEventV1
(
event
,
buffer
);
}
else
{
writeEventV2
(
event
,
buffer
);
}
}
}
src/lstdpp128/EventData.cpp
View file @
df9e4afc
...
...
@@ -42,10 +42,10 @@ uint32_t eventDataPlus(Event const & event) {
bool
boardHasEnergy
(
BoardType
type
)
{
if
(
type
==
CFD
||
type
==
C1724_PHA
_RT
||
type
==
C1730_PHA
_RT
||
type
==
C1724_PHA
||
type
==
C1730_PHA
||
type
==
C1740_QDC
||
type
==
C1725_PHA
_RT
)
{
||
type
==
C1725_PHA
)
{
return
true
;
}
return
false
;
...
...
@@ -61,16 +61,16 @@ uint16_t boardEnergyResolution(BoardType type) {
case
CFD
:
return
12
;
case
C1724_PHA
_RT
:
case
C1724_PHA
:
return
15
;
case
C1730_PHA
_RT
:
case
C1730_PHA
:
return
15
;
case
C1740_QDC
:
return
16
;
case
C1725_PHA
_RT
:
case
C1725_PHA
:
return
15
;
}
...
...
@@ -86,16 +86,16 @@ uint16_t eventEnergy(Event const & event) {
if
(
event
.
boardType
()
==
CFD
)
{
return
event
.
data
[
0
]
&
0xFFF
;
}
else
if
(
event
.
boardType
()
==
C1724_PHA
_RT
)
{
else
if
(
event
.
boardType
()
==
C1724_PHA
)
{
return
event
.
data
[
0
]
&
0x7FFF
;
}
else
if
(
event
.
boardType
()
==
C1730_PHA
_RT
)
{
else
if
(
event
.
boardType
()
==
C1730_PHA
)
{
return
event
.
data
[
0
]
&
0x7FFF
;
}
else
if
(
event
.
boardType
()
==
C1740_QDC
)
{
return
event
.
data
[
0
]
&
0xFFFF
;
}
else
if
(
event
.
boardType
()
==
C1725_PHA
_RT
)
{
else
if
(
event
.
boardType
()
==
C1725_PHA
)
{
return
event
.
data
[
0
]
&
0x7FFF
;
}
...
...
@@ -108,7 +108,8 @@ uint16_t eventEnergy(Event const & event) {
bool
boardHasQ
(
BoardType
type
)
{
if
(
type
==
C1751_PSD
||
type
==
C1730_PSD_RT
)
{
||
type
==
C1730_PSD
||
type
==
C1725_PSD
)
{
return
true
;
}
return
false
;
...
...
@@ -121,7 +122,8 @@ bool eventHasQ(Event const & event) {
uint16_t
boardQShortResolution
(
BoardType
type
)
{
if
(
type
==
C1751_PSD
||
type
==
C1730_PSD_RT
)
{
||
type
==
C1730_PSD
||
type
==
C1725_PSD
)
{
return
15
;
}
return
0
;
...
...
@@ -134,7 +136,8 @@ uint16_t eventQShortResolution(Event const & event) {
uint16_t
boardQLongResolution
(
BoardType
type
)
{
if
(
type
==
C1751_PSD
||
type
==
C1730_PSD_RT
)
{
||
type
==
C1730_PSD
||
type
==
C1725_PSD
)
{
return
16
;
}
return
0
;
...
...
@@ -171,7 +174,22 @@ float eventQRatio(Event const & event) {
///////////////////////////////////////////////////////////////////////////////
// Position XY
bool
boardHasPositionXY
(
BoardType
type
)
{
bool
boardHasPositionX
(
BoardType
type
)
{
if
(
type
==
C1740_QDIV
||
type
==
C1740_QDC
||
type
==
MCC
||
type
==
CAMERA
)
{
return
true
;
}
return
false
;
}
bool
eventHasPositionX
(
Event
const
&
event
)
{
return
boardHasPositionX
(
event
.
boardType
());
}
bool
boardHasPositionY
(
BoardType
type
)
{
if
(
type
==
C1740_QDIV
||
type
==
MCC
...
...
@@ -181,8 +199,8 @@ bool boardHasPositionXY(BoardType type) {
return
false
;
}
bool
eventHasPosition
X
Y
(
Event
const
&
event
)
{
return
boardHasPosition
X
Y
(
event
.
boardType
());
bool
eventHasPositionY
(
Event
const
&
event
)
{
return
boardHasPositionY
(
event
.
boardType
());
}
uint16_t
boardPositionXResolution
(
BoardType
type
)
{
...
...
@@ -191,6 +209,9 @@ uint16_t boardPositionXResolution(BoardType type) {
case
C1740_QDIV
:
return
5
;
case
C1740_QDC
:
return
6
;
case
MCC
:
return
16
;
...
...
@@ -319,35 +340,6 @@ float eventZeroCrossing(Event const & event) {
return
floatData
(
event
,
1
);
}
///////////////////////////////////////////////////////////////////////////////
// Fine timestamp
bool
boardHasFineTimestamp
(
BoardType
type
)
{
if
(
type
==
C1725_PHA_RT
)
{
return
true
;
}
return
false
;
}
bool
eventHasFineTimestamp
(
Event
const
&
event
)
{
return
boardHasFineTimestamp
(
event
.
boardType
());
}
uint16_t
boardFineTimestampResolution
(
BoardType
type
)
{
if
(
type
==
C1725_PHA_RT
)
{
return
10
;
}
return
0
;
}
uint16_t
eventFineTimestampResolution
(
Event
const
&
event
)
{
return
boardFineTimestampResolution
(
event
.
boardType
());
}
uint16_t
eventFineTimestamp
(
Event
const
&
event
)
{
return
event
.
data
[
1
]
&
0x3FF
;
}
///////////////////////////////////////////////////////////////////////////////
// Special unspecified data
...
...
@@ -355,6 +347,15 @@ bool boardHasUnspecifiedData(BoardType type) {
if
(
type
==
GGPICKUP
)
{
return
true
;
}
if
(
type
==
C1751_PSD
||
type
==
C1730_PSD
||
type
==
C1725_PSD
||
type
==
C1724_PHA
||
type
==
C1730_PHA
||
type
==
C1725_PHA
||
type
==
C1740_QDC
)
{
return
true
;
}
return
false
;
}
...
...
@@ -366,6 +367,15 @@ uint16_t boardUnspecifiedDataResolution(BoardType type) {
if
(
type
==
GGPICKUP
)
{
return
32
;
}
if
(
type
==
C1751_PSD
||
type
==
C1730_PSD
||
type
==
C1725_PSD
||
type
==
C1724_PHA
||
type
==
C1730_PHA
||
type
==
C1725_PHA
||
type
==
C1740_QDC
)
{
return
16
;
}
return
0
;
}
...
...
@@ -380,51 +390,29 @@ uint32_t eventUnspecifiedData(Event const & event) {
///////////////////////////////////////////////////////////////////////////////
// Flags
uint8_t
boardHasFlags
(
BoardType
type
)
{
if
(
type
==
C1751_PSD
)
{
return
PILE_UP
;
}
if
(
type
==
C1730_PSD_RT
)
{
return
PILE_UP
|
TRIGGER_LOST
|
N_TRIGGER_COUNTED
|
N_LOST_TRIGGER_COUNTED
;
}
if
(
type
==
C1724_PHA_RT
)
{
return
PILE_UP
|
DEAD_TIME_OR_LOST_EVENTS
;
}
if
(
type
==
C1730_PHA_RT
)
{
return
PILE_UP
|
DEAD_TIME_OR_LOST_EVENTS
|
OVER_RANGE
|
N_TRIGGER_COUNTED
|
N_LOST_TRIGGER_COUNTED
;
}
if
(
type
==
C1740_QDC
)
{
return
PILE_UP
|
OVER_RANGE
;
}
bool
boardHasFlags
(
BoardType
type
)
{
if
(
type
==
C1725_PHA_RT
)
{
return
PILE_UP
|
DEAD_TIME_OR_LOST_EVENTS
|
OVER_RANGE
|
N_TRIGGER_COUNTED
|
N_LOST_TRIGGER_COUNTED
;
if
(
type
==
C1751_PSD
||
type
==
C1730_PSD
||
type
==
C1725_PSD
||
type
==
C1724_PHA
||
type
==
C1730_PHA
||
type
==
C1725_PHA
||
type
==
C1740_QDC
)
{
return
true
;
}
return
0
;
return
false
;
}
uint8_t
eventHasFlags
(
Event
const
&
event
)
{
bool
eventHasFlags
(
Event
const
&
event
)
{
return
boardHasFlags
(
event
.
boardType
());
}
uint
8
_t
eventFlags
(
Event
const
&
event
)
{
uint
16
_t
eventFlags
(
Event
const
&
event
)
{
if
(
eventHasFlags
(
event
)
!=
0
)
{
// Bits
// 31 : PU (Pile Up)
// 30 : Dead Time / Lost Event(s)
// 29 : Over-Range / Saturation
// 28 : Trigger Lost
// 27 : N Trigger Counted
// 26 : N Lost Trigger Counted
// Shift 26bits.
return
(
event
.
data
[
1
]
>>
26
);
if
(
eventHasFlags
(
event
))
{
// Shift 16 bits.
return
(
event
.
data
[
1
]
>>
16
);
}
return
0
;
...
...
@@ -452,9 +440,12 @@ std::string eventDataColumnsToString(BoardType type) {
os
<<
setw
(
12
)
<<
"A+B"
;
}
if
(
boardHasPositionXY
(
type
))
{
if
(
boardHasPositionX
(
type
))
{
os
<<
setw
(
12
)
<<
"X"
;
}
if
(
boardHasPositionY
(
type
))
{
os
<<
setw
(
12
)
<<
"X"
;
os
<<
setw
(
12
)
<<
"Y"
;
}
// data[1]
...
...
@@ -462,13 +453,9 @@ std::string eventDataColumnsToString(BoardType type) {
os
<<
setw
(
12
)
<<
"0-crossing"
;
}
if
(
boardHasFineTimestamp
(
type
))
{
os
<<
setw
(
12
)
<<
"fine-ts"
;
}
// flags.
if
(
boardHasFlags
(
type
)
!=
0
)
{
os
<<
setw
(
1
0
)
<<
"flags"
;
if
(
boardHasFlags
(
type
))
{
os
<<
setw
(
1
8
)
<<
"flags"
;
}
return
os
.
str
();
...
...
@@ -493,8 +480,11 @@ std::string eventDataToString(Event const & event) {
os
<<
setw
(
12
)
<<
eventAplusB
(
event
);
}
if
(
eventHasPositionX
Y
(
event
))
{
if
(
eventHasPositionX
(
event
))
{
os
<<
setw
(
12
)
<<
eventPositionX
(
event
);
}
if
(
eventHasPositionY
(
event
))
{
os
<<
setw
(
12
)
<<
eventPositionY
(
event
);
}
...
...
@@ -503,17 +493,13 @@ std::string eventDataToString(Event const & event) {
os
<<
setw
(
12
)
<<
eventZeroCrossing
(
event
);
}
if
(
eventHasFineTimestamp
(
event
))
{