diff --git a/Detectors/TPC/calibration/SpacePoints/include/SpacePoints/TrackResiduals.h b/Detectors/TPC/calibration/SpacePoints/include/SpacePoints/TrackResiduals.h index a896f0c170f9d..819766573e26a 100644 --- a/Detectors/TPC/calibration/SpacePoints/include/SpacePoints/TrackResiduals.h +++ b/Detectors/TPC/calibration/SpacePoints/include/SpacePoints/TrackResiduals.h @@ -299,12 +299,12 @@ class TrackResiduals /// \param ip Bin index in Y/X /// \param iz Bin index in Z/X /// \return global bin number - unsigned short getGlbVoxBin(int ix, int ip, int iz) const; + size_t getGlbVoxBin(int ix, int ip, int iz) const; /// Calculates the global bin number /// \param bvox Array with the voxels bin indices in X, Y/X and Z/X /// \return global bin number - unsigned short getGlbVoxBin(const std::array& bvox) const; + size_t getGlbVoxBin(const std::array& bvox) const; /// Calculates the coordinates of the center for a given voxel. /// These are not global TPC coordinates, but the coordinates for the given global binning system. @@ -498,7 +498,7 @@ class TrackResiduals float mEffVdriftCorr{0.f}; ///< global correction factor for vDrift based on d(delta(z))/dz fit float mEffT0Corr{0.f}; ///< global correction for T0 shift from offset of d(delta(z))/dz fit // (intermediate) results - std::array, SECTORSPERSIDE * SIDES> mXBinsIgnore{}; ///< flags which X bins to ignore + std::array, SECTORSPERSIDE * SIDES> mXBinsIgnore{}; ///, SECTORSPERSIDE * SIDES> mValidFracXBins{}; ///< for each sector for each X-bin the fraction of validated voxels std::array, SECTORSPERSIDE * SIDES> mVoxelResults{}; ///< results per sector and per voxel for 3-D distortions VoxRes mVoxelResultsOut{}; ///< the results from mVoxelResults are copied in here to be able to stream them @@ -508,13 +508,13 @@ class TrackResiduals }; //_____________________________________________________ -inline unsigned short TrackResiduals::getGlbVoxBin(const std::array& bvox) const +inline size_t TrackResiduals::getGlbVoxBin(const std::array& bvox) const { return bvox[VoxX] + (bvox[VoxF] + bvox[VoxZ] * mNY2XBins) * mNXBins; } //_____________________________________________________ -inline unsigned short TrackResiduals::getGlbVoxBin(int ix, int ip, int iz) const +inline size_t TrackResiduals::getGlbVoxBin(int ix, int ip, int iz) const { return ix + (ip + iz * mNY2XBins) * mNXBins; } diff --git a/Detectors/TPC/calibration/SpacePoints/src/TrackResiduals.cxx b/Detectors/TPC/calibration/SpacePoints/src/TrackResiduals.cxx index 8daf8fec651e2..f847bc070940a 100644 --- a/Detectors/TPC/calibration/SpacePoints/src/TrackResiduals.cxx +++ b/Detectors/TPC/calibration/SpacePoints/src/TrackResiduals.cxx @@ -70,11 +70,24 @@ void TrackResiduals::setY2XBinning(const std::vector& binning) LOG(error) << "Binning already initialized, not changing y/x binning"; return; } - int nBins = binning.size() - 1; + + if (binning.size() == 0) { + LOGP(info, "Empty binning provided, will use default uniform y/x binning with {} bins", mNY2XBins); + return; + } else if (binning.size() == 1) { + const int bins = static_cast(binning.at(0)); + setNY2XBins(bins); + LOGP(info, "Setting uniform binning for y/x with {} bins", bins - 1); + return; + } + + const int nBins = binning.size() - 1; if (fabsf(binning[0] + 1.f) > param::sEps || fabsf(binning[nBins] - 1.f) > param::sEps) { LOG(error) << "Provided binning for y/x not in range -1 to 1: " << binning[0] << " - " << binning[nBins] << ". Not changing y/x binning"; return; } + + LOGP(info, "Setting custom binning for y/x with {} bins", nBins); setNY2XBins(nBins); mUniformBins[VoxF] = false; mY2XBinsDH.clear(); @@ -84,6 +97,7 @@ void TrackResiduals::setY2XBinning(const std::vector& binning) mY2XBinsDH.push_back(.5f * (binning[iBin + 1] - binning[iBin])); mY2XBinsDI.push_back(.5f / mY2XBinsDH[iBin]); mY2XBinsCenter.push_back(binning[iBin] + mY2XBinsDH[iBin]); + LOGF(info, "Bin %i: center (%.3f), half bin width (%.3f)", iBin, mY2XBinsCenter.back(), mY2XBinsDH.back()); } } @@ -94,11 +108,24 @@ void TrackResiduals::setZ2XBinning(const std::vector& binning) LOG(error) << "Binning already initialized, not changing z/x binning"; return; } + + if (binning.size() == 0) { + LOGP(info, "Empty binning provided, will use default uniform z/x binning with {} bins", mNZ2XBins); + return; + } else if (binning.size() == 1) { + const int bins = static_cast(binning.at(0)); + setNZ2XBins(bins); + LOGP(info, "Setting uniform binning for z/x with {} bins", bins); + return; + } + int nBins = binning.size() - 1; if (fabsf(binning[0]) > param::sEps || fabsf(binning[nBins] - 1.f) > param::sEps) { LOG(error) << "Provided binning for z/x not in range 0 to 1: " << binning[0] << " - " << binning[nBins] << ". Not changing z/x binning"; return; } + + LOGP(info, "Setting custom binning for z/x with {} bins", nBins); setNZ2XBins(nBins); mUniformBins[VoxZ] = false; mZ2XBinsDH.clear(); @@ -108,6 +135,7 @@ void TrackResiduals::setZ2XBinning(const std::vector& binning) mZ2XBinsDH.push_back(.5f * (binning[iBin + 1] - binning[iBin]) * mMaxZ2X); mZ2XBinsDI.push_back(.5f / mZ2XBinsDH[iBin]); mZ2XBinsCenter.push_back(binning[iBin] * mMaxZ2X + mZ2XBinsDH[iBin]); + LOGF(info, "Bin %i: center (%.3f), half bin width (%.3f)", iBin, mZ2XBinsCenter.back(), mZ2XBinsDH.back()); } } @@ -181,7 +209,7 @@ void TrackResiduals::initResultsContainer(int iSec) for (int ix = 0; ix < mNXBins; ++ix) { for (int ip = 0; ip < mNY2XBins; ++ip) { for (int iz = 0; iz < mNZ2XBins; ++iz) { - int binGlb = getGlbVoxBin(ix, ip, iz); + const size_t binGlb = getGlbVoxBin(ix, ip, iz); VoxRes& resVox = mVoxelResults[iSec][binGlb]; resVox.bvox[VoxX] = ix; resVox.bvox[VoxF] = ip; @@ -338,7 +366,7 @@ void TrackResiduals::processSectorResiduals(int iSec) initResultsContainer(iSec); // effective t0 correction changes sign between A-/C-side float effT0corr = (iSec < SECTORSPERSIDE) ? mEffT0Corr : -1. * mEffT0Corr; - std::vector binData; + std::vector binData; for (const auto& res : mLocalResidualsIn) { binData.push_back(getGlbVoxBin(res.bvox)); } @@ -356,7 +384,7 @@ void TrackResiduals::processSectorResiduals(int iSec) dyVec.reserve(1e3); dzVec.reserve(1e3); tgVec.reserve(1e3); - int currVoxBin = -1; + size_t currVoxBin = -1; unsigned int nPointsInVox = 0; unsigned int nProcessed = 0; while (nProcessed < binData.size()) {