Project
Loading...
Searching...
No Matches
SampaBunchCrossingCounter.cxx
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
14#include "NofBits.h"
16
17using namespace o2::constants::lhc;
18
19namespace o2::mch::raw
20{
21
23
25 uint32_t firstOrbit)
26{
27 orbit -= firstOrbit;
28 auto bunchCrossingCounter = (orbit * LHCMaxBunches + bc) % ((1 << 20) - 1);
29 impl::assertNofBits("bunchCrossingCounter", bunchCrossingCounter, 20);
30 return bunchCrossingCounter;
31}
32
33std::tuple<uint32_t, uint16_t> orbitBC(uint20_t bunchCrossingCounter,
34 uint32_t firstOrbit)
35{
36 impl::assertNofBits("bunchCrossingCounter", bunchCrossingCounter, 20);
37 uint32_t orbit = bunchCrossingCounter / LHCMaxBunches + firstOrbit;
38 int32_t bc = bunchCrossingCounter % LHCMaxBunches;
39 return {orbit, bc};
40}
41
42} // namespace o2::mch::raw
uint64_t orbit
Definition RawEventData.h:6
uint64_t bc
Definition RawEventData.h:5
Header to collect LHC related constants.
constexpr int LHCMaxBunches
void assertNofBits(std::string_view msg, T value, int n)
Definition NofBits.h:29
uint20_t sampaBunchCrossingCounter(uint32_t orbit, uint16_t bc, uint32_t firstOrbit)
std::tuple< uint32_t, uint16_t > orbitBC(uint20_t bunchCrossing, uint32_t firstOrbit)
uint32_t uint20_t
Definition DataFormats.h:68