105 const float fac =
x / sigma;
106 return std::exp(-fac * fac / 2);
112 std::vector<IDCAverageGroupHelper<IDCAverageGroupCRU>> idcStruct(sNThreads,
IDCAverageGroupHelper<IDCAverageGroupCRU>{this->mIDCsGrouped, this->mWeightsPad, this->mWeightsRow, this->mIDCsUngrouped, this->mRobustAverage, this->getCRU()});
113#pragma omp parallel for num_threads(sNThreads)
114 for (
unsigned int integrationInterval = 0; integrationInterval < this->getNIntegrationIntervals(); ++integrationInterval) {
115 const unsigned int threadNum = omp_get_thread_num();
116 idcStruct[threadNum].set(threadNum, integrationInterval);
117 loopOverGroups(idcStruct[threadNum], padStatusFlags);
124 std::vector<IDCAverageGroupHelper<IDCAverageGroupTPC>> idcStruct(sNThreads,
IDCAverageGroupHelper<IDCAverageGroupTPC>{this->mIDCsGrouped, this->mWeightsPad, this->mWeightsRow, this->mIDCsUngrouped, this->mRobustAverage, this->mIDCGroupHelperSector});
125 for (
int thread = 0; thread < sNThreads; ++thread) {
126 idcStruct[thread].setThreadNum(thread);
129 const int cruStart = (mSide == Side::A) ? 0 : CRU::MaxCRU / 2;
130 const int cruEnd = (mSide == Side::A) ? CRU::MaxCRU / 2 : CRU::MaxCRU;
132#pragma omp parallel for num_threads(sNThreads)
133 for (
unsigned int i = cruStart;
i < cruEnd; ++
i) {
134 const unsigned int threadNum = omp_get_thread_num();
136 idcStruct[threadNum].setCRU(cru);
137 for (
unsigned int integrationInterval = 0; integrationInterval < this->getNIntegrationIntervals(); ++integrationInterval) {
138 idcStruct[threadNum].setIntegrationInterval(integrationInterval);
139 loopOverGroups(idcStruct[threadNum], padStatusFlags);
147 const auto& mapper = Mapper::instance();
148 const float xMin = 83.65f;
149 const float xMax = 247.7f;
150 const float yMin = -51;
151 const float yMax = 49;
153 poly->GetXaxis()->SetTickLength(0.01f);
155 poly->SetContour(255);
156 gStyle->SetNumberContours(255);
158 TCanvas can(
"can",
"can", 2000, 1400);
159 can.SetRightMargin(0.01f);
160 can.SetLeftMargin(0.06f);
161 can.SetTopMargin(0.04f);
163 poly->SetTitle(
nullptr);
164 poly->GetYaxis()->SetTickSize(0.002f);
165 poly->GetYaxis()->SetTitleOffset(0.7f);
170 for (
unsigned int i = 0;
i < Mapper::NREGIONS; ++
i) {
171 if constexpr (std::is_same_v<Type, IDCAverageGroupCRU>) {
172 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);
173 loopOverGroups(idcStruct);
174 const int nidcs = this->mIDCsGrouped.getNIDCsPerIntegrationInterval();
176 drawGroupingInformations(
i, this->mIDCsGrouped.getGroupPads(), this->mIDCsGrouped.getGroupRows(), this->mIDCsGrouped.getGroupLastRowsThreshold(), this->mIDCsGrouped.getGroupLastPadsThreshold(), mOverlapRows, mOverlapPads, nidcs, this->mIDCsGrouped.getGroupPadsSectorEdges());
178 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);
179 loopOverGroups(idcStruct);
180 const int nidcs = this->mIDCGroupHelperSector.getNIDCs(
i);
182 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());
186 painter::drawSectorLocalPadNumberPoly(kBlack);
187 painter::drawSectorInformationPoly(kRed, kRed);
190 lat.SetTextColor(kBlack);
191 lat.SetTextSize(0.02f);
192 lat.SetTextAlign(12);
193 const float posYInf = -44.5f;
194 const float offsx = 1;
195 lat.DrawLatex(xMin + offsx, posYInf,
"nPads | nRows | nLastPads | nLastRows");
197 lat.SetTextColor(kGreen + 2);
198 lat.DrawLatex(mapper.getPadRegionInfo(4).getRadiusFirstRow(), posYInf,
"nPadsSectorEdge | overlapRows | overlapPads");
200 lat.SetTextColor(kBlack);
201 lat.DrawLatex(xMin + offsx, 47.2f,
"IDCs");
204 const int dataRate = sumIDCs * Mapper::NSECTORS *
sizeof(
short) * 1000 / (1024 * 1024);
205 lat.DrawLatex(xMin + offsx, 50.5f, fmt::format(
"IDCDelta data rate (short): {} MB/s IDCs per sector: {}", dataRate, sumIDCs).
data());
207 if constexpr (std::is_same_v<Type, IDCAverageGroupCRU>) {
208 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;
209 can.SaveAs(outName.data());
211 std::string sgrRows = {
"_"};
212 std::string sgrPads = {
"_"};
213 std::string sgrRowsTh = {
"_"};
214 std::string sgrPadsTh = {
"_"};
216 for (
unsigned int i = 0;
i < Mapper::NREGIONS; ++
i) {
217 const int grRows = this->mIDCGroupHelperSector.getGroupingParameter().getGroupRows(
i);
218 sgrRows += fmt::format(
"{}_", grRows);
219 const int grPads = this->mIDCGroupHelperSector.getGroupingParameter().getGroupPads(
i);
220 sgrPads += fmt::format(
"{}_", grPads);
221 const int grRowsTh = this->mIDCGroupHelperSector.getGroupingParameter().getGroupLastRowsThreshold(
i);
222 sgrRowsTh += fmt::format(
"{}_", grRowsTh);
223 const int grPadsTh = this->mIDCGroupHelperSector.getGroupingParameter().getGroupLastPadsThreshold(
i);
224 sgrPadsTh += fmt::format(
"{}_", grPadsTh);
227 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;
228 can.SaveAs(outName.data());
234void 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
239 lat.SetTextColor(kBlack);
240 lat.SetTextSize(0.02f);
241 lat.SetTextAlign(12);
246 lat.DrawLatex(radius, -47, fmt::format(
"{} | {} | {} | {}", grPads, grRows, groupLastRowsThreshold, groupLastPadsThreshold).
data());
248 lat.SetTextColor(kGreen + 2);
249 lat.DrawLatex(radius, -49, fmt::format(
"{} | {} | {}", groupPadsSectorEdges, overlapRows, overlapPads).
data());
252 lat.SetTextColor(kBlack);
254 lat.DrawLatex((radius + radiusNext) / 2, 47.2f, Form(
"%i", nIDCs));
258template <
class LoopType>
261 const unsigned int region = idcStruct.getRegion();
262 const int groupRows = idcStruct.getGroupRows();
263 const int groupPads = idcStruct.getGroupPads();
264 const int lastRow = idcStruct.getLastRow();
265 const int groupPadsSectorEdges = idcStruct.getTotalGroupPadsSectorEdges();
266 unsigned int rowGrouped = 0;
267 const bool applyWeights = mOverlapRows && mOverlapPads;
269 if (groupPadsSectorEdges) {
270 const auto groupingType = idcStruct.getEdgePadGroupingType();
271 const bool groupRowsEdge = groupingType == EdgePadGroupingMethod::ROWS;
272 const int groupedPads = idcStruct.getGroupedPadsSectorEdges();
273 const int endrow = groupRowsEdge ? lastRow + 1 : Mapper::ROWSPERREGION[region];
274 const int stepRow = groupRowsEdge ? groupRows : 1;
275 for (
int ulrow = 0; ulrow < endrow; ulrow += stepRow) {
276 const bool bNotLastrow = ulrow != lastRow;
278 if constexpr (std::is_same_v<LoopType, IDCAverageGroupDraw>) {
279 idcStruct.mCol = ulrow / stepRow;
282 for (
int iYLocalSide = 0; iYLocalSide < 2; ++iYLocalSide) {
284 for (
int padGroup = 0; padGroup < groupedPads; ++padGroup) {
285 const int nPadsPerGroup = idcStruct.getPadsInGroupSectorEdges(padGroup);
286 for (
int padInGroup = 0; padInGroup < nPadsPerGroup; ++padInGroup) {
287 const int endRow = (groupRowsEdge && (ulrow + stepRow >= Mapper::ROWSPERREGION[region] || !bNotLastrow)) ? (Mapper::ROWSPERREGION[region] - ulrow) : stepRow;
288 for (
int iRowMerge = 0; iRowMerge < endRow; ++iRowMerge) {
289 const int irow = ulrow + iRowMerge;
290 const int ungroupedPad = !iYLocalSide ? pad : Mapper::PADSPERROW[region][irow] - pad - 1;
291 const int padInRegion = Mapper::OFFSETCRULOCAL[region][irow] + ungroupedPad;
293 if constexpr (std::is_same_v<LoopType, IDCAverageGroupCRU> || std::is_same_v<LoopType, IDCAverageGroupTPC>) {
294 if (padStatusFlags) {
295 const auto flag = padStatusFlags->getCalArray(idcStruct.getCRU()).getValue(padInRegion);
296 if ((flag & PadFlags::flagSkip) == PadFlags::flagSkip) {
300 idcStruct.addValue(padInRegion, 1);
303 drawLatex(idcStruct, padNum, padInRegion,
true);
308 if constexpr (std::is_same_v<LoopType, IDCAverageGroupCRU> || std::is_same_v<LoopType, IDCAverageGroupTPC>) {
309 const int ungroupedPad = !iYLocalSide ? pad - 1 : Mapper::PADSPERROW[region][ulrow] - pad;
310 idcStruct.setSectorEdgeIDC(ulrow, ungroupedPad);
311 idcStruct.clearRobustAverage();
313 ++idcStruct.mGroupCounter;
322 for (
int iRow = 0; iRow <= lastRow; iRow += groupRows) {
323 const bool bNotLastrow = iRow != lastRow;
326 for (
int iYLocalSide = 0; iYLocalSide < 2; ++iYLocalSide) {
327 if constexpr (std::is_same_v<LoopType, IDCAverageGroupDraw>) {
328 idcStruct.mCol = region + iRow / groupRows + iYLocalSide;
330 unsigned int padGrouped = iYLocalSide ? idcStruct.getPadsPerRow(rowGrouped) / 2 : idcStruct.getPadsPerRow(rowGrouped) / 2 - 1;
331 const int nPadsStart = Mapper::PADSPERROW[region][iRow] / 2;
332 const int nPadsEnd = idcStruct.getLastPad(iRow) + nPadsStart;
335 for (
int iPad = nPadsStart; iPad <= nPadsEnd; iPad += groupPads) {
336 if constexpr (std::is_same_v<LoopType, IDCAverageGroupCRU> || std::is_same_v<LoopType, IDCAverageGroupTPC>) {
337 idcStruct.clearRobustAverage();
340 const int startRow = ((iRow - mOverlapRows) < 0) ? 0 : -mOverlapRows;
341 const int endRow = ((iRow + groupRows + mOverlapRows) >= Mapper::ROWSPERREGION[region] || !bNotLastrow) ? (Mapper::ROWSPERREGION[region] - iRow) : (mOverlapRows + groupRows);
342 for (
int iRowMerge = startRow; iRowMerge < endRow; ++iRowMerge) {
343 const bool bOverlapRowRight = iRowMerge >= groupRows;
344 const unsigned int ungroupedRow = iRow + iRowMerge;
345 const int offsPad =
static_cast<int>(Mapper::ADDITIONALPADSPERROW[region][ungroupedRow]) -
static_cast<int>(Mapper::ADDITIONALPADSPERROW[region][iRow]);
347 const bool lastPad = iPad == nPadsEnd;
348 const int padEnd = lastPad ? (
static_cast<int>(Mapper::PADSPERROW[region][ungroupedRow]) - iPad - groupPadsSectorEdges) : (groupPads + offsPad + mOverlapPads);
349 const int padStart = offsPad - mOverlapPads;
351 for (
int ipadMerge = padStart; ipadMerge < padEnd; ++ipadMerge) {
352 const unsigned int ungroupedPad = iYLocalSide ? (iPad + ipadMerge) : Mapper::PADSPERROW[region][ungroupedRow] - (iPad + ipadMerge) - 1;
353 const unsigned int padInRegion = Mapper::OFFSETCRULOCAL[region][ungroupedRow] + ungroupedPad;
356 if constexpr (std::is_same_v<LoopType, IDCAverageGroupCRU> || std::is_same_v<LoopType, IDCAverageGroupTPC>) {
358 if (padStatusFlags) {
359 const auto flag = padStatusFlags->getCalArray(idcStruct.getCRU()).
getValue(padInRegion);
360 if ((flag & PadFlags::flagSkip) == PadFlags::flagSkip) {
370 const int relPosRow = std::abs(iRowMerge);
371 if (ipadMerge < offsPad) {
372 const int relPosPad = std::abs(ipadMerge - offsPad);
373 weight = idcStruct.getWeight(relPosRow, relPosPad);
374 }
else if (!lastPad && ipadMerge >= (groupPads + offsPad)) {
375 const int relPosPad = std::abs(1 + ipadMerge - (groupPads + offsPad));
376 weight = idcStruct.getWeight(relPosRow, relPosPad);
378 weight = idcStruct.getWeightRow(relPosRow);
380 }
else if (bNotLastrow && bOverlapRowRight) {
381 const int relPosRow = std::abs(1 + iRowMerge - (groupRows));
382 if (ipadMerge < offsPad) {
383 const int relPosPad = std::abs(ipadMerge - offsPad);
384 weight = idcStruct.getWeight(relPosRow, relPosPad);
385 }
else if (!lastPad && ipadMerge >= (groupPads + offsPad)) {
386 const int relPosPad = std::abs(1 + ipadMerge - (groupPads + offsPad));
387 weight = idcStruct.getWeight(relPosRow, relPosPad);
389 weight = idcStruct.getWeightRow(relPosRow);
391 }
else if (ipadMerge < offsPad) {
393 const int relPadPos = std::abs(ipadMerge - offsPad);
394 weight = idcStruct.getWeightPad(relPadPos);
395 }
else if (!lastPad && ipadMerge >= (groupPads + offsPad)) {
396 const int relPadPos = std::abs(1 + ipadMerge - (groupPads + offsPad));
397 weight = idcStruct.getWeightPad(relPadPos);
400 idcStruct.addValue(padInRegion,
weight);
402 idcStruct.addValue(padInRegion);
408 const bool fillNotPoly = iRowMerge < 0 || (bNotLastrow && bOverlapRowRight) || (ipadMerge < offsPad) || (!lastPad && ipadMerge >= (groupPads + offsPad));
409 drawLatex(idcStruct, padNum, padInRegion, !fillNotPoly, idcStruct.mColors.size());
413 if constexpr (std::is_same_v<LoopType, IDCAverageGroupCRU> || std::is_same_v<LoopType, IDCAverageGroupTPC>) {
414 idcStruct.setGroupedIDC(rowGrouped, padGrouped, applyWeights);
416 ++idcStruct.mGroupCounter;
419 iYLocalSide ? ++padGrouped : --padGrouped;
429 TFile fOut(outFileName,
"RECREATE");
430 fOut.WriteObject(
this, outName);