96 Error(
"TChainIndex",
"Cannot create a TChainIndex."
97 " The Tree passed as an argument is not a TChain");
107 for (i = 0; i < chain->GetNtrees(); i++) {
108 chain->LoadTree((chain->GetTreeOffset())[i]);
119 Error(
"TChainIndex",
"Tree in file %s has an index built with majorname=%s and minorname=%s",chain->GetTree()->GetCurrentFile()->GetName(),index->
GetMajorName(),index->
GetMinorName());
124 chain->GetTree()->BuildIndex(majorname, minorname, long64major, long64minor);
125 index = chain->GetTree()->GetTreeIndex();
126 chain->GetTree()->SetTreeIndex(
nullptr);
129 if (!index || index->
IsZombie() || index->
GetN() == 0) {
132 Error(
"TChainIndex",
"Error creating a tree index on a tree in the chain");
137 if (ti_index ==
nullptr) {
138 Error(
"TChainIndex",
"The underlying TTree must have a TTreeIndex but has a %s.",
149 if(
fEntries[i].GetMaxIndexValPair() >
fEntries[i+1].GetMinIndexValPair() ) {
152 Warning(
"TChainIndex",
"The indices in files of this chain aren't sorted.");
165 if (ti_index ==
nullptr) {
166 Error(
"Append",
"The given index is not a TTreeIndex but a %s",
179 if(
fEntries[i].GetMaxIndexValPair() >
fEntries[i+1].GetMinIndexValPair() ) {
182 Error(
"Append",
"The indices in files of this chain aren't sorted.");
193 for (
unsigned int i = 0; i <
fEntries.size(); i++) {
196 fTree->GetTree()->SetTreeIndex(
nullptr);
211 if (
fTree->GetTreeIndex() ==
this)
212 fTree->SetTreeIndex(
nullptr);
224 using std::make_pair;
226 Warning(
"GetSubTreeIndex",
"No subindices in the chain. The chain is probably empty");
232 if( indexValue <
fEntries[0].GetMinIndexValPair() ) {
233 Warning(
"GetSubTreeIndex",
"The index value is less than the smallest index values in subtrees");
238 for (
unsigned int i = 0; i <
fEntries.size() - 1; i++) {
239 if( indexValue <
fEntries[i+1].GetMinIndexValPair() ) {
245 if( indexValue >
fEntries[treeNo].GetMaxIndexValPair() ) {
250 chain->LoadTree(chain->GetTreeOffset()[treeNo]);
253 return make_pair(
static_cast<TVirtualIndex*
>(index), treeNo);
255 index =
fEntries[treeNo].fTreeIndex;
257 Warning(
"GetSubTreeIndex",
"The tree has no index and the chain index"
258 " doesn't store an index for that tree");
262 fTree->GetTree()->SetTreeIndex(index);
263 return make_pair(
static_cast<TVirtualIndex*
>(index), treeNo);
275 if (
fEntries[treeNo].fTreeIndex == index) {
277 fTree->GetTree()->SetTreeIndex(
nullptr);
286 if (!parent)
return -3;
295 if (pentry >=
fTree->GetEntries())
return -2;
310 return fTree->GetEntryNumberWithIndex(majorv,minorv);
318 std::pair<TVirtualIndex*, Int_t> indexAndNumber =
GetSubTreeIndex(major, minor);
319 if (!indexAndNumber.first) {
324 Long64_t rv = indexAndNumber.first->GetEntryNumberWithBestIndex(major, minor);
328 return rv + chain->GetTreeOffset()[indexAndNumber.second];
338 std::pair<TVirtualIndex*, Int_t> indexAndNumber =
GetSubTreeIndex(major, minor);
339 if (!indexAndNumber.first) {
344 Long64_t rv = indexAndNumber.first->GetEntryNumberWithIndex(major, minor);
349 return rv + chain->GetTreeOffset()[indexAndNumber.second];
400 if ((majorFormula ==
nullptr || majorFormula->GetNdim() == 0) ||
401 (minorFormula ==
nullptr || minorFormula->GetNdim() == 0))
444 index->SetName(newname && std::strlen(newname) ? newname :
GetName());
int Int_t
Signed integer 4 bytes (int).
double Double_t
Double 8 bytes.
long long Long64_t
Portable signed long integer 8 bytes.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Holds a description of indices of trees in the chain.
std::pair< Long64_t, Long64_t > IndexValPair_t
void Swap(TChainIndexEntry &other)
TVirtualIndex * fTreeIndex
Long64_t fMinIndexValMinor
Long64_t fMaxIndexValMinor
void SetMinMaxFrom(const TTreeIndex *index)
std::vector< TChainIndexEntry > fEntries
TTreeFormula * fMinorFormulaParent
! Pointer to minor TreeFormula in Parent tree (if any)
~TChainIndex() override
The destructor.
bool IsValidFor(const TTree *parent) override
Return true if index can be applied to the TTree.
TObject * Clone(const char *newname="") const override
Create a deep copy of the TChainIndex.
void Append(const TVirtualIndex *, bool delaySort=false) override
Add an index to this chain.
std::pair< TVirtualIndex *, Int_t > GetSubTreeIndex(Long64_t major, Long64_t minor) const
Returns a TVirtualIndex for a tree which holds the entry with the specified major and minor values an...
Long64_t GetEntryNumberWithIndex(Long64_t major, Long64_t minor) const override
Returns the entry number with given index values.
void ReleaseSubTreeIndex(TVirtualIndex *index, Int_t treeNo) const
Releases the tree index got using GetSubTreeIndex.
Long64_t GetEntryNumberWithBestIndex(Long64_t major, Long64_t minor) const override
See TTreeIndex::GetEntryNumberWithBestIndex for details.
void UpdateFormulaLeaves(const TTree *parent) override
Updates the parent formulae.
TChainIndex()
Default constructor for TChainIndex.
void DeleteIndices()
Delete all the indices which were built by this object.
TTreeFormula * fMajorFormulaParent
! Pointer to major TreeFormula in Parent tree (if any)
Long64_t GetEntryNumberFriend(const TTree *parent) override
See TTreeIndex::GetEntryNumberFriend for description.
TTreeFormula * GetMajorFormulaParent(const TTree *parent)
Return a pointer to the TreeFormula corresponding to the majorname in parent tree T.
void SetTree(TTree *T) override
See TTreeIndex::SetTree.
TTreeFormula * GetMinorFormulaParent(const TTree *parent)
Return a pointer to the TreeFormula corresponding to the minorname in parent tree T.
A chain is a collection of files containing TTree objects.
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TObject()
TObject constructor.
A Tree Index with majorname and minorname.
virtual Long64_t * GetIndexValues() const
virtual Long64_t * GetIndexValuesMinor() const
Long64_t GetN() const override
Helper class to prevent infinite recursion in the usage of TTree Friends.
A TTree represents a columnar dataset.
virtual Long64_t GetReadEntry() const
virtual const char * GetMajorName() const =0
TVirtualIndex()
Default constructor for TVirtualIndex.
virtual const char * GetMinorName() const =0
virtual Long64_t GetN() const =0
TClass * IsA() const override
TTree * fTree
! pointer to Tree