Project
Loading...
Searching...
No Matches
CH.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
12#include <map>
13#include <cstdint>
17#include <stdexcept>
18#include <fmt/format.h>
19#include <iostream>
20#include <algorithm>
21
22namespace
23{
24void add(std::map<uint32_t, uint32_t>& e2d, int deId, int dsId,
25 uint16_t solarId, uint8_t groupId, uint8_t index)
26{
27 o2::mch::raw::DsElecId dselec(solarId, groupId, index);
28 auto code = encode(dselec);
29 auto already = e2d.find(code);
30
31 // ensure we don't try to use already used key in the map
32 if (already != e2d.end()) {
33 auto previous = o2::mch::raw::decodeDsDetId(already->second);
34 throw std::logic_error(fmt::format("FATAL_ERROR: dselec={} (deId,dsId={},{}) is already in the map for (deId,dsId={})",
35 o2::mch::raw::asString(dselec), deId, dsId, o2::mch::raw::asString(previous)));
36 }
37
38 // // ensure we don't have duplicated codes in the map
39 // if (std::find_if(begin(e2d), end(e2d), [code](const auto& v) { return v.second == code; }) != end(e2d)) {
40 // throw std::logic_error(fmt::format("FATAL_ERROR dselec={} (de,ds={},{}) is already referenced in the map !",
41 // o2::mch::raw::asString(dselec), deId, dsId));
42 // }
43 e2d.emplace(code, encode(o2::mch::raw::DsDetId(deId, dsId)));
44}
45
46void add_cru(std::map<uint16_t, uint32_t>& s2f, int feeId, int linkId, uint16_t solarId)
47{
48 auto code = encode(o2::mch::raw::FeeLinkId(feeId, linkId));
49 // ensure we don't have duplicated codes in the map
50 if (std::find_if(begin(s2f), end(s2f), [code](const auto& v) { return v.second == code; }) != end(s2f)) {
51 throw std::logic_error(fmt::format("FATAL_ERROR feeid,link=({},{}) (solarId={}) is already referenced in the map !",
52 feeId, linkId, solarId));
53 }
54 s2f.emplace(solarId, code);
55}
56} // namespace
A DsDetId is just a pair (detection element id, dual sampa id)
Definition DsDetId.h:22
GLuint GLuint end
Definition glcorearb.h:469
const GLdouble * v
Definition glcorearb.h:832
GLuint index
Definition glcorearb.h:781
std::string asString(const SampaCluster &sc)
DsDetId decodeDsDetId(uint32_t code)
Create a DsDetId object from a integer code.
Definition DsDetId.cxx:33
Enum< T >::Iterator begin(Enum< T >)
Definition Defs.h:173
coder encode(vec, triggers, clusters)