82 const int nClusters = track.getNClusterReferences();
84 int nClsROC[4] = {0, 0, 0, 0};
85 int nClsSubThreshROC[4] = {0, 0, 0, 0};
88 std::array<std::vector<float>, nType> chargeTotROC;
89 std::array<std::vector<float>, nType> chargeMaxROC;
90 for (
int i = 0;
i < nType; ++
i) {
96 std::vector<int> excludeClVector;
97 std::vector<int> regionVector;
98 std::vector<unsigned char> rowIndexVector;
99 std::vector<unsigned char> padVector;
100 std::vector<unsigned char> sectorVector;
101 std::vector<int> stackVector;
102 std::vector<float> localXVector;
103 std::vector<float> localYVector;
104 std::vector<float> offsPadVector;
106 std::vector<float> topologyCorrVector;
107 std::vector<float> topologyCorrTotVector;
108 std::vector<float> topologyCorrMaxVector;
109 std::vector<float> gainVector;
110 std::vector<float> gainResidualVector;
111 std::vector<float> residualCorrTotVector;
112 std::vector<float> residualCorrMaxVector;
113 std::vector<float> scCorrVector;
115 std::vector<o2::tpc::TrackTPC> trackVector;
116 std::vector<o2::tpc::ClusterNative> clVector;
117 std::vector<unsigned int> occupancyVector;
118 std::vector<bool> isClusterShared;
131 topologyCorrTotVector.reserve(
nClusters);
132 topologyCorrMaxVector.reserve(
nClusters);
135 residualCorrTotVector.reserve(
nClusters);
136 residualCorrMaxVector.reserve(
nClusters);
145 unsigned char rowIndexOld = 0;
146 unsigned char sectorIndexOld = 0;
147 float minChargeTot = 100000.f;
148 float minChargeMax = 100000.f;
151 for (
int iCl = 0; iCl <
nClusters; iCl++) {
155 unsigned char sectorIndex = 0;
156 unsigned char rowIndex = 0;
157 unsigned int clusterIndexNumb = 0;
160 track.getClusterReference(*mTPCTrackClIdxVecInput, iCl, sectorIndex, rowIndex, clusterIndexNumb);
163 const unsigned int absoluteIndex = mClusterIndex->
clusterOffset[sectorIndex][rowIndex] + clusterIndexNumb;
169 const CRU cru(
Sector(sectorIndex), region);
173 const int stackNumber =
static_cast<int>(
stack);
179 const auto flagsCl = cl.getFlags();
192 excludeCl += 0b10000;
199 if (!mPropagateTrack) {
200 if (mRefit ==
nullptr) {
201 LOGP(error,
"mRefit is a nullptr, call the function setRefit() before looping over the tracks.");
203 mRefit->setTrackReferenceX(xPosition);
204 check = (mRefit->RefitTrackAsGPU(track,
false,
true) < 0) ?
false :
true;
207 track.rotate(o2::math_utils::detail::sector2Angle<float>(sectorIndex));
211 if (!
check || std::isnan(track.getParam(1))) {
215 if (excludeCl != 0) {
218 excludeClVector.emplace_back(excludeCl);
219 regionVector.emplace_back(region);
220 rowIndexVector.emplace_back(rowIndex);
221 padVector.emplace_back(pad);
222 sectorVector.emplace_back(sectorIndex);
223 stackVector.emplace_back(stackNumber);
224 localXVector.emplace_back(localX);
225 localYVector.emplace_back(localY);
226 offsPadVector.emplace_back(offsPad);
227 trackVector.emplace_back(track);
228 clVector.emplace_back(cl);
230 isClusterShared.emplace_back(isShared);
232 topologyCorrVector.emplace_back(-999.f);
233 topologyCorrTotVector.emplace_back(-999.f);
234 topologyCorrMaxVector.emplace_back(-999.f);
235 gainVector.emplace_back(-999.f);
236 gainResidualVector.emplace_back(-999.f);
237 residualCorrTotVector.emplace_back(-999.f);
238 residualCorrMaxVector.emplace_back(-999.f);
239 scCorrVector.emplace_back(-999.f);
242 rowIndexOld = rowIndex;
243 sectorIndexOld = sectorIndex;
248 float chargeTot = cl.
qTot;
249 float chargeMax = cl.
qMax;
252 const float threshold = mCalibCont.getZeroSupressionThreshold(sectorIndex, rowIndex, pad);
255 int missingClusters = rowIndexOld - rowIndex - 1;
256 if ((missingClusters > 0) && (missingClusters <= mMaxMissingCl)) {
258 if (sectorIndexOld == sectorIndex) {
260 nClsSubThreshROC[0] += missingClusters;
261 nClsROC[0] += missingClusters;
263 nClsSubThreshROC[1] += missingClusters;
264 nClsROC[1] += missingClusters;
266 nClsSubThreshROC[2] += missingClusters;
267 nClsROC[2] += missingClusters;
269 nClsSubThreshROC[3] += missingClusters;
270 nClsROC[3] += missingClusters;
275 nClsSubThreshROC[0] += missingClusters;
276 nClsROC[0] += missingClusters;
278 nClsSubThreshROC[1] += missingClusters;
279 nClsROC[1] += missingClusters;
281 nClsSubThreshROC[2] += missingClusters;
282 nClsROC[2] += missingClusters;
284 nClsSubThreshROC[3] += missingClusters;
285 nClsROC[3] += missingClusters;
289 rowIndexOld = rowIndex;
290 sectorIndexOld = sectorIndex;
293 float effectiveLength = 1.0f;
294 float effectiveLengthTot = 1.0f;
295 float effectiveLengthMax = 1.0f;
298 chargeTot /= effectiveLength;
299 chargeMax /= effectiveLength;
304 chargeTot /= effectiveLengthTot;
305 chargeMax /= effectiveLengthMax;
310 float gainResidual = 1.0f;
312 gain = mCalibCont.getGain(sectorIndex, rowIndex, pad);
315 gainResidual = mCalibCont.getResidualGain(sectorIndex, rowIndex, pad);
317 chargeTot /= gain * gainResidual;
318 chargeMax /= gain * gainResidual;
321 float corrTot = 1.0f;
322 float corrMax = 1.0f;
324 corrTot = mCalibCont.getResidualCorrection(stackID,
ChargeType::Tot, track.getTgl(), track.getSnp());
325 corrMax = mCalibCont.getResidualCorrection(stackID,
ChargeType::Max, track.getTgl(), track.getSnp());
327 chargeTot /= corrTot;
330 chargeMax /= corrMax;
335 if (chargeTot < minChargeTot) {
336 minChargeTot = chargeTot;
339 if (chargeMax < minChargeMax) {
340 minChargeMax = chargeMax;
344 const float time = cl.getTime() - track.getTime0();
357 chargeTotROC[0].emplace_back(chargeTot);
358 chargeMaxROC[0].emplace_back(chargeMax);
361 chargeTotROC[1].emplace_back(chargeTot);
362 chargeMaxROC[1].emplace_back(chargeMax);
365 chargeTotROC[2].emplace_back(chargeTot);
366 chargeMaxROC[2].emplace_back(chargeMax);
369 chargeTotROC[3].emplace_back(chargeTot);
370 chargeMaxROC[3].emplace_back(chargeMax);
374 chargeTotROC[4].emplace_back(chargeTot);
375 chargeMaxROC[4].emplace_back(chargeMax);
379 excludeClVector.emplace_back(0);
380 regionVector.emplace_back(region);
381 rowIndexVector.emplace_back(rowIndex);
382 padVector.emplace_back(pad);
383 sectorVector.emplace_back(sectorIndex);
384 stackVector.emplace_back(stackNumber);
385 localXVector.emplace_back(localX);
386 localYVector.emplace_back(localY);
387 offsPadVector.emplace_back(offsPad);
388 trackVector.emplace_back(track);
389 clVector.emplace_back(cl);
391 isClusterShared.emplace_back(isShared);
393 topologyCorrVector.emplace_back(effectiveLength);
394 topologyCorrTotVector.emplace_back(effectiveLengthTot);
395 topologyCorrMaxVector.emplace_back(effectiveLengthMax);
396 gainVector.emplace_back(gain);
397 gainResidualVector.emplace_back(gainResidual);
398 residualCorrTotVector.emplace_back(corrTot);
399 residualCorrMaxVector.emplace_back(corrMax);
400 scCorrVector.emplace_back(scCorr);
405 output.NHitsSubThresholdIROC = nClsROC[0];
406 output.NHitsSubThresholdOROC1 = nClsROC[1];
407 output.NHitsSubThresholdOROC2 = nClsROC[2];
408 output.NHitsSubThresholdOROC3 = nClsROC[3];
411 if (minChargeTot <= mMinChargeTotThreshold && minChargeMax <= mMinChargeMaxThreshold) {
412 output.NHitsIROC = nClsROC[0] - nClsSubThreshROC[0];
413 output.NHitsOROC1 = nClsROC[1] - nClsSubThreshROC[1];
414 output.NHitsOROC2 = nClsROC[2] - nClsSubThreshROC[2];
415 output.NHitsOROC3 = nClsROC[3] - nClsSubThreshROC[3];
419 fillMissingClusters(nClsSubThreshROC, minChargeTot, minChargeMax, subthresholdMethod, chargeTotROC, chargeMaxROC);
422 output.NHitsIROC = nClsROC[0];
423 output.NHitsOROC1 = nClsROC[1];
424 output.NHitsOROC2 = nClsROC[2];
425 output.NHitsOROC3 = nClsROC[3];
429 auto chargeTotVector = mDebug ? chargeTotROC[4] : std::vector<float>();
430 auto chargeMaxVector = mDebug ? chargeMaxROC[4] : std::vector<float>();
447 if (mStreamer ==
nullptr) {
451 (*mStreamer) <<
"dEdxDebug"
453 <<
"excludeClVector=" << excludeClVector
454 <<
"regionVector=" << regionVector
455 <<
"rowIndexVector=" << rowIndexVector
456 <<
"padVector=" << padVector
457 <<
"sectorVector=" << sectorVector
458 <<
"stackVector=" << stackVector
459 <<
"topologyCorrVector=" << topologyCorrVector
460 <<
"topologyCorrTotVector=" << topologyCorrTotVector
461 <<
"topologyCorrMaxVector=" << topologyCorrMaxVector
462 <<
"gainVector=" << gainVector
463 <<
"gainResidualVector=" << gainResidualVector
464 <<
"residualCorrTotVector=" << residualCorrTotVector
465 <<
"residualCorrMaxVector=" << residualCorrMaxVector
466 <<
"scCorrVector=" << scCorrVector
467 <<
"localXVector=" << localXVector
468 <<
"localYVector=" << localYVector
469 <<
"offsPadVector=" << offsPadVector
470 <<
"trackVector=" << trackVector
471 <<
"clVector=" << clVector
472 <<
"minChargeTot=" << minChargeTot
473 <<
"minChargeMax=" << minChargeMax
475 <<
"occupancy=" << occupancyVector
476 <<
"chargeTotVector=" << chargeTotVector
477 <<
"chargeMaxVector=" << chargeMaxVector
478 <<
"isClusterShared=" << isClusterShared