Determine the data type of TBranch within a TTree

I have a .root file created by someone else. I want to read it with external standalone C++ code. This TFile contains a TTree with multiple TBranch. I have success reading the data in the TBranch using the code below. (I’ve also had success with TTreeReader).

To successfully read the value from the TBranch, somehow I have to know that it’s an Int_t. Is there a way of seeing what the data type is before reading?

I’ve tried opening the TFile with TBrowser in ROOT but couldn’t find anything that looked useful. During the creation of the TTree the data type “/F /D /b etc.” must have been specified. Is this not stored?

I think somewhere in Get Ttree entries without knowing type how to do this is described, but that post is too advanced for me for now.

Thanks.

    TFile captureFile(inputCaptureFile.c_str());
    TTree* captureTree = (TTree*)captureFile.Get("cell");
    Int_t capture_nFiber;
    captureTree->SetBranchAddress("nFiber",&capture_nFiber);
    captureTree->SetBranchStatus("*",0);
    captureTree->SetBranchStatus("nFiber",1);
    for (int i=0;i<500000;i++) {
        captureTree->GetEntry(i);
        cout<<capture_nFiber<<" ";
    }
captureTree->Print();

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.