Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cbmroot
Manage
Activity
Members
Labels
Plan
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computing
cbmroot
Commits
52ae62c1
Commit
52ae62c1
authored
1 year ago
by
Felix Weiglhofer
Browse files
Options
Downloads
Patches
Plain Diff
algo: Make RICH Unpacker thread-safe.
parent
8f054f2e
No related branches found
No related tags found
1 merge request
!1352
algo: Unpack RICH in parallel.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
algo/detectors/rich/Unpack.cxx
+56
-57
56 additions, 57 deletions
algo/detectors/rich/Unpack.cxx
algo/detectors/rich/Unpack.h
+38
-29
38 additions, 29 deletions
algo/detectors/rich/Unpack.h
with
94 additions
and
86 deletions
algo/detectors/rich/Unpack.cxx
+
56
−
57
View file @
52ae62c1
...
@@ -12,30 +12,27 @@ namespace cbm::algo::rich
...
@@ -12,30 +12,27 @@ namespace cbm::algo::rich
{
{
// ---- Algorithm execution ---------------------------------------------
// ---- Algorithm execution ---------------------------------------------
Unpack
::
resultType
Unpack
::
operator
()(
const
uint8_t
*
msContent
,
const
fles
::
MicrosliceDescriptor
&
msDescr
,
Unpack
::
resultType
Unpack
::
operator
()(
const
uint8_t
*
msContent
,
const
fles
::
MicrosliceDescriptor
&
msDescr
,
const
uint64_t
tTimeslice
)
const
uint64_t
tTimeslice
)
const
{
{
// --- Output data
MSContext
ctx
;
resultType
result
=
{};
fMonitor
=
UnpackMonitorData
();
fOutputVec
.
clear
();
// Clear CbmTime of MS. Used to get time offset of subtriggers to MS start
// Clear CbmTime of MS. Used to get time offset of subtriggers to MS start
fCbmTimeMS
=
0
;
ctx
.
cbmTimeMS
=
0
;
ctx
.
digis
.
reserve
(
msDescr
.
size
/
sizeof
(
u32
));
rich
::
MicrosliceReader
reader
;
rich
::
MicrosliceReader
reader
;
reader
.
SetData
(
msContent
,
msDescr
.
size
);
reader
.
SetData
(
msContent
,
msDescr
.
size
);
const
auto
mstime
=
msDescr
.
idx
;
const
auto
mstime
=
msDescr
.
idx
;
fMsR
efTime
=
mstime
-
tTimeslice
;
ctx
.
r
efTime
=
mstime
-
tTimeslice
;
// There are a lot of MS with 8 bytes size
// There are a lot of MS with 8 bytes size
// Does one need these MS?
// Does one need these MS?
if
(
reader
.
GetSize
()
<=
8
)
return
result
;
if
(
reader
.
GetSize
()
<=
8
)
return
{}
;
while
(
true
)
{
while
(
true
)
{
ProcessTrbPacket
(
reader
);
ProcessTrbPacket
(
reader
,
ctx
);
ProcessHubBlock
(
reader
);
ProcessHubBlock
(
reader
,
ctx
);
// -4*2 for 2 last words which contain microslice index
// -4*2 for 2 last words which contain microslice index
if
(
reader
.
GetOffset
()
>=
reader
.
GetSize
()
-
8
)
break
;
if
(
reader
.
GetOffset
()
>=
reader
.
GetSize
()
-
8
)
break
;
...
@@ -45,19 +42,17 @@ namespace cbm::algo::rich
...
@@ -45,19 +42,17 @@ namespace cbm::algo::rich
uint32_t
msIndexWord1
=
reader
.
NextWord
();
uint32_t
msIndexWord1
=
reader
.
NextWord
();
uint32_t
msIndexWord2
=
reader
.
NextWord
();
uint32_t
msIndexWord2
=
reader
.
NextWord
();
result
.
first
=
fOutputVec
;
return
std
::
make_pair
(
std
::
move
(
ctx
.
digis
),
std
::
move
(
ctx
.
monitor
));
result
.
second
=
fMonitor
;
return
result
;
}
}
void
Unpack
::
ProcessTrbPacket
(
rich
::
MicrosliceReader
&
reader
)
void
Unpack
::
ProcessTrbPacket
(
rich
::
MicrosliceReader
&
reader
,
MSContext
&
ctx
)
const
{
{
//process CBM time
//process CBM time
const
uint32_t
word_MSB
=
reader
.
NextWord
();
// CBM 63:32
const
uint32_t
word_MSB
=
reader
.
NextWord
();
// CBM 63:32
const
uint32_t
word_LSB
=
reader
.
NextWord
();
// CBM 31: 0
const
uint32_t
word_LSB
=
reader
.
NextWord
();
// CBM 31: 0
fC
bmTimePacket
=
(
uint64_t
)
word_MSB
<<
32
|
word_LSB
;
ctx
.
c
bmTimePacket
=
(
uint64_t
)
word_MSB
<<
32
|
word_LSB
;
if
(
fC
bmTimeMS
==
0
)
fC
bmTimeMS
=
fC
bmTimePacket
;
if
(
ctx
.
c
bmTimeMS
==
0
)
ctx
.
c
bmTimeMS
=
ctx
.
c
bmTimePacket
;
//discard unused words
//discard unused words
for
(
auto
l
=
0
;
l
<
10
;
++
l
)
{
for
(
auto
l
=
0
;
l
<
10
;
++
l
)
{
...
@@ -72,9 +67,9 @@ namespace cbm::algo::rich
...
@@ -72,9 +67,9 @@ namespace cbm::algo::rich
const
TdcTimeData
td
=
ProcessTimeData
(
wordTime
);
const
TdcTimeData
td
=
ProcessTimeData
(
wordTime
);
const
double
fullTime
=
CalculateTime
(
epoch
,
td
.
fCoarse
,
td
.
fFine
);
const
double
fullTime
=
CalculateTime
(
epoch
,
td
.
fCoarse
,
td
.
fFine
);
if
(
l
==
0
)
fP
revLastCh0ReTime
[
12
]
=
fullTime
;
if
(
l
==
0
)
ctx
.
p
revLastCh0ReTime
[
12
]
=
fullTime
;
if
(
l
==
1
)
fM
bsCorr
=
fullTime
-
fP
revLastCh0ReTime
[
12
];
// = MbsPrevTimeCh1 - MbsPrevTimeCh0
if
(
l
==
1
)
ctx
.
m
bsCorr
=
fullTime
-
ctx
.
p
revLastCh0ReTime
[
12
];
// = MbsPrevTimeCh1 - MbsPrevTimeCh0
if
(
l
>
1
)
fP
revLastCh0ReTime
[
l
-
2
]
=
fullTime
;
if
(
l
>
1
)
ctx
.
p
revLastCh0ReTime
[
l
-
2
]
=
fullTime
;
}
}
const
uint32_t
trbNum
=
reader
.
NextWord
();
// TRB trigger number
const
uint32_t
trbNum
=
reader
.
NextWord
();
// TRB trigger number
...
@@ -82,7 +77,7 @@ namespace cbm::algo::rich
...
@@ -82,7 +77,7 @@ namespace cbm::algo::rich
}
}
void
Unpack
::
ProcessHubBlock
(
rich
::
MicrosliceReader
&
reader
)
void
Unpack
::
ProcessHubBlock
(
rich
::
MicrosliceReader
&
reader
,
MSContext
&
ctx
)
const
{
{
uint32_t
word
=
reader
.
NextWord
();
uint32_t
word
=
reader
.
NextWord
();
const
uint32_t
hubId
=
word
&
0xffff
;
// 16 bits
const
uint32_t
hubId
=
word
&
0xffff
;
// 16 bits
...
@@ -90,7 +85,7 @@ namespace cbm::algo::rich
...
@@ -90,7 +85,7 @@ namespace cbm::algo::rich
bool
isLast
=
false
;
// if true then it is CTS sub-sub-event
bool
isLast
=
false
;
// if true then it is CTS sub-sub-event
size_t
totalSize
=
0
;
size_t
totalSize
=
0
;
fC
urrentSubSubEvent
=
0
;
ctx
.
c
urrentSubSubEvent
=
0
;
uint32_t
subSubEventId
,
subSubEventSize
;
uint32_t
subSubEventId
,
subSubEventSize
;
...
@@ -104,18 +99,18 @@ namespace cbm::algo::rich
...
@@ -104,18 +99,18 @@ namespace cbm::algo::rich
if
(
!
isLast
)
{
// all except last are DiRICH events
if
(
!
isLast
)
{
// all except last are DiRICH events
if
(((
subSubEventId
>>
12
)
&
0xF
)
!=
0x7
)
{
// catch invalid ids
if
(((
subSubEventId
>>
12
)
&
0xF
)
!=
0x7
)
{
// catch invalid ids
fM
onitor
.
fNumErrInvalidHubId
++
;
ctx
.
m
onitor
.
fNumErrInvalidHubId
++
;
}
}
if
(
totalSize
==
hubSize
)
{
fM
onitor
.
fNumErrInvalidHubSize
++
;
}
if
(
totalSize
==
hubSize
)
{
ctx
.
m
onitor
.
fNumErrInvalidHubSize
++
;
}
ProcessSubSubEvent
(
reader
,
subSubEventSize
,
subSubEventId
);
ProcessSubSubEvent
(
reader
,
subSubEventSize
,
subSubEventId
,
ctx
);
fC
urrentSubSubEvent
++
;
ctx
.
c
urrentSubSubEvent
++
;
}
}
}
}
//last event ist expected to be CTS
//last event ist expected to be CTS
if
(
totalSize
!=
hubSize
||
!
isLast
)
{
fM
onitor
.
fNumErrInvalidHubSize
++
;
}
if
(
totalSize
!=
hubSize
||
!
isLast
)
{
ctx
.
m
onitor
.
fNumErrInvalidHubSize
++
;
}
subSubEventSize
=
ProcessCtsHeader
(
reader
,
subSubEventSize
,
subSubEventId
);
subSubEventSize
=
ProcessCtsHeader
(
reader
,
subSubEventSize
,
subSubEventId
);
ProcessSubSubEvent
(
reader
,
subSubEventSize
,
subSubEventId
);
ProcessSubSubEvent
(
reader
,
subSubEventSize
,
subSubEventId
,
ctx
);
// read last words
// read last words
int
lastWordsCounter
=
0
;
int
lastWordsCounter
=
0
;
...
@@ -126,11 +121,11 @@ namespace cbm::algo::rich
...
@@ -126,11 +121,11 @@ namespace cbm::algo::rich
if
(
reader
.
IsNextPadding
())
word
=
reader
.
NextWord
();
if
(
reader
.
IsNextPadding
())
word
=
reader
.
NextWord
();
break
;
break
;
}
}
if
(
lastWordsCounter
>=
7
)
{
fM
onitor
.
fNumErrExcessLastWords
++
;
}
if
(
lastWordsCounter
>=
7
)
{
ctx
.
m
onitor
.
fNumErrExcessLastWords
++
;
}
}
}
}
}
int
Unpack
::
ProcessCtsHeader
(
rich
::
MicrosliceReader
&
reader
,
uint32_t
subSubEventSize
,
uint32_t
subSubEventId
)
int
Unpack
::
ProcessCtsHeader
(
rich
::
MicrosliceReader
&
reader
,
uint32_t
subSubEventSize
,
uint32_t
subSubEventId
)
const
{
{
const
uint32_t
word
=
reader
.
NextWord
();
const
uint32_t
word
=
reader
.
NextWord
();
const
uint32_t
ctsState
=
word
&
0xffff
;
// 16 bits
const
uint32_t
ctsState
=
word
&
0xffff
;
// 16 bits
...
@@ -154,7 +149,8 @@ namespace cbm::algo::rich
...
@@ -154,7 +149,8 @@ namespace cbm::algo::rich
return
nofTimeWords
;
return
nofTimeWords
;
}
}
void
Unpack
::
ProcessSubSubEvent
(
rich
::
MicrosliceReader
&
reader
,
int
nofTimeWords
,
uint32_t
subSubEventId
)
void
Unpack
::
ProcessSubSubEvent
(
rich
::
MicrosliceReader
&
reader
,
int
nofTimeWords
,
uint32_t
subSubEventId
,
MSContext
&
ctx
)
const
{
{
uint32_t
epoch
=
0
;
// store last epoch obtained in sub-sub-event
uint32_t
epoch
=
0
;
// store last epoch obtained in sub-sub-event
...
@@ -171,11 +167,11 @@ namespace cbm::algo::rich
...
@@ -171,11 +167,11 @@ namespace cbm::algo::rich
}
}
// First word is expected to be of type "header"
// First word is expected to be of type "header"
if
(
GetTdcWordType
(
reader
.
NextWord
())
!=
TdcWordType
::
Header
)
{
fM
onitor
.
fNumErrInvalidFirstMessage
++
;
}
if
(
GetTdcWordType
(
reader
.
NextWord
())
!=
TdcWordType
::
Header
)
{
ctx
.
m
onitor
.
fNumErrInvalidFirstMessage
++
;
}
// Second word is expected to be of type "epoch"
// Second word is expected to be of type "epoch"
uint32_t
word
=
reader
.
NextWord
();
uint32_t
word
=
reader
.
NextWord
();
if
(
GetTdcWordType
(
word
)
!=
TdcWordType
::
Epoch
)
{
fM
onitor
.
fNumErrInvalidSecondMessage
++
;
}
if
(
GetTdcWordType
(
word
)
!=
TdcWordType
::
Epoch
)
{
ctx
.
m
onitor
.
fNumErrInvalidSecondMessage
++
;
}
else
{
else
{
epoch
=
ProcessEpoch
(
word
);
epoch
=
ProcessEpoch
(
word
);
}
}
...
@@ -185,7 +181,7 @@ namespace cbm::algo::rich
...
@@ -185,7 +181,7 @@ namespace cbm::algo::rich
word
=
reader
.
NextWord
();
word
=
reader
.
NextWord
();
switch
(
GetTdcWordType
(
word
))
{
switch
(
GetTdcWordType
(
word
))
{
case
TdcWordType
::
TimeData
:
{
case
TdcWordType
::
TimeData
:
{
ProcessTimeDataWord
(
epoch
,
word
,
subSubEventId
,
raisingTime
);
ProcessTimeDataWord
(
epoch
,
word
,
subSubEventId
,
raisingTime
,
ctx
);
break
;
break
;
}
}
case
TdcWordType
::
Epoch
:
{
case
TdcWordType
::
Epoch
:
{
...
@@ -193,43 +189,44 @@ namespace cbm::algo::rich
...
@@ -193,43 +189,44 @@ namespace cbm::algo::rich
break
;
break
;
}
}
case
TdcWordType
::
Header
:
{
case
TdcWordType
::
Header
:
{
fM
onitor
.
fNumErrWildHeaderMessage
++
;
ctx
.
m
onitor
.
fNumErrWildHeaderMessage
++
;
break
;
break
;
}
}
case
TdcWordType
::
Trailer
:
{
case
TdcWordType
::
Trailer
:
{
fM
onitor
.
fNumErrWildTrailerMessage
++
;
ctx
.
m
onitor
.
fNumErrWildTrailerMessage
++
;
break
;
break
;
}
}
case
TdcWordType
::
Debug
:
{
case
TdcWordType
::
Debug
:
{
break
;
break
;
// for the moment do nothing
// for the moment do nothing
fM
onitor
.
fNumDebugMessage
++
;
ctx
.
m
onitor
.
fNumDebugMessage
++
;
break
;
break
;
}
}
case
TdcWordType
::
Error
:
{
case
TdcWordType
::
Error
:
{
fM
onitor
.
fNumErrTdcErrorWord
++
;
ctx
.
m
onitor
.
fNumErrTdcErrorWord
++
;
break
;
break
;
}
}
}
}
}
}
// Last word is expected to be of type "trailer"
// Last word is expected to be of type "trailer"
if
(
GetTdcWordType
(
reader
.
NextWord
())
!=
TdcWordType
::
Trailer
)
{
fM
onitor
.
fNumErrInvalidLastMessage
++
;
}
if
(
GetTdcWordType
(
reader
.
NextWord
())
!=
TdcWordType
::
Trailer
)
{
ctx
.
m
onitor
.
fNumErrInvalidLastMessage
++
;
}
}
}
// ---- ProcessTimeDataWord ----
// ---- ProcessTimeDataWord ----
void
Unpack
::
ProcessTimeDataWord
(
uint32_t
epoch
,
uint32_t
tdcWord
,
uint32_t
subSubEventId
,
void
Unpack
::
ProcessTimeDataWord
(
uint32_t
epoch
,
uint32_t
tdcWord
,
uint32_t
subSubEventId
,
std
::
vector
<
double
>&
raisingTime
)
std
::
vector
<
double
>&
raisingTime
,
MSContext
&
ctx
)
const
{
{
const
TdcTimeData
td
=
ProcessTimeData
(
tdcWord
);
const
TdcTimeData
td
=
ProcessTimeData
(
tdcWord
);
const
double
fullTime
=
CalculateTime
(
epoch
,
td
.
fCoarse
,
td
.
fFine
);
const
double
fullTime
=
CalculateTime
(
epoch
,
td
.
fCoarse
,
td
.
fFine
);
if
(
td
.
fChannel
!=
0
)
{
if
(
td
.
fChannel
!=
0
)
{
const
double
dT
=
fullTime
-
fPrevLastCh0ReTime
[
fCurrentSubSubEvent
];
const
double
dT
=
fullTime
-
ctx
.
prevLastCh0ReTime
[
ctx
.
currentSubSubEvent
];
const
double
subtrigOffset
=
(
fCbmTimePacket
-
fCbmTimeMS
)
*
25.0
;
// offset of SubTrigger to MS start in ns
const
double
subtrigOffset
=
const
double
fullTimeCorr
=
dT
-
fMbsCorr
+
subtrigOffset
;
(
ctx
.
cbmTimePacket
-
ctx
.
cbmTimeMS
)
*
25.0
;
// offset of SubTrigger to MS start in ns
const
double
fullTimeCorr
=
dT
-
ctx
.
mbsCorr
+
subtrigOffset
;
if
(
td
.
fChannel
<
1
||
td
.
fChannel
>=
raisingTime
.
size
())
{
fM
onitor
.
fNumErrChannelOutOfBounds
++
;
}
if
(
td
.
fChannel
<
1
||
td
.
fChannel
>=
raisingTime
.
size
())
{
ctx
.
m
onitor
.
fNumErrChannelOutOfBounds
++
;
}
if
(
td
.
fIsRisingEdge
)
{
if
(
td
.
fIsRisingEdge
)
{
// always store the latest raising edge. It means that in case RRFF situation only middle RF will be matched.
// always store the latest raising edge. It means that in case RRFF situation only middle RF will be matched.
raisingTime
[
td
.
fChannel
]
=
fullTimeCorr
;
raisingTime
[
td
.
fChannel
]
=
fullTimeCorr
;
...
@@ -239,7 +236,9 @@ namespace cbm::algo::rich
...
@@ -239,7 +236,9 @@ namespace cbm::algo::rich
// Matching was found, calculate ToT, if tot is in a good range -> create digi
// Matching was found, calculate ToT, if tot is in a good range -> create digi
const
double
ToT
=
fullTimeCorr
-
raisingTime
[
td
.
fChannel
];
const
double
ToT
=
fullTimeCorr
-
raisingTime
[
td
.
fChannel
];
if
(
ToT
>=
fToTMin
&&
ToT
<=
fToTMax
)
{
if
(
ToT
>=
fToTMin
&&
ToT
<=
fToTMax
)
{
if
(
fullTimeCorr
>=
0.0
)
{
WriteOutputDigi
(
subSubEventId
,
td
.
fChannel
,
raisingTime
[
td
.
fChannel
],
ToT
);
}
if
(
fullTimeCorr
>=
0.0
)
{
WriteOutputDigi
(
subSubEventId
,
td
.
fChannel
,
raisingTime
[
td
.
fChannel
],
ToT
,
ctx
);
}
}
}
// pair was created, set raising edge to -1.
// pair was created, set raising edge to -1.
raisingTime
[
td
.
fChannel
]
=
-
1.
;
raisingTime
[
td
.
fChannel
]
=
-
1.
;
...
@@ -248,25 +247,25 @@ namespace cbm::algo::rich
...
@@ -248,25 +247,25 @@ namespace cbm::algo::rich
}
}
}
}
double
Unpack
::
CalculateTime
(
uint32_t
epoch
,
uint32_t
coarse
,
uint32_t
fine
)
double
Unpack
::
CalculateTime
(
uint32_t
epoch
,
uint32_t
coarse
,
uint32_t
fine
)
const
{
{
return
((
double
)
epoch
)
*
2048.
*
5.
+
((
double
)
coarse
)
*
5.
-
((
double
)
fine
)
*
0.005
;
return
((
double
)
epoch
)
*
2048.
*
5.
+
((
double
)
coarse
)
*
5.
-
((
double
)
fine
)
*
0.005
;
}
}
void
Unpack
::
WriteOutputDigi
(
int32_t
fpgaID
,
int32_t
channel
,
double
time
,
double
tot
)
void
Unpack
::
WriteOutputDigi
(
int32_t
fpgaID
,
int32_t
channel
,
double
time
,
double
tot
,
MSContext
&
ctx
)
const
{
{
double
ToTcorr
=
fbDoToTCorr
?
fParams
.
fElinkParams
[
fpgaID
]
.
fToTshift
[
channel
]
:
0.
;
double
ToTcorr
=
fbDoToTCorr
?
fParams
.
fElinkParams
.
at
(
fpgaID
)
.
fToTshift
[
channel
]
:
0.
;
int32_t
pixelUID
=
GetPixelUID
(
fpgaID
,
channel
);
int32_t
pixelUID
=
GetPixelUID
(
fpgaID
,
channel
);
//check ordering
//check ordering
double
finalTime
=
time
+
(
double
)
fMsR
efTime
-
fParams
.
fElinkParams
[
fpgaID
]
.
fTimeOffset
;
double
finalTime
=
time
+
(
double
)
ctx
.
r
efTime
-
fParams
.
fElinkParams
.
at
(
fpgaID
)
.
fTimeOffset
;
// Do not accept digis, where the MS und TS differs by more than 6 sec (mainly TS0)
// Do not accept digis, where the MS und TS differs by more than 6 sec (mainly TS0)
if
(
6e9
<
finalTime
)
return
;
if
(
6e9
<
finalTime
)
return
;
fOutputVec
.
emplace_back
(
pixelUID
,
finalTime
,
tot
-
ToTcorr
);
ctx
.
digis
.
emplace_back
(
pixelUID
,
finalTime
,
tot
-
ToTcorr
);
}
}
bool
Unpack
::
CheckMaskedDiRICH
(
int32_t
subSubEventId
)
bool
Unpack
::
CheckMaskedDiRICH
(
int32_t
subSubEventId
)
const
{
{
for
(
unsigned
int
i
=
0
;
i
<
fMaskedDiRICHes
.
size
();
++
i
)
{
for
(
unsigned
int
i
=
0
;
i
<
fMaskedDiRICHes
.
size
();
++
i
)
{
if
(
fMaskedDiRICHes
.
at
(
i
)
==
subSubEventId
)
return
true
;
if
(
fMaskedDiRICHes
.
at
(
i
)
==
subSubEventId
)
return
true
;
...
@@ -274,7 +273,7 @@ namespace cbm::algo::rich
...
@@ -274,7 +273,7 @@ namespace cbm::algo::rich
return
false
;
return
false
;
}
}
TdcWordType
Unpack
::
GetTdcWordType
(
uint32_t
tdcWord
)
TdcWordType
Unpack
::
GetTdcWordType
(
uint32_t
tdcWord
)
const
{
{
uint32_t
tdcTimeDataMarker
=
(
tdcWord
>>
31
)
&
0x1
;
// 1 bit
uint32_t
tdcTimeDataMarker
=
(
tdcWord
>>
31
)
&
0x1
;
// 1 bit
uint32_t
tdcMarker
=
(
tdcWord
>>
29
)
&
0x7
;
// 3 bits
uint32_t
tdcMarker
=
(
tdcWord
>>
29
)
&
0x7
;
// 3 bits
...
@@ -293,14 +292,14 @@ namespace cbm::algo::rich
...
@@ -293,14 +292,14 @@ namespace cbm::algo::rich
return
TdcWordType
::
Error
;
return
TdcWordType
::
Error
;
}
}
int32_t
Unpack
::
GetPixelUID
(
int32_t
fpgaID
,
int32_t
ch
)
int32_t
Unpack
::
GetPixelUID
(
int32_t
fpgaID
,
int32_t
ch
)
const
{
{
// First 16 bits are used for the FPGA ID, then
// First 16 bits are used for the FPGA ID, then
// 8 bits unused and then 8 bits are used for the channel
// 8 bits unused and then 8 bits are used for the channel
return
((
fpgaID
<<
16
)
|
(
ch
&
0x00FF
));
return
((
fpgaID
<<
16
)
|
(
ch
&
0x00FF
));
}
}
TdcTimeData
Unpack
::
ProcessTimeData
(
uint32_t
tdcWord
)
TdcTimeData
Unpack
::
ProcessTimeData
(
uint32_t
tdcWord
)
const
{
{
TdcTimeData
out
;
TdcTimeData
out
;
out
.
fCoarse
=
static_cast
<
uint32_t
>
(
tdcWord
&
0x7ff
);
// 11 bits
out
.
fCoarse
=
static_cast
<
uint32_t
>
(
tdcWord
&
0x7ff
);
// 11 bits
...
@@ -310,13 +309,13 @@ namespace cbm::algo::rich
...
@@ -310,13 +309,13 @@ namespace cbm::algo::rich
return
out
;
return
out
;
}
}
uint32_t
Unpack
::
ProcessEpoch
(
uint32_t
tdcWord
)
{
return
static_cast
<
uint32_t
>
(
tdcWord
&
0xfffffff
);
}
uint32_t
Unpack
::
ProcessEpoch
(
uint32_t
tdcWord
)
const
{
return
static_cast
<
uint32_t
>
(
tdcWord
&
0xfffffff
);
}
uint16_t
Unpack
::
ProcessHeader
(
uint32_t
tdcWord
)
uint16_t
Unpack
::
ProcessHeader
(
uint32_t
tdcWord
)
const
{
{
return
static_cast
<
uint16_t
>
(
tdcWord
&
0xff
);
//8 bits
return
static_cast
<
uint16_t
>
(
tdcWord
&
0xff
);
//8 bits
}
}
uint16_t
Unpack
::
ProcessTrailer
(
uint32_t
tdcWord
)
{
return
static_cast
<
uint16_t
>
(
tdcWord
&
0xffff
);
}
uint16_t
Unpack
::
ProcessTrailer
(
uint32_t
tdcWord
)
const
{
return
static_cast
<
uint16_t
>
(
tdcWord
&
0xffff
);
}
}
// namespace cbm::algo::rich
}
// namespace cbm::algo::rich
This diff is collapsed.
Click to expand it.
algo/detectors/rich/Unpack.h
+
38
−
29
View file @
52ae62c1
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
#include
<sstream>
#include
<sstream>
#include
<utility>
#include
<utility>
#include
"Definitions.h"
namespace
cbm
::
algo
::
rich
namespace
cbm
::
algo
::
rich
{
{
class
MicrosliceReader
;
class
MicrosliceReader
;
...
@@ -118,7 +120,7 @@ namespace cbm::algo::rich
...
@@ -118,7 +120,7 @@ namespace cbm::algo::rich
** @return RICH digi data
** @return RICH digi data
**/
**/
resultType
operator
()(
const
uint8_t
*
msContent
,
const
fles
::
MicrosliceDescriptor
&
msDescr
,
resultType
operator
()(
const
uint8_t
*
msContent
,
const
fles
::
MicrosliceDescriptor
&
msDescr
,
const
uint64_t
tTimeslice
);
const
uint64_t
tTimeslice
)
const
;
/** @brief Set the parameter container
/** @brief Set the parameter container
** @param params Pointer to parameter container
** @param params Pointer to parameter container
...
@@ -126,34 +128,49 @@ namespace cbm::algo::rich
...
@@ -126,34 +128,49 @@ namespace cbm::algo::rich
void
SetParams
(
std
::
unique_ptr
<
UnpackPar
>
params
)
{
fParams
=
*
(
std
::
move
(
params
));
}
void
SetParams
(
std
::
unique_ptr
<
UnpackPar
>
params
)
{
fParams
=
*
(
std
::
move
(
params
));
}
private
:
private
:
void
ProcessTrbPacket
(
MicrosliceReader
&
reader
);
struct
MSContext
{
u64
cbmTimeMS
=
0
;
// CbmTime of MS. Used to get time offset of subtriggers to MS start
u64
cbmTimePacket
=
0
;
u64
refTime
=
0
;
double
prevLastCh0ReTime
[
13
];
// 12 DiRICHes chnl0 + 1 CTS chnl0
double
mbsCorr
=
0.
;
uint16_t
currentSubSubEvent
=
0
;
void
ProcessHubBlock
(
MicrosliceReader
&
reader
);
std
::
vector
<
CbmRichDigi
>
digis
;
UnpackMonitorData
monitor
;
};
private
:
void
ProcessTrbPacket
(
MicrosliceReader
&
reader
,
MSContext
&
ctx
)
const
;
int
Process
CtsHeader
(
MicrosliceReader
&
reader
,
uint32_t
subSubEventSize
,
uint32_t
subSubEventId
)
;
void
Process
HubBlock
(
MicrosliceReader
&
reader
,
MSContext
&
ctx
)
const
;
void
Process
SubSubEvent
(
MicrosliceReader
&
reader
,
int
nofTimeWords
,
uint32_t
subSubEventId
);
int
Process
CtsHeader
(
MicrosliceReader
&
reader
,
u
int
32_t
subSubEventSize
,
uint32_t
subSubEventId
)
const
;
void
ProcessTimeDataWord
(
uint32_t
epoch
,
uint32_t
tdcWord
,
uint32_t
subSubEventId
,
void
ProcessSubSubEvent
(
MicrosliceReader
&
reader
,
int
nofTimeWords
,
uint32_t
subSubEventId
,
MSContext
&
ctx
)
const
;
std
::
vector
<
double
>&
raisingTime
);
TdcWordType
GetTdcWordType
(
uint32_t
tdcWord
);
void
ProcessTimeDataWord
(
uint32_t
epoch
,
uint32_t
tdcWord
,
uint32_t
subSubEventId
,
std
::
vector
<
double
>&
raisingTime
,
MSContext
&
ctx
)
const
;
Tdc
TimeData
ProcessTimeData
(
uint32_t
tdcWord
);
Tdc
WordType
GetTdcWordType
(
uint32_t
tdcWord
)
const
;
uint32_t
ProcessEpoch
(
uint32_t
tdcWord
);
TdcTimeData
ProcessTimeData
(
uint32_t
tdcWord
)
const
;
uint
16
_t
Process
Header
(
uint32_t
tdcWord
);
uint
32
_t
Process
Epoch
(
uint32_t
tdcWord
)
const
;
uint16_t
Process
Trail
er
(
uint32_t
tdcWord
);
uint16_t
Process
Head
er
(
uint32_t
tdcWord
)
const
;
void
WriteOutputDigi
(
int
32
_t
fpgaID
,
int32_t
channel
,
double
time
,
double
tot
)
;
u
int
16
_t
ProcessTrailer
(
uint32_t
tdcWord
)
const
;
double
CalculateTime
(
u
int32_t
epoch
,
u
int32_t
c
oarse
,
uint32_t
fine
)
;
void
WriteOutputDigi
(
int32_t
fpgaID
,
int32_t
c
hannel
,
double
time
,
double
tot
,
MSContext
&
ctx
)
const
;
int32_t
GetPixelUID
(
int32_t
fpgaID
,
int32_t
ch
)
;
double
CalculateTime
(
uint32_t
epoch
,
u
int32_t
coarse
,
u
int32_t
fine
)
const
;
bool
CheckMaskedDiRICH
(
int32_t
subSubEventId
);
int32_t
GetPixelUID
(
int32_t
fpgaID
,
int32_t
ch
)
const
;
bool
CheckMaskedDiRICH
(
int32_t
subSubEventId
)
const
;
private
:
private
:
UnpackPar
fParams
=
{};
///< Parameter container
UnpackPar
fParams
=
{};
///< Parameter container
...
@@ -162,23 +179,15 @@ namespace cbm::algo::rich
...
@@ -162,23 +179,15 @@ namespace cbm::algo::rich
bool
fbDoToTCorr
=
true
;
//activates ToT correction from parameter file
bool
fbDoToTCorr
=
true
;
//activates ToT correction from parameter file
uint64_t
fCbmTimeMS
;
// uint64_t fCbmTimeMS;
uint64_t
fCbmTimePacket
;
// uint64_t fCbmTimePacket;
double
fMbsCorr
=
0.
;
double
fPrevLastCh0ReTime
[
13
];
// 12 DiRICHes chnl0 + 1 CTS chnl0
uint16_t
fCurrentSubSubEvent
=
0
;
uint64_t
fMsRefTime
=
0
;
// double fMbsCorr = 0.;
// double fPrevLastCh0ReTime[13]; // 12 DiRICHes chnl0 + 1 CTS chnl0
// uint16_t fCurrentSubSubEvent = 0;
double
fToTMin
=
-
20.
;
double
fToTMin
=
-
20.
;
double
fToTMax
=
100.
;
double
fToTMax
=
100.
;
/** @brief Default return vector for Unpack function. */
std
::
vector
<
CbmRichDigi
>
fOutputVec
=
{};
/** @brief Storage of monitoring data. */
UnpackMonitorData
fMonitor
;
};
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment