15#ifndef 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>());
64 if (mCalibTrackTopologySpline) {
65 mCalibTrackTopologySpline->
destroy();
67 if (mCalibTrackTopologyPol) {
68 mCalibTrackTopologyPol->
destroy();
70 mCalibTrackTopologySpline =
nullptr;
71 mCalibTrackTopologyPol =
nullptr;
78 if (mCalibTrackTopologyPol) {
80 }
else if (mCalibTrackTopologySpline) {
83 mCalibTrackTopologyPol =
nullptr;
84 mCalibTrackTopologySpline =
nullptr;
95 obj->setActualBufferAddress(
mFlatBufferPtr + sizeOfCalibdEdxTrackTopologyObj<Type>());
100 if (mCalibTrackTopologyPol) {
102 }
else if (mCalibTrackTopologySpline) {
105 mCalibTrackTopologyPol =
nullptr;
106 mCalibTrackTopologySpline =
nullptr;
116 obj->setFutureBufferAddress(distBuffer);
124 if (mCalibTrackTopologyPol) {
125 return mCalibTrackTopologyPol->getMinThreshold();
127 const float minThr = 0;
128 LOGP(info,
"Topology correction not set! Returning default min threshold of: {}", minThr);
135 if (mCalibTrackTopologyPol) {
136 return mCalibTrackTopologyPol->getMaxThreshold();
138 const float maxThr = 1;
139 LOGP(info,
"Topology correction not set! Returning default max threshold of: {}", maxThr);
146 setTopologyCorrection(calibTrackTopology, mCalibTrackTopologyPol);
147 mCalibTrackTopologySpline =
nullptr;
154 setTopologyCorrection(calibTrackTopology, mCalibTrackTopologyPol);
155 mCalibTrackTopologySpline =
nullptr;
160 setTopologyCorrection(calibTrackTopology, mCalibTrackTopologySpline);
161 mCalibTrackTopologyPol =
nullptr;
167 mThresholdMap.setMinCorrectionFactor(defaultVal - 0.1f);
168 mThresholdMap.setMaxCorrectionFactor(defaultVal + 0.1f);
171 mThresholdMap.setGainCorrection(sector, globPad, defaultVal);
177void CalibdEdxContainer::setTopologyCorrection(
const Type& calibTrackTopologyTmp, Type*& obj)
182 const std::size_t flatbufferSize = calibTrackTopologyTmp.getFlatBufferSize();
185 const std::size_t objSize = sizeOfCalibdEdxTrackTopologyObj<Type>();
188 const std::size_t totalSize = flatbufferSize + objSize;
195 obj->cloneFromObject(calibTrackTopologyTmp,
nullptr);
201#ifndef GPUCA_STANDALONE
205 TFile fInp(fileName.data(),
"READ");
207 fInp.GetObject(objName.data(),
threshold);
214 const auto thresholdMapProcessed = processThresholdMap(thresholdMap, maxCorrectionFactor);
216 mThresholdMap = thresholdMapTmp;
219CalDet<float> CalibdEdxContainer::processThresholdMap(
const CalDet<float>& thresholdMap,
const float maxThreshold,
const int32_t nPadsInRowCl,
const int32_t nPadsInPadCl)
const
226 for (int32_t lrow = 0; lrow <= maxRow; ++lrow) {
228 const int32_t rowStart = std::clamp(lrow - nPadsInRowCl, 0, maxRow);
229 const int32_t rowEnd = std::clamp(lrow + nPadsInRowCl, 0, maxRow);
234 int32_t countThr = 0;
236 for (int32_t rowCl = rowStart; rowCl <= rowEnd; ++rowCl) {
239 const int32_t diffAddPads = addPadsCl - addPadsStart;
240 const int32_t padClCentre = pad + diffAddPads;
243 const int32_t padStart = std::clamp(padClCentre - nPadsInPadCl, 0, maxPad);
244 const int32_t padEnd = std::clamp(padClCentre + nPadsInPadCl, 0, maxPad);
245 for (int32_t padCl = padStart; padCl <= padEnd; ++padCl) {
248 if (padCl == (int32_t)pad && rowCl == lrow) {
261 const float meanThresold = sumThr / countThr;
263 thresholdMapProcessed.setValue(sector, globalPad, meanThresold);
268 return thresholdMapProcessed;
279 mGainMap = gainMapTmp;
285 mGainMapResidual = gainMapResTmp;
290 loadTopologyCorrectionFromFile(fileName, mCalibTrackTopologyPol);
295 loadTopologyCorrectionFromFile(fileName, mCalibTrackTopologySpline);
299void CalibdEdxContainer::loadTopologyCorrectionFromFile(std::string_view fileName, Type*& obj)
302 Type calibTrackTopologyTmp(fileName.data());
303 setTopologyCorrection(calibTrackTopologyTmp, obj);
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_REAL_PADS_IN_SECTOR
Global TPC definitions and constants.
void setFromMap(const o2::tpc::CalDet< bool > &)
setting the stored values from CalDet