11#ifndef FRAMEWORK_ROOTTREEREADER_H
12#define FRAMEWORK_ROOTTREEREADER_H
140template <
typename KeyType>
174 static_assert(std::is_same<KeyType, const char*>::value ==
false,
"the key type must not be const char*");
220 template <
typename DataT,
typename BASE>
227 static const size_t STAGE = BASE::STAGE + 1;
255 if constexpr (
STAGE > 1) {
256 PrevT::setupInstance(
tree, publishhook);
258 mPublishHook = publishhook;
261 mBranch =
tree.GetBranch(mName.c_str());
263 std::string sizebranchName = std::string(mName) +
"Size";
264 auto sizebranch =
tree.GetBranch(sizebranchName.c_str());
265 auto* classinfo = TClass::GetClass(mBranch->GetClassName());
266 if constexpr (not std::is_void<value_type>::value) {
268 auto* storedclass = TClass::GetClass(
typeid(
value_type));
269 if (classinfo != storedclass) {
270 throw std::runtime_error(std::string(
"Configured type ") +
271 (storedclass !=
nullptr ? storedclass->GetName() :
typeid(
value_type).
name()) +
272 " does not match the stored data type " +
273 (classinfo !=
nullptr ? classinfo->GetName() :
"") +
274 " in branch " + mName);
278 if (classinfo ==
nullptr) {
279 throw std::runtime_error(std::string(
"can not find class description for branch ") + mName);
281 LOG(info) <<
"branch set up: " << mName;
284 throw std::runtime_error(
"mismatching class type, expecting std::vector<char> for binary branch");
286 mSizeBranch = sizebranch;
287 LOG(info) <<
"binary branch set up: " << mName;
289 mClassInfo = classinfo;
291 throw std::runtime_error(std::string(
"can not find branch ") + mName);
300 if constexpr (
STAGE > 1) {
301 PrevT::process(context,
entry, stackcreator);
304 auto snapshot = [&context, &stackcreator](
const KeyType&
key,
const auto&
object) {
312 char*
data =
nullptr;
314 mBranch->SetAddress(&
data);
315 mBranch->GetEntry(
entry);
317 data =
reinterpret_cast<char*
>(mClassInfo->New());
318 if (
data ==
nullptr) {
319 LOG(
error) <<
"branch " << mName <<
": cannot create an empty " << mClassInfo->GetName() <<
", nothing published";
325 if (mPublishHook !=
nullptr && (*mPublishHook).
hook(mName, context,
Output{mKey.origin, mKey.description, mKey.subSpec, std::move(stackcreator())},
data)) {
330 if (mSizeBranch !=
nullptr) {
333 mSizeBranch->SetAddress(&datasize);
334 mSizeBranch->GetEntry(
entry);
337 if (
buffer->size() == datasize) {
338 LOG(
debug) <<
"branch " << mName <<
": publishing binary chunk of " << datasize <<
" bytes(s)";
339 snapshot(mKey, std::move(*
buffer));
341 LOG(
error) <<
"branch " << mName <<
": inconsitent size of binary chunk "
342 <<
buffer->size() <<
" vs " << datasize;
344 snapshot(mKey,
empty);
347 if constexpr (std::is_void<value_type>::value ==
true) {
358 auto* delfunc = mClassInfo->GetDelete();
363 mBranch->DropBaskets(
"all");
370 TBranch* mBranch =
nullptr;
371 TBranch* mSizeBranch =
nullptr;
372 TClass* mClassInfo =
nullptr;
380 template <
typename T>
383 template <
typename U>
388 template <
typename U>
393 template <
typename U>
410 template <
typename... Args>
415 mInput.SetCacheSize(0);
416 parseConstructorArgs<0>(std::forward<Args>(args)...);
417 mBranchConfiguration->setup(mInput, mPublishHook);
423 mInput.AddFile(fileName);
424 mNEntries = mInput.GetEntries();
431 if (mNEntries == 0) {
434 if (mNofPublished >= 0) {
440 if ((mReadEntry + 1) >= mNEntries) {
443 if (mReadEntry < mNEntries) {
444 mReadEntry = mNEntries;
451 if (mMaxEntries > 0 && (mNofPublished + 1) >= mMaxEntries) {
452 if (mReadEntry < mNEntries) {
453 mReadEntry = mNEntries;
482 template <
typename ContextType,
typename... HeaderTypes>
484 HeaderTypes&&... headers)
const
486 if (mNEntries == 0) {
487 if (mNofPublished != 0) {
490 }
else if (mReadEntry >= mNEntries || (mMaxEntries > 0 && mNofPublished >= mMaxEntries)) {
494 auto stackcreator = [&headers...]() {
498 mBranchConfiguration->exec(context, mReadEntry, stackcreator);
505 return mNofPublished + 1;
510 template <
typename T,
typename... Args>
511 const char* getCharArg(T arg, Args&&...)
513 static_assert(std::is_same<T, const char*>::value,
"missing branch name after publishing key, use const char* argument right after the key");
518 template <
size_t skip,
typename U,
typename... Args>
519 void parseConstructorArgs(U
key, Args&&... args)
522 mBranchConfiguration = createBranchConfiguration<0, BranchConfigurationInterface>({}, std::forward<U>(
key), std::forward<Args>(args)...);
528 template <
size_t skip,
typename BASE,
typename U,
typename... Args>
529 std::unique_ptr<BranchConfigurationInterface> createBranchConfiguration(
ConstructorArgs&& cargs, U
def, Args&&... args)
531 if constexpr (skip > 0) {
532 return createBranchConfiguration<skip - 1,
BASE>(std::move(cargs), std::forward<Args>(args)...);
533 }
else if constexpr (std::is_same<U, const char*>::value) {
535 }
else if constexpr (std::is_same<U, int>::value) {
537 }
else if constexpr (std::is_same<U, PublishingMode>::value) {
538 mPublishingMode =
def;
539 }
else if constexpr (std::is_same<U, SpecialPublishHook*>::value) {
541 }
else if constexpr (is_specialization_v<U, BranchDefinition>) {
543 using type = BranchConfigurationElement<typename U::type, BASE>;
544 return std::move(createBranchConfiguration<0, type>(std::move(cargs), std::forward<Args>(args)...));
545 }
else if constexpr (
sizeof...(Args) > 0) {
546 const char* arg = getCharArg(std::forward<Args>(args)...);
547 if (arg !=
nullptr && *arg != 0) {
549 using type = BranchConfigurationElement<void, BASE>;
550 return std::move(createBranchConfiguration<1, type>(std::move(cargs), std::forward<Args>(args)...));
552 throw std::runtime_error(
"expecting valid branch name string after key");
554 static_assert(always_static_assert<U>::value,
"argument mismatch, define branches either as argument pairs of key and branchname or using the BranchDefinition helper struct");
556 return createBranchConfiguration<0, BASE>(std::move(cargs), std::forward<Args>(args)...);
561 template <
size_t skip,
typename T>
562 std::unique_ptr<BranchConfigurationInterface> createBranchConfiguration(
ConstructorArgs&& cargs)
564 static_assert(skip == 0);
565 return std::move(std::make_unique<T>(cargs));
571 std::unique_ptr<BranchConfigurationInterface> mBranchConfiguration;
577 int mNofPublished = -1;
579 int mMaxEntries = -1;
583 SpecialPublishHook* mPublishHook =
nullptr;
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 process
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 Print launch bounds used for RTC code as debugging for exit after def(1)) AddOption(allowOptimizedSlaveReconstruction
char error[CURL_ERROR_SIZE]
Class for time synchronization of RawReader instances.
void snapshot(const Output &spec, T const &object)
void process(ProcessingContext &context, int entry, std::function< o2::header::Stack()> &stackcreator)
Run the reader, first recursively for all lower stages, and then the current stage.
void exec(ProcessingContext &ctx, int entry, std::function< o2::header::Stack()> stackcreator) override
BranchConfigurationElement()=default
static const size_t STAGE
BranchConfigurationElement(ConstructorArgs const &args)
void setupInstance(TTree &tree, SpecialPublishHook *publishhook=nullptr)
~BranchConfigurationElement() override=default
void setup(TTree &tree, SpecialPublishHook *publishhook=nullptr) override
virtual ~BranchConfigurationInterface()=default
BranchConfigurationInterface(ConstructorArgs const &)
virtual void setup(TTree &, SpecialPublishHook *h=nullptr)
Setup the branch configuration, namely get the branch and class information from the tree.
static const size_t STAGE
virtual void exec(ProcessingContext &ctx, int entry, std::function< o2::header::Stack()> stackcreator)
BranchConfigurationInterface()=default
bool operator()(ContextType &context, HeaderTypes &&... headers) const
self_type & operator++(int)=delete
postfix increment forbidden
void addFile(const char *fileName)
add a file as source for the tree
self_type & operator++()
prefix increment, move to the next entry
o2::framework::ROOTSerialized< char, TClass > ROOTSerializedByClass
PublishingMode
Publishing mode determines what to do when the number of entries in the tree is reached.
@ Single
no more data after end of tree
@ Loop
start over at entry 0
GenericRootTreeReader(const char *treename, Args &&... args)
GenericRootTreeReader()
default constructor
int getCount() const
return the number of published entries
std::vector< ConstructorArg > ConstructorArgs
std::vector< char > BinaryDataStoreType
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
GLuint const GLchar * name
GLint GLint GLsizei GLint GLenum GLenum type
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
Defining ITS Vertex explicitly as messageable.
Lifetime
Possible Lifetime of objects being exchanged by the DPL.
BranchDefinition(U _key, std::string &&_name)
BranchDefinition(U _key, const char *_name)
BranchDefinition(U _key, std::string const &_name)
helper structure to hold the constructor arguments for BranchConfigurationElement stages
ConstructorArg(key_type _key, const char *_name)
ConstructorArg(key_type _key, std::string const &_name)
std::function< bool(std::string_view name, ProcessingContext &context, Output const &, char *data)> hook
header::DataOrigin origin
header::DataHeader::SubSpecificationType subSpec
header::DataOrigin origin
DefaultKey(const Output &desc)
header::DataDescription description
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))