26#define BOOST_TEST_MODULE ITSMFT TimeFrame lifecycle
27#define BOOST_TEST_MAIN
28#define BOOST_TEST_DYN_LINK
29#include <boost/test/unit_test.hpp>
66class LegacyLikeDecoder
73 gsl::span<const unsigned char>::iterator& patterns,
81 decoded.global = {
static_cast<float>(sensorID) * 10.f,
static_cast<float>(cluster.
getRow()),
static_cast<float>(cluster.
getCol())};
82 decoded.cylinderFrame = {
static_cast<float>(sensorID) + 100.f,
static_cast<float>(cluster.
getRow()) + 1.f,
static_cast<float>(cluster.
getCol()) + 2.f, 0.01f * sensorID};
83 decoded.rowColumnCovariance = {clusterData.sig2Row, 0.f, clusterData.sig2Col};
84 decoded.nPixels = clusterData.nPixels;
85 decoded.layer = sensorID;
94 mutable int decodeCount{0};
106constexpr std::array<unsigned char, 3> onePixelPattern{1, 1, 0x80};
107constexpr std::array<unsigned char, 3> threePixelPattern{1, 3, 0xE0};
109std::vector<unsigned char> concatPatterns(std::initializer_list<gsl::span<const unsigned char>> parts)
111 std::vector<unsigned char>
bytes;
112 for (
const auto& p : parts) {
113 bytes.insert(
bytes.end(), p.begin(), p.end());
118std::vector<SurfaceDescriptor> makeITSTestCatalog()
120 std::vector<SurfaceDescriptor>
surfaces;
128std::vector<LayerId> identitySurfaces(
uint16_t nLayers)
130 std::vector<LayerId> mapping;
131 mapping.reserve(nLayers);
145 return {
static_cast<float>(sensorID) * 10.f,
static_cast<float>(
row),
static_cast<float>(
col)};
149 std::vector<CompClusterExt>
clusters;
150 std::vector<unsigned char> patterns;
151 std::vector<ROFRecord> rofs;
167 f.patterns = concatPatterns({onePixelPattern, threePixelPattern, onePixelPattern, threePixelPattern});
186Fixture makeReplacementFixture()
196 f.patterns = concatPatterns({threePixelPattern, threePixelPattern, onePixelPattern, threePixelPattern, onePixelPattern});
216const std::vector<Expected> expectedClusters{
217 {0, 0, 0, 10, 20, 0, 1},
218 {1, 1, 1, 11, 21, 0, 3},
219 {2, 0, 0, 12, 22, 1, 1},
220 {3, 2, 2, 13, 23, 2, 3},
235 for (std::size_t expectedIndex = 0; expectedIndex < expectedClusters.size(); ++expectedIndex) {
236 const auto&
e = expectedClusters[expectedIndex];
237 const auto localClusterId =
static_cast<uint32_t>(std::count_if(
238 expectedClusters.begin(), expectedClusters.begin() + expectedIndex,
239 [&](
const auto& previous) { return previous.layer == e.layer; }));
245 if (globals[
index].clusterId == localClusterId) {
246 globalMeasurement = &globals[
index];
251 BOOST_REQUIRE(globalMeasurement !=
nullptr);
252 BOOST_REQUIRE(measurement !=
nullptr);
254 const auto g = expectedGlobal(
e.sensorID,
e.row,
e.col);
270 BOOST_REQUIRE_EQUAL(normalizedLabels.size(), 1u);
276 std::shared_ptr<BoundedMemoryResource> pool = std::make_shared<BoundedMemoryResource>())
278 auto layout = catalogLayout(catalog);
279 BOOST_REQUIRE(frame.
configure(std::move(layout), 0, 0, std::move(pool)));
288 const auto catalog = makeITSTestCatalog();
289 const auto orderedSurfaces = identitySurfaces(
ITSNLayers);
291 LegacyLikeDecoder decoder{o2::detectors::DetID::ITS};
296 const auto plan = catalogLayout(catalogView);
297 configureFrame(frame, catalogView);
301 BOOST_REQUIRE_GT(learnedCapacity, 1024u);
303 const auto f = makeFixture();
304 BOOST_REQUIRE_NO_THROW(test::loadTimeFrameSource(frame, decoder,
origin, timing,
f.clusters,
f.patterns,
f.rofs, &dict(), &
f.labels, o2::detectors::DetID::ITS,
305 gsl::span<const LayerId>{orderedSurfaces}, plan.getSurfaceCatalog()));
308 verifyFixtureLoaded(frame,
f);
328 const auto catalog = makeITSTestCatalog();
329 const auto orderedSurfaces = identitySurfaces(
ITSNLayers);
335 const auto*
const scratch = &frame.
getScratch();
336 auto layout = catalogLayout(catalogView);
337 auto failingPool = std::make_shared<BoundedMemoryResource>(0);
359 const auto catalog = makeITSTestCatalog();
367 configureFrame(frame, catalogView);
374 const auto catalog = makeITSTestCatalog();
375 const auto orderedSurfaces = identitySurfaces(
ITSNLayers);
377 LegacyLikeDecoder decoder{o2::detectors::DetID::ITS};
380 const auto baselineFixture = makeFixture();
381 auto malformedReplacement = makeReplacementFixture();
382 const auto plan = catalogLayout(catalogView);
384 configureFrame(frame, catalogView);
385 BOOST_REQUIRE_NO_THROW(test::loadTimeFrameSource(frame, decoder,
origin, timing, baselineFixture.clusters,
386 baselineFixture.patterns, baselineFixture.rofs, &dict(),
387 &baselineFixture.labels, o2::detectors::DetID::ITS,
388 gsl::span<const LayerId>{orderedSurfaces}, plan.getSurfaceCatalog()));
389 verifyFixtureLoaded(frame, baselineFixture);
391 malformedReplacement.rofs.front().setFirstEntry(1);
392 BOOST_CHECK_EXCEPTION(test::loadTimeFrameSource(frame, decoder,
origin, timing, malformedReplacement.clusters,
393 malformedReplacement.patterns, malformedReplacement.rofs, &dict(),
394 &malformedReplacement.labels, o2::detectors::DetID::ITS,
395 gsl::span<const LayerId>{orderedSurfaces}, plan.getSurfaceCatalog()),
396 std::runtime_error, [](
const std::runtime_error&
error) { return std::string(error.what()).find(
"Invalid ROF cluster range") != std::string::npos; });
header::DataOrigin origin
Definition of the ITSMFT compact cluster.
Passive common TimeFrame owner.
unsigned short int uint16_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
char error[CURL_ERROR_SIZE]
std::vector< o2::MCCompLabel > labels
Definition of a container to keep Monte Carlo truth external to simulation objects.
const Acts::Surface * surface
Runtime-plan-owned, detector-neutral CA workspace.
std::vector< std::shared_ptr< Surface > > surfaces
int ID
Detector identifiers: continuous, starting from 0.
UShort_t getSensorID() const
static constexpr unsigned short InvalidPatternID
static constexpr int makeVariant(int high, int low) noexcept
static constexpr KeyType makeKey(SlabSite site, int iteration, int variant, int slot) noexcept
size_t capacity(uint64_t key, double scale) const
void update(uint64_t key, double scale, size_t emitted, size_t capacityUsed, bool overflowed, bool memoryLimited)
bool empty() const noexcept
std::size_t getNCells() const noexcept
auto & getMemoryPool() const noexcept
std::size_t getNEdges() const noexcept
GLenum GLuint GLint GLint layer
constexpr float DefClusError2Col
ClusterData< T > extractClusterData(const CompClusterExt &c, gsl::span< const unsigned char >::iterator &patterns, const TopologyDictionary *dict)
constexpr float DefClusError2Row
constexpr int ITSNLayers
ITS CA layer count.
BOOST_AUTO_TEST_CASE(Cluster_messageable)
const SurfaceDescriptor * surfaces
SurfaceCovariance2F covariance
auto & getGenericTracks()
auto & getTrackClusterIndices()
auto getPrimaryVerticesNum()
void resetTimeFrame() noexcept
const DetectorConfiguration & getDetectorConfiguration() const noexcept
int getNrof(int layer) const
TimeFrameScratch & getScratch()
std::size_t getTotalMeasurements() const noexcept
bool isConfigured() const noexcept
gsl::span< const o2::MCCompLabel > getLabels(LayerId layer, uint32_t clusterId) const
CapacityEstimator & getCapacityEstimator() noexcept
uint32_t getNMeasurementSurfaces() const noexcept
const SurfaceMeasurement * getSurfaceMeasurement(LayerId layer, uint32_t clusterId) const noexcept
gsl::span< const GlobalMeasurement > getGlobalMeasurements(LayerId surface) const
auto & getMemoryPool() const noexcept
bool configure(DetectorConfiguration &&layout, std::size_t maxEdges, std::size_t maxCells, std::shared_ptr< BoundedMemoryResource > memoryPool)
coder decode(ctfImage, triggersD, clustersD)
std::vector< Cluster > clusters
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())