45static_assert(std::is_nothrow_move_assignable_v<RBranchData>);
46static_assert(std::is_nothrow_move_constructible_v<RBranchData>);
50void AssertNoNullBranchAddresses(
const std::vector<RBranchData> &branches)
52 std::vector<TBranch *> branchesWithNullAddress;
53 for (
const auto &branchData : branches) {
54 if (branchData.fOutputBranch->GetAddress() ==
nullptr)
55 branchesWithNullAddress.push_back(branchData.fOutputBranch);
58 if (branchesWithNullAddress.empty())
62 std::vector<std::string> missingBranchNames;
63 std::transform(branchesWithNullAddress.begin(), branchesWithNullAddress.end(),
64 std::back_inserter(missingBranchNames), [](
TBranch *
b) { return b->GetName(); });
65 std::string msg =
"RDataFrame::Snapshot:";
66 if (missingBranchNames.size() == 1) {
67 msg +=
" branch " + missingBranchNames[0] +
68 " is needed as it provides the size for one or more branches containing dynamically sized arrays, but "
72 for (
const auto &bName : missingBranchNames)
74 msg.resize(msg.size() - 2);
75 msg +=
" are needed as they provide the size of other branches containing dynamically sized arrays, but they are";
77 msg +=
" not part of the set of branches that are being written out.";
78 throw std::runtime_error(msg);
84 if (
auto *getBranchRes = inputTree->
GetBranch(branchName.c_str()))
88 if (
auto *findBranchRes = inputTree->
FindBranch(branchName.c_str()))
94std::vector<RBranchData>::iterator CreateCStyleArrayBranch(
TTree &outputTree, std::vector<RBranchData> &outputBranches,
95 std::vector<RBranchData>::iterator thisBranch,
96 TBranch *inputBranch,
int basketSize,
void *address)
107 const auto bname = leaf->GetName();
108 auto *sizeLeaf = leaf->GetLeafCount();
109 const auto sizeLeafName = sizeLeaf ? std::string(sizeLeaf->GetName()) : std::to_string(leaf->GetLenStatic());
112 if (sizeLeaf || leaf->GetLenStatic() > 1) {
117 std::find_if(outputBranches.begin(), outputBranches.end(),
118 [&sizeLeafName](const RBranchData &bd) { return bd.fOutputBranchName == sizeLeafName; });
119 if (sizeLeafIt == outputBranches.end()) {
122 const auto indexBeforeEmplace = std::distance(outputBranches.begin(), thisBranch);
123 outputBranches.emplace_back(
"", sizeLeafName, false, nullptr);
124 thisBranch = outputBranches.begin() + indexBeforeEmplace;
125 sizeLeafIt = outputBranches.end() - 1;
127 if (!sizeLeafIt->fOutputBranch) {
129 const auto sizeTypeStr = ROOT::Internal::RDF::TypeName2ROOTTypeName(sizeLeaf->GetTypeName());
131 const auto bufSize = (basketSize > 0) ? basketSize : sizeLeaf->GetBranch()->GetBasketSize();
134 auto *outputBranch = outputTree.Branch(sizeLeafName.c_str(), static_cast<void *>(nullptr),
135 (sizeLeafName +
'/' + sizeTypeStr).c_str(), bufSize);
136 sizeLeafIt->fOutputBranch = outputBranch;
140 const auto btype = leaf->GetTypeName();
142 if (rootbtype ==
' ') {
144 "RDataFrame::Snapshot: could not correctly construct a leaflist for C-style array in column %s. The "
145 "leaf is of type '%s'. This column will not be written out.",
150 const auto leaflist = std::string(bname) +
"[" + sizeLeafName +
"]/" + rootbtype;
152 const auto bufSize = (basketSize > 0) ? basketSize : inputBranch->GetBasketSize();
153 void *addressForBranch = [address]() ->
void * {
158 return rawRVec->
data();
162 thisBranch->fOutputBranch =
163 outputTree.
Branch(thisBranch->fOutputBranchName.c_str(), addressForBranch, leaflist.c_str(), bufSize);
164 thisBranch->fOutputBranch->SetTitle(inputBranch->
GetTitle());
165 thisBranch->fIsCArray =
true;
171void SetBranchAddress(
TBranch *inputBranch,
RBranchData &branchData,
void *valueAddress)
173 const static TClassRef TBOClRef(
"TBranchObject");
174 if (inputBranch && inputBranch->
IsA() == TBOClRef) {
181 void *correctAddress = [valueAddress, isCArray = branchData.
fIsCArray]() ->
void * {
186 return rawRVec->
data();
195void CreateFundamentalTypeBranch(
TTree &outputTree,
RBranchData &bd,
void *valueAddress,
int bufSize)
201 if (rootTypeChar ==
' ') {
203 "RDataFrame::Snapshot: could not correctly construct a leaflist for fundamental type in column %s. This "
204 "column will not be written out.",
216 const std::string &fileName)
220 if (fileMode !=
"update")
224 std::unique_ptr<TFile> outFile{
TFile::Open(fileName.c_str(),
"UPDATE_WITHOUT_GLOBALREGISTRATION")};
225 if (!outFile || outFile->IsZombie())
226 throw std::invalid_argument(
"Snapshot: cannot open file \"" + fileName +
"\" in update mode");
229 if (!outFile->GetKey(objName.c_str()))
234 if (
auto existingTree = outFile->Get<
TTree>(objName.c_str()); existingTree) {
237 existingTree->Delete(
"all");
240 outFile->Delete((objName +
";*").c_str());
243 const std::string msg =
"Snapshot: object \"" + objName +
"\" already present in file \"" + fileName +
244 "\". If you want to delete the original object and write another, please set the "
245 "'fOverwriteIfExists' option to true in RSnapshotOptions.";
246 throw std::invalid_argument(msg);
250void SetBranchesHelper(
TTree *inputTree,
TTree &outputTree,
251 std::vector<ROOT::Internal::RDF::RBranchData> &allBranchData, std::size_t currentIndex,
252 int basketSize,
void *valueAddress)
254 auto branchData = allBranchData.begin() + currentIndex;
259 SetBranchAddress(inputBranch, *branchData, valueAddress);
268 const auto bufSize = (basketSize > 0) ? basketSize : (inputBranch ? inputBranch->GetBasketSize() : 32000);
269 const auto splitLevel = inputBranch ? inputBranch->
GetSplitLevel() : 99;
272 if (
dynamic_cast<TDataType *
>(dictionary)) {
274 CreateFundamentalTypeBranch(outputTree, *branchData, valueAddress, bufSize);
284 branchData = CreateCStyleArrayBranch(outputTree, allBranchData, branchData, inputBranch, bufSize, valueAddress);
297 if (
auto *classPtr =
dynamic_cast<TClass *
>(dictionary)) {
299 if (inputBranch &&
dynamic_cast<TBranchObject *
>(inputBranch) && valueAddress)
302 inputBranch->
GetAddress(), bufSize, splitLevel);
304 else if (valueAddress)
307 valueAddress, bufSize, splitLevel);
316 throw std::logic_error(
317 "RDataFrame::Snapshot: something went wrong when creating a TTree branch, please report this as a bug.");
331 }
else if (options.
fOutputFormat == OutputFormat::kRNTuple) {
338 throw std::invalid_argument(
"RDataFrame::Snapshot: unrecognized output format");
342std::string ModeWithoutGlobalRegistration(
const std::string &
mode)
344 if (
mode.find(
"_WITHOUT_GLOBALREGISTRATION") != std::string::npos) {
347 return mode +
"_WITHOUT_GLOBALREGISTRATION";
353 const std::type_info *typeID)
360 if (
auto datatype =
dynamic_cast<TDataType *
>(dictionary); datatype) {
362 }
else if (
auto tclass =
dynamic_cast<TClass *
>(dictionary); tclass) {
373 if (
auto fundamental = std::get_if<FundamentalType>(&
fTypeData); fundamental) {
374 assert(!pointerToPointer);
375 return fundamental->fBytes.data();
378 auto &dynamic = std::get<EmptyDynamicType>(
fTypeData);
379 if (!dynamic.fEmptyInstance) {
381 assert(
dynamic_cast<TDataType *
>(dictionary) ==
384 auto tclass =
dynamic_cast<TClass *
>(dictionary);
386 dynamic.fEmptyInstance = std::shared_ptr<void>{tclass->New(), tclass->GetDestructor()};
389 if (pointerToPointer) {
391 dynamic.fRawPtrToEmptyInstance = dynamic.fEmptyInstance.get();
392 return &dynamic.fRawPtrToEmptyInstance;
394 return dynamic.fEmptyInstance.get();
407 if (
auto fundamental = std::get_if<FundamentalType>(&
fTypeData); fundamental) {
408 fundamental->fBytes.fill(std::byte{0});
416 std::string_view
filename, std::string_view dirname, std::string_view treename,
const ColumnNames_t &vbnames,
419 const std::vector<const std::type_info *> &colTypeIDs)
431 for (
unsigned int i = 0; i < vbnames.size(); ++i) {
432 fBranchData.emplace_back(vbnames[i], std::move(outputBranchNames[i]), isDefine[i], colTypeIDs[i]);
445 const auto fileOpenMode = [&]() {
446 TString checkupdate = fOptions.fMode;
447 checkupdate.ToLower();
448 return checkupdate ==
"update" ?
"updated" :
"created";
451 "A lazy Snapshot action was booked but never triggered. The tree '%s' in output file '%s' was not %s. "
452 "In case it was desired instead, remember to trigger the Snapshot operation, by storing "
453 "its result in a variable and for example calling the GetValue() method on it.",
486 auto nValues = values.size();
487 for (
decltype(nValues) i{}; i < nValues; i++) {
504 for (std::size_t i = 0; i <
fBranchData.size(); i++) {
512 void *dummyValueAddress{};
513 for (std::size_t i = 0; i <
fBranchData.size(); i++) {
514 SetBranchesHelper(inputTree, outputTree,
fBranchData, i,
fOptions.fBasketSize, dummyValueAddress);
521 "", GetSnapshotCompressionSettings(
fOptions)));
523 throw std::runtime_error(
"Snapshot: could not create output file " +
fFileName);
529 if (checkupdate ==
"update")
576 const std::string finalName = *
reinterpret_cast<const std::string *
>(newName);
577 std::vector<std::string> inputBranchNames;
578 std::vector<std::string> outputBranchNames;
579 std::vector<bool> isDefine;
580 std::vector<const std::type_info *> inputColumnTypeIDs;
593 std::move(inputBranchNames),
594 std::move(outputBranchNames),
603 unsigned int nSlots, std::string_view
filename, std::string_view dirname, std::string_view treename,
606 const std::vector<const std::type_info *> &colTypeIDs)
623 for (
unsigned int slot = 0; slot <
fNSlots; ++slot) {
626 thisSlot.reserve(vbnames.size());
627 for (
unsigned int i = 0; i < vbnames.size(); ++i) {
628 thisSlot.emplace_back(vbnames[i], outputBranchNames[i], isDefine[i], colTypeIDs[i]);
643 const auto fileOpenMode = [&]() {
644 TString checkupdate = fOptions.fMode;
645 checkupdate.ToLower();
646 return checkupdate ==
"update" ?
"updated" :
"created";
649 "A lazy Snapshot action was booked but never triggered. The tree '%s' in output file '%s' was not %s. "
650 "In case it was desired instead, remember to trigger the Snapshot operation, by storing "
651 "its result in a variable and for example calling the GetValue() method on it.",
707 if ((autoFlush > 0) && (entries % autoFlush == 0))
712 const std::vector<void *> &values)
719 auto nValues = values.size();
720 for (
decltype(nValues) i{}; i < nValues; i++) {
736 const std::vector<void *> &values)
740 assert(branchData.size() == values.size());
741 for (std::size_t i = 0; i < branchData.size(); i++) {
745 AssertNoNullBranchAddresses(branchData);
750 void *dummyValueAddress{};
752 for (std::size_t i = 0; i < branchData.size(); i++) {
753 SetBranchesHelper(inputTree, outputTree, branchData, i,
fOptions.fBasketSize, dummyValueAddress);
763 throw std::runtime_error(
"Snapshot: could not create output file " +
fFileName);
765 fMerger = std::make_unique<ROOT::TBufferMerger>(std::move(outFile));
781 assert(
fOutputFile &&
"Missing output file in Snapshot finalization.");
825 const std::string finalName = *
reinterpret_cast<const std::string *
>(newName);
826 std::vector<std::string> inputBranchNames;
827 std::vector<std::string> outputBranchNames;
828 std::vector<bool> isDefine;
829 std::vector<const std::type_info *> inputColumnTypeIDs;
843 std::move(inputBranchNames),
844 std::move(outputBranchNames),
849 std::move(inputColumnTypeIDs)};
853 unsigned int nSlots, std::string_view
filename, std::string_view dirname, std::string_view ntuplename,
856 const std::vector<const std::type_info *> &colTypeIDs)
882 Warning(
"Snapshot",
"A lazy Snapshot action was booked but never triggered.");
890 for (
decltype(nFields) i = 0; i < nFields; i++) {
900 if (typeName.substr(0, 25) ==
"ROOT::RNTupleCardinality<") {
902 std::string cardinalityType = typeName.substr(25, typeName.size() - 26);
904 "Column \"%s\" is a read-only \"%s\" column. It will be snapshot as its inner type \"%s\" instead.",
925 throw std::runtime_error(
"Snapshot: could not create output file " +
fFileName);
931 if (checkupdate ==
"update")
955 for (
decltype(values.size()) i = 0; i < values.size(); i++) {
958 fillContext->Fill(*outputEntry);
993 const std::string finalName = *
reinterpret_cast<const std::string *
>(newName);
1032 (std::string{
"R_rdf_column_to_bitmask_mapping_"} +
fTree->GetName()).c_str());
1036 fTree->AutoSave(
"flushbaskets");
1039 std::string tree =
fTree->GetName();
1042 std::string file =
fFile->GetName();
1048 fOutputLoopManager->SetDataSource(std::make_unique<ROOT::Internal::RDF::RTTreeDS>(tree, file));
1064 if (variationIndex != it->second) {
1065 throw std::logic_error(
"Branch " + branchName +
1066 " is being registered with different variation index than the expected one: " +
1067 std::to_string(variationIndex));
1074 const auto vectorIndex = variationIndex / 64u;
1075 const auto bitIndex = variationIndex % 64u;
1078 while (vectorIndex >=
fBitMasks.size()) {
1079 std::string bitmaskBranchName =
1080 std::string{
"R_rdf_mask_"} +
fTree->GetName() +
'_' + std::to_string(
fBitMasks.size());
1081 fBitMasks.push_back(Bitmask{bitmaskBranchName});
1082 fTree->Branch(bitmaskBranchName.c_str(),
fBitMasks.back().branchBuffer.get());
1093 mask.bitset.reset();
1099 const auto vectorIndex =
index / 64;
1100 const auto bitIndex =
index % 64;
1101 fBitMasks[vectorIndex].bitset.set(bitIndex,
true);
1114 throw std::runtime_error(
"The TTree associated to the Snapshot action doesn't exist, any more.");
1117 *
mask.branchBuffer =
mask.bitset.to_ullong();
1127 std::string_view
filename, std::string_view dirname, std::string_view treename,
const ColumnNames_t &vbnames,
1130 const std::vector<const std::type_info *> &colTypeIDs)
1133 EnsureValidSnapshotOutput(
fOptions, std::string(treename), std::string(
filename));
1138 GetSnapshotCompressionSettings(
fOptions)));
1140 throw std::runtime_error(std::string{
"Snapshot: could not create output file "} + std::string{
filename});
1143 if (!dirname.empty()) {
1147 if (checkupdate ==
"update")
1149 fOutputHandle->fFile->mkdir(std::string{dirname}.c_str(),
"",
true);
1151 outputDir =
fOutputHandle->fFile->mkdir(std::string{dirname}.c_str());
1154 fOutputHandle->fTree = std::make_unique<TTree>(std::string{treename}.c_str(), std::string{treename}.c_str(),
1163 for (
unsigned int i = 0; i < vbnames.size(); ++i) {
1165 fBranchData.emplace_back(vbnames[i], outputBranchNames[i], isDefine[i], colTypeIDs[i]);
1180 unsigned int columnIndex,
1181 unsigned int originalColumnIndex,
1182 unsigned int variationIndex,
1183 std::string
const &variationName)
1185 if (columnIndex == originalColumnIndex) {
1188 assert(variationIndex == 0);
1197 std::replace(newOutputName.begin(), newOutputName.end(),
':',
'_');
1203 assert(
static_cast<unsigned int>(
fBranchData[columnIndex].fVariationIndex) == variationIndex);
1216 for (std::size_t i = 0; i <
fBranchData.size(); i++) {
1227 std::vector<bool>
const &filterPassed)
1231 for (std::size_t i = 0; i < values.size(); i++) {
1232 const auto variationIndex =
fBranchData[i].fVariationIndex;
1233 if (variationIndex < 0) {
1238 if (variationIndex == 0 || filterPassed[variationIndex]) {
1239 const bool fundamentalType =
fBranchData[i].WriteValueIfFundamental(values[i]);
1240 if (!fundamentalType) {
1245 if (filterPassed[variationIndex]) {
if(isa< VarDecl >(D)||isa< FieldDecl >(D)||isa< EnumConstantDecl >(D))
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char mode
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.