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 
32  const int numClusters,
35  const EventContext &ctx) const {
36  ATH_MSG_DEBUG("Making xAOD::StripClusterContainer");
37 
39  m_stripClustersKey, ctx};
40 
41  ATH_CHECK(stripClustersHandle.record(
42  std::make_unique<xAOD::StripClusterContainer>(),
43  std::make_unique<xAOD::StripClusterAuxContainer>()));
44 
45  int rdoIndex_counter = 0;
46 
47  for (int i = 0; i < numClusters; i++) {
48  // Puch back numClusters of StripCluster
49  auto stripCl =
50  stripClustersHandle->push_back(std::make_unique<xAOD::StripCluster>());
51 
52  // Build Matrix
53  Eigen::Matrix<float, 1, 1> localPosition;
54  Eigen::Matrix<float, 1, 1> localCovariance;
55 
56  localPosition(0, 0) = scAux.localPosition.at(i);
57  localCovariance(0, 0) = scAux.localCovariance.at(i);
58 
59  Eigen::Matrix<float, 3, 1> globalPosition(
60  scAux.globalPosition.at(i * 3), scAux.globalPosition.at(i * 3 + 1),
61  scAux.globalPosition.at(i * 3 + 2));
62 
63  std::vector<Identifier> RDOs;
64  RDOs.reserve(meta->scRdoIndex[i]);
65  // Cover RDO
66  for (int j = 0; j < meta->scRdoIndex[i]; ++j) {
67  RDOs.push_back(Identifier(scAux.rdoList.at(rdoIndex_counter + j)));
68  }
69 
70  rdoIndex_counter += meta->scRdoIndex[i];
71 
72  stripCl->setMeasurement<1>(scAux.idHash.at(i), localPosition,
73  localCovariance);
74  stripCl->setIdentifier(scAux.id.at(i));
75  stripCl->setRDOlist(RDOs);
76  stripCl->globalPosition() = globalPosition;
77  stripCl->setChannelsInPhi(scAux.channelsInPhi.at(i));
78  }
79 
80  return StatusCode::SUCCESS;
81 }
82 
84  const int numClusters,
87  const EventContext &ctx) const {
88  ATH_MSG_DEBUG("Making xAOD::PixelClusterContainer");
89 
91  m_pixelClustersKey, ctx};
92 
93  ATH_CHECK(pixelClustersHandle.record(
94  std::make_unique<xAOD::PixelClusterContainer>(),
95  std::make_unique<xAOD::PixelClusterAuxContainer>()));
96 
97  ATH_CHECK(pixelClustersHandle.isValid());
98  ATH_MSG_DEBUG("Container '" << m_pixelClustersKey << "' initialised");
99 
100  int rdoIndex_counter = 0;
101  int totListIndex_counter = 0;
102  int chargeListIndex_counter = 0;
103 
104  for (int i = 0; i < numClusters; i++) {
105  // Puch back numClusters of PixelCluster
106  auto pixelCl =
107  pixelClustersHandle->push_back(std::make_unique<xAOD::PixelCluster>());
108 
109  Eigen::Matrix<float, 2, 1> localPosition(pxAux.localPosition.at(i * 2),
110  pxAux.localPosition.at(i * 2 + 1));
111  Eigen::Matrix<float, 2, 2> localCovariance;
112  localCovariance.setZero();
113  localCovariance(0, 0) = pxAux.localCovariance.at(i * 2);
114  localCovariance(1, 1) = pxAux.localCovariance.at(i * 2 + 1);
115  Eigen::Matrix<float, 3, 1> globalPosition(
116  pxAux.globalPosition.at(i * 3), pxAux.globalPosition.at(i * 3 + 1),
117  pxAux.globalPosition.at(i * 3 + 2));
118 
119  std::vector<Identifier> RDOs;
120  RDOs.reserve(meta->pcRdoIndex[i]);
121  // Cover RDO
122  for (int j = 0; j < meta->pcRdoIndex[i]; ++j) {
123  RDOs.push_back(Identifier(pxAux.rdoList.at(rdoIndex_counter + j)));
124  }
125 
126  std::vector<int> vec_totList;
127  vec_totList.reserve(meta->pcTotIndex[i]);
128  for (int j = 0; j < meta->pcTotIndex[i]; ++j) {
129  vec_totList.push_back(pxAux.totList.at(totListIndex_counter + j));
130  }
131 
132  std::vector<float> vec_chargeList;
133  vec_chargeList.reserve(meta->pcChargeIndex[i]);
134  for (int k = 0; k < meta->pcChargeIndex[i]; ++k) {
135  vec_chargeList.push_back(pxAux.totList.at(chargeListIndex_counter + k));
136  }
137 
138  rdoIndex_counter += meta->pcRdoIndex[i];
139  totListIndex_counter += meta->pcTotIndex[i];
140  chargeListIndex_counter += meta->pcChargeIndex[i];
141 
142  pixelCl->setMeasurement<2>(pxAux.idHash.at(i), localPosition,
143  localCovariance);
144  pixelCl->setIdentifier(pxAux.id.at(i));
145  pixelCl->setRDOlist(RDOs);
146  pixelCl->globalPosition() = globalPosition;
147  pixelCl->setToTlist(vec_totList);
148  pixelCl->setTotalToT(pxAux.totalToT.at(i));
149  pixelCl->setChargelist(vec_chargeList);
150  pixelCl->setTotalCharge(pxAux.totalCharge.at(i));
151  pixelCl->setLVL1A(pxAux.lvl1a.at(i));
152  pixelCl->setChannelsInPhiEta(pxAux.channelsInPhi.at(i),
153  pxAux.channelsInEta.at(i));
154  pixelCl->setWidthInEta(pxAux.widthInEta.at(i));
155  pixelCl->setOmegas(pxAux.omegaX.at(i), pxAux.omegaY.at(i));
156  pixelCl->setIsSplit(pxAux.isSplit.at(i));
157  pixelCl->setSplitProbabilities(pxAux.splitProbability1.at(i),
158  pxAux.splitProbability2.at(i));
159  }
160  return StatusCode::SUCCESS;
161 }
162 
164  const int numPixelSpacePoints,
166  const std::vector<std::vector<const xAOD::UncalibratedMeasurement *>>
167  pixelsp_meas,
168  const EventContext &ctx) const {
169  ATH_MSG_DEBUG("Making xAOD::SpacePointContainer");
170 
171  SG::WriteHandle<xAOD::SpacePointContainer> pixelSpacePointsHandle{
172  m_pixelSpacePointsKey, ctx};
173 
174  ATH_CHECK(pixelSpacePointsHandle.record(
175  std::make_unique<xAOD::SpacePointContainer>(),
176  std::make_unique<xAOD::SpacePointAuxContainer>()));
177 
178  ATH_CHECK(pixelSpacePointsHandle.isValid());
179  ATH_MSG_DEBUG("Container '" << m_pixelSpacePointsKey << "' initialised");
180 
181  for (int i = 0; i < numPixelSpacePoints; i++) {
182  // Puch back numPixelSpacePoints of SpacePoint
183  auto pxsp =
184  pixelSpacePointsHandle->push_back(std::make_unique<xAOD::SpacePoint>());
185  Eigen::Matrix<float, 3, 1> globalPosition(
186  psAux.globalPosition.at(i * 3), psAux.globalPosition.at(i * 3 + 1),
187  psAux.globalPosition.at(i * 3 + 2));
188 
189  std::vector<const xAOD::UncalibratedMeasurement *> pixel_meas(
190  pixelsp_meas.at(i).size());
191  std::copy(pixelsp_meas.at(i).begin(), pixelsp_meas.at(i).end(),
192  pixel_meas.begin());
193 
194  pxsp->setSpacePoint(psAux.elementIdList.at(i), globalPosition,
195  psAux.varianceR.at(i), psAux.varianceZ.at(i),
196  pixel_meas);
197  }
198  return StatusCode::SUCCESS;
199 }
200 
202  const int numStripSpacePoints,
204  const std::vector<std::vector<const xAOD::UncalibratedMeasurement *>>
205  stripsp_meas,
206  const EventContext &ctx) const {
207  ATH_MSG_DEBUG("Making xAOD::SpacePointContainer");
208 
209  SG::WriteHandle<xAOD::SpacePointContainer> stripSpacePointsHandle{
210  m_stripSpacePointsKey, ctx};
211 
212  ATH_CHECK(stripSpacePointsHandle.record(
213  std::make_unique<xAOD::SpacePointContainer>(),
214  std::make_unique<xAOD::SpacePointAuxContainer>()));
215 
216  ATH_CHECK(stripSpacePointsHandle.isValid());
217  ATH_MSG_DEBUG("Container '" << m_stripSpacePointsKey << "' initialised");
218 
219  for (int i = 0; i < numStripSpacePoints; i++) {
220  // Puch back numStripSpacePoints of SpacePoint
221  auto ssp =
222  stripSpacePointsHandle->push_back(std::make_unique<xAOD::SpacePoint>());
223 
224  Eigen::Matrix<float, 3, 1> globalPosition(
225  sspAux.globalPosition.at(i * 3), sspAux.globalPosition.at(i * 3 + 1),
226  sspAux.globalPosition.at(i * 3 + 2));
227 
228  std::vector<const xAOD::UncalibratedMeasurement *> strip_meas(
229  stripsp_meas.at(i).size());
230  std::copy(stripsp_meas.at(i).begin(), stripsp_meas.at(i).end(),
231  strip_meas.begin());
232 
233  float topHalfStripLength = sspAux.topHalfStripLength.at(i);
234  float bottomHalfStripLength = sspAux.bottomHalfStripLength.at(i);
235  Eigen::Matrix<float, 3, 1> topStripDirection(
236  sspAux.topStripDirection.at(i * 3),
237  sspAux.topStripDirection.at(i * 3 + 1),
238  sspAux.topStripDirection.at(i * 3 + 2));
239  Eigen::Matrix<float, 3, 1> bottomStripDirection(
240  sspAux.bottomStripDirection.at(i * 3),
241  sspAux.bottomStripDirection.at(i * 3 + 1),
242  sspAux.bottomStripDirection.at(i * 3 + 2));
243  Eigen::Matrix<float, 3, 1> stripCenterDistance(
244  sspAux.topStripCenter.at(i * 3), sspAux.topStripCenter.at(i * 3 + 1),
245  sspAux.topStripCenter.at(i * 3 + 2));
246  Eigen::Matrix<float, 3, 1> topStripCenter(
247  sspAux.topStripCenter.at(i * 3), sspAux.topStripCenter.at(i * 3 + 1),
248  sspAux.topStripCenter.at(i * 3 + 2));
249  ssp->setSpacePoint(
250  {sspAux.elementIdList.at(i), sspAux.elementIdList.at(i + 1)},
251  globalPosition, sspAux.varianceR.at(i), sspAux.varianceZ.at(i),
252  strip_meas, topHalfStripLength, bottomHalfStripLength,
253  topStripDirection, bottomStripDirection, stripCenterDistance,
254  topStripCenter);
255  }
256  return StatusCode::SUCCESS;
257 }
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::makeStripSpacePointContainer
StatusCode makeStripSpacePointContainer(const int numStripSpacePoints, const EFTrackingDataFormats::SpacePointAuxInput &sspAux, const std::vector< std::vector< const xAOD::UncalibratedMeasurement * >> stripsp_meas, const EventContext &ctx) const
Create xAOD::SpacePointContainer by creating xAOD::SpacePoint for Strip SpacePoint objects one by one...
Definition: xAODContainerMaker.cxx:201
EFTrackingDataFormats::StripClusterAuxInput::globalPosition
std::vector< float > globalPosition
Definition: EFTrackingDataFormats.h:191
EFTrackingDataFormats::SpacePointAuxInput::varianceR
std::vector< float > varianceR
Definition: EFTrackingDataFormats.h:233
EFTrackingDataFormats::Metadata::pcChargeIndex
int pcChargeIndex[1000]
Definition: EFTrackingDataFormats.h:110
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:83
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:80
EFTrackingDataFormats::Metadata::pcTotIndex
int pcTotIndex[1000]
Definition: EFTrackingDataFormats.h:109
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:77
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
xAODContainerMaker::makePixelClusterContainer
StatusCode makePixelClusterContainer(const int numClusters, const EFTrackingDataFormats::PixelClusterAuxInput &pxAux, const EFTrackingDataFormats::Metadata *meta, const EventContext &ctx) const
Create xAOD::PixelClusterContainer by creating xAOD::PixelCluster objects one by one.
Definition: xAODContainerMaker.cxx:83
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
xAODContainerMaker::makeStripClusterContainer
StatusCode makeStripClusterContainer(const int numClusters, const EFTrackingDataFormats::StripClusterAuxInput &scAux, const EFTrackingDataFormats::Metadata *meta, const EventContext &ctx) const
Create xAOD::StripClusterContainer by creating xAOD::StripCluster objects one by one.
Definition: xAODContainerMaker.cxx:31
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::Metadata::pcRdoIndex
int pcRdoIndex[1000]
Definition: EFTrackingDataFormats.h:108
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::Metadata::scRdoIndex
int scRdoIndex[1000]
Definition: EFTrackingDataFormats.h:107
EFTrackingDataFormats::PixelClusterAuxInput::id
std::vector< long unsigned int > id
Definition: EFTrackingDataFormats.h:201
xAODContainerMaker::makePixelSpacePointContainer
StatusCode makePixelSpacePointContainer(const int numPixelSpacePoints, const EFTrackingDataFormats::SpacePointAuxInput &psAux, const std::vector< std::vector< const xAOD::UncalibratedMeasurement * >> pixelsp_meas, const EventContext &ctx) const
Create xAOD::SpacePointContainer by creating xAOD::SpacePoint for Pixel SpacePoint objects one by one...
Definition: xAODContainerMaker.cxx:163
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:74
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
fitman.k
k
Definition: fitman.py:528
EFTrackingDataFormats::SpacePointAuxInput::topStripDirection
std::vector< float > topStripDirection
Definition: EFTrackingDataFormats.h:237
Identifier
Definition: IdentifierFieldParser.cxx:14