41 Error(
"TClonesReader::GetCA()",
"Read error in TBranchProxy.");
70 Error(
"TSTLReader::GetCP()",
"Read error in TBranchProxy.");
74 Error(
"TSTLReader::GetCP()",
"Logic error, proxy object not set in TBranchProxy.");
90 if (!myCollectionProxy)
return 0;
91 return myCollectionProxy->
Size();
96 if (!myCollectionProxy)
return 0;
98 return *(
void**)myCollectionProxy->
At(idx);
101 return myCollectionProxy->
At(idx);
113 if (!proxy->
Read()) {
115 Error(
"TCollectionLessSTLReader::GetCP()",
"Read error in TBranchProxy.");
119 Error(
"TCollectionLessSTLReader::GetCP()",
"Logic error, proxy object not set in TBranchProxy.");
123 return localCollection;
128 if (!myCollectionProxy)
return 0;
130 return myCollectionProxy->
Size();
135 if (!myCollectionProxy)
return 0;
138 return *(
void**)myCollectionProxy->
At(idx);
140 return myCollectionProxy->
At(idx);
152 TObjectArrayReader() : basicTypeSize(-1) { }
153 ~TObjectArrayReader() {}
157 Error(
"TObjectArrayReader::GetCP()",
"Read error in TBranchProxy.");
165 if (!myCollectionProxy)
return 0;
166 return myCollectionProxy->
Size();
169 if (!proxy->
Read())
return 0;
172 void *array = (
void*)proxy->
GetStart();
174 if (basicTypeSize == -1){
177 Error(
"TObjectArrayReader::At()",
"Cannot get class info from branch proxy.");
183 objectSize = basicTypeSize;
185 return (
void*)((
Byte_t*)array + (objectSize * idx));
188 void SetBasicTypeSize(
Int_t size){
189 basicTypeSize = size;
193 class TArrayParameterSizeReader :
public TObjectArrayReader {
197 TArrayParameterSizeReader(
TTreeReader *treeReader,
const char *branchName) : indexReader(*treeReader, branchName) {}
203 class TArrayFixedSizeReader :
public TObjectArrayReader {
208 TArrayFixedSizeReader(
Int_t sizeArg) : size(sizeArg) {}
215 ~TBasicTypeArrayReader() {}
220 Error(
"TBasicTypeArrayReader::GetCP()",
"Read error in TBranchProxy.");
229 if (!myCollectionProxy)
return 0;
230 return myCollectionProxy->
Size();
235 if (!myCollectionProxy)
return 0;
240 class TBasicTypeClonesReader :
public TClonesReader {
244 TBasicTypeClonesReader(
Int_t offsetArg) : offset(offsetArg) {}
248 if (!myClonesArray)
return 0;
249 return (
Byte_t*)myClonesArray->
At(idx) + offset;
258 TLeafReader(
TTreeReaderValueBase *valueReaderArg) : valueReader(valueReaderArg), elementSize(-1) {}
262 return myLeaf ? myLeaf->
GetLen() : 0;
268 if (elementSize == -1){
270 if (!myLeaf)
return 0;
273 return (
Byte_t*)address + (elementSize * idx);
282 class TLeafParameterSizeReader :
public TLeafReader {
286 TLeafParameterSizeReader(
TTreeReader *treeReader,
const char *leafName,
TTreeReaderValueBase *valueReaderArg) : TLeafReader(valueReaderArg), sizeReader(*treeReader, leafName) {}
311 Error(
"TTreeReaderArrayBase::CreateProxy()",
"TTreeReader object not set / available for branch %s!",
317 const char* brDataType =
"{UNDETERMINED}";
320 brDataType = GetBranchDataType(br, dictUnused);
322 Error(
"TTreeReaderArrayBase::CreateProxy()",
"The template argument type T of %s accessing branch %s (which contains data of type %s) is not known to ROOT. You will need to create a dictionary for it.",
323 GetDerivedTypeName(), fBranchName.Data(), brDataType);
336 Fatal(
"TTreeReaderArrayBase::CreateProxy()",
"No fImpl set!");
346 if (fBranchName.Contains(
".")){
347 TRegexp leafNameExpression (
"\\.[a-zA-Z0-9_]+$");
348 TString leafName (fBranchName(leafNameExpression));
349 TString branchName = fBranchName(0, fBranchName.Length() - leafName.
Length());
352 Error(
"TTreeReaderArrayBase::CreateProxy()",
"The tree does not have a branch called %s. You could check with TTree::Print() for available branches.", fBranchName.Data());
357 myLeaf = branch->GetLeaf(
TString(leafName(1, leafName.
Length())));
359 Error(
"TTreeReaderArrayBase::CreateProxy()",
"The tree does not have a branch, nor a sub-branch called %s. You could check with TTree::Print() for available branches.", fBranchName.Data());
366 Error(
"TTreeReaderArrayBase::CreateProxy()",
"Failed to get the dictionary for %s.", myLeaf->
GetTypeName());
372 branchActualType = fDict;
374 fBranchName = branchName;
375 fLeafName = leafName(1, leafName.
Length());
378 Error(
"TTreeReaderArrayBase::CreateProxy()",
"Leaf of type %s cannot be read by TTreeReaderValue<%s>.", myLeaf->
GetTypeName(), fDict->GetName());
386 Error(
"TTreeReaderArrayBase::CreateProxy()",
"The tree does not have a branch called %s. You could check with TTree::Print() for available branches.", fBranchName.Data());
400 bool isTopLevel = branch->
GetMother() == branch;
402 membername = strrchr(branch->
GetName(),
'.');
403 if (membername.
IsNull()) {
404 membername = branch->
GetName();
408 fTreeReader->GetProxies()->Add(namedProxy);
414 const char* nonCollTypeName = GetBranchContentDataType(branch, branchActualTypeName, branchActualType);
415 if (nonCollTypeName) {
416 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
"The branch %s contains data of type %s, which should be accessed through a TTreeReaderValue< %s >.",
417 fBranchName.Data(), nonCollTypeName, nonCollTypeName);
421 if (!branchActualType) {
422 if (branchActualTypeName.
IsNull()) {
423 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
"Cannot determine the type contained in the collection of branch %s. That's weird - please report!",
426 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
"The branch %s contains data of type %s, which does not have a dictionary.",
427 fBranchName.Data(), branchActualTypeName.
Data());
433 if (fDict != branchActualType) {
434 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
"The branch %s contains data of type %s. It cannot be accessed by a TTreeReaderArray<%s>",
435 fBranchName.Data(), branchActualType->
GetName(), fDict->GetName());
458 fImpl =
new TLeafReader(
this);
464 fImpl =
new TLeafParameterSizeReader(fTreeReader, leafFullName.
Data(),
this);
480 fImpl =
new TSTLReader();
486 fImpl =
new TClonesReader();
497 fImpl =
new TBasicTypeArrayReader();
500 fImpl =
new TBasicTypeClonesReader(element->
GetOffset());
504 ((TObjectArrayReader*)fImpl)->SetBasicTypeSize(((
TDataType*)fDict)->
Size());
508 fImpl =
new TClonesReader();
519 Error(
"TTreeReaderArrayBase::CreateProxy",
"Failed to get the top leaf from the branch");
525 fImpl =
new TArrayFixedSizeReader(size);
528 fImpl =
new TArrayParameterSizeReader(fTreeReader, sizeLeaf->
GetName());
530 ((TObjectArrayReader*)fImpl)->SetBasicTypeSize(((
TDataType*)fDict)->
Size());
532 Error(
"TTreeReaderArrayBase::CreateProxy",
"Support for branches of type TBranchClones not implemented");
534 Error(
"TTreeReaderArrayBase::CreateProxy",
"Support for branches of type TBranchObject not implemented");
536 Error(
"TTreeReaderArrayBase::CreateProxy",
"Support for branches of type TBranchSTL not implemented");
537 fImpl =
new TSTLReader();
539 Error(
"TTreeReaderArrayBase::CreateProxy",
"Support for branches of type TBranchRef not implemented");
558 contentTypeName =
"";
562 || brElement->
GetType() == 3) {
567 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Could not get value class.");
576 if (brElement->
GetType() == 3) {
585 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Cannot determine STL collection type of %s stored in branch %s", brElement->
GetClassName(), branch->
GetName());
590 if (isMap) contentTypeName =
"std::pair< ";
591 contentTypeName += splitType.fElements[1];
593 contentTypeName += splitType.fElements[2];
594 contentTypeName +=
" >";
599 }
else if (brElement->
GetType() == 31
600 || brElement->
GetType() == 41) {
605 if (ExpectedTypeRet == 0) {
611 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"The branch %s contains a data type %d for which the dictionary cannot be retrieved.",
612 branch->
GetName(), (int)dtData);
617 }
else if (ExpectedTypeRet == 1) {
618 int brID = brElement->
GetID();
621 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"The branch %s contains data of type %s for which the dictionary does not exist. It's needed.",
636 return "{CANNOT DETERMINE TBranchElement DATA TYPE}";
648 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get class from branch element.");
652 if (!myCollectionProxy){
653 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get collection proxy from STL class");
661 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get valueClass from collectionProxy.");
664 contentTypeName = dict->
GetName();
668 if (!fProxy->Setup() || !fProxy->Read()){
669 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Failed to get type from proxy, unable to check type");
670 contentTypeName =
"UNKNOWN";
672 return contentTypeName;
676 contentTypeName = dict->
GetName();
690 contentTypeName =
"TClonesArray";
691 Warning(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Not able to check type correctness, ignoring check");
699 if (dict) contentTypeName = dict->
GetName();
704 contentTypeName = dict->
GetName();
715 if ((!dataTypeName || !dataTypeName[0])
728 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"The branch %s was created using a leaf list and cannot be represented as a C++ type. Please access one of its siblings using a TTreeReaderValueArray:", branch->
GetName());
731 while ((leaf = (
TLeaf*) iLeaves())) {
732 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
" %s.%s", branch->
GetName(), leaf->GetName());
738 Warning(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Not able to check type correctness, ignoring check");
745 return "TClonesArray";
748 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"The branch %s is a TBranchRef and cannot be represented as a C++ type.", branch->
GetName());
751 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"The branch %s is of type %s - something that is not handled yet.", branch->
GetName(), branch->IsA()->
GetName());
Describe Streamer information for one class version.
virtual const char * GetName() const
Returns name of object.
virtual const char * GetClassName() const
Return the name of the user class whose content is stored in this branch, if any. ...
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
static TDataType * GetDataType(EDataType type)
Given a EDataType type, get the TDataType* that represents it.
TVirtualCollectionProxy * GetCollectionProxy()
Return the collection proxy describing the branch content, if any.
TString GetTypeName()
Get basic type of typedef, e,g.
Int_t GetSplitLevel() const
virtual Int_t GetExpectedType(TClass *&clptr, EDataType &type)
Fill expectedClass and expectedType with information on the data type of the object/values contained ...
TTreeReader is a simple, robust and fast interface to read values from a TTree, TChain or TNtuple...
Namespace for new ROOT classes and functions.
void Fatal(const char *location, const char *msgfmt,...)
virtual TClass * GetValueClass() const =0
TStreamerElement * GetElement(Int_t id) const
virtual const char * GetTypeName() const
virtual TLeaf * GetLeafCounter(Int_t &countval) const
Return a pointer to the counter of this leaf.
Regular expression class.
static TDictionary * GetDictionary(const char *name)
TStreamerInfo * GetInfo() const
Get streamer info for the branch class.
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
virtual void * GetStart(UInt_t=0)
Int_t GetArrayLength() const
EReadStatus ProxyRead()
Try to read the value from the TBranchProxy, returns the status of the read.
Type GetType(const std::string &Name)
TObject * At(Int_t idx) const
virtual EDataType GetType() const =0
void SetContentDict(TDictionary *dict)
TBranchElement * GetBranchCount() const
const Detail::TBranchProxy * GetProxy() const
const char * GetBranchContentDataType(TBranch *branch, TString &contentTypeName, TDictionary *&dict) const
Access a branch's collection content (not the collection itself) through a proxy. ...
virtual TLeaf * GetLeaf(const char *name) const
Return pointer to the 1st Leaf named name in thisBranch.
int IsSTLCont(int testAlloc=0) const
type : type name: vector<list<classA,allocator>,allocator> testAlloc: if true, we test allocator...
TLeaf * GetLeaf()
If we are reading a leaf, return the corresponding TLeaf.
virtual Int_t GetLenType() const
TDictionary * GetContentDict() const
Extracts data from a TTree.
virtual const char * GetClonesName() const
TTreeReaderValueBase::EReadStatus fReadStatus
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
virtual Int_t GetLen() const
Return the number of effective elements of this leaf.
virtual const char * GetTypeName() const
Return type name of element in the branch.
Basic data type descriptor (datatype information is obtained from CINT).
This class defines an abstract interface that must be implemented by all classes that contain diction...
virtual Bool_t HasPointers() const =0
virtual TLeaf * GetLeafCount() const
TClass * GetCurrentClass()
Return a pointer to the current type of the data member corresponding to branch element.
void * GetAddress()
Returns the memory address of the object being read.
The ROOT global object gROOT contains a list of all defined classes.
void Warning(const char *location, const char *msgfmt,...)
A Branch for the case of an object.
TObject * UncheckedAt(Int_t i) const
TVirtualCollectionProxy * GetCollection()
virtual const char * GetClassName() const
Return the name of the user class whose content is stored in this branch, if any. ...
virtual void * At(UInt_t idx)=0
TObjArray * GetListOfLeaves()
TClass * GetClass() const
Int_t GetClassSize() const
TObjArray * GetElements() const
virtual UInt_t Size() const =0
typedef void((*Func_t)())
An array of clone (identical) objects.
const char * GetTypeName() const
virtual ~TVirtualCollectionReader()
Proxy around an arbitrary container, which implements basic functionality and iteration.
virtual TClass * GetClass() const
Int_t GetEntries() const
Return the number of objects in array (i.e.
virtual void * At(Detail::TBranchProxy *, size_t)=0
Base class for all the proxy object.
Bool_t IsaPointer() const
TBranch * GetBranch() const
A TTree is a list of TBranches.
TBranch * GetMother() const
Get our top-level parent branch in the tree.
void Error(ErrorHandler_t func, int code, const char *va_(fmt),...)
Write error message and call a handler, if required.
TClass * GetClass() const
const char * Data() const
virtual size_t GetSize(Detail::TBranchProxy *)=0