44static_assert(std::is_nothrow_move_assignable_v<RBranchData>);
45static_assert(std::is_nothrow_move_constructible_v<RBranchData>);
49void AssertNoNullBranchAddresses(
const std::vector<RBranchData> &branches)
51 std::vector<TBranch *> branchesWithNullAddress;
52 for (
const auto &branchData : branches) {
53 if (branchData.fOutputBranch->GetAddress() ==
nullptr)
54 branchesWithNullAddress.push_back(branchData.fOutputBranch);
57 if (branchesWithNullAddress.empty())
61 std::vector<std::string> missingBranchNames;
62 std::transform(branchesWithNullAddress.begin(), branchesWithNullAddress.end(),
63 std::back_inserter(missingBranchNames), [](
TBranch *
b) { return b->GetName(); });
64 std::string msg =
"RDataFrame::Snapshot:";
65 if (missingBranchNames.size() == 1) {
66 msg +=
" branch " + missingBranchNames[0] +
67 " is needed as it provides the size for one or more branches containing dynamically sized arrays, but "
71 for (
const auto &bName : missingBranchNames)
73 msg.resize(msg.size() - 2);
74 msg +=
" are needed as they provide the size of other branches containing dynamically sized arrays, but they are";
76 msg +=
" not part of the set of branches that are being written out.";
77 throw std::runtime_error(msg);
93std::vector<RBranchData>::iterator CreateCStyleArrayBranch(
TTree &outputTree, std::vector<RBranchData> &outputBranches,
94 std::vector<RBranchData>::iterator thisBranch,
95 TBranch *inputBranch,
int basketSize,
void *address)
106 const auto bname = leaf->GetName();
107 auto *sizeLeaf = leaf->GetLeafCount();
108 const auto sizeLeafName = sizeLeaf ? std::string(sizeLeaf->GetName()) : std::to_string(leaf->GetLenStatic());
111 if (sizeLeaf || leaf->GetLenStatic() > 1) {
116 std::find_if(outputBranches.begin(), outputBranches.end(),
117 [&sizeLeafName](const RBranchData &bd) { return bd.fOutputBranchName == sizeLeafName; });
118 if (sizeLeafIt == outputBranches.end()) {
121 const auto indexBeforeEmplace = std::distance(outputBranches.begin(), thisBranch);
122 outputBranches.emplace_back(
"", sizeLeafName, false, nullptr);
123 thisBranch = outputBranches.begin() + indexBeforeEmplace;
124 sizeLeafIt = outputBranches.end() - 1;
126 if (!sizeLeafIt->fOutputBranch) {
128 const auto sizeTypeStr = ROOT::Internal::RDF::TypeName2ROOTTypeName(sizeLeaf->GetTypeName());
130 const auto bufSize = (basketSize > 0) ? basketSize : sizeLeaf->GetBranch()->GetBasketSize();
133 auto *outputBranch = outputTree.Branch(sizeLeafName.c_str(), static_cast<void *>(nullptr),
134 (sizeLeafName +
'/' + sizeTypeStr).c_str(), bufSize);
135 sizeLeafIt->fOutputBranch = outputBranch;
139 const auto btype = leaf->GetTypeName();
141 if (rootbtype ==
' ') {
143 "RDataFrame::Snapshot: could not correctly construct a leaflist for C-style array in column %s. The "
144 "leaf is of type '%s'. This column will not be written out.",
149 const auto leaflist = std::string(bname) +
"[" + sizeLeafName +
"]/" + rootbtype;
151 const auto bufSize = (basketSize > 0) ? basketSize : inputBranch->GetBasketSize();
152 void *addressForBranch = [address]() ->
void * {
157 return rawRVec->
data();
161 thisBranch->fOutputBranch =
162 outputTree.
Branch(thisBranch->fOutputBranchName.c_str(), addressForBranch, leaflist.c_str(), bufSize);
163 thisBranch->fOutputBranch->SetTitle(inputBranch->
GetTitle());
164 thisBranch->fIsCArray =
true;
170void SetBranchAddress(
TBranch *inputBranch,
RBranchData &branchData,
void *valueAddress)
172 const static TClassRef TBOClRef(
"TBranchObject");
173 if (inputBranch && inputBranch->
IsA() == TBOClRef) {
180 void *correctAddress = [valueAddress, isCArray = branchData.
fIsCArray]() ->
void * {
185 return rawRVec->
data();
194void CreateFundamentalTypeBranch(
TTree &outputTree,
RBranchData &bd,
void *valueAddress,
int bufSize)
200 if (rootTypeChar ==
' ') {
202 "RDataFrame::Snapshot: could not correctly construct a leaflist for fundamental type in column %s. This "
203 "column will not be written out.",
215 const std::string &fileName)
219 if (fileMode !=
"update")
223 std::unique_ptr<TFile> outFile{
TFile::Open(fileName.c_str(),
"update")};
224 if (!outFile || outFile->IsZombie())
225 throw std::invalid_argument(
"Snapshot: cannot open file \"" + fileName +
"\" in update mode");
228 if (!outFile->GetKey(objName.c_str()))
233 if (
auto existingTree = outFile->Get<
TTree>(objName.c_str()); existingTree) {
236 existingTree->Delete(
"all");
239 outFile->Delete((objName +
";*").c_str());
242 const std::string msg =
"Snapshot: object \"" + objName +
"\" already present in file \"" + fileName +
243 "\". If you want to delete the original object and write another, please set the "
244 "'fOverwriteIfExists' option to true in RSnapshotOptions.";
245 throw std::invalid_argument(msg);
249void SetBranchesHelper(
TTree *inputTree,
TTree &outputTree,
250 std::vector<ROOT::Internal::RDF::RBranchData> &allBranchData, std::size_t currentIndex,
251 int basketSize,
void *valueAddress)
253 auto branchData = allBranchData.begin() + currentIndex;
258 SetBranchAddress(inputBranch, *branchData, valueAddress);
267 const auto bufSize = (basketSize > 0) ? basketSize : (inputBranch ? inputBranch->GetBasketSize() : 32000);
268 const auto splitLevel = inputBranch ? inputBranch->
GetSplitLevel() : 99;
271 if (
dynamic_cast<TDataType *
>(dictionary)) {
273 CreateFundamentalTypeBranch(outputTree, *branchData, valueAddress, bufSize);
283 branchData = CreateCStyleArrayBranch(outputTree, allBranchData, branchData, inputBranch, bufSize, valueAddress);
296 if (
auto *classPtr =
dynamic_cast<TClass *
>(dictionary)) {
298 if (inputBranch &&
dynamic_cast<TBranchObject *
>(inputBranch) && valueAddress)
301 inputBranch->
GetAddress(), bufSize, splitLevel);
303 else if (valueAddress)
306 valueAddress, bufSize, splitLevel);
315 throw std::logic_error(
316 "RDataFrame::Snapshot: something went wrong when creating a TTree branch, please report this as a bug.");
330 }
else if (options.
fOutputFormat == OutputFormat::kRNTuple) {
337 throw std::invalid_argument(
"RDataFrame::Snapshot: unrecognized output format");
343 const std::type_info *typeID)
350 if (
auto datatype =
dynamic_cast<TDataType *
>(dictionary); datatype) {
352 }
else if (
auto tclass =
dynamic_cast<TClass *
>(dictionary); tclass) {
363 if (
auto fundamental = std::get_if<FundamentalType>(&
fTypeData); fundamental) {
364 assert(!pointerToPointer);
365 return fundamental->fBytes.data();
368 auto &dynamic = std::get<EmptyDynamicType>(
fTypeData);
369 if (!dynamic.fEmptyInstance) {
371 assert(
dynamic_cast<TDataType *
>(dictionary) ==
374 auto tclass =
dynamic_cast<TClass *
>(dictionary);
376 dynamic.fEmptyInstance = std::shared_ptr<void>{tclass->New(), tclass->GetDestructor()};
379 if (pointerToPointer) {
381 dynamic.fRawPtrToEmptyInstance = dynamic.fEmptyInstance.get();
382 return &dynamic.fRawPtrToEmptyInstance;
384 return dynamic.fEmptyInstance.get();
397 if (
auto fundamental = std::get_if<FundamentalType>(&
fTypeData); fundamental) {
398 fundamental->fBytes.fill(std::byte{0});
406 std::string_view filename, std::string_view dirname, std::string_view treename,
const ColumnNames_t &vbnames,
409 const std::vector<const std::type_info *> &colTypeIDs)
421 for (
unsigned int i = 0; i < vbnames.size(); ++i) {
422 fBranchData.emplace_back(vbnames[i], std::move(outputBranchNames[i]), isDefine[i], colTypeIDs[i]);
435 const auto fileOpenMode = [&]() {
436 TString checkupdate = fOptions.fMode;
437 checkupdate.ToLower();
438 return checkupdate ==
"update" ?
"updated" :
"created";
441 "A lazy Snapshot action was booked but never triggered. The tree '%s' in output file '%s' was not %s. "
442 "In case it was desired instead, remember to trigger the Snapshot operation, by storing "
443 "its result in a variable and for example calling the GetValue() method on it.",
476 auto nValues = values.size();
477 for (
decltype(nValues) i{}; i < nValues; i++) {
482 if (
auto *data = rawRVec->data();
fBranchData[i].fBranchAddressForCArrays != data) {
494 for (std::size_t i = 0; i <
fBranchData.size(); i++) {
502 void *dummyValueAddress{};
503 for (std::size_t i = 0; i <
fBranchData.size(); i++) {
504 SetBranchesHelper(inputTree, outputTree,
fBranchData, i,
fOptions.fBasketSize, dummyValueAddress);
513 throw std::runtime_error(
"Snapshot: could not create output file " +
fFileName);
519 if (checkupdate ==
"update")
566 const std::string finalName = *
reinterpret_cast<const std::string *
>(newName);
567 std::vector<std::string> inputBranchNames;
568 std::vector<std::string> outputBranchNames;
569 std::vector<bool> isDefine;
570 std::vector<const std::type_info *> inputColumnTypeIDs;
583 std::move(inputBranchNames),
584 std::move(outputBranchNames),
593 unsigned int nSlots, std::string_view filename, std::string_view dirname, std::string_view treename,
596 const std::vector<const std::type_info *> &colTypeIDs)
613 for (
unsigned int slot = 0; slot <
fNSlots; ++slot) {
616 thisSlot.reserve(vbnames.size());
617 for (
unsigned int i = 0; i < vbnames.size(); ++i) {
618 thisSlot.emplace_back(vbnames[i], outputBranchNames[i], isDefine[i], colTypeIDs[i]);
633 const auto fileOpenMode = [&]() {
634 TString checkupdate = fOptions.fMode;
635 checkupdate.ToLower();
636 return checkupdate ==
"update" ?
"updated" :
"created";
639 "A lazy Snapshot action was booked but never triggered. The tree '%s' in output file '%s' was not %s. "
640 "In case it was desired instead, remember to trigger the Snapshot operation, by storing "
641 "its result in a variable and for example calling the GetValue() method on it.",
697 if ((autoFlush > 0) && (entries % autoFlush == 0))
702 const std::vector<void *> &values)
709 auto nValues = values.size();
710 for (
decltype(nValues) i{}; i < nValues; i++) {
726 const std::vector<void *> &values)
730 assert(branchData.size() == values.size());
731 for (std::size_t i = 0; i < branchData.size(); i++) {
735 AssertNoNullBranchAddresses(branchData);
740 void *dummyValueAddress{};
742 for (std::size_t i = 0; i < branchData.size(); i++) {
743 SetBranchesHelper(inputTree, outputTree, branchData, i,
fOptions.fBasketSize, dummyValueAddress);
751 GetSnapshotCompressionSettings(
fOptions))};
753 throw std::runtime_error(
"Snapshot: could not create output file " +
fFileName);
755 fMerger = std::make_unique<ROOT::TBufferMerger>(std::move(outFile));
771 assert(
fOutputFile &&
"Missing output file in Snapshot finalization.");
815 const std::string finalName = *
reinterpret_cast<const std::string *
>(newName);
816 std::vector<std::string> inputBranchNames;
817 std::vector<std::string> outputBranchNames;
818 std::vector<bool> isDefine;
819 std::vector<const std::type_info *> inputColumnTypeIDs;
833 std::move(inputBranchNames),
834 std::move(outputBranchNames),
839 std::move(inputColumnTypeIDs)};
843 unsigned int nSlots, std::string_view filename, std::string_view dirname, std::string_view ntuplename,
846 const std::vector<const std::type_info *> &colTypeIDs)
872 Warning(
"Snapshot",
"A lazy Snapshot action was booked but never triggered.");
880 for (
decltype(nFields) i = 0; i < nFields; i++) {
890 if (typeName.substr(0, 25) ==
"ROOT::RNTupleCardinality<") {
892 std::string cardinalityType = typeName.substr(25, typeName.size() - 26);
894 "Column \"%s\" is a read-only \"%s\" column. It will be snapshot as its inner type \"%s\" instead.",
915 throw std::runtime_error(
"Snapshot: could not create output file " +
fFileName);
921 if (checkupdate ==
"update")
945 for (
decltype(values.size()) i = 0; i < values.size(); i++) {
948 fillContext->Fill(*outputEntry);
983 const std::string finalName = *
reinterpret_cast<const std::string *
>(newName);
1022 (std::string{
"R_rdf_column_to_bitmask_mapping_"} +
fTree->GetName()).c_str());
1026 fTree->AutoSave(
"flushbaskets");
1029 std::string tree =
fTree->GetName();
1032 std::string file =
fFile->GetName();
1038 fOutputLoopManager->SetDataSource(std::make_unique<ROOT::Internal::RDF::RTTreeDS>(tree, file));
1054 if (variationIndex != it->second) {
1055 throw std::logic_error(
"Branch " + branchName +
1056 " is being registered with different variation index than the expected one: " +
1057 std::to_string(variationIndex));
1064 const auto vectorIndex = variationIndex / 64u;
1065 const auto bitIndex = variationIndex % 64u;
1068 while (vectorIndex >=
fBitMasks.size()) {
1069 std::string bitmaskBranchName =
1070 std::string{
"R_rdf_mask_"} +
fTree->GetName() +
'_' + std::to_string(
fBitMasks.size());
1071 fBitMasks.push_back(Bitmask{bitmaskBranchName});
1072 fTree->Branch(bitmaskBranchName.c_str(),
fBitMasks.back().branchBuffer.get());
1083 mask.bitset.reset();
1089 const auto vectorIndex = index / 64;
1090 const auto bitIndex = index % 64;
1091 fBitMasks[vectorIndex].bitset.set(bitIndex,
true);
1104 throw std::runtime_error(
"The TTree associated to the Snapshot action doesn't exist, any more.");
1107 *mask.branchBuffer = mask.bitset.to_ullong();
1117 std::string_view filename, std::string_view dirname, std::string_view treename,
const ColumnNames_t &vbnames,
1120 const std::vector<const std::type_info *> &colTypeIDs)
1123 EnsureValidSnapshotOutput(
fOptions, std::string(treename), std::string(filename));
1129 throw std::runtime_error(std::string{
"Snapshot: could not create output file "} + std::string{filename});
1132 if (!dirname.empty()) {
1136 if (checkupdate ==
"update")
1138 fOutputHandle->fFile->mkdir(std::string{dirname}.c_str(),
"",
true);
1140 outputDir =
fOutputHandle->fFile->mkdir(std::string{dirname}.c_str());
1143 fOutputHandle->fTree = std::make_unique<TTree>(std::string{treename}.c_str(), std::string{treename}.c_str(),
1152 for (
unsigned int i = 0; i < vbnames.size(); ++i) {
1154 fBranchData.emplace_back(vbnames[i], outputBranchNames[i], isDefine[i], colTypeIDs[i]);
1169 unsigned int columnIndex,
1170 unsigned int originalColumnIndex,
1171 unsigned int variationIndex,
1172 std::string
const &variationName)
1174 if (columnIndex == originalColumnIndex) {
1177 assert(variationIndex == 0);
1186 std::replace(newOutputName.begin(), newOutputName.end(),
':',
'_');
1192 assert(
static_cast<unsigned int>(
fBranchData[columnIndex].fVariationIndex) == variationIndex);
1205 for (std::size_t i = 0; i <
fBranchData.size(); i++) {
1216 std::vector<bool>
const &filterPassed)
1220 for (std::size_t i = 0; i < values.size(); i++) {
1221 const auto variationIndex =
fBranchData[i].fVariationIndex;
1222 if (variationIndex < 0) {
1227 if (variationIndex == 0 || filterPassed[variationIndex]) {
1228 const bool fundamentalType =
fBranchData[i].WriteValueIfFundamental(values[i]);
1229 if (!fundamentalType) {
1234 if (filterPassed[variationIndex]) {
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
static TBranch * SearchForBranch(TTree *tree, const char *name)
The head node of a RDF computation graph.
std::shared_ptr< SnapshotOutputWriter > fOutputHandle
RSnapshotOptions fOptions
SnapshotHelperWithVariations(std::string_view filename, std::string_view dirname, std::string_view treename, const ColumnNames_t &, const ColumnNames_t &bnames, const RSnapshotOptions &options, std::vector< bool > &&, ROOT::Detail::RDF::RLoopManager *outputLoopMgr, ROOT::Detail::RDF::RLoopManager *inputLoopMgr, const std::vector< const std::type_info * > &colTypeIDs)
void InitTask(TTreeReader *, unsigned int slot)
Bind all output branches to RDF columns for the given slots.
ROOT::Detail::RDF::RLoopManager * fInputLoopManager
std::vector< RBranchData > fBranchData
ROOT::Detail::RDF::RLoopManager * fOutputLoopManager
void Exec(unsigned int, const std::vector< void * > &values, std::vector< bool > const &filterPassed)
Connect all output fields to the values pointed to by values, fill the output dataset,...
void RegisterVariedColumn(unsigned int slot, unsigned int columnIndex, unsigned int originalColumnIndex, unsigned int varationIndex, std::string const &variationName)
Register a new column as a variation of the column at originalColumnIndex, and clone its properties.
std::vector< std::shared_ptr< ROOT::RNTupleFillContext > > fFillContexts
void FinalizeTask(unsigned int slot)
RSnapshotOptions fOptions
std::unique_ptr< ROOT::RNTupleParallelWriter > fWriter
ColumnNames_t fOutputFieldNames
std::unique_ptr< TFile > fOutputFile
UntypedSnapshotRNTupleHelper(unsigned int nSlots, std::string_view filename, std::string_view dirname, std::string_view ntuplename, const ColumnNames_t &vfnames, const ColumnNames_t &fnames, const RSnapshotOptions &options, ROOT::Detail::RDF::RLoopManager *inputLM, ROOT::Detail::RDF::RLoopManager *outputLM, const std::vector< const std::type_info * > &colTypeIDs)
std::vector< std::unique_ptr< ROOT::REntry > > fEntries
std::vector< const std::type_info * > fInputColumnTypeIDs
void Exec(unsigned int slot, const std::vector< void * > &values)
ROOT::Detail::RDF::RLoopManager * fOutputLoopManager
UntypedSnapshotRNTupleHelper MakeNew(void *newName)
Create a new UntypedSnapshotRNTupleHelper with a different output file name.
std::vector< ROOT::RFieldToken > fFieldTokens
ROOT::Detail::RDF::RLoopManager * fInputLoopManager
ColumnNames_t fInputFieldNames
void InitTask(TTreeReader *, unsigned int slot)
UntypedSnapshotTTreeHelperMT(unsigned int nSlots, std::string_view filename, std::string_view dirname, std::string_view treename, const ColumnNames_t &vbnames, const ColumnNames_t &bnames, const RSnapshotOptions &options, std::vector< bool > &&isDefine, ROOT::Detail::RDF::RLoopManager *loopManager, ROOT::Detail::RDF::RLoopManager *inputLM, const std::vector< const std::type_info * > &colTypeIDs)
void UpdateCArraysPtrs(unsigned int slot, const std::vector< void * > &values)
void SetEmptyBranches(TTree *inputTree, TTree &outputTree)
ROOT::Detail::RDF::RLoopManager * fInputLoopManager
ROOT::Detail::RDF::RLoopManager * fOutputLoopManager
std::vector< std::shared_ptr< ROOT::TBufferMergerFile > > fOutputFiles
std::vector< std::vector< RBranchData > > fBranchData
UntypedSnapshotTTreeHelperMT MakeNew(void *newName, std::string_view="nominal")
Create a new UntypedSnapshotTTreeHelperMT with a different output file name.
RSnapshotOptions fOptions
std::vector< int > fBranchAddressesNeedReset
void InitTask(TTreeReader *r, unsigned int slot)
std::vector< TTree * > fInputTrees
void FinalizeTask(unsigned int slot)
void Exec(unsigned int slot, const std::vector< void * > &values)
std::vector< std::unique_ptr< TTree > > fOutputTrees
std::unique_ptr< ROOT::TBufferMerger > fMerger
void SetBranches(unsigned int slot, const std::vector< void * > &values)
RSnapshotOptions fOptions
ROOT::Detail::RDF::RLoopManager * fOutputLoopManager
ROOT::Detail::RDF::RLoopManager * fInputLoopManager
std::vector< RBranchData > fBranchData
void InitTask(TTreeReader *, unsigned int)
UntypedSnapshotTTreeHelper MakeNew(void *newName, std::string_view="nominal")
Create a new UntypedSnapshotTTreeHelper with a different output file name.
void SetEmptyBranches(TTree *inputTree, TTree &outputTree)
bool fBranchAddressesNeedReset
std::unique_ptr< TFile > fOutputFile
void SetBranches(const std::vector< void * > &values)
std::unique_ptr< TTree > fOutputTree
void Exec(unsigned int, const std::vector< void * > &values)
UntypedSnapshotTTreeHelper(std::string_view filename, std::string_view dirname, std::string_view treename, const ColumnNames_t &vbnames, const ColumnNames_t &bnames, const RSnapshotOptions &options, std::vector< bool > &&isDefine, ROOT::Detail::RDF::RLoopManager *loopManager, ROOT::Detail::RDF::RLoopManager *inputLM, const std::vector< const std::type_info * > &colTypeIDs)
void UpdateCArraysPtrs(const std::vector< void * > &values)
pointer data() noexcept
Return a pointer to the vector's buffer, even if empty().
static RResult< std::unique_ptr< RFieldBase > > Create(const std::string &fieldName, const std::string &typeName, const ROOT::RCreateFieldOptions &options, const ROOT::RNTupleDescriptor *desc, ROOT::DescriptorId_t fieldId)
Factory method to resurrect a field from the stored on-disk type information.
static std::unique_ptr< RNTupleModel > CreateBare()
Creates a "bare model", i.e. an RNTupleModel with no default entry.
static std::unique_ptr< RNTupleParallelWriter > Append(std::unique_ptr< ROOT::RNTupleModel > model, std::string_view ntupleName, TDirectory &fileOrDirectory, const ROOT::RNTupleWriteOptions &options=ROOT::RNTupleWriteOptions())
Append an RNTuple to the existing file.
Common user-tunable settings for storing RNTuples.
void SetEnablePageChecksums(bool val)
Note that turning off page checksums will also turn off the same page merging optimization (see tunin...
void SetMaxUnzippedClusterSize(std::size_t val)
void SetMaxUnzippedPageSize(std::size_t val)
void SetInitialUnzippedPageSize(std::size_t val)
void SetEnableSamePageMerging(bool val)
void SetApproxZippedClusterSize(std::size_t val)
void SetCompression(std::uint32_t val)
A "std::vector"-like collection of values implementing handy operation to analyse them.
A Branch for the case of an object.
A TTree is a list of TBranches.
virtual const char * GetClassName() const
Return the name of the user class whose content is stored in this branch, if any.
virtual char * GetAddress() const
Int_t GetSplitLevel() const
TClass * IsA() const override
virtual void SetAddress(void *add)
Set address of this branch.
TObjArray * GetListOfLeaves()
TClassRef is used to implement a permanent reference to a TClass object.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Basic data type descriptor (datatype information is obtained from CINT).
static TDictionary * GetDictionary(const char *name)
Retrieve the type (class, fundamental type, typedef etc) named "name".
TDirectory::TContext keeps track and restore the current directory.
Describe directory structure in memory.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
const char * GetTitle() const override
Returns title of object.
void ToLower()
Change string to lower-case.
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
A TTree represents a columnar dataset.
virtual TBranch * FindBranch(const char *name)
Return the branch that correspond to the path 'branchname', which can include the name of the tree or...
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
TBranch * Branch(const char *name, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
Add a new branch, and infer the data type from the type of obj being passed.
virtual TTree * GetTree() const
@ kEntriesReshuffled
If set, signals that this TTree is the output of the processing of another TTree, and the entries are...
std::vector< std::string > ReplaceDotWithUnderscore(const std::vector< std::string > &columnNames)
Replace occurrences of '.
char TypeName2ROOTTypeName(const std::string &b)
Convert type name (e.g.
std::string TypeID2TypeName(const std::type_info &id)
Returns the name of a type starting from its type_info An empty string is returned in case of failure...
std::string GetTypeNameWithOpts(const ROOT::RDF::RDataSource &ds, std::string_view colName, bool vector2RVec)
char TypeID2ROOTTypeName(const std::type_info &tid)
TBranch * CallBranchImp(TTree &tree, const char *branchname, TClass *ptrClass, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99)
TBranch * CallBranchImpRef(TTree &tree, const char *branchname, TClass *ptrClass, EDataType datatype, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99)
std::vector< std::string > ColumnNames_t
int CompressionSettings(RCompressionSetting::EAlgorithm::EValues algorithm, int compressionLevel)
ROOT::ESTLType STLKind(std::string_view type)
Converts STL container name to number.
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...
Stores empty instances of classes, so a dummy object can be written when a systematic variation doesn...
Stores variations of a fundamental type.
Stores properties of each output branch in a Snapshot.
void * EmptyInstance(bool pointerToPointer)
Return a pointer to an empty instance of the type represented by this branch.
void ClearBranchContents()
Point the branch address to an empty instance of the type represented by this branch or write null by...
void * fBranchAddressForCArrays
std::variant< FundamentalType, EmptyDynamicType > fTypeData
std::string fOutputBranchName
void ClearBranchPointers()
std::string fInputBranchName
const std::type_info * fInputTypeID
std::unique_ptr< uint64_t > branchBuffer
void Write() const
Write the current event and the bitmask to the output dataset.
std::unique_ptr< TTree > fTree
void ClearMaskBits()
Clear all bits, as if none of the variations passed its filter.
SnapshotOutputWriter(SnapshotOutputWriter const &)=delete
RLoopManager * fOutputLoopManager
std::string fDirectoryName
std::unordered_map< std::string, std::pair< std::string, unsigned int > > fBranchToBitmaskMapping
std::unique_ptr< TFile > fFile
void RegisterBranch(std::string const &branchName, unsigned int variationIndex)
Register a branch and corresponding systematic uncertainty.
SnapshotOutputWriter(TFile *file)
void SetMaskBit(unsigned int index)
Set a bit signalling that the variation at index passed its filter.
bool MaskEmpty() const
Test if any of the mask bits are set.
SnapshotOutputWriter & operator=(SnapshotOutputWriter const &)=delete
std::unordered_map< std::string, unsigned int > fBranchToVariationMapping
SnapshotOutputWriter(SnapshotOutputWriter &&) noexcept=delete
std::vector< Bitmask > fBitMasks
Tag to let data sources use the native data type when creating a column reader.
EValues
Note: this is only temporarily a struct and will become a enum class hence the name convention used.
A collection of options to steer the creation of the dataset on disk through Snapshot().
ESnapshotOutputFormat fOutputFormat
Which data format to write to.
std::string fMode
Mode of creation of output file.
ECAlgo fCompressionAlgorithm
Compression algorithm of output file.
int fCompressionLevel
Compression level of output file.
bool fOverwriteIfExists
If fMode is "UPDATE", overwrite object in output file if it already exists.