39 buildDETypeLarge(0, {{1, 17, 39, 61, 77, 93, 109}});
40 buildDETypeMedium(1, {{2, 18, 40, 62, 78, 94, 110}},
true);
41 buildDETypeMedium(2, {{4, 20, 42, 64, 80, 96, 111}},
false);
42 buildDETypeCut(3, {{6, 22, 44, 66, 82, 98, 112}},
true);
43 buildDETypeShort(4, {{0, 26, 48, 68, 84, 100, 113}});
44 buildDETypeCut(5, {{9, 30, 52, 70, 86, 102, 114}},
false);
45 buildDETypeMedium(6, {{12, 34, 56, 72, 88, 104, 115}},
false);
46 buildDETypeMedium(7, {{14, 36, 58, 74, 90, 106, 116}},
true);
47 buildDETypeLarge(8, {{16, 38, 60, 76, 92, 108, 117}});
51void Mapping::setupSegmentation(
int rpcLine,
int column,
int nStripsNBP,
int stripPitchNBP,
int nBoardsBP,
52 int firstBoardId,
bool isBelowBeamPipe)
55 MpColumn& columnStruct{mDetectionElements[rpcLine].columns[column]};
56 columnStruct.nStripsNBP = nStripsNBP;
57 columnStruct.stripPitchNBP = stripPitchNBP;
58 columnStruct.stripPitchBP = (nBoardsBP > 0) ? 4 / nBoardsBP : 0;
59 int nBoardsBPtot = nBoardsBP;
62 if (!isBelowBeamPipe) {
67 for (
int iboard = 0; iboard < nBoardsBPtot; ++iboard) {
68 int boardIdx = firstBoardId + iboard - 1;
70 if ((isBelowBeamPipe && iboard == 3) || (!isBelowBeamPipe && iboard == 0)) {
74 columnStruct.boardsBP.push_back(boardIdx);
75 mBoardIndexes[boardIdx].deType = (boardIdx < 117) ? rpcLine : 0;
76 mBoardIndexes[boardIdx].column = (boardIdx < 117) ? column : 0;
77 mBoardIndexes[boardIdx].line = (boardIdx < 117) ? iboard : 0;
82void Mapping::setupSegmentationLastColumn(
int rpcLine,
int boardId)
86 setupSegmentation(rpcLine, 6, 16, 4, 1, boardId);
90void Mapping::buildDETypeLarge(
int rpcLine, std::array<int, 7> boards)
93 for (
int icolumn = 0; icolumn < 6; ++icolumn) {
94 setupSegmentation(rpcLine, icolumn, 8, 4, 1, boards[icolumn]);
96 setupSegmentationLastColumn(rpcLine, boards[6]);
100void Mapping::buildDETypeMedium(
int rpcLine, std::array<int, 7> boards,
bool largeNonBend)
103 int stripPitchNBP = largeNonBend ? 4 : 2;
104 int nStripsNBP = 32 / stripPitchNBP;
105 for (
int icolumn = 0; icolumn < 5; ++icolumn) {
106 setupSegmentation(rpcLine, icolumn, nStripsNBP, stripPitchNBP, 2, boards[icolumn]);
108 setupSegmentation(rpcLine, 5, 8, 4, 2, boards[5]);
109 setupSegmentationLastColumn(rpcLine, boards[6]);
113void Mapping::buildDETypeCut(
int rpcLine, std::array<int, 7> boards,
bool isBelowBeamPipe)
116 setupSegmentation(rpcLine, 0, 16, 2, 3, boards[0], isBelowBeamPipe);
117 for (
int icolumn = 1; icolumn < 6; ++icolumn) {
118 int nBoardsBP = (icolumn < 3) ? 4 : 2;
119 int stripPitchNBP = (icolumn < 5) ? 2 : 4;
120 setupSegmentation(rpcLine, icolumn, 32 / stripPitchNBP, stripPitchNBP, nBoardsBP, boards[icolumn]);
122 setupSegmentationLastColumn(rpcLine, boards[6]);
126void Mapping::buildDETypeShort(
int rpcLine, std::array<int, 7> boards)
129 setupSegmentation(rpcLine, 0, 0, 0, 0, boards[0]);
130 setupSegmentation(rpcLine, 1, 8, 2, 4, boards[1]);
131 for (
int icolumn = 2; icolumn < 6; ++icolumn) {
132 int nBoardsBP = (icolumn < 3) ? 4 : 2;
133 int stripPitchNBP = (icolumn < 5) ? 2 : 4;
134 setupSegmentation(rpcLine, icolumn, 32 / stripPitchNBP, stripPitchNBP, nBoardsBP, boards[icolumn]);
136 setupSegmentationLastColumn(rpcLine, boards[6]);
149 int stripPitch = (cathode == 0) ? mDetectionElements[rpcLine].columns[column].stripPitchBP
150 : mDetectionElements[rpcLine].columns[column].stripPitchNBP;
165 return mDetectionElements[rpcLine].columns[column].nStripsNBP;
174 return (rpcLine == 4) ? 1 : 0;
184 return ((mDetectionElements[rpcLine].columns[column].boardsBP[0] == 117) ? 1 : 0);
194 int lastBoard = mDetectionElements[rpcLine].columns[column].boardsBP.size() - 1;
195 if (column == 0 && rpcLine == 3) {
210 if (line < mDetectionElements[rpcLine].columns[column].boardsBP.size()) {
211 int boardIdx = mDetectionElements[rpcLine].columns[column].boardsBP[line];
212 if (boardIdx < 117) {
213 int boardId = boardIdx + 1;
221 std::cerr <<
"Cannot find local board in DE " << deId <<
" column " << column <<
" line " << line << std::endl;
236 return (cathode == 0) ? getNeighboursBP(stripIndex, rpcLine) : getNeighboursNBP(stripIndex, rpcLine);
240std::vector<Mapping::MpStripIndex> Mapping::getNeighboursNBP(
const Mapping::MpStripIndex& stripIndex,
int rpcLine)
const
243 std::vector<MpStripIndex> neighbours;
245 for (
int delta = -1; delta <= 1; delta += 2) {
246 neigh.column = stripIndex.
column;
247 neigh.line = stripIndex.
line;
248 neigh.strip = stripIndex.
strip + delta;
249 if (neigh.strip < 0) {
250 if (stripIndex.
column == 0 || (stripIndex.
column == 1 && rpcLine == 4)) {
254 if (!isValidLine(neigh.line, neigh.column, rpcLine)) {
258 neigh.strip = mDetectionElements[rpcLine].columns[neigh.column].nStripsNBP - 1;
259 }
else if (neigh.strip >= mDetectionElements[rpcLine].columns[stripIndex.
column].nStripsNBP) {
260 if (stripIndex.
column == 6) {
266 neighbours.push_back(neigh);
272std::vector<Mapping::MpStripIndex> Mapping::getNeighboursBP(
const Mapping::MpStripIndex& stripIndex,
int rpcLine)
const
275 std::vector<MpStripIndex> neighbours;
278 for (
int delta = -1; delta <= 1; delta += 2) {
279 neigh.column = stripIndex.column;
280 neigh.line = stripIndex.line;
281 neigh.strip = stripIndex.strip + delta;
282 if (neigh.strip < 0) {
284 if (!isValidLine(neigh.line, neigh.column, rpcLine)) {
290 if (!isValidLine(neigh.line, neigh.column, rpcLine)) {
295 neighbours.push_back(neigh);
299 int stripPitch = mDetectionElements[rpcLine].columns[stripIndex.column].stripPitchBP;
300 for (
int delta = -1; delta <= 1; delta += 2) {
301 neigh.column = stripIndex.column + delta;
302 if (!isValidColumn(neigh.column, rpcLine)) {
305 int stripPitchNeigh = mDetectionElements[rpcLine].columns[neigh.column].stripPitchBP;
306 int absStripNeigh = (
detparams::NStripsBP * stripIndex.line + stripIndex.strip) * stripPitch / stripPitchNeigh;
308 if (!isValidLine(neigh.line, neigh.column, rpcLine)) {
312 neighbours.push_back(neigh);
313 if (stripPitch > stripPitchNeigh) {
314 neigh.strip = (neigh.strip % 2 == 0) ? neigh.strip + 1 : neigh.strip - 1;
315 neighbours.push_back(neigh);
332 int step = (descending) ? -1 : 1;
335 if (neigh.
strip < 0 || neigh.
strip >= nStrips) {
339 isOk = isValidLine(neigh.
line, neigh.
column, rpcLine);
342 isOk = isValidColumn(neigh.
column, rpcLine);
345 if (neigh.
strip < 0) {
347 nStrips = mDetectionElements[rpcLine].columns[neigh.
column].nStripsNBP;
349 neigh.
strip = nStrips - 1;
369 if (deId < 0 || deId >= 72) {
373 if (!isValidColumn(column, rpcLine)) {
376 if (!isValidLine(line, column, rpcLine)) {
380 int nStrips = (cathode == 0) ?
detparams::NStripsBP : mDetectionElements[rpcLine].columns[column].nStripsNBP;
381 if (strip < 0 || strip >= nStrips) {
389bool Mapping::isValidColumn(
int column,
int rpcLine)
const
392 if (column < 0 || column > 6 || (rpcLine == 4 && column == 0)) {
400bool Mapping::isValidLine(
int line,
int column,
int rpcLine)
const
403 auto& columnStruct{mDetectionElements[rpcLine].columns[column]};
405 if (line >= columnStruct.boardsBP.size() || columnStruct.boardsBP[line] == 117) {
416 if (strip > 7 && stripPitch == 4) {
423double Mapping::getColumnLeftPosition(
int column,
int chamber,
int rpcLine)
const
427 double col = (double)column;
429 col += (column == 1) ? -1. : -1.5;
435double Mapping::getColumnBottomPosition(
int column,
int chamber,
int rpcLine)
const
438 double nBoardsDown = (rpcLine == 5 && column == 0) ? 1. : 2.;
443double Mapping::getColumnHeight(
int column,
int chamber,
int rpcLine)
const
446 double sizeFactor = 1.;
447 if (column == 0 && (rpcLine == 3 || rpcLine == 5)) {
454double Mapping::getColumnWidth(
int column,
int chamber,
int rpcLine)
const
457 double sizeFactor = 1.;
460 }
else if (column == 1 && rpcLine == 4) {
467double Mapping::getStripLowEdge(
int strip,
int stripPitch,
int line,
int chamber)
const
475double Mapping::getStripLeftEdge(
int strip,
int stripPitch,
int column,
int chamber,
int rpcLine)
const
478 if (column == 6 && strip > 7) {
483 return getStripSize(chamber, stripPitch) * strip + getColumnLeftPosition(column, chamber, rpcLine);
499 auto& columnStruct{mDetectionElements[deType].columns[column]};
501 double x1 = 0.,
y1 = 0., x2 = 0., y2 = 0.;
504 x1 = getColumnLeftPosition(column, chamber, deType);
505 x2 =
x1 + getColumnWidth(column, chamber, deType);
507 y1 = getStripLowEdge(strip, columnStruct.stripPitchBP, line, chamber);
509 }
else if (strip < columnStruct.nStripsNBP) {
511 y1 = getColumnBottomPosition(column, chamber, deType);
513 y2 =
y1 + getColumnHeight(column, chamber, deType);
516 x1 = getStripLeftEdge(strip, columnStruct.stripPitchNBP, column, chamber, deType);
517 x2 =
x1 +
getStripSize(chamber, columnStruct.stripPitchNBP, strip);
519 std::cout <<
"Warning: no non-bending strip " << strip <<
" in column " << column <<
" of DE " << deId << std::endl;
534 assert(boardId <= 234);
535 auto& boardIndex{mBoardIndexes[(boardId - 1) % 117]};
536 int deId = boardIndex.deType + 9 * chamber;
540 return stripByLocation(strip, cathode, boardIndex.line, boardIndex.column, deId, warn);
544int Mapping::getColumn(
double xPos,
int chamber,
int rpcLine)
const
554 xShift += 1.5 * boardUnitWidth;
556 double column = xShift / boardUnitWidth;
559 }
else if (column > 6) {
567int Mapping::getLine(
double yPos,
const MpColumn& column,
int chamber)
const
570 unsigned long int nBoards = column.boardsBP.size();
576 double yShift = yPos + 2. * boardUnitHeight;
580 double boardHeight = boardUnitHeight * 4 / nBoards;
581 int iline = (
int)(yShift / boardHeight);
582 if (iline >= nBoards) {
585 if (column.boardsBP[iline] == 117) {
604 stripIndex.
column = getColumn(xPos, chamber, rpcLine);
606 stripIndex.
strip = 16;
608 if (stripIndex.
column >= 7) {
610 std::cout <<
"Warning: xPos " << xPos <<
" not inside RPC " << deId << std::endl;
615 const auto& column{mDetectionElements[rpcLine].columns[stripIndex.
column]};
616 stripIndex.
line = getLine(yPos, column, chamber);
617 if (stripIndex.
line >= 4) {
619 std::cout <<
"Warning: yPos " << yPos <<
" not inside RPC " << deId << std::endl;
626 double stripSize =
getStripSize(chamber, column.stripPitchBP);
627 stripIndex.
strip = (
int)((yPos - yBoardLow) / stripSize);
629 double xBoardLeft = getColumnLeftPosition(stripIndex.
column, chamber, rpcLine);
630 double stripSize =
getStripSize(chamber, column.stripPitchNBP);
631 double diff = xPos - xBoardLeft;
633 if (stripIndex.
column == 6) {
634 double offset = 8. * stripSize;
637 stripSize = stripSize / 2.;
641 stripIndex.
strip = (
int)(diff / stripSize) + stripOffset;
Useful detector parameters for MID.
Useful geometrical parameters for MID.
int getNStripsNBP(int column, int deId) const
int getBoardId(int line, int column, int deId, bool warn=true) const
int getFirstColumn(int deId) const
bool isValid(int deId, int column, int cathode=0, int line=0, int strip=0) const
MpStripIndex stripByPosition(double xPos, double yPos, int cathode, int deId, bool warn=true) const
MpArea stripByLocationInBoard(int strip, int cathode, int boardId, int chamber, bool warn=true) const
int getLastBoardBP(int column, int deId) const
int getFirstBoardBP(int column, int deId) const
double getStripSize(int strip, int cathode, int column, int deId) const
MpArea stripByLocation(int strip, int cathode, int line, int column, int deId, bool warn=true) const
std::vector< MpStripIndex > getNeighbours(const Mapping::MpStripIndex &stripIndex, int cathode, int deId) const
MpStripIndex nextStrip(const MpStripIndex &stripIndex, int cathode, int deId, bool descending=false) const
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLuint GLfloat GLfloat GLfloat x1
constexpr int NDetectionElements
Number of RPCs.
constexpr int NStripsBP
Number of strips in the Bending Plane.
double getLocalBoardWidth(int chamber)
double getLocalBoardHeight(int chamber)
double getStripUnitPitchSize(int chamber)
double getRPCHalfLength(int chamber, int rpc)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Indexes required to define a strip in the detection element.
int strip
Line of the local board in the column.
int line
Column in the DE.