Project
Loading...
Searching...
No Matches
ElectronicMapperDummy.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 <map>
14#include <fmt/format.h>
19#include "dslist.h"
20
21namespace
22{
23
24constexpr int firstSolarId{360}; // so at least we get some overlap with real solarIds
25
26// build the map to go from electronic ds id to detector ds id
27std::map<uint32_t, uint32_t> buildDsElecId2DsDetIdMap()
28{
29 std::map<uint32_t, uint32_t> e2d;
30
32
33 uint16_t n{0};
34 uint16_t solarId{firstSolarId};
35 uint8_t groupId{0};
36 uint8_t index{0};
37
38 for (auto deId : o2::mch::constants::deIdsForAllMCH) {
39 // assign a tuple (solarId,groupId,index) to the pair (deId,dsId)
40 for (auto dsId : dslist(deId)) {
41 // index 0..4
42 // groupId 0..7
43 // solarId 0..nsolars
44 if (n % 5 == 0) {
45 index = 0;
46 if (n % 8 == 0) {
47 groupId = 0;
48 } else {
49 groupId++;
50 }
51 } else {
52 index++;
53 }
54 if (n % 40 == 0) {
55 solarId++;
56 }
57 o2::mch::raw::DsElecId dsElecId(solarId, groupId, index);
58 o2::mch::raw::DsDetId dsDetId(deId, dsId);
59 e2d.emplace(o2::mch::raw::encode(dsElecId),
60 o2::mch::raw::encode(dsDetId));
61 n++;
62 };
63 };
64 return e2d;
65}
66
67std::map<uint32_t, uint16_t> buildFeeLinkId2SolarIdMap()
68{
69 std::map<uint32_t, uint16_t> c2s;
70
71 uint16_t n{0};
72 uint16_t solarId{firstSolarId};
73
75
76 std::set<uint16_t> solarIds;
77
78 for (auto deId : o2::mch::constants::deIdsForAllMCH) {
79 // assign a tuple (fee,link) to each solarId
80 for (auto dsId : dslist(deId)) {
81 if (n % 40 == 0) {
82 solarId++;
83 solarIds.insert(solarId);
84 }
85 n++;
86 }
87 }
88 for (auto solarId : solarIds) {
89 auto feeId = solarId / 12;
90 auto linkId = solarId - feeId * 12;
91 c2s[encode(o2::mch::raw::FeeLinkId(feeId, linkId))] = solarId;
92 }
93 return c2s;
94}
95} // namespace
96
97namespace o2::mch::raw
98{
99
100template <>
101std::function<std::optional<DsDetId>(DsElecId)>
103{
104 static std::map<uint32_t, uint32_t> dsElecId2DsDetId = buildDsElecId2DsDetIdMap();
105 return impl::mapperElec2Det<ElectronicMapperDummy>(dsElecId2DsDetId);
106}
107
108template <>
109std::function<std::optional<DsElecId>(DsDetId)>
111{
112 static std::map<uint32_t, uint32_t> dsDetId2dsElecId = impl::inverseMap(buildDsElecId2DsDetIdMap());
113 return impl::mapperDet2Elec<ElectronicMapperDummy>(dsDetId2dsElecId);
114}
115
116template <>
117std::function<std::optional<uint16_t>(FeeLinkId)>
119{
120 static auto f2s = buildFeeLinkId2SolarIdMap();
121 return impl::mapperFeeLink2Solar<ElectronicMapperDummy>(f2s);
122}
123
124template <>
125std::function<std::optional<FeeLinkId>(uint16_t)>
127{
128 static auto s2f = impl::inverseMap(buildFeeLinkId2SolarIdMap());
129 return impl::mapperSolar2FeeLink<ElectronicMapperDummy>(s2f);
130}
131
132template <>
133std::set<uint16_t> getSolarUIDs<ElectronicMapperDummy>(int deid)
134{
135 return impl::getSolarUIDs<ElectronicMapperDummy>(deid);
136}
137
138template <>
139std::set<uint16_t> getSolarUIDs<ElectronicMapperDummy>()
140{
141 return impl::getSolarUIDs<ElectronicMapperDummy>();
142}
143
144template <>
146{
147 return impl::solar2FeeLinkConsistencyCheck<ElectronicMapperDummy>();
148}
149
150template <>
151std::set<DsElecId> getAllDs<ElectronicMapperDummy>()
152{
153 return impl::getAllDs<ElectronicMapperDummy>();
154}
155
156template <>
157std::set<uint16_t> getSolarUIDsPerFeeId<ElectronicMapperDummy>(uint16_t feeid)
158{
159 return impl::getSolarUIDsPerFeeId<ElectronicMapperDummy>(feeid);
160}
161
162template <>
163std::set<DsDetId> getDualSampas<ElectronicMapperDummy>(uint16_t solarId)
164{
165 return impl::getDualSampas<ElectronicMapperDummy>(solarId);
166}
167
168template <>
169std::set<DsDetId> getDualSampasPerFeeId<ElectronicMapperDummy>(uint16_t feeId)
170{
171 return impl::getDualSampasPerFeeId<ElectronicMapperDummy>(feeId);
172}
173
174template <>
175std::optional<uint16_t> solarIndex2Id<ElectronicMapperDummy>(uint16_t solarIndex)
176{
177 return impl::solarIndex2Id<ElectronicMapperDummy>(solarIndex);
178}
179
180template <>
181std::optional<uint16_t> solarId2Index<ElectronicMapperDummy>(uint16_t solarId)
182{
183 return impl::solarId2Index<ElectronicMapperDummy>(solarId);
184}
185
186} // namespace o2::mch::raw
A DsDetId is just a pair (detection element id, dual sampa id)
Definition DsDetId.h:22
std::function< std::set< int >(int deId)> createDualSampaMapper()
Definition dslist.cxx:15
GLdouble n
Definition glcorearb.h:1982
GLuint index
Definition glcorearb.h:781
uint8_t itsSharedClusterMap uint8_t
std::array< int, 156 > deIdsForAllMCH
std::map< VALUE, KEY > inverseMap(const std::map< KEY, VALUE > &src)
std::set< uint16_t > getSolarUIDsPerFeeId< ElectronicMapperDummy >(uint16_t feeid)
std::set< DsDetId > getDualSampas< ElectronicMapperDummy >(uint16_t solarId)
std::function< std::optional< DsElecId >(DsDetId)> createDet2ElecMapper< ElectronicMapperDummy >()
std::set< DsDetId > getDualSampasPerFeeId< ElectronicMapperDummy >(uint16_t feeId)
std::vector< std::string > solar2FeeLinkConsistencyCheck< ElectronicMapperDummy >()
std::optional< uint16_t > solarIndex2Id< ElectronicMapperDummy >(uint16_t solarIndex)
std::set< DsElecId > getAllDs< ElectronicMapperDummy >()
std::function< std::optional< DsDetId >(DsElecId)> createElec2DetMapper< ElectronicMapperDummy >(uint64_t timestamp)
std::optional< uint16_t > solarId2Index< ElectronicMapperDummy >(uint16_t solarId)
std::function< std::optional< uint16_t >(FeeLinkId)> createFeeLink2SolarMapper< ElectronicMapperDummy >()
std::function< std::optional< FeeLinkId >(uint16_t)> createSolar2FeeLinkMapper< ElectronicMapperDummy >()
uint32_t encode(const DsDetId &id)
Create an integer code for the given id.
Definition DsDetId.cxx:28
std::set< uint16_t > getSolarUIDs< ElectronicMapperDummy >()
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
auto dslist
coder encode(vec, triggers, clusters)