ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
xAODClusterMaker Class Reference

Creates xAOD pixel and strip cluster containers from FPGA input. More...

#include <xAODClusterMaker.h>

Inheritance diagram for xAODClusterMaker:
Collaboration diagram for xAODClusterMaker:

Public Member Functions

StatusCode initialize () override
 Initialise the tool. More...
 
StatusCode makeStripClusterContainer (const EFTrackingTransient::StripClusterAuxInput &scAux, const EFTrackingTransient::Metadata *metadata, const EventContext &ctx) const
 Make the strip cluster container. More...
 
StatusCode makeStripClusterContainer (const uint64_t *stripClusters, const EFTrackingTransient::Metadata *metadata, const EventContext &ctx) const
 Make the strip cluster container. More...
 
StatusCode makePixelClusterContainer (const EFTrackingTransient::PixelClusterAuxInput &pxAux, const EFTrackingTransient::Metadata *metadata, const EventContext &ctx) const
 Make the pixel cluster container. More...
 
StatusCode makePixelClusterContainer (const uint64_t *pixelClusters, const EFTrackingTransient::Metadata *metadata, const EventContext &ctx) const
 Make the pixel cluster container. More...
 

Private Attributes

SG::WriteHandleKey< xAOD::PixelClusterContainerm_pixelClustersKey
 Key for the pixel clusters container to be created. More...
 
SG::WriteHandleKey< xAOD::StripClusterContainerm_stripClustersKey
 Key for the strip clusters container to be created. More...
 
Gaudi::Property< bool > m_doBulkCopy {this, "DoBulkCopy", true, "Do bulk copy"}
 Do bulk copy method. More...
 
ServiceHandle< IChronoStatSvc > m_chronoSvc {this, "ChronoStatSvc", "ChronoStatSvc"}
 

Detailed Description

Creates xAOD pixel and strip cluster containers from FPGA input.

Definition at line 34 of file xAODClusterMaker.h.

Member Function Documentation

◆ initialize()

StatusCode xAODClusterMaker::initialize ( )
override

Initialise the tool.

Definition at line 24 of file xAODClusterMaker.cxx.

24  {
25  ATH_MSG_INFO("Initialising xAODClusterMaker tool");
26 
27  // Initialise the write handles
28  ATH_CHECK(m_pixelClustersKey.initialize());
29  ATH_CHECK(m_stripClustersKey.initialize());
30 
31  // Initialise the chrono service
32  ATH_CHECK(m_chronoSvc.retrieve());
33 
34  return StatusCode::SUCCESS;
35 }

◆ makePixelClusterContainer() [1/2]

StatusCode xAODClusterMaker::makePixelClusterContainer ( const EFTrackingTransient::PixelClusterAuxInput pxAux,
const EFTrackingTransient::Metadata metadata,
const EventContext &  ctx 
) const

Make the pixel cluster container.

Parameters
pxAuxInput pixel cluster data
metadataInput metadata
ctx
Returns
StatusCode

Definition at line 522 of file xAODClusterMaker.cxx.

525  {
526  ATH_MSG_DEBUG("Making xAOD::PixelClusterContainer");
527 
528 
530 
531  if (!m_doBulkCopy) {
532  // --------------------------------------------------------------------
533  // proceed with the element-wise method
534  // --------------------------------------------------------------------
535  ATH_MSG_DEBUG("You are running the element-wise container creation method.");
536  Athena::Chrono chrono("ElementWiseMethod", m_chronoSvc.get());
537 
538  ATH_CHECK(pixelClustersHandle.record(
539  std::make_unique<xAOD::PixelClusterContainer>(),
540  std::make_unique<xAOD::PixelClusterAuxContainer>()));
541 
542  ATH_CHECK(pixelClustersHandle.isValid());
543  ATH_MSG_DEBUG("Container '" << m_pixelClustersKey << "' initialised");
544 
545  int rdoIndex_counter = 0;
546 
547  for (unsigned int i = 0; i < metadata->numOfPixelClusters; i++) {
548  // Push back numClusters of PixelCluster
549  auto pixelCl = pixelClustersHandle->push_back(
550  std::make_unique<xAOD::PixelCluster>());
551 
552  Eigen::Matrix<float, 2, 1> localPosition(
553  pxAux.localPosition[i * 2], pxAux.localPosition[i * 2 + 1]);
554  Eigen::Matrix<float, 2, 2> localCovariance;
555  localCovariance.setZero();
556  localCovariance(0, 0) = pxAux.localCovariance[i * 2];
557  localCovariance(1, 1) = pxAux.localCovariance[i * 2 + 1];
558  Eigen::Matrix<float, 3, 1> globalPosition(
559  pxAux.globalPosition[i * 3], pxAux.globalPosition[i * 3 + 1],
560  pxAux.globalPosition[i * 3 + 2]);
561 
562  std::vector<Identifier> RDOs;
563  RDOs.reserve(metadata->pcRdoIndex[i]);
564  // Cover RDO
565  for (unsigned int j = 0; j < metadata->pcRdoIndex[i]; ++j) {
566  RDOs.push_back(Identifier(pxAux.rdoList[rdoIndex_counter + j]));
567  }
568 
569  rdoIndex_counter += metadata->pcRdoIndex[i];
570 
571  pixelCl->setMeasurement<2>(pxAux.idHash[i], localPosition,
572  localCovariance);
573  pixelCl->setIdentifier(pxAux.id[i]);
574  pixelCl->setRDOlist(RDOs);
575  pixelCl->globalPosition() = globalPosition;
576  pixelCl->setTotalToT(pxAux.totalToT[i]);
577  pixelCl->setChannelsInPhiEta(pxAux.channelsInPhi[i],
578  pxAux.channelsInEta[i]);
579  pixelCl->setWidthInEta(pxAux.widthInEta[i]);
580  }
581 
582  return StatusCode::SUCCESS;
583  }
584 
585  // --------------------------------------------------------------------
586  // proceed with the bulk copy method
587  // --------------------------------------------------------------------
588 
589  ATH_MSG_DEBUG("You are running the bulk copy container creation method.");
590  Athena::Chrono chrono("BulkCopyMethod", m_chronoSvc.get());
591 
592  // --------------------------
593  // Create the container and aux. container
594  // --------------------------
595  auto pixelCl = std::make_unique<xAOD::PixelClusterContainer>();
596  auto pixelClAux = std::make_unique<xAOD::PixelClusterAuxContainer>();
597  pixelCl->setStore(pixelClAux.get());
598 
599  // Pre-allocate memory for all clusters in the AuxContainer
600  // and reserve the same space in the container.
601  const size_t nClusters = metadata->numOfPixelClusters;
602  pixelClAux->resize(nClusters);
603  pixelCl->reserve(nClusters);
604 
605  // Now, push back the PixelCluster objects
606  // and create them all at once.
607  // Note, that no data is set yet,
608  // we will do that in the next step.
609  for (size_t i = 0; i < nClusters; ++i) {
610  pixelCl->push_back(std::make_unique<xAOD::PixelCluster>());
611  }
612 
613  // --------------------------
614  // Prepare local buffers for each of the
615  // fixed-size attributes.
616  // --------------------------
617  std::vector<long unsigned int> identifierBuffer(nClusters);
618  std::vector<unsigned int> idHashBuffer(nClusters);
619  std::vector<std::array<float, 3>> gpBuffer(nClusters);
620  std::vector<float> localPosX(nClusters);
621  std::vector<float> localPosY(nClusters);
622  std::vector<float> localCovXX(nClusters);
623  std::vector<float> localCovYY(nClusters);
624  std::vector<int> totalToTBuffer(nClusters);
625  std::vector<float> widthInEtaBuffer(nClusters);
626  std::vector<int> channelsInPhiBuffer(nClusters);
627  std::vector<int> channelsInEtaBuffer(nClusters);
628 
629  for (size_t i = 0; i < nClusters; ++i) {
630 
631  // Fill the identifierBuffer
632  identifierBuffer[i] = pxAux.id[i];
633 
634  // Fill the idHashBuffer
635  idHashBuffer[i] = pxAux.idHash[i];
636 
637  // Fill the globalPositionBuffers
638  gpBuffer[i] = {
639  pxAux.globalPosition[3 * i],
640  pxAux.globalPosition[3 * i + 1],
641  pxAux.globalPosition[3 * i + 2],
642  };
643 
644  // Fill the localPositionBuffers
645  localPosX[i] = pxAux.localPosition[2 * i];
646  localPosY[i] = pxAux.localPosition[2 * i + 1];
647 
648  // Fill the localCovBuffer[i]
649  localCovXX[i] = pxAux.localCovariance[2 * i];
650  localCovYY[i] = pxAux.localCovariance[2 * i + 1];
651 
652  // Fill the totalToTBuffer
653  totalToTBuffer[i] = pxAux.totalToT[i];
654 
655  // Fill the widthInEtaBuffer
656  widthInEtaBuffer[i] = pxAux.widthInEta[i];
657 
658  // Fill the channelsInPhiEtaBuffer
659  channelsInPhiBuffer[i] = pxAux.channelsInPhi[i];
660  channelsInEtaBuffer[i] = pxAux.channelsInEta[i];
661  }
662 
663  // --------------------------
664  // Now, use SG::Accessors to do a bulk copy into
665  // the container memory.
666  // --------------------------
667 
668  // FIXED-SIZE ATTRIBUTES
669  static const SG::Accessor<long unsigned int> idAcc("identifier");
670  static const SG::Accessor<unsigned int> idHashAcc("idHash");
671  static const SG::Accessor<float> localPosXAcc("localPositionX");
672  static const SG::Accessor<float> localPosYAcc("localPositionY");
673  static const SG::Accessor<float> localCovXXAcc("localCovarianceXX");
674  static const SG::Accessor<float> localCovYYAcc("localCovarianceYY");
675  static const SG::Accessor<int> totAcc("totalToT");
676  static const SG::Accessor<float> widthEtaAcc("widthInEta");
677  static const SG::Accessor<int> channelsInPhiAcc("channelsInPhi");
678  static const SG::Accessor<int> channelsInEtaAcc("channelsInEta");
679 
680  // VARIABLE-LENGTH ATTRIBUTES
681  static const SG::Accessor<std::array<float, 3>> globalPosAcc(
682  "globalPosition");
683 
684  // Get spans into the container
685  auto idSpan = idAcc.getDataSpan(*pixelCl);
686  auto idHashSpan = idHashAcc.getDataSpan(*pixelCl);
687  auto locPosXSpan = localPosXAcc.getDataSpan(*pixelCl);
688  auto locPosYSpan = localPosYAcc.getDataSpan(*pixelCl);
689  auto locCovXXSpan = localCovXXAcc.getDataSpan(*pixelCl);
690  auto locCovYYSpan = localCovYYAcc.getDataSpan(*pixelCl);
691  auto totSpan = totAcc.getDataSpan(*pixelCl);
692  auto wEtaSpan = widthEtaAcc.getDataSpan(*pixelCl);
693  auto gpSpan = globalPosAcc.getDataSpan(*pixelCl);
694  auto channelsInPhiSpan = channelsInPhiAcc.getDataSpan(*pixelCl);
695  auto channelsInEtaSpan = channelsInEtaAcc.getDataSpan(*pixelCl);
696 
697  // Bulk copy the fixed-size attributes
698  CxxUtils::copy_bounded(identifierBuffer, idSpan);
699  CxxUtils::copy_bounded(idHashBuffer, idHashSpan);
700  CxxUtils::copy_bounded(localPosX, locPosXSpan);
701  CxxUtils::copy_bounded(localPosY, locPosYSpan);
702  CxxUtils::copy_bounded(localCovXX, locCovXXSpan);
703  CxxUtils::copy_bounded(localCovYY, locCovYYSpan);
704  CxxUtils::copy_bounded(totalToTBuffer, totSpan);
705  CxxUtils::copy_bounded(widthInEtaBuffer, wEtaSpan);
706  CxxUtils::copy_bounded(gpBuffer, gpSpan);
707  CxxUtils::copy_bounded(channelsInPhiBuffer, channelsInPhiSpan);
708  CxxUtils::copy_bounded(channelsInEtaBuffer, channelsInEtaSpan);
709 
710  // --------------------------
711  // Copy the variable-length data.
712  // We need to loop over the number of
713  // clusters to get access to each
714  // element.
715  // --------------------------
716  static const SG::Accessor<std::vector<unsigned long long>> rdoListAcc(
717  "rdoList");
718  auto rdoSpan = rdoListAcc.getDataSpan(*pixelCl);
719 
720  int rdoIndex_counter = 0;
721  // loop over the clusters
722  for (size_t i = 0; i < nClusters; ++i) {
723  size_t nRDOs = metadata->pcRdoIndex[i];
724 
725  // direct ref to destination vector
726  std::vector<unsigned long long> &rdosForThisCluster = rdoSpan[i];
727 
728  // pre-size the vector
729  rdosForThisCluster.resize(nRDOs);
730 
731  // direct element access
732  for (size_t j = 0; j < nRDOs; ++j) {
733  rdosForThisCluster[j] = pxAux.rdoList[rdoIndex_counter + j];
734  }
735  rdoIndex_counter += nRDOs;
736  }
737  // --------------------------
738  // Record the container + aux container into StoreGate,
739  // but now we do it AFTER filling the container!
740  // --------------------------
741 
742  ATH_CHECK(
743  pixelClustersHandle.record(std::move(pixelCl), std::move(pixelClAux)));
744 
745  ATH_MSG_DEBUG("Bulk copy for fixed-size variables done.");
746  return StatusCode::SUCCESS;
747 }

◆ makePixelClusterContainer() [2/2]

StatusCode xAODClusterMaker::makePixelClusterContainer ( const uint64_t *  pixelClusters,
const EFTrackingTransient::Metadata metadata,
const EventContext &  ctx 
) const

Make the pixel cluster container.

Parameters
pixelClustersraw input from the EDM output
metadataInput metadata
ctx
Returns
StatusCode

Definition at line 280 of file xAODClusterMaker.cxx.

283  {
284  ATH_MSG_DEBUG("Making xAOD::PixelClusterContainer");
285 
286 
288 
289  if (!m_doBulkCopy) {
290  // --------------------------------------------------------------------
291  // proceed with the element-wise method
292  // --------------------------------------------------------------------
293  Athena::Chrono chrono("ElementWiseMethod", m_chronoSvc.get());
294 
295  ATH_CHECK(pixelClustersHandle.record(std::make_unique<xAOD::PixelClusterContainer>(),std::make_unique<xAOD::PixelClusterAuxContainer>()));
296 
297  ATH_CHECK(pixelClustersHandle.isValid());
298 
299  for (unsigned int i = 0; i < metadata->numOfPixelClusters; i++)
300  {
301  // Push back numClusters of StripCluster
302  auto pixelCl = pixelClustersHandle->push_back(std::make_unique<xAOD::PixelCluster>());
303 
304  int row = 0; // idhash
305  long unsigned int idHash = pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8];
306  row = 1; // id
307  unsigned long long id = pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8];
308 
309  std::vector<Identifier> RDOs;
310  row = 2; // rdo w1
311  unsigned long long rdo = pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8];
312  if (rdo) RDOs.push_back(Identifier(rdo));
313 
314  row = 3; // rdo w2
315  rdo = pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8];
316  if (rdo) RDOs.push_back(Identifier(rdo));
317 
318  row = 4; // rdo w3
319  rdo = pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8];
320  if (rdo) RDOs.push_back(Identifier(rdo));
321 
322  row = 5; // rdo w4
323  rdo = pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8];
324  if (rdo) RDOs.push_back(Identifier(rdo));
325 
326  Eigen::Matrix<float, 2, 1> localPosition;
327  Eigen::Matrix<float, 2, 2> localCovariance;
328  localCovariance.setZero();
329  row = 6; // local x
330  localPosition(0 , 0) = std::bit_cast<double>(pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8]);
331 
332  row = 7; // local y
333  localPosition(1 , 1) = std::bit_cast<double>(pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8]);
334 
335  row = 8; // local covariance xx
336  localCovariance(0, 0) = std::bit_cast<double>(pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8]);
337 
338  row = 9; // local covariance yy
339  localCovariance(1, 1) = std::bit_cast<double>(pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8]);
340 
341  row = 10; // global x
342  float globalX = std::bit_cast<double>(pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8]);
343 
344  row = 11; // global y
345  float globalY = std::bit_cast<double>(pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8]);
346 
347  row = 12; // global
348  float globalZ = std::bit_cast<double>(pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8]);
349 
350  row = 13; // channels in phi
351  int channelsInPhi = pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8];
352 
353  row = 14; // channels in eta
354  int channelsInEta = pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8];
355 
356  row = 15; // width in eta
357  double widthInEta = std::bit_cast<double>(pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8]);
358 
359  row = 18; // total ToT
360  int totalToT = pixelClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8];
361 
362  Eigen::Matrix<float, 3, 1> globalPosition(globalX, globalY, globalZ);
363 
364  pixelCl->setMeasurement<2>(idHash, localPosition,localCovariance);
365  pixelCl->setIdentifier(id);
366  pixelCl->setRDOlist(RDOs);
367  pixelCl->globalPosition() = globalPosition;
368  pixelCl->setTotalToT(totalToT);
369  pixelCl->setChannelsInPhiEta(channelsInPhi, channelsInEta);
370  pixelCl->setWidthInEta(widthInEta);
371  }
372  return StatusCode::SUCCESS;
373  }
374 
375  ATH_MSG_DEBUG("Doing bulk copy");
376  // Doing bulk copy
377  // --------------------------
378  // Create the container and aux. container
379  // --------------------------
380  auto pixelCl = std::make_unique<xAOD::PixelClusterContainer>();
381  auto pixelClAux = std::make_unique<xAOD::PixelClusterAuxContainer>();
382  pixelCl->setStore(pixelClAux.get());
383 
384  // Pre-allocate memory for all clusters in the AuxContainer
385  // and reserve the same space in the container.
386  const size_t nClusters = metadata->numOfPixelClusters;
387  pixelClAux->resize(nClusters);
388  pixelCl->reserve(nClusters);
389 
390  // Now, push back the PixelCluster objects
391  // and create them all at once.
392  // Note, that no data is set yet,
393  // we will do that in the next step.
394  for (size_t i = 0; i < nClusters; ++i) {
395  pixelCl->push_back(std::make_unique<xAOD::PixelCluster>());
396  }
397 
398  // --------------------------
399  // Prepare local buffers for each of the
400  // fixed-size attributes.
401  // --------------------------
403  const size_t offset = 8;
404 
405  // RDO accessor
406  static const SG::Accessor<std::vector<unsigned long long>> rdoListAcc("rdoList");
407  auto rdoSpan = rdoListAcc.getDataSpan(*pixelCl);
408 
409  const auto* base = pixelClusters;
410 
411  // Row pointers (only once)
412  const auto* idHashPtr = base + 0 * N + offset;
413  const auto* identifierPtr = base + 1 * N + offset;
414  const uint64_t* rdoPtrs[4] = {
415  base + 2 * N + offset,
416  base + 3 * N + offset,
417  base + 4 * N + offset,
418  base + 5 * N + offset
419  };
420  const auto* localXPtr = base + 6 * N + offset;
421  const auto* localYPtr = base + 7 * N + offset;
422  const auto* covXXPtr = base + 8 * N + offset;
423  const auto* covYYPtr = base + 9 * N + offset;
424  const auto* gpXPtr = base + 10 * N + offset;
425  const auto* gpYPtr = base + 11 * N + offset;
426  const auto* gpZPtr = base + 12 * N + offset;
427  const auto* channelsPhiPtr = base + 13 * N + offset;
428  const auto* channelsEtaPtr = base + 14 * N + offset;
429  const auto* widthEtaPtr = base + 15 * N + offset;
430  const auto* totalToTPtr = base + 18 * N + offset;
431 
432 
433  std::vector<long unsigned int> identifierBuffer(nClusters);
434  std::vector<unsigned int> idHashBuffer(nClusters);
435  std::vector<std::array<float, 3>> gpBuffer(nClusters);
436  std::vector<std::array<float, 2>> localPositionBuffer(nClusters);
437  std::vector<std::array<float, 4>> localCovarianceBuffer(nClusters);
438  std::vector<int> totalToTBuffer(nClusters);
439  std::vector<float> widthInEtaBuffer(nClusters);
440  std::vector<int> channelsInPhiBuffer(nClusters);
441  std::vector<int> channelsInEtaBuffer(nClusters);
442 
443  for (unsigned int i = 0; i < metadata->numOfPixelClusters; ++i) {
444 
445  // Basic IDs
446  idHashBuffer[i] = static_cast<unsigned int>(idHashPtr[i]);
447  identifierBuffer[i] = static_cast<unsigned long>(identifierPtr[i]);
448 
449  // RDOs: push non-zero entries into the cluster's list
450  std::vector<unsigned long long>& rdoList = rdoSpan[i];
451  for (int r = 0; r < 4; ++r) {
452  if (!rdoPtrs[r][i]) continue;
453  unsigned long long rdo = static_cast<unsigned long long>(rdoPtrs[r][i]);
454  rdoList.push_back(rdo);
455  }
456 
457  localPositionBuffer[i][0] = static_cast<float>(std::bit_cast<double>(localXPtr[i]));
458  localCovarianceBuffer[i][0] = static_cast<float>(std::bit_cast<double>(covXXPtr[i]));
459 
460  localPositionBuffer[i][1] = static_cast<float>(std::bit_cast<double>(localYPtr[i]));
461  localCovarianceBuffer[i][3] = static_cast<float>(std::bit_cast<double>(covYYPtr[i]));
462 
463  gpBuffer[i][0] = static_cast<float>(std::bit_cast<double>(gpXPtr[i]));
464  gpBuffer[i][1] = static_cast<float>(std::bit_cast<double>(gpYPtr[i]));
465  gpBuffer[i][2] = static_cast<float>(std::bit_cast<double>(gpZPtr[i]));
466 
467  // Additional attributes
468  channelsInPhiBuffer[i] = static_cast<int>(channelsPhiPtr[i]);
469  channelsInEtaBuffer[i] = static_cast<int>(channelsEtaPtr[i]);
470  widthInEtaBuffer[i] = static_cast<float>(std::bit_cast<double>(widthEtaPtr[i]));
471  totalToTBuffer[i] = static_cast<int>(totalToTPtr[i]);
472 
473  }
474 
475 
476  // --------------------------
477  // Now, use SG::Accessors to do a bulk copy into
478  // the container memory.
479  // --------------------------
480 
481  // FIXED-SIZE ATTRIBUTES
482  static const SG::Accessor<long unsigned int> idAcc("identifier");
483  static const SG::Accessor<unsigned int> idHashAcc("identifierHash");
484  static const SG::Accessor<std::array<float, 3>> globalPosAcc("globalPosition");
485  static const SG::Accessor<std::array<float, 2>> localPosAcc("localPositionDim2");
486  static const SG::Accessor<std::array<float, 4>> localCovAcc("localCovarianceDim2");
487  static const SG::Accessor<int> totalToTAcc("totalToT");
488  static const SG::Accessor<int> channelsInPhiAcc("channelsInPhi");
489  static const SG::Accessor<int> channelsInEtaAcc("channelsInEta");
490  static const SG::Accessor<float> widthInEtaAcc("widthInEta");
491 
492  // Get spans into the container
493  auto idSpan = idAcc.getDataSpan(*pixelCl);
494  auto idHashSpan = idHashAcc.getDataSpan(*pixelCl);
495  auto gpSpan = globalPosAcc.getDataSpan(*pixelCl);
496  auto locPosSpan = localPosAcc.getDataSpan(*pixelCl);
497  auto locCovSpan = localCovAcc.getDataSpan(*pixelCl);
498  auto totalToTSpan = totalToTAcc.getDataSpan(*pixelCl);
499  auto channelsInPhiSpan = channelsInPhiAcc.getDataSpan(*pixelCl);
500  auto channelsInEtaSpan = channelsInEtaAcc.getDataSpan(*pixelCl);
501  auto widthInEtaSpan = widthInEtaAcc.getDataSpan(*pixelCl);
502 
503  // Bulk copy the fixed-size attributes
504  CxxUtils::copy_bounded(identifierBuffer, idSpan);
505  CxxUtils::copy_bounded(idHashBuffer, idHashSpan);
506  CxxUtils::copy_bounded(localPositionBuffer, locPosSpan);
507  CxxUtils::copy_bounded(localCovarianceBuffer, locCovSpan);
508  CxxUtils::copy_bounded(gpBuffer, gpSpan);
509  CxxUtils::copy_bounded(totalToTBuffer, totalToTSpan);
510  CxxUtils::copy_bounded(channelsInPhiBuffer, channelsInPhiSpan);
511  CxxUtils::copy_bounded(channelsInEtaBuffer, channelsInEtaSpan);
512  CxxUtils::copy_bounded(widthInEtaBuffer, widthInEtaSpan);
513 
514  ATH_CHECK(pixelClustersHandle.record(std::move(pixelCl), std::move(pixelClAux)));
515 
516 
517  return StatusCode::SUCCESS;
518 }

◆ makeStripClusterContainer() [1/2]

StatusCode xAODClusterMaker::makeStripClusterContainer ( const EFTrackingTransient::StripClusterAuxInput scAux,
const EFTrackingTransient::Metadata metadata,
const EventContext &  ctx 
) const

Make the strip cluster container.

Parameters
scAuxInput strip cluster data
metadataInput metadata
ctx
Returns
StatusCode

Definition at line 229 of file xAODClusterMaker.cxx.

232  {
233  ATH_MSG_DEBUG("Making xAOD::StripClusterContainer");
234 
236  m_stripClustersKey , ctx};
237 
238  ATH_CHECK(stripClustersHandle.record(
239  std::make_unique<xAOD::StripClusterContainer>(),
240  std::make_unique<xAOD::StripClusterAuxContainer>()));
241 
242  int rdoIndex_counter = 0;
243 
244  for (unsigned int i = 0; i < metadata->numOfStripClusters; i++) {
245  // Push back numClusters of StripCluster
246  auto stripCl =
247  stripClustersHandle->push_back(std::make_unique<xAOD::StripCluster>());
248 
249  // Build Matrix
250  Eigen::Matrix<float, 1, 1> localPosition;
251  Eigen::Matrix<float, 1, 1> localCovariance;
252 
253  localPosition(0, 0) = scAux.localPosition.at(i);
254  localCovariance(0, 0) = scAux.localCovariance.at(i);
255 
256  Eigen::Matrix<float, 3, 1> globalPosition(
257  scAux.globalPosition.at(i * 3), scAux.globalPosition.at(i * 3 + 1),
258  scAux.globalPosition.at(i * 3 + 2));
259 
260  std::vector<Identifier> RDOs;
261  RDOs.reserve(metadata->scRdoIndex[i]);
262  // Cover RDO
263  for (unsigned int j = 0; j < metadata->scRdoIndex[i]; ++j) {
264  RDOs.push_back(Identifier(scAux.rdoList.at(rdoIndex_counter + j)));
265  }
266 
267  rdoIndex_counter += metadata->scRdoIndex[i];
268 
269  stripCl->setMeasurement<1>(scAux.idHash.at(i), localPosition,
270  localCovariance);
271  stripCl->setIdentifier(scAux.id.at(i));
272  stripCl->setRDOlist(RDOs);
273  stripCl->globalPosition() = globalPosition;
274  stripCl->setChannelsInPhi(scAux.channelsInPhi.at(i));
275  }
276  return StatusCode::SUCCESS;
277 }

◆ makeStripClusterContainer() [2/2]

StatusCode xAODClusterMaker::makeStripClusterContainer ( const uint64_t *  stripClusters,
const EFTrackingTransient::Metadata metadata,
const EventContext &  ctx 
) const

Make the strip cluster container.

Parameters
stripClustersraw input from the EDM output
metadataInput metadata
ctx
Returns
StatusCode

Definition at line 37 of file xAODClusterMaker.cxx.

40  {
41  ATH_MSG_DEBUG("Making xAOD::StripClusterContainer");
42 
44 
45  if (!m_doBulkCopy) {
46  ATH_CHECK(stripClustersHandle.record(std::make_unique<xAOD::StripClusterContainer>(), std::make_unique<xAOD::StripClusterAuxContainer>()));
47 
48 
49  for (unsigned int i = 0; i < metadata->numOfStripClusters; i++)
50  {
51  // Push back numClusters of StripCluster
52  auto stripCl = stripClustersHandle->push_back(std::make_unique<xAOD::StripCluster>());
53 
54  // Build Matrix
55  Eigen::Matrix<float, 1, 1> localPosition;
56  Eigen::Matrix<float, 1, 1> localCovariance;
57 
58  int row = 0; // idhash
59  long unsigned int idHash = stripClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8];
60  row = 1; // id
61  unsigned long long id = stripClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8];
62 
63  std::vector<Identifier> RDOs;
64  row = 2; // rdo w1
65  unsigned long long rdo = stripClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8];
66  if (rdo) RDOs.push_back(Identifier(rdo));
67 
68  row = 3; // rdo w2
69  rdo = stripClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8];
70  if (rdo) RDOs.push_back(Identifier(rdo));
71 
72  row = 4; // rdo w3
73  rdo = stripClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8];
74  if (rdo) RDOs.push_back(Identifier(rdo));
75 
76  row = 5; // rdo w4
77  rdo = stripClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8];
78  if (rdo) RDOs.push_back(Identifier(rdo));
79  row = 6; // local x
80  localPosition(0, 0) = std::bit_cast<double>(stripClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8]);
81  row = 8; // local covariance xx
82  localCovariance(0, 0) = std::bit_cast<double>(stripClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8]);
83  row = 9; // global x
84  double globalX = std::bit_cast<double>(stripClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8]);
85  row = 10; // global y
86  double globalY = std::bit_cast<double>(stripClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8]);
87  row = 11; // global z
88  double globalZ = std::bit_cast<double>(stripClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8]);
89  row = 12; // channels in phi
90  auto channelsinPhi = stripClusters[row * EFTrackingTransient::MAX_NUM_CLUSTERS + i + 8];
91 
92 
93  Eigen::Matrix<float, 3, 1> globalPosition(globalX, globalY, globalZ);
94  stripCl->setMeasurement<1>(idHash, localPosition, localCovariance);
95 
96  stripCl->setIdentifier(id);
97  stripCl->setRDOlist(RDOs);
98  stripCl->globalPosition() = globalPosition;
99  stripCl->setChannelsInPhi(channelsinPhi);
100  }
101 
102  return StatusCode::SUCCESS;
103  }
104 
105  ATH_MSG_DEBUG("Doing bulk copy");
106  // Doing bulk copy
107  // --------------------------
108  // Create the container and aux. container
109  // --------------------------
110  auto stripCl = std::make_unique<xAOD::StripClusterContainer>();
111  auto stripClAux = std::make_unique<xAOD::StripClusterAuxContainer>();
112  stripCl->setStore(stripClAux.get());
113 
114  // Pre-allocate memory for all clusters in the AuxContainer
115  // and reserve the same space in the container.
116  const size_t nClusters = metadata->numOfStripClusters;
117  stripClAux->resize(nClusters);
118  stripCl->reserve(nClusters);
119 
120  // Now, push back the objects
121  // and create them all at once.
122  // Note, that no data is set yet,
123  // we will do that in the next step.
124  for (size_t i = 0; i < nClusters; ++i) {
125  stripCl->push_back(std::make_unique<xAOD::StripCluster>());
126  }
127 
128  // --------------------------
129  // Prepare local buffers for each of the
130  // fixed-size attributes.
131  // --------------------------
133  const size_t offset = 8;
134 
135  // Allocate output buffers
136  std::vector<unsigned int> idHashBuffer(nClusters);
137  std::vector<long unsigned int> identifierBuffer(nClusters);
138  std::vector<std::array<float, 1>> localPosX(nClusters);
139  std::vector<std::array<float, 1>> localCovXX(nClusters);
140  std::vector<std::array<float, 3>> gpBuffer(nClusters);
141  std::vector<int> channelsInPhiBuffer(nClusters);
142 
143  // RDO accessor
144  static const SG::Accessor<std::vector<unsigned long long>> rdoListAcc("rdoList");
145  auto rdoSpan = rdoListAcc.getDataSpan(*stripCl);
146 
147  // Raw pointer to cluster data
148  const auto* base = stripClusters;
149 
150  // Row pointers
151  const auto* idHashPtr = base + 0 * N + offset;
152  const auto* identifierPtr = base + 1 * N + offset;
153  const uint64_t* rdoPtrs[4] = {
154  base + 2 * N + offset,
155  base + 3 * N + offset,
156  base + 4 * N + offset,
157  base + 5 * N + offset
158  };
159  const auto* localPosXPtr = base + 6 * N + offset;
160  const auto* localCovXXPtr = base + 8 * N + offset;
161  const auto* gpXPtr = base + 9 * N + offset;
162  const auto* gpYPtr = base + 10 * N + offset;
163  const auto* gpZPtr = base + 11 * N + offset;
164  const auto* channelsPhiPtr = base + 12 * N + offset;
165 
166  // Loop over clusters
167  for (size_t i = 0; i < nClusters; ++i) {
168  idHashBuffer[i] = static_cast<unsigned int>(idHashPtr[i]);
169  identifierBuffer[i] = static_cast<unsigned long>(identifierPtr[i]);
170 
171  // RDOs: push non-zero entries into the cluster's list
172  std::vector<unsigned long long>& rdoList = rdoSpan[i];
173  for (int r = 0; r < 4; ++r) {
174  if (!rdoPtrs[r][i]) continue;
175  unsigned long long rdo = static_cast<unsigned long long>(rdoPtrs[r][i]);
176  rdoList.push_back(rdo);
177  }
178 
179  localPosX[i][0] = static_cast<float>(std::bit_cast<double>(localPosXPtr[i]));
180  localCovXX[i][0] = static_cast<float>(std::bit_cast<double>(localCovXXPtr[i]));
181 
182  gpBuffer[i][0] = static_cast<float>(std::bit_cast<double>(gpXPtr[i]));
183  gpBuffer[i][1] = static_cast<float>(std::bit_cast<double>(gpYPtr[i]));
184  gpBuffer[i][2] = static_cast<float>(std::bit_cast<double>(gpZPtr[i]));
185 
186  channelsInPhiBuffer[i] = static_cast<int>(channelsPhiPtr[i]);
187  }
188 
189 
190  // --------------------------
191  // Now, use SG::Accessors to do a bulk copy into
192  // the container memory.
193  // --------------------------
194 
195  // FIXED-SIZE ATTRIBUTES
196  static const SG::Accessor<long unsigned int> idAcc("identifier");
197  static const SG::Accessor<unsigned int> idHashAcc("identifierHash");
198  static const SG::Accessor<std::array<float, 1>> localPosXAcc("localPositionDim1");
199  static const SG::Accessor<std::array<float, 1>> localCovXXAcc("localCovarianceDim1");
200  static const SG::Accessor<int> channelsInPhiAcc("channelsInPhi");
201 
202  // VARIABLE-LENGTH ATTRIBUTES
203  static const SG::Accessor<std::array<float, 3>> globalPosAcc("globalPosition");
204 
205  // Get spans into the container
206  auto idSpan = idAcc.getDataSpan(*stripCl);
207  auto idHashSpan = idHashAcc.getDataSpan(*stripCl);
208  auto locPosXSpan = localPosXAcc.getDataSpan(*stripCl);
209  auto locCovXXSpan = localCovXXAcc.getDataSpan(*stripCl);
210  auto channelsInPhiSpan = channelsInPhiAcc.getDataSpan(*stripCl);
211  auto gpSpan = globalPosAcc.getDataSpan(*stripCl);
212 
213  // Bulk copy the fixed-size attributes
214  CxxUtils::copy_bounded(identifierBuffer, idSpan);
215  CxxUtils::copy_bounded(idHashBuffer, idHashSpan);
216  CxxUtils::copy_bounded(localPosX, locPosXSpan);
217  CxxUtils::copy_bounded(localCovXX, locCovXXSpan);
218  CxxUtils::copy_bounded(gpBuffer, gpSpan);
219  CxxUtils::copy_bounded(channelsInPhiBuffer, channelsInPhiSpan);
220 
221 
222  ATH_CHECK(stripClustersHandle.record(std::move(stripCl), std::move(stripClAux)));
223 
224  return StatusCode::SUCCESS;
225 }

Member Data Documentation

◆ m_chronoSvc

ServiceHandle<IChronoStatSvc> xAODClusterMaker::m_chronoSvc {this, "ChronoStatSvc", "ChronoStatSvc"}
private

Definition at line 106 of file xAODClusterMaker.h.

◆ m_doBulkCopy

Gaudi::Property<bool> xAODClusterMaker::m_doBulkCopy {this, "DoBulkCopy", true, "Do bulk copy"}
private

Do bulk copy method.

Definition at line 104 of file xAODClusterMaker.h.

◆ m_pixelClustersKey

SG::WriteHandleKey<xAOD::PixelClusterContainer> xAODClusterMaker::m_pixelClustersKey
private
Initial value:
{
this, "PixelClusterContainerKey", "FPGAPixelClusters",
"Key for output pixel cluster container"}

Key for the pixel clusters container to be created.

Definition at line 95 of file xAODClusterMaker.h.

◆ m_stripClustersKey

SG::WriteHandleKey<xAOD::StripClusterContainer> xAODClusterMaker::m_stripClustersKey
private
Initial value:
{
this, "StripClusterContainerKey", "FPGAStripClusters",
"Key for output strip cluster container"}

Key for the strip clusters container to be created.

Definition at line 100 of file xAODClusterMaker.h.


The documentation for this class was generated from the following files:
base
std::string base
Definition: hcg.cxx:78
beamspotman.r
def r
Definition: beamspotman.py:674
EFTrackingTransient::PixelClusterAuxInput::localPosition
std::vector< float > localPosition
Definition: EFTrackingTransient.h:229
xAODClusterMaker::m_pixelClustersKey
SG::WriteHandleKey< xAOD::PixelClusterContainer > m_pixelClustersKey
Key for the pixel clusters container to be created.
Definition: xAODClusterMaker.h:95
EFTrackingTransient::PixelClusterAuxInput::channelsInEta
std::vector< int > channelsInEta
Definition: EFTrackingTransient.h:234
xAODClusterMaker::m_doBulkCopy
Gaudi::Property< bool > m_doBulkCopy
Do bulk copy method.
Definition: xAODClusterMaker.h:104
EFTrackingTransient::StripClusterAuxInput::globalPosition
std::vector< float > globalPosition
Definition: EFTrackingTransient.h:216
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
EFTrackingTransient::MAX_NUM_CLUSTERS
constexpr unsigned int MAX_NUM_CLUSTERS
Definition: EFTrackingTransient.h:27
EFTrackingTransient::StripClusterAuxInput::localCovariance
std::vector< float > localCovariance
Definition: EFTrackingTransient.h:213
TRT::Hit::globalZ
@ globalZ
Definition: HitInfo.h:39
keylayer_zslicemap.row
row
Definition: keylayer_zslicemap.py:155
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
EFTrackingTransient::StripClusterAuxInput::rdoList
std::vector< unsigned long long > rdoList
Definition: EFTrackingTransient.h:217
python.checkMetadata.metadata
metadata
Definition: checkMetadata.py:175
xAODClusterMaker::m_stripClustersKey
SG::WriteHandleKey< xAOD::StripClusterContainer > m_stripClustersKey
Key for the strip clusters container to be created.
Definition: xAODClusterMaker.h:100
Athena::Chrono
Exception-safe IChronoSvc caller.
Definition: Chrono.h:50
EFTrackingTransient::PixelClusterAuxInput::rdoList
std::vector< unsigned long long > rdoList
Definition: EFTrackingTransient.h:232
lumiFormat.i
int i
Definition: lumiFormat.py:85
EFTrackingTransient::PixelClusterAuxInput::localCovariance
std::vector< float > localCovariance
Definition: EFTrackingTransient.h:230
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
EFTrackingTransient::StripClusterAuxInput::idHash
std::vector< unsigned int > idHash
Definition: EFTrackingTransient.h:214
CxxUtils::copy_bounded
OutputIterator copy_bounded(InputIterator begi, InputIterator endi, OutputIterator bego, OutputIterator endo)
Copy a range with bounds restriction.
Definition: copy_bounded.h:79
EFTrackingTransient::PixelClusterAuxInput::totalToT
std::vector< int > totalToT
Definition: EFTrackingTransient.h:237
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EFTrackingTransient::PixelClusterAuxInput::idHash
std::vector< unsigned int > idHash
Definition: EFTrackingTransient.h:228
EFTrackingTransient::StripClusterAuxInput::localPosition
std::vector< float > localPosition
Definition: EFTrackingTransient.h:212
EFTrackingTransient::PixelClusterAuxInput::channelsInPhi
std::vector< int > channelsInPhi
Definition: EFTrackingTransient.h:233
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
EFTrackingTransient::PixelClusterAuxInput::id
std::vector< long unsigned int > id
Definition: EFTrackingTransient.h:227
EFTrackingTransient::PixelClusterAuxInput::widthInEta
std::vector< float > widthInEta
Definition: EFTrackingTransient.h:235
EFTrackingTransient::PixelClusterAuxInput::globalPosition
std::vector< float > globalPosition
Definition: EFTrackingTransient.h:231
EFTrackingTransient::StripClusterAuxInput::id
std::vector< long unsigned int > id
Definition: EFTrackingTransient.h:215
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
EFTrackingTransient::StripClusterAuxInput::channelsInPhi
std::vector< int > channelsInPhi
Definition: EFTrackingTransient.h:218
xAODClusterMaker::m_chronoSvc
ServiceHandle< IChronoStatSvc > m_chronoSvc
Definition: xAODClusterMaker.h:106
Identifier
Definition: IdentifierFieldParser.cxx:14