Accessing TNonSplitBrowsable


Please read tips for efficient and successful posting and posting code

_ROOT Version: 16.08/05
_Platform: Scientific Linux
_Compiler: Unsure


I’m trying to write a macro where I would plot a 2D histogram. The data I need to plot is stored in a TNonSplitBrowsable, within a TBranchElement. I was just going to get a pointer to the TBranchElement and then use that to get a pointer to the TNonSplitBrowsable so I could then access the required leaves but I can’t find any method that does this. I can access the leaves via TBrowser but this makes doing any sort of more complicated plotting very difficult.

Below is an image of the file structure, where “pos” is the TNonSplitBrowsable
TNonSplitBrowsable

Hi @stephen-mul ,
what does tree->Print() print for that tree?

Cheers,
Enrico

******************************************************************************
*Tree    :T         : RAT Tree                                               *
*Entries :    10000 : Total =       233944473 bytes  File  Size =  136388822 *
*        :          : Tree compression factor =   1.71                       *
******************************************************************************
*Branch  :ds                                                                 *
*Entries :    10000 : BranchElement (see below)                              *
*............................................................................*
*Br    0 :fUniqueID : UInt_t                                                 *
*Entries :    10000 : Total  Size=      40870 bytes  File Size  =        685 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=  58.93     *
*............................................................................*
*Br    1 :fBits     : UInt_t                                                 *
*Entries :    10000 : Total  Size=      80874 bytes  File Size  =      13020 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   6.17     *
*............................................................................*
*Br    2 :runID     : Int_t                                                  *
*Entries :    10000 : Total  Size=      40854 bytes  File Size  =        715 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=  56.43     *
*............................................................................*
*Br    3 :ratVersion : string                                                *
*Entries :    10000 : Total  Size=     161349 bytes  File Size  =      15555 *
*Baskets :       10 : Basket Size=      32000 bytes  Compression=  10.34     *
*............................................................................*
*Br    4 :procResult : Int_t procResult_                                     *
*Entries :    10000 : Total  Size=      83097 bytes  File Size  =      13040 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   6.17     *
*............................................................................*
*Br    5 :procResult.first : string first[procResult_]                       *
*Entries :    10000 : Total  Size=     623139 bytes  File Size  =      28360 *
*Baskets :       25 : Basket Size=      32000 bytes  Compression=  21.94     *
*............................................................................*
*Br    6 :procResult.second : Int_t second[procResult_]                      *
*Entries :    10000 : Total  Size=     282078 bytes  File Size  =      16470 *
*Baskets :       15 : Basket Size=      32000 bytes  Compression=  17.08     *
*............................................................................*
*Br    7 :mc        : Int_t mc_                                              *
*Entries :    10000 : Total  Size=     206048 bytes  File Size  =      12995 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   6.18     *
*............................................................................*
*Br    8 :mc.fUniqueID : UInt_t fUniqueID[mc_]                               *
*Entries :    10000 : Total  Size=      81027 bytes  File Size  =      12980 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   6.20     *
*............................................................................*
*Br    9 :mc.fBits  : UInt_t fBits[mc_]                                      *
*Entries :    10000 : Total  Size=      80991 bytes  File Size  =      13045 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   6.16     *
*............................................................................*
*Br   10 :mc.id     : Int_t id[mc_]                                          *
*Entries :    10000 : Total  Size=      80964 bytes  File Size  =      27930 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   2.88     *
*............................................................................*
*Br   11 :mc.numPE  : Int_t numPE[mc_]                                       *
*Entries :    10000 : Total  Size=      80991 bytes  File Size  =      27633 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   2.91     *
*............................................................................*
*Br   12 :mc.numDarkHits : Int_t numDarkHits[mc_]                            *
*Entries :    10000 : Total  Size=      81045 bytes  File Size  =      44842 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   1.79     *
*............................................................................*
*Br   13 :mc.utc.fSec : Int_t fSec[mc_]                                      *
*Entries :    10000 : Total  Size=      81010 bytes  File Size  =      13073 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   6.15     *
*............................................................................*
*Br   14 :mc.utc.fNanoSec : Int_t fNanoSec[mc_]                              *
*Entries :    10000 : Total  Size=      81046 bytes  File Size  =      26545 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   3.03     *
*............................................................................*
*Br   15 :mc.summary : vector<RAT::DS::MCSummary> summary[mc_]               *
*Entries :    10000 : Total  Size=  196055665 bytes  File Size  =  119858962 *
*Baskets :     3941 : Basket Size=      32000 bytes  Compression=   1.63     *
*............................................................................*
*Br   16 :mc.particle : vector<RAT::DS::MCParticle> particle[mc_]            *
*Entries :    10000 : Total  Size=    2639498 bytes  File Size  =    1013806 *
*Baskets :       85 : Basket Size=      32000 bytes  Compression=   2.60     *
*............................................................................*
*Br   17 :mc.parent : vector<RAT::DS::MCParticle> parent[mc_]                *
*Entries :    10000 : Total  Size=     161445 bytes  File Size  =      15530 *
*Baskets :       10 : Basket Size=      32000 bytes  Compression=  10.35     *
*............................................................................*
*Br   18 :mc.track  : vector<RAT::DS::MCTrack> track[mc_]                    *
*Entries :    10000 : Total  Size=     161431 bytes  File Size  =      15470 *
*Baskets :       10 : Basket Size=      32000 bytes  Compression=  10.39     *
*............................................................................*
*Br   19 :mc.pmt    : vector<RAT::DS::MCPMT> pmt[mc_]                        *
*Entries :    10000 : Total  Size=   26747725 bytes  File Size  =   12467438 *
*Baskets :      895 : Basket Size=      32000 bytes  Compression=   2.14     *
*............................................................................*
*Br   20 :calib     : Int_t calib_                                           *
*Entries :    10000 : Total  Size=      86675 bytes  File Size  =      12975 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   6.20     *
*............................................................................*
*Br   21 :calib.fUniqueID : UInt_t fUniqueID[calib_]                         *
*Entries :    10000 : Total  Size=      41040 bytes  File Size  =        775 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=  52.17     *
*............................................................................*
*Br   22 :calib.fBits : UInt_t fBits[calib_]                                 *
*Entries :    10000 : Total  Size=      41004 bytes  File Size  =        755 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=  53.53     *
*............................................................................*
*Br   23 :calib.id  : Int_t id[calib_]                                       *
*Entries :    10000 : Total  Size=      40977 bytes  File Size  =        740 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=  54.59     *
*............................................................................*
*Br   24 :calib.mode : Int_t mode[calib_]                                    *
*Entries :    10000 : Total  Size=      40995 bytes  File Size  =        750 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=  53.88     *
*............................................................................*
*Br   25 :calib.intensity : Float_t intensity[calib_]                        *
*Entries :    10000 : Total  Size=      41040 bytes  File Size  =        775 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=  52.17     *
*............................................................................*
*Br   26 :calib.name : string name[calib_]                                   *
*Entries :    10000 : Total  Size=     100995 bytes  File Size  =      14655 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   6.85     *
*............................................................................*
*Br   27 :calib.utc.fSec : Int_t fSec[calib_]                                *
*Entries :    10000 : Total  Size=      41023 bytes  File Size  =        770 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=  52.51     *
*............................................................................*
*Br   28 :calib.utc.fNanoSec : Int_t fNanoSec[calib_]                        *
*Entries :    10000 : Total  Size=      41059 bytes  File Size  =        790 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=  51.20     *
*............................................................................*
*Br   29 :calib.pos : TVector3 pos[calib_]                                   *
*Entries :    10000 : Total  Size=      40986 bytes  File Size  =        745 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=  54.23     *
*............................................................................*
*Br   30 :ev        : Int_t ev_                                              *
*Entries :    10000 : Total  Size=      90988 bytes  File Size  =      19238 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   4.18     *
*............................................................................*
*Br   31 :ev.fUniqueID : UInt_t fUniqueID[ev_]                               *
*Entries :    10000 : Total  Size=      58239 bytes  File Size  =       9268 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   6.22     *
*............................................................................*
*Br   32 :ev.fBits  : UInt_t fBits[ev_]                                      *
*Entries :    10000 : Total  Size=      58203 bytes  File Size  =       9292 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   6.20     *
*............................................................................*
*Br   33 :ev.id     : Int_t id[ev_]                                          *
*Entries :    10000 : Total  Size=      58176 bytes  File Size  =       9227 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   6.24     *
*............................................................................*
*Br   34 :ev.qTotal : Float_t qTotal[ev_]                                    *
*Entries :    10000 : Total  Size=      58212 bytes  File Size  =      26552 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   2.17     *
*............................................................................*
*Br   35 :ev.calibratedTriggerTime : Float_t calibratedTriggerTime[ev_]      *
*Entries :    10000 : Total  Size=      58347 bytes  File Size  =      26928 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   2.14     *
*............................................................................*
*Br   36 :ev.deltat : Double_t deltat[ev_]                                   *
*Entries :    10000 : Total  Size=      75444 bytes  File Size  =      44386 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   1.69     *
*............................................................................*
*Br   37 :ev.utc.fSec : Int_t fSec[ev_]                                      *
*Entries :    10000 : Total  Size=      58222 bytes  File Size  =      14285 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   4.04     *
*............................................................................*
*Br   38 :ev.utc.fNanoSec : Int_t fNanoSec[ev_]                              *
*Entries :    10000 : Total  Size=      58258 bytes  File Size  =      27807 *
*Baskets :        5 : Basket Size=      32000 bytes  Compression=   2.07     *
*............................................................................*
*Br   39 :ev.pmt    : vector<RAT::DS::PMT> pmt[ev_]                          *
*Entries :    10000 : Total  Size=    2686517 bytes  File Size  =    1473815 *
*Baskets :       88 : Basket Size=      32000 bytes  Compression=   1.82     *
*............................................................................*
*Br   40 :ev.centroid : vector<RAT::DS::Centroid> centroid[ev_]              *
*Entries :    10000 : Total  Size=     454179 bytes  File Size  =     153197 *
*Baskets :       20 : Basket Size=      32000 bytes  Compression=   2.96     *
*............................................................................*
*Br   41 :ev.bonsaifits : vector<RAT::DS::BonsaiFit> bonsaifits[ev_]         *
*Entries :    10000 : Total  Size=    1033074 bytes  File Size  =     389906 *
*Baskets :       35 : Basket Size=      32000 bytes  Compression=   2.65     *
*............................................................................*
*Br   42 :ev.pathfit : vector<RAT::DS::PathFit> pathfit[ev_]                 *
*Entries :    10000 : Total  Size=     829971 bytes  File Size  =     441856 *
*Baskets :       30 : Basket Size=      32000 bytes  Compression=   1.88     *
*............................................................................*
*Br   43 :user      : vector<double>                                         *
*Entries :    10000 : Total  Size=     141265 bytes  File Size  =      16280 *
*Baskets :       10 : Basket Size=      32000 bytes  Compression=   8.65     *
*............................................................................*

it’s quite long but for the tree T this is the output of Print()

Alright, from that output we can see that mc.particle contains variables of type vector<RAT::DS::MCParticle>, and there is no pos sub-branch.

TBrowser shows a pos because it knows that RAT::DS::MCParticle has a pos data member and therefore mc.particle.pos can be used to refer to the vector of pos data members of each of the elements of the mc.particle vector.

You should be able to read mc.particle.pos using TTreeReader or RDataFrame. Under the hood they will have to read all of mc.particle, but just like TBrowser they can expose just the single data-member to users.

Cheers,
Enrico

Thanks Enrico. I’m not sure how to use these methods you suggest. I tried TTreeReader tr; like I would use TBrowser but this output nothing

Hi,
the graphical interface ROOT has is TBrowser. To use TTreeReader or RDataFrame (or other ROOT features) you have to write a C++ or Python program, you can find more resources at https://root.cern/manual .

Cheers,
Enrico

Hi Enrico. I can’t just use it from the command line to test it out?

Hi Enrico, think I’ve a simpler way to do it. I’m just able to write tree->Draw(“mc.mc.particle.pos.fX”) to output the histogram I need. Thanks

Yes you can write arbitrary C++ code at the ROOT prompt.

Ah yes absolutely, that’s the functionality that TBrowser also uses under the hood, I should have mentioned it but I was side-tracked by the request of “complicated plotting”: TTree::Draw is not always sufficient for that.

Glad you found a solution!
Cheers,
Enrico

Sorry if “complicated plotting” was misleading. It might be complicated for me only perhaps! I really just meant I needed some of the functionality outside of what you can do in TBrowser. Regardless, thanks very much for the help