Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 makePixelClusterContainer (const EFTrackingTransient::PixelClusterAuxInput &pxAux, 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()

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 88 of file xAODClusterMaker.cxx.

91  {
92  ATH_MSG_DEBUG("Making xAOD::PixelClusterContainer");
93 
94 
96  m_pixelClustersKey, ctx};
97 
98  if (!m_doBulkCopy) {
99  // --------------------------------------------------------------------
100  // proceed with the element-wise method
101  // --------------------------------------------------------------------
102  ATH_MSG_DEBUG("You are running the element-wise container creation method.");
103  Athena::Chrono chrono("ElementWiseMethod", m_chronoSvc.get());
104 
105  ATH_CHECK(pixelClustersHandle.record(
106  std::make_unique<xAOD::PixelClusterContainer>(),
107  std::make_unique<xAOD::PixelClusterAuxContainer>()));
108 
109  ATH_CHECK(pixelClustersHandle.isValid());
110  ATH_MSG_DEBUG("Container '" << m_pixelClustersKey << "' initialised");
111 
112  int rdoIndex_counter = 0;
113 
114  for (unsigned int i = 0; i < metadata->numOfPixelClusters; i++) {
115  // Push back numClusters of PixelCluster
116  auto pixelCl = pixelClustersHandle->push_back(
117  std::make_unique<xAOD::PixelCluster>());
118 
119  Eigen::Matrix<float, 2, 1> localPosition(
120  pxAux.localPosition[i * 2], pxAux.localPosition[i * 2 + 1]);
121  Eigen::Matrix<float, 2, 2> localCovariance;
122  localCovariance.setZero();
123  localCovariance(0, 0) = pxAux.localCovariance[i * 2];
124  localCovariance(1, 1) = pxAux.localCovariance[i * 2 + 1];
125  Eigen::Matrix<float, 3, 1> globalPosition(
126  pxAux.globalPosition[i * 3], pxAux.globalPosition[i * 3 + 1],
127  pxAux.globalPosition[i * 3 + 2]);
128 
129  std::vector<Identifier> RDOs;
130  RDOs.reserve(metadata->pcRdoIndex[i]);
131  // Cover RDO
132  for (unsigned int j = 0; j < metadata->pcRdoIndex[i]; ++j) {
133  RDOs.push_back(Identifier(pxAux.rdoList[rdoIndex_counter + j]));
134  }
135 
136  rdoIndex_counter += metadata->pcRdoIndex[i];
137 
138  pixelCl->setMeasurement<2>(pxAux.idHash[i], localPosition,
139  localCovariance);
140  pixelCl->setIdentifier(pxAux.id[i]);
141  pixelCl->setRDOlist(RDOs);
142  pixelCl->globalPosition() = globalPosition;
143  pixelCl->setTotalToT(pxAux.totalToT[i]);
144  pixelCl->setChannelsInPhiEta(pxAux.channelsInPhi[i],
145  pxAux.channelsInEta[i]);
146  pixelCl->setWidthInEta(pxAux.widthInEta[i]);
147  pixelCl->setOmegas(pxAux.omegaX[i], pxAux.omegaY[i]);
148  }
149  return StatusCode::SUCCESS;
150  }
151 
152  // --------------------------------------------------------------------
153  // proceed with the bulk copy method
154  // --------------------------------------------------------------------
155 
156  ATH_MSG_DEBUG("You are running the bulk copy container creation method.");
157  Athena::Chrono chrono("BulkCopyMethod", m_chronoSvc.get());
158 
159  // --------------------------
160  // Create the container and aux. container
161  // --------------------------
162  auto pixelCl = std::make_unique<xAOD::PixelClusterContainer>();
163  auto pixelClAux = std::make_unique<xAOD::PixelClusterAuxContainer>();
164  pixelCl->setStore(pixelClAux.get());
165 
166  // Pre-allocate memory for all clusters in the AuxContainer
167  // and reserve the same space in the container.
168  const size_t nClusters = metadata->numOfPixelClusters;
169  pixelClAux->resize(nClusters);
170  pixelCl->reserve(nClusters);
171 
172  // Now, push back the PixelCluster objects
173  // and create them all at once.
174  // Note, that no data is set yet,
175  // we will do that in the next step.
176  for (size_t i = 0; i < nClusters; ++i) {
177  pixelCl->push_back(std::make_unique<xAOD::PixelCluster>());
178  }
179 
180  // --------------------------
181  // Prepare local buffers for each of the
182  // fixed-size attributes.
183  // --------------------------
184  std::vector<long unsigned int> identifierBuffer(nClusters);
185  std::vector<unsigned int> idHashBuffer(nClusters);
186  std::vector<std::array<float, 3>> gpBuffer(nClusters);
187  std::vector<float> localPosX(nClusters);
188  std::vector<float> localPosY(nClusters);
189  std::vector<float> localCovXX(nClusters);
190  std::vector<float> localCovYY(nClusters);
191  std::vector<int> totalToTBuffer(nClusters);
192  std::vector<float> widthInEtaBuffer(nClusters);
193  std::vector<float> omegaXBuffer(nClusters);
194  std::vector<float> omegaYBuffer(nClusters);
195  std::vector<int> channelsInPhiBuffer(nClusters);
196  std::vector<int> channelsInEtaBuffer(nClusters);
197 
198  for (size_t i = 0; i < nClusters; ++i) {
199 
200  // Fill the identifierBuffer
201  identifierBuffer[i] = pxAux.id[i];
202 
203  // Fill the idHashBuffer
204  idHashBuffer[i] = pxAux.idHash[i];
205 
206  // Fill the globalPositionBuffers
207  gpBuffer[i] = {
208  pxAux.globalPosition[3 * i],
209  pxAux.globalPosition[3 * i + 1],
210  pxAux.globalPosition[3 * i + 2],
211  };
212 
213  // Fill the localPositionBuffers
214  localPosX[i] = pxAux.localPosition[2 * i];
215  localPosY[i] = pxAux.localPosition[2 * i + 1];
216 
217  // Fill the localCovBuffer[i]
218  localCovXX[i] = pxAux.localCovariance[2 * i];
219  localCovYY[i] = pxAux.localCovariance[2 * i + 1];
220 
221  // Fill the totalToTBuffer
222  totalToTBuffer[i] = pxAux.totalToT[i];
223 
224  // Fill the widthInEtaBuffer
225  widthInEtaBuffer[i] = pxAux.widthInEta[i];
226 
227  // Fill the omegaBuffer
228  omegaXBuffer[i] = pxAux.omegaX[i];
229  omegaYBuffer[i] = pxAux.omegaY[i];
230 
231  // Fill the channelsInPhiEtaBuffer
232  channelsInPhiBuffer[i] = pxAux.channelsInPhi[i];
233  channelsInEtaBuffer[i] = pxAux.channelsInEta[i];
234  }
235 
236  // --------------------------
237  // Now, use SG::Accessors to do a bulk copy into
238  // the container memory.
239  // --------------------------
240 
241  // FIXED-SIZE ATTRIBUTES
242  static const SG::Accessor<long unsigned int> idAcc("identifier");
243  static const SG::Accessor<unsigned int> idHashAcc("idHash");
244  static const SG::Accessor<float> localPosXAcc("localPositionX");
245  static const SG::Accessor<float> localPosYAcc("localPositionY");
246  static const SG::Accessor<float> localCovXXAcc("localCovarianceXX");
247  static const SG::Accessor<float> localCovYYAcc("localCovarianceYY");
248  static const SG::Accessor<int> totAcc("totalToT");
249  static const SG::Accessor<float> widthEtaAcc("widthInEta");
250  static const SG::Accessor<float> omegaXAcc("omegasX");
251  static const SG::Accessor<float> omegaYAcc("omegasY");
252  static const SG::Accessor<int> channelsInPhiAcc("channelsInPhi");
253  static const SG::Accessor<int> channelsInEtaAcc("channelsInEta");
254 
255  // VARIABLE-LENGTH ATTRIBUTES
256  static const SG::Accessor<std::array<float, 3>> globalPosAcc(
257  "globalPosition");
258 
259  // Get spans into the container
260  auto idSpan = idAcc.getDataSpan(*pixelCl);
261  auto idHashSpan = idHashAcc.getDataSpan(*pixelCl);
262  auto locPosXSpan = localPosXAcc.getDataSpan(*pixelCl);
263  auto locPosYSpan = localPosYAcc.getDataSpan(*pixelCl);
264  auto locCovXXSpan = localCovXXAcc.getDataSpan(*pixelCl);
265  auto locCovYYSpan = localCovYYAcc.getDataSpan(*pixelCl);
266  auto totSpan = totAcc.getDataSpan(*pixelCl);
267  auto wEtaSpan = widthEtaAcc.getDataSpan(*pixelCl);
268  auto omegaXSpan = omegaXAcc.getDataSpan(*pixelCl);
269  auto omegaYSpan = omegaYAcc.getDataSpan(*pixelCl);
270  auto gpSpan = globalPosAcc.getDataSpan(*pixelCl);
271  auto channelsInPhiSpan = channelsInPhiAcc.getDataSpan(*pixelCl);
272  auto channelsInEtaSpan = channelsInEtaAcc.getDataSpan(*pixelCl);
273 
274  // Bulk copy the fixed-size attributes
275  CxxUtils::copy_bounded(identifierBuffer, idSpan);
276  CxxUtils::copy_bounded(idHashBuffer, idHashSpan);
277  CxxUtils::copy_bounded(localPosX, locPosXSpan);
278  CxxUtils::copy_bounded(localPosY, locPosYSpan);
279  CxxUtils::copy_bounded(localCovXX, locCovXXSpan);
280  CxxUtils::copy_bounded(localCovYY, locCovYYSpan);
281  CxxUtils::copy_bounded(totalToTBuffer, totSpan);
282  CxxUtils::copy_bounded(widthInEtaBuffer, wEtaSpan);
283  CxxUtils::copy_bounded(omegaXBuffer, omegaXSpan);
284  CxxUtils::copy_bounded(omegaYBuffer, omegaYSpan);
285  CxxUtils::copy_bounded(gpBuffer, gpSpan);
286  CxxUtils::copy_bounded(channelsInPhiBuffer, channelsInPhiSpan);
287  CxxUtils::copy_bounded(channelsInEtaBuffer, channelsInEtaSpan);
288 
289  // --------------------------
290  // Copy the variable-length data.
291  // We need to loop over the number of
292  // clusters to get access to each
293  // element.
294  // --------------------------
295  static const SG::Accessor<std::vector<unsigned long long>> rdoListAcc(
296  "rdoList");
297  auto rdoSpan = rdoListAcc.getDataSpan(*pixelCl);
298 
299  int rdoIndex_counter = 0;
300  // loop over the clusters
301  for (size_t i = 0; i < nClusters; ++i) {
302  size_t nRDOs = metadata->pcRdoIndex[i];
303 
304  // direct ref to destination vector
305  std::vector<unsigned long long> &rdosForThisCluster = rdoSpan[i];
306 
307  // pre-size the vector
308  rdosForThisCluster.resize(nRDOs);
309 
310  // direct element access
311  for (size_t j = 0; j < nRDOs; ++j) {
312  rdosForThisCluster[j] = pxAux.rdoList[rdoIndex_counter + j];
313  }
314  rdoIndex_counter += nRDOs;
315  }
316  // --------------------------
317  // Record the container + aux container into StoreGate,
318  // but now we do it AFTER filling the container!
319  // --------------------------
320 
321  ATH_CHECK(
322  pixelClustersHandle.record(std::move(pixelCl), std::move(pixelClAux)));
323 
324  ATH_MSG_DEBUG("Bulk copy for fixed-size variables done.");
325  return StatusCode::SUCCESS;
326 }

◆ makeStripClusterContainer()

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 37 of file xAODClusterMaker.cxx.

40  {
41  ATH_MSG_DEBUG("Making xAOD::StripClusterContainer");
42 
44  m_stripClustersKey, ctx};
45 
46  ATH_CHECK(stripClustersHandle.record(
47  std::make_unique<xAOD::StripClusterContainer>(),
48  std::make_unique<xAOD::StripClusterAuxContainer>()));
49 
50  int rdoIndex_counter = 0;
51 
52  for (unsigned int i = 0; i < metadata->numOfStripClusters; i++) {
53  // Push back numClusters of StripCluster
54  auto stripCl =
55  stripClustersHandle->push_back(std::make_unique<xAOD::StripCluster>());
56 
57  // Build Matrix
58  Eigen::Matrix<float, 1, 1> localPosition;
59  Eigen::Matrix<float, 1, 1> localCovariance;
60 
61  localPosition(0, 0) = scAux.localPosition.at(i);
62  localCovariance(0, 0) = scAux.localCovariance.at(i);
63 
64  Eigen::Matrix<float, 3, 1> globalPosition(
65  scAux.globalPosition.at(i * 3), scAux.globalPosition.at(i * 3 + 1),
66  scAux.globalPosition.at(i * 3 + 2));
67 
68  std::vector<Identifier> RDOs;
69  RDOs.reserve(metadata->scRdoIndex[i]);
70  // Cover RDO
71  for (unsigned int j = 0; j < metadata->scRdoIndex[i]; ++j) {
72  RDOs.push_back(Identifier(scAux.rdoList.at(rdoIndex_counter + j)));
73  }
74 
75  rdoIndex_counter += metadata->scRdoIndex[i];
76 
77  stripCl->setMeasurement<1>(scAux.idHash.at(i), localPosition,
78  localCovariance);
79  stripCl->setIdentifier(scAux.id.at(i));
80  stripCl->setRDOlist(RDOs);
81  stripCl->globalPosition() = globalPosition;
82  stripCl->setChannelsInPhi(scAux.channelsInPhi.at(i));
83  }
84 
85  return StatusCode::SUCCESS;
86 }

Member Data Documentation

◆ m_chronoSvc

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

Definition at line 80 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 78 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 69 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 74 of file xAODClusterMaker.h.


The documentation for this class was generated from the following files:
EFTrackingTransient::PixelClusterAuxInput::localPosition
std::vector< float > localPosition
Definition: EFTrackingTransient.h:225
xAODClusterMaker::m_pixelClustersKey
SG::WriteHandleKey< xAOD::PixelClusterContainer > m_pixelClustersKey
Key for the pixel clusters container to be created.
Definition: xAODClusterMaker.h:69
EFTrackingTransient::PixelClusterAuxInput::channelsInEta
std::vector< int > channelsInEta
Definition: EFTrackingTransient.h:230
xAODClusterMaker::m_doBulkCopy
Gaudi::Property< bool > m_doBulkCopy
Do bulk copy method.
Definition: xAODClusterMaker.h:78
EFTrackingTransient::StripClusterAuxInput::globalPosition
std::vector< float > globalPosition
Definition: EFTrackingTransient.h:212
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::StripClusterAuxInput::localCovariance
std::vector< float > localCovariance
Definition: EFTrackingTransient.h:209
EFTrackingTransient::StripClusterAuxInput::rdoList
std::vector< unsigned long long > rdoList
Definition: EFTrackingTransient.h:213
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:74
Athena::Chrono
Exception-safe IChronoSvc caller.
Definition: Chrono.h:50
EFTrackingTransient::PixelClusterAuxInput::rdoList
std::vector< unsigned long long > rdoList
Definition: EFTrackingTransient.h:228
lumiFormat.i
int i
Definition: lumiFormat.py:85
EFTrackingTransient::PixelClusterAuxInput::localCovariance
std::vector< float > localCovariance
Definition: EFTrackingTransient.h:226
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
EFTrackingTransient::StripClusterAuxInput::idHash
std::vector< unsigned int > idHash
Definition: EFTrackingTransient.h:210
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:235
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EFTrackingTransient::PixelClusterAuxInput::idHash
std::vector< unsigned int > idHash
Definition: EFTrackingTransient.h:224
EFTrackingTransient::StripClusterAuxInput::localPosition
std::vector< float > localPosition
Definition: EFTrackingTransient.h:208
EFTrackingTransient::PixelClusterAuxInput::channelsInPhi
std::vector< int > channelsInPhi
Definition: EFTrackingTransient.h:229
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
EFTrackingTransient::PixelClusterAuxInput::id
std::vector< long unsigned int > id
Definition: EFTrackingTransient.h:223
EFTrackingTransient::PixelClusterAuxInput::widthInEta
std::vector< float > widthInEta
Definition: EFTrackingTransient.h:231
EFTrackingTransient::PixelClusterAuxInput::globalPosition
std::vector< float > globalPosition
Definition: EFTrackingTransient.h:227
EFTrackingTransient::StripClusterAuxInput::id
std::vector< long unsigned int > id
Definition: EFTrackingTransient.h:211
EFTrackingTransient::StripClusterAuxInput::channelsInPhi
std::vector< int > channelsInPhi
Definition: EFTrackingTransient.h:214
xAODClusterMaker::m_chronoSvc
ServiceHandle< IChronoStatSvc > m_chronoSvc
Definition: xAODClusterMaker.h:80
EFTrackingTransient::PixelClusterAuxInput::omegaX
std::vector< float > omegaX
Definition: EFTrackingTransient.h:232
EFTrackingTransient::PixelClusterAuxInput::omegaY
std::vector< float > omegaY
Definition: EFTrackingTransient.h:233
Identifier
Definition: IdentifierFieldParser.cxx:14