15#if !defined(GPUCA_STANDALONE)
26#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
27void CalibdEdxContainer::cloneFromObject(
const CalibdEdxContainer& obj,
char* newFlatBufferPtr)
30 mCalibResidualdEdx = obj.mCalibResidualdEdx;
31 mThresholdMap = obj.mThresholdMap;
32 mGainMap = obj.mGainMap;
33 mGainMapResidual = obj.mGainMapResidual;
34 mDeadChannelMap = obj.mDeadChannelMap;
35 mApplyFullGainMap = obj.mApplyFullGainMap;
36 mCalibsLoad = obj.mCalibsLoad;
37 if (obj.mCalibTrackTopologyPol) {
38 subobjectCloneFromObject(mCalibTrackTopologyPol, obj.mCalibTrackTopologyPol);
40 if (obj.mCalibTrackTopologySpline) {
41 subobjectCloneFromObject(mCalibTrackTopologySpline, obj.mCalibTrackTopologySpline);
46void CalibdEdxContainer::subobjectCloneFromObject(Type*& obj,
const Type* objOld)
49 memset((
void*)obj, 0,
sizeof(*obj));
50 obj->cloneFromObject(*objOld,
mFlatBufferPtr + sizeOfCalibdEdxTrackTopologyObj<Type>());
65 if (mCalibTrackTopologySpline) {
66 mCalibTrackTopologySpline->
destroy();
68 if (mCalibTrackTopologyPol) {
69 mCalibTrackTopologyPol->
destroy();
71 mCalibTrackTopologySpline =
nullptr;
72 mCalibTrackTopologyPol =
nullptr;
79 if (mCalibTrackTopologyPol) {
81 }
else if (mCalibTrackTopologySpline) {
84 mCalibTrackTopologyPol =
nullptr;
85 mCalibTrackTopologySpline =
nullptr;
96 obj->setActualBufferAddress(
mFlatBufferPtr + sizeOfCalibdEdxTrackTopologyObj<Type>());
101 if (mCalibTrackTopologyPol) {
103 }
else if (mCalibTrackTopologySpline) {
106 mCalibTrackTopologyPol =
nullptr;
107 mCalibTrackTopologySpline =
nullptr;
117 obj->setFutureBufferAddress(distBuffer);
123#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
127 if (mCalibTrackTopologyPol) {
128 return mCalibTrackTopologyPol->getMinThreshold();
130 const float minThr = 0;
131 LOGP(info,
"Topology correction not set! Returning default min threshold of: {}", minThr);
138 if (mCalibTrackTopologyPol) {
139 return mCalibTrackTopologyPol->getMaxThreshold();
141 const float maxThr = 1;
142 LOGP(info,
"Topology correction not set! Returning default max threshold of: {}", maxThr);
149 loadTopologyCorrectionFromFile(fileName, mCalibTrackTopologyPol);
154 loadTopologyCorrectionFromFile(fileName, mCalibTrackTopologySpline);
159 setTopologyCorrection(calibTrackTopology, mCalibTrackTopologyPol);
160 mCalibTrackTopologySpline =
nullptr;
167 setTopologyCorrection(calibTrackTopology, mCalibTrackTopologyPol);
168 mCalibTrackTopologySpline =
nullptr;
173 setTopologyCorrection(calibTrackTopology, mCalibTrackTopologySpline);
174 mCalibTrackTopologyPol =
nullptr;
179 TFile fInp(fileName.data(),
"READ");
181 fInp.GetObject(objName.data(),
threshold);
188 const auto thresholdMapProcessed = processThresholdMap(thresholdMap, maxCorrectionFactor);
190 mThresholdMap = thresholdMapTmp;
193CalDet<float> CalibdEdxContainer::processThresholdMap(
const CalDet<float>& thresholdMap,
const float maxThreshold,
const int32_t nPadsInRowCl,
const int32_t nPadsInPadCl)
const
200 for (int32_t lrow = 0; lrow <= maxRow; ++lrow) {
202 const int32_t rowStart = std::clamp(lrow - nPadsInRowCl, 0, maxRow);
203 const int32_t rowEnd = std::clamp(lrow + nPadsInRowCl, 0, maxRow);
208 int32_t countThr = 0;
210 for (int32_t rowCl = rowStart; rowCl <= rowEnd; ++rowCl) {
213 const int32_t diffAddPads = addPadsCl - addPadsStart;
214 const int32_t padClCentre = pad + diffAddPads;
217 const int32_t padStart = std::clamp(padClCentre - nPadsInPadCl, 0, maxPad);
218 const int32_t padEnd = std::clamp(padClCentre + nPadsInPadCl, 0, maxPad);
219 for (int32_t padCl = padStart; padCl <= padEnd; ++padCl) {
222 if (padCl == pad && rowCl == lrow) {
235 const float meanThresold = sumThr / countThr;
237 thresholdMapProcessed.setValue(sector, globalPad, meanThresold);
242 return thresholdMapProcessed;
253 mGainMap = gainMapTmp;
259 mGainMapResidual = gainMapResTmp;
265 mThresholdMap.setMinCorrectionFactor(defaultVal - 0.1f);
266 mThresholdMap.setMaxCorrectionFactor(defaultVal + 0.1f);
269 mThresholdMap.setGainCorrection(sector, globPad, defaultVal);
275void CalibdEdxContainer::loadTopologyCorrectionFromFile(std::string_view fileName, Type*& obj)
278 Type calibTrackTopologyTmp(fileName.data());
279 setTopologyCorrection(calibTrackTopologyTmp, obj);
283void CalibdEdxContainer::setTopologyCorrection(
const Type& calibTrackTopologyTmp, Type*& obj)
288 const std::size_t flatbufferSize = calibTrackTopologyTmp.getFlatBufferSize();
291 const std::size_t objSize = sizeOfCalibdEdxTrackTopologyObj<Type>();
294 const std::size_t totalSize = flatbufferSize + objSize;
301 obj->cloneFromObject(calibTrackTopologyTmp,
nullptr);
Definition of container class for dE/dx corrections.
void setFutureBufferAddress(char *futureFlatBufferPtr)
void destroy()
_______________ Utilities _______________________________________________
static T * relocatePointer(const char *oldBase, char *newBase, const T *ptr)
Relocates a pointer inside a buffer to the new buffer address.
void setActualBufferAddress(char *actualFlatBufferPtr)
_____________ Methods for moving the class with its external buffer to another location _____________...
void startConstruction()
_____________ Construction _________
void moveBufferTo(char *newBufferPtr)
void finishConstruction(int32_t flatBufferSize)
void cloneFromObject(const FlatObject &obj, char *newFlatBufferPtr)
const T getValue(const int sec, const int globalPadInSector) const
void loadSplineTopologyCorrectionFromFile(std::string_view fileName)
void setDefaultZeroSupresssionThreshold()
void setGainMap(const CalDet< float > &gainMap, const float minGain, const float maxGain)
setting the gain map map from a CalDet
void loadPolTopologyCorrectionFromFile(std::string_view fileName)
================================================================================================
void setPolTopologyCorrection(const CalibdEdxTrackTopologyPol &calibTrackTopology)
const ChargeType const float const float const float const float const float const float threshold
void setActualBufferAddress(char *actualFlatBufferPtr)
set location of external flat buffer
void setSplineTopologyCorrection(const CalibdEdxTrackTopologySpline &calibTrackTopology)
float getMinZeroSupresssionThreshold() const
void setDeadChannelMap(const CalDet< bool > &deadMap)
setting the gain map map from a CalDet
void setZeroSupresssionThreshold(const CalDet< float > &thresholdMap)
void setFutureBufferAddress(char *futureFlatBufferPtr)
set future location of the flat buffer
void setDefaultPolTopologyCorrection()
setting a default topology correction which just returns 1
float getMaxZeroSupresssionThreshold() const
void moveBufferTo(char *newBufferPtr)
void setGainMapResidual(const CalDet< float > &gainMapResidual, const float minResidualGain=0.7f, const float maxResidualGain=1.3f)
setting the gain map map from a CalDet
void loadZeroSupresssionThresholdFromFile(std::string_view fileName, std::string_view objName, const float minCorrectionFactor, const float maxCorrectionFactor)
void destroy()
destroy the object (release internal flat buffer)
calibration class for the track topology correction of the dE/dx using multvariate polynomials
void setDefaultPolynomials()
setting a default topology correction which just returns 1
void destroy()
destroy the object (release internal flat buffer)
static GlobalPadNumber getGlobalPadNumber(const unsigned int lrow, const unsigned int pad, const unsigned int region)
static const std::vector< unsigned int > ADDITIONALPADSPERROW[NREGIONS]
additional pads per row compared to first row
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
static constexpr unsigned int NSECTORS
total number of sectors in the TPC
static constexpr unsigned int NREGIONS
total number of regions in one sector
#define TPC_PADS_IN_SECTOR
Global TPC definitions and constants.
void setFromMap(const o2::tpc::CalDet< bool > &)
setting the stored values from CalDet