Skip to content

TTree cannot find branch of friend TChain stored in inner TTree #20249

@vepadulano

Description

@vepadulano

Check duplicate issues.

  • Checked for duplicates

Description

Connected to #20248

Error in <TTreeFormula::Compile>:  Bad numerical expression : "stepzerochain.value"
************************************
*    Row   *     value * stepzeroc *
************************************
*        0 *         0 *           *
*        1 *         1 *           *
*        2 *         2 *           *
*        3 *         3 *           *
************************************

Reproducer

#include <TChain.h>
#include <TFile.h>
#include <TTree.h>

#include <memory>
#include <iostream>

void write_data(const char *name, const char *treename, int first, int last)
{
    auto file = std::make_unique<TFile>(name, "RECREATE");
    auto tree = std::make_unique<TTree>(treename, treename);

    int value{};
    tree->Branch("value", &value);

    for (value = first; value < last; ++value)
    {
        tree->Fill();
    }

    file->Write();
}

void run()
{
    // The TTree name is different than the name of the TChain that wraps it.
    write_data("stepzero_0.root", "events_zero", 3, 7);

    auto chain0 = std::make_unique<TChain>("stepzerochain");
    chain0->Add("stepzero_0.root?#events_zero");

    // The TTree name is different than the name of the TChain that wraps it.
    write_data("stepone_0.root", "events_one", 0, chain0->GetEntries());

    auto file = std::make_unique<TFile>("stepone_0.root");
    std::unique_ptr<TTree> tree{file->Get<TTree>("events_one")};
    tree->AddFriend(chain0.get());

    tree->Scan("value:stepzerochain.value");

}

int main()
{
    run();
}

ROOT version

any

Installation method

any

Operating system

any

Additional context

No response

Metadata

Metadata

Labels

bugexperimentAffects an experiment / reported by its software & computimng experts

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions