ATLAS Offline Software
Loading...
Searching...
No Matches
ActsTrk::ConstTrackContainerHandlesHelper Class Reference

#include <TrackContainerHandlesHelper.h>

Collaboration diagram for ActsTrk::ConstTrackContainerHandlesHelper:

Public Member Functions

StatusCode initialize (const std::string &prefix)
 Sets up the handles.
template<class PropOwner>
 ConstTrackContainerHandlesHelper (PropOwner *owner)
 Constructor taking the pointer to the class holding the object used to declare the data dependency from the WriteHandleKeys to the AvalancheScheduler.
std::unique_ptr< ActsTrk::PersistentTrackContainer > build (const Acts::TrackingGeometry *geo, const Acts::GeometryContext &geoContext, const EventContext &context) const

Private Member Functions

void restoreUncalibMeasurementPtr (xAOD::TrackStateAuxContainer &statesLink) const
std::unique_ptr< ActsTrk::MultiTrajectory > buildMtj (const Acts::TrackingGeometry *geo, const EventContext &context) const

Private Attributes

SG::ReadHandleKey< xAOD::TrackStateContainer > m_statesKey
SG::ReadHandleKey< xAOD::TrackParametersContainer > m_parametersKey
SG::ReadHandleKey< xAOD::TrackJacobianContainer > m_jacobiansKey
SG::ReadHandleKey< xAOD::TrackMeasurementContainer > m_measurementsKey
SG::ReadHandleKey< xAOD::TrackSurfaceContainer > m_surfacesKey
SG::WriteHandleKey< ActsTrk::MultiTrajectory > m_mtjKey
SG::ReadHandleKey< xAOD::TrackSummaryContainer > m_xAODTrackSummaryKey
SG::ReadHandleKey< xAOD::TrackSurfaceContainer > m_trackSurfacesKey
SG::WriteHandleKey< ActsTrk::TrackSummaryContainer > m_trackSummaryKey

Detailed Description

Definition at line 94 of file TrackContainerHandlesHelper.h.

Constructor & Destructor Documentation

◆ ConstTrackContainerHandlesHelper()

template<class PropOwner>
ActsTrk::ConstTrackContainerHandlesHelper::ConstTrackContainerHandlesHelper ( PropOwner * owner)

Constructor taking the pointer to the class holding the object used to declare the data dependency from the WriteHandleKeys to the AvalancheScheduler.

The object should be defined in the header like ActsTrk::ConstTrackContainerHandlesHelper m_trackHelper{this};

Member Function Documentation

◆ build()

std::unique_ptr< ActsTrk::PersistentTrackContainer > ActsTrk::ConstTrackContainerHandlesHelper::build ( const Acts::TrackingGeometry * geo,
const Acts::GeometryContext & geoContext,
const EventContext & context ) const

Definition at line 266 of file TrackContainerHandlesHelper.cxx.

268 {
269
270 std::unique_ptr<ActsTrk::MultiTrajectory> mtj = buildMtj(geo,evtContext);
271 auto mtjHandle = SG::makeHandle(m_mtjKey, evtContext);
272 if (mtjHandle.record(std::move(mtj)).isFailure()) {
273 throw std::runtime_error(
274 "ConstTrackContainerHandle<C>::build failed recording MTJ");
275 }
276 DataLink<xAOD::TrackSummaryContainer> summaryLink(m_xAODTrackSummaryKey.key(),
277 evtContext);
278 if (not summaryLink.isValid()) {
279 throw std::runtime_error(
280 "ConstTrackContainerHandle::build, SummaryLink is invalid");
281 }
282
283 auto surfacesHandle = SG::makeHandle(m_trackSurfacesKey, evtContext);
284 if (not surfacesHandle.isValid()) {
285 throw std::runtime_error(
286 "ConstTrackContainerHandle::build, SurfaceHandle is invalid");
287 }
288
289 auto constTrackSummary = std::make_unique<ActsTrk::TrackSummaryContainer>(summaryLink);
290 constTrackSummary->decodeSurfaces( surfacesHandle.cptr());
291
292 auto summaryHandle = SG::makeHandle(m_trackSummaryKey, evtContext);
293 if (summaryHandle.record(std::move(constTrackSummary)).isFailure()) {
294 throw std::runtime_error(
295 "MutableTrackContainerHandle::build, can't record "
296 "TrackSummary");
297 }
298
299 auto constTrack = std::make_unique<ActsTrk::PersistentTrackContainer>(
300 DataLink<ActsTrk::TrackSummaryContainer>(m_trackSummaryKey.key(),
301 evtContext),
302 DataLink<ActsTrk::MultiTrajectory>(m_mtjKey.key(), evtContext));
303
304 return constTrack;
305
306}
SG::WriteHandleKey< ActsTrk::MultiTrajectory > m_mtjKey
SG::WriteHandleKey< ActsTrk::TrackSummaryContainer > m_trackSummaryKey
SG::ReadHandleKey< xAOD::TrackSurfaceContainer > m_trackSurfacesKey
SG::ReadHandleKey< xAOD::TrackSummaryContainer > m_xAODTrackSummaryKey
std::unique_ptr< ActsTrk::MultiTrajectory > buildMtj(const Acts::TrackingGeometry *geo, const EventContext &context) const
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())

◆ buildMtj()

std::unique_ptr< ActsTrk::MultiTrajectory > ActsTrk::ConstTrackContainerHandlesHelper::buildMtj ( const Acts::TrackingGeometry * geo,
const EventContext & context ) const
private

Definition at line 215 of file TrackContainerHandlesHelper.cxx.

216 {
217 // we need to build it from backends
218 DataLink<xAOD::TrackStateAuxContainer> statesLink(m_statesKey.key() + "Aux.",
219 evtContext);
220 if (not statesLink.isValid()) {
221 throw std::runtime_error(
222 "ConstMultiTrajectoryHandle::build, StatesLink is invalid");
223 }
224 // The restoration of the pointers to uncalibrated measurements should only
225 // be done once, if it is done in parallel by multiple callers all callers should
226 // write exactly the same value to exactly the same memory location
227 xAOD::TrackStateAuxContainer *nonConstStatesLink ATLAS_THREAD_SAFE = const_cast<xAOD::TrackStateAuxContainer *>(statesLink.getDataPtr());
228 restoreUncalibMeasurementPtr(*nonConstStatesLink);
229
230 DataLink<xAOD::TrackParametersAuxContainer> parametersLink(
231 m_parametersKey.key() + "Aux.", evtContext);
232 if (not parametersLink.isValid()) {
233 throw std::runtime_error(
234 "ConstMultiTrajectoryHandle::build, ParametersLink is invalid");
235 }
236
237 DataLink<xAOD::TrackJacobianAuxContainer> jacobiansLink(
238 m_jacobiansKey.key() + "Aux.", evtContext);
239 if (not jacobiansLink.isValid()) {
240 throw std::runtime_error(
241 "ConstMultiTrajectoryHandle::build, JacobiansLink is invalid");
242 }
243
244 DataLink<xAOD::TrackMeasurementAuxContainer> measurementsLink(
245 m_measurementsKey.key() + "Aux.", evtContext);
246 if (not measurementsLink.isValid()) {
247 throw std::runtime_error(
248 "ConstMultiTrajectoryHandle::build, MeasurementsLink is invalid");
249 }
250
251 DataLink<xAOD::TrackSurfaceAuxContainer> surfacesLink(
252 m_surfacesKey.key() + "Aux.", evtContext);
253 if (not surfacesLink.isValid()) {
254 throw std::runtime_error(
255 "ConstMultiTrajectoryHandle::build, SurfacesLink is invalid");
256 }
257
258
259 auto cmtj = std::make_unique<ActsTrk::MultiTrajectory>(
260 statesLink, parametersLink, jacobiansLink, measurementsLink, surfacesLink);
261 cmtj->fillSurfaces(geo);
262 return cmtj;
263}
#define ATLAS_THREAD_SAFE
SG::ReadHandleKey< xAOD::TrackMeasurementContainer > m_measurementsKey
SG::ReadHandleKey< xAOD::TrackSurfaceContainer > m_surfacesKey
SG::ReadHandleKey< xAOD::TrackStateContainer > m_statesKey
void restoreUncalibMeasurementPtr(xAOD::TrackStateAuxContainer &statesLink) const
SG::ReadHandleKey< xAOD::TrackJacobianContainer > m_jacobiansKey
SG::ReadHandleKey< xAOD::TrackParametersContainer > m_parametersKey
TrackStateAuxContainer_v1 TrackStateAuxContainer

◆ initialize()

StatusCode ActsTrk::ConstTrackContainerHandlesHelper::initialize ( const std::string & prefix)

Sets up the handles.

  • prefix - common prefix for all the names the value would typically be taken from configurable string property

Definition at line 187 of file TrackContainerHandlesHelper.cxx.

188 {
189 m_statesKey = prefix + "TrackStates";
190 m_parametersKey = prefix + "TrackParameters";
191 m_jacobiansKey = prefix + "TrackJacobians";
192 m_measurementsKey = prefix + "TrackMeasurements";
193 m_surfacesKey = prefix + "TrackSurfaces";
194 m_mtjKey = prefix + "MultiTrajectory";
195
202
203 m_xAODTrackSummaryKey = prefix + "TrackSummary";
204 m_trackSurfacesKey = prefix + "TrackSurfaces";
205 m_trackSummaryKey = prefix + "TrackSummary";
206
210
211 return StatusCode::SUCCESS;
212}
#define INIT_CHECK(key)

◆ restoreUncalibMeasurementPtr()

void ActsTrk::ConstTrackContainerHandlesHelper::restoreUncalibMeasurementPtr ( xAOD::TrackStateAuxContainer & statesLink) const
private

Definition at line 337 of file TrackContainerHandlesHelper.cxx.

337 {
338 using link_t = ElementLink< xAOD::UncalibratedMeasurementContainer >;
339 static const SG::ConstAccessor< link_t > link_accessor("uncalibratedMeasurementLink");
340
341 if (statesLink.getAuxIDs().test(link_accessor.auxid())){
342 const_span<link_t> elementLinks = getElementVector(statesLink, link_accessor);
343
345 decor("uncalibratedMeasurement");
346
347 std::span<const xAOD::UncalibratedMeasurement *> uncalibratedMeasurements
348 = createDecoration( statesLink, decor);
349
350 for (unsigned int index = 0; index < elementLinks.size(); ++index) {
351 const link_t &el = elementLinks[index];
352 const xAOD::UncalibratedMeasurement *a_measurement = (el.isValid() ? *el : nullptr);
353 // @TODO is this check necessary ?
354 if (uncalibratedMeasurements[index] != nullptr && a_measurement != uncalibratedMeasurements[index]) {
355 throwConflictingUncalibratedMeasurementPointerValue(uncalibratedMeasurements[index], a_measurement);
356 }
357 uncalibratedMeasurements[index]=a_measurement;
358 }
359 }
360 else {
361 std::cerr << "WARNING no uncalibratedMeasurementLink aux data " << std::endl;
362 }
363}
virtual const auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.
str index
Definition DeMoScan.py:362
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:570
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition AuxElement.h:576
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.

Member Data Documentation

◆ m_jacobiansKey

SG::ReadHandleKey<xAOD::TrackJacobianContainer> ActsTrk::ConstTrackContainerHandlesHelper::m_jacobiansKey
private

Definition at line 122 of file TrackContainerHandlesHelper.h.

◆ m_measurementsKey

SG::ReadHandleKey<xAOD::TrackMeasurementContainer> ActsTrk::ConstTrackContainerHandlesHelper::m_measurementsKey
private

Definition at line 123 of file TrackContainerHandlesHelper.h.

◆ m_mtjKey

SG::WriteHandleKey<ActsTrk::MultiTrajectory> ActsTrk::ConstTrackContainerHandlesHelper::m_mtjKey
private

Definition at line 126 of file TrackContainerHandlesHelper.h.

◆ m_parametersKey

SG::ReadHandleKey<xAOD::TrackParametersContainer> ActsTrk::ConstTrackContainerHandlesHelper::m_parametersKey
private

Definition at line 121 of file TrackContainerHandlesHelper.h.

◆ m_statesKey

SG::ReadHandleKey<xAOD::TrackStateContainer> ActsTrk::ConstTrackContainerHandlesHelper::m_statesKey
private

Definition at line 120 of file TrackContainerHandlesHelper.h.

◆ m_surfacesKey

SG::ReadHandleKey<xAOD::TrackSurfaceContainer> ActsTrk::ConstTrackContainerHandlesHelper::m_surfacesKey
private

Definition at line 124 of file TrackContainerHandlesHelper.h.

◆ m_trackSummaryKey

SG::WriteHandleKey<ActsTrk::TrackSummaryContainer> ActsTrk::ConstTrackContainerHandlesHelper::m_trackSummaryKey
private

Definition at line 136 of file TrackContainerHandlesHelper.h.

◆ m_trackSurfacesKey

SG::ReadHandleKey<xAOD::TrackSurfaceContainer> ActsTrk::ConstTrackContainerHandlesHelper::m_trackSurfacesKey
private

Definition at line 135 of file TrackContainerHandlesHelper.h.

◆ m_xAODTrackSummaryKey

SG::ReadHandleKey<xAOD::TrackSummaryContainer> ActsTrk::ConstTrackContainerHandlesHelper::m_xAODTrackSummaryKey
private

Definition at line 134 of file TrackContainerHandlesHelper.h.


The documentation for this class was generated from the following files: