ATLAS Offline Software
Loading...
Searching...
No Matches
CmxCpSubBlock.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TRIGT1CALOBYTESTREAM_CMXCPSUBBLOCK_H
6#define TRIGT1CALOBYTESTREAM_CMXCPSUBBLOCK_H
7
8#include <stdint.h>
9#include <vector>
10
11#include "CmxSubBlock.h"
12
13namespace LVL1BS {
14
22
23class CmxCpSubBlock : public CmxSubBlock {
24
25 public:
26
31
34
36 void clear();
37
39 unsigned int presenceMap(int slice, int cpm) const;
41 int chip(int slice, int cpm, int tob) const;
43 int localCoord(int slice, int cpm, int tob) const;
45 int isolation(int slice, int cpm, int tob) const;
47 int energy(int slice, int cpm, int tob) const;
49 int tobError(int slice, int cpm, int tob) const;
51 unsigned int hits(int slice, int source, int flag) const;
53 int hitsError(int slice, int source, int flag) const;
55 int roiOverflow(int slice, int source) const;
56
58 void setPresenceMap(int slice, int cpm, unsigned int map);
60 void setTob(int slice, int cpm, int chip, int loc, // NB chip and loc 4 and 2 bits here, as in diagram
61 int energy, int isol, int error);
63 void setHits(int slice, int source, int flag, unsigned int hits, int error);
65 void setRoiOverflow(int slice, int source, int overflow);
66
68 bool pack();
70 bool unpack();
71
72 private:
74 static const int s_wordLength = 32;
75 // TOB bit positions and masks
76 static const int s_tobEnergyBit = 0;
77 static const int s_tobIsolationBit = 8;
78 static const int s_tobErrorBit = 13;
79 static const int s_tobOverflowBit = 18;
80 static const int s_tobCoordBit = 19;
81 static const int s_tobChipBit = 21;
82 static const int s_tobCpmBit = 25;
83 static const int s_tobWordId = 0;
84 static const uint32_t s_tobEnergyMask = 0xff;
85 static const uint32_t s_tobIsolationMask = 0x1f;
86 static const uint32_t s_tobErrorMask = 0x3f; // includes RoI overflow
87 static const uint32_t s_tobCoordMask = 0x3;
88 static const uint32_t s_tobChipMask = 0xf;
89 static const uint32_t s_tobCpmMask = 0xf;
90 // EM/Tau hit and topo counts bit positions and masks
91 static const int s_threshBit = 0;
92 static const int s_threshErrorBit = 24;
93 static const int s_hlFlagBit = 25;
94 static const int s_sourceIdBit = 26;
95 static const int s_dataWordIdBit = 29;
96 static const int s_threshWordId = 1;
97 static const uint32_t s_threshMask = 0xffffff;
98 static const uint32_t s_errorMask = 0x1;
99 static const uint32_t s_hlFlagMask = 0x1;
100 static const uint32_t s_sourceIdMask = 0x7;
101 static const uint32_t s_dataWordIdMask = 0x7;
102 // Neutral format
103 static const int s_presenceBits = 16;
104 static const int s_coordBits = 2;
105 static const int s_isolationBits = 5;
106 static const int s_parityErrorBits = 1;
107 static const int s_parityErrorMask = 0x1;
108 static const int s_energyBits = 8;
109 static const int s_hitsBits = 24;
110 static const int s_hitsErrorBits = 1;
111 static const int s_roiOverflowBits = 1;
112 static const int s_paddingBits = 45;
113 static const int s_bunchCrossingBits = 12;
114 static const int s_fifoOverflowBits = 1;
115 static const int s_topoChecksumBits = 16;
116 static const int s_topoMapBits = 14;
117 static const int s_topoCountsBits = 21;
118 static const int s_topoPaddingBits = 11;
119 static const int s_glinkPins = 20;
120 static const int s_modules = 14;
121 static const int s_tobsPerModule = 5;
122 static const int s_muxPhases = 4;
123
124 int dataWordId(uint32_t word) const;
125 int sourceId(uint32_t word) const;
126 int cpm(uint32_t word) const;
127 int hlFlag(uint32_t word) const;
128 unsigned int mapIndex(int slice, int cpm) const;
129 unsigned int tobIndex(int slice, int cpm, int tob) const;
130 unsigned int hitIndex(int slice, int source, int flag) const;
131 unsigned int ovfIndex(int slice, int source) const;
132 void resize();
133
135 bool packNeutral();
137 bool packUncompressed();
139 bool unpackNeutral();
141 bool unpackUncompressed();
142
144 std::vector<uint32_t> m_tobData;
146 std::vector<uint32_t> m_hitsData;
148 std::vector<unsigned int> m_presenceMaps;
150 std::vector<int> m_cpmTobCount;
152 std::vector<int> m_overflow;
153
154};
155
156inline int CmxCpSubBlock::dataWordId(const uint32_t word) const
157{
158 return (word >> s_dataWordIdBit) & s_dataWordIdMask;
159}
160
161inline int CmxCpSubBlock::sourceId(const uint32_t word) const
162{
163 return (word >> s_sourceIdBit) & s_sourceIdMask;
164}
165
166inline int CmxCpSubBlock::cpm(const uint32_t word) const
167{
168 return (word >> s_tobCpmBit) & s_tobCpmMask;
169}
170
171inline int CmxCpSubBlock::hlFlag(const uint32_t word) const
172{
173 return (word >> s_hlFlagBit) & s_hlFlagMask;
174}
175
176} // end namespace
177
178#endif
static const int s_isolationBits
static const uint32_t s_tobChipMask
bool unpackNeutral()
Unpack neutral data.
unsigned int hits(int slice, int source, int flag) const
Return hit/topo counts for given source ID and HL flag.
static const int s_parityErrorMask
static const int s_parityErrorBits
int roiOverflow(int slice, int source) const
Return RoI overflow for given source ID.
static const int s_threshErrorBit
static const int s_tobIsolationBit
static const int s_tobOverflowBit
static const int s_tobChipBit
static const int s_bunchCrossingBits
static const int s_threshBit
bool packUncompressed()
Pack uncompressed data.
SourceId
Sources of threshold sums.
static const int s_tobsPerModule
void clear()
Clear all data.
bool unpackUncompressed()
Unpack uncompressed data.
static const uint32_t s_sourceIdMask
static const int s_tobWordId
static const int s_hlFlagBit
int energy(int slice, int cpm, int tob) const
Return energy for given cpm and tob.
static const int s_sourceIdBit
static const int s_hitsErrorBits
static const uint32_t s_tobCoordMask
bool unpack()
Unpack data.
std::vector< int > m_overflow
RoI overflows for neutral data.
static const int s_fifoOverflowBits
static const int s_glinkPins
static const uint32_t s_hlFlagMask
std::vector< uint32_t > m_tobData
TOB data.
static const int s_energyBits
static const int s_topoChecksumBits
static const int s_tobEnergyBit
static const uint32_t s_threshMask
static const int s_tobCoordBit
void setPresenceMap(int slice, int cpm, unsigned int map)
Store presence map.
int sourceId(uint32_t word) const
static const int s_topoPaddingBits
unsigned int tobIndex(int slice, int cpm, int tob) const
static const int s_coordBits
int hitsError(int slice, int source, int flag) const
Return hit error for given source ID and HL flag.
static const uint32_t s_dataWordIdMask
bool packNeutral()
Pack neutral data.
static const int s_modules
static const int s_roiOverflowBits
static const int s_tobCpmBit
std::vector< int > m_cpmTobCount
CPM TOB count vector for unpacking.
static const uint32_t s_tobCpmMask
static const int s_muxPhases
unsigned int mapIndex(int slice, int cpm) const
unsigned int presenceMap(int slice, int cpm) const
Return presence map for given CPM.
unsigned int ovfIndex(int slice, int source) const
static const int s_presenceBits
static const int s_hitsBits
int dataWordId(uint32_t word) const
bool pack()
Pack data.
static const uint32_t s_tobEnergyMask
std::vector< uint32_t > m_hitsData
Hits and topo data.
static const int s_wordLength
Data word length.
static const int s_threshWordId
void setHits(int slice, int source, int flag, unsigned int hits, int error)
Store hit counts for given source ID and HL flag.
void setRoiOverflow(int slice, int source, int overflow)
Store RoI overflow for given source ID.
int chip(int slice, int cpm, int tob) const
Return chip for given cpm and tob.
static const int s_paddingBits
int localCoord(int slice, int cpm, int tob) const
Return Local coordinate for given cpm and tob.
int isolation(int slice, int cpm, int tob) const
Return isolation for given cpm and tob.
static const uint32_t s_errorMask
int hlFlag(uint32_t word) const
static const int s_topoCountsBits
int tobError(int slice, int cpm, int tob) const
Return error bits for given cpm and tob.
static const int s_dataWordIdBit
static const int s_topoMapBits
std::vector< unsigned int > m_presenceMaps
Presence maps.
static const int s_tobErrorBit
int cpm(uint32_t word) const
void setTob(int slice, int cpm, int chip, int loc, int energy, int isol, int error)
Store TOB (RoI) data for given CPM, chip, local coord.
static const uint32_t s_tobIsolationMask
static const uint32_t s_tobErrorMask
unsigned int hitIndex(int slice, int source, int flag) const
STL class.