ATLAS Offline Software
xAODContainerMaker.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
12 #include "xAODContainerMaker.h"
13 
14 #include "Identifier/Identifier.h"
15 #include "StoreGate/WriteHandle.h"
19 
21  ATH_MSG_INFO("Initializing xAODContainerMaker tool");
22 
23  ATH_CHECK(m_pixelClustersKey.initialize());
24  ATH_CHECK(m_stripClustersKey.initialize());
25  ATH_CHECK(m_stripSpacePointsKey.initialize());
26  ATH_CHECK(m_pixelSpacePointsKey.initialize());
27 
28  return StatusCode::SUCCESS;
29 }
30 
34  const EventContext &ctx) const {
35  ATH_MSG_DEBUG("Making xAOD::StripClusterContainer");
36 
38  m_stripClustersKey, ctx};
39 
40  ATH_CHECK(stripClustersHandle.record(
41  std::make_unique<xAOD::StripClusterContainer>(),
42  std::make_unique<xAOD::StripClusterAuxContainer>()));
43 
44  int rdoIndex_counter = 0;
45 
46  for (unsigned int i = 0; i < metadata->numOfStripClusters; i++) {
47  // Puch back numClusters of StripCluster
48  auto stripCl =
49  stripClustersHandle->push_back(std::make_unique<xAOD::StripCluster>());
50 
51  // Build Matrix
52  Eigen::Matrix<float, 1, 1> localPosition;
53  Eigen::Matrix<float, 1, 1> localCovariance;
54 
55  localPosition(0, 0) = scAux.localPosition.at(i);
56  localCovariance(0, 0) = scAux.localCovariance.at(i);
57 
58  Eigen::Matrix<float, 3, 1> globalPosition(
59  scAux.globalPosition.at(i * 3), scAux.globalPosition.at(i * 3 + 1),
60  scAux.globalPosition.at(i * 3 + 2));
61 
62  std::vector<Identifier> RDOs;
63  RDOs.reserve(metadata->scRdoIndex[i]);
64  // Cover RDO
65  for (unsigned int j = 0; j < metadata->scRdoIndex[i]; ++j) {
66  RDOs.push_back(Identifier(scAux.rdoList.at(rdoIndex_counter + j)));
67  }
68 
69  rdoIndex_counter += metadata->scRdoIndex[i];
70 
71  stripCl->setMeasurement<1>(scAux.idHash.at(i), localPosition,
72  localCovariance);
73  stripCl->setIdentifier(scAux.id.at(i));
74  stripCl->setRDOlist(RDOs);
75  stripCl->globalPosition() = globalPosition;
76  stripCl->setChannelsInPhi(scAux.channelsInPhi.at(i));
77  }
78 
79  return StatusCode::SUCCESS;
80 }
81 
85  const EventContext &ctx) const {
86  ATH_MSG_DEBUG("Making xAOD::PixelClusterContainer");
87 
89  m_pixelClustersKey, ctx};
90 
91  ATH_CHECK(pixelClustersHandle.record(
92  std::make_unique<xAOD::PixelClusterContainer>(),
93  std::make_unique<xAOD::PixelClusterAuxContainer>()));
94 
95  ATH_CHECK(pixelClustersHandle.isValid());
96  ATH_MSG_DEBUG("Container '" << m_pixelClustersKey << "' initialised");
97 
98  int rdoIndex_counter = 0;
99  int totListIndex_counter = 0;
100  int chargeListIndex_counter = 0;
101 
102  for (unsigned int i = 0; i < metadata->numOfPixelClusters; i++) {
103  // Puch back numClusters of PixelCluster
104  auto pixelCl =
105  pixelClustersHandle->push_back(std::make_unique<xAOD::PixelCluster>());
106 
107  Eigen::Matrix<float, 2, 1> localPosition(pxAux.localPosition.at(i * 2),
108  pxAux.localPosition.at(i * 2 + 1));
109  Eigen::Matrix<float, 2, 2> localCovariance;
110  localCovariance.setZero();
111  localCovariance(0, 0) = pxAux.localCovariance.at(i * 2);
112  localCovariance(1, 1) = pxAux.localCovariance.at(i * 2 + 1);
113  Eigen::Matrix<float, 3, 1> globalPosition(
114  pxAux.globalPosition.at(i * 3), pxAux.globalPosition.at(i * 3 + 1),
115  pxAux.globalPosition.at(i * 3 + 2));
116 
117  std::vector<Identifier> RDOs;
118  RDOs.reserve(metadata->pcRdoIndex[i]);
119  // Cover RDO
120  for (unsigned int j = 0; j < metadata->pcRdoIndex[i]; ++j) {
121  RDOs.push_back(Identifier(pxAux.rdoList.at(rdoIndex_counter + j)));
122  }
123 
124  std::vector<int> vec_totList;
125  vec_totList.reserve(metadata->pcTotIndex[i]);
126  for (unsigned int j = 0; j < metadata->pcTotIndex[i]; ++j) {
127  vec_totList.push_back(pxAux.totList.at(totListIndex_counter + j));
128  }
129 
130  std::vector<float> vec_chargeList;
131  vec_chargeList.reserve(metadata->pcChargeIndex[i]);
132  for (unsigned int k = 0; k < metadata->pcChargeIndex[i]; ++k) {
133  vec_chargeList.push_back(pxAux.totList.at(chargeListIndex_counter + k));
134  }
135 
136  rdoIndex_counter += metadata->pcRdoIndex[i];
137  totListIndex_counter += metadata->pcTotIndex[i];
138  chargeListIndex_counter += metadata->pcChargeIndex[i];
139 
140  pixelCl->setMeasurement<2>(pxAux.idHash.at(i), localPosition,
141  localCovariance);
142  pixelCl->setIdentifier(pxAux.id.at(i));
143  pixelCl->setRDOlist(RDOs);
144  pixelCl->globalPosition() = globalPosition;
145  pixelCl->setToTlist(vec_totList);
146  pixelCl->setTotalToT(pxAux.totalToT.at(i));
147  pixelCl->setChargelist(vec_chargeList);
148  pixelCl->setTotalCharge(pxAux.totalCharge.at(i));
149  pixelCl->setLVL1A(pxAux.lvl1a.at(i));
150  pixelCl->setChannelsInPhiEta(pxAux.channelsInPhi.at(i),
151  pxAux.channelsInEta.at(i));
152  pixelCl->setWidthInEta(pxAux.widthInEta.at(i));
153  pixelCl->setOmegas(pxAux.omegaX.at(i), pxAux.omegaY.at(i));
154  pixelCl->setIsSplit(pxAux.isSplit.at(i));
155  pixelCl->setSplitProbabilities(pxAux.splitProbability1.at(i),
156  pxAux.splitProbability2.at(i));
157  }
158  return StatusCode::SUCCESS;
159 }
160 
163  const std::vector<std::vector<const xAOD::UncalibratedMeasurement *>>
164  pixelsp_meas,
166  const EventContext &ctx) const {
167  ATH_MSG_DEBUG("Making xAOD::SpacePointContainer");
168 
169  SG::WriteHandle<xAOD::SpacePointContainer> pixelSpacePointsHandle{
170  m_pixelSpacePointsKey, ctx};
171 
172  ATH_CHECK(pixelSpacePointsHandle.record(
173  std::make_unique<xAOD::SpacePointContainer>(),
174  std::make_unique<xAOD::SpacePointAuxContainer>()));
175 
176  ATH_CHECK(pixelSpacePointsHandle.isValid());
177  ATH_MSG_DEBUG("Container '" << m_pixelSpacePointsKey << "' initialised");
178 
179  for (unsigned int i = 0; i < metadata->numOfPixelSpacePoints; i++) {
180  // Puch back numPixelSpacePoints of SpacePoint
181  auto pxsp =
182  pixelSpacePointsHandle->push_back(std::make_unique<xAOD::SpacePoint>());
183  Eigen::Matrix<float, 3, 1> globalPosition(
184  psAux.globalPosition.at(i * 3), psAux.globalPosition.at(i * 3 + 1),
185  psAux.globalPosition.at(i * 3 + 2));
186 
187  std::vector<const xAOD::UncalibratedMeasurement *> pixel_meas(
188  pixelsp_meas.at(i).size());
189  std::copy(pixelsp_meas.at(i).begin(), pixelsp_meas.at(i).end(),
190  pixel_meas.begin());
191 
192  pxsp->setSpacePoint(psAux.elementIdList.at(i), globalPosition,
193  psAux.varianceR.at(i), psAux.varianceZ.at(i),
194  pixel_meas);
195  }
196  return StatusCode::SUCCESS;
197 }
198 
201  const std::vector<std::vector<const xAOD::UncalibratedMeasurement *>>
202  stripsp_meas,
204  const EventContext &ctx) const {
205  ATH_MSG_DEBUG("Making xAOD::SpacePointContainer");
206 
207  SG::WriteHandle<xAOD::SpacePointContainer> stripSpacePointsHandle{
208  m_stripSpacePointsKey, ctx};
209 
210  ATH_CHECK(stripSpacePointsHandle.record(
211  std::make_unique<xAOD::SpacePointContainer>(),
212  std::make_unique<xAOD::SpacePointAuxContainer>()));
213 
214  ATH_CHECK(stripSpacePointsHandle.isValid());
215  ATH_MSG_DEBUG("Container '" << m_stripSpacePointsKey << "' initialised");
216 
217  for (unsigned int i = 0; i < metadata->numOfStripSpacePoints; i++) {
218  // Puch back numStripSpacePoints of SpacePoint
219  auto ssp =
220  stripSpacePointsHandle->push_back(std::make_unique<xAOD::SpacePoint>());
221 
222  Eigen::Matrix<float, 3, 1> globalPosition(
223  sspAux.globalPosition.at(i * 3), sspAux.globalPosition.at(i * 3 + 1),
224  sspAux.globalPosition.at(i * 3 + 2));
225 
226  std::vector<const xAOD::UncalibratedMeasurement *> strip_meas(
227  stripsp_meas.at(i).size());
228  std::copy(stripsp_meas.at(i).begin(), stripsp_meas.at(i).end(),
229  strip_meas.begin());
230 
231  float topHalfStripLength = sspAux.topHalfStripLength.at(i);
232  float bottomHalfStripLength = sspAux.bottomHalfStripLength.at(i);
233  Eigen::Matrix<float, 3, 1> topStripDirection(
234  sspAux.topStripDirection.at(i * 3),
235  sspAux.topStripDirection.at(i * 3 + 1),
236  sspAux.topStripDirection.at(i * 3 + 2));
237  Eigen::Matrix<float, 3, 1> bottomStripDirection(
238  sspAux.bottomStripDirection.at(i * 3),
239  sspAux.bottomStripDirection.at(i * 3 + 1),
240  sspAux.bottomStripDirection.at(i * 3 + 2));
241  Eigen::Matrix<float, 3, 1> stripCenterDistance(
242  sspAux.topStripCenter.at(i * 3), sspAux.topStripCenter.at(i * 3 + 1),
243  sspAux.topStripCenter.at(i * 3 + 2));
244  Eigen::Matrix<float, 3, 1> topStripCenter(
245  sspAux.topStripCenter.at(i * 3), sspAux.topStripCenter.at(i * 3 + 1),
246  sspAux.topStripCenter.at(i * 3 + 2));
247  ssp->setSpacePoint(
248  {sspAux.elementIdList.at(i), sspAux.elementIdList.at(i + 1)},
249  globalPosition, sspAux.varianceR.at(i), sspAux.varianceZ.at(i),
250  strip_meas, topHalfStripLength, bottomHalfStripLength,
251  topStripDirection, bottomStripDirection, stripCenterDistance,
252  topStripCenter);
253  }
254  return StatusCode::SUCCESS;
255 }
xAODContainerMaker::makeStripClusterContainer
StatusCode makeStripClusterContainer(const EFTrackingDataFormats::StripClusterAuxInput &scAux, const EFTrackingDataFormats::Metadata *metadata, const EventContext &ctx) const
Create xAOD::StripClusterContainer by creating xAOD::StripCluster objects one by one.
Definition: xAODContainerMaker.cxx:31
EFTrackingDataFormats::PixelClusterAuxInput::localCovariance
std::vector< float > localCovariance
Definition: EFTrackingDataFormats.h:204
EFTrackingDataFormats::StripClusterAuxInput
The StripClusterAuxInput struct is used to simplify the creaction of the xAOD::StripClusterContainer.
Definition: EFTrackingDataFormats.h:186
EFTrackingDataFormats::StripClusterAuxInput::localPosition
std::vector< float > localPosition
Definition: EFTrackingDataFormats.h:187
xAODContainerMaker::makePixelClusterContainer
StatusCode makePixelClusterContainer(const EFTrackingDataFormats::PixelClusterAuxInput &pxAux, const EFTrackingDataFormats::Metadata *metadata, const EventContext &ctx) const
Create xAOD::PixelClusterContainer by creating xAOD::PixelCluster objects one by one.
Definition: xAODContainerMaker.cxx:82
EFTrackingDataFormats::StripClusterAuxInput::globalPosition
std::vector< float > globalPosition
Definition: EFTrackingDataFormats.h:191
EFTrackingDataFormats::SpacePointAuxInput::varianceR
std::vector< float > varianceR
Definition: EFTrackingDataFormats.h:233
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
EFTrackingDataFormats::SpacePointAuxInput::varianceZ
std::vector< float > varianceZ
Definition: EFTrackingDataFormats.h:234
EFTrackingDataFormats::PixelClusterAuxInput
The PixelClusterAuxInput struct is used to simplify the creaction of the xAOD::PixelClusterContainer.
Definition: EFTrackingDataFormats.h:200
EFTrackingDataFormats::SpacePointAuxInput
The SpacePointAuxInput struct is used to simplify the creaction of the xAOD::SpacePointContainer.
Definition: EFTrackingDataFormats.h:229
EFTrackingDataFormats::PixelClusterAuxInput::localPosition
std::vector< float > localPosition
Definition: EFTrackingDataFormats.h:203
EFTrackingDataFormats::PixelClusterAuxInput::idHash
std::vector< unsigned int > idHash
Definition: EFTrackingDataFormats.h:202
EFTrackingDataFormats::PixelClusterAuxInput::totalCharge
std::vector< float > totalCharge
Definition: EFTrackingDataFormats.h:215
xAODContainerMaker.h
Tool for making xAOD container.
EFTrackingDataFormats::PixelClusterAuxInput::splitProbability2
std::vector< float > splitProbability2
Definition: EFTrackingDataFormats.h:219
EFTrackingDataFormats::StripClusterAuxInput::localCovariance
std::vector< float > localCovariance
Definition: EFTrackingDataFormats.h:188
EFTrackingDataFormats::SpacePointAuxInput::topHalfStripLength
std::vector< float > topHalfStripLength
Definition: EFTrackingDataFormats.h:235
xAODContainerMaker::m_stripSpacePointsKey
SG::WriteHandleKey< xAOD::SpacePointContainer > m_stripSpacePointsKey
Key for the Strip SpacePoint container.
Definition: xAODContainerMaker.h:82
python.checkMetadata.metadata
metadata
Definition: checkMetadata.py:175
EFTrackingDataFormats::PixelClusterAuxInput::channelsInPhi
std::vector< int > channelsInPhi
Definition: EFTrackingDataFormats.h:207
xAODContainerMaker::m_pixelSpacePointsKey
SG::WriteHandleKey< xAOD::SpacePointContainer > m_pixelSpacePointsKey
Key for the Pixel SpacePoint container.
Definition: xAODContainerMaker.h:79
EFTrackingDataFormats::PixelClusterAuxInput::isSplit
std::vector< char > isSplit
Definition: EFTrackingDataFormats.h:217
xAODContainerMaker::m_stripClustersKey
SG::WriteHandleKey< xAOD::StripClusterContainer > m_stripClustersKey
Key for the strip cluster container.
Definition: xAODContainerMaker.h:76
WriteHandle.h
Handle class for recording to StoreGate.
EFTrackingDataFormats::StripClusterAuxInput::id
std::vector< long unsigned int > id
Definition: EFTrackingDataFormats.h:190
EFTrackingDataFormats::Metadata
The structure of the Metadata containing data after clusterization.
Definition: EFTrackingDataFormats.h:102
EFTrackingDataFormats::PixelClusterAuxInput::globalPosition
std::vector< float > globalPosition
Definition: EFTrackingDataFormats.h:205
EFTrackingDataFormats::PixelClusterAuxInput::rdoList
std::vector< unsigned long long > rdoList
Definition: EFTrackingDataFormats.h:206
PixelClusterAuxContainer.h
EFTrackingDataFormats::PixelClusterAuxInput::omegaY
std::vector< float > omegaY
Definition: EFTrackingDataFormats.h:211
EFTrackingDataFormats::PixelClusterAuxInput::omegaX
std::vector< float > omegaX
Definition: EFTrackingDataFormats.h:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EFTrackingDataFormats::SpacePointAuxInput::bottomHalfStripLength
std::vector< float > bottomHalfStripLength
Definition: EFTrackingDataFormats.h:236
EFTrackingDataFormats::SpacePointAuxInput::globalPosition
std::vector< float > globalPosition
Definition: EFTrackingDataFormats.h:231
EFTrackingDataFormats::PixelClusterAuxInput::channelsInEta
std::vector< int > channelsInEta
Definition: EFTrackingDataFormats.h:208
EFTrackingDataFormats::StripClusterAuxInput::rdoList
std::vector< unsigned long long > rdoList
Definition: EFTrackingDataFormats.h:192
EFTrackingDataFormats::PixelClusterAuxInput::totList
std::vector< int > totList
Definition: EFTrackingDataFormats.h:212
SpacePointAuxContainer.h
EFTrackingDataFormats::SpacePointAuxInput::topStripCenter
std::vector< float > topStripCenter
Definition: EFTrackingDataFormats.h:240
EFTrackingDataFormats::PixelClusterAuxInput::id
std::vector< long unsigned int > id
Definition: EFTrackingDataFormats.h:201
StripClusterAuxContainer.h
EFTrackingDataFormats::PixelClusterAuxInput::lvl1a
std::vector< int > lvl1a
Definition: EFTrackingDataFormats.h:220
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
xAODContainerMaker::initialize
StatusCode initialize() override
Definition: xAODContainerMaker.cxx:20
EFTrackingDataFormats::SpacePointAuxInput::bottomStripDirection
std::vector< float > bottomStripDirection
Definition: EFTrackingDataFormats.h:238
EFTrackingDataFormats::StripClusterAuxInput::channelsInPhi
std::vector< int > channelsInPhi
Definition: EFTrackingDataFormats.h:193
EFTrackingDataFormats::SpacePointAuxInput::elementIdList
std::vector< unsigned int > elementIdList
Definition: EFTrackingDataFormats.h:230
EFTrackingDataFormats::PixelClusterAuxInput::splitProbability1
std::vector< float > splitProbability1
Definition: EFTrackingDataFormats.h:218
xAODContainerMaker::m_pixelClustersKey
SG::WriteHandleKey< xAOD::PixelClusterContainer > m_pixelClustersKey
Key for the pixel cluster container.
Definition: xAODContainerMaker.h:73
EFTrackingDataFormats::PixelClusterAuxInput::widthInEta
std::vector< float > widthInEta
Definition: EFTrackingDataFormats.h:209
calibdata.copy
bool copy
Definition: calibdata.py:27
EFTrackingDataFormats::PixelClusterAuxInput::totalToT
std::vector< int > totalToT
Definition: EFTrackingDataFormats.h:213
EFTrackingDataFormats::StripClusterAuxInput::idHash
std::vector< unsigned int > idHash
Definition: EFTrackingDataFormats.h:189
xAODContainerMaker::makePixelSpacePointContainer
StatusCode makePixelSpacePointContainer(const EFTrackingDataFormats::SpacePointAuxInput &psAux, const std::vector< std::vector< const xAOD::UncalibratedMeasurement * >> pixelsp_meas, const EFTrackingDataFormats::Metadata *metadata, const EventContext &ctx) const
Create xAOD::SpacePointContainer by creating xAOD::SpacePoint for Pixel SpacePoint objects one by one...
Definition: xAODContainerMaker.cxx:161
fitman.k
k
Definition: fitman.py:528
EFTrackingDataFormats::SpacePointAuxInput::topStripDirection
std::vector< float > topStripDirection
Definition: EFTrackingDataFormats.h:237
xAODContainerMaker::makeStripSpacePointContainer
StatusCode makeStripSpacePointContainer(const EFTrackingDataFormats::SpacePointAuxInput &sspAux, const std::vector< std::vector< const xAOD::UncalibratedMeasurement * >> stripsp_meas, const EFTrackingDataFormats::Metadata *metadata, const EventContext &ctx) const
Create xAOD::SpacePointContainer by creating xAOD::SpacePoint for Strip SpacePoint objects one by one...
Definition: xAODContainerMaker.cxx:199
Identifier
Definition: IdentifierFieldParser.cxx:14