Project
Loading...
Searching...
No Matches
TruthSeeding.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef O2_ITS_CA_TRUTH_SEEDING_H_
13#define O2_ITS_CA_TRUTH_SEEDING_H_
14
15#include <algorithm>
16#include <limits>
17#include <optional>
18#include <gsl/span>
19
24
25namespace o2::its::ca
26{
27// Keep the readout window anchored to the actual input ROF records, including
28// sparse/triggered input, while using the legacy interval and timing types.
29inline std::optional<o2::its::TimeEstBC> truthSeedingWindow(
30 gsl::span<const o2::itsmft::ROFRecord> rofs, const o2::InteractionRecord& origin,
31 const o2::its::LayerTiming& timing) noexcept
32{
33 if (rofs.empty() || timing.mROFLength == 0) {
34 return std::nullopt;
35 }
36 const int64_t offset = static_cast<int64_t>(timing.mROFDelay) + timing.mROFBias;
37 const int64_t begin = std::max(int64_t{0}, rofs.front().getBCData().differenceInBC(origin) + offset - timing.mROFAddTimeErr);
38 const int64_t end = rofs.back().getBCData().differenceInBC(origin) + offset + timing.mROFLength + timing.mROFAddTimeErr;
39 if (begin >= end || end > std::numeric_limits<o2::its::TimeStampType>::max()) {
40 return std::nullopt;
41 }
42 return o2::its::TimeEstBC{static_cast<uint32_t>(begin), static_cast<uint32_t>(end - begin)};
43}
44
45// Use the same origin as cluster loading. ROF delay/bias belong to the
46// readout window, not to the collision timestamp. Preserve the existing
47// forward uncertainty interval and select only collisions overlapping this TF.
48inline std::optional<o2::its::TimeEstBC> truthSeedingTime(
49 const o2::InteractionRecord& collision, const o2::InteractionRecord& origin,
50 const o2::its::TimeEstBC& window, uint32_t duration) noexcept
51{
52 if (collision.isDummy() || window.lower() >= window.upper() || duration == 0) {
53 return std::nullopt;
54 }
55 const auto begin = collision.differenceInBC(origin);
56 const auto end = begin + duration;
57 if (end <= window.lower() || begin >= window.upper() || end <= 0) {
58 return std::nullopt;
59 }
60 // TimeEstBC has unsigned bounds; clip only the part preceding this origin.
61 const auto clippedBegin = std::max(int64_t{0}, begin);
62 if (end > std::numeric_limits<o2::its::TimeStampType>::max()) {
63 return std::nullopt;
64 }
65 return o2::its::TimeEstBC{static_cast<uint32_t>(clippedBegin), static_cast<uint32_t>(end - clippedBegin)};
66}
67} // namespace o2::its::ca
68
69#endif
header::DataOrigin origin
Definition of the ITSMFT ROFrame (trigger) record.
GLuint GLuint end
Definition glcorearb.h:469
GLintptr offset
Definition glcorearb.h:660
std::optional< o2::its::TimeEstBC > truthSeedingWindow(gsl::span< const o2::itsmft::ROFRecord > rofs, const o2::InteractionRecord &origin, const o2::its::LayerTiming &timing) noexcept
std::optional< o2::its::TimeEstBC > truthSeedingTime(const o2::InteractionRecord &collision, const o2::InteractionRecord &origin, const o2::its::TimeEstBC &window, uint32_t duration) noexcept