49 if (!
proxy->GetSuppressErrorsForMissingBranch())
50 Error(
"TClonesReader::GetCA()",
"Read error in TBranchProxy.");
79 if (!
proxy->GetSuppressErrorsForMissingBranch())
80 Error(
"TSTLReader::GetCP()",
"Read error in TBranchProxy.");
83 if (!
proxy->GetWhere()) {
84 Error(
"TSTLReader::GetCP()",
"Logic error, proxy object not set in TBranchProxy.");
116 if (!
proxy->Read()) {
118 if (!
proxy->GetSuppressErrorsForMissingBranch())
119 Error(
"TCollectionLessSTLReader::GetCP()",
"Read error in TBranchProxy.");
122 if (!
proxy->GetWhere()) {
123 Error(
"TCollectionLessSTLReader::GetCP()",
"Logic error, proxy object not set in TBranchProxy.");
127 return fLocalCollection;
161 Int_t fBasicTypeSize;
163 TObjectArrayReader() : fBasicTypeSize(-1) { }
168 if (!
proxy->GetSuppressErrorsForMissingBranch())
169 Error(
"TObjectArrayReader::GetCP()",
"Read error in TBranchProxy.");
181 if (!
proxy->Read())
return nullptr;
184 void *array = (
void*)
proxy->GetStart();
186 if (fBasicTypeSize == -1){
189 Error(
"TObjectArrayReader::At()",
"Cannot get class info from branch proxy.");
201 fBasicTypeSize =
size;
205 template <
class BASE>
206 class TDynamicArrayReader :
public BASE {
209 class TVirtualSizeReaderImpl {
212 virtual size_t GetSize() = 0;
215 template <
typename T>
216 class TSizeReaderImpl
final :
public TVirtualSizeReaderImpl {
221 size_t GetSize()
final {
return *fSizeReader; }
224 std::unique_ptr<TVirtualSizeReaderImpl> fSizeReader;
227 template <
class...
ARGS>
259 }
while (!
sizeLeaf && !parent.empty());
263 Error(
"TDynamicArrayReader ",
"Cannot find leaf count for %s or any parent branch!",
leafName);
274 }
else if (
leafType ==
"UShort_t") {
280 }
else if (
leafType ==
"Long64_t") {
282 }
else if (
leafType ==
"ULong64_t") {
285 Error(
"TDynamicArrayReader ",
286 "Unsupported size type for leaf %s. Supported types are int, short int, long int, long long int and "
287 "their unsigned counterparts.",
295 class TArrayParameterSizeReader :
public TDynamicArrayReader<TObjectArrayReader> {
304 class TArrayFixedSizeReader :
public TObjectArrayReader {
321 if (!
proxy->GetSuppressErrorsForMissingBranch())
322 Error(
"TBasicTypeArrayReader::GetCP()",
"Read error in TBranchProxy.");
342 class TBasicTypeClonesReader
final:
public TClonesReader {
370 if (fElementSize == -1){
372 if (!
myLeaf)
return nullptr;
373 fElementSize =
myLeaf->GetLenType();
375 return (
Byte_t*)address + (fElementSize * idx);
384 class TLeafParameterSizeReader :
public TDynamicArrayReader<TLeafReader> {
393 return TDynamicArrayReader<TLeafReader>::GetSize(
proxy);
411 fSetupStatus = kSetupInternalError;
413 Error(
"TTreeReaderArrayBase::CreateProxy()",
"TTreeReader object not set / available for branch %s!",
415 fSetupStatus = kSetupTreeDestructed;
419 TBranch*
br = fTreeReader->GetTree()->GetBranch(fBranchName);
425 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.",
426 GetDerivedTypeName(), fBranchName.Data(),
brDataType);
427 fSetupStatus = kSetupMissingDictionary;
439 (std::find(fTreeReader->fSuppressErrorsForMissingBranches.cbegin(),
440 fTreeReader->fSuppressErrorsForMissingBranches.cend(),
441 fBranchName.Data()) != fTreeReader->fSuppressErrorsForMissingBranches.cend());
450 Error(
"TTreeReaderArrayBase::CreateProxy()",
451 "No dictionary for branch %s.", fBranchName.Data());
458 fSetupStatus = kSetupMatch;
469 fSetupStatus = kSetupMatch;
471 Error(
"TTreeReaderArrayBase::CreateProxy()",
472 "Type ambiguity (want %s, have %s) for branch %s.",
473 fDict->GetName(),
namedProxy->GetContentDict()->GetName(), fBranchName.Data());
486 auto *
director = fTreeReader->fDirector.get();
488 if (
branch->GetTree() != fTreeReader->GetTree()->GetTree()) {
490 std::optional<std::size_t>
index;
491 std::size_t current{};
492 auto &&
friends = fTreeReader->GetTree()->GetTree()->GetListOfFriends();
494 if (
branch->GetTree() ==
fe->GetTree()) {
500 if (!
index.has_value()) {
501 Error(
"TTreeReaderArrayBase::CreateProxy()",
502 "The branch %s is contained in a Friend TTree that is not directly attached to the main.\n"
503 "This is not yet supported by TTreeReader.",
511 fTreeReader->AddProxy(
514 namedProxy = fTreeReader->FindProxy(fBranchName);
517 fSetupStatus = kSetupMatch;
519 fSetupStatus = kSetupMismatch;
526 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
"The branch %s contains data of type %s, which should be accessed through a TTreeReaderValue< %s >.",
528 if (fSetupStatus == kSetupInternalError)
529 fSetupStatus = kSetupNotACollection;
535 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
"Cannot determine the type contained in the collection of branch %s. That's weird - please report!",
538 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
"The branch %s contains data of type %s, which does not have a dictionary.",
540 if (fSetupStatus == kSetupInternalError)
541 fSetupStatus = kSetupMissingDictionary;
564 if (
l > 0 &&
l ==
r)
574 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
"The branch %s contains data of type %s. It cannot be accessed by a TTreeReaderArray<%s>",
576 if (fSetupStatus == kSetupInternalError || fSetupStatus >= 0)
577 fSetupStatus = kSetupMismatch;
600 branch = fTreeReader->GetTree()->GetBranch(fBranchName);
604 if (!fBranchName.Contains(
".")) {
606 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
607 "The tree does not have a branch called %s. You could check with TTree::Print() for available branches.",
610 fSetupStatus = kSetupMissingBranch;
621 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
622 "The tree does not have a branch called %s. You could check with TTree::Print() for available branches.",
625 fSetupStatus = kSetupMissingBranch;
633 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
634 "The tree does not have a branch, nor a sub-branch called %s. You could check with TTree::Print() for "
635 "available branches.",
638 fSetupStatus = kSetupMissingBranch;
645 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
"Failed to get the dictionary for %s.",
myLeaf->GetTypeName());
646 fSetupStatus = kSetupMissingDictionary;
657 fHaveLeaf = (fLeafName.Length() > 0);
658 fSetupStatus = kSetupMatchLeaf;
661 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
"Leaf of type %s cannot be read by TTreeReaderValue<%s>.",
myLeaf->GetTypeName(), fDict->GetName());
663 fSetupStatus = kSetupMismatch;
685 if (!
myLeaf->GetLeafCount()){
686 fImpl = std::make_unique<TLeafReader>(
this);
692 fImpl = std::make_unique<TLeafParameterSizeReader>(fTreeReader,
leafFullName.Data(),
this);
694 fSetupStatus = kSetupMatchLeaf;
708 if (fSetupStatus == kSetupInternalError)
709 fSetupStatus = kSetupMatch;
712 Error(
"TTreeReaderArrayBase::SetImpl",
713 "STL Collection nested in a TClonesArray not yet supported");
714 fSetupStatus = kSetupInternalError;
717 fImpl = std::make_unique<TSTLReader>();
723 fImpl = std::make_unique<TClonesReader>();
726 fImpl = std::make_unique<TBasicTypeArrayReader>();
730 fImpl = std::make_unique<TBasicTypeClonesReader>(
element->GetOffset());
733 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
737 fImpl = std::make_unique<TArrayParameterSizeReader>(fTreeReader,
branchElement->GetBranchCount()->GetName());
741 fImpl = std::make_unique<TBasicTypeArrayReader>();
744 fImpl = std::make_unique<TBasicTypeClonesReader>(
element->GetOffset());
747 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
750 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
755 fImpl = std::make_unique<TArrayParameterSizeReader>(fTreeReader,
branchElement->GetBranchCount()->GetName());
759 fImpl = std::make_unique<TClonesReader>();
761 Error(
"TTreeReaderArrayBase::SetImpl()",
762 "Cannot read branch %s: unhandled streamer element type %s",
763 fBranchName.Data(),
element->IsA()->GetName());
764 fSetupStatus = kSetupInternalError;
769 fImpl = std::make_unique<TCollectionLessSTLReader>(
branchElement->GetClass()->GetCollectionProxy());
775 Error(
"TTreeReaderArrayBase::SetImpl",
"Failed to get the top leaf from the branch");
776 fSetupStatus = kSetupMissingBranch;
781 if (fSetupStatus == kSetupInternalError)
782 fSetupStatus = kSetupMatch;
784 fImpl = std::make_unique<TArrayFixedSizeReader>(
topLeaf->GetLenStatic());
787 fImpl = std::make_unique<TArrayParameterSizeReader>(fTreeReader,
sizeLeaf->GetName());
791 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchClones not implemented");
792 fSetupStatus = kSetupInternalError;
794 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchObject not implemented");
795 fSetupStatus = kSetupInternalError;
797 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchSTL not implemented");
798 fImpl = std::make_unique<TSTLReader>();
799 fSetupStatus = kSetupInternalError;
801 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchRef not implemented");
802 fSetupStatus = kSetupInternalError;
830 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Could not get value class.");
848 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Cannot determine STL collection type of %s stored in branch %s",
brElement->GetClassName(),
branch->GetName());
880 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"The branch %s contains a data type %d for which the dictionary cannot be retrieved.",
890 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"The branch %s contains data of type %s for which the dictionary does not exist. It's needed.",
905 return "{CANNOT DETERMINE TBranchElement DATA TYPE}";
917 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get class from branch element.");
922 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get collection proxy from STL class");
930 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get valueClass from collectionProxy.");
937 if (!fProxy->Setup() || !fProxy->Read()){
938 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Failed to get type from proxy, unable to check type");
960 Warning(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Not able to check type correctness, ignoring check");
962 fSetupStatus = kSetupNoCheck;
964 else if (!dict && (
branch->GetSplitLevel() == 0 ||
brElement->GetClass()->GetCollectionProxy())){
966 dict =
brElement->GetClass()->GetCollectionProxy()->GetValueClass();
1003 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 TTreeReaderArray:",
branch->GetName());
1007 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
" %s.%s",
branch->GetName(),
leaf->GetName());
1013 Warning(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Not able to check type correctness, ignoring check");
1015 fSetupStatus = kSetupNoCheck;
1021 return "TClonesArray";
1024 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"The branch %s is a TBranchRef and cannot be represented as a C++ type.",
branch->GetName());
1027 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"The branch %s is of type %s - something that is not handled yet.",
branch->GetName(),
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