24constexpr uint32_t kByteCountMask = 0x40000000;
25constexpr uint32_t kClassMask = 0x80000000;
26constexpr uint32_t kNewClassTag = 0xFFFFFFFF;
27constexpr uint16_t kStreamedMemberWise = 0x4000;
28constexpr uint32_t kIsReferenced = 1 << 4;
29constexpr int64_t kMapOffset = 2;
39struct EmbeddedBasket {
44using Object = std::variant<std::monostate,
45 std::shared_ptr<BranchInfo>,
46 std::shared_ptr<LeafInfo>,
47 std::shared_ptr<EmbeddedBasket>,
48 std::shared_ptr<std::string>>;
51std::shared_ptr<T>
as(Object
const& o)
53 auto*
p = std::get_if<std::shared_ptr<T>>(&o);
54 return p ? *
p :
nullptr;
63 explicit ObjectReader(Cursor&
c) : mC(
c) {}
66 std::map<std::string, std::string> stringMap();
78 void skipObject(
char const*
className,
bool checkVersion =
true);
79 std::vector<Object> objArray();
82 std::shared_ptr<BranchInfo> tbranch(
int64_t mapAt);
83 std::shared_ptr<LeafInfo> tleaf(std::string
const&
className,
int64_t mapAt);
84 std::shared_ptr<EmbeddedBasket> tbasket(
int64_t mapAt);
85 std::shared_ptr<std::string> tobjstring(
int64_t mapAt);
88 std::map<int64_t, std::string> mClasses;
89 std::map<int64_t, Object> mObjects;
96 if (it == table.end() || std::find(it->second.begin(), it->second.end(),
version) == it->second.end()) {
101ObjectReader::Versioned ObjectReader::header(
char const*
className)
104 auto bcnt = mC.
u32();
105 if (!(bcnt & kByteCountMask)) {
106 throw UnsupportedLayout(std::string(
"object of class ") +
className +
" without byte count");
108 size_t end =
start + 4 + (bcnt & ~kByteCountMask);
110 mC.
fail(std::string(
"byte count of ") +
className +
" past the end of the buffer");
113 if (
version & kStreamedMemberWise) {
114 throw UnsupportedLayout(std::string(
"memberwise streaming of ") +
className);
120void ObjectReader::tobject()
123 if (
version & kStreamedMemberWise) {
128 checkVersion(
"TObject",
version);
131 if (
bits & kIsReferenced) {
136std::string ObjectReader::tnamed()
149 auto bcnt = mC.
u32();
150 if (!(bcnt & kByteCountMask)) {
151 throw UnsupportedLayout(std::string(
"object of class ") +
className +
" without byte count");
158 mC.
skip(bcnt & ~kByteCountMask);
161std::vector<Object> ObjectReader::objArray()
169 mC.
fail(
"negative TObjArray size");
171 std::vector<Object>
result;
172 for (
int i = 0;
i <
size; ++
i) {
173 result.push_back(anyObject());
181Object ObjectReader::anyObject()
184 auto begPos = mC.
pos();
185 auto bcnt = mC.
u32();
186 if (!(bcnt & kByteCountMask) || bcnt == kNewClassTag) {
191 if (tag & kClassMask) {
192 throw UnsupportedLayout(
"new object without byte count");
198 throw UnsupportedLayout(
"reference to the parent object");
200 auto it = mObjects.find(tag);
201 if (it == mObjects.end()) {
206 size_t end = begPos + 4 + (bcnt & ~kByteCountMask);
208 mC.
fail(
"object byte count past the end of the buffer");
213 if (!(tag & kClassMask)) {
214 throw UnsupportedLayout(
"object reference with byte count");
215 }
else if (tag == kNewClassTag) {
217 mClasses[tagAt + kMapOffset] =
className;
220 auto it = mClasses.find(tag & ~kClassMask);
221 if (it == mClasses.end()) {
224 result = readByClass(it->second, beg + kMapOffset);
230Object ObjectReader::readByClass(std::string
const&
className,
int64_t mapAt)
233 return tbranch(mapAt);
235 if (
className.size() == 6 &&
className.starts_with(
"TLeaf") && std::string_view(
"OBSILFD").find(
className[5]) != std::string_view::npos) {
239 return tbasket(mapAt);
242 return tobjstring(mapAt);
244 throw UnsupportedLayout(
"objects of class " +
className);
247std::shared_ptr<LeafInfo> ObjectReader::tleaf(std::string
const&
className,
int64_t mapAt)
250 auto leaf = std::make_shared<LeafInfo>();
251 mObjects[mapAt] = leaf;
253 auto vl =
header(
"TLeaf");
255 leaf->name = tnamed();
256 leaf->len = mC.
i32();
257 if (leaf->len <= 0) {
263 leaf->isUnsigned = mC.
u8() != 0;
264 auto count = anyObject();
267 }
else if (!std::holds_alternative<std::monostate>(
count)) {
268 throw UnsupportedLayout(
"fLeafCount of " + leaf->name +
" is not a leaf");
276std::shared_ptr<EmbeddedBasket> ObjectReader::tbasket(
int64_t mapAt)
279 auto basket = std::make_shared<EmbeddedBasket>();
280 mObjects[mapAt] = basket;
282 checkVersion(
"TBasket",
header.version % 1000);
283 auto keylen =
header.keylen;
284 auto nevbuf =
header.nevbuf;
287 if (nevbuf < 0 || last < keylen) {
288 mC.
fail(
"inconsistent embedded basket header");
290 basket->nEntries = nevbuf;
295 bool displacements = flag > 40;
299 bool hasBuffer = flag > 10;
303 if (flag == 1 && nevbuf > 0) {
305 mC.
skip(4 + 4 * (
size_t)nevbuf);
307 mC.
skip(4 + 4 * (
size_t)nevbuf);
314 basket->data.assign(
data.begin(),
data.end());
319std::shared_ptr<std::string> ObjectReader::tobjstring(
int64_t mapAt)
321 auto s = std::make_shared<std::string>();
330std::shared_ptr<BranchInfo> ObjectReader::tbranch(
int64_t mapAt)
332 auto b = std::make_shared<BranchInfo>();
336 skipObject(
"TAttFill",
false);
340 auto writeBasket = mC.
i32();
342 skipObject(
"ROOT::TIOFeatures",
false);
344 auto maxBaskets = mC.
i32();
346 b->entries = mC.
i64();
348 b->totBytes = mC.
i64();
349 b->zipBytes = mC.
i64();
350 if (maxBaskets < 0 || writeBasket < 0 || b->
entries < 0) {
351 mC.
fail(
"inconsistent TBranch header for " +
b->name);
354 if ((
size_t)maxBaskets > mC.
remaining() / 20) {
355 mC.
fail(
"fMaxBaskets " +
std::to_string(maxBaskets) +
" of branch " +
b->name +
" exceeds the buffer");
358 if (!objArray().
empty()) {
359 throw UnsupportedLayout(
"branch " +
b->name +
" has sub-branches");
361 auto leaves = objArray();
362 if (leaves.size() != 1 || !as<LeafInfo>(leaves[0])) {
363 throw UnsupportedLayout(
"branch " +
b->name +
" does not have exactly one leaf");
365 auto baskets = objArray();
367 auto readArray = [
this, maxBaskets](
auto reader) {
369 std::vector<int64_t>
values(maxBaskets);
375 auto basketBytes = readArray([
this] {
return (
int64_t)mC.
i32(); });
376 auto basketEntry = readArray([
this] {
return mC.
i64(); });
377 auto basketSeek = readArray([
this] {
return mC.
i64(); });
378 if (!mC.
string().empty()) {
379 throw UnsupportedLayout(
"branch " +
b->name +
" stores its baskets in another file");
383 auto leaf = as<LeafInfo>(leaves[0]);
384 b->leafClass = leaf->className[5];
385 b->isUnsigned = leaf->isUnsigned;
386 b->fixedLen = leaf->len;
387 b->countBranch = leaf->countLeaf;
391 while (nNormal < maxBaskets && nNormal < writeBasket && basketSeek[nNormal] != 0) {
394 for (
int i = 0;
i < nNormal; ++
i) {
395 if (basketBytes[
i] <= 0 || basketSeek[
i] < 0) {
396 mC.
fail(
"invalid basket location in branch " +
b->name);
400 bool hasNext =
i + 1 < maxBaskets;
401 if (basketEntry[
i] < 0 || (hasNext && basketEntry[
i + 1] < basketEntry[
i])) {
402 mC.
fail(
"invalid basket entries in branch " +
b->name);
404 int64_t n = hasNext ? basketEntry[
i + 1] - basketEntry[
i] : -1;
406 mC.
fail(
"invalid basket entries in branch " +
b->name);
411 bool knownNormal = nNormal < maxBaskets;
412 int64_t normalEntries = nNormal == 0 ? 0 : (knownNormal ? basketEntry[nNormal] : -1);
413 if (normalEntries !=
b->entries) {
415 for (
auto& o : baskets) {
416 auto e = as<EmbeddedBasket>(o);
417 if (!
e || (!knownNormal &&
e->nEntries == 0)) {
420 b->baskets.push_back(BasketRef{0, 0,
first,
e->nEntries,
true, std::move(
e->data)});
428 if (nNormal > 0 &&
b->baskets[nNormal - 1].nEntries < 0) {
429 int64_t rest =
b->entries -
b->baskets[nNormal - 1].firstEntry;
430 for (
size_t i = nNormal;
i <
b->baskets.size(); ++
i) {
431 rest -=
b->baskets[
i].nEntries;
433 if (rest >= 0 && rest <= INT32_MAX) {
434 b->baskets[nNormal - 1].nEntries = (
int32_t)rest;
440TreeInfo ObjectReader::tree()
445 skipObject(
"TAttLine",
false);
446 skipObject(
"TAttFill",
false);
447 skipObject(
"TAttMarker",
false);
448 t.entries = mC.
i64();
449 t.totBytes = mC.
i64();
450 t.zipBytes = mC.
i64();
454 auto nClusterRange = mC.
u32();
457 mC.
skip(8 * (
size_t)nClusterRange);
459 mC.
skip(8 * (
size_t)nClusterRange);
460 skipObject(
"ROOT::TIOFeatures",
false);
461 for (
auto& o : objArray()) {
462 auto b = as<BranchInfo>(o);
464 throw UnsupportedLayout(
"tree " +
t.name +
" has a branch which is not a TBranch");
466 t.branches.push_back(std::move(*
b));
473std::map<std::string, std::string> ObjectReader::stringMap()
475 std::map<std::string, std::string>
result;
480 for (
int i = 0;
i <
n; ++
i) {
481 auto key = as<std::string>(anyObject());
482 auto value = as<std::string>(anyObject());
484 throw UnsupportedLayout(
"TMap entry which is not a TObjString pair");
513 static const std::map<std::string, std::vector<int>> table{
537 return ObjectReader{
c}.tree();
543 return ObjectReader{
c}.stringMap();
unsigned short int uint16_t
std::vector< std::string > header
std::vector< long > entries
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual Show related Highlight grid Show only individual collision Color clusters belonging to track objects Set line Enable drawing TPC data Enable drawing TOF data Enable drawing magnetic field Set field line step count Invert colors configStandalone Heavy OpenGL display display_heavy Show tracks with ITS contribution Show tracks with TOF contribution Enable propagation of loopers Show clusters at nominal x of pad row for early transformed data Split CE tracks when they cross the central Mark clusters Mark adjacent clusters Hide rejected tracks Apply filter on tracks to be displayed Separate increase X h configStandalone Camera window renderer OpenGL display display_camera Orient the camera such that the y axis is always upwards Full Screen MultiSample Anti Downsampling Anti Enable Vertical Sync Target frame or if the backend cannot limit to the refresh Use OpenGL indirect draws to reduce number of draw calls Display h configStandalone Vulkan display display_vulkan Have uniform buffers in host accessible device memory h configStandalone Internal display display_internal Number of updates the Qt GUI may send ahead of the last one the display has before it waits for the display Opacity of the console background Number of console lines the history is shortened to this when it reaches twice the size Time in seconds an info message fades out after setInfoTime h OpenGL display display Font size Do not use Freetype for font Renderer for event Frontend to use for event ROOT macros used as track filter Console script file
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
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
std::span< const uint8_t > buffer() const
std::span< const uint8_t > bytes(size_t n)
std::string const & file() const
int64_t displacement() const
std::string string()
TString: 1-byte length, or 0xFF followed by a 4-byte length.
void fail(std::string const &what) const
std::string cstring()
NUL-terminated string, as used for class names after kNewClassTag.
GLuint const GLchar * name
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * value
GLenum GLsizei GLsizei GLint * values
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * bits
GLenum GLenum GLsizei len
TreeInfo readTreePayload(std::span< const uint8_t > payload, uint16_t keylen, std::string const &file, uint64_t fileOffset)
BasketHeader readBasketHeader(Cursor &c)
size_t leafElementSize(char leafClass)
Size in bytes of one value of a leaf class on disk.
std::map< std::string, std::vector< int > > const & supportedClassVersions()
std::map< std::string, std::string > readStringMapPayload(std::span< const uint8_t > payload, uint16_t keylen, std::string const &file, uint64_t fileOffset)
Deserializes a TMap of TObjString to TObjString (metaData, parentFiles).
PlaceholderNode as(Configurable< T > const &v)
void check(const std::vector< std::string > &arguments, const std::vector< ConfigParamSpec > &workflowOptions, const std::vector< DeviceSpec > &deviceSpecs, CheckMatrix &matrix)
std::string to_string(gsl::span< T, Size > span)
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))