Project
Loading...
Searching...
No Matches
DsDetId.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
13#include "Assertions.h"
14#include <fmt/format.h>
15#include <iostream>
16
17namespace o2::mch::raw
18{
19
20DsDetId::DsDetId(int deId, int dsId)
21{
22 impl::assertIsInRange("deId", deId, 0, 1025);
23 impl::assertIsInRange("dsId", dsId, 0, 1361);
24 mDeId = static_cast<uint16_t>(deId);
25 mDsId = static_cast<uint16_t>(dsId);
26}
27
28uint32_t encode(const DsDetId& id)
29{
30 return id.deId() << 16 | id.dsId();
31}
32
34{
35 uint16_t deId = static_cast<uint16_t>((x & 0xFFFF0000) >> 16);
36 uint16_t dsId = static_cast<uint16_t>(x & 0xFFFF);
37 return DsDetId(deId, dsId);
38}
39
40std::ostream& operator<<(std::ostream& os, const DsDetId& id)
41{
42 os << fmt::format("DsDetId(DE={:4d},DS={:4d}) CODE={:8d}", id.deId(), id.dsId(), encode(id));
43 return os;
44}
45
46std::string asString(DsDetId dsDetId)
47{
48 return fmt::format("DE{}-DS{}", dsDetId.deId(), dsDetId.dsId());
49}
50
51} // namespace o2::mch::raw
A DsDetId is just a pair (detection element id, dual sampa id)
Definition DsDetId.h:22
DsDetId(int deId, int dsId)
Definition DsDetId.cxx:20
uint16_t deId() const
deId returns one of the 156 possible detection element id
Definition DsDetId.h:27
uint16_t dsId() const
Definition DsDetId.h:31
GLint GLenum GLint x
Definition glcorearb.h:403
int assertIsInRange(std::string what, uint64_t value, uint64_t min, uint64_t max)
Definition Assertions.h:20
std::string asString(const SampaCluster &sc)
DsDetId decodeDsDetId(uint32_t code)
Create a DsDetId object from a integer code.
Definition DsDetId.cxx:33
uint32_t encode(const DsDetId &id)
Create an integer code for the given id.
Definition DsDetId.cxx:28
std::ostream & operator<<(std::ostream &stream, o2::InteractionRecord const &ir)