Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions DataFormats/Detectors/TPC/include/DataFormatsTPC/CMV.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// @file CMV.h
/// @author Tuba Gündem, tuba.gundem@cern.ch
/// @brief Common mode values data format definition

/// The data is sent by the CRU as 96 bit words. The CMV data layout is as follows:
/// - 80-bit Header: [version:8][packetID:8][errorCode:8][magicWord:8][heartbeatOrbit:32][heartbeatBC:16]
/// - 16-bit CMV value: [CMV:16]

#ifndef ALICEO2_DATAFORMATSTPC_CMV_H
#define ALICEO2_DATAFORMATSTPC_CMV_H

#include <bitset>

namespace o2::tpc::cmv
{

static constexpr uint32_t NTimeBins = 3564; ///< number of time bins (spans 8 orbits)
static constexpr uint32_t SignificantBits = 2; ///< number of bits used for floating point precision
static constexpr float FloatConversion = 1.f / float(1 << SignificantBits); ///< conversion factor from integer representation to float

/// Header definition of the CMVs
struct Header {
static constexpr uint8_t MagicWord = 0xDC;
union {
uint32_t word0 = 0; ///< bits 0 - 31
struct {
uint8_t version : 8; ///< version
uint8_t packetID : 8; ///< packet id
uint8_t errorCode : 8; ///< errors
uint8_t magicWord : 8; ///< magic word
};
};
union {
uint32_t word1 = 0; ///< bits 32 - 63
struct {
uint32_t heartbeatOrbit : 32; ///< first heart beat timing of the package

Check failure on line 47 in DataFormats/Detectors/TPC/include/DataFormatsTPC/CMV.h

View workflow job for this annotation

GitHub Actions / PR formatting / whitespace

Trailing spaces

Remove the trailing spaces at the end of the line.
};
};
union {
uint16_t word2 = 0; ///< bits 64 - 79
struct {
uint16_t heartbeatBC : 16; ///< first BC id of the package
};
};
};

/// CMV single data container
struct Data {
uint16_t CMV{0}; ///< 16bit ADC value

Check failure on line 61 in DataFormats/Detectors/TPC/include/DataFormatsTPC/CMV.h

View workflow job for this annotation

GitHub Actions / PR formatting / whitespace

Trailing spaces

Remove the trailing spaces at the end of the line.
// Raw integer accessors
uint16_t getCMV() const { return CMV; }
void setCMV(uint16_t value) { CMV = value; }

Check failure on line 65 in DataFormats/Detectors/TPC/include/DataFormatsTPC/CMV.h

View workflow job for this annotation

GitHub Actions / PR formatting / whitespace

Trailing spaces

Remove the trailing spaces at the end of the line.
// Float helpers using SignificantBits for fixed-point conversion
float getCMVFloat() const { return static_cast<float>(CMV) * FloatConversion; }
void setCMVFloat(float value) {
// round to nearest representable fixed-point value
setCMV(uint32_t((value + 0.5f * FloatConversion) / FloatConversion));
}
};

/// CMV full data container: one packet carries NTimeBins time bins
struct Container {
Header header; ///< CMV data header
Data data[NTimeBins]; ///< data values for given number of time bins

// Header and data accessors
const Header& getHeader() const { return header; }
Header& getHeader() { return header; }

const Data* getData() const { return data; }
Data* getData() { return data; }

// Per-time-bin CMV accessors
uint16_t getCMV(uint32_t timeBin) const { return data[timeBin].getCMV(); }
void setCMV(uint32_t timeBin, uint16_t value) { data[timeBin].setCMV(value); }

float getCMVFloat(uint32_t timeBin) const { return data[timeBin].getCMVFloat(); }
void setCMVFloat(uint32_t timeBin, float value) { data[timeBin].setCMVFloat(value); }

};
} // namespace o2::tpc::cmv

#endif
1 change: 1 addition & 0 deletions Detectors/TPC/base/include/TPCBase/RDHUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ static constexpr FEEIDType UserLogicLinkID = 15; ///< virtual link ID for ZS dat
static constexpr FEEIDType IDCLinkID = 20; ///< Identifier for integrated digital currents
static constexpr FEEIDType ILBZSLinkID = 21; ///< Identifier for improved link-based ZS
static constexpr FEEIDType DLBZSLinkID = 22; ///< Identifier for dense link-based ZS
static constexpr FEEIDType CMVLinkID = 23; ///< Identifier for common mode values
static constexpr FEEIDType SACLinkID = 25; ///< Identifier for sampled analog currents

/// compose feeid from cru, endpoint and link
Expand Down
21 changes: 21 additions & 0 deletions Detectors/TPC/workflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ o2_add_library(TPCWorkflow
src/KryptonRawFilterSpec.cxx
src/OccupancyFilterSpec.cxx
src/SACProcessorSpec.cxx
src/CMVToVectorSpec.cxx
src/IDCToVectorSpec.cxx
src/CalibdEdxSpec.cxx
src/CalibratordEdxSpec.cxx
Expand Down Expand Up @@ -289,3 +290,23 @@ o2_add_executable(pressure-temperature
PUBLIC_LINK_LIBRARIES O2::TPCWorkflow)

add_subdirectory(readers)

o2_add_executable(cmv-to-vector
COMPONENT_NAME tpc
SOURCES src/tpc-cmv-to-vector.cxx
PUBLIC_LINK_LIBRARIES O2::TPCWorkflow)

# o2_add_executable(cmv-flp
# COMPONENT_NAME tpc
# SOURCES src/tpc-flp-cmv.cxx
# PUBLIC_LINK_LIBRARIES O2::TPCWorkflow)

# o2_add_executable(cmv-distribute
# COMPONENT_NAME tpc
# SOURCES src/tpc-distribute-cmv.cxx
# PUBLIC_LINK_LIBRARIES O2::TPCWorkflow)

# o2_add_executable(cmv-producer
# COMPONENT_NAME tpc
# SOURCES src/tpc-cmv-producer.cxx
# PUBLIC_LINK_LIBRARIES O2::TPCWorkflow)
31 changes: 31 additions & 0 deletions Detectors/TPC/workflow/include/TPCWorkflow/CMVToVectorSpec.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// @file CMVToVectorSpec.h
/// @author Tuba Gündem, tuba.gundem@cern.ch
/// @brief Processor to convert CMVs to a vector in a CRU

#ifndef TPC_CMVToVectorSpec_H_
#define TPC_CMVToVectorSpec_H_

#include "Framework/DataProcessorSpec.h"
#include <string_view>

namespace o2::tpc
{

/// create a processor spec
/// convert CMV raw values to a vector in a CRU
o2::framework::DataProcessorSpec getCMVToVectorSpec(const std::string inputSpec, std::vector<uint32_t> const& crus);

} // end namespace o2::tpc

#endif //TPC_CMVToVectorSpec_H_
Loading
Loading