Project
Loading...
Searching...
No Matches
GlobalMapper.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
16
18
19#include <fmt/format.h>
22
23namespace o2
24{
25namespace mid
26{
27int getStripId(int deId, int columnId, int lineId, int stripId, int cathode)
28{
29 return stripId | (cathode << 4) | (lineId << 5) | (columnId << 7) | (deId << 10);
30}
31
32std::array<int, 4> GlobalMapper::getStripGeom(int deId, int columnId, int lineId, int stripId, int cathode) const
33{
34 int irpc = detparams::getRPCLine(deId);
35 int offsetNB = 32 * columnId;
36 int offsetB = 32 * (2 * irpc - detparams::NRPCLines);
37 int xpos = offsetNB;
38 int ypos = offsetB;
39 int pitch = static_cast<int>(mMapping.getStripSize(stripId, cathode, columnId, deId));
40 int xwidth = pitch;
41 int ywidth = pitch;
42
43 if (cathode == 0) {
44 ypos += pitch * (16 * lineId + stripId);
45 xwidth = 32;
46 if (columnId == 6) {
47 xwidth += 16;
48 }
49 } else {
50 xpos += pitch * stripId;
51 int firstLine = mMapping.getFirstBoardBP(columnId, deId);
52 int lastLine = mMapping.getLastBoardBP(columnId, deId);
53 int nLines = lastLine - firstLine + 1;
54 ypos += 16 * firstLine;
55 ywidth = (nLines == 3) ? 48 : 64;
56 if (columnId == 6 && stripId >= 8) {
57 // The strip pitch for the previous strips was 4 cm
58 // while the one for this strip is 2 cm
59 // So we need to add 2 * 8 to the offset...
60 xpos += 8 * pitch;
61 }
62 }
63
64 if (geoparams::isShortRPC(deId) && columnId == 1) {
65 xpos += 16;
66 if (cathode == 0) {
67 xwidth = 16;
68 }
69 }
70
71 if (!detparams::isRightSide(deId)) {
72 xpos *= -1;
73 xwidth *= -1;
74 }
75
76 return {mScaleFactor * xpos, mScaleFactor * ypos, mScaleFactor * xwidth, mScaleFactor * ywidth};
77}
78
79ExtendedMappingInfo GlobalMapper::buildExtendedInfo(int deId, int columnId, int lineId, int stripId, int cathode) const
80{
81 ExtendedMappingInfo info;
82 info.id = getStripId(deId, columnId, lineId, stripId, cathode);
83 auto locId = static_cast<int>(mCrateMapper.deLocalBoardToRO(deId, columnId, lineId));
84 info.locId = locId;
85 std::string side = detparams::isRightSide(deId) ? "R" : "L";
86 auto crateId = (locId >> 4) % 8;
87 auto locInCrate = (locId & 0xF);
88 info.rpc = detparams::getDEName(deId);
89 info.deId = deId;
90 info.columnId = columnId;
91 info.lineId = lineId;
92 info.stripId = stripId;
93 info.cathode = cathode;
94 info.locIdDcs = fmt::format("{}{}{}{}", crateId, side, (locInCrate >= 8 ? "1" : "0"), locInCrate);
95 auto geom = getStripGeom(deId, columnId, lineId, stripId, cathode);
96 info.xpos = geom[0];
97 info.ypos = geom[1];
98 info.xwidth = geom[2];
99 info.ywidth = geom[3];
100 return info;
101}
102
103std::vector<ExtendedMappingInfo> GlobalMapper::buildStripsInfo() const
104{
105 std::vector<ExtendedMappingInfo> out;
106 for (int ide = 0; ide < o2::mid::detparams::NDetectionElements; ++ide) {
107 for (int icol = mMapping.getFirstColumn(ide); icol < 7; ++icol) {
108 int firstLine = mMapping.getFirstBoardBP(icol, ide);
109 int nStrips = mMapping.getNStripsNBP(icol, ide);
110 // NBP
111 for (int istrip = 0; istrip < nStrips; ++istrip) {
112 auto info = buildExtendedInfo(ide, icol, firstLine, istrip, 1);
113 out.emplace_back(info);
114 }
115 // BP
116 int lastLine = mMapping.getLastBoardBP(icol, ide);
117 for (int iline = firstLine; iline <= lastLine; ++iline) {
118 for (int istrip = 0; istrip < 16; ++istrip) {
119 auto info = buildExtendedInfo(ide, icol, iline, istrip, 0);
120 out.emplace_back(info);
121 }
122 }
123 }
124 }
125 return out;
126}
127
128std::map<int, std::vector<std::pair<int, int>>> GlobalMapper::buildDEGeom() const
129{
130 std::map<int, std::vector<std::pair<int, int>>> out;
131 std::pair<int, int> tmp;
132 for (int ide = 0; ide < o2::mid::detparams::NDetectionElements; ++ide) {
133 int icol = mMapping.getFirstColumn(ide);
134 int iline = mMapping.getFirstBoardBP(icol, ide);
135 bool isCutLow = (iline != 0);
136 // (x1,y1)
137 auto info = buildExtendedInfo(ide, icol, iline, 0, 0);
138 out[ide].emplace_back(info.xpos, info.ypos);
139 if (isCutLow) {
140 tmp = {info.xpos + info.xwidth, info.ypos};
141 }
142 // (x1, y2)
143 iline = mMapping.getLastBoardBP(icol, ide);
144 info = buildExtendedInfo(ide, icol, iline, 15, 0);
145 out[ide].emplace_back(info.xpos, info.ypos + info.ywidth);
146 if (iline == 2) {
147 // Cut high
148 // (x1',y2)
149 out[ide].emplace_back(info.xpos + info.xwidth, info.ypos + info.ywidth);
150 info = buildExtendedInfo(ide, 1, 3, 15, 0);
151 // (x1',y2')
152 out[ide].emplace_back(info.xpos, info.ypos + info.ywidth);
153 }
154 // (x2,y2)
155 info = buildExtendedInfo(ide, 6, 0, 15, 0);
156 out[ide].emplace_back(info.xpos + info.xwidth, info.ypos + info.ywidth);
157 // (x2,y1)
158 info = buildExtendedInfo(ide, 6, 0, 0, 0);
159 out[ide].emplace_back(info.xpos + info.xwidth, info.ypos);
160 if (isCutLow) {
161 // Cut low
162 // (x1',y1')
163 info = buildExtendedInfo(ide, 1, 0, 0, 0);
164 out[ide].emplace_back(info.xpos, info.ypos);
165 // (x1',y1)
166 out[ide].emplace_back(tmp);
167 }
168 // (x1, y1)
169 out[ide].emplace_back(out[ide].front());
170 }
171 return out;
172}
173
174} // namespace mid
175} // namespace o2
Useful detector parameters for MID.
Useful geometrical parameters for MID.
Global mapper for MID.
uint32_t side
Definition RawData.h:0
uint8_t deLocalBoardToRO(uint8_t deId, uint8_t columnId, uint8_t lineId) const
Converts the LOC ID expressed in the offline convention into the readout convention.
std::map< int, std::vector< std::pair< int, int > > > buildDEGeom() const
Build the geometry for the Detection elements.
std::vector< ExtendedMappingInfo > buildStripsInfo() const
Build the strips info.
int getNStripsNBP(int column, int deId) const
Definition Mapping.cxx:159
int getFirstColumn(int deId) const
Definition Mapping.cxx:169
int getLastBoardBP(int column, int deId) const
Definition Mapping.cxx:188
int getFirstBoardBP(int column, int deId) const
Definition Mapping.cxx:178
double getStripSize(int strip, int cathode, int column, int deId) const
Definition Mapping.cxx:140
constexpr int NDetectionElements
Number of RPCs.
constexpr int NRPCLines
Number of RPC lines.
std::string getDEName(int deId)
bool isRightSide(int deId)
bool isShortRPC(int deId)
int getStripId(int deId, int columnId, int lineId, int stripId, int cathode)
Gets the unique strip ID.
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...