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;
110 if (
auto cl =
cp.GetValueClass())
124 if (!
proxy->Read()) {
126 if (!
proxy->GetSuppressErrorsForMissingBranch())
127 Error(
"TSTLReader::GetCP()",
"Read error in TBranchProxy.");
130 if (!
proxy->GetWhere()) {
131 Error(
"TSTLReader::GetCP()",
"Logic error, proxy object not set in TBranchProxy.");
180 if (!
proxy->Read()) {
182 if (!
proxy->GetSuppressErrorsForMissingBranch())
183 Error(
"TCollectionLessSTLReader::GetCP()",
"Read error in TBranchProxy.");
186 if (!
proxy->GetWhere()) {
187 Error(
"TCollectionLessSTLReader::GetCP()",
"Logic error, proxy object not set in TBranchProxy.");
191 return fLocalCollection;
240 Int_t fBasicTypeSize;
243 TObjectArrayReader() : fBasicTypeSize(-1) {}
247 if (!
proxy->Read()) {
249 if (!
proxy->GetSuppressErrorsForMissingBranch())
250 Error(
"TObjectArrayReader::GetCP()",
"Read error in TBranchProxy.");
269 void *array = (
void *)
proxy->GetStart();
271 if (fBasicTypeSize == -1) {
274 Error(
"TObjectArrayReader::At()",
"Cannot get class info from branch proxy.");
294 return proxy->GetValueSize();
299class TDynamicArrayReader :
public BASE {
302 class TVirtualSizeReaderImpl {
305 virtual size_t GetSize() = 0;
308 template <
typename T>
309 class TSizeReaderImpl
final :
public TVirtualSizeReaderImpl {
314 size_t GetSize()
final {
return *fSizeReader; }
317 std::unique_ptr<TVirtualSizeReaderImpl> fSizeReader;
320 template <
class...
ARGS>
352 }
while (!
sizeLeaf && !parent.empty());
356 Error(
"TDynamicArrayReader ",
"Cannot find leaf count for %s or any parent branch!",
leafName);
365 template <
class...
ARGS>
382 }
else if (
leafType ==
"UShort_t") {
388 }
else if (
leafType ==
"Long64_t") {
390 }
else if (
leafType ==
"ULong64_t") {
393 Error(
"TDynamicArrayReader ",
394 "Unsupported size type for leaf %s. Supported types are int, short int, long int, long long int and "
395 "their unsigned counterparts.",
404class TArrayParameterSizeReader :
public TDynamicArrayReader<TObjectArrayReader> {
407 : TDynamicArrayReader<TObjectArrayReader>(
treeReader, branchName)
421class TArrayFixedSizeReader :
public TObjectArrayReader {
437 if (!
proxy->Read()) {
439 if (!
proxy->GetSuppressErrorsForMissingBranch())
440 Error(
"TBasicTypeArrayReader::GetCP()",
"Read error in TBranchProxy.");
467 if (!
proxy->Read()) {
469 if (!
proxy->GetSuppressErrorsForMissingBranch())
470 Error(
"TBasicTypeArrayReader::GetValueSize()",
"Read error in TBranchProxy.");
474 return proxy->GetValueSize();
478class TBasicTypeClonesReader
final :
public TClonesReader {
486 TBasicTypeClonesReader(
const TBasicTypeClonesReader &) =
delete;
488 TBasicTypeClonesReader(TBasicTypeClonesReader &&) =
delete;
489 TBasicTypeClonesReader &
operator=(TBasicTypeClonesReader &&) =
delete;
518 if (fElementSize == -1) {
522 fElementSize =
myLeaf->GetLenType();
524 return (
Byte_t *)address + (fElementSize * idx);
532 return leaf ?
leaf->GetLenType() : 0;
536 void ProxyRead() { fValueReader->
ProxyRead(); }
539class TLeafParameterSizeReader :
public TDynamicArrayReader<TLeafReader> {
549 return TDynamicArrayReader<TLeafReader>::GetSize(
proxy);
564 fSetupStatus = kSetupInternalError;
566 Error(
"TTreeReaderArrayBase::CreateProxy()",
"TTreeReader object not set / available for branch %s!",
568 fSetupStatus = kSetupTreeDestructed;
572 TBranch *
br = fTreeReader->GetTree()->GetBranch(fBranchName);
578 Error(
"TTreeReaderArrayBase::CreateProxy()",
579 "The template argument type T of %s accessing branch %s (which contains data of type %s) is not known to "
580 "ROOT. You will need to create a dictionary for it.",
581 GetDerivedTypeName(), fBranchName.Data(),
brDataType);
582 fSetupStatus = kSetupMissingDictionary;
594 fTreeReader->fSuppressErrorsForMissingBranches.cend());
603 Error(
"TTreeReaderArrayBase::CreateProxy()",
"No dictionary for branch %s.", fBranchName.Data());
610 fSetupStatus = kSetupMatch;
621 fSetupStatus = kSetupMatch;
623 Error(
"TTreeReaderArrayBase::CreateProxy()",
"Type ambiguity (want %s, have %s) for branch %s.",
624 fDict->GetName(),
namedProxy->GetContentDict()->GetName(), fBranchName.Data());
636 auto *
director = fTreeReader->fDirector.get();
638 if (
branch->GetTree() != fTreeReader->GetTree()->GetTree()) {
640 std::optional<std::size_t>
index;
641 std::size_t current{};
642 auto &&
friends = fTreeReader->GetTree()->GetTree()->GetListOfFriends();
644 if (
branch->GetTree() ==
fe->GetTree()) {
650 if (!
index.has_value()) {
651 Error(
"TTreeReaderArrayBase::CreateProxy()",
652 "The branch %s is contained in a Friend TTree that is not directly attached to the main.\n"
653 "This is not yet supported by TTreeReader.",
661 fTreeReader->AddProxy(
664 namedProxy = fTreeReader->FindProxy(fBranchName);
667 fSetupStatus = kSetupMatch;
669 fSetupStatus = kSetupMismatch;
677 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
678 "The branch %s contains data of type %s, which should be accessed through a TTreeReaderValue< %s >.",
680 if (fSetupStatus == kSetupInternalError)
681 fSetupStatus = kSetupNotACollection;
687 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
688 "Cannot determine the type contained in the collection of branch %s. That's weird - please report!",
691 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
692 "The branch %s contains data of type %s, which does not have a dictionary.", fBranchName.Data(),
694 if (fSetupStatus == kSetupInternalError)
695 fSetupStatus = kSetupMissingDictionary;
735 for (
int i = 0; i <
info.fArrayNDims; i++) {
792 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
793 "The branch %s contains data of type %s. It cannot be accessed by a TTreeReaderArray<%s>",
795 if (fSetupStatus == kSetupInternalError || fSetupStatus >= 0)
796 fSetupStatus = kSetupMismatch;
819 branch = fTreeReader->GetTree()->GetBranch(fBranchName);
823 if (!fBranchName.Contains(
".")) {
825 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
826 "The tree does not have a branch called %s. You could check with TTree::Print() for available branches.",
829 fSetupStatus = kSetupMissingBranch;
836 TString branchName = fBranchName(0, fBranchName.Length() -
leafName.Length());
837 branch = fTreeReader->GetTree()->GetBranch(branchName);
840 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
841 "The tree does not have a branch called %s. You could check with TTree::Print() for available branches.",
844 fSetupStatus = kSetupMissingBranch;
852 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
853 "The tree does not have a branch, nor a sub-branch called %s. You could check with TTree::Print() for "
854 "available branches.",
857 fSetupStatus = kSetupMissingBranch;
864 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
"Failed to get the dictionary for %s.",
myLeaf->GetTypeName());
865 fSetupStatus = kSetupMissingDictionary;
875 fBranchName = branchName;
877 fHaveLeaf = (fLeafName.Length() > 0);
878 fSetupStatus = kSetupMatchLeaf;
880 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
"Leaf of type %s cannot be read by TTreeReaderValue<%s>.",
881 myLeaf->GetTypeName(), fDict->GetName());
883 fSetupStatus = kSetupMismatch;
905 if (!
myLeaf->GetLeafCount()) {
906 fImpl = std::make_unique<TLeafReader>(
this);
911 fImpl = std::make_unique<TLeafParameterSizeReader>(fTreeReader,
leafFullName.Data(),
this);
913 fSetupStatus = kSetupMatchLeaf;
926 if (fSetupStatus == kSetupInternalError)
927 fSetupStatus = kSetupMatch;
930 Error(
"TTreeReaderArrayBase::SetImpl",
"STL Collection nested in a TClonesArray not yet supported");
931 fSetupStatus = kSetupInternalError;
934 fImpl = std::make_unique<TSTLReader>();
939 fImpl = std::make_unique<TClonesReader>();
941 fImpl = std::make_unique<TBasicTypeArrayReader>();
944 fImpl = std::make_unique<TBasicTypeClonesReader>(
element->GetOffset());
946 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
949 fImpl = std::make_unique<TArrayParameterSizeReader>(fTreeReader,
branchElement->GetBranchCount());
952 fImpl = std::make_unique<TBasicTypeArrayReader>();
954 fImpl = std::make_unique<TBasicTypeClonesReader>(
element->GetOffset());
956 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
959 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
963 fImpl = std::make_unique<TArrayParameterSizeReader>(fTreeReader,
branchElement->GetBranchCount());
966 fImpl = std::make_unique<TClonesReader>();
968 Error(
"TTreeReaderArrayBase::SetImpl()",
"Cannot read branch %s: unhandled streamer element type %s",
969 fBranchName.Data(),
element->IsA()->GetName());
970 fSetupStatus = kSetupInternalError;
974 fImpl = std::make_unique<TCollectionLessSTLReader>(
branchElement->GetClass()->GetCollectionProxy());
980 Error(
"TTreeReaderArrayBase::SetImpl",
"Failed to get the top leaf from the branch");
981 fSetupStatus = kSetupMissingBranch;
986 if (fSetupStatus == kSetupInternalError)
987 fSetupStatus = kSetupMatch;
989 fImpl = std::make_unique<TArrayFixedSizeReader>(
topLeaf->GetLenStatic());
991 fImpl = std::make_unique<TArrayParameterSizeReader>(fTreeReader,
sizeLeaf->GetName());
995 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchClones not implemented");
996 fSetupStatus = kSetupInternalError;
998 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchObject not implemented");
999 fSetupStatus = kSetupInternalError;
1001 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchSTL not implemented");
1002 fImpl = std::make_unique<TSTLReader>();
1003 fSetupStatus = kSetupInternalError;
1005 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchRef not implemented");
1006 fSetupStatus = kSetupInternalError;
1022 for (
int i = 0; i <
arrInfo.fArrayNDims; ++i)
1051 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Could not get value class.");
1070 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1071 "Cannot determine STL collection type of %s stored in branch %s",
brElement->GetClassName(),
1103 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1104 "The branch %s contains a data type %d for which the dictionary cannot be retrieved.",
1116 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1117 "The branch %s contains data of type %s for which the dictionary does not exist. It's needed.",
1131 return "{CANNOT DETERMINE TBranchElement DATA TYPE}";
1143 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get class from branch element.");
1148 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get collection proxy from STL class");
1157 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get valueClass from collectionProxy.");
1163 if (!fProxy->Setup() || !fProxy->Read()) {
1164 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1165 "Failed to get type from proxy, unable to check type");
1186 Warning(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1187 "Not able to check type correctness, ignoring check");
1189 fSetupStatus = kSetupNoCheck;
1190 }
else if (!dict && (
branch->GetSplitLevel() == 0 ||
brElement->GetClass()->GetCollectionProxy())) {
1192 dict =
brElement->GetClass()->GetCollectionProxy()->GetValueClass();
1230 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1231 "The branch %s was created using a leaf list and cannot be represented as a C++ type. Please access one "
1232 "of its siblings using a TTreeReaderArray:",
1237 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
" %s.%s",
branch->GetName(),
leaf->GetName());
1244 Warning(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1245 "Not able to check type correctness, ignoring check");
1247 fSetupStatus = kSetupNoCheck;
1253 return "TClonesArray";
1256 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1257 "The branch %s is a TBranchRef and cannot be represented as a C++ type.",
branch->GetName());
1260 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1261 "The branch %s is of type %s - something that is not handled yet.",
branch->GetName(),
1262 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.
StreamerElementArrayInfo FillStreamerElementArrayInfo(TStreamerElement *elem)
const char * GetBranchContentDataType(TBranch *branch, TString &contentTypeName, TDictionary *&dict, StreamerElementArrayInfo &arrInfo)
Access a branch's collection content (not the collection itself) through a proxy.
void SetImpl(TBranch *branch, TLeaf *myLeaf)
Create the TVirtualCollectionReader object for our branch.
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