Project
Loading...
Searching...
No Matches
RawReader.cxx
Go to the documentation of this file.
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
14
15#include <boost/tokenizer.hpp>
16#include <boost/lexical_cast.hpp>
17#include <list>
18
23#include "TPCBase/Mapper.h"
25
26#include <fairlogger/Logger.h>
27
28using namespace o2::tpc;
29
30RawReader::RawReader(int region, int link, int run, int sampaVersion)
31 : mUseRawInMode3(true),
32 mApplyChannelMask(false),
33 mCheckAdcClock(false),
34 mRegion(region),
35 mLink(link),
36 mRun(run),
37 mSampaVersion(sampaVersion),
38 mLastEvent(-1),
39 mTimestampOfFirstData({0, 0, 0, 0, 0}),
40 mEvents(),
41 mData(),
42 mDataIterator(mData.end()),
43 mSyncPos(),
44 mChannelMask(nullptr),
45 mAdcError(std::make_shared<std::vector<std::tuple<short, short, short>>>()),
46 mEventSynchronizer(std::make_shared<RawReaderEventSync>())
47{
48 mSyncPos.fill(-1);
49}
50
51bool RawReader::addInputFile(const std::vector<std::string>* infiles)
52{
53 bool ret = false;
54 for (const auto& f : *infiles) {
55 ret |= addInputFile(f);
56 }
57
58 return ret;
59}
60
61bool RawReader::addInputFile(std::string infile)
62{
63 typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
64 boost::char_separator<char> sep{":"};
65 tokenizer tok{infile, sep};
66 if (std::distance(tok.begin(), tok.end()) < 3) {
67 LOG(error) << "Not enough arguments";
68 return false;
69 }
70
71 tokenizer::iterator it1 = tok.begin();
72 std::string path = boost::lexical_cast<std::string>(*it1);
73 int run = std::stoi(path.substr(path.find("run") + 3, 6));
74
75 int region, link;
76 try {
77 ++it1;
78 region = boost::lexical_cast<int>(*it1);
79 } catch (boost::bad_lexical_cast) {
80 LOG(error) << "Please enter a region for " << path;
81 return false;
82 }
83
84 try {
85 ++it1;
86 link = boost::lexical_cast<int>(*it1);
87 } catch (boost::bad_lexical_cast) {
88 LOG(error) << "Please enter a link number for " << path;
89 return false;
90 }
91
92 int sampaVersion = -1;
93 if (++it1 == tok.end()) {
94 LOG(debug) << "No SAMPA version was entered, assuming latest.";
95 } else {
96 try {
97 sampaVersion = boost::lexical_cast<int>(*it1);
98 } catch (boost::bad_lexical_cast) {
99 LOG(error) << "Please enter a valid SAMPA version for " << path;
100 return false;
101 }
102 }
103
104 return addInputFile(region, link, sampaVersion, path, run);
105}
106
107bool RawReader::addInputFile(int region, int link, int sampaVersion, std::string path, int run)
108{
109 if (mRun == -1) {
110 mRun = run;
111 }
112 if (mRegion == -1) {
113 mRegion = region;
114 }
115 if (mLink == -1) {
116 mLink = link;
117 }
118 if (mSampaVersion == -1) {
119 mSampaVersion = sampaVersion;
120 }
121
122 if (run != mRun) {
123 LOG(debug) << "Run of RawReader is " << mRun << " and not " << run;
124 return false;
125 }
126
127 if (region != mRegion) {
128 LOG(debug) << "Region of RawReader is " << mRegion << " and not " << region;
129 return false;
130 }
131
132 if (link != mLink) {
133 LOG(debug) << "Link of RawReader is " << mLink << " and not " << link;
134 return false;
135 }
136
137 if (sampaVersion != mSampaVersion) {
138 LOG(debug) << "SAMPA Version of RawReader is " << mSampaVersion << " and not " << sampaVersion;
139 return false;
140 }
141
142 std::ifstream file(path);
143 if (!file.is_open()) {
144 LOG(error) << "Can't read file " << path;
145 return false;
146 }
147
148 Header h;
149 int pos = 0;
150 file.seekg(0, file.end);
151 int length = file.tellg();
152 file.seekg(0, file.beg);
153
154 while (pos < length) {
155 file.read((char*)&h, sizeof(h));
156 if (h.reserved_01 != 0x0F || h.reserved_2() != 0x3fec2fec1fec0fec) {
157 LOG(error) << "Header does not look consistent";
158 }
159 EventInfo eD;
160 eD.path = path;
161 eD.posInFile = file.tellg();
162 eD.header = h;
163 if (h.headerVersion == 1) {
164 // auto ins = mEvents.insert(std::make_pair(h.eventCount(),std::shared_ptr<std::vector<EventInfo>>(new std::vector<EventInfo>)));
165 auto ins = mEvents.insert(std::make_pair(h.eventCount(), std::make_shared<std::vector<EventInfo>>()));
166 ins.first->second->push_back(eD);
167
168 if (h.eventCount() == 0) {
169 LOG(debug) << "Processing event 0 to find sync pattern for event synchronization";
170 loadEvent(0); // processing first event to find the SYNC pattern (mode 1) or start of data (mode 2)
171 mLastEvent = -1;
172 }
173
174 mEventSynchronizer->addEventOffset(
175 h.eventCount(),
176 (h.timeStamp() - mTimestampOfFirstData[0]));
177
178 file.seekg(pos + (h.nWords * 4));
179 pos = file.tellg();
180 } else {
181 LOG(error) << "Header version " << (int)h.headerVersion << " not implemented.";
182 return false;
183 }
184 }
185
186 return true;
187}
188
190{
191 const Mapper& mapper = Mapper::instance();
192 const PartitionInfo& partInfo = mapper.getPartitionInfo(mRegion / 2);
193 LOG(debug) << "Loading event " << event << " for Link " << (mRegion * partInfo.getNumberOfFECs()) + mLink;
194
195 if (mLastEvent == -1 && event != getFirstEvent()) {
196 LOG(debug) << "First event was not loaded (maybe important for decoding RAW GBT frames) loading first event.";
197 mSyncPos.fill(-1);
198 mTimestampOfFirstData.fill(0);
200 LOG(debug) << "Continue with event " << event;
201 }
202 mData.clear();
203
204 auto ev = mEvents.find(event);
205
206 if (ev == mEvents.end()) {
207 return false;
208 }
209 mLastEvent = event;
210
211 for (auto& eventInfo : *(ev->second)) {
212 switch (eventInfo.header.dataType) {
213 case 1: // RAW GBT frames
214 {
215 LOG(debug) << "Data of readout mode 1 (RAW GBT frames)";
216 if (!decodeRawGBTFrames(eventInfo)) {
217 return false;
218 }
219 break;
220 }
221 case 2: // Decoded data
222 {
223 LOG(debug) << "Data of readout mode 2 (decoded data)";
224 if (!decodePreprocessedData(eventInfo)) {
225 return false;
226 }
227 break;
228 }
229 case 3: // both, RAW GBT frames and decoded data
230 {
231 if (mUseRawInMode3) {
232 LOG(debug) << "Data of readout mode 3 (decoding RAW GBT frames)";
233 if (!decodeRawGBTFrames(eventInfo)) {
234 return false;
235 }
236 } else {
237 LOG(debug) << "Data of readout mode 3 (using decoded data)";
238 if (!decodePreprocessedData(eventInfo)) {
239 return false;
240 }
241 }
242 break;
243 }
244 default: {
245 LOG(debug) << "Readout mode not known";
246 break;
247 }
248 }
249 }
250
251 mDataIterator = mData.begin();
252 LOG(debug);
253 LOG(debug);
254 return true;
255}
256
257bool RawReader::decodePreprocessedData(EventInfo eventInfo)
258{
259 std::ifstream file(eventInfo.path);
260 if (!file.is_open()) {
261 LOG(error) << "Can't read file " << eventInfo.path;
262 return false;
263 }
264
265 int nWords = eventInfo.header.nWords - 8;
266 uint32_t words[nWords];
267 LOG(debug) << "reading " << nWords << " words from position " << eventInfo.posInFile << " in file " << eventInfo.path;
268 file.seekg(eventInfo.posInFile);
269 file.read((char*)&words, nWords * sizeof(words[0]));
270
271 const Mapper& mapper = Mapper::instance();
272
273 std::array<char, 5> sampas;
274 std::array<char, 5> sampaChannelStart;
275 for (char i = 0; i < 5; ++i) {
276 sampas[i] = (i == 4) ? 2 : (mRegion % 2) ? i / 2 + 3 : i / 2;
277 sampaChannelStart[i] = (i == 4) ? // 5th half SAMPA corresponds to SAMPA2
278 ((mRegion % 2) ? 16 : 0)
279 : // every even CRU receives channel 0-15 from SAMPA 2, the odd ones channel 16-31
280 ((i % 2) ? 16 : 0); // every even half SAMPA containes channel 0-15, the odd ones channel 16-31
281 }
282
283 std::array<uint32_t, 5> ids;
284 std::array<bool, 5> writeValue;
285 writeValue.fill(false);
286 std::array<std::array<uint16_t, 16>, 5> adcValues;
287
288 int indexStep = (eventInfo.header.dataType == 3) ? 8 : 4;
289 int offset = (eventInfo.header.dataType == 3) ? 4 : 0;
290
291 long i_start = 0;
292 if (eventInfo.header.eventCount() > 0) {
293 LOG(debug) << "Using offset [" << mTimestampOfFirstData[0] + mEventSynchronizer->getEventOffset(eventInfo.header.eventCount()) << "] "
294 << "instead of [" << eventInfo.header.timeStamp() << "] "
295 << " (diff = " << mTimestampOfFirstData[0] + mEventSynchronizer->getEventOffset(eventInfo.header.eventCount()) - eventInfo.header.timeStamp() << ") ";
296
297 i_start = mTimestampOfFirstData[0] + mEventSynchronizer->getEventOffset(eventInfo.header.eventCount()) - eventInfo.header.timeStamp() - 1;
298 i_start *= indexStep;
299 }
300
301 LOG(debug) << "Start index for Event " << eventInfo.header.eventCount() << " is " << i_start;
302
303 for (long i = i_start; i < nWords; i = i + indexStep) {
304 ids[4] = (words[i + offset] >> 4) & 0xF;
305 ids[3] = (words[i + offset] >> 8) & 0xF;
306 ids[2] = (words[i + offset] >> 12) & 0xF;
307 ids[1] = (words[i + offset] >> 16) & 0xF;
308 ids[0] = (words[i + offset] >> 20) & 0xF;
309
310 adcValues[4][((ids[4] & 0x7) * 2) + 1] = (((ids[4] >> 3) & 0x1) == 0) ? 0 : words[i + offset + 3] & 0x3FF;
311 adcValues[4][((ids[4] & 0x7) * 2)] = (((ids[4] >> 3) & 0x1) == 0) ? 0 : (words[i + offset + 3] >> 10) & 0x3FF;
312 adcValues[3][((ids[3] & 0x7) * 2) + 1] = (((ids[3] >> 3) & 0x1) == 0) ? 0 : (words[i + offset + 3] >> 20) & 0x3FF;
313 adcValues[3][((ids[3] & 0x7) * 2)] = (((ids[3] >> 3) & 0x1) == 0) ? 0 : ((words[i + offset + 2] & 0xFF) << 2) | ((words[i + offset + 3] >> 30) & 0x3);
314 adcValues[2][((ids[2] & 0x7) * 2) + 1] = (((ids[2] >> 3) & 0x1) == 0) ? 0 : (words[i + offset + 2] >> 8) & 0x3FF;
315 adcValues[2][((ids[2] & 0x7) * 2)] = (((ids[2] >> 3) & 0x1) == 0) ? 0 : (words[i + offset + 2] >> 18) & 0x3FF;
316 adcValues[1][((ids[1] & 0x7) * 2) + 1] = (((ids[1] >> 3) & 0x1) == 0) ? 0 : ((words[i + offset + 1] & 0x3F) << 4) | ((words[i + offset + 2] >> 28) & 0xF);
317 adcValues[1][((ids[1] & 0x7) * 2)] = (((ids[1] >> 3) & 0x1) == 0) ? 0 : (words[i + offset + 1] >> 6) & 0x3FF;
318 adcValues[0][((ids[0] & 0x7) * 2) + 1] = (((ids[0] >> 3) & 0x1) == 0) ? 0 : (words[i + offset + 1] >> 16) & 0x3FF;
319 adcValues[0][((ids[0] & 0x7) * 2)] = (((ids[0] >> 3) & 0x1) == 0) ? 0 : ((words[i + offset + 0] & 0xF) << 6) | ((words[i + offset + 1] >> 26) & 0x3F);
320
321 for (char j = 0; j < 5; ++j) {
322 if (ids[j] == 0x8) {
323 writeValue[j] = true;
324 // header TS is one before first word -> +1
325 if (mTimestampOfFirstData[j] == 0) {
326 mTimestampOfFirstData[j] = eventInfo.header.timeStamp() + 1 + i / indexStep;
327 }
328 }
329 }
330
331 for (char j = 0; j < 5; ++j) {
332 if (writeValue[j] & (ids[j] == 0xF)) {
333 for (int k = 0; k < 16; ++k) {
334 const PadPos padPos = mapper.padPosRegion(
335 mRegion, mLink, sampas[j], k + sampaChannelStart[j]);
336
337 if (mApplyChannelMask && // channel mask should be applied
338 (mChannelMask != nullptr) && // channel mask is available
339 !mChannelMask->getValue(CRU(mRegion), padPos.getPad(), padPos.getRow())) { // channel mask
340 continue;
341 }
342
343 // auto ins = mData.insert(std::make_pair(padPos, std::shared_ptr<std::vector<uint16_t>>(new std::vector<uint16_t>)));
344 auto ins = mData.insert(std::make_pair(padPos, std::make_shared<std::vector<uint16_t>>()));
345 ins.first->second->push_back(adcValues[j][k]);
346 }
347 }
348 }
349 }
350 return true;
351}
352
353bool RawReader::decodeRawGBTFrames(EventInfo eventInfo)
354{
355 std::ifstream file(eventInfo.path);
356 if (!file.is_open()) {
357 LOG(error) << "Can't read file " << eventInfo.path;
358 return false;
359 }
360
361 int nWords = eventInfo.header.nWords - 8;
362 uint32_t words[nWords];
363 LOG(debug) << "reading " << nWords << " words from position " << eventInfo.posInFile << " in file " << eventInfo.path;
364 LOG(debug) << "Header time stamp is " << eventInfo.header.timeStamp();
365 file.seekg(eventInfo.posInFile);
366 file.read((char*)&words, nWords * sizeof(words[0]));
367
368 const Mapper& mapper = Mapper::instance();
369
370 std::array<char, 5> sampas;
371 std::array<char, 5> sampaChannelStart;
372 for (char i = 0; i < 5; ++i) {
373 sampas[i] = (i == 4) ? 2 : (mRegion % 2) ? i / 2 + 3 : i / 2;
374 sampaChannelStart[i] = (i == 4) ? // 5th half SAMPA corresponds to SAMPA2
375 ((mRegion % 2) ? 16 : 0)
376 : // every even CRU receives channel 0-15 from SAMPA 2, the odd ones channel 16-31
377 ((i % 2) ? 16 : 0); // every even half SAMPA containes channel 0-15, the odd ones channel 16-31
378 }
379
380 std::array<SyncPatternMonitor, 5> syncMon{
381 SyncPatternMonitor((mRegion % 2) ? 3 : 0, 0),
382 SyncPatternMonitor((mRegion % 2) ? 3 : 0, 1),
383 SyncPatternMonitor((mRegion % 2) ? 4 : 1, 0),
384 SyncPatternMonitor((mRegion % 2) ? 4 : 1, 1),
385 SyncPatternMonitor(2, (mRegion % 2) ? 1 : 0)};
386 std::array<AdcClockMonitor, 3> adcClockMon{
387 AdcClockMonitor((mRegion % 2) ? 3 : 0),
388 AdcClockMonitor((mRegion % 2) ? 4 : 1),
389 AdcClockMonitor(2)};
390 std::array<bool, 3> adcClockFound{false, false, false};
391
392 std::array<short, 5> lastSyncPos;
393 std::array<std::list<uint16_t>, 5> adcValues;
394 mAdcError->clear();
395 uint64_t timebin = 0;
396
397 int indexStep = (eventInfo.header.dataType == 3) ? 8 : 4;
398
399 long i_start = 0;
400 if (eventInfo.header.eventCount() > 0) {
401 LOG(debug) << "Using offset [" << mTimestampOfFirstData[0] + mEventSynchronizer->getEventOffset(eventInfo.header.eventCount()) << "] "
402 << "instead of [" << eventInfo.header.timeStamp() << "] "
403 << " (diff = " << mTimestampOfFirstData[0] + mEventSynchronizer->getEventOffset(eventInfo.header.eventCount()) - eventInfo.header.timeStamp() << ") ";
404
405 i_start = mTimestampOfFirstData[0] + mEventSynchronizer->getEventOffset(eventInfo.header.eventCount()) - eventInfo.header.timeStamp() - 1;
406 i_start *= indexStep;
407 }
408
409 LOG(debug) << "Start index for Event " << eventInfo.header.eventCount() << " is " << i_start;
410
411 GBTFrame frame;
412 if (eventInfo.header.eventCount() > 0) {
413 frame.setData(words[i_start - indexStep], words[i_start - indexStep + 1], words[i_start - indexStep + 2], words[i_start - indexStep + 3]);
414 }
415 GBTFrame lastFrame;
416
417 for (long i = i_start; i < nWords; i = i + indexStep) {
418
419 lastSyncPos = mSyncPos;
420 lastFrame = frame;
421 frame.setData(words[i], words[i + 1], words[i + 2], words[i + 3]);
422
423 if (syncMon[0].addSequence(frame.getHalfWord(0, 0, 0), frame.getHalfWord(0, 1, 0), frame.getHalfWord(0, 2, 0), frame.getHalfWord(0, 3, 0))) {
424 mSyncPos[0] = syncMon[0].getPosition();
425 }
426 if (syncMon[1].addSequence(frame.getHalfWord(0, 0, 1), frame.getHalfWord(0, 1, 1), frame.getHalfWord(0, 2, 1), frame.getHalfWord(0, 3, 1))) {
427 mSyncPos[1] = syncMon[1].getPosition();
428 }
429 if (syncMon[2].addSequence(frame.getHalfWord(1, 0, 0), frame.getHalfWord(1, 1, 0), frame.getHalfWord(1, 2, 0), frame.getHalfWord(1, 3, 0))) {
430 mSyncPos[2] = syncMon[2].getPosition();
431 }
432 if (syncMon[3].addSequence(frame.getHalfWord(1, 0, 1), frame.getHalfWord(1, 1, 1), frame.getHalfWord(1, 2, 1), frame.getHalfWord(1, 3, 1))) {
433 mSyncPos[3] = syncMon[3].getPosition();
434 }
435 if (syncMon[4].addSequence(frame.getHalfWord(2, 0), frame.getHalfWord(2, 1), frame.getHalfWord(2, 2), frame.getHalfWord(2, 3))) {
436 mSyncPos[4] = syncMon[4].getPosition();
437 }
438
439 if (mCheckAdcClock) {
440
441 bool adcCheckErr0 = adcClockMon[0].addSequence(frame.getAdcClock(0));
442 bool adcCheckErr1 = adcClockMon[1].addSequence(frame.getAdcClock(1));
443 bool adcCheckErr2 = adcClockMon[2].addSequence(frame.getAdcClock(2));
444
445 if (mSyncPos[0] >= 0) {
446 adcClockFound[0] = adcClockFound[0] | (!adcCheckErr0);
447 }
448 if (mSyncPos[2] >= 0) {
449 adcClockFound[1] = adcClockFound[1] | (!adcCheckErr1);
450 }
451 if (mSyncPos[4] >= 0) {
452 adcClockFound[2] = adcClockFound[2] | (!adcCheckErr2);
453 }
454 if (adcClockFound[0] & adcCheckErr0) {
455 adcClockFound[0] = false;
456 LOG(debug) << "ADC clock error of SAMPA " << ((mRegion % 2) ? 3 : 0) << " in frame [" << i / indexStep << "]";
457 mAdcError->emplace_back(std::make_tuple((mRegion % 2) ? 3 : 0, i, mSyncPos[0]));
458 };
459 if (adcClockFound[1] & adcCheckErr1) {
460 adcClockFound[1] = false;
461 LOG(debug) << "ADC clock error of SAMPA " << ((mRegion % 2) ? 4 : 1) << " in frame [" << i / indexStep << "]";
462 mAdcError->emplace_back(std::make_tuple((mRegion % 2) ? 4 : 1, i, mSyncPos[2]));
463 };
464 if (adcClockFound[2] & adcCheckErr2) {
465 adcClockFound[2] = false;
466 LOG(debug) << "ADC clock error of SAMPA " << 2 << " in frame [" << i / indexStep << "]";
467 mAdcError->emplace_back(std::make_tuple(2, i, mSyncPos[4]));
468 };
469 }
470
471 short value1;
472 short value2;
473 for (short iHalfSampa = 0; iHalfSampa < 5; ++iHalfSampa) {
474 if (mSyncPos[iHalfSampa] < 0) {
475 LOG(debug1) << "Sync pattern for half SAMPA " << iHalfSampa << " not yet found";
476 continue;
477 }
478 if (lastSyncPos[iHalfSampa] < 0) {
479 LOG(debug1) << "Sync pattern for half SAMPA " << iHalfSampa << " not yet found";
480 LOG(debug1) << lastFrame;
481 continue;
482 }
483 if (mTimestampOfFirstData[iHalfSampa] == 0) {
484 if (iHalfSampa == 0) {
485 LOG(debug) << "Setting timestamp of first data to " << eventInfo.header.timeStamp() + 1 + i / indexStep << " for half SAMPA " << iHalfSampa << " (" << 1 + i / indexStep << ")";
486 }
487 mTimestampOfFirstData[iHalfSampa] = eventInfo.header.timeStamp() + 1 + i / indexStep;
488 }
489
490 switch (mSyncPos[iHalfSampa]) {
491 case 0:
492 value1 = (frame.getHalfWord(iHalfSampa / 2, 1, iHalfSampa % 2) << 5) | frame.getHalfWord(iHalfSampa / 2, 0, iHalfSampa % 2);
493 value2 = (frame.getHalfWord(iHalfSampa / 2, 3, iHalfSampa % 2) << 5) | frame.getHalfWord(iHalfSampa / 2, 2, iHalfSampa % 2);
494 break;
495
496 case 1:
497 value1 = (lastFrame.getHalfWord(iHalfSampa / 2, 2, iHalfSampa % 2) << 5) | lastFrame.getHalfWord(iHalfSampa / 2, 1, iHalfSampa % 2);
498 value2 = (frame.getHalfWord(iHalfSampa / 2, 0, iHalfSampa % 2) << 5) | lastFrame.getHalfWord(iHalfSampa / 2, 3, iHalfSampa % 2);
499 break;
500
501 case 2:
502 value1 = (lastFrame.getHalfWord(iHalfSampa / 2, 3, iHalfSampa % 2) << 5) | lastFrame.getHalfWord(iHalfSampa / 2, 2, iHalfSampa % 2);
503 value2 = (frame.getHalfWord(iHalfSampa / 2, 1, iHalfSampa % 2) << 5) | frame.getHalfWord(iHalfSampa / 2, 0, iHalfSampa % 2);
504 break;
505
506 case 3:
507 value1 = (frame.getHalfWord(iHalfSampa / 2, 0, iHalfSampa % 2) << 5) | lastFrame.getHalfWord(iHalfSampa / 2, 3, iHalfSampa % 2);
508 value2 = (frame.getHalfWord(iHalfSampa / 2, 2, iHalfSampa % 2) << 5) | frame.getHalfWord(iHalfSampa / 2, 1, iHalfSampa % 2);
509 break;
510
511 default:
512 return false;
513 }
514
515 if (mSampaVersion == 1 || mSampaVersion == 2) {
516 adcValues[iHalfSampa].emplace_back(value1 ^ (1 << 9)); // Invert bit 9 vor SAMPA v1 and v2
517 adcValues[iHalfSampa].emplace_back(value2 ^ (1 << 9)); // Invert bit 9 vor SAMPA v1 and v2
518 } else {
519 adcValues[iHalfSampa].emplace_back(value1);
520 adcValues[iHalfSampa].emplace_back(value2);
521 }
522 }
523
524 for (char j = 0; j < 5; ++j) {
525 if (adcValues[j].size() == 16) {
526 for (int k = 0; k < 16; ++k) {
527 const PadPos padPos = mapper.padPosRegion(
528 mRegion, mLink, sampas[j], k + sampaChannelStart[j]);
529
530 if (mApplyChannelMask && // channel mask should be applied
531 (mChannelMask != nullptr) && // channel mask is available
532 !mChannelMask->getValue(CRU(mRegion), padPos.getPad(), padPos.getRow())) { // channel mask
533 adcValues[j].pop_front(); // discard value
534 continue;
535 }
536
537 // auto ins = mData.insert(std::make_pair(padPos, std::shared_ptr<std::vector<uint16_t>>(new std::vector<uint16_t>)));
538 auto ins = mData.insert(std::make_pair(padPos, std::make_shared<std::vector<uint16_t>>()));
539 ins.first->second->push_back(adcValues[j].front());
540 adcValues[j].pop_front();
541 }
542 }
543 }
544 }
545 return true;
546}
Class to monitor the ADC smapling clock contained in the GBT frame.
std::ostringstream debug
GBT Frame object.
int32_t i
uint16_t pos
Definition RawData.h:3
uint32_t j
Definition RawData.h:0
Class to monitor the data stream and detect synchronization patterns.
Class for time synchronization of RawReader instances.
Class to monitor the ADC smapling clock contained in the GBT frame.
GBTFrame class for the TPC.
Definition GBTFrame.h:64
short getAdcClock(short sampa) const
Definition GBTFrame.h:129
void setData(unsigned word3, unsigned word2, unsigned word1, unsigned word0)
Definition GBTFrame.h:254
short getHalfWord(const short sampa, const short halfword, const short chan=0) const
Definition GBTFrame.h:124
const PartitionInfo & getPartitionInfo(const unsigned char partition) const
Definition Mapper.h:389
const PadPos padPosRegion(const int cruNumber, const int fecInPartition, const int sampaOnFEC, const int channelOnSAMPA) const
Definition Mapper.h:236
static Mapper & instance(const std::string mappingDir="")
Definition Mapper.h:44
unsigned char getNumberOfFECs() const
int64_t getFirstEvent() const
Definition RawReader.h:143
bool addInputFile(std::string infile)
Definition RawReader.cxx:61
bool loadEvent(int64_t event)
Class to monitor the data stream and detect synchronization patterns.
struct _cl_event * event
Definition glcorearb.h:2982
GLsizeiptr size
Definition glcorearb.h:659
GLuint * ids
Definition glcorearb.h:647
GLdouble f
Definition glcorearb.h:310
GLintptr offset
Definition glcorearb.h:660
GLuint GLsizei GLsizei * length
Definition glcorearb.h:790
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
Global TPC definitions and constants.
Definition SimTraits.h:168
int posInFile
Position in data file.
Definition RawReader.h:74
Header header
Header of this evend.
Definition RawReader.h:75
std::string path
Path to data file.
Definition RawReader.h:73
Data header struct.
Definition RawReader.h:41
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"