48 Error(
"TClonesReader::GetCA()",
"Read error in TBranchProxy.");
77 Error(
"TSTLReader::GetCP()",
"Read error in TBranchProxy.");
80 if (!
proxy->GetWhere()) {
81 Error(
"TSTLReader::GetCP()",
"Logic error, proxy object not set in TBranchProxy.");
113 if (!
proxy->Read()) {
115 Error(
"TCollectionLessSTLReader::GetCP()",
"Read error in TBranchProxy.");
118 if (!
proxy->GetWhere()) {
119 Error(
"TCollectionLessSTLReader::GetCP()",
"Logic error, proxy object not set in TBranchProxy.");
123 return fLocalCollection;
157 Int_t fBasicTypeSize;
159 TObjectArrayReader() : fBasicTypeSize(-1) { }
164 Error(
"TObjectArrayReader::GetCP()",
"Read error in TBranchProxy.");
176 if (!
proxy->Read())
return nullptr;
179 void *array = (
void*)
proxy->GetStart();
181 if (fBasicTypeSize == -1){
184 Error(
"TObjectArrayReader::At()",
"Cannot get class info from branch proxy.");
196 fBasicTypeSize =
size;
200 template <
class BASE>
201 class TDynamicArrayReader :
public BASE {
204 class TVirtualSizeReaderImpl {
207 virtual size_t GetSize() = 0;
210 template <
typename T>
211 class TSizeReaderImpl
final :
public TVirtualSizeReaderImpl {
216 size_t GetSize()
final {
return *fSizeReader; }
219 std::unique_ptr<TVirtualSizeReaderImpl> fSizeReader;
222 template <
class...
ARGS>
254 }
while (!
sizeLeaf && !parent.empty());
258 Error(
"TDynamicArrayReader ",
"Cannot find leaf count for %s or any parent branch!",
leafName);
269 }
else if (
leafType ==
"UShort_t") {
275 }
else if (
leafType ==
"Long64_t") {
277 }
else if (
leafType ==
"ULong64_t") {
280 Error(
"TDynamicArrayReader ",
281 "Unsupported size type for leaf %s. Supported types are int, short int, long int, long long int and "
282 "their unsigned counterparts.",
290 class TArrayParameterSizeReader :
public TDynamicArrayReader<TObjectArrayReader> {
299 class TArrayFixedSizeReader :
public TObjectArrayReader {
316 Error(
"TBasicTypeArrayReader::GetCP()",
"Read error in TBranchProxy.");
336 class TBasicTypeClonesReader
final:
public TClonesReader {
364 if (fElementSize == -1){
366 if (!
myLeaf)
return nullptr;
367 fElementSize =
myLeaf->GetLenType();
369 return (
Byte_t*)address + (fElementSize * idx);
378 class TLeafParameterSizeReader :
public TDynamicArrayReader<TLeafReader> {
387 return TDynamicArrayReader<TLeafReader>::GetSize(
proxy);
405 fSetupStatus = kSetupInternalError;
407 Error(
"TTreeReaderArrayBase::CreateProxy()",
"TTreeReader object not set / available for branch %s!",
409 fSetupStatus = kSetupTreeDestructed;
413 TBranch*
br = fTreeReader->GetTree()->GetBranch(fBranchName);
419 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.",
420 GetDerivedTypeName(), fBranchName.Data(),
brDataType);
421 fSetupStatus = kSetupMissingDictionary;
437 Error(
"TTreeReaderArrayBase::CreateProxy()",
438 "No dictionary for branch %s.", fBranchName.Data());
445 fSetupStatus = kSetupMatch;
456 fSetupStatus = kSetupMatch;
458 Error(
"TTreeReaderArrayBase::CreateProxy()",
459 "Type ambiguity (want %s, have %s) for branch %s.",
460 fDict->GetName(),
namedProxy->GetContentDict()->GetName(), fBranchName.Data());
473 auto director = fTreeReader->fDirector;
475 if (
branch->GetTree() != fTreeReader->GetTree()->GetTree()) {
480 if (
branch->GetTree() ==
fe->GetTree()) {
486 Error(
"TTreeReaderArrayBase::CreateProxy()",
"The branch %s is contained in a Friend TTree that is not directly attached to the main.\n"
487 "This is not yet supported by TTreeReader.",
497 fTreeReader->fFriendProxies.resize(
index+1);
506 fSetupStatus = kSetupMatch;
508 fSetupStatus = kSetupMismatch;
515 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
"The branch %s contains data of type %s, which should be accessed through a TTreeReaderValue< %s >.",
517 if (fSetupStatus == kSetupInternalError)
518 fSetupStatus = kSetupNotACollection;
524 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
"Cannot determine the type contained in the collection of branch %s. That's weird - please report!",
527 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
"The branch %s contains data of type %s, which does not have a dictionary.",
529 if (fSetupStatus == kSetupInternalError)
530 fSetupStatus = kSetupMissingDictionary;
553 if (
l > 0 &&
l ==
r)
563 Error(
"TTreeReaderArrayBase::CreateContentProxy()",
"The branch %s contains data of type %s. It cannot be accessed by a TTreeReaderArray<%s>",
565 if (fSetupStatus == kSetupInternalError || fSetupStatus >= 0)
566 fSetupStatus = kSetupMismatch;
587 branch = fTreeReader->GetTree()->GetBranch(fBranchName);
591 if (!fBranchName.Contains(
".")) {
592 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
"The tree does not have a branch called %s. You could check with TTree::Print() for available branches.", fBranchName.Data());
593 fSetupStatus = kSetupMissingBranch;
603 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
"The tree does not have a branch called %s. You could check with TTree::Print() for available branches.", fBranchName.Data());
604 fSetupStatus = kSetupMissingBranch;
611 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
"The tree does not have a branch, nor a sub-branch called %s. You could check with TTree::Print() for available branches.", fBranchName.Data());
612 fSetupStatus = kSetupMissingBranch;
619 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
"Failed to get the dictionary for %s.",
myLeaf->GetTypeName());
620 fSetupStatus = kSetupMissingDictionary;
631 fHaveLeaf = (fLeafName.Length() > 0);
632 fSetupStatus = kSetupMatchLeaf;
635 Error(
"TTreeReaderArrayBase::GetBranchAndLeaf()",
"Leaf of type %s cannot be read by TTreeReaderValue<%s>.",
myLeaf->GetTypeName(), fDict->GetName());
637 fSetupStatus = kSetupMismatch;
662 if (!
myLeaf->GetLeafCount()){
663 fImpl = std::make_unique<TLeafReader>(
this);
669 fImpl = std::make_unique<TLeafParameterSizeReader>(fTreeReader,
leafFullName.Data(),
this);
671 fSetupStatus = kSetupMatchLeaf;
685 if (fSetupStatus == kSetupInternalError)
686 fSetupStatus = kSetupMatch;
689 Error(
"TTreeReaderArrayBase::SetImpl",
690 "STL Collection nested in a TClonesArray not yet supported");
691 fSetupStatus = kSetupInternalError;
694 fImpl = std::make_unique<TSTLReader>();
700 fImpl = std::make_unique<TClonesReader>();
703 fImpl = std::make_unique<TBasicTypeArrayReader>();
707 fImpl = std::make_unique<TBasicTypeClonesReader>(
element->GetOffset());
710 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
714 fImpl = std::make_unique<TArrayParameterSizeReader>(fTreeReader,
branchElement->GetBranchCount()->GetName());
718 fImpl = std::make_unique<TBasicTypeArrayReader>();
721 fImpl = std::make_unique<TBasicTypeClonesReader>(
element->GetOffset());
724 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
727 fImpl = std::make_unique<TArrayFixedSizeReader>(
element->GetArrayLength());
732 fImpl = std::make_unique<TArrayParameterSizeReader>(fTreeReader,
branchElement->GetBranchCount()->GetName());
736 fImpl = std::make_unique<TClonesReader>();
738 Error(
"TTreeReaderArrayBase::SetImpl()",
739 "Cannot read branch %s: unhandled streamer element type %s",
740 fBranchName.Data(),
element->IsA()->GetName());
741 fSetupStatus = kSetupInternalError;
746 fImpl = std::make_unique<TCollectionLessSTLReader>(
branchElement->GetClass()->GetCollectionProxy());
752 Error(
"TTreeReaderArrayBase::SetImpl",
"Failed to get the top leaf from the branch");
753 fSetupStatus = kSetupMissingBranch;
758 if (fSetupStatus == kSetupInternalError)
759 fSetupStatus = kSetupMatch;
761 fImpl = std::make_unique<TArrayFixedSizeReader>(
topLeaf->GetLenStatic());
764 fImpl = std::make_unique<TArrayParameterSizeReader>(fTreeReader,
sizeLeaf->GetName());
768 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchClones not implemented");
769 fSetupStatus = kSetupInternalError;
771 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchObject not implemented");
772 fSetupStatus = kSetupInternalError;
774 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchSTL not implemented");
775 fImpl = std::make_unique<TSTLReader>();
776 fSetupStatus = kSetupInternalError;
778 Error(
"TTreeReaderArrayBase::SetImpl",
"Support for branches of type TBranchRef not implemented");
779 fSetupStatus = kSetupInternalError;
807 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Could not get value class.");
825 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Cannot determine STL collection type of %s stored in branch %s",
brElement->GetClassName(),
branch->GetName());
857 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"The branch %s contains a data type %d for which the dictionary cannot be retrieved.",
867 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"The branch %s contains data of type %s for which the dictionary does not exist. It's needed.",
882 return "{CANNOT DETERMINE TBranchElement DATA TYPE}";
894 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get class from branch element.");
899 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get collection proxy from STL class");
907 Error(
"TTreeReaderArrayBase::GetBranchDataType()",
"Could not get valueClass from collectionProxy.");
914 if (!fProxy->Setup() || !fProxy->Read()){
915 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Failed to get type from proxy, unable to check type");
937 Warning(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Not able to check type correctness, ignoring check");
939 fSetupStatus = kSetupNoCheck;
941 else if (!dict && (
branch->GetSplitLevel() == 0 ||
brElement->GetClass()->GetCollectionProxy())){
943 dict =
brElement->GetClass()->GetCollectionProxy()->GetValueClass();
980 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());
984 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
" %s.%s",
branch->GetName(),
leaf->GetName());
990 Warning(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"Not able to check type correctness, ignoring check");
992 fSetupStatus = kSetupNoCheck;
998 return "TClonesArray";
1001 Error(
"TTreeReaderArrayBase::GetBranchContentDataType()",
"The branch %s is a TBranchRef and cannot be represented as a C++ type.",
branch->GetName());
1004 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)
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