34from array 
import array
 
   38# We create the file and the tree
 
   39with ROOT.TFile("outfile.root", 
"RECREATE") as 
ofile:
 
   43    n = array(
'f', [ 1.5 ])
 
   44    t.Branch(
'floatb', 
n, 
'floatb/F')
 
   48    a = array(
'd', 
N*[ 0. ])
 
   49    t.Branch(
'arrayb', 
a, 
'arrayb[' + str(
N) + 
']/D')
 
   53    t.Branch(
'nparrayb', 
npa, 
'nparrayb[' + str(
N) + 
']/D')
 
   56    v = 
ROOT.std.vector(
'double')(
N*[ 0. ])
 
   57    t.Branch(
'vectorb0', 
v)
 
   60    cb = 
ROOT.
TH1D(
"myHisto", 
"myHisto", 64, -4, 4)
 
   63    t.Branch(
'classb', cb)
 
   75    t.Branch(
'structll', ms, 
'myint/I:myfloat/F')
 
   82    t.Branch(
'myfloatb', 
ROOT.
addressof(ms, 
'myfloat'), 
'myfloat/F')
 
   84    # 
Let's write one entry in our tree 
   86    # Finally flush the content of the tree to the file 
   90### Pythonization of TTree::SetBranchAddress 
   92This section is to be considered for advanced users. Simple event 
   93loops reading tree entries in Python can be performed as shown above. 
   95Below an example is shown of reading different types tree branches. 
   96Note that `SetBranchAddress` will just link a given branch with a 
   97certain Python object; after that, in order to read the content of such 
   98branch for a given TTree entry `x`, TTree::GetEntry(x) must be 
  102from array import array 
  106with ROOT.TFile('outfile.root
') as infile: 
  110    # Basic type branch (float) - use array of length 1 
  111    n = array('f', [ 0. ]) 
  112    t.SetBranchAddress('floatb', n) 
  114    # Array branch - use array of length N 
  116    a = array('d', N*[ 0. ]) 
  117    t.SetBranchAddress('arrayb', a) 
  119    # Array branch - use NumPy array of length N 
  120    npa = np.array(N*[ 0. ]) 
  124    v = ROOT.std.vector('double')() 
  125    t.SetBranchAddress('vectorb', v) 
  129    # Any other class known to ROOT would have worked 
  131    t.SetBranchAddress('classb', cb) 
  133    # Struct as leaflist. This is interpreted on the fly, 
  134    # but could be known to ROOT by other means, such as 
  135    # header inclusion or dictionary load. 
  136    ROOT.gInterpreter.Declare(''' 
  143    t.SetBranchAddress(
'structll', ms)
 
static Roo_reg_AGKInteg1D instance
 
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
 
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
 
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void when
 
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
 
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
 
A chain is a collection of files containing TTree objects.
 
1-D histogram with a double per channel (see TH1 documentation)
 
A simple TTree restricted to a list of float variables only.
 
A TTree represents a columnar dataset.
 
virtual Int_t Fill()
Fill all branches.
 
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=nullptr)
Change branch address, dealing with clone trees properly.
 
TBranch * Branch(const char *name, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
Add a new branch, and infer the data type from the type of obj being passed.
 
int iterate(rng_state_t *X)
 
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
 
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...