ATLAS Offline Software
Loading...
Searching...
No Matches
CmxJetSubBlock.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_CMXJETSUBBLOCK_H
6#define TRIGT1CALOBYTESTREAM_CMXJETSUBBLOCK_H
7
8#include <stdint.h>
9#include <vector>
10
11#include "CmxSubBlock.h"
12
13namespace LVL1BS {
14
22
24
25public:
30 };
31
34
36 void clear();
37
39 unsigned int presenceMap(int slice, int jem) const;
41 int frame(int slice, int jem, int tob) const;
43 int localCoord(int slice, int jem, int tob) const;
45 int energyLarge(int slice, int jem, int tob) const;
47 int energySmall(int slice, int jem, int tob) const;
49 int tobError(int slice, int jem, int tob) const;
51 int parityBits(int slice, int jem) const;
53 unsigned int hits(int slice, int source, int flag) const;
55 int hitsError(int slice, int source, int flag) const;
56
58 void setPresenceMap(int slice, int jem, unsigned int map);
60 void setTob(int slice, int jem, int frame, int loc,
61 int energyLarge, int energySmall, int error);
63 void setParityBits(int slice, int jem, int parity);
65 void setHits(int slice, int source, int flag, unsigned int hits, int error);
66
68 bool pack();
70 bool unpack();
71
72private:
74 static const int s_wordLength = 32;
75 // TOB bit positions and masks
76 static const int s_tobEnergyLgBit = 0;
77 static const int s_tobEnergySmBit = 10;
78 static const int s_tobErrorBit = 19;
79 static const int s_tobCoordBit = 20;
80 static const int s_tobFrameBit = 22;
81 static const int s_tobJemBit = 25;
82 static const int s_tobWordId = 0;
83 static const uint32_t s_tobEnergyLgMask = 0x3ff;
84 static const uint32_t s_tobEnergySmMask = 0x1ff;
85 static const uint32_t s_tobErrorMask = 0x1;
86 static const uint32_t s_tobCoordMask = 0x3;
87 static const uint32_t s_tobFrameMask = 0x7;
88 static const uint32_t s_tobJemMask = 0xf;
89 // Jet hit and topo counts bit positions and masks
90 static const int s_threshBit = 0;
91 static const int s_threshErrorBit = 16;
92 static const int s_threshHlFlagBit = 19;
93 static const int s_topoHlFlagBit = 24;
94 static const int s_hlFlagBit = 19;
95 static const int s_sourceIdBit = 25;
96 static const int s_dataWordIdBit = 29;
97 static const int s_threshWordId = 1;
98 static const uint32_t s_threshMainMask = 0x7fff;
99 static const uint32_t s_threshFwdLMask = 0xffff;
100 static const uint32_t s_threshFwdHMask = 0x3fff;
101 static const uint32_t s_errorMask = 0x7; // Includes RoI overflow
102 static const uint32_t s_topoCheckMask = 0xffff;
103 static const uint32_t s_topoMapMask = 0xffff;
104 static const uint32_t s_topoCountsMask = 0xffffff;
105 static const uint32_t s_hlFlagMask = 0x1;
106 static const uint32_t s_sourceIdMask = 0xf;
107 static const uint32_t s_dataWordIdMask = 0x7;
108 // Neutral format
109 static const int s_presenceBits = 8;
110 static const int s_coordBits = 2;
111 static const int s_energyLgBits = 10;
112 //static const int s_energySmBits[8] = {3,6,5,4,7,2,9,0};
113 static const int s_energySmBits[8];
114 static const int s_threshMainBits = 15;
115 static const int s_threshFwdLBits = 16;
116 static const int s_threshFwdHBits = 14;
117 static const int s_parityErrorBits = 1;
118 static const int s_roiOverflowBits = 1;
119 static const int s_paddingBits = 31;
120 static const int s_bunchCrossingBits = 12;
121 static const int s_fifoOverflowBits = 1;
122 static const int s_topoChecksumBits = 16;
123 static const int s_topoMapBits = 16;
124 static const int s_topoCountsBits = 24;
125 static const int s_topoPaddingBits = 3;
126 static const int s_glinkPins = 20;
127 static const int s_modules = 16;
128 static const int s_tobsPerModule = 4;
129 static const int s_muxPhases = 4;
130
131 int dataWordId(uint32_t word) const;
132 int sourceId(uint32_t word) const;
133 int jem(uint32_t word) const;
134 int hlFlag(uint32_t word) const;
135 unsigned int mapIndex(int slice, int jem) const;
136 unsigned int parIndex(int slice, int jem) const;
137 unsigned int tobIndex(int slice, int jem, int tob) const;
138 unsigned int hitIndex(int slice, int source, int flag) const;
139 void resize();
140
142 bool packNeutral();
144 bool packUncompressed();
146 bool unpackNeutral();
148 bool unpackUncompressed();
149
151 std::vector<uint32_t> m_tobData;
153 std::vector<uint32_t> m_hitsData;
155 std::vector<unsigned int> m_presenceMaps;
157 std::vector<int> m_parityBits;
159 std::vector<int> m_jemTobCount;
160
161};
162
163inline int CmxJetSubBlock::dataWordId(const uint32_t word) const
164{
165 return (word >> s_dataWordIdBit) & s_dataWordIdMask;
166}
167
168inline int CmxJetSubBlock::sourceId(const uint32_t word) const
169{
170 return (word >> s_sourceIdBit) & s_sourceIdMask;
171}
172
173inline int CmxJetSubBlock::jem(const uint32_t word) const
174{
175 return (word >> s_tobJemBit) & s_tobJemMask;
176}
177
178inline int CmxJetSubBlock::hlFlag(const uint32_t word) const
179{
180 uint8_t shift = (((word >> s_sourceIdBit) & s_sourceIdMask) < 7 ? s_threshHlFlagBit : s_topoHlFlagBit);
181 return (word >> shift) & s_hlFlagMask;
182}
183// ============================================================================
184} // end namespace
185// ============================================================================
186#endif
unsigned int parIndex(int slice, int jem) const
static const int s_threshBit
static const uint32_t s_dataWordIdMask
static const uint32_t s_topoCheckMask
static const int s_muxPhases
static const int s_sourceIdBit
int energyLarge(int slice, int jem, int tob) const
Return energy large window size for given jem and tob.
std::vector< unsigned int > m_presenceMaps
Presence maps.
static const int s_threshWordId
static const int s_threshHlFlagBit
bool unpackNeutral()
Unpack neutral data.
static const int s_topoCountsBits
std::vector< uint32_t > m_tobData
TOB data.
static const int s_coordBits
int localCoord(int slice, int jem, int tob) const
Return Local coordinate for given jem and tob.
void setParityBits(int slice, int jem, int parity)
Store parity bits for neutral format.
static const uint32_t s_tobEnergyLgMask
static const int s_topoPaddingBits
static const int s_tobEnergySmBit
bool unpack()
Unpack data.
int frame(int slice, int jem, int tob) const
Return frame for given jem and tob.
bool unpackUncompressed()
Unpack uncompressed data.
static const int s_tobWordId
int jem(uint32_t word) const
static const int s_parityErrorBits
int energySmall(int slice, int jem, int tob) const
Return energy small window size for given jem and tob.
int sourceId(uint32_t word) const
static const int s_energySmBits[8]
bool packUncompressed()
Pack uncompressed 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_tobEnergyLgBit
static const int s_topoMapBits
static const uint32_t s_threshMainMask
unsigned int presenceMap(int slice, int jem) const
Return presence map for given JEM.
static const int s_bunchCrossingBits
static const uint32_t s_tobEnergySmMask
static const int s_threshMainBits
unsigned int mapIndex(int slice, int jem) const
static const int s_topoHlFlagBit
int parityBits(int slice, int jem) const
Return parity bits for given JEM.
unsigned int hitIndex(int slice, int source, int flag) const
static const int s_hlFlagBit
static const uint32_t s_threshFwdLMask
static const uint32_t s_sourceIdMask
static const int s_fifoOverflowBits
std::vector< int > m_parityBits
Parity data for neutral format.
static const int s_threshFwdLBits
static const int s_threshFwdHBits
unsigned int tobIndex(int slice, int jem, int tob) const
static const int s_presenceBits
static const uint32_t s_tobJemMask
static const uint32_t s_tobCoordMask
static const int s_dataWordIdBit
void setHits(int slice, int source, int flag, unsigned int hits, int error)
Store hit counts for given source ID and HL flag.
static const int s_energyLgBits
static const int s_tobCoordBit
static const int s_tobFrameBit
static const uint32_t s_topoMapMask
static const uint32_t s_tobFrameMask
static const int s_paddingBits
std::vector< uint32_t > m_hitsData
Hits and topo data.
static const uint32_t s_threshFwdHMask
static const uint32_t s_errorMask
int dataWordId(uint32_t word) const
static const int s_tobErrorBit
static const int s_tobJemBit
static const int s_roiOverflowBits
void setPresenceMap(int slice, int jem, unsigned int map)
Store presence map.
static const int s_modules
void setTob(int slice, int jem, int frame, int loc, int energyLarge, int energySmall, int error)
Store TOB (RoI) data for given JEM, frame, local coord.
static const int s_wordLength
Data word length.
std::vector< int > m_jemTobCount
JEM TOB count vector for unpacking.
void clear()
Clear all data.
static const uint32_t s_topoCountsMask
int hitsError(int slice, int source, int flag) const
Return hit error for given source ID and HL flag.
static const int s_topoChecksumBits
static const uint32_t s_hlFlagMask
static const int s_glinkPins
static const uint32_t s_tobErrorMask
bool packNeutral()
Pack neutral data.
static const int s_threshErrorBit
int tobError(int slice, int jem, int tob) const
Return error bit for given jem and tob.
int hlFlag(uint32_t word) const
static const int s_tobsPerModule
STL class.