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);
83 if (
auto *getBranchRes = inputTree->
GetBranch(branchName.c_str()))
87 if (
auto *findBranchRes = inputTree->
FindBranch(branchName.c_str()))
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_WITHOUT_GLOBALREGISTRATION")};
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");
341std::string ModeWithoutGlobalRegistration(
const std::string &
mode)
343 if (
mode.find(
"_WITHOUT_GLOBALREGISTRATION") != std::string::npos) {
346 return mode +
"_WITHOUT_GLOBALREGISTRATION";
352 const std::type_info *typeID)
359 if (
auto datatype =
dynamic_cast<TDataType *
>(dictionary); datatype) {
361 }
else if (
auto tclass =
dynamic_cast<TClass *
>(dictionary); tclass) {
372 if (
auto fundamental = std::get_if<FundamentalType>(&
fTypeData); fundamental) {
373 assert(!pointerToPointer);
374 return fundamental->fBytes.data();
377 auto &dynamic = std::get<EmptyDynamicType>(
fTypeData);
378 if (!dynamic.fEmptyInstance) {
380 assert(
dynamic_cast<TDataType *
>(dictionary) ==
383 auto tclass =
dynamic_cast<TClass *
>(dictionary);
385 dynamic.fEmptyInstance = std::shared_ptr<void>{tclass->New(), tclass->GetDestructor()};
388 if (pointerToPointer) {
390 dynamic.fRawPtrToEmptyInstance = dynamic.fEmptyInstance.get();
391 return &dynamic.fRawPtrToEmptyInstance;
393 return dynamic.fEmptyInstance.get();
406 if (
auto fundamental = std::get_if<FundamentalType>(&
fTypeData); fundamental) {
407 fundamental->fBytes.fill(std::byte{0});
415 std::string_view
filename, std::string_view dirname, std::string_view treename,
const ColumnNames_t &vbnames,
418 const std::vector<const std::type_info *> &colTypeIDs)
430 for (
unsigned int i = 0; i < vbnames.size(); ++i) {
431 fBranchData.emplace_back(vbnames[i], std::move(outputBranchNames[i]), isDefine[i], colTypeIDs[i]);
444 const auto fileOpenMode = [&]() {
445 TString checkupdate = fOptions.fMode;
446 checkupdate.ToLower();
447 return checkupdate ==
"update" ?
"updated" :
"created";
450 "A lazy Snapshot action was booked but never triggered. The tree '%s' in output file '%s' was not %s. "
451 "In case it was desired instead, remember to trigger the Snapshot operation, by storing "
452 "its result in a variable and for example calling the GetValue() method on it.",
485 auto nValues = values.size();
486 for (
decltype(nValues) i{}; i < nValues; i++) {
503 for (std::size_t i = 0; i <
fBranchData.size(); i++) {
511 void *dummyValueAddress{};
512 for (std::size_t i = 0; i <
fBranchData.size(); i++) {
513 SetBranchesHelper(inputTree, outputTree,
fBranchData, i,
fOptions.fBasketSize, dummyValueAddress);
520 "", GetSnapshotCompressionSettings(
fOptions)));
522 throw std::runtime_error(
"Snapshot: could not create output file " +
fFileName);
528 if (checkupdate ==
"update")
575 const std::string finalName = *
reinterpret_cast<const std::string *
>(newName);
576 std::vector<std::string> inputBranchNames;
577 std::vector<std::string> outputBranchNames;
578 std::vector<bool> isDefine;
579 std::vector<const std::type_info *> inputColumnTypeIDs;
592 std::move(inputBranchNames),
593 std::move(outputBranchNames),
602 unsigned int nSlots, std::string_view
filename, std::string_view dirname, std::string_view treename,
605 const std::vector<const std::type_info *> &colTypeIDs)
622 for (
unsigned int slot = 0; slot <
fNSlots; ++slot) {
625 thisSlot.reserve(vbnames.size());
626 for (
unsigned int i = 0; i < vbnames.size(); ++i) {
627 thisSlot.emplace_back(vbnames[i], outputBranchNames[i], isDefine[i], colTypeIDs[i]);
642 const auto fileOpenMode = [&]() {
643 TString checkupdate = fOptions.fMode;
644 checkupdate.ToLower();
645 return checkupdate ==
"update" ?
"updated" :
"created";
648 "A lazy Snapshot action was booked but never triggered. The tree '%s' in output file '%s' was not %s. "
649 "In case it was desired instead, remember to trigger the Snapshot operation, by storing "
650 "its result in a variable and for example calling the GetValue() method on it.",
706 if ((autoFlush > 0) && (entries % autoFlush == 0))
711 const std::vector<void *> &values)
718 auto nValues = values.size();
719 for (
decltype(nValues) i{}; i < nValues; i++) {
735 const std::vector<void *> &values)
739 assert(branchData.size() == values.size());
740 for (std::size_t i = 0; i < branchData.size(); i++) {
744 AssertNoNullBranchAddresses(branchData);
749 void *dummyValueAddress{};
751 for (std::size_t i = 0; i < branchData.size(); i++) {
752 SetBranchesHelper(inputTree, outputTree, branchData, i,
fOptions.fBasketSize, dummyValueAddress);
762 throw std::runtime_error(
"Snapshot: could not create output file " +
fFileName);
764 fMerger = std::make_unique<ROOT::TBufferMerger>(std::move(outFile));
780 assert(
fOutputFile &&
"Missing output file in Snapshot finalization.");
824 const std::string finalName = *
reinterpret_cast<const std::string *
>(newName);
825 std::vector<std::string> inputBranchNames;
826 std::vector<std::string> outputBranchNames;
827 std::vector<bool> isDefine;
828 std::vector<const std::type_info *> inputColumnTypeIDs;
842 std::move(inputBranchNames),
843 std::move(outputBranchNames),
848 std::move(inputColumnTypeIDs)};
852 unsigned int nSlots, std::string_view
filename, std::string_view dirname, std::string_view ntuplename,
855 const std::vector<const std::type_info *> &colTypeIDs)
881 Warning(
"Snapshot",
"A lazy Snapshot action was booked but never triggered.");
889 for (
decltype(nFields) i = 0; i < nFields; i++) {
899 if (typeName.substr(0, 25) ==
"ROOT::RNTupleCardinality<") {
901 std::string cardinalityType = typeName.substr(25, typeName.size() - 26);
903 "Column \"%s\" is a read-only \"%s\" column. It will be snapshot as its inner type \"%s\" instead.",
924 throw std::runtime_error(
"Snapshot: could not create output file " +
fFileName);
930 if (checkupdate ==
"update")
954 for (
decltype(values.size()) i = 0; i < values.size(); i++) {
957 fillContext->Fill(*outputEntry);
992 const std::string finalName = *
reinterpret_cast<const std::string *
>(newName);
1031 (std::string{
"R_rdf_column_to_bitmask_mapping_"} +
fTree->GetName()).c_str());
1035 fTree->AutoSave(
"flushbaskets");
1038 std::string tree =
fTree->GetName();
1041 std::string file =
fFile->GetName();
1047 fOutputLoopManager->SetDataSource(std::make_unique<ROOT::Internal::RDF::RTTreeDS>(tree, file));
1063 if (variationIndex != it->second) {
1064 throw std::logic_error(
"Branch " + branchName +
1065 " is being registered with different variation index than the expected one: " +
1066 std::to_string(variationIndex));
1073 const auto vectorIndex = variationIndex / 64u;
1074 const auto bitIndex = variationIndex % 64u;
1077 while (vectorIndex >=
fBitMasks.size()) {
1078 std::string bitmaskBranchName =
1079 std::string{
"R_rdf_mask_"} +
fTree->GetName() +
'_' + std::to_string(
fBitMasks.size());
1080 fBitMasks.push_back(Bitmask{bitmaskBranchName});
1081 fTree->Branch(bitmaskBranchName.c_str(),
fBitMasks.back().branchBuffer.get());
1092 mask.bitset.reset();
1098 const auto vectorIndex =
index / 64;
1099 const auto bitIndex =
index % 64;
1100 fBitMasks[vectorIndex].bitset.set(bitIndex,
true);
1113 throw std::runtime_error(
"The TTree associated to the Snapshot action doesn't exist, any more.");
1116 *
mask.branchBuffer =
mask.bitset.to_ullong();
1126 std::string_view
filename, std::string_view dirname, std::string_view treename,
const ColumnNames_t &vbnames,
1129 const std::vector<const std::type_info *> &colTypeIDs)
1132 EnsureValidSnapshotOutput(
fOptions, std::string(treename), std::string(
filename));
1137 GetSnapshotCompressionSettings(
fOptions)));
1139 throw std::runtime_error(std::string{
"Snapshot: could not create output file "} + std::string{
filename});
1142 if (!dirname.empty()) {
1146 if (checkupdate ==
"update")
1148 fOutputHandle->fFile->mkdir(std::string{dirname}.c_str(),
"",
true);
1150 outputDir =
fOutputHandle->fFile->mkdir(std::string{dirname}.c_str());
1153 fOutputHandle->fTree = std::make_unique<TTree>(std::string{treename}.c_str(), std::string{treename}.c_str(),
1162 for (
unsigned int i = 0; i < vbnames.size(); ++i) {
1164 fBranchData.emplace_back(vbnames[i], outputBranchNames[i], isDefine[i], colTypeIDs[i]);
1179 unsigned int columnIndex,
1180 unsigned int originalColumnIndex,
1181 unsigned int variationIndex,
1182 std::string
const &variationName)
1184 if (columnIndex == originalColumnIndex) {
1187 assert(variationIndex == 0);
1196 std::replace(newOutputName.begin(), newOutputName.end(),
':',
'_');
1202 assert(
static_cast<unsigned int>(
fBranchData[columnIndex].fVariationIndex) == variationIndex);
1215 for (std::size_t i = 0; i <
fBranchData.size(); i++) {
1226 std::vector<bool>
const &filterPassed)
1230 for (std::size_t i = 0; i < values.size(); i++) {
1231 const auto variationIndex =
fBranchData[i].fVariationIndex;
1232 if (variationIndex < 0) {
1237 if (variationIndex == 0 || filterPassed[variationIndex]) {
1238 const bool fundamentalType =
fBranchData[i].WriteValueIfFundamental(values[i]);
1239 if (!fundamentalType) {
1244 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.