46 TClonesReader() =
default;
48 TClonesReader(
const TClonesReader &) =
delete;
49 TClonesReader &
operator=(
const TClonesReader &) =
delete;
50 TClonesReader(TClonesReader &&) =
delete;
51 TClonesReader &
operator=(TClonesReader &&) =
delete;
57 if (!
proxy->GetSuppressErrorsForMissingBranch())
58 Error(
"TClonesReader::GetCA()",
"Read error in TBranchProxy.");
87 if (!
proxy->GetSuppressErrorsForMissingBranch())
88 Error(
"TClonesReader::GetValueSize()",
"Read error in TBranchProxy.");
92 return proxy->GetValueSize();
101 switch (
cp.GetCollectionType()) {
104 default:
return false;
122 if (!
proxy->Read()) {
124 if (!
proxy->GetSuppressErrorsForMissingBranch())
125 Error(
"TSTLReader::GetCP()",
"Read error in TBranchProxy.");
128 if (!
proxy->GetWhere()) {
129 Error(
"TSTLReader::GetCP()",
"Logic error, proxy object not set in TBranchProxy.");
178 if (!
proxy->Read()) {
180 if (!
proxy->GetSuppressErrorsForMissingBranch())
181 Error(
"TCollectionLessSTLReader::GetCP()",
"Read error in TBranchProxy.");
184 if (!
proxy->GetWhere()) {
185 Error(
"TCollectionLessSTLReader::GetCP()",
"Logic error, proxy object not set in TBranchProxy.");
189 return fLocalCollection;
238 Int_t fBasicTypeSize;
241 TObjectArrayReader() : fBasicTypeSize(-1) {}
245 if (!
proxy->Read()) {
247 if (!
proxy->GetSuppressErrorsForMissingBranch())
248 Error(
"TObjectArrayReader::GetCP()",
"Read error in TBranchProxy.");
267 void *array = (
void *)
proxy->GetStart();
269 if (fBasicTypeSize == -1) {
272 Error(
"TObjectArrayReader::At()",
"Cannot get class info from branch proxy.");
292 return proxy->GetValueSize();
297class TDynamicArrayReader :
public BASE {
300 class TVirtualSizeReaderImpl {
303 virtual size_t GetSize() = 0;
306 template <
typename T>
307 class TSizeReaderImpl
final :
public TVirtualSizeReaderImpl {
312 size_t GetSize()
final {
return *fSizeReader; }
315 std::unique_ptr<TVirtualSizeReaderImpl> fSizeReader;
318 template <
class...
ARGS>
350 }
while (!
sizeLeaf && !parent.empty());
354 Error(
"TDynamicArrayReader ",
"Cannot find leaf count for %s or any parent branch!",
leafName);
365 }
else if (
leafType ==
"UShort_t") {
371 }
else if (
leafType ==
"Long64_t") {
373 }
else if (
leafType ==
"ULong64_t") {
376 Error(
"TDynamicArrayReader ",
377 "Unsupported size type for leaf %s. Supported types are int, short int, long int, long long int and "
378 "their unsigned counterparts.",
386class TArrayParameterSizeReader :
public TDynamicArrayReader<TObjectArrayReader> {
395class TArrayFixedSizeReader :
public TObjectArrayReader {
411 if (!
proxy->Read()) {
413 if (!
proxy->GetSuppressErrorsForMissingBranch())
414 Error(
"TBasicTypeArrayReader::GetCP()",
"Read error in TBranchProxy.");
441 if (!
proxy->Read()) {
443 if (!
proxy->GetSuppressErrorsForMissingBranch())
444 Error(
"TBasicTypeArrayReader::GetValueSize()",
"Read error in TBranchProxy.");
448 return proxy->GetValueSize();
452class TBasicTypeClonesReader
final :
public TClonesReader {
460 TBasicTypeClonesReader(
const TBasicTypeClonesReader &) =
delete;
462 TBasicTypeClonesReader(TBasicTypeClonesReader &&) =
delete;
463 TBasicTypeClonesReader &
operator=(TBasicTypeClonesReader &&) =
delete;
492 if (fElementSize == -1) {
496 fElementSize =
myLeaf->GetLenType();
498 return (
Byte_t *)address + (fElementSize * idx);
506 return leaf ?
leaf->GetLenType() : 0;
510 void ProxyRead() { fValueReader->
ProxyRead(); }
513class TLeafParameterSizeReader :
public TDynamicArrayReader<TLeafReader> {
523 return TDynamicArrayReader<TLeafReader>::GetSize(
proxy);
538 fSetupStatus = kSetupInternalError;
540 Error(
"TTreeReaderArrayBase::CreateProxy()",
"TTreeReader object not set / available for branch %s!",
542 fSetupStatus = kSetupTreeDestructed;
546 TBranch *
br = fTreeReader->GetTree()->GetBranch(fBranchName);
552 Error(
"TTreeReaderArrayBase::CreateProxy()",
553 "The template argument type T of %s accessing branch %s (which contains data of type %s) is not known to "
554 "ROOT. You will need to create a dictionary for it.",
555 GetDerivedTypeName(), fBranchName.Data(),
brDataType);
556 fSetupStatus = kSetupMissingDictionary;
568 fTreeReader->fSuppressErrorsForMissingBranches.cend());
577 Error(
"TTreeReaderArrayBase::CreateProxy()",
"No dictionary for branch %s.", fBranchName.Data());
584 fSetupStatus = kSetupMatch;
595 fSetupStatus = kSetupMatch;
597 Error(
"TTreeReaderArrayBase::CreateProxy()",
"Type ambiguity (want %s, have %s) for branch %s.",
598 fDict->GetName(),
namedProxy->GetContentDict()->GetName(), fBranchName.Data());
610 auto *
director = fTreeReader->fDirector.get();
612 if (
branch->GetTree() != fTreeReader->GetTree()->GetTree()) {
614 std::optional<std::size_t>
index;
615 std::size_t current{};
616 auto &&
friends = fTreeReader->GetTree()->GetTree()->GetListOfFriends();
618 if (
branch->GetTree() ==
fe->GetTree()) {
624 if (!
index.has_value()) {
625 Error(
"TTreeReaderArrayBase::CreateProxy()",
626 "The branch %s is contained in a Friend TTree that is not directly attached to the main.\n"
627 "This is not yet supported by TTreeReader.",
635 fTreeReader->AddProxy(
638 namedProxy = fTreeReader->FindProxy(fBranchName);
641 fSetupStatus = kSetupMatch;
643 fSetupStatus = kSetupMismatch;
650 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
651 "The branch %s contains data of type %s, which should be accessed through a TTreeReaderValue< %s >.",
653 if (fSetupStatus == kSetupInternalError)
654 fSetupStatus = kSetupNotACollection;
660 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
661 "Cannot determine the type contained in the collection of branch %s. That's weird - please report!",
664 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
665 "The branch %s contains data of type %s, which does not have a dictionary.", fBranchName.Data(),
667 if (fSetupStatus == kSetupInternalError)
668 fSetupStatus = kSetupMissingDictionary;
702 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
703 "The branch %s contains data of type %s. It cannot be accessed by a TTreeReaderArray<%s>",
705 if (fSetupStatus == kSetupInternalError || fSetupStatus >= 0)
706 fSetupStatus = kSetupMismatch;
729 branch = fTreeReader->GetTree()->GetBranch(fBranchName);
733 if (!fBranchName.Contains(
".")) {
735 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
736 "The tree does not have a branch called %s. You could check with TTree::Print() for available branches.",
739 fSetupStatus = kSetupMissingBranch;
750 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
751 "The tree does not have a branch called %s. You could check with TTree::Print() for available branches.",
754 fSetupStatus = kSetupMissingBranch;
762 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
763 "The tree does not have a branch, nor a sub-branch called %s. You could check with TTree::Print() for "
764 "available branches.",
767 fSetupStatus = kSetupMissingBranch;
774 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
"Failed to get the dictionary for %s.",
myLeaf->GetTypeName());
775 fSetupStatus = kSetupMissingDictionary;
787 fHaveLeaf = (fLeafName.Length() > 0);
788 fSetupStatus = kSetupMatchLeaf;
790 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
"Leaf of type %s cannot be read by TTreeReaderValue<%s>.",
791 myLeaf->GetTypeName(), fDict->GetName());
793 fSetupStatus = kSetupMismatch;
815 if (!
myLeaf->GetLeafCount()) {
816 fImpl = std::make_unique<TLeafReader>(
this);
821 fImpl = std::make_unique<TLeafParameterSizeReader>(fTreeReader,
leafFullName.Data(),
this);
823 fSetupStatus = kSetupMatchLeaf;
836 if (fSetupStatus == kSetupInternalError)
837 fSetupStatus = kSetupMatch;
840 Error(
"TTreeReaderArrayBase::SetImpl",
"STL Collection nested in a TClonesArray not yet supported");
841 fSetupStatus = kSetupInternalError;
844 fImpl = std::make_unique<TSTLReader>();
849 fImpl = std::make_unique<TClonesReader>();
851 fImpl = std::make_unique<TBasicTypeArrayReader>();
854 fImpl = std::make_unique<TBasicTypeClonesReader>(
element->GetOffset());
856 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
860 std::make_unique<TArrayParameterSizeReader>(fTreeReader,
branchElement->GetBranchCount()->GetName());
863 fImpl = std::make_unique<TBasicTypeArrayReader>();
865 fImpl = std::make_unique<TBasicTypeClonesReader>(
element->GetOffset());
867 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
870 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
875 std::make_unique<TArrayParameterSizeReader>(fTreeReader,
branchElement->GetBranchCount()->GetName());
878 fImpl = std::make_unique<TClonesReader>();
880 Error(
"TTreeReaderArrayBase::SetImpl()",
"Cannot read branch %s: unhandled streamer element type %s",
881 fBranchName.Data(),
element->IsA()->GetName());
882 fSetupStatus = kSetupInternalError;
886 fImpl = std::make_unique<TCollectionLessSTLReader>(
branchElement->GetClass()->GetCollectionProxy());
892 Error(
"TTreeReaderArrayBase::SetImpl",
"Failed to get the top leaf from the branch");
893 fSetupStatus = kSetupMissingBranch;
898 if (fSetupStatus == kSetupInternalError)
899 fSetupStatus = kSetupMatch;
901 fImpl = std::make_unique<TArrayFixedSizeReader>(
topLeaf->GetLenStatic());
903 fImpl = std::make_unique<TArrayParameterSizeReader>(fTreeReader,
sizeLeaf->GetName());
907 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchClones not implemented");
908 fSetupStatus = kSetupInternalError;
910 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchObject not implemented");
911 fSetupStatus = kSetupInternalError;
913 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchSTL not implemented");
914 fImpl = std::make_unique<TSTLReader>();
915 fSetupStatus = kSetupInternalError;
917 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchRef not implemented");
918 fSetupStatus = kSetupInternalError;
944 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Could not get value class.");
963 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
964 "Cannot determine STL collection type of %s stored in branch %s",
brElement->GetClassName(),
996 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
997 "The branch %s contains a data type %d for which the dictionary cannot be retrieved.",
1007 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1008 "The branch %s contains data of type %s for which the dictionary does not exist. It's needed.",
1022 return "{CANNOT DETERMINE TBranchElement DATA TYPE}";
1033 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get class from branch element.");
1038 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get collection proxy from STL class");
1047 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get valueClass from collectionProxy.");
1053 if (!fProxy->Setup() || !fProxy->Read()) {
1054 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1055 "Failed to get type from proxy, unable to check type");
1076 Warning(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1077 "Not able to check type correctness, ignoring check");
1079 fSetupStatus = kSetupNoCheck;
1080 }
else if (!dict && (
branch->GetSplitLevel() == 0 ||
brElement->GetClass()->GetCollectionProxy())) {
1082 dict =
brElement->GetClass()->GetCollectionProxy()->GetValueClass();
1120 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1121 "The branch %s was created using a leaf list and cannot be represented as a C++ type. Please access one "
1122 "of its siblings using a TTreeReaderArray:",
1127 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
" %s.%s",
branch->GetName(),
leaf->GetName());
1134 Warning(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1135 "Not able to check type correctness, ignoring check");
1137 fSetupStatus = kSetupNoCheck;
1143 return "TClonesArray";
1146 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1147 "The branch %s is a TBranchRef and cannot be represented as a C++ type.",
branch->GetName());
1150 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1151 "The branch %s is of type %s - something that is not handled yet.",
branch->GetName(),
1152 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
Binding & operator=(OUT(*fun)(void))
Base class for all the proxy object.
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.
Describe one element (data member) to be Streamed.
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