51 if (!
proxy->GetSuppressErrorsForMissingBranch())
52 Error(
"TClonesReader::GetCA()",
"Read error in TBranchProxy.");
80 return ca ?
ca->GetClass()->Size() : 0;
89 switch (
cp.GetCollectionType()) {
92 default:
return false;
110 if (!
proxy->Read()) {
112 if (!
proxy->GetSuppressErrorsForMissingBranch())
113 Error(
"TSTLReader::GetCP()",
"Read error in TBranchProxy.");
116 if (!
proxy->GetWhere()) {
117 Error(
"TSTLReader::GetCP()",
"Logic error, proxy object not set in TBranchProxy.");
166 if (!
proxy->Read()) {
168 if (!
proxy->GetSuppressErrorsForMissingBranch())
169 Error(
"TCollectionLessSTLReader::GetCP()",
"Read error in TBranchProxy.");
172 if (!
proxy->GetWhere()) {
173 Error(
"TCollectionLessSTLReader::GetCP()",
"Logic error, proxy object not set in TBranchProxy.");
177 return fLocalCollection;
226 Int_t fBasicTypeSize;
229 TObjectArrayReader() : fBasicTypeSize(-1) {}
233 if (!
proxy->Read()) {
235 if (!
proxy->GetSuppressErrorsForMissingBranch())
236 Error(
"TObjectArrayReader::GetCP()",
"Read error in TBranchProxy.");
255 void *array = (
void *)
proxy->GetStart();
257 if (fBasicTypeSize == -1) {
260 Error(
"TObjectArrayReader::At()",
"Cannot get class info from branch proxy.");
280 return proxy->GetValueSize();
285class TDynamicArrayReader :
public BASE {
288 class TVirtualSizeReaderImpl {
291 virtual size_t GetSize() = 0;
294 template <
typename T>
295 class TSizeReaderImpl
final :
public TVirtualSizeReaderImpl {
300 size_t GetSize()
final {
return *fSizeReader; }
303 std::unique_ptr<TVirtualSizeReaderImpl> fSizeReader;
306 template <
class...
ARGS>
338 }
while (!
sizeLeaf && !parent.empty());
342 Error(
"TDynamicArrayReader ",
"Cannot find leaf count for %s or any parent branch!",
leafName);
353 }
else if (
leafType ==
"UShort_t") {
359 }
else if (
leafType ==
"Long64_t") {
361 }
else if (
leafType ==
"ULong64_t") {
364 Error(
"TDynamicArrayReader ",
365 "Unsupported size type for leaf %s. Supported types are int, short int, long int, long long int and "
366 "their unsigned counterparts.",
374class TArrayParameterSizeReader :
public TDynamicArrayReader<TObjectArrayReader> {
383class TArrayFixedSizeReader :
public TObjectArrayReader {
399 if (!
proxy->Read()) {
401 if (!
proxy->GetSuppressErrorsForMissingBranch())
402 Error(
"TBasicTypeArrayReader::GetCP()",
"Read error in TBranchProxy.");
429 if (!
proxy->Read()) {
431 if (!
proxy->GetSuppressErrorsForMissingBranch())
432 Error(
"TBasicTypeArrayReader::GetValueSize()",
"Read error in TBranchProxy.");
436 return proxy->GetValueSize();
440class TBasicTypeClonesReader
final :
public TClonesReader {
474 if (fElementSize == -1) {
478 fElementSize =
myLeaf->GetLenType();
480 return (
Byte_t *)address + (fElementSize * idx);
488 return leaf ?
leaf->GetLenType() : 0;
492 void ProxyRead() { fValueReader->
ProxyRead(); }
495class TLeafParameterSizeReader :
public TDynamicArrayReader<TLeafReader> {
505 return TDynamicArrayReader<TLeafReader>::GetSize(
proxy);
521 fSetupStatus = kSetupInternalError;
523 Error(
"TTreeReaderArrayBase::CreateProxy()",
"TTreeReader object not set / available for branch %s!",
525 fSetupStatus = kSetupTreeDestructed;
529 TBranch *
br = fTreeReader->GetTree()->GetBranch(fBranchName);
535 Error(
"TTreeReaderArrayBase::CreateProxy()",
536 "The template argument type T of %s accessing branch %s (which contains data of type %s) is not known to "
537 "ROOT. You will need to create a dictionary for it.",
538 GetDerivedTypeName(), fBranchName.Data(),
brDataType);
539 fSetupStatus = kSetupMissingDictionary;
551 fTreeReader->fSuppressErrorsForMissingBranches.cend());
560 Error(
"TTreeReaderArrayBase::CreateProxy()",
"No dictionary for branch %s.", fBranchName.Data());
567 fSetupStatus = kSetupMatch;
578 fSetupStatus = kSetupMatch;
580 Error(
"TTreeReaderArrayBase::CreateProxy()",
"Type ambiguity (want %s, have %s) for branch %s.",
581 fDict->GetName(),
namedProxy->GetContentDict()->GetName(), fBranchName.Data());
593 auto *
director = fTreeReader->fDirector.get();
595 if (
branch->GetTree() != fTreeReader->GetTree()->GetTree()) {
597 std::optional<std::size_t>
index;
598 std::size_t current{};
599 auto &&
friends = fTreeReader->GetTree()->GetTree()->GetListOfFriends();
601 if (
branch->GetTree() ==
fe->GetTree()) {
607 if (!
index.has_value()) {
608 Error(
"TTreeReaderArrayBase::CreateProxy()",
609 "The branch %s is contained in a Friend TTree that is not directly attached to the main.\n"
610 "This is not yet supported by TTreeReader.",
618 fTreeReader->AddProxy(
621 namedProxy = fTreeReader->FindProxy(fBranchName);
624 fSetupStatus = kSetupMatch;
626 fSetupStatus = kSetupMismatch;
633 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
634 "The branch %s contains data of type %s, which should be accessed through a TTreeReaderValue< %s >.",
636 if (fSetupStatus == kSetupInternalError)
637 fSetupStatus = kSetupNotACollection;
643 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
644 "Cannot determine the type contained in the collection of branch %s. That's weird - please report!",
647 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
648 "The branch %s contains data of type %s, which does not have a dictionary.", fBranchName.Data(),
650 if (fSetupStatus == kSetupInternalError)
651 fSetupStatus = kSetupMissingDictionary;
685 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
686 "The branch %s contains data of type %s. It cannot be accessed by a TTreeReaderArray<%s>",
688 if (fSetupStatus == kSetupInternalError || fSetupStatus >= 0)
689 fSetupStatus = kSetupMismatch;
712 branch = fTreeReader->GetTree()->GetBranch(fBranchName);
716 if (!fBranchName.Contains(
".")) {
718 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
719 "The tree does not have a branch called %s. You could check with TTree::Print() for available branches.",
722 fSetupStatus = kSetupMissingBranch;
733 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
734 "The tree does not have a branch called %s. You could check with TTree::Print() for available branches.",
737 fSetupStatus = kSetupMissingBranch;
745 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
746 "The tree does not have a branch, nor a sub-branch called %s. You could check with TTree::Print() for "
747 "available branches.",
750 fSetupStatus = kSetupMissingBranch;
757 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
"Failed to get the dictionary for %s.",
myLeaf->GetTypeName());
758 fSetupStatus = kSetupMissingDictionary;
770 fHaveLeaf = (fLeafName.Length() > 0);
771 fSetupStatus = kSetupMatchLeaf;
773 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
"Leaf of type %s cannot be read by TTreeReaderValue<%s>.",
774 myLeaf->GetTypeName(), fDict->GetName());
776 fSetupStatus = kSetupMismatch;
798 if (!
myLeaf->GetLeafCount()) {
799 fImpl = std::make_unique<TLeafReader>(
this);
804 fImpl = std::make_unique<TLeafParameterSizeReader>(fTreeReader,
leafFullName.Data(),
this);
806 fSetupStatus = kSetupMatchLeaf;
819 if (fSetupStatus == kSetupInternalError)
820 fSetupStatus = kSetupMatch;
823 Error(
"TTreeReaderArrayBase::SetImpl",
"STL Collection nested in a TClonesArray not yet supported");
824 fSetupStatus = kSetupInternalError;
827 fImpl = std::make_unique<TSTLReader>();
832 fImpl = std::make_unique<TClonesReader>();
834 fImpl = std::make_unique<TBasicTypeArrayReader>();
837 fImpl = std::make_unique<TBasicTypeClonesReader>(
element->GetOffset());
839 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
843 std::make_unique<TArrayParameterSizeReader>(fTreeReader,
branchElement->GetBranchCount()->GetName());
846 fImpl = std::make_unique<TBasicTypeArrayReader>();
848 fImpl = std::make_unique<TBasicTypeClonesReader>(
element->GetOffset());
850 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
853 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
858 std::make_unique<TArrayParameterSizeReader>(fTreeReader,
branchElement->GetBranchCount()->GetName());
861 fImpl = std::make_unique<TClonesReader>();
863 Error(
"TTreeReaderArrayBase::SetImpl()",
"Cannot read branch %s: unhandled streamer element type %s",
864 fBranchName.Data(),
element->IsA()->GetName());
865 fSetupStatus = kSetupInternalError;
869 fImpl = std::make_unique<TCollectionLessSTLReader>(
branchElement->GetClass()->GetCollectionProxy());
875 Error(
"TTreeReaderArrayBase::SetImpl",
"Failed to get the top leaf from the branch");
876 fSetupStatus = kSetupMissingBranch;
881 if (fSetupStatus == kSetupInternalError)
882 fSetupStatus = kSetupMatch;
884 fImpl = std::make_unique<TArrayFixedSizeReader>(
topLeaf->GetLenStatic());
886 fImpl = std::make_unique<TArrayParameterSizeReader>(fTreeReader,
sizeLeaf->GetName());
890 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchClones not implemented");
891 fSetupStatus = kSetupInternalError;
893 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchObject not implemented");
894 fSetupStatus = kSetupInternalError;
896 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchSTL not implemented");
897 fImpl = std::make_unique<TSTLReader>();
898 fSetupStatus = kSetupInternalError;
900 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchRef not implemented");
901 fSetupStatus = kSetupInternalError;
927 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Could not get value class.");
946 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
947 "Cannot determine STL collection type of %s stored in branch %s",
brElement->GetClassName(),
979 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
980 "The branch %s contains a data type %d for which the dictionary cannot be retrieved.",
990 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
991 "The branch %s contains data of type %s for which the dictionary does not exist. It's needed.",
1005 return "{CANNOT DETERMINE TBranchElement DATA TYPE}";
1016 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get class from branch element.");
1021 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get collection proxy from STL class");
1030 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get valueClass from collectionProxy.");
1036 if (!fProxy->Setup() || !fProxy->Read()) {
1037 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1038 "Failed to get type from proxy, unable to check type");
1059 Warning(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1060 "Not able to check type correctness, ignoring check");
1062 fSetupStatus = kSetupNoCheck;
1063 }
else if (!dict && (
branch->GetSplitLevel() == 0 ||
brElement->GetClass()->GetCollectionProxy())) {
1065 dict =
brElement->GetClass()->GetCollectionProxy()->GetValueClass();
1103 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1104 "The branch %s was created using a leaf list and cannot be represented as a C++ type. Please access one "
1105 "of its siblings using a TTreeReaderArray:",
1110 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
" %s.%s",
branch->GetName(),
leaf->GetName());
1117 Warning(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1118 "Not able to check type correctness, ignoring check");
1120 fSetupStatus = kSetupNoCheck;
1126 return "TClonesArray";
1129 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1130 "The branch %s is a TBranchRef and cannot be represented as a C++ type.",
branch->GetName());
1133 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1134 "The branch %s is of type %s - something that is not handled yet.",
branch->GetName(),
1135 branch->IsA()->GetName());
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
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 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
Base class for all the proxy object.
Base class of TTreeReaderArray.
void CreateProxy() override
Create the proxy object for our branch.
bool GetBranchAndLeaf(TBranch *&branch, TLeaf *&myLeaf, TDictionary *&branchActualType, bool suppressErrorsForMissingBranch=false)
Determine the branch / leaf and its type; reset fProxy / fSetupStatus on error.
void SetImpl(TBranch *branch, TLeaf *myLeaf)
Create the TVirtualCollectionReader object for our branch.
const char * GetBranchContentDataType(TBranch *branch, TString &contentTypeName, TDictionary *&dict)
Access a branch's collection content (not the collection itself) through a proxy.
Base class of TTreeReaderValue.
void * GetAddress()
Returns the memory address of the object being read.
@ kReadError
Problem reading data.
@ kReadSuccess
Data read okay.
TLeaf * GetLeaf()
If we are reading a leaf, return the corresponding TLeaf.
virtual ~TVirtualCollectionReader()
A Branch for the case of an object.
A TTree is a list of TBranches.
TClass instances represent classes, structs and namespaces in the ROOT type system.
An array of clone (identical) objects.
Basic data type descriptor (datatype information is obtained from CINT).
TString GetTypeName()
Get basic type of typedef, e,g.: "class TDirectory*" -> "TDirectory".
static TDataType * GetDataType(EDataType type)
Given a EDataType type, get the TDataType* that represents it.
This class defines an abstract interface that must be implemented by all classes that contain diction...
static TDictionary * GetDictionary(const char *name)
Retrieve the type (class, fundamental type, typedef etc) named "name".
The TEnum class implements the enum type.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
const char * GetName() const override
Returns name of object.
Regular expression class.
Describes a persistent version of a class.
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
Defines a common interface to inspect/change the contents of an object that represents a collection.
void forward(const LAYERDATA &prevLayerData, LAYERDATA &currLayerData)
apply the weights (and functions) in forward direction of the DNN