17#include <fmt/format.h>
26 const unsigned int row = ulrow / groupRows;
27 return (
row >= groupedrows) ? (groupedrows - 1) :
row;
30unsigned int o2::tpc::IDCGroupHelperRegion::getGroupedPad(
const unsigned int upad,
const unsigned int ulrow,
const unsigned int region,
const unsigned int groupPads,
const unsigned int groupRows,
const unsigned int groupedrows,
const unsigned int groupPadsSectorEdges,
const std::vector<unsigned int>& padsPerRow)
32 const int relPadHalf =
static_cast<int>(std::floor((upad - 0.5f *
Mapper::PADSPERROW[region][ulrow]) / groupPads));
33 const unsigned int nGroupedPads = padsPerRow[getGroupedRow(ulrow, groupRows, groupedrows)];
34 const unsigned int nGroupedPadsHalf = (nGroupedPads / 2);
35 if (std::abs(relPadHalf) >= nGroupedPadsHalf) {
36 return std::signbit(relPadHalf) ? 0 : nGroupedPads - 1;
38 return static_cast<unsigned int>(
static_cast<int>(nGroupedPadsHalf) + relPadHalf);
52 if (ulrow < lastRow) {
53 const int relPadinRow = ulrow % groupRows;
54 const int localPadOffset = relPadinRow * padsGroupedSecEdge;
55 const int totalOff = isLeftSide ? (localPadOffset + getIndexGroupPadsSectorEdges(groupPadsSectorEdges, upad) - padsGroupedSecEdge * groupRows) : (localPadOffset + getIndexGroupPadsSectorEdges(groupPadsSectorEdges,
Mapper::PADSPERROW[region][ulrow] - upad - 1) + 1);
58 const int relPadinRow = ulrow - lastRow;
59 const int localPadOffset = relPadinRow * padsGroupedSecEdge;
60 const int totalOff = isLeftSide ? (localPadOffset + getIndexGroupPadsSectorEdges(groupPadsSectorEdges, upad) - padsGroupedSecEdge * (
Mapper::ROWSPERREGION[region] - lastRow)) : (localPadOffset + getIndexGroupPadsSectorEdges(groupPadsSectorEdges,
Mapper::PADSPERROW[region][ulrow] - upad - 1) + 1);
64 const int totalOff = isLeftSide ? (getIndexGroupPadsSectorEdges(groupPadsSectorEdges, upad) - padsGroupedSecEdge) : (getIndexGroupPadsSectorEdges(groupPadsSectorEdges,
Mapper::PADSPERROW[region][ulrow] - upad - 1) + 1);
68 throw std::invalid_argument(
"Wrong type for EdgePadGroupingMethod");
75 mPadsPerRow.resize(mRows);
76 mOffsRow.resize(mRows);
82 const unsigned int rowsRemainder = nTotRows % mGroupRows;
83 unsigned int lastRow = nTotRows - rowsRemainder;
84 if (rowsRemainder <= mGroupLastRowsThreshold) {
85 lastRow -= mGroupRows;
90unsigned int o2::tpc::IDCGroupHelperRegion::getLastPad(
const unsigned int ulrow,
const unsigned int region,
const unsigned char groupPads,
const unsigned char groupLastPadsThreshold,
const unsigned int groupPadsSectorEdges)
93 const unsigned int padsRemainder = nPads % groupPads;
94 int unsigned lastPad = (padsRemainder == 0) ? nPads - groupPads : nPads - padsRemainder;
95 if (padsRemainder && padsRemainder <= groupLastPadsThreshold) {
103 const unsigned int nRows = getLastRow() / mGroupRows + 1;
105 for (
unsigned int irow = 0; irow < nRows; ++irow) {
106 const unsigned int row = irow * mGroupRows;
107 mPadsPerRow[irow] = 2 * (getLastPad(
row) / mGroupPads + 1);
113 mNIDCsPerCRU = std::accumulate(mPadsPerRow.begin(), mPadsPerRow.end(),
decltype(mPadsPerRow)::value_type(0)) + 2 * padsSectorEdge * getGroupedPadsSectorEdges();
114 mOffsRow.front() = getGroupedPadsSectorEdges() * rowsSectorEdge;
115 for (
unsigned int i = 1;
i < (mRows - 1); ++
i) {
116 const unsigned int lastInd =
i - 1;
117 mOffsRow[
i] = mOffsRow[lastInd] + mPadsPerRow[lastInd] + 2 * getGroupedPadsSectorEdges() * rowsSectorEdge;
121 mOffsRow.back() = mOffsRow[mRows - 2] + mPadsPerRow[mRows - 2] + getGroupedPadsSectorEdges() * offsIndex;
127 TFile fOut(outFileName,
"UPDATE");
128 fOut.WriteObject(
this, outName);
149 return getIndexGroupPadsSectorEdges(mGroupPadsSectorEdges, urelpad);
154 const auto totalUngroupedPads = groupPadsSectorEdges % 10 +
count;
155 if (urelpad < totalUngroupedPads) {
158 return 1 + getIndexGroupPadsSectorEdges(groupPadsSectorEdges / 10, urelpad, totalUngroupedPads);
helper class for grouping of pads and rows for one region
Definition of the parameter for the grouping of the IDCs.
static unsigned int getGroupedPad(const unsigned int upad, const unsigned int ulrow, const unsigned int region, const unsigned int groupPads, const unsigned int groupRows, const unsigned int groupedrows, const unsigned int groupPadsSectorEdges, const std::vector< unsigned int > &padsPerRow)
unsigned int getGroupedPadsSectorEdges() const
void dumpToFile(const char *outFileName="IDCGroupHelperRegion.root", const char *outName="IDCGroupHelperRegion") const
unsigned int getLastPad(const unsigned int ulrow) const
void setRows(const unsigned int nRows)
set number of grouped rows
static unsigned int getGroupedRow(const unsigned int ulrow, const unsigned int groupRows, const unsigned int groupedrows)
unsigned int getTotalGroupPadsSectorEdges() const
static bool isSectorEdgePad(const unsigned int upad, const unsigned int ulrow, const unsigned int region, const unsigned int groupPadsSectorEdges)
unsigned int getIndexUngroupedGlob(const unsigned int ugrow, const unsigned int upad, unsigned int integrationInterval) const
EdgePadGroupingMethod getEdgePadGroupingType() const
static int getOffsetForEdgePad(const unsigned int upad, const unsigned int ulrow, const unsigned int groupRows, const unsigned int groupPadsSectorEdges, const unsigned int region, const int lastRow)
void initIDCGroupHelperRegion()
initialize members
const unsigned int mRegion
region of input IDCs
unsigned int getPadsInGroupSectorEdges(const unsigned indexGroup) const
static unsigned int getIndexGroupPadsSectorEdges(const unsigned int groupPadsSectorEdges, const unsigned int urelpad)
unsigned int getGlobalPadNumber(const unsigned int ulrow, const unsigned int pad) const
unsigned int getLastRow() const
static constexpr unsigned int ROWOFFSET[NREGIONS]
offset to calculate local row from global row
static GlobalPadNumber getGlobalPadNumber(const unsigned int lrow, const unsigned int pad, const unsigned int region)
static const std::vector< unsigned int > PADSPERROW[NREGIONS]
number of pads per row in region
static constexpr unsigned int ROWSPERREGION[NREGIONS]
number of pad rows for region
@ NO
no grouping in row direction
@ ROWS
grouping in row direction
static EdgePadGroupingMethod getEdgePadGroupingType(unsigned int groupPadsSectorEdges)
static unsigned int getGroupedPadsSectorEdges(unsigned int groupPadsSectorEdges)
static unsigned int getPadsInGroupSectorEdges(unsigned int groupPadsSectorEdges, const unsigned int group)
static unsigned int getTotalGroupPadsSectorEdges(unsigned int groupPadsSectorEdges)