20 std::smatch match_regex;
22 if ( not std::regex_search(tracks, match_regex, word_regex) or match_regex.size() < 2) {
23 throw std::runtime_error(
24 std::string(
"prefixFromTrackContainerName: key does not contain "
25 "Tracks in the name ") + tracks);
28 return match_regex[1].str();
31 template <
typename T,
typename IFACE,
typename AUX>
33 const EventContext& evtContext) {
35 if (handle.
record(std::move(iface), std::move(aux)).isFailure()) {
36 throw std::runtime_error(
37 std::string(
"MutableTrackContainerHandlesHelper::recordxAOD, can't record ") +
key.key() +
" backend");
42 template <
typename KTYPE>
43 void INIT_CHECK(KTYPE&
key) {
44 if (
key.initialize().isFailure()) {
45 throw std::runtime_error(
46 std::string(
"MutableTrackContainerHandlesHelper: can not initialize handle") +
key.key());
52 const std::string&
prefix) {
59 prefix +
"MultiTrajectory";
77 return StatusCode::SUCCESS;
80 std::unique_ptr<ActsTrk::MultiTrajectory>
87 auto statesInterface =
88 ActsTrk::makeInterfaceContainer<xAOD::TrackStateContainer>(
89 mmtj.trackStatesAux());
92 auto parametersInterface =
93 ActsTrk::makeInterfaceContainer<xAOD::TrackParametersContainer>(
94 mmtj.trackParametersAux());
97 auto jacobiansInterface =
98 ActsTrk::makeInterfaceContainer<xAOD::TrackJacobianContainer>(
99 mmtj.trackJacobiansAux());
102 auto measurementsInterface =
103 ActsTrk::makeInterfaceContainer<xAOD::TrackMeasurementContainer>(
104 mmtj.trackMeasurementsAux());
111 auto cmtj = std::make_unique<ActsTrk::MultiTrajectory>(
123 cmtj->moveSurfaces(&mmtj);
124 cmtj->moveLinks(&mmtj);
129 std::unique_ptr<ActsTrk::TrackContainer>
134 std::unique_ptr<ActsTrk::MultiTrajectory> constMtj =
135 moveToConst(std::move(tc.trackStateContainer()), evtContext);
138 if (constMtjHandle.record(std::move(constMtj)).isFailure()) {
139 throw std::runtime_error(
140 "MutableTrackContainerHandlesHelper::moveToConst, can't record "
141 "ConstMultiTrajectory");
144 auto trackSurfacesAux = std::make_unique<xAOD::TrackSurfaceAuxContainer>();
145 tc.container().encodeSurfaces(trackSurfacesAux.get(), geoContext);
147 auto interfaceTrackSummaryContainer =
148 ActsTrk::makeInterfaceContainer<xAOD::TrackSummaryContainer>(
149 tc.container().m_mutableTrackBackendAux.get());
152 auto trackSurfaces = ActsTrk::makeInterfaceContainer<xAOD::TrackSurfaceContainer>(
153 trackSurfacesAux.get());
156 auto constTrackSummary = std::make_unique<ActsTrk::TrackSummaryContainer>(
159 constTrackSummary->restoreDecorations();
160 constTrackSummary->fillFrom(tc.container());
163 if (constTrackSummaryHandle.record(std::move(constTrackSummary))
165 throw std::runtime_error(
166 "MutableTrackContainerHandlesHelper::moveToConst, can't record "
169 auto constTrack = std::make_unique<ActsTrk::TrackContainer>(
178 const std::string&
prefix) {
201 return StatusCode::SUCCESS;
204 std::unique_ptr<ActsTrk::MultiTrajectory>
206 const Acts::GeometryContext& geoContext,
207 const EventContext& evtContext)
const {
211 if (not statesLink.
isValid()) {
212 throw std::runtime_error(
213 "ConstMultiTrajectoryHandle::build, StatesLink is invalid");
223 if (not parametersLink.
isValid()) {
224 throw std::runtime_error(
225 "ConstMultiTrajectoryHandle::build, ParametersLink is invalid");
230 if (not jacobiansLink.
isValid()) {
231 throw std::runtime_error(
232 "ConstMultiTrajectoryHandle::build, JacobiansLink is invalid");
237 if (not measurementsLink.
isValid()) {
238 throw std::runtime_error(
239 "ConstMultiTrajectoryHandle::build, MeasurementsLink is invalid");
244 if (not surfacesLink.
isValid()) {
245 throw std::runtime_error(
246 "ConstMultiTrajectoryHandle::build, SurfacesLink is invalid");
250 auto cmtj = std::make_unique<ActsTrk::MultiTrajectory>(
251 statesLink, parametersLink, jacobiansLink, measurementsLink, surfacesLink);
252 cmtj->fillSurfaces(
geo, geoContext);
256 std::unique_ptr<ActsTrk::TrackContainer>
258 const Acts::GeometryContext& geoContext,
259 const EventContext& evtContext)
const {
261 std::unique_ptr<ActsTrk::MultiTrajectory> mtj =
264 if (mtjHandle.record(std::move(mtj)).isFailure()) {
265 throw std::runtime_error(
266 "ConstTrackContainerHandle<C>::build failed recording MTJ");
270 if (not summaryLink.
isValid()) {
271 throw std::runtime_error(
272 "ConstTrackContainerHandle::build, SummaryLink is invalid");
276 if (not surfacesHandle.isValid()) {
277 throw std::runtime_error(
278 "ConstTrackContainerHandle::build, SurfaceHandle is invalid");
281 auto constTrackSummary = std::make_unique<ActsTrk::TrackSummaryContainer>(summaryLink);
282 constTrackSummary->decodeSurfaces( surfacesHandle.cptr(), geoContext);
285 if (summaryHandle.record(std::move(constTrackSummary)).isFailure()) {
286 throw std::runtime_error(
287 "MutableTrackContainerHandle::build, can't record "
291 auto constTrack = std::make_unique<ActsTrk::TrackContainer>(
301 template <
typename T>
302 using const_span = std::span<T const>;
305 template <
typename T>
308 const_span<T> ret(
data, aux_container.
size() );
313 template <
typename T>
315 std::size_t
sz=aux_container.
size();
317 return std::span<T>(
data,
sz );
322 std::stringstream
msg;
323 msg <<
"Conflicting values for TrackState.uncalibratedMeasurement. Already set " <<
static_cast<const void *
>(is)
324 <<
" would set " <<
static_cast<const void *
>(should);
325 throw std::runtime_error(
msg.str());
334 const_span<link_t> elementLinks = getElementVector(statesLink, link_accessor);
337 decor(
"uncalibratedMeasurement");
339 std::span<const xAOD::UncalibratedMeasurement *> uncalibratedMeasurements
340 = createDecoration( statesLink, decor);
343 const link_t &
el = elementLinks[
index];
346 if (uncalibratedMeasurements[
index] !=
nullptr && a_measurement != uncalibratedMeasurements[
index]) {
347 throwConflictingUncalibratedMeasurementPointerValue(uncalibratedMeasurements[
index], a_measurement);
349 uncalibratedMeasurements[
index]=a_measurement;
353 std::cerr <<
"WARNING no uncalibratedMeasurementLink aux data " << std::endl;