# Loop over leaves from root file

**URL:** <https://root-forum.cern.ch/t/loop-over-leaves-from-root-file/48575>\
**Category:** Newbie\
**Tags:** root\
**Created:** [January 26, 2022, 12:43pm UTC](https://root-forum.cern.ch/t/loop-over-leaves-from-root-file/48575 "2022-01-26T12:43:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eddymaoui](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eddymaoui/32/20559_2.png) [@eddymaoui](https://root-forum.cern.ch/u/eddymaoui)\
**Post date:** [January 26, 2022, 12:43pm UTC](https://root-forum.cern.ch/t/loop-over-leaves-from-root-file/48575/1 "2022-01-26T12:43:34Z")

</div>

I am trying to loop over leaves from a root file such as most of those leaves are declared as vectors  
T-\>GetEntry(i) // show some errors

Note that the objective of this script is to calculate the number of hits by an event.  
Please find attached a script describing this issue and the root file.

[output.root](https://root-forum.cern.ch/uploads/short-url/3dGBmTLmbtJYNa4MoALmVn1HnPj.root) (42.8 KB)  
[reader.cc](https://root-forum.cern.ch/uploads/short-url/55L89ZKprZn1JMuvF8IzRPzjlnG.cc) (476 Bytes)

* * *

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [January 26, 2022, 2:32pm UTC](https://root-forum.cern.ch/t/loop-over-leaves-from-root-file/48575/2 "2022-01-26T14:32:36Z")

</div>

You need to load dictionaries (shared libraries) for classes that are used in your ROOT file.

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [January 26, 2022, 5:06pm UTC](https://root-forum.cern.ch/t/loop-over-leaves-from-root-file/48575/3 "2022-01-26T17:06:11Z")

</div>

Hi @eddymaoui ,  
to elaborate @Wile_E_Coyote 's comment further, when opening the file with `root output.root` you should see:

```auto
~/Downloads root -l output.root
root [0]
Attaching file output.root as _file0...
Warning in <TClass::Init>: no dictionary for class Event is available
Warning in <TClass::Init>: no dictionary for class Neutrino is available
Warning in <TClass::Init>: no dictionary for class BaseTrack is available
Warning in <TClass::Init>: no dictionary for class Vec3D is available
Warning in <TClass::Init>: no dictionary for class Primary is available
Warning in <TClass::Init>: no dictionary for class McTrack is available
Warning in <TClass::Init>: no dictionary for class Hit is available
Warning in <TClass::Init>: no dictionary for class RawHit is available
Warning in <TClass::Init>: no dictionary for class Header is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::XSecFile is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::String is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::AsciiIO is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::detector is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::muon_desc_file is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::node is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::target is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::drawing is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::physics is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::generator is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::simul is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::cut_primary is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::cut is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::cut_seamuon is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::cut_in is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::cut_nu is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::start_run is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::spectrum is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::PM1_type_area is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::PDF is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::model is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::can is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::genvol is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::merge is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::coord_origin is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::genhencut is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::k40 is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::norma is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::Vector<MONTE_CARLO::seed> is available
Warning in <TClass::Init>: no dictionary for class MONTE_CARLO::livetime is available
(TFile *) 0x5570321f4350

```

These warnings mean that ROOT won’t know how to read branches of those types from the file, because the corresponding “I/O information” (stored in ROOT dictionaries) is missing. See also [I/O of custom classes - ROOT](https://root.cern/manual/io_custom_classes/) for documentation on generating dictionaries for your classes, and [GitHub - eguiraud/root\_dictionaries\_tutorial: A tutorial on creating ROOT dictionaries to perform I/O of custom C++ classes](https://github.com/eguiraud/root_dictionaries_tutorial) for some practical examples.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [March 3, 2022, 8:33pm UTC](https://root-forum.cern.ch/t/loop-over-leaves-from-root-file/48575/4 "2022-03-03T20:33:31Z")

</div>

> These warnings mean that ROOT won’t know how to read branches of those types from the file, because the corresponding “I/O information”

More exactly, those warnings means that ROOT does not know about object of this type and thus you will not be able to read the data into those kind of objects.

However, the ROOT files are ‘self describing’ and there is many ways to still be able to read the data without the original data (The easiest is to use `RDataFrame` but there is other alternatives).
