Skip to content

Commit a757263

Browse files
wiechuladavidrohr
authored andcommitted
TPC: Processing of sampled analogue currents (SAC)
1 parent d5ecf99 commit a757263

13 files changed

Lines changed: 956 additions & 53 deletions

File tree

DataFormats/Detectors/TPC/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ o2_target_root_dictionary(
5757
include/DataFormatsTPC/CompressedClusters.h
5858
include/DataFormatsTPC/CTF.h
5959
include/DataFormatsTPC/IDC.h
60+
include/DataFormatsTPC/SAC.h
6061
include/DataFormatsTPC/ZeroSuppression.h
6162
include/DataFormatsTPC/ZeroSuppressionLinkBased.h
6263
include/DataFormatsTPC/TrackCuts.h

DataFormats/Detectors/TPC/include/DataFormatsTPC/Defs.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
#include "MathUtils/Cartesian.h"
2929
#endif
3030

31-
namespace o2
32-
{
33-
namespace tpc
31+
namespace o2::tpc
3432
{
3533

3634
/// TPC readout sidE
@@ -58,7 +56,8 @@ enum GEMstack { IROCgem = 0,
5856
OROC3gem = 3 };
5957
constexpr unsigned short GEMSTACKSPERSECTOR = 4;
6058
constexpr unsigned short GEMSPERSTACK = 4;
61-
constexpr unsigned short GEMSTACKSPERSIDE = 144;
59+
constexpr unsigned short GEMSTACKSPERSIDE = GEMSTACKSPERSECTOR * SECTORSPERSIDE;
60+
constexpr unsigned short GEMSTACKS = GEMSTACKSPERSECTOR * SECTORSPERSIDE * SIDES;
6261

6362
/// Definition of the different pad subsets
6463
enum class PadSubset : char {
@@ -164,7 +163,6 @@ typename Enum<T>::Iterator end(Enum<T>)
164163
{
165164
return typename Enum<T>::Iterator(((int)T::Last) + 1);
166165
}
167-
} // namespace tpc
168-
} // namespace o2
166+
} // namespace o2::tpc
169167

170168
#endif

DataFormats/Detectors/TPC/include/DataFormatsTPC/RawDataTypes.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ namespace o2::tpc::raw_data_types
2424
{
2525
enum class Type {
2626
RAWDATA = 0, ///< GBT raw data
27-
LinkZS = 1, ///< Link-based zero suppression
28-
ZS = 2, ///< final zero suppression
29-
IDC = 3, ///< integrated digitial current, with priority bit to end up in separate buffer
30-
IAC = 4, ///< Analogue currents from the current monitor
27+
LinkZS = 1, ///< Link-based Zero Suppression
28+
ZS = 2, ///< final Zero Suppression
29+
IDC = 3, ///< Integrated Digitial Currents, with priority bit to end up in separate buffer
30+
SAC = 4, ///< Sampled Analogue Currents from the current monitor
3131
};
3232

3333
const std::unordered_map<Type, std::string_view> TypeNameMap{
3434
{Type::RAWDATA, "RAWDATA"},
3535
{Type::LinkZS, "LinkZS"},
3636
{Type::ZS, "ZS"},
3737
{Type::IDC, "IDC"},
38-
{Type::IAC, "IAC"},
38+
{Type::SAC, "SAC"},
3939
};
4040

4141
} // namespace o2::tpc::raw_data_types
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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 SAC.h
13+
/// \brief Sampled Analogue Currents (SACs) data format definitions
14+
/// @author Jens Wiechula, Jens.Wiechula@ikf.uni-frankfurt.de
15+
16+
#ifndef ALICEO2_DATAFORMATSTPC_SAC_H
17+
#define ALICEO2_DATAFORMATSTPC_SAC_H
18+
19+
#include <cstdint>
20+
#include <string_view>
21+
22+
namespace o2::tpc::sac
23+
{
24+
25+
static constexpr uint32_t FEsPerInstance = 9;
26+
27+
/// 256bit CRU header word of SACs
28+
struct headerDef {
29+
static constexpr uint32_t MagicWord = 0xabcd; ///< magic word
30+
31+
union {
32+
uint64_t word0 = 0; ///< bits 0 - 63
33+
struct { ///
34+
uint32_t version : 8; ///< header version number
35+
uint32_t instance : 4; ///< 0: TPC A (slave), 1: TPC C (master), 2/3: TRD
36+
uint32_t empty0 : 8; ///< not used
37+
uint32_t bunchCrossing : 12; ///< bunch crossing when SAC packet was received
38+
uint32_t orbit : 32; ///< orbit when SAC packet was received
39+
}; ///
40+
}; ///
41+
///
42+
union { ///
43+
uint64_t word1 = 0; ///< bits 64 - 127
44+
struct { ///<
45+
uint32_t pktCount : 16; ///< internal packet counter, should always increase by one
46+
uint32_t empty1_0 : 16; ///< not used
47+
uint32_t empty1_1; ///< not used
48+
}; ///
49+
}; ///
50+
///
51+
union { ///
52+
uint64_t word2 = 0; ///< bits 128 - 191
53+
}; ///
54+
///
55+
union { ///
56+
uint64_t word3 = 0; ///< bits 192 - 255
57+
struct { ///
58+
uint32_t empty3_0; ///<
59+
uint32_t empty3_1 : 16; ///<
60+
uint32_t magicWord : 16; ///< magic word should always correspond to MagicWord
61+
}; ///
62+
}; ///
63+
64+
bool check() const { return magicWord == MagicWord; }
65+
};
66+
67+
struct dataDef {
68+
static constexpr uint32_t HeaderWord = 0xdeadbeef;
69+
static constexpr uint32_t TrailerWord = 0xbeefdead;
70+
static constexpr uint32_t PacketSize = 1024;
71+
static constexpr uint32_t DataSize = 1000;
72+
73+
uint32_t header = 0; ///< header magic word, should always be HeaderWord
74+
///
75+
union { ///
76+
uint32_t sizeFE = 0; ///<
77+
struct { ///
78+
uint32_t feid : 8; ///< front end ID (card number in rack): 1 - 9
79+
uint32_t pktSize : 24; ///< total size of the packet in bytes, should always be 1024
80+
}; ///
81+
}; ///
82+
///
83+
uint32_t pktNumber = 0; ///< packet number of this front end card. Should always increase by 1
84+
uint32_t timeStamp = 0; ///< tims stamp
85+
char dataWords[DataSize]; ///< ASCI encoded SAC data
86+
uint32_t crc32 = 0; ///< CRC32 checksum
87+
uint32_t trailer = 0; ///< trailer magic word, should always be TrailerWord
88+
89+
bool check() const
90+
{
91+
return (header == HeaderWord) && (trailer == TrailerWord) && (pktSize == PacketSize);
92+
}
93+
};
94+
95+
struct packet {
96+
headerDef header;
97+
dataDef data;
98+
99+
uint32_t getInstance() const
100+
{
101+
return header.instance;
102+
}
103+
104+
/// return the global front end card index
105+
/// 0 - 9: A-Side
106+
/// 10 - 17: C-Side
107+
uint32_t getFEIndex() const
108+
{
109+
return data.feid - 1 + header.instance * FEsPerInstance;
110+
}
111+
112+
std::string_view getDataWords()
113+
{
114+
return std::string_view(data.dataWords, dataDef::DataSize);
115+
}
116+
117+
bool check() const
118+
{
119+
return header.check() && data.check();
120+
}
121+
122+
int getCheckMask() const
123+
{
124+
return (header.check() << 1) | data.check();
125+
}
126+
};
127+
128+
} // namespace o2::tpc::sac
129+
130+
#endif

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ namespace rdh_utils
2525
using o2::raw::RDHUtils;
2626
using FEEIDType = uint16_t;
2727
static constexpr FEEIDType UserLogicLinkID = 15; ///< virtual link ID for ZS data
28-
static constexpr FEEIDType IDCLinkID = 20; ///< Identifier for digital currents
29-
static constexpr FEEIDType IACLinkID = 25; ///< Identifier for analog currents
28+
static constexpr FEEIDType IDCLinkID = 20; ///< Identifier for integrated digital currents
29+
static constexpr FEEIDType SACLinkID = 25; ///< Identifier for sampled analog currents
3030

3131
/// compose feeid from cru, endpoint and link
3232
static constexpr FEEIDType getFEEID(const FEEIDType cru, const FEEIDType endpoint, const FEEIDType link) { return FEEIDType((cru << 7) | ((endpoint & 1) << 6) | (link & 0x3F)); }

Detectors/TPC/calibration/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ o2_add_library(TPCCalibration
2525
src/CalibPadGainTracksBase.cxx
2626
src/CalibLaserTracks.cxx
2727
src/LaserTracksCalibrator.cxx
28+
src/SACDecoder.cxx
2829
src/IDCAverageGroup.cxx
2930
src/IDCAverageGroupBase.cxx
3031
src/IDCAverageGroupHelper.cxx
@@ -63,6 +64,7 @@ o2_target_root_dictionary(TPCCalibration
6364
include/TPCCalibration/FastHisto.h
6465
include/TPCCalibration/CalibLaserTracks.h
6566
include/TPCCalibration/LaserTracksCalibrator.h
67+
include/TPCCalibration/SACDecoder.h
6668
include/TPCCalibration/IDCAverageGroup.h
6769
include/TPCCalibration/IDCAverageGroupBase.h
6870
include/TPCCalibration/IDCAverageGroupHelper.h

0 commit comments

Comments
 (0)