Skip to content

Commit 9808d50

Browse files
committed
First commit of processing common mode values in O2
1 parent ee2b995 commit 9808d50

File tree

6 files changed

+660
-0
lines changed

6 files changed

+660
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// @file CMV.h
13+
/// @author Tuba Gündem, tuba.gundem@cern.ch
14+
/// @brief Common mode values data format definition
15+
16+
/// The data is sent by the CRU as 96 bit words. The CMV data layout is as follows:
17+
/// - 80-bit Header: [version:8][packetID:8][errorCode:8][magicWord:8][heartbeatOrbit:32][heartbeatBC:16]
18+
/// - 16-bit CMV value: [CMV:16]
19+
20+
#ifndef ALICEO2_DATAFORMATSTPC_CMV_H
21+
#define ALICEO2_DATAFORMATSTPC_CMV_H
22+
23+
#include <bitset>
24+
25+
namespace o2::tpc::cmv
26+
{
27+
28+
static constexpr uint32_t NTimeBins = 3564; ///< number of time bins (spans 8 orbits)
29+
static constexpr uint32_t SignificantBits = 2; ///< number of bits used for floating point precision
30+
static constexpr float FloatConversion = 1.f / float(1 << SignificantBits); ///< conversion factor from integer representation to float
31+
32+
/// Header definition of the CMVs
33+
struct Header {
34+
static constexpr uint8_t MagicWord = 0xDC;
35+
union {
36+
uint32_t word0 = 0; ///< bits 0 - 31
37+
struct {
38+
uint8_t version : 8; ///< version
39+
uint8_t packetID : 8; ///< packet id
40+
uint8_t errorCode : 8; ///< errors
41+
uint8_t magicWord : 8; ///< magic word
42+
};
43+
};
44+
union {
45+
uint32_t word1 = 0; ///< bits 32 - 63
46+
struct {
47+
uint32_t heartbeatOrbit : 32; ///< first heart beat timing of the package
48+
};
49+
};
50+
union {
51+
uint16_t word2 = 0; ///< bits 64 - 79
52+
struct {
53+
uint16_t heartbeatBC : 16; ///< first BC id of the package
54+
};
55+
};
56+
};
57+
58+
/// CMV single data container
59+
struct Data {
60+
uint16_t CMV{0}; ///< 16bit ADC value
61+
62+
// Raw integer accessors
63+
uint16_t getCMV() const { return CMV; }
64+
void setCMV(uint16_t value) { CMV = value; }
65+
66+
// Float helpers using SignificantBits for fixed-point conversion
67+
float getCMVFloat() const { return static_cast<float>(CMV) * FloatConversion; }
68+
void setCMVFloat(float value) {
69+
// round to nearest representable fixed-point value
70+
setCMV(uint32_t((value + 0.5f * FloatConversion) / FloatConversion));
71+
}
72+
};
73+
74+
/// CMV full data container: one packet carries NTimeBins time bins
75+
struct Container {
76+
Header header; ///< CMV data header
77+
Data data[NTimeBins]; ///< data values for given number of time bins
78+
79+
// Header and data accessors
80+
const Header& getHeader() const { return header; }
81+
Header& getHeader() { return header; }
82+
83+
const Data* getData() const { return data; }
84+
Data* getData() { return data; }
85+
86+
// Per-time-bin CMV accessors
87+
uint16_t getCMV(uint32_t timeBin) const { return data[timeBin].getCMV(); }
88+
void setCMV(uint32_t timeBin, uint16_t value) { data[timeBin].setCMV(value); }
89+
90+
float getCMVFloat(uint32_t timeBin) const { return data[timeBin].getCMVFloat(); }
91+
void setCMVFloat(uint32_t timeBin, float value) { data[timeBin].setCMVFloat(value); }
92+
93+
};
94+
} // namespace o2::tpc::cmv
95+
96+
#endif

Detectors/TPC/base/include/TPCBase/RDHUtils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ static constexpr FEEIDType UserLogicLinkID = 15; ///< virtual link ID for ZS dat
2828
static constexpr FEEIDType IDCLinkID = 20; ///< Identifier for integrated digital currents
2929
static constexpr FEEIDType ILBZSLinkID = 21; ///< Identifier for improved link-based ZS
3030
static constexpr FEEIDType DLBZSLinkID = 22; ///< Identifier for dense link-based ZS
31+
static constexpr FEEIDType CMVLinkID = 23; ///< Identifier for common mode values
3132
static constexpr FEEIDType SACLinkID = 25; ///< Identifier for sampled analog currents
3233

3334
/// compose feeid from cru, endpoint and link

Detectors/TPC/workflow/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ o2_add_library(TPCWorkflow
2525
src/KryptonRawFilterSpec.cxx
2626
src/OccupancyFilterSpec.cxx
2727
src/SACProcessorSpec.cxx
28+
src/CMVToVectorSpec.cxx
2829
src/IDCToVectorSpec.cxx
2930
src/CalibdEdxSpec.cxx
3031
src/CalibratordEdxSpec.cxx
@@ -289,3 +290,23 @@ o2_add_executable(pressure-temperature
289290
PUBLIC_LINK_LIBRARIES O2::TPCWorkflow)
290291

291292
add_subdirectory(readers)
293+
294+
o2_add_executable(cmv-to-vector
295+
COMPONENT_NAME tpc
296+
SOURCES src/tpc-cmv-to-vector.cxx
297+
PUBLIC_LINK_LIBRARIES O2::TPCWorkflow)
298+
299+
# o2_add_executable(cmv-flp
300+
# COMPONENT_NAME tpc
301+
# SOURCES src/tpc-flp-cmv.cxx
302+
# PUBLIC_LINK_LIBRARIES O2::TPCWorkflow)
303+
304+
# o2_add_executable(cmv-distribute
305+
# COMPONENT_NAME tpc
306+
# SOURCES src/tpc-distribute-cmv.cxx
307+
# PUBLIC_LINK_LIBRARIES O2::TPCWorkflow)
308+
309+
# o2_add_executable(cmv-producer
310+
# COMPONENT_NAME tpc
311+
# SOURCES src/tpc-cmv-producer.cxx
312+
# PUBLIC_LINK_LIBRARIES O2::TPCWorkflow)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// @file CMVToVectorSpec.h
13+
/// @author Tuba Gündem, tuba.gundem@cern.ch
14+
/// @brief Processor to convert CMVs to a vector in a CRU
15+
16+
#ifndef TPC_CMVToVectorSpec_H_
17+
#define TPC_CMVToVectorSpec_H_
18+
19+
#include "Framework/DataProcessorSpec.h"
20+
#include <string_view>
21+
22+
namespace o2::tpc
23+
{
24+
25+
/// create a processor spec
26+
/// convert CMV raw values to a vector in a CRU
27+
o2::framework::DataProcessorSpec getCMVToVectorSpec(const std::string inputSpec, std::vector<uint32_t> const& crus);
28+
29+
} // end namespace o2::tpc
30+
31+
#endif //TPC_CMVToVectorSpec_H_

0 commit comments

Comments
 (0)