125 std::vector<IDCAverageGroupHelper<IDCAverageGroupTPC>> idcStruct(sNThreads,
IDCAverageGroupHelper<IDCAverageGroupTPC>{this->mIDCsGrouped, this->mWeightsPad, this->mWeightsRow, this->mIDCsUngrouped, this->mRobustAverage, this->mIDCGroupHelperSector});
126 for (
int thread = 0; thread < sNThreads; ++thread) {
127 idcStruct[thread].setThreadNum(thread);
130 const int cruStart = (mSide == Side::A) ? 0 : CRU::MaxCRU / 2;
131 const int cruEnd = (mSide == Side::A) ? CRU::MaxCRU / 2 : CRU::MaxCRU;
133#pragma omp parallel for num_threads(sNThreads)
134 for (
unsigned int i = cruStart;
i < cruEnd; ++
i) {
135 const unsigned int threadNum = omp_get_thread_num();
137 idcStruct[threadNum].setCRU(cru);
138 for (
unsigned int integrationInterval = 0; integrationInterval < this->getNIntegrationIntervals(); ++integrationInterval) {
139 idcStruct[threadNum].setIntegrationInterval(integrationInterval);
140 loopOverGroups(idcStruct[threadNum], padStatusFlags);
148 const auto& mapper = Mapper::instance();
149 const float xMin = 83.65f;
150 const float xMax = 247.7f;
151 const float yMin = -51;
152 const float yMax = 49;
154 poly->GetXaxis()->SetTickLength(0.01f);
156 poly->SetContour(255);
157 gStyle->SetNumberContours(255);
159 TCanvas can(
"can",
"can", 2000, 1400);
160 can.SetRightMargin(0.01f);
161 can.SetLeftMargin(0.06f);
162 can.SetTopMargin(0.04f);
164 poly->SetTitle(
nullptr);
165 poly->GetYaxis()->SetTickSize(0.002f);
166 poly->GetYaxis()->SetTitleOffset(0.7f);
171 for (
unsigned int i = 0;
i < Mapper::NREGIONS; ++
i) {
172 if constexpr (std::is_same_v<Type, IDCAverageGroupCRU>) {
173 IDCAverageGroupHelper<IDCAverageGroupDraw> idcStruct(this->mIDCsGrouped.getGroupPads(), this->mIDCsGrouped.getGroupRows(), this->mIDCsGrouped.getGroupLastRowsThreshold(), this->mIDCsGrouped.getGroupLastPadsThreshold(), this->mIDCsGrouped.getGroupPadsSectorEdges(),
i, Mapper::PADSPERREGION[
i], mapper.getPadRegionInfo(
i), *poly);
174 loopOverGroups(idcStruct);
175 const int nidcs = this->mIDCsGrouped.getNIDCsPerIntegrationInterval();
177 drawGroupingInformations(
i, this->mIDCsGrouped.getGroupPads(), this->mIDCsGrouped.getGroupRows(), this->mIDCsGrouped.getGroupLastRowsThreshold(), this->mIDCsGrouped.getGroupLastPadsThreshold(), mOverlapRows, mOverlapPads, nidcs, this->mIDCsGrouped.getGroupPadsSectorEdges());
179 IDCAverageGroupHelper<IDCAverageGroupDraw> idcStruct(this->mIDCGroupHelperSector.getGroupingParameter().getGroupPads(
i), this->mIDCGroupHelperSector.getGroupingParameter().getGroupRows(
i), this->mIDCGroupHelperSector.getGroupingParameter().getGroupLastRowsThreshold(
i), this->mIDCGroupHelperSector.getGroupingParameter().getGroupLastPadsThreshold(
i), this->mIDCGroupHelperSector.getGroupingParameter().getGroupPadsSectorEdges(),
i, Mapper::PADSPERREGION[
i], mapper.getPadRegionInfo(
i), *poly);
180 loopOverGroups(idcStruct);
181 const int nidcs = this->mIDCGroupHelperSector.getNIDCs(
i);
183 drawGroupingInformations(
i, this->mIDCGroupHelperSector.getGroupingParameter().getGroupPads(
i), this->mIDCGroupHelperSector.getGroupingParameter().getGroupRows(
i), this->mIDCGroupHelperSector.getGroupingParameter().getGroupLastRowsThreshold(
i), this->mIDCGroupHelperSector.getGroupingParameter().getGroupLastPadsThreshold(
i), mOverlapRows, mOverlapPads, nidcs, this->mIDCGroupHelperSector.getGroupingParameter().getGroupPadsSectorEdges());
187 painter::drawSectorLocalPadNumberPoly(kBlack);
188 painter::drawSectorInformationPoly(kRed, kRed);
191 lat.SetTextColor(kBlack);
192 lat.SetTextSize(0.02f);
193 lat.SetTextAlign(12);
194 const float posYInf = -44.5f;
195 const float offsx = 1;
196 lat.DrawLatex(xMin + offsx, posYInf,
"nPads | nRows | nLastPads | nLastRows");
198 lat.SetTextColor(kGreen + 2);
199 lat.DrawLatex(mapper.getPadRegionInfo(4).getRadiusFirstRow(), posYInf,
"nPadsSectorEdge | overlapRows | overlapPads");
201 lat.SetTextColor(kBlack);
202 lat.DrawLatex(xMin + offsx, 47.2f,
"IDCs");
205 const int dataRate = sumIDCs * Mapper::NSECTORS *
sizeof(short) * 1000 / (1024 * 1024);
206 lat.DrawLatex(xMin + offsx, 50.5f, fmt::format(
"IDCDelta data rate (short): {} MB/s IDCs per sector: {}", dataRate, sumIDCs).
data());
208 if constexpr (std::is_same_v<Type, IDCAverageGroupCRU>) {
209 const std::string outName =
filename.empty() ? fmt::format(
"grouping_rows-{}_pads-{}_rowThr-{}_padThr-{}_ovRows-{}_ovPads-{}_edge-{}.pdf", this->mIDCsGrouped.getGroupPads(), this->mIDCsGrouped.getGroupRows(), this->mIDCsGrouped.getGroupLastRowsThreshold(), this->mIDCsGrouped.getGroupLastPadsThreshold(), mOverlapRows, mOverlapPads, this->mIDCsGrouped.getGroupPadsSectorEdges()) :
filename;
210 can.SaveAs(outName.data());
212 std::string sgrRows = {
"_"};
213 std::string sgrPads = {
"_"};
214 std::string sgrRowsTh = {
"_"};
215 std::string sgrPadsTh = {
"_"};
217 for (
unsigned int i = 0;
i < Mapper::NREGIONS; ++
i) {
218 const int grRows = this->mIDCGroupHelperSector.getGroupingParameter().getGroupRows(
i);
219 sgrRows += fmt::format(
"{}_", grRows);
220 const int grPads = this->mIDCGroupHelperSector.getGroupingParameter().getGroupPads(
i);
221 sgrPads += fmt::format(
"{}_", grPads);
222 const int grRowsTh = this->mIDCGroupHelperSector.getGroupingParameter().getGroupLastRowsThreshold(
i);
223 sgrRowsTh += fmt::format(
"{}_", grRowsTh);
224 const int grPadsTh = this->mIDCGroupHelperSector.getGroupingParameter().getGroupLastPadsThreshold(
i);
225 sgrPadsTh += fmt::format(
"{}_", grPadsTh);
228 const std::string outName =
filename.empty() ? fmt::format(
"grouping_rows{}pads{}rowThr{}padThr{}ovRows-{}_ovPads-{}_edge-{}.pdf", sgrRows, sgrPads, sgrRowsTh, sgrPadsTh, mOverlapRows, mOverlapPads, this->mIDCGroupHelperSector.getGroupingParameter().getGroupPadsSectorEdges()) :
filename;
229 can.SaveAs(outName.data());
235void o2::tpc::IDCAverageGroup<Type>::drawGroupingInformations(
const int region,
const int grPads,
const int grRows,
const int groupLastRowsThreshold,
const int groupLastPadsThreshold,
const int overlapRows,
const int overlapPads,
const int nIDCs,
const int groupPadsSectorEdges)
const
240 lat.SetTextColor(kBlack);
241 lat.SetTextSize(0.02f);
242 lat.SetTextAlign(12);
247 lat.DrawLatex(radius, -47, fmt::format(
"{} | {} | {} | {}", grPads, grRows, groupLastRowsThreshold, groupLastPadsThreshold).
data());
249 lat.SetTextColor(kGreen + 2);
250 lat.DrawLatex(radius, -49, fmt::format(
"{} | {} | {}", groupPadsSectorEdges, overlapRows, overlapPads).
data());
253 lat.SetTextColor(kBlack);
255 lat.DrawLatex((radius + radiusNext) / 2, 47.2f, Form(
"%i", nIDCs));
259template <
class LoopType>
262 const unsigned int region = idcStruct.getRegion();
263 const int groupRows = idcStruct.getGroupRows();
264 const int groupPads = idcStruct.getGroupPads();
265 const int lastRow = idcStruct.getLastRow();
266 const int groupPadsSectorEdges = idcStruct.getTotalGroupPadsSectorEdges();
267 unsigned int rowGrouped = 0;
268 const bool applyWeights = mOverlapRows && mOverlapPads;
270 if (groupPadsSectorEdges) {
271 const auto groupingType = idcStruct.getEdgePadGroupingType();
272 const bool groupRowsEdge = groupingType == EdgePadGroupingMethod::ROWS;
273 const int groupedPads = idcStruct.getGroupedPadsSectorEdges();
274 const int endrow = groupRowsEdge ? lastRow + 1 : Mapper::ROWSPERREGION[region];
275 const int stepRow = groupRowsEdge ? groupRows : 1;
276 for (
int ulrow = 0; ulrow < endrow; ulrow += stepRow) {
277 const bool bNotLastrow = ulrow != lastRow;
279 if constexpr (std::is_same_v<LoopType, IDCAverageGroupDraw>) {
280 idcStruct.mCol = ulrow / stepRow;
283 for (
int iYLocalSide = 0; iYLocalSide < 2; ++iYLocalSide) {
285 for (
int padGroup = 0; padGroup < groupedPads; ++padGroup) {
286 const int nPadsPerGroup = idcStruct.getPadsInGroupSectorEdges(padGroup);
287 for (
int padInGroup = 0; padInGroup < nPadsPerGroup; ++padInGroup) {
288 const int endRow = (groupRowsEdge && (ulrow + stepRow >= Mapper::ROWSPERREGION[region] || !bNotLastrow)) ? (Mapper::ROWSPERREGION[region] - ulrow) : stepRow;
289 for (
int iRowMerge = 0; iRowMerge < endRow; ++iRowMerge) {
290 const int irow = ulrow + iRowMerge;
291 const int ungroupedPad = !iYLocalSide ? pad : Mapper::PADSPERROW[region][irow] - pad - 1;
292 const int padInRegion = Mapper::OFFSETCRULOCAL[region][irow] + ungroupedPad;
294 if constexpr (std::is_same_v<LoopType, IDCAverageGroupCRU> || std::is_same_v<LoopType, IDCAverageGroupTPC>) {
295 if (padStatusFlags) {
296 const auto flag = padStatusFlags->getCalArray(idcStruct.getCRU()).
getValue(padInRegion);
297 if ((flag & PadFlags::flagSkip) == PadFlags::flagSkip) {
301 idcStruct.addValue(padInRegion, 1);
304 drawLatex(idcStruct, padNum, padInRegion,
true);
309 if constexpr (std::is_same_v<LoopType, IDCAverageGroupCRU> || std::is_same_v<LoopType, IDCAverageGroupTPC>) {
310 const int ungroupedPad = !iYLocalSide ? pad - 1 : Mapper::PADSPERROW[region][ulrow] - pad;
311 idcStruct.setSectorEdgeIDC(ulrow, ungroupedPad);
312 idcStruct.clearRobustAverage();
314 ++idcStruct.mGroupCounter;
323 for (
int iRow = 0; iRow <= lastRow; iRow += groupRows) {
324 const bool bNotLastrow = iRow != lastRow;
327 for (
int iYLocalSide = 0; iYLocalSide < 2; ++iYLocalSide) {
328 if constexpr (std::is_same_v<LoopType, IDCAverageGroupDraw>) {
329 idcStruct.mCol = region + iRow / groupRows + iYLocalSide;
331 unsigned int padGrouped = iYLocalSide ? idcStruct.getPadsPerRow(rowGrouped) / 2 : idcStruct.getPadsPerRow(rowGrouped) / 2 - 1;
332 const int nPadsStart = Mapper::PADSPERROW[region][iRow] / 2;
333 const int nPadsEnd = idcStruct.getLastPad(iRow) + nPadsStart;
336 for (
int iPad = nPadsStart; iPad <= nPadsEnd; iPad += groupPads) {
337 if constexpr (std::is_same_v<LoopType, IDCAverageGroupCRU> || std::is_same_v<LoopType, IDCAverageGroupTPC>) {
338 idcStruct.clearRobustAverage();
341 const int startRow = ((iRow - mOverlapRows) < 0) ? 0 : -mOverlapRows;
342 const int endRow = ((iRow + groupRows + mOverlapRows) >= Mapper::ROWSPERREGION[region] || !bNotLastrow) ? (Mapper::ROWSPERREGION[region] - iRow) : (mOverlapRows + groupRows);
343 for (
int iRowMerge = startRow; iRowMerge < endRow; ++iRowMerge) {
344 const bool bOverlapRowRight = iRowMerge >= groupRows;
345 const unsigned int ungroupedRow = iRow + iRowMerge;
346 const int offsPad =
static_cast<int>(Mapper::ADDITIONALPADSPERROW[region][ungroupedRow]) -
static_cast<int>(Mapper::ADDITIONALPADSPERROW[region][iRow]);
348 const bool lastPad = iPad == nPadsEnd;
349 const int padEnd = lastPad ? (
static_cast<int>(Mapper::PADSPERROW[region][ungroupedRow]) - iPad - groupPadsSectorEdges) : (groupPads + offsPad + mOverlapPads);
350 const int padStart = offsPad - mOverlapPads;
352 for (
int ipadMerge = padStart; ipadMerge < padEnd; ++ipadMerge) {
353 const unsigned int ungroupedPad = iYLocalSide ? (iPad + ipadMerge) : Mapper::PADSPERROW[region][ungroupedRow] - (iPad + ipadMerge) - 1;
354 const unsigned int padInRegion = Mapper::OFFSETCRULOCAL[region][ungroupedRow] + ungroupedPad;
357 if constexpr (std::is_same_v<LoopType, IDCAverageGroupCRU> || std::is_same_v<LoopType, IDCAverageGroupTPC>) {
359 if (padStatusFlags) {
360 const auto flag = padStatusFlags->getCalArray(idcStruct.getCRU()).
getValue(padInRegion);
361 if ((flag & PadFlags::flagSkip) == PadFlags::flagSkip) {
371 const int relPosRow = std::abs(iRowMerge);
372 if (ipadMerge < offsPad) {
373 const int relPosPad = std::abs(ipadMerge - offsPad);
374 weight = idcStruct.getWeight(relPosRow, relPosPad);
375 }
else if (!lastPad && ipadMerge >= (groupPads + offsPad)) {
376 const int relPosPad = std::abs(1 + ipadMerge - (groupPads + offsPad));
377 weight = idcStruct.getWeight(relPosRow, relPosPad);
379 weight = idcStruct.getWeightRow(relPosRow);
381 }
else if (bNotLastrow && bOverlapRowRight) {
382 const int relPosRow = std::abs(1 + iRowMerge - (groupRows));
383 if (ipadMerge < offsPad) {
384 const int relPosPad = std::abs(ipadMerge - offsPad);
385 weight = idcStruct.getWeight(relPosRow, relPosPad);
386 }
else if (!lastPad && ipadMerge >= (groupPads + offsPad)) {
387 const int relPosPad = std::abs(1 + ipadMerge - (groupPads + offsPad));
388 weight = idcStruct.getWeight(relPosRow, relPosPad);
390 weight = idcStruct.getWeightRow(relPosRow);
392 }
else if (ipadMerge < offsPad) {
394 const int relPadPos = std::abs(ipadMerge - offsPad);
395 weight = idcStruct.getWeightPad(relPadPos);
396 }
else if (!lastPad && ipadMerge >= (groupPads + offsPad)) {
397 const int relPadPos = std::abs(1 + ipadMerge - (groupPads + offsPad));
398 weight = idcStruct.getWeightPad(relPadPos);
401 idcStruct.addValue(padInRegion,
weight);
403 idcStruct.addValue(padInRegion);
409 const bool fillNotPoly = iRowMerge < 0 || (bNotLastrow && bOverlapRowRight) || (ipadMerge < offsPad) || (!lastPad && ipadMerge >= (groupPads + offsPad));
410 drawLatex(idcStruct, padNum, padInRegion, !fillNotPoly, idcStruct.mColors.size());
414 if constexpr (std::is_same_v<LoopType, IDCAverageGroupCRU> || std::is_same_v<LoopType, IDCAverageGroupTPC>) {
415 idcStruct.setGroupedIDC(rowGrouped, padGrouped, applyWeights);
417 ++idcStruct.mGroupCounter;
420 iYLocalSide ? ++padGrouped : --padGrouped;
430 TFile fOut(outFileName,
"RECREATE");
431 fOut.WriteObject(
this, outName);
438 TFile inpf(fileName,
"READ");
440 Temp* idcAverageGroupTmp{
nullptr};
441 idcAverageGroupTmp =
reinterpret_cast<Temp*
>(inpf.GetObjectChecked(
name, Temp::Class()));
443 if (!idcAverageGroupTmp) {
444 LOGP(error,
"Failed to load {} from {}",
name, inpf.GetName());
447 if constexpr (std::is_same_v<Type, IDCAverageGroupCRU>) {
448 this->setIDCs(idcAverageGroupTmp->getIDCsUngrouped());
450 this->setIDCs(idcAverageGroupTmp->getIDCsUngrouped(), idcAverageGroupTmp->getSide());
453 delete idcAverageGroupTmp;