ATLAS Offline Software
Loading...
Searching...
No Matches
ZdcByteStreamTool Class Reference

Tool to perform ROB fragments to ZdcDigits and from ZdcDigits to raw data conversions. More...

#include <ZdcByteStreamTool.h>

Inheritance diagram for ZdcByteStreamTool:
Collaboration diagram for ZdcByteStreamTool:

Public Member Functions

 ZdcByteStreamTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize () override
virtual StatusCode finalize () override
StatusCode convert (const IROBDataProviderSvc::VROBFRAG &robFrags, ZdcDigitsCollection *ttCollection)
 Convert ROB fragments to ZdcCollection.
const std::vector< uint32_t > & sourceIDs ()
 Return reference to vector with all possible Source Identifiers.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()
 AlgTool InterfaceID.
static StatusCode convert (const ZdcDigitsCollection *ttCollection, RawEventWrite *re)
 Convert ZdcCollection to ROB fragments.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef std::map< unsigned int, ZdcDigits * > ZdcDigitsMap
typedef std::map< unsigned int, const ZdcDigits * > ZdcDigitsMapConst
typedef IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator
typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType RODPointer
typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

void addCompStats (const std::vector< uint32_t > &stats)
 Add compression stats to totals.
void printCompStats () const
 Print compression stats.
void printVec (const std::vector< int > &vec) const
 Print a vector.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

int m_dataFormat
 Sub_block header version.
int m_printCompStats
 Compression version.
int m_channels
 Number of channels per module (may not all be used)
int m_crates
 Number of crates.
int m_slinks
 Number of modules per crate (may not all exist)
int m_dfltSlicesLut
 Default number of LUT slices in simulation.
int m_dfltSlicesFadc
 Default number of FADC slices in simulation.
int m_forceSlicesLut
 Force number of LUT slices in bytestream.
int m_forceSlicesFadc
 Force number of FADC slices in bytestream.
int m_pedestal
 Pedestal value.
int m_fadcBaseline
 FADC baseline lower bound.
int m_fadcThreshold
 FADC threshold for super-compressed format.
int m_zeroSuppress
 Zero suppression on input.
std::vector< uint32_t > m_sourceIDs
 ROB source IDs.
eformat::SubDetector m_subDetector
 Sub-detector type.
ZdcSrcIdMapm_srcIdMap
 Source ID converter.
ZdcPpmSubBlockm_errorBlock {}
 Trigger tower key provider.
DataVector< ZdcPpmSubBlockm_ppmBlocks
 Vector for current PPM sub-blocks.
std::vector< uint32_t > m_compStats
 Vector for compression statistics.
std::vector< uint32_t > * m_rodStatus
 ROD Status words.
std::map< uint32_t, std::vector< uint32_t > * > m_rodStatusMap
 ROD status map.
const ZdcIDm_zdcID {}
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Tool to perform ROB fragments to ZdcDigits and from ZdcDigits to raw data conversions.

Based on ROD Tool from Level1 from Peter Faulkner

Definition at line 53 of file ZdcByteStreamTool.h.

Member Typedef Documentation

◆ ROBIterator

typedef IROBDataProviderSvc::VROBFRAG::const_iterator ZdcByteStreamTool::ROBIterator
private

Definition at line 82 of file ZdcByteStreamTool.h.

◆ RODPointer

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

◆ ZdcDigitsMap

typedef std::map<unsigned int, ZdcDigits*> ZdcByteStreamTool::ZdcDigitsMap
private

Definition at line 80 of file ZdcByteStreamTool.h.

◆ ZdcDigitsMapConst

typedef std::map<unsigned int, const ZdcDigits*> ZdcByteStreamTool::ZdcDigitsMapConst
private

Definition at line 81 of file ZdcByteStreamTool.h.

Constructor & Destructor Documentation

◆ ZdcByteStreamTool()

ZdcByteStreamTool::ZdcByteStreamTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 46 of file ZdcByteStreamTool.cxx.

48 :
49 AthAlgTool(type, name, parent),
50 //m_version(1),
51 //m_compVers(4),
52 m_channels(64),
53 m_crates(8),
54 //m_modules(16),
55 m_subDetector(eformat::FORWARD_ZDC),
56 m_srcIdMap(nullptr),
57 //m_towerKey(0),
58 //m_errorBlock(0),
59 m_rodStatus(nullptr)
60
61{
62 declareInterface<ZdcByteStreamTool> (this);
63
64 declareProperty("PrintCompStats", m_printCompStats = 0, "Print compressed format statistics");
65
66 // Properties for reading bytestream only
67 declareProperty("ZeroSuppress", m_zeroSuppress = 0,
68 "Only make trigger towers with non-zero EM or Had energy");
69 declareProperty("ROBSourceIDs", m_sourceIDs, "ROB fragment source identifiers");
70 declareProperty("PedestalValue", m_pedestal = 10,
71 "Pedestal value - needed for compressed formats 0,1 only");
72
73 // Properties for writing bytestream only
74 declareProperty("DataFormat", m_dataFormat = 1, "Format identifier (0-3) in sub-block header");
75 declareProperty("FADCBaseline", m_fadcBaseline = 0,
76 "FADC baseline lower bound for compressed formats");
77 declareProperty("FADCThreshold", m_fadcThreshold = 1,
78 "FADC threshold for super-compressed format");
79 declareProperty("SlinksPerCrate", m_slinks = 4, "The number of S-Links per crate");
80 declareProperty("SimulSlicesLUT", m_dfltSlicesLut = 1,
81 "The number of LUT slices in the simulation");
82 declareProperty("SimulSlicesFADC", m_dfltSlicesFadc = 7,
83 "The number of FADC slices in the simulation");
84 declareProperty("ForceSlicesLUT", m_forceSlicesLut = 0,
85 "If >0, the number of LUT slices in bytestream");
86 declareProperty("ForceSlicesFADC", m_forceSlicesFadc = 0,
87 "If >0, the number of FADC slices in bytestream");
88
89}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
int m_dataFormat
Sub_block header version.
int m_fadcThreshold
FADC threshold for super-compressed format.
int m_slinks
Number of modules per crate (may not all exist)
int m_printCompStats
Compression version.
int m_zeroSuppress
Zero suppression on input.
int m_channels
Number of channels per module (may not all be used)
int m_fadcBaseline
FADC baseline lower bound.
int m_crates
Number of crates.
int m_dfltSlicesFadc
Default number of FADC slices in simulation.
std::vector< uint32_t > * m_rodStatus
ROD Status words.
eformat::SubDetector m_subDetector
Sub-detector type.
int m_forceSlicesLut
Force number of LUT slices in bytestream.
int m_pedestal
Pedestal value.
int m_forceSlicesFadc
Force number of FADC slices in bytestream.
std::vector< uint32_t > m_sourceIDs
ROB source IDs.
int m_dfltSlicesLut
Default number of LUT slices in simulation.
ZdcSrcIdMap * m_srcIdMap
Source ID converter.

Member Function Documentation

◆ addCompStats()

void ZdcByteStreamTool::addCompStats ( const std::vector< uint32_t > & stats)
private

Add compression stats to totals.

Definition at line 576 of file ZdcByteStreamTool.cxx.

577{
578 if (stats.empty()) return;
579 const int n = stats.size();
580 if (m_compStats.empty()) m_compStats.resize(n);
581 for (int i = 0; i < n; ++i)
582 m_compStats[i] += stats[i];
583}
std::vector< uint32_t > m_compStats
Vector for compression statistics.

◆ convert() [1/2]

StatusCode ZdcByteStreamTool::convert ( const IROBDataProviderSvc::VROBFRAG & robFrags,
ZdcDigitsCollection * ttCollection )

Convert ROB fragments to ZdcCollection.

Definition at line 143 of file ZdcByteStreamTool.cxx.

145{
146
147 const bool debug = msgLvl(MSG::DEBUG);
148 //const bool debug = 1;
149 const bool verbose = msgLvl(MSG::VERBOSE);
150
151
152 if (debug) msg(MSG::DEBUG);
153 if (verbose) msg(MSG::VERBOSE);
154
155 // Clear trigger tower map
156
157 typedef std::map<uint32_t,ZdcDigits*> hashmapType;
158 hashmapType digits_map;
159
160 // Loop over ROB fragments
161 //msg(MSG::INFO) << "ZDC: Inside EVENT !" << endmsg;
162 int robCount = 0;
163 ROBIterator rob = robFrags.begin();
164 ROBIterator robEnd = robFrags.end();
165 for (; rob != robEnd; ++rob)
166 {
167
168 ++robCount;
169 if (debug)
170 {
171 msg() << "ZDC: Treating ROB fragment " << robCount << endmsg;
172 }
173
174 // Unpack ROD data (slinks)
175
176 RODPointer payloadBeg;
178 RODPointer payloadEnd;
179 (*rob)->rod_data(payloadBeg);
180 payloadEnd = payloadBeg + (*rob)->rod_ndata();
181 payload = payloadBeg;
182 if (payload == payloadEnd)
183 {
184 if (debug) msg() << "ZDC: ROB fragment empty" << endmsg;
185 continue;
186 }
187
188 // Check identifier
189 const uint32_t sourceID = (*rob)->rod_source_id();
190 if (debug)
191 {
192 if (ZdcSrcIdMap::subDet(sourceID) != m_subDetector || ZdcSrcIdMap::daqOrRoi(sourceID)
193 != 0)
194 {
195 msg() << "ZDC: Wrong source identifier in data: " << MSG::hex << sourceID << MSG::dec
196 << endmsg;
197 }
198 }
199 const int rodCrate = ZdcSrcIdMap::crate(sourceID);
200 if (debug)
201 {
202 msg() << "ZDC: Treating crate " << rodCrate << " slink " << ZdcSrcIdMap::slink(sourceID)
203 << "From SubDetectorID " << ZdcSrcIdMap::subDet(sourceID) << endmsg;
204 }
205
206 /* Comment out - this needs adaptation as there are too much L1 dialect in here
207 * for now I wnat ot compile/run the bytestream to esd convertion, as I know how
208 * to unpack the ppm data
209 *
210 */
211 // First word is User Header
212 ZdcUserHeader userHeader(*payload);
213 const int minorVersion = (*rob)->rod_version() & 0xffff;
214 userHeader.setVersion(minorVersion);
215 const int headerWords = userHeader.words();
216 if (headerWords != 1 && debug)
217 {
218 msg() << "ZDC: Unexpected number of user header words: " << headerWords << endmsg;
219 }
220 // Does this makes sense??? Look above headerWords == 1
221 for (int i = 0; i < headerWords; ++i)
222 ++payload;
223 // triggered slice offsets
224 const int trigLut = userHeader.ppmLut();
225 const int trigFadc = userHeader.ppmFadc();
226 // FADC baseline lower bound
227 m_fadcBaseline = userHeader.lowerBound();
228 if (debug)
229 {
230 msg() << "ZDC: Minor format version number: " << MSG::hex << minorVersion << MSG::dec
231 << endmsg << "ZDC: LUT triggered slice offset: " << trigLut << endmsg
232 << "ZDC: FADC triggered slice offset: " << trigFadc << endmsg
233 << "ZDC: FADC baseline lower bound: " << m_fadcBaseline << endmsg;
234 }
235 const int runNumber = (*rob)->rod_run_no() & 0xffffff;
236
237 // Find the number of channels per sub-block
238 int chanPerSubBlock = 0;
239 if (payload != payloadEnd)
240 {
242 {
243 msg(MSG::ERROR) << "Missing Sub-block header" << endmsg;
244 return StatusCode::FAILURE;
245 }
246 ZdcPpmSubBlock testBlock;
247 //Fix coverity CID 19251
248 //payload = testBlock.read(payload, payloadEnd);
249 testBlock.read(payload, payloadEnd);
250 chanPerSubBlock = testBlock.channelsPerSubBlock();
251 if (chanPerSubBlock == 0)
252 {
253 msg(MSG::ERROR) << "Unsupported version/data format: " << testBlock.version()
254 << "/" << testBlock.format() << endmsg;
255 return StatusCode::FAILURE;
256 }
257 if (m_channels % chanPerSubBlock != 0)
258 {
259 msg(MSG::ERROR) << "Invalid channels per sub-block: " << chanPerSubBlock << endmsg;
260 return StatusCode::FAILURE;
261 }
262 if (debug) msg() << "Channels per sub-block: " << chanPerSubBlock << endmsg;
263 }
264 else
265 {
266 if (debug) msg() << "ROB fragment contains user header only" << endmsg;
267 continue;
268 }
269 const int numSubBlocks = m_channels / chanPerSubBlock;
270
271 // Loop over PPMs
272
273 payload = payloadBeg;
274 for (int i = 0; i < headerWords; ++i)
275 ++payload;
276 while (payload != payloadEnd)
277 {
278
279 // Get all sub-blocks for one PPM
280
281 int crate = 0;
282 int module = 0;
283 m_ppmBlocks.clear();
284 for (int block = 0; block < numSubBlocks; ++block)
285 {
287 || ZdcPpmSubBlock::errorBlock(*payload))
288 {
289 msg(MSG::ERROR) << "Unexpected data sequence" << endmsg;
290 return StatusCode::FAILURE;
291 }
292 if (chanPerSubBlock != m_channels && ZdcSubBlock::seqno(*payload) != block
293 * chanPerSubBlock)
294 {
295 if (debug)
296 {
297 msg() << "Unexpected channel sequence number: "
298 << ZdcSubBlock::seqno(*payload) << " expected " << block
299 * chanPerSubBlock << endmsg;
300 }
301 if (!m_ppmBlocks.empty()) break;
302 else
303 {
304 if (!debug)
305 {
306 msg(MSG::ERROR) << "Unexpected channel sequence number" << endmsg;
307 }
308 return StatusCode::FAILURE;
309 }
310 }
311 ZdcPpmSubBlock* const subBlock = new ZdcPpmSubBlock();
312 m_ppmBlocks.push_back(subBlock);
313 payload = subBlock->read(payload, payloadEnd);
314 if (block == 0)
315 {
316 crate = subBlock->crate();
317 module = subBlock->module();
318 if (debug)
319 {
320 msg() << "Module " << module << endmsg;
321 if (crate != rodCrate)
322 {
323 msg() << "Inconsistent crate number in ROD source ID" << endmsg;
324 }
325 }
326 }
327 else
328 {
329 if (subBlock->crate() != crate)
330 {
331 msg(MSG::ERROR) << "Inconsistent crate number in sub-blocks" << endmsg;
332 return StatusCode::FAILURE;
333 }
334 if (subBlock->module() != module)
335 {
336 msg(MSG::ERROR) << "Inconsistent module number in sub-blocks" << endmsg;
337 return StatusCode::FAILURE;
338 }
339 }
340 if (payload == payloadEnd && block != numSubBlocks - 1)
341 {
342 if (debug) msg() << "Premature end of data" << endmsg;
343 break;
344 }
345 }
346
347 // Is there an error block?
348
349 //delete m_errorBlock;
350 //m_errorBlock = 0;
351 m_errorBlock->clear();
352 if (payload != payloadEnd)
353 {
355 && ZdcPpmSubBlock::errorBlock(*payload))
356 {
357 if (debug) msg() << "Error block found" << endmsg;
358 //m_errorBlock = new ZdcPpmSubBlock();
359 payload = m_errorBlock->read(payload, payloadEnd);
360 if (m_errorBlock->crate() != crate)
361 {
362 msg(MSG::ERROR) << "Inconsistent crate number in error block" << endmsg;
363 return StatusCode::FAILURE;
364 }
365 if (m_errorBlock->module() != module)
366 {
367 msg(MSG::ERROR) << "Inconsistent module number in error block" << endmsg;
368 return StatusCode::FAILURE;
369 }
370 if (m_errorBlock->dataWords() && !m_errorBlock->unpack())
371 {
372 if (debug)
373 {
374 std::string errMsg(m_errorBlock->unpackErrorMsg());
375 msg() << "Unpacking error block failed: " << errMsg << endmsg;
376 }
377 }
378 //delete m_errorBlock;
379 }
380 }
381
382 // Loop over sub-blocks and fill trigger towers
383
384 const int actualSubBlocks = m_ppmBlocks.size();
385 for (int block = 0; block < actualSubBlocks; ++block)
386 {
387 ZdcPpmSubBlock* const subBlock = m_ppmBlocks[block];
388 subBlock->setLutOffset(trigLut);
389 subBlock->setFadcOffset(trigFadc);
390 subBlock->setPedestal(m_pedestal);
392 subBlock->setRunNumber(runNumber);
393 if (debug)
394 {
395 msg() << "Unpacking sub-block version/format/seqno: " << subBlock->version()
396 << "/" << subBlock->format() << "/" << subBlock->seqno() << endmsg;
397 }
398 if (subBlock->dataWords() && !subBlock->unpack())
399 {
400 if (debug)
401 {
402 std::string errMsg(subBlock->unpackErrorMsg());
403 msg() << "Unpacking PPM sub-block failed: " << errMsg << endmsg;
404 }
405 }
406 if (m_printCompStats) addCompStats(subBlock->compStats());
407 for (int chan = 0; chan < chanPerSubBlock; ++chan)
408 {
409 const int channel = block * chanPerSubBlock + chan;
410 std::vector<int> lut;
411 std::vector<int> fadc;
412 std::vector<int> bcidLut;
413 std::vector<int> bcidFadc;
414 subBlock->ppmData(channel, lut, fadc, bcidLut, bcidFadc);
415// int trigLutKeep = trigLut;
416// int trigFadcKeep = trigFadc;
417 if (lut.size() < size_t(trigLut + 1))
418 {
419 if (debug)
420 {
421 msg() << "Triggered LUT slice from header "
422 << "inconsistent with number of slices: " << trigLut << ", "
423 << lut.size() << ", reset to 0" << endmsg;
424 }
425// trigLutKeep = 0;
426 }
427 if (fadc.size() < size_t(trigFadc + 1))
428 {
429 if (debug)
430 {
431 msg() << "Triggered FADC slice from header "
432 << "inconsistent with number of slices: " << trigFadc << ", "
433 << fadc.size() << ", reset to 0" << endmsg;
434 }
435// trigFadcKeep = 0;
436 }
437 /*
438 LVL1::DataError errorBits(0);
439 if (m_errorBlock)
440 {
441 errorBits.set(LVL1::DataError::PPMErrorWord,
442 m_errorBlock->ppmError(channel));
443 errorBits.set(LVL1::DataError::SubStatusWord, m_errorBlock->subStatus());
444 }
445 else
446 {
447 errorBits.set(LVL1::DataError::PPMErrorWord, subBlock->ppmError(channel));
448 const ZdcPpmSubBlock* const lastBlock = m_ppmBlocks[actualSubBlocks - 1];
449 errorBits.set(LVL1::DataError::SubStatusWord, lastBlock->subStatus());
450 }
451 // Wrong bit set for compressed formats 1.01 to 1.03
452 if (subBlock->format() > 1 && subBlock->seqno() < 4)
453 {
454 errorBits.set(LVL1::DataError::ModuleError, (errorBits.error()
455 >> (LVL1::DataError::ModuleError + 1)) & 0x1);
456 }
457 const int error = errorBits.error();
458 */
459 // Only save non-zero data
460
461 const bool any = std::accumulate(lut.begin(), lut.end(), 0)
462 || std::accumulate(fadc.begin(), fadc.end(), 0)
463 || std::accumulate(bcidLut.begin(), bcidLut.end(), 0)
464 || std::accumulate(bcidFadc.begin(), bcidFadc.end(), 0);
465
466
467 // Channel as unpacked is a SLink channel ordering, which is different
468 // from PPM channel ordering
469 // the sequence is :
470 // All channel A MCM
471 // All channel D MCM
472 // All channel B MCM
473 // All channel C MCM
474 Identifier chan_id;
475
476 int ppmChannel = subBlock->getPpmChannel(channel);
477
478 msg(MSG::DEBUG) << "--> ZCS: " << ZdcCablingService::getInstance() << endmsg;
479 chan_id = ZdcCablingService::getInstance()->h2s_channel_id(module, ppmChannel);
480
481 const uint32_t chan_hash = chan_id.get_identifier32().get_compact();
482 msg(MSG::DEBUG) << "chan_hash = " << chan_hash << endmsg;
483
484 //Change after uncommenting the above
485 //if (any || error)
486 if (any)
487 {
488 int gain = ZdcCablingService::getInstance()->hwid2gain(module,ppmChannel);
489 int delay = ZdcCablingService::getInstance()->hwid2delay(module,ppmChannel);
490 if (debug)
491 {
492 msg(MSG::DEBUG) << endmsg;
493 msg(MSG::DEBUG) <<" --------------------------------------" << endmsg;
494 msg(MSG::DEBUG) <<
495 "--> ZDC: [SubDet., Crate, Mod., Slink Chn., PPM Chan.] ";
496 msg(MSG::DEBUG) <<
497 "[" << m_subDetector << ", " << crate << ", " <<
498 module << ", " << channel << "," << ppmChannel << "]" << endmsg;
499
500 msg(MSG::DEBUG) << "--> ZDC: LUT: ";
501 printVec(lut);
502 msg(MSG::DEBUG) << endmsg;
503
504 msg(MSG::DEBUG) << "--> ZDC: FADC: ";
505 printVec(fadc);
506 msg(MSG::DEBUG) << endmsg;
507
508 msg(MSG::DEBUG) << "--> ZDC: bcidLUT: ";
509 printVec(bcidLut);
510 msg(MSG::DEBUG) << endmsg;
511
512 msg(MSG::DEBUG) << "--> ZDC: bcidFADC: ";
513 printVec(bcidFadc);
514 msg(MSG::DEBUG) << endmsg;
515
516 msg(MSG::DEBUG) << "--> ZDC ID: " << chan_id.getString() << endmsg;
517 msg(MSG::DEBUG) << "--> ID side: " << m_zdcID->side(chan_id) << endmsg;
518 msg(MSG::DEBUG) << "--> ID module: " << m_zdcID->module(chan_id) << endmsg;
519 msg(MSG::DEBUG) << "--> ID type: " << m_zdcID->type(chan_id) << endmsg;
520 msg(MSG::DEBUG) << "--> ID channel: " << m_zdcID->channel(chan_id) << endmsg;
521
522 msg(MSG::DEBUG) << "gain=" << gain << " delay=" << delay << endmsg;
523
524 msg(MSG::DEBUG) <<" --------------------------------------" << endmsg;
525
526 }
527
528 hashmapType::iterator iter = digits_map.find(chan_hash);
529 if (iter == digits_map.end())
530 {
531 digits_map.insert(std::pair<uint32_t,ZdcDigits*>(chan_hash,new ZdcDigits(chan_id)));
532 iter = digits_map.find(chan_hash);
533 }
534 if (iter != digits_map.end())
535 {
536 if (gain==0&&delay==0) (*iter).second->set_digits_gain0_delay0(fadc);
537 if (gain==1&&delay==0) (*iter).second->set_digits_gain1_delay0(fadc);
538 if (gain==0&&delay==1) (*iter).second->set_digits_gain0_delay1(fadc);
539 if (gain==1&&delay==1) (*iter).second->set_digits_gain1_delay1(fadc);
540 }
541
542 }
543 }
544 }
545 }
546 }
547
548 hashmapType::iterator iter = digits_map.begin();
549 hashmapType::iterator iter_end = digits_map.end();
550
551 while (iter != iter_end)
552 {
553 ttCollection->push_back((*iter).second);
554 ++iter;
555 }
556
557 msg(MSG::DEBUG) << "-->ZDC: Collection has " << ttCollection->size() << " elements " << endmsg;
558
559 return StatusCode::SUCCESS;
560}
#define endmsg
double delay(std::size_t d)
const bool debug
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
value_type get_compact() const
Get the compact id.
std::string getString() const
Provide a string form of the identifier - hexadecimal.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
DataVector< ZdcPpmSubBlock > m_ppmBlocks
Vector for current PPM sub-blocks.
IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator
OFFLINE_FRAGMENTS_NAMESPACE::PointerType RODPointer
void printVec(const std::vector< int > &vec) const
Print a vector.
void addCompStats(const std::vector< uint32_t > &stats)
Add compression stats to totals.
ZdcPpmSubBlock * m_errorBlock
Trigger tower key provider.
int hwid2gain(int crate, int channel) const
static const ZdcCablingService * getInstance()
get pointer to service instance
int hwid2delay(int crate, int channel) const
Identifier h2s_channel_id(int crate, int channel) const
void setPedestal(int pedval)
void setLutOffset(int offset)
void ppmData(int chan, std::vector< int > &lut, std::vector< int > &fadc, std::vector< int > &bcidLut, std::vector< int > &bcidFadc) const
Return unpacked data for given channel.
void setFadcBaseline(int baseline)
const std::vector< uint32_t > & compStats() const
Return reference to compression stats.
bool unpack()
Unpack data.
void setRunNumber(int run)
static bool errorBlock(uint32_t word)
Check if a header word is for an error block.
void setFadcOffset(int offset)
static int channelsPerSubBlock(int version, int format)
Return the number of channels per sub-block.
int getPpmChannel(const int channel) const
static eformat::SubDetector subDet(uint32_t code)
ID -> sub-detector.
static int crate(uint32_t code)
moduleID -> crate
static int daqOrRoi(uint32_t code)
moduleID -> daqOrRoi
static int slink(uint32_t code)
moduleID -> slink
int version() const
OFFLINE_FRAGMENTS_NAMESPACE::PointerType read(const OFFLINE_FRAGMENTS_NAMESPACE::PointerType beg, const OFFLINE_FRAGMENTS_NAMESPACE::PointerType end)
Input complete packed sub-block from ROD array.
int dataWords() const
Return number of data words.
int format() const
int crate() const
std::string unpackErrorMsg() const
Return the unpacking error message for printing.
static SubBlockWordType wordType(uint32_t word)
Word identification.
int module() const
int seqno() const
bool verbose
Definition hcg.cxx:73
constexpr auto lut(Generator &&f)
setEventNumber uint32_t

◆ convert() [2/2]

StatusCode ZdcByteStreamTool::convert ( const ZdcDigitsCollection * ttCollection,
RawEventWrite * re )
static

Convert ZdcCollection to ROB fragments.

Definition at line 565 of file ZdcByteStreamTool.cxx.

567{
568 //if (re) ttCollection->size();
569 //See PpmByteStreamTool for a implementation
570 return StatusCode::SUCCESS;
571}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode ZdcByteStreamTool::finalize ( )
overridevirtual

Definition at line 125 of file ZdcByteStreamTool.cxx.

126{
127 if (m_printCompStats && msgLvl(MSG::INFO))
128 {
129 msg(MSG::INFO);
131 }
132
133 delete m_rodStatus;
134 delete m_errorBlock;
135 //delete m_towerKey;
136 delete m_srcIdMap;
137 return StatusCode::SUCCESS;
138}
void printCompStats() const
Print compression stats.

◆ initialize()

StatusCode ZdcByteStreamTool::initialize ( )
overridevirtual

Definition at line 93 of file ZdcByteStreamTool.cxx.

94{
95 /*
96 * This would be used for crate/module/channel to eta/phi/layer mappings
97 StatusCode sc = m_zdcMaps.retrieve();
98 if (sc.isFailure())
99 {
100 msg(MSG::ERROR) << "Failed to retrieve tool " << m_zdcMaps << endmsg;
101 return sc;
102 }
103 else msg(MSG::INFO) << "Retrieved tool " << m_zdcMaps << endmsg;
104 */
105 m_srcIdMap = new ZdcSrcIdMap();
106 m_errorBlock = new ZdcPpmSubBlock();
107 m_rodStatus = new std::vector<uint32_t>(2);
108
109 const ZdcID* zdcID = nullptr;
110 if (detStore()->retrieve( zdcID ).isFailure() ) {
111 msg(MSG::ERROR) << "execute: Could not retrieve ZdcID object from the detector store" << endmsg;
112 return StatusCode::FAILURE;
113 }
114 else {
115 msg(MSG::DEBUG) << "execute: retrieved ZdcID" << endmsg;
116 }
117 m_zdcID = zdcID;
118
119 return StatusCode::SUCCESS;
120}
const ServiceHandle< StoreGateSvc > & detStore() const
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & ZdcByteStreamTool::interfaceID ( )
static

AlgTool InterfaceID.

Definition at line 40 of file ZdcByteStreamTool.cxx.

41{
43}
static const InterfaceID IID_IZdcByteStreamTool("ZdcByteStreamTool", 1, 1)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ printCompStats()

void ZdcByteStreamTool::printCompStats ( ) const
private

Print compression stats.

Definition at line 588 of file ZdcByteStreamTool.cxx.

589{
590 msg() << "Compression stats format/count: ";
591 const int n = m_compStats.size();
592 for (int i = 0; i < n; ++i)
593 {
594 msg() << " " << i << "/" << m_compStats[i];
595 }
596 msg() << endmsg;
597}

◆ printVec()

void ZdcByteStreamTool::printVec ( const std::vector< int > & vec) const
private

Print a vector.

Definition at line 622 of file ZdcByteStreamTool.cxx.

623{
624 std::vector<int>::const_iterator pos;
625 //msg() << "-----> " ;
626 for (pos = vec.begin(); pos != vec.end(); ++pos)
627 {
628 if (pos != vec.begin()) msg() << ",";
629 msg() << *pos;
630 }
631 //msg() << endmsg;
632}
std::vector< size_t > vec

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sourceIDs()

const std::vector< uint32_t > & ZdcByteStreamTool::sourceIDs ( )

Return reference to vector with all possible Source Identifiers.

Definition at line 602 of file ZdcByteStreamTool.cxx.

603{
604 if (m_sourceIDs.empty()) {
605 const int maxlinks = ZdcSrcIdMap::maxSlinks();
606 for (int crate = 0; crate < m_crates; ++crate) {
607 for (int slink = 0; slink < maxlinks; ++slink) {
608 const int daqOrRoi = 0;
609 const uint32_t rodId = ZdcSrcIdMap::getRodID(crate, slink, daqOrRoi,
611 const uint32_t robId = ZdcSrcIdMap::getRobID(rodId);
612 m_sourceIDs.push_back(robId);
613 }
614 }
615 }
616 return m_sourceIDs;
617}
static uint32_t getRobID(uint32_t rod_id)
ROD -> ROB.
static uint32_t getRodID(int crate, int slink, int daqOrRoi, eformat::SubDetector subdet)
Make a ROD Source ID.
static int maxSlinks()
Return the maximum possible number of slinks.

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_channels

int ZdcByteStreamTool::m_channels
private

Number of channels per module (may not all be used)

Definition at line 101 of file ZdcByteStreamTool.h.

◆ m_compStats

std::vector<uint32_t> ZdcByteStreamTool::m_compStats
private

Vector for compression statistics.

Definition at line 135 of file ZdcByteStreamTool.h.

◆ m_crates

int ZdcByteStreamTool::m_crates
private

Number of crates.

Definition at line 103 of file ZdcByteStreamTool.h.

◆ m_dataFormat

int ZdcByteStreamTool::m_dataFormat
private

Sub_block header version.

Data compression format

Definition at line 95 of file ZdcByteStreamTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_dfltSlicesFadc

int ZdcByteStreamTool::m_dfltSlicesFadc
private

Default number of FADC slices in simulation.

Definition at line 111 of file ZdcByteStreamTool.h.

◆ m_dfltSlicesLut

int ZdcByteStreamTool::m_dfltSlicesLut
private

Default number of LUT slices in simulation.

Definition at line 109 of file ZdcByteStreamTool.h.

◆ m_errorBlock

ZdcPpmSubBlock* ZdcByteStreamTool::m_errorBlock {}
private

Trigger tower key provider.

Definition at line 131 of file ZdcByteStreamTool.h.

131{};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_fadcBaseline

int ZdcByteStreamTool::m_fadcBaseline
private

FADC baseline lower bound.

Definition at line 119 of file ZdcByteStreamTool.h.

◆ m_fadcThreshold

int ZdcByteStreamTool::m_fadcThreshold
private

FADC threshold for super-compressed format.

Definition at line 121 of file ZdcByteStreamTool.h.

◆ m_forceSlicesFadc

int ZdcByteStreamTool::m_forceSlicesFadc
private

Force number of FADC slices in bytestream.

Definition at line 115 of file ZdcByteStreamTool.h.

◆ m_forceSlicesLut

int ZdcByteStreamTool::m_forceSlicesLut
private

Force number of LUT slices in bytestream.

Definition at line 113 of file ZdcByteStreamTool.h.

◆ m_pedestal

int ZdcByteStreamTool::m_pedestal
private

Pedestal value.

Definition at line 117 of file ZdcByteStreamTool.h.

◆ m_ppmBlocks

DataVector<ZdcPpmSubBlock> ZdcByteStreamTool::m_ppmBlocks
private

Vector for current PPM sub-blocks.

Definition at line 133 of file ZdcByteStreamTool.h.

◆ m_printCompStats

int ZdcByteStreamTool::m_printCompStats
private

Compression version.

Compression statistics print flag

Definition at line 99 of file ZdcByteStreamTool.h.

◆ m_rodStatus

std::vector<uint32_t>* ZdcByteStreamTool::m_rodStatus
private

ROD Status words.

Definition at line 137 of file ZdcByteStreamTool.h.

◆ m_rodStatusMap

std::map<uint32_t, std::vector<uint32_t>*> ZdcByteStreamTool::m_rodStatusMap
private

ROD status map.

Definition at line 139 of file ZdcByteStreamTool.h.

◆ m_slinks

int ZdcByteStreamTool::m_slinks
private

Number of modules per crate (may not all exist)

Number of slinks per crate when writing out bytestream

Definition at line 107 of file ZdcByteStreamTool.h.

◆ m_sourceIDs

std::vector<uint32_t> ZdcByteStreamTool::m_sourceIDs
private

ROB source IDs.

Definition at line 125 of file ZdcByteStreamTool.h.

◆ m_srcIdMap

ZdcSrcIdMap* ZdcByteStreamTool::m_srcIdMap
private

Source ID converter.

Definition at line 129 of file ZdcByteStreamTool.h.

◆ m_subDetector

eformat::SubDetector ZdcByteStreamTool::m_subDetector
private

Sub-detector type.

Definition at line 127 of file ZdcByteStreamTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_zdcID

const ZdcID* ZdcByteStreamTool::m_zdcID {}
private

Definition at line 141 of file ZdcByteStreamTool.h.

141{};

◆ m_zeroSuppress

int ZdcByteStreamTool::m_zeroSuppress
private

Zero suppression on input.

Definition at line 123 of file ZdcByteStreamTool.h.


The documentation for this class was generated from the following files: