Project
Loading...
Searching...
No Matches
ClusterHardware.h
Go to the documentation of this file.
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
16#ifndef ALICEO2_DATAFORMATSTPC_CLUSTERHARDWARE_H
17#define ALICEO2_DATAFORMATSTPC_CLUSTERHARDWARE_H
18
19#include <cstdint>
20
21namespace o2
22{
23namespace tpc
24{
25struct ClusterHardware { // Draft of hardware clusters in bit-packed format.
26 // padPre: word 0, bits 0 - 19 (20 bit, two-complement, 4 fixed-point-bits) - Quantity needed to compute the pad.
27 // padPeak: word 0, bits 20-27 (8 bit, unsigned integer) - Offset of padPre.
28 // timePre: word 1, bits 0-19 (20 bit, two-complement, 4 fixed-point-bits) - Quantity needed to compute the time.
29 // timePeak: word 1, bits 20-28 (9 bit, unsigned integer) - Offset of timePre.
30 // sigmaPadPre: word 2, bits 0-19 (20 bit, unsigned, 4 fixed-point-bits) - Quantity needed to compute the sigma^2 of
31 // the pad.
32 // sigmaTimePre: word 3, bits 0-19 (20 bit, unsigned, 4 fixed-point-bits) - Quantity needed to compute the
33 // sigma^2 of the time.
34 // qMax: word 2, bits 20-30 (11 bit, 1 fixed-point-bit) - QMax of the cluster.
35 // qTot: word 4, bits 0-18 (19 bit, 4 fixed-point-bits) - Total charge of the cluster.
36 // row: word 3, bits 20-24 (5 bit, unsigned integer) - Row of the cluster (local, needs to add
37 // PadRegionInfo::getGlobalRowOffset)
38 // flags: word 4, bits 19-26 (8 bit) up to 8 bit flag field.
39 // remaining bits: reserved, must be 0!, could be used for additional bits later.
40 uint32_t word0; //< word0 of binary hardware cluster
41 uint32_t word1; //< word1 of binary hardware cluster
42 uint32_t word2; //< word2 of binary hardware cluster
43 uint32_t word3; //< word3 of binary hardware cluster
44 uint32_t word4; //< word4 of binary hardware cluster
45
46 float getQTotFloat() const
47 {
48 unsigned int qTotInt = word4 & 0x7FFFF;
49 return (qTotInt / 16.f);
50 }
51
52 int getQTot() const { return (getQTotFloat() + 0.5); }
53
54 int getQMax() const
55 {
56 int qmaxint = (word2 & 0x7FF00000) >> 20;
57 return (qmaxint / 2.0 + 0.5);
58 }
59
60 int getRow() const { return ((word3 & 0x1F00000) >> 20); }
61
62 int getFlags() const { return ((word4 & 0x7F80000) >> 19); }
63
64 float getPadPre() const
65 {
66 int padPreInt = word0 & 0xFFFFF;
67 if (padPreInt & 0x80000) {
68 padPreInt |= 0xFFF00000;
69 }
70 return (padPreInt / 16.f);
71 }
72
85 float getPad() const
86 {
87 int padPeak = (word0 & 0xFF00000) >> 20;
88 return (getPadPre() / getQTotFloat() + padPeak);
89 }
90
91 float getTimeLocalPre() const
92 {
93 int timePreInt = word1 & 0xFFFFF;
94 if (timePreInt & 0x80000) {
95 timePreInt |= 0xFFF00000;
96 }
97 return (timePreInt / 16.f);
98 }
99
100 int getTimePeak() const
101 {
102 return (word1 & 0x1FF00000) >> 20;
103 }
104
105 float getTimeLocal() const // Returns the local time, not taking into account the time bin offset of the container
106 {
107 int timePeak = getTimePeak();
108 return (getTimeLocalPre() / getQTotFloat() + timePeak);
109 }
110
111 float getSigmaPad2() const
112 {
113 int sigmaPad2PreInt = word2 & 0xFFFFF;
114 float sigmaPad2Pre = sigmaPad2PreInt / 16.f;
115 return sigmaPad2Pre / getQTotFloat() - (getPadPre() * getPadPre()) / (getQTotFloat() * getQTotFloat());
116 }
117
118 float getSigmaTime2() const
119 {
120 int sigmaTime2PreInt = word3 & 0xFFFFF;
121 float sigmaTime2Pre = sigmaTime2PreInt / 16.f;
122 return sigmaTime2Pre / getQTotFloat() - (getTimeLocalPre() * getTimeLocalPre()) / (getQTotFloat() * getQTotFloat());
123 }
124
125 void setCluster(float pad, float time, float sigmaPad2, float sigmaTime2, float qMax, float qTot, int row, int flags)
126 {
127 int max = qMax * 2.f;
128 int tot = qTot * 16.f;
129 qTot = tot / 16.f;
130 int padPeak = pad + 0.5;
131 pad -= padPeak;
132 int timePeak = time + 0.5;
133 time -= timePeak;
134 pad *= qTot;
135 time *= qTot;
136 int p = pad * 16.f;
137 int t = time * 16.f;
138 pad = p / 16.f;
139 time = t / 16.f;
140 sigmaPad2 = (sigmaPad2 + pad / qTot * pad / qTot) * qTot;
141 sigmaTime2 = (sigmaTime2 + time / qTot * time / qTot) * qTot;
142 int sp = sigmaPad2 * 16.f;
143 int st = sigmaTime2 * 16.f;
144 word0 = (p & 0xFFFFF) | ((padPeak & 0xFF) << 20);
145 word1 = (t & 0xFFFFF) | ((timePeak & 0x1FF) << 20);
146 word2 = (sp & 0xFFFFF) | ((max & 0x7FF) << 20);
147 word3 = (st & 0xFFFFF) | ((row & 0x1F) << 20);
148 word4 = (tot & 0x7FFFF) | ((flags & 0xFF) << 19);
149 }
150
151 void setCluster(int padPeak, int timePeak, int pPre, int tPre, int sigmaPad2Pre, int sigmaTime2Pre, int qMax, int qTot, int row, int flags)
152 {
153 word0 = (pPre & 0xFFFFF) | ((padPeak & 0xFF) << 20);
154 word1 = (tPre & 0xFFFFF) | ((timePeak & 0x1FF) << 20);
155 word2 = (sigmaPad2Pre & 0xFFFFF) | ((qMax & 0x7FF) << 20);
156 word3 = (sigmaTime2Pre & 0xFFFFF) | ((row & 0x1F) << 20);
157 word4 = (qTot & 0x7FFFF) | ((flags & 0xFF) << 19);
158 }
159};
160
161struct ClusterHardwareContainer { // Temporary struct to hold a set of hardware clusters, prepended by an RDH, and a
162 // short header with metadata, to be replace
163 // The total structure is supposed to use up to 8 kb (like a readout block, thus it can hold up to 406 clusters ((8192
164 // - 40) / 20)
165 uint64_t mRDH[8]; //< 8 * 64 bit RDH (raw data header)
166 uint32_t timeBinOffset; //< Time offset in timebins since beginning of the time frame
167 uint16_t numberOfClusters; //< Number of clusters in this 8kb structure
168 uint16_t CRU; //< CRU of the cluster
169 ClusterHardware clusters[0]; //< Clusters
170};
171} // namespace tpc
172} // namespace o2
173
174#endif
int16_t time
Definition RawEventData.h:4
benchmark::State & st
GLbitfield flags
Definition glcorearb.h:1570
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
void setCluster(float pad, float time, float sigmaPad2, float sigmaTime2, float qMax, float qTot, int row, int flags)
void setCluster(int padPeak, int timePeak, int pPre, int tPre, int sigmaPad2Pre, int sigmaTime2Pre, int qMax, int qTot, int row, int flags)
constexpr size_t max
std::vector< int > row