Main Convert method.
121 {
122
123
124 std::unordered_map<uint32_t, std::vector<std::bitset<256>>> allStripData;
125 std::unordered_map<uint32_t, IdentifierHash> keyToHash;
126
127 IdentifierHash offlineHash = 0;
128
129 for (const auto& rdo : vecRDOs) {
136
137 if (strip_max == 0xFFFF){
138
139 const Identifier rdoID{rdo->identify()};
141 continue;
142 }
143
145 if((barrelEC == 0 && eta_mod > 0) || barrelEC > 0)
sideAC = 1;
146
148
149 if (barrelEC == 0) {
150 if(disk < 2){
151 eta_group =
static_cast<uint8_t>(std::floor((std::abs(eta_mod)-1) / 4));
152 }else{
153 eta_group =
static_cast<uint8_t>(std::floor((std::abs(eta_mod)-1) / 2));
154 }
155 }else {
156 if(eta_mod>=0 && eta_mod<=9) eta_group =
static_cast<uint8_t>(std::floor(eta_mod / 4));
157 else if(eta_mod>=10 && eta_mod<=13) eta_group =
static_cast<uint8_t>(std::floor((eta_mod+2)/4));
158 else if(eta_mod>13) eta_group =
static_cast<uint8_t>(std::floor((eta_mod-6)/2));
159 }
160
161 uint8_t chips_per_module = (strip_max + 1) / 128;
162 uint32_t key = hccKey(barrelEC, side, disk, phi_mod, eta_mod, eta_group);
163
165 keyToHash.insert({
key,offlineHash});
166 ATH_MSG_DEBUG(
"barrel: "<< barrelEC<<
" sideAC: " << (uint32_t)sideAC <<
" disk: "<<(uint32_t)disk <<
" side: " << (uint32_t)side <<
" phi_mod: "<<(uint32_t)phi_mod <<
" eta_mod: " << eta_mod <<
" eta group: "<<(uint32_t)eta_group <<
" chips per module: " << (uint32_t)chips_per_module <<
" " << (uint32_t)robID <<
" " << (uint32_t)
m_itkStripsID->wafer_hash(
offlineID(rdo)));
168 auto& StripData = allStripData[
key];
169
170 if (StripData.empty()) {
171 StripData.resize(chips_per_module);
172 }
173
174
176 int chip =
static_cast<int>(std::floor(
strip / 128));
177 int strip_position =
strip % 128;
178 int strip_logical_channel = 2*strip_position + (
isNear(eta_mod, barrelEC == 0)? 0 : 1);
179
180 ATH_MSG_DEBUG(
"strip N: "<<
strip <<
" chip n: " << chip <<
" Strip position: " << strip_position <<
" Strip position logical: " << strip_logical_channel);
181 StripData[chip].set(strip_logical_channel);
182 }
183
184 std::vector<uint8_t> vec8Data;
187
188 ATH_MSG_DEBUG(
"All strip data size: " << allStripData.size());
189
190
191 for (const auto& [key, StripData] : allStripData) {
192
195 int ptype = 1;
196 bool keyRecorded = false;
198
199 ATH_MSG_DEBUG(
"key is: " << std::bitset<32>(key) <<
" StripData size: " << StripData.size());
200
201 for (
size_t i = 0;
i < StripData.size(); ++
i) {
202
203 std::bitset<256>
hits = StripData[
i];
204
205 if(hits==0){
206 ++ichannel;
207 continue;
208 }
209
210
212
214 ++ichannel;
215 continue;
216 }
219 keyRecorded = true;
221 }
222 vec8Data.push_back(0xed);
223 vec8Data.push_back(0x6f);
225
227 vec8Data.push_back(0);
228 vec8Data.push_back(0);
229 }
230 uint32_t packetLenght = (vec8Data.size()-vectorSize)+4;
231 ATH_MSG_DEBUG(
"Packet Lenght: " << (uint32_t)packetLenght <<
" " << std::bitset<32>(packetLenght));
232
233 std::vector<uint8_t> pktlenght = split32bitWord(packetLenght);
234
235 ATH_MSG_DEBUG(
"PktLenght: " << pktlenght.size() <<
" vec8Data size: " << vec8Data.size());
236
238 vec8Data.insert(vec8Data.begin()+offset, pktlenght.begin(), pktlenght.end());
239 vectorSize = vec8Data.size();
240
245 }
246 vec32Data.clear();
247 }
248
249
252
254
256
257 for(auto &word: vec32Data){
259 }
260 return;
261}
#define ATH_MSG_WARNING(x,...)
const SCT_ID * m_itkStripsID
Identifier helper class for the ITkStrips subdetector that creates compact Identifier objects and Ide...
uint16_t getStripMax(const SCT_RDORawData *rdo) const
Get the maxumum strip value info from the RDO.
Identifier offlineID(const SCT_RDORawData *rdo) const
Get the offline Identifier from the RDO.
int getBarrelEC(const SCT_RDORawData *rdo) const
Get the barrel/endcape info from the RDO.
std::atomic< uint8_t > m_l0tag
int getEtaModule(const SCT_RDORawData *rdo) const
Get the eta value info from the RDO.
int getSide(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.
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.
uint8_t getPhiModule(const SCT_RDORawData *rdo) const
Get the phi value info from the RDO.
uint8_t getDiskLayer(const SCT_RDORawData *rdo) const
Get disk/layer info from the RDO.
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, uint32_t hccKey, uint16_t &size) const
ToolHandle< ITkStripDataRateMonTool > m_dataRateMonTool
bool isNear(const int &eta_mod, bool isBarrel=false) const
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.
std::atomic< uint8_t > m_bcid
Method to encode RDO data to vector of 16 bin words.