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
bc0ddb93
Commit
bc0ddb93
authored
1 year ago
by
Felix Weiglhofer
Committed by
Dominik Smith
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
algo::UnpackSts: Make thread-safe.
parent
2e14e7df
No related branches found
No related tags found
1 merge request
!1219
algo: Unpack TOF and STS in parallel.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
algo/detectors/sts/UnpackSts.cxx
+14
-13
14 additions, 13 deletions
algo/detectors/sts/UnpackSts.cxx
algo/detectors/sts/UnpackSts.h
+14
-8
14 additions, 8 deletions
algo/detectors/sts/UnpackSts.h
with
28 additions
and
21 deletions
algo/detectors/sts/UnpackSts.cxx
+
14
−
13
View file @
bc0ddb93
...
@@ -20,19 +20,20 @@ namespace cbm::algo
...
@@ -20,19 +20,20 @@ namespace cbm::algo
// ---- Algorithm execution ---------------------------------------------
// ---- Algorithm execution ---------------------------------------------
UnpackSts
::
resultType
UnpackSts
::
operator
()(
const
uint8_t
*
msContent
,
const
fles
::
MicrosliceDescriptor
&
msDescr
,
UnpackSts
::
resultType
UnpackSts
::
operator
()(
const
uint8_t
*
msContent
,
const
fles
::
MicrosliceDescriptor
&
msDescr
,
const
uint64_t
tTimeslice
)
const
uint64_t
tTimeslice
)
const
{
{
// --- Output data
// --- Output data
resultType
result
=
{};
resultType
result
=
{};
// --- Current Timeslice start time in epoch units. Note that it is always a multiple of epochs
// --- Current Timeslice start time in epoch units. Note that it is always a multiple of epochs
// --- and the epoch is a multiple of ns.
// --- and the epoch is a multiple of ns.
TimeSpec
time
;
const
uint64_t
epochLengthInNs
=
fkEpochLength
*
fkClockCycleNom
/
fkClockCycleDen
;
const
uint64_t
epochLengthInNs
=
fkEpochLength
*
fkClockCycleNom
/
fkClockCycleDen
;
fC
urrentTsTime
=
tTimeslice
/
epochLengthInNs
;
time
.
c
urrentTsTime
=
tTimeslice
/
epochLengthInNs
;
// --- Current TS_MSB epoch cycle
// --- Current TS_MSB epoch cycle
auto
const
msTime
=
msDescr
.
idx
;
// Unix time of MS in ns
auto
const
msTime
=
msDescr
.
idx
;
// Unix time of MS in ns
fC
urrentCycle
=
std
::
ldiv
(
msTime
,
fkCycleLength
).
quot
;
time
.
c
urrentCycle
=
std
::
ldiv
(
msTime
,
fkCycleLength
).
quot
;
// --- Number of messages in microslice
// --- Number of messages in microslice
auto
msSize
=
msDescr
.
size
;
auto
msSize
=
msDescr
.
size
;
...
@@ -60,7 +61,7 @@ namespace cbm::algo
...
@@ -60,7 +61,7 @@ namespace cbm::algo
result
.
second
.
fNumErrInvalidFirstMessage
++
;
result
.
second
.
fNumErrInvalidFirstMessage
++
;
return
result
;
return
result
;
}
}
ProcessTsmsbMessage
(
message
[
1
]);
ProcessTsmsbMessage
(
message
[
1
]
,
time
);
// --- Message loop
// --- Message loop
for
(
uint32_t
messageNr
=
2
;
messageNr
<
numMessages
;
messageNr
++
)
{
for
(
uint32_t
messageNr
=
2
;
messageNr
<
numMessages
;
messageNr
++
)
{
...
@@ -69,11 +70,11 @@ namespace cbm::algo
...
@@ -69,11 +70,11 @@ namespace cbm::algo
switch
(
message
[
messageNr
].
GetMessType
())
{
switch
(
message
[
messageNr
].
GetMessType
())
{
case
stsxyter
::
MessType
::
Hit
:
{
case
stsxyter
::
MessType
::
Hit
:
{
ProcessHitMessage
(
message
[
messageNr
],
result
.
first
,
result
.
second
);
ProcessHitMessage
(
message
[
messageNr
],
time
,
result
.
first
,
result
.
second
);
break
;
break
;
}
}
case
stsxyter
::
MessType
::
TsMsb
:
{
case
stsxyter
::
MessType
::
TsMsb
:
{
ProcessTsmsbMessage
(
message
[
messageNr
]);
ProcessTsmsbMessage
(
message
[
messageNr
]
,
time
);
break
;
break
;
}
}
default
:
{
default
:
{
...
@@ -91,8 +92,8 @@ namespace cbm::algo
...
@@ -91,8 +92,8 @@ namespace cbm::algo
// ----- Process hit message --------------------------------------------
// ----- Process hit message --------------------------------------------
inline
void
UnpackSts
::
ProcessHitMessage
(
const
stsxyter
::
Message
&
message
,
vector
<
CbmStsDigi
>&
digiVec
,
inline
void
UnpackSts
::
ProcessHitMessage
(
const
stsxyter
::
Message
&
message
,
const
TimeSpec
&
time
,
UnpackStsMonitorData
&
monitor
)
const
vector
<
CbmStsDigi
>&
digiVec
,
UnpackStsMonitorData
&
monitor
)
const
{
{
// --- Check eLink and get parameters
// --- Check eLink and get parameters
...
@@ -114,7 +115,7 @@ namespace cbm::algo
...
@@ -114,7 +115,7 @@ namespace cbm::algo
}
}
// --- Expand time stamp to time within timeslice (in clock cycle)
// --- Expand time stamp to time within timeslice (in clock cycle)
uint64_t
messageTime
=
message
.
GetHitTimeBinning
()
+
fC
urrentEpochTime
;
uint64_t
messageTime
=
message
.
GetHitTimeBinning
()
+
time
.
c
urrentEpochTime
;
// --- Convert time stamp from clock cycles to ns. Round to nearest full ns.
// --- Convert time stamp from clock cycles to ns. Round to nearest full ns.
messageTime
=
(
messageTime
*
fkClockCycleNom
+
fkClockCycleDen
/
2
)
/
fkClockCycleDen
;
messageTime
=
(
messageTime
*
fkClockCycleNom
+
fkClockCycleDen
/
2
)
/
fkClockCycleDen
;
...
@@ -143,7 +144,7 @@ namespace cbm::algo
...
@@ -143,7 +144,7 @@ namespace cbm::algo
// ----- Process an epoch (TS_MSB) message ------------------------------
// ----- Process an epoch (TS_MSB) message ------------------------------
inline
void
UnpackSts
::
ProcessTsmsbMessage
(
const
stsxyter
::
Message
&
message
)
inline
void
UnpackSts
::
ProcessTsmsbMessage
(
const
stsxyter
::
Message
&
message
,
TimeSpec
&
time
)
const
{
{
// The compression of time is based on the hierarchy epoch cycle - epoch - message time.
// The compression of time is based on the hierarchy epoch cycle - epoch - message time.
// Cycles are counted from the start of Unix time and are multiples of an epoch (ts_msb).
// Cycles are counted from the start of Unix time and are multiples of an epoch (ts_msb).
...
@@ -156,13 +157,13 @@ namespace cbm::algo
...
@@ -156,13 +157,13 @@ namespace cbm::algo
auto
epoch
=
message
.
GetTsMsbValBinning
();
auto
epoch
=
message
.
GetTsMsbValBinning
();
// --- Cycle wrap
// --- Cycle wrap
if
(
epoch
<
fC
urrentEpoch
)
fC
urrentCycle
++
;
if
(
epoch
<
time
.
c
urrentEpoch
)
time
.
c
urrentCycle
++
;
// --- Update current epoch counter
// --- Update current epoch counter
fC
urrentEpoch
=
epoch
;
time
.
c
urrentEpoch
=
epoch
;
// --- Calculate epoch time in clocks cycles relative to timeslice start time
// --- Calculate epoch time in clocks cycles relative to timeslice start time
fC
urrentEpochTime
=
(
fC
urrentCycle
*
fkEpochsPerCycle
+
epoch
-
fC
urrentTsTime
)
*
fkEpochLength
;
time
.
c
urrentEpochTime
=
(
time
.
c
urrentCycle
*
fkEpochsPerCycle
+
epoch
-
time
.
c
urrentTsTime
)
*
fkEpochLength
;
}
}
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
algo/detectors/sts/UnpackSts.h
+
14
−
8
View file @
bc0ddb93
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
#ifndef CBM_ALGO_UNPACKSTS_H
#ifndef CBM_ALGO_UNPACKSTS_H
#define CBM_ALGO_UNPACKSTS_H 1
#define CBM_ALGO_UNPACKSTS_H 1
#include
"CbmStsDigi.h"
#include
"CbmStsDigi.h"
#include
"MicrosliceDescriptor.hpp"
#include
"MicrosliceDescriptor.hpp"
...
@@ -17,6 +16,7 @@
...
@@ -17,6 +16,7 @@
#include
<memory>
#include
<memory>
#include
<vector>
#include
<vector>
#include
"Prelude.h"
#include
"StsXyterMessage.h"
#include
"StsXyterMessage.h"
namespace
cbm
::
algo
namespace
cbm
::
algo
...
@@ -103,13 +103,23 @@ namespace cbm::algo
...
@@ -103,13 +103,23 @@ namespace cbm::algo
** @return STS digi data
** @return STS 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
**/
**/
void
SetParams
(
std
::
unique_ptr
<
UnpackStsPar
>
params
)
{
fParams
=
*
(
std
::
move
(
params
));
}
void
SetParams
(
std
::
unique_ptr
<
UnpackStsPar
>
params
)
{
fParams
=
*
(
std
::
move
(
params
));
}
private
:
// types
/**
* @brief Structure to hold the current time information for the current microslice
*/
struct
TimeSpec
{
u64
currentTsTime
=
0
;
///< Unix time of timeslice in units of epoch length
u64
currentCycle
=
0
;
///< Current epoch cycle
u32
currentEpoch
=
0
;
///< Current epoch number within epoch cycle
u64
currentEpochTime
=
0
;
///< Current epoch time relative to timeslice in clock cycles
};
private
:
// methods
private
:
// methods
/** @brief Process a hit message
/** @brief Process a hit message
...
@@ -117,20 +127,16 @@ namespace cbm::algo
...
@@ -117,20 +127,16 @@ namespace cbm::algo
** @param digiVec Vector to append the created digi to
** @param digiVec Vector to append the created digi to
** @param monitor Reference to monitor object
** @param monitor Reference to monitor object
**/
**/
void
ProcessHitMessage
(
const
stsxyter
::
Message
&
message
,
std
::
vector
<
CbmStsDigi
>&
digiVec
,
void
ProcessHitMessage
(
const
stsxyter
::
Message
&
message
,
const
TimeSpec
&
time
,
std
::
vector
<
CbmStsDigi
>&
digiVec
,
UnpackStsMonitorData
&
monitor
)
const
;
UnpackStsMonitorData
&
monitor
)
const
;
/** @brief Process an epoch message (TS_MSB)
/** @brief Process an epoch message (TS_MSB)
** @param message SMX message (32-bit word)
** @param message SMX message (32-bit word)
**/
**/
void
ProcessTsmsbMessage
(
const
stsxyter
::
Message
&
message
)
;
void
ProcessTsmsbMessage
(
const
stsxyter
::
Message
&
message
,
TimeSpec
&
time
)
const
;
private
:
// members
private
:
// members
uint64_t
fCurrentTsTime
=
0
;
///< Unix time of timeslice in units of epoch length
uint64_t
fCurrentCycle
=
0
;
///< Current epoch cycle
uint32_t
fCurrentEpoch
=
0
;
///< Current epoch number within epoch cycle
uint64_t
fCurrentEpochTime
=
0
;
///< Current epoch time relative to timeslice in clock cycles
UnpackStsPar
fParams
=
{};
///< Parameter container
UnpackStsPar
fParams
=
{};
///< Parameter container
/** Number of TS_MSB epochs per cycle **/
/** Number of TS_MSB epochs per cycle **/
...
...
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