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);
539 fSetupStatus = kSetupInternalError;
541 Error(
"TTreeReaderArrayBase::CreateProxy()",
"TTreeReader object not set / available for branch %s!",
543 fSetupStatus = kSetupTreeDestructed;
547 TBranch *
br = fTreeReader->GetTree()->GetBranch(fBranchName);
553 Error(
"TTreeReaderArrayBase::CreateProxy()",
554 "The template argument type T of %s accessing branch %s (which contains data of type %s) is not known to "
555 "ROOT. You will need to create a dictionary for it.",
556 GetDerivedTypeName(), fBranchName.Data(),
brDataType);
557 fSetupStatus = kSetupMissingDictionary;
569 fTreeReader->fSuppressErrorsForMissingBranches.cend());
578 Error(
"TTreeReaderArrayBase::CreateProxy()",
"No dictionary for branch %s.", fBranchName.Data());
585 fSetupStatus = kSetupMatch;
596 fSetupStatus = kSetupMatch;
598 Error(
"TTreeReaderArrayBase::CreateProxy()",
"Type ambiguity (want %s, have %s) for branch %s.",
599 fDict->GetName(),
namedProxy->GetContentDict()->GetName(), fBranchName.Data());
611 auto *
director = fTreeReader->fDirector.get();
613 if (
branch->GetTree() != fTreeReader->GetTree()->GetTree()) {
615 std::optional<std::size_t>
index;
616 std::size_t current{};
617 auto &&
friends = fTreeReader->GetTree()->GetTree()->GetListOfFriends();
619 if (
branch->GetTree() ==
fe->GetTree()) {
625 if (!
index.has_value()) {
626 Error(
"TTreeReaderArrayBase::CreateProxy()",
627 "The branch %s is contained in a Friend TTree that is not directly attached to the main.\n"
628 "This is not yet supported by TTreeReader.",
636 fTreeReader->AddProxy(
639 namedProxy = fTreeReader->FindProxy(fBranchName);
642 fSetupStatus = kSetupMatch;
644 fSetupStatus = kSetupMismatch;
651 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
652 "The branch %s contains data of type %s, which should be accessed through a TTreeReaderValue< %s >.",
654 if (fSetupStatus == kSetupInternalError)
655 fSetupStatus = kSetupNotACollection;
661 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
662 "Cannot determine the type contained in the collection of branch %s. That's weird - please report!",
665 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
666 "The branch %s contains data of type %s, which does not have a dictionary.", fBranchName.Data(),
668 if (fSetupStatus == kSetupInternalError)
669 fSetupStatus = kSetupMissingDictionary;
703 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
704 "The branch %s contains data of type %s. It cannot be accessed by a TTreeReaderArray<%s>",
706 if (fSetupStatus == kSetupInternalError || fSetupStatus >= 0)
707 fSetupStatus = kSetupMismatch;
730 branch = fTreeReader->GetTree()->GetBranch(fBranchName);
734 if (!fBranchName.Contains(
".")) {
736 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
737 "The tree does not have a branch called %s. You could check with TTree::Print() for available branches.",
740 fSetupStatus = kSetupMissingBranch;
751 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
752 "The tree does not have a branch called %s. You could check with TTree::Print() for available branches.",
755 fSetupStatus = kSetupMissingBranch;
763 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
764 "The tree does not have a branch, nor a sub-branch called %s. You could check with TTree::Print() for "
765 "available branches.",
768 fSetupStatus = kSetupMissingBranch;
775 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
"Failed to get the dictionary for %s.",
myLeaf->GetTypeName());
776 fSetupStatus = kSetupMissingDictionary;
788 fHaveLeaf = (fLeafName.Length() > 0);
789 fSetupStatus = kSetupMatchLeaf;
791 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
"Leaf of type %s cannot be read by TTreeReaderValue<%s>.",
792 myLeaf->GetTypeName(), fDict->GetName());
794 fSetupStatus = kSetupMismatch;
816 if (!
myLeaf->GetLeafCount()) {
817 fImpl = std::make_unique<TLeafReader>(
this);
822 fImpl = std::make_unique<TLeafParameterSizeReader>(fTreeReader,
leafFullName.Data(),
this);
824 fSetupStatus = kSetupMatchLeaf;
837 if (fSetupStatus == kSetupInternalError)
838 fSetupStatus = kSetupMatch;
841 Error(
"TTreeReaderArrayBase::SetImpl",
"STL Collection nested in a TClonesArray not yet supported");
842 fSetupStatus = kSetupInternalError;
845 fImpl = std::make_unique<TSTLReader>();
850 fImpl = std::make_unique<TClonesReader>();
852 fImpl = std::make_unique<TBasicTypeArrayReader>();
855 fImpl = std::make_unique<TBasicTypeClonesReader>(
element->GetOffset());
857 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
861 std::make_unique<TArrayParameterSizeReader>(fTreeReader,
branchElement->GetBranchCount()->GetName());
864 fImpl = std::make_unique<TBasicTypeArrayReader>();
866 fImpl = std::make_unique<TBasicTypeClonesReader>(
element->GetOffset());
868 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
871 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
876 std::make_unique<TArrayParameterSizeReader>(fTreeReader,
branchElement->GetBranchCount()->GetName());
879 fImpl = std::make_unique<TClonesReader>();
881 Error(
"TTreeReaderArrayBase::SetImpl()",
"Cannot read branch %s: unhandled streamer element type %s",
882 fBranchName.Data(),
element->IsA()->GetName());
883 fSetupStatus = kSetupInternalError;
887 fImpl = std::make_unique<TCollectionLessSTLReader>(
branchElement->GetClass()->GetCollectionProxy());
893 Error(
"TTreeReaderArrayBase::SetImpl",
"Failed to get the top leaf from the branch");
894 fSetupStatus = kSetupMissingBranch;
899 if (fSetupStatus == kSetupInternalError)
900 fSetupStatus = kSetupMatch;
902 fImpl = std::make_unique<TArrayFixedSizeReader>(
topLeaf->GetLenStatic());
904 fImpl = std::make_unique<TArrayParameterSizeReader>(fTreeReader,
sizeLeaf->GetName());
908 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchClones not implemented");
909 fSetupStatus = kSetupInternalError;
911 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchObject not implemented");
912 fSetupStatus = kSetupInternalError;
914 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchSTL not implemented");
915 fImpl = std::make_unique<TSTLReader>();
916 fSetupStatus = kSetupInternalError;
918 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchRef not implemented");
919 fSetupStatus = kSetupInternalError;
945 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Could not get value class.");
964 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
965 "Cannot determine STL collection type of %s stored in branch %s",
brElement->GetClassName(),
997 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
998 "The branch %s contains a data type %d for which the dictionary cannot be retrieved.",
1008 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1009 "The branch %s contains data of type %s for which the dictionary does not exist. It's needed.",
1023 return "{CANNOT DETERMINE TBranchElement DATA TYPE}";
1034 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get class from branch element.");
1039 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get collection proxy from STL class");
1048 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get valueClass from collectionProxy.");
1054 if (!fProxy->Setup() || !fProxy->Read()) {
1055 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1056 "Failed to get type from proxy, unable to check type");
1077 Warning(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1078 "Not able to check type correctness, ignoring check");
1080 fSetupStatus = kSetupNoCheck;
1081 }
else if (!dict && (
branch->GetSplitLevel() == 0 ||
brElement->GetClass()->GetCollectionProxy())) {
1083 dict =
brElement->GetClass()->GetCollectionProxy()->GetValueClass();
1121 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1122 "The branch %s was created using a leaf list and cannot be represented as a C++ type. Please access one "
1123 "of its siblings using a TTreeReaderArray:",
1128 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
" %s.%s",
branch->GetName(),
leaf->GetName());
1135 Warning(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1136 "Not able to check type correctness, ignoring check");
1138 fSetupStatus = kSetupNoCheck;
1144 return "TClonesArray";
1147 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1148 "The branch %s is a TBranchRef and cannot be represented as a C++ type.",
branch->GetName());
1151 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
1152 "The branch %s is of type %s - something that is not handled yet.",
branch->GetName(),
1153 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
void operator=(const TProof &)
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.
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.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
void forward(const LAYERDATA &prevLayerData, LAYERDATA &currLayerData)
apply the weights (and functions) in forward direction of the DNN