37bool AreThereSubBranches(std::string_view parentBrName,
TTree &tree)
39 const std::string prefix = [&parentBrName]() {
40 if (parentBrName.back() ==
'.')
41 return std::string(parentBrName);
42 return std::string(parentBrName) +
'.';
49 if (prefix.compare(0, prefix.
size(), leaf->GetName(), prefix.
size()) == 0)
59 fDirector(nullptr), fInitialized(false), fIsMember(false), fIsClone(false), fIsaPointer(false),
60 fHasLeafCount(false), fBranchName(
""), fParent(nullptr), fDataMember(
""),
61 fClassName(
""),
fClass(nullptr), fElement(nullptr), fMemberOffset(0), fOffset(0), fArrayLength(1),
62 fBranch(nullptr), fBranchCount(nullptr),
64 fRead(-1), fWhere(nullptr),fCollection(nullptr)
73 fDirector(boss), fInitialized(false), fIsMember(false), fIsClone(false), fIsaPointer(false),
74 fHasLeafCount(false), fBranchName(top), fParent(nullptr), fDataMember(
""),
75 fClassName(
""),
fClass(nullptr), fElement(nullptr), fMemberOffset(0), fOffset(0), fArrayLength(1),
76 fBranch(nullptr), fBranchCount(nullptr),
78 fRead(-1), fWhere(nullptr),fCollection(nullptr)
91 fDirector(boss), fInitialized(false), fIsMember(true), fIsClone(false), fIsaPointer(false),
92 fHasLeafCount(false), fBranchName(top), fParent(nullptr), fDataMember(membername),
93 fClassName(
""),
fClass(nullptr), fElement(nullptr), fMemberOffset(0), fOffset(0), fArrayLength(1),
94 fBranch(nullptr), fBranchCount(nullptr),
96 fRead(-1), fWhere(nullptr),fCollection(nullptr)
112 fDirector(boss), fInitialized(false), fIsMember(true), fIsClone(false), fIsaPointer(false),
113 fHasLeafCount(false), fBranchName(top), fParent(parent), fDataMember(membername),
114 fClassName(
""),
fClass(nullptr), fElement(nullptr), fMemberOffset(0), fOffset(0), fArrayLength(1),
115 fBranch(nullptr), fBranchCount(nullptr),
117 fRead(-1), fWhere(nullptr),fCollection(nullptr)
120 if (fBranchName.Length() && fBranchName[fBranchName.Length()-1]!=
'.') {
121 ((
TString&)fBranchName).Append(
".");
132 fDirector(boss), fInitialized(false), fIsMember(membername != nullptr && membername[0]), fIsClone(false), fIsaPointer(false),
133 fHasLeafCount(false), fBranchName(branch->GetName()), fParent(nullptr), fDataMember(membername),
134 fClassName(
""),
fClass(nullptr), fElement(nullptr), fMemberOffset(0), fOffset(0), fArrayLength(1),
135 fBranch(nullptr), fBranchCount(nullptr),
137 fRead(-1), fWhere(nullptr),fCollection(nullptr)
155 std::string sFullBranchName = fullBranchName;
156 std::string::size_type pos = sFullBranchName.rfind(branch->
GetFullName());
157 if (pos != std::string::npos) {
158 sFullBranchName.erase(pos);
161 return sFullBranchName;
169 const char *membername,
bool suppressMissingBranchError)
172 fIsMember(membername != nullptr && membername[0]),
175 fHasLeafCount(false),
176 fSuppressMissingBranchError(suppressMissingBranchError),
179 fDataMember(membername),
187 fBranchCount(nullptr),
203 if (fNotify.IsLinked() && fDirector && fDirector->GetTree())
204 fNotify.RemoveLink(*(fDirector->GetTree()));
214 fBranchCount =
nullptr;
222 fInitialized =
false;
223 fHasLeafCount =
false;
225 fCollection =
nullptr;
233 std::cout <<
"fBranchName " << fBranchName << std::endl;
235 std::cout <<
"fBranch " << fBranch << std::endl;
237 std::cout <<
"fLeafCount " << fLeafCount << std::endl;
238 else if (fBranchCount)
239 std::cout <<
"fBranchCount " << fBranchCount << std::endl;
250 if (!fDirector->GetTree()) {
253 if (!fNotify.IsLinked()) {
254 fNotify.PrependLink(*fDirector->GetTree());
258 if (!fParent->Setup()) {
268 Int_t i = fDirector->GetReadEntry();
269 if (i<0) fDirector->SetReadEntry(0);
270 if (fParent->Read()) {
271 if (i<0) fDirector->SetReadEntry(i);
276 if (clones) pcl = clones->
GetClass();
281 if (fCollection)
delete fCollection;
283 pcl = fCollection->GetValueClass();
284 if (pcl ==
nullptr) {
286 Error(
"Setup",
"Not finding TClass for collection for the data member %s seems no longer be in class %s",fDataMember.Data(),fParent->GetClass()->GetName());
294 fClass = fElement->GetClassPointer();
295 fMemberOffset = fElement->GetOffset();
296 fArrayLength = fElement->GetArrayLength();
298 Error(
"Setup",
"Data member %s seems no longer be in class %s",fDataMember.Data(),pcl->
GetName());
304 fWhere = fParent->fWhere;
306 if (fParent->IsaPointer()) {
320 fBranch = fDirector->GetTree()->GetBranch(fBranchName.Data());
322 if (!fSuppressMissingBranchError && !AreThereSubBranches(fBranchName.View(), *fDirector->GetTree())) {
329 auto *tree = fDirector->GetTree()->GetTree();
330 Error(
"TBranchProxy::Setup()",
"%s",
331 Form(
"Branch '%s' is not available from tree '%s' in file '%s'.", fBranchName.Data(),
338 fWhere = (
double*)fBranch->GetAddress();
346 fWhere = (
double*)fBranch->GetAddress();
350 TLeaf *leaf2 =
nullptr;
351 if (fDataMember.Length()) {
352 leaf2 = fBranch->GetLeaf(fDataMember);
353 }
else if (!fWhere) {
354 leaf2 = (
TLeaf*)fBranch->GetListOfLeaves()->At(0);
359 fArrayLength = leaf2->
GetLen();
362 fHasLeafCount =
true;
367 TLeaf *leaf = (
TLeaf*) fBranch->GetListOfLeaves()->At(0);
377 fWhere = (
double*)fBranch->GetAddress();
388 fClassName =
"TClonesArray";
393 fIsaPointer = fElement->IsaPointer();
394 fClass = fElement->GetClassPointer();
405 if ( fIsMember && be->
GetType()==3 ) {
407 }
else if (fIsaPointer) {
408 clones = (
TClonesArray*)*(
void**)((
char*)fWhere+fOffset);
412 if (!fIsMember) fIsClone =
true;
430 if (!fIsMember) fIsClone =
true;
447 }
else if (be->
GetType()==41) {
453 }
else if (be->
GetType()==31) {
466 fWhere = ((
unsigned char*)be->
GetObject()) + fOffset;
471 fClassName = fBranch->GetClassName();
474 fClassName = fBranch->GetClassName();
515 member = fDataMember;
518 fMemberOffset =
fClass->GetDataMemberOffset(member);
520 if (fMemberOffset<0) {
521 Error(
"Setup",
"%s",
Form(
"Negative offset %d for %s in %s",
522 fMemberOffset,fBranch->
GetName(),
523 bcount?bcount->
GetName():
"unknown"));
529 fClass->GetStreamerInfo()->GetElements()->FindObject(fDataMember);
531 fMemberOffset = fElement->GetOffset();
537 member += fDataMember;
538 fMemberOffset =
fClass->GetDataMemberOffset(member);
546 Error(
"Setup",
"%s",
Form(
"Missing TClass object for %s\n",fClassName.Data()));
552 fOffset = fMemberOffset;
556 fWhere = ((
unsigned char*)fWhere) + fMemberOffset;
561 if (fWhere!=
nullptr) {
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
static std::string GetFriendBranchName(TTree *directorTree, TBranch *branch, const char *fullBranchName)
For a fullBranchName that might contain a leading friend tree path (but access elements designating a...
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Base class for all the proxy object.
const TString fBranchName
bool Setup()
Initialize/cache the necessary information.
void Reset()
Completely reset the object.
TBranchProxy()
Constructor.
virtual void Print()
Display the content of the object.
virtual ~TBranchProxy()
Typical Destructor.
void Attach(Detail::TBranchProxy *p)
Attach a TBranchProxy object to this director.
A Branch for the case of an object.
TBranchElement * GetBranchCount() const
const char * GetClassName() const override
Return the name of the user class whose content is stored in this branch, if any.
TStreamerInfo * GetInfo() const
Get streamer info for the branch class.
void SetupAddresses() override
If the branch address is not set, we set all addresses starting with the top level parent branch.
TVirtualCollectionProxy * GetCollectionProxy()
Return the collection proxy describing the branch content, if any.
Int_t GetEntry(Long64_t entry=0, Int_t getall=0) override
Read all branches of a BranchElement and return total number of bytes.
char * GetObject() const
Return a pointer to our object.
TClass * IsA() const override
A TTree is a list of TBranches.
virtual TString GetFullName() const
Return the 'full' name of the branch.
virtual void SetAddress(void *add)
Set address of this branch.
TBranch * GetMother() const
Get our top-level parent branch in the tree.
TClass instances represent classes, structs and namespaces in the ROOT type system.
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0, Bool_t isTransient=kFALSE) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist,...
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
TClass * IsA() const override
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
An array of clone (identical) objects.
TClass * GetClass() const
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
virtual void * GetValuePointer() const
virtual Int_t GetLen() const
Return the number of effective elements of this leaf, for the current entry.
virtual TLeaf * GetLeafCount() const
If this leaf stores a variable-sized array or a multi-dimensional array whose last dimension has vari...
TBranch * GetBranch() const
const char * GetName() const override
Returns name of object.
TObject * At(Int_t idx) const override
virtual Bool_t IsaPointer() const
Describes a persistent version of a class.
Int_t GetElementOffset(Int_t id) const override
TObjArray * GetElements() const override
const char * Data() const
TString & Remove(Ssiz_t pos)
A TTree represents a columnar dataset.
virtual Long64_t GetReadEntry() const
virtual TTree * GetTree() const
virtual TClass * GetValueClass() const =0
If the value type is a user-defined class, return a pointer to the TClass representing the value type...
virtual TVirtualCollectionProxy * Generate() const =0
Returns a clean object of the actual class that derives from TVirtualCollectionProxy.
virtual TStreamerElement * GetStreamerElement(const char *datamember, Int_t &offset) const =0
std::vector< std::string > GetTreeFullPaths(const TTree &tree)
std::vector< std::string > GetFileNamesFromTree(const TTree &tree)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...