Project
Loading...
Searching...
No Matches
CompressedClusters.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
16#include "GPUCommonLogger.h"
17#include <cstring>
18#ifndef GPUCA_STANDALONE
20#include "TBuffer.h"
21#include <vector>
22#include <gsl/span>
23#endif
24
25namespace o2::tpc
26{
27
29{
31 CompressedClustersPtrs& cp = *this;
33 cc = c;
34 for (unsigned int i = 0; i < sizeof(cp) / sizeof(size_t); i++) {
35 reinterpret_cast<void**>(&cp)[i] = reinterpret_cast<void*>(reinterpret_cast<const size_t*>(&offsets)[i] + reinterpret_cast<size_t>(&c)); // Restore pointers from offsets
36 }
37};
38
39void CompressedClustersFlat::set(size_t bufferSize, const CompressedClusters& v)
40{
43 const CompressedClustersPtrs& ptrs = v;
44 cc = v;
45 for (unsigned int i = 0; i < sizeof(offsets) / sizeof(size_t); i++) {
46 reinterpret_cast<size_t*>(&offsets)[i] = (reinterpret_cast<const size_t*>(&ptrs)[i] - reinterpret_cast<size_t>(this)); // Compute offsets from beginning of structure
47 }
48 ptrForward = nullptr;
49 totalDataSize = bufferSize;
50}
51
53{
54 memset((void*)this, 0, sizeof(*this));
55 ptrForward = p;
56}
57
59{
60 LOG(info) << "nTracks" << nTracks;
61 for (unsigned int i = 0; i < nTracks; i++) {
62 LOG(info) << " " << i << ":" << (unsigned int)qPtA[i] << " " << (unsigned int)rowA[i] << " " << (unsigned int)sliceA[i] << " " << (unsigned int)timeA[i] << " " << (unsigned int)padA[i];
63 }
64 LOG(info) << "nAttachedClusters" << nAttachedClusters;
65 for (unsigned int i = 0; i < nAttachedClusters; i++) {
66 LOG(info) << " " << i << ":" << (unsigned int)qTotA[i] << " " << (unsigned int)qMaxA[i] << " " << (unsigned int)flagsA[i] << " " << (unsigned int)sigmaPadA[i] << " " << (unsigned int)sigmaTimeA[i];
67 }
68 LOG(info) << "nAttachedClustersReduced" << nAttachedClustersReduced;
69 for (unsigned int i = 0; i < nAttachedClustersReduced; i++) {
70 LOG(info) << " " << i << ":" << (unsigned int)rowDiffA[i] << " " << (unsigned int)sliceLegDiffA[i] << " " << (unsigned int)padResA[i] << " " << (unsigned int)timeResA[i];
71 }
72 LOG(info) << "nUnattachedClusters" << nUnattachedClusters;
73 for (unsigned int i = 0; i < nUnattachedClusters; i++) {
74 LOG(info) << " " << i << ":" << (unsigned int)qTotU[i] << " " << (unsigned int)qMaxU[i] << " " << (unsigned int)flagsU[i] << " " << (unsigned int)padDiffU[i] << " " << (unsigned int)timeDiffU[i] << " " << (unsigned int)sigmaPadU[i] << " " << (unsigned int)sigmaTimeU[i];
75 }
76}
77
78#ifndef GPUCA_STANDALONE
79void CompressedClustersROOT::Streamer(TBuffer& R__b)
80{
81 // the custom streamer for CompressedClustersROOT
82 if (R__b.IsReading()) {
83 R__b.ReadClassBuffer(CompressedClustersROOT::Class(), this);
84 gsl::span flatdata{this->flatdata, static_cast<std::size_t>(this->flatdataSize)};
86 } else {
87 std::vector<char> flatdata;
88 // member flatdata is nullptr unless it is an already extracted object which
89 // is streamed again. Overriding the existing flatbuffer is a potential
90 // memory leak
91 // Note: lots of cornercases here which are diffucult to catch with the design
92 // of CompClusters container (which is optimized to be used with GPU). Main concern
93 // is if an extracted object is not read-only and the counters are changed.
94 // TODO: we can add a consistency check whether the size of the flatbuffer
95 // and the pointers match the object.
96 bool isflat = this->flatdata != nullptr;
97 if (!isflat) {
99 this->flatdataSize = flatdata.size();
100 this->flatdata = flatdata.data();
101 }
102 R__b.WriteClassBuffer(CompressedClustersROOT::Class(), this);
103 if (!isflat) {
104 this->flatdataSize = 0;
105 this->flatdata = nullptr;
106 }
107 }
108}
109#endif
110
111} // namespace o2::tpc
Helper for the CompressedClusters container.
Container to store compressed TPC cluster data.
int32_t i
uint32_t c
Definition RawData.h:2
GLuint GLsizei const GLuint const GLintptr * offsets
Definition glcorearb.h:2595
const GLdouble * v
Definition glcorearb.h:832
Global TPC definitions and constants.
Definition SimTraits.h:167
void setForward(const CompressedClusters *p)
const CompressedClusters * ptrForward
void set(size_t bufferSize, const CompressedClusters &v)
static size_t flattenTo(ContainerType &container, CompressedClustersROOT &clusters)
static size_t restoreFrom(ContainerType &container, CompressedClustersROOT &clusters)
Restore the array pointers from the data in the container.
std::vector< o2::mch::ChannelCode > cc
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"