17#ifndef ALICEOW_GPUCOMMON_TPCFASTTRANSFORMATION_FLATOBJECT_H
18#define ALICEOW_GPUCOMMON_TPCFASTTRANSFORMATION_FLATOBJECT_H
20#if !defined(GPUCA_GPUCODE_DEVICE)
134 template <
typename T>
146 newPtr =
new T[newSize];
148 int32_t mcp = std::min(newSize, oldSize);
151 std::memmove(newPtr,
ptr, mcp *
sizeof(T));
153 if (newSize > oldSize) {
154 std::memset(newPtr + mcp, 0, (newSize - oldSize) *
sizeof(T));
162 template <
typename T>
174 newPtr =
new T*[newSize];
176 int32_t mcp = std::min(newSize, oldSize);
177 std::memmove(newPtr,
ptr, mcp *
sizeof(T*));
178 if (newSize > oldSize) {
179 std::memset(newPtr + mcp, 0, (newSize - oldSize) *
sizeof(T*));
275 static constexpr size_t alignSize(
size_t sizeBytes,
size_t alignmentBytes)
277 auto res = sizeBytes % alignmentBytes;
278 return res ? sizeBytes + (alignmentBytes -
res) : sizeBytes;
285 return (
ptr !=
nullptr) ?
reinterpret_cast<T*
>(newBase + (
reinterpret_cast<const char*
>(
ptr) - oldBase)) :
nullptr;
288#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
291 template <
class T,
class TFile>
295 template <
class T,
class TFile>
299#if !defined(GPUCA_GPUCODE)
417 if (!newFlatBufferPtr) {
430 if (!obj.isConstructed()) {
431 return "tested object is not constructed!";
435 tst.cloneFromObject(obj,
nullptr);
436 if (!tst.isConstructed() || !tst.isBufferInternal()) {
437 return "error at cloneFromObject()!";
442 char* buf0 = tst.releaseInternalBuffer();
443 char* buf1 =
new char[tst.getFlatBufferSize()];
444 char* buf2 =
new char[tst.getFlatBufferSize()];
445 std::memcpy(buf1, tst.getFlatBufferPtr(), tst.getFlatBufferSize());
446 tst.setActualBufferAddress(buf1);
449 tst.setFutureBufferAddress(buf2);
450 std::memcpy(buf2, buf1, tst.getFlatBufferSize());
453 if (tst.isBufferInternal()) {
454 return err =
"error, buffer should be external!";
457 tst.adoptInternalBuffer(buf2);
458 if (!tst.isBufferInternal()) {
459 return err =
"error, buffer should be internal!";
462 obj.cloneFromObject(tst,
nullptr);
463 if (!obj.isBufferInternal()) {
464 return err =
"error, buffer should be internal!";
477 printf(
"0x%02x ",
v);
478 if (
i && ((
i + 1) % 20) == 0) {
490#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
491template <
class T,
class TFile>
495 assert(obj.isConstructed());
497 if (outf.IsZombie()) {
498 LOG(
error) <<
"Failed to write to file " << outf.GetName();
502 bool isBufferExternal = !obj.isBufferInternal();
503 if (isBufferExternal) {
504 obj.adoptInternalBuffer(obj.mFlatBufferPtr);
506 outf.WriteObjectAny(&obj, T::Class(),
name);
507 if (isBufferExternal) {
508 obj.clearInternalBufferPtr();
513template <
class T,
class TFile>
518 if (inpf.IsZombie()) {
519 LOG(
error) <<
"Failed to read from file " << inpf.GetName();
522 T* pobj =
reinterpret_cast<T*
>(inpf.GetObjectChecked(
name, T::Class()));
524 LOG(
error) <<
"Failed to load " <<
name <<
" from " << inpf.GetName();
527 if (pobj->mFlatBufferSize > 0 && pobj->mFlatBufferContainer ==
nullptr) {
528 LOG(
error) <<
"Failed to load " <<
name <<
" from " << inpf.GetName() <<
": empty flat buffer container";
531 pobj->setActualBufferAddress(pobj->mFlatBufferContainer);
536#ifndef GPUCA_GPUCODE_DEVICE
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
char error[CURL_ERROR_SIZE]
char * releaseInternalBuffer()
_____________ Methods for making the data buffer external __________________________
void setFutureBufferAddress(char *futureFlatBufferPtr)
uint32_t mConstructionMask
mask for constructed object members, first two bytes are used by this class
int32_t mFlatBufferSize
size of the flat buffer
FlatObject & operator=(const FlatObject &)=delete
void printC() const
Print the content of the flat buffer.
void adoptInternalBuffer(char *buf)
char * mFlatBufferContainer
void destroy()
_______________ Utilities _______________________________________________
bool isConstructed() const
Tells if the object is constructed.
static constexpr size_t getBufferAlignmentBytes()
Gives minimal alignment in bytes required for the flat buffer.
static T * relocatePointer(const char *oldBase, char *newBase, const T *ptr)
Relocates a pointer inside a buffer to the new buffer address.
ClassDefNV(FlatObject, 1)
Pointer to the flat buffer.
void setActualBufferAddress(char *actualFlatBufferPtr)
_____________ Methods for moving the class with its external buffer to another location _____________...
static std::string stressTest(T &obj)
Test the flat object functionality for a child class T.
static int32_t writeToFile(T &obj, TFile &outf, const char *name)
write a child class object to the file
FlatObject()=default
_____________ Constructors / destructors __________________________
void startConstruction()
_____________ Construction _________
void moveBufferTo(char *newBufferPtr)
void finishConstruction(int32_t flatBufferSize)
bool isBufferInternal() const
Tells if the buffer is internal.
static constexpr size_t alignSize(size_t sizeBytes, size_t alignmentBytes)
_______________ Generic utilities _______________________________________________
FlatObject(const FlatObject &)=delete
T * resizeArray(T *&ptr, int32_t oldSize, int32_t newSize, T *newPtr=nullptr)
void cloneFromObject(const FlatObject &obj, char *newFlatBufferPtr)
static constexpr size_t getClassAlignmentBytes()
GPUCA_GPUCODE.
void clearInternalBufferPtr()
T ** resizeArray(T **&ptr, int32_t oldSize, int32_t newSize, T **newPtr=nullptr)
ConstructionState
GPUCA_GPUCODE.
@ InProgress
construction started: temporary memory is reserved
@ NotConstructed
the object is not constructed
@ Constructed
the object is constructed, temporary memory is released
static T * readFromFile(TFile &inpf, const char *name)
read a child class object from the file
GPUdi() size_t getFlatBufferSize() const
Gives size of the flat buffer.
GPUdi() const char *getFlatBufferPtr() const
Gives pointer to the flat buffer.
static constexpr size_t getClassAlignmentBytes()
GPUdi() size_t getFlatBufferSize() const
static constexpr size_t getBufferAlignmentBytes()
GLuint const GLchar * name
GLenum GLuint GLenum GLsizei const GLchar * buf
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"