Skip to content

Commit

Permalink
change Alignment store to map (#759)
Browse files Browse the repository at this point in the history
This PR changes the demonstrator for the AlignmentDetector to a map in order not to overwrite accidentally prior IOV transforms.

Obviously this is not the most performant contextual data approach on the client side.
  • Loading branch information
asalzburger committed Mar 31, 2021
1 parent 4efbca9 commit 464c247
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ ProcessCode PropagationAlgorithm<propagator_t>::execute(
sMomentum = startParameters.momentum();
pOutput = executeTest(context, startParameters);
} else {
// execute the test for neeutral particles
// execute the test for neutral particles
Acts::NeutralBoundTrackParameters neutralParameters(
surface, std::move(pars), std::move(cov));
sPosition = neutralParameters.position(context.geoContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "Acts/Surfaces/Surface.hpp"
#include "ActsExamples/GenericDetector/GenericDetectorElement.hpp"

#include <iostream>
#include <map>
#include <memory>

namespace ActsExamples {
Expand Down Expand Up @@ -72,20 +74,23 @@ class AlignedDetectorElement : public Generic::GenericDetectorElement {
unsigned int iov);

/// Return the set of alignment transforms in flight
const std::vector<std::unique_ptr<Acts::Transform3>>& alignedTransforms()
const;
const std::map<unsigned int, std::unique_ptr<Acts::Transform3>>&
alignedTransforms() const;

private:
std::vector<std::unique_ptr<Acts::Transform3>> m_alignedTransforms;
std::map<unsigned int, std::unique_ptr<Acts::Transform3>> m_alignedTransforms;
};

inline const Acts::Transform3& AlignedDetectorElement::transform(
const Acts::GeometryContext& gctx) const {
// Check if a different transform than the nominal exists
if (m_alignedTransforms.size()) {
if (not m_alignedTransforms.empty()) {
// cast into the right context object
auto alignContext = gctx.get<ContextType>();
return (*m_alignedTransforms[alignContext.iov].get());
auto aTransform = m_alignedTransforms.find(alignContext.iov);
if (aTransform != m_alignedTransforms.end()) {
return (*aTransform->second.get());
}
}
// Return the standard transform if not found
return nominalTransform(gctx);
Expand All @@ -98,15 +103,10 @@ inline const Acts::Transform3& AlignedDetectorElement::nominalTransform(

inline void AlignedDetectorElement::addAlignedTransform(
std::unique_ptr<Acts::Transform3> alignedTransform, unsigned int iov) {
// most standard case, it's just a new one:
auto cios = m_alignedTransforms.size();
for (unsigned int ic = cios; ic <= iov; ++ic) {
m_alignedTransforms.push_back(nullptr);
}
m_alignedTransforms[iov] = std::move(alignedTransform);
}

inline const std::vector<std::unique_ptr<Acts::Transform3>>&
inline const std::map<unsigned int, std::unique_ptr<Acts::Transform3>>&
AlignedDetectorElement::alignedTransforms() const {
return m_alignedTransforms;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class AlignmentDecorator : public IContextDecorator {
std::unique_ptr<const Acts::Logger> m_logger; ///!< the logging instance
std::string m_name = "AlignmentDecorator";

///< protect multiple alignments to be loaded at once
///< Protect multiple alignments to be loaded at once
std::mutex m_alignmentMutex;
std::vector<bool> m_iovStatus;
std::vector<bool> m_flushStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <Acts/Geometry/TrackingGeometry.hpp>

#include <random>
#include <thread>

ActsExamples::Contextual::AlignmentDecorator::AlignmentDecorator(
const ActsExamples::Contextual::AlignmentDecorator::Config& cfg,
Expand All @@ -26,6 +27,10 @@ ActsExamples::Contextual::AlignmentDecorator::decorate(
// In which iov batch are we?
unsigned int iov = context.eventNumber / m_cfg.iovSize;

ACTS_VERBOSE("IOV handling in thread " << std::this_thread::get_id() << ".");
ACTS_VERBOSE("IOV resolved to " << iov << " - from event "
<< context.eventNumber << ".");

if (m_cfg.randomNumberSvc != nullptr) {
// Detect if we have a new alignment range
if (m_iovStatus.size() == 0 or m_iovStatus.size() < iov or
Expand Down

0 comments on commit 464c247

Please sign in to comment.