 |
ATLAS Offline Software
|
Go to the documentation of this file.
14 #include "Identifier/Identifier.h"
18 template<
unsigned int n>
20 chunk(std::bitset<128>
b){
21 static constexpr std::bitset<128> mask64(~0ULL);
22 static constexpr
unsigned int shift{
n * 64};
23 return ((
b >>shift) & mask64).to_ullong();
28 const int formatter{
static_cast<int>((fibre/12) & 0x7)};
29 const int linkNum{
static_cast<int>((fibre - (
formatter*12)) & 0xF)};
30 const int rodLink{(
formatter << 4) | linkNum};
34 geometryKey(
int barrel,
int disk,
int phi_mod,
int eta_group){
35 return (
static_cast<uint64_t>(barrel) << 48) |
36 (
static_cast<uint64_t>(disk) << 32) |
37 (
static_cast<uint64_t>(phi_mod) << 16) |
56 if (sctDetElement->swapPhiReadoutDirection()) {
61 return StatusCode::SUCCESS;
68 const std::vector<const SCT_RDORawData*>& vecRDOs)
const {
71 std::unordered_map<uint64_t, std::vector<std::bitset<256>>> allStripData;
73 for (
const auto& rdo : vecRDOs) {
86 eta_group =
static_cast<int>(std::floor((eta_mod+1) / 2));
88 eta_group =
static_cast<int>(std::floor(eta_mod / 2));
91 int chips_per_module = (strip_max + 1) / 128;
93 auto& StripData = allStripData[
key];
95 if (StripData.empty()) {
96 StripData.resize(chips_per_module);
101 int chip =
static_cast<int>(std::floor(
strip / 128));
102 int strip_position =
strip % 128;
103 int strip_logical_channel = 2*strip_position + (eta_mod & 1);
104 StripData[chip].set(strip_logical_channel);
107 std::vector<uint8_t> vec8Data;
110 for (
const auto& [
key, StripData] : allStripData) {
112 for (
size_t i = 0;
i < StripData.size(); ++
i) {
113 std::bitset<256>
hits = StripData[
i];
131 size_t total_clusters =
clusters.size();
132 size_t cluster_pos = 0;
134 while (cluster_pos < total_clusters) {
137 data_encode.push_back((
header>>8) & 0xff);
138 data_encode.push_back(
header & 0xff);
140 size_t max_cluster_pp = 0;
141 for (; max_cluster_pp < 4 && cluster_pos < total_clusters; ++max_cluster_pp, ++cluster_pos) {
145 uint16_t clusterbits = ((ichannel & 0xf) << 11) | (cluster & 0x7ff);
146 data_encode.push_back((clusterbits>>8) & 0xff);
147 data_encode.push_back(clusterbits & 0xff);
150 while (max_cluster_pp < 4) {
151 data_encode.push_back(0x7F);
152 data_encode.push_back(0xFF);
161 std::vector<uint16_t>
167 std::bitset<128> dataEven;
168 std::bitset<128> dataOdd;
169 for(
int i=0;
i<128; ++
i){
170 dataEven[
i] = inputData[2*
i];
171 dataOdd[
i] = inputData[2*
i+1];
181 while (d0l or d0h or d1l or d1h){
182 if (
clusters.size() > maxCluster)
break;
185 if (cluster1 != 0x3ff)
188 if (
clusters.size() > maxCluster)
break;
191 if (cluster0 != 0x3ff)
206 if (bit_addr > 127)
return false;
208 return bit_addr<64 ? data_low64>>bit_addr & 1 : data_high64>>(bit_addr-64) & 1;
214 data_low64 = (data_low64 & ~(1ULL << bit_addr)) | ((
uint64_t)
value << bit_addr);
215 }
else if (bit_addr < 128) {
217 (data_high64 & ~(1ULL << (bit_addr-64))) | ((
uint64_t)
value << (bit_addr-64));
228 hit_addr = __builtin_ctzll(hits_low64);
229 }
else if (hits_high64){
230 hit_addr = __builtin_ctzll(hits_high64) + 64;
233 hitpat_next3 =
getBit_128b(hit_addr+1, hits_high64, hits_low64) << 2
234 |
getBit_128b(hit_addr+2, hits_high64, hits_low64) << 1
235 |
getBit_128b(hit_addr+3, hits_high64, hits_low64);
237 for (
int i=0;
i<4; ++
i)
240 if (hit_addr == 128) {
243 hit_addr += isSecondRow<<7;
244 return hit_addr << 3 | hitpat_next3;
250 int num8Words{
static_cast<int>(vec8Words.size())};
251 if (num8Words % 4 != 0) {
253 while (num8Words % 4 != 0) {
254 vec8Words.push_back(0x40);
259 const unsigned short int numWords{4};
260 const unsigned short int position[numWords]{0, 8, 16, 24};
261 unsigned short int arr8Words[numWords]{0, 0, 0, 0};
263 for (
int i{0};
i<num8Words;
i += numWords) {
264 for (
int j{0}; j<numWords; j++) {
265 arr8Words[j] = vec8Words[
i + j];
268 vec32Words.push_back(uint32Word);
281 uint8Word =
static_cast<uint32_t>(*(arr8Words +
i));
283 uint32Word |= (uint8Word <<
pos);
311 return rodLinkFromOnlineID(
onlineID(rdo));
366 uint8_t bcid_low = bc_cout & 0x7;
369 const uint16_t Header{
static_cast<uint16_t>(((
uint8_t)typ << 12) | (0x1 << 11) | (l0tag & 0x7f) << 4 | (bcid_low) << 1 | bc_parity)};
385 const int rodLink{rodLinkFromOnlineID(
m_cabling->getOnlineIdFromHash(linkHash))};
def retrieve(aClass, aKey=None)
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
virtual StatusCode initialize() override
Initialize.
ToolHandle< IITkStripCablingTool > m_cabling
Providing mappings of online and offline identifiers and also serial numbers.
int getDiskLayer(const SCT_RDORawData *rdo) const
Get disk/layer info from the RDO.
std::set< Identifier > m_swapModuleID
Swap Module identifier, set by SCTRawContByteStreamTool.
std::vector< uint16_t > clusterFinder(const std::bitset< 256 > &inputData, const uint8_t maxCluster=63) const
@breif Method to set pairs of 8 bit words to a 32 bit word.
std::uint32_t fibre() const
Return the fibre.
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
int phi_module(const Identifier &id) const
uint32_t onlineID(const SCT_RDORawData *rdo) const
Get the online Identifier from the RDO.
uint16_t clusterFinder_sub(uint64_t &hits_high64, uint64_t &hits_low64, bool isSecondRow) const
int getPhiModule(const SCT_RDORawData *rdo) const
Get the phi value info from the RDO.
uint16_t getHeaderUsingHash(const IdentifierHash &linkHash, const int &errorWord) const
Get the 16-bit word for a header for a link with a ByteStream error.
uint32_t set32Bits(const unsigned short int *arr8Words, const unsigned short int *position, const unsigned short int &numWords) const
int getStripMax(const SCT_RDORawData *rdo) const
Get the maxumum strip value info from the RDO.
BooleanProperty m_condensed
Example Boolean used to determine decoding mode, maybe unused finally.
int getRODLink(const SCT_RDORawData *rdo) const
Get the ROD link number info in the RDO header data.
void encodeData(const std::vector< uint16_t > &clusters, const uint16_t ichannel, std::vector< uint8_t > &data_encode, int typ, uint8_t l0tag, uint8_t bc_count) const
Identifier offlineID(const SCT_RDORawData *rdo) const
Get the offline Identifier from the RDO.
::StatusCode StatusCode
StatusCode definition for legacy code.
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
bool getParity_8bits(uint8_t val) const
int getEtaModule(const SCT_RDORawData *rdo) const
Get the eta value info from the RDO.
uint16_t getHeaderUsingRDO(const SCT_RDORawData *rdo) const
Get the 16-bit word for a header for a hit.
std::atomic< uint8_t > m_bcid
Method to encode RDO data to vector of 16 bin words.
void setBit_128b(uint8_t bit_addr, bool value, uint64_t &data_high64, uint64_t &data_low64) const
std::atomic< uint8_t > m_l0tag
bool getBit_128b(uint8_t bit_addr, uint64_t data_high64, uint64_t data_low64) const
virtual void fillROD(std::vector< uint32_t > &vec32Data, const uint32_t &robID, const std::vector< const SCT_RDORawData * > &vecRDOs) const override
Main Convert method.
int layer_disk(const Identifier &id) const
uint16_t getHeaderPhysicsPacket(int typ, uint8_t l0tag, uint8_t bc_count) const
Get the 16-bit word for a header with Type (PR or LP), L0Tag event and BCID.
int side(const SCT_RDORawData *rdo) const
Get the side info from the RDO.
int getStrip(const SCT_RDORawData *rdo) const
Get the strip number info from the RDO.
uint16_t getTrailer(const int &errorWord) const
Get the 16-bit word for a trailer, with or without ByteStream errors.
int getBarrelEC(const SCT_RDORawData *rdo) const
Get the barrel/endcape info from the RDO.
int strip(const Identifier &id) const
int eta_module(const Identifier &id) const
int strip_max(const Identifier &id) const
int side(const Identifier &id) const
virtual Identifier identify() const override final
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
const SCT_ID * m_itkStripsID
Identifier helper class for the ITkStrips subdetector that creates compact Identifier objects and Ide...
void packFragments(std::vector< uint8_t > &vec8Words, std::vector< uint32_t > &vec32Words) const
Method to pack vector of 8 bit words intto a vector of 32 bit words.