# Reading TClonesArray in JITted RDF

**URL:** <https://root-forum.cern.ch/t/reading-tclonesarray-in-jitted-rdf/45784>\
**Category:** ROOT\
**Tags:** rdataframe\
**Created:** [July 10, 2021, 11:43am UTC](https://root-forum.cern.ch/t/reading-tclonesarray-in-jitted-rdf/45784 "2021-07-10T11:43:57Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [July 12, 2021, 9:59am UTC](https://root-forum.cern.ch/t/reading-tclonesarray-in-jitted-rdf/45784/2 "2021-07-12T09:59:15Z")

</div>

Hi Pieter,  
if I understand correctly RDF correctly reads `Electron` as a `TClonesArray` branch.  
The problem is really that `TClonesArray`, being type-erased like all ROOT collections, has a clunky API: it requires that you downcast its elements from `TObject` to their actual types.  
That’s fairly different from [Opening TClonesArray from Delphes Branches with RDataFrame](https://root-forum.cern.ch/t/opening-tclonesarray-from-delphes-branches-with-rdataframe/39392) where RDF was not able to read `TClonesArray` branches at all (that was an I/O problem, this is an API problem).

Now naturally, you’d like RDF to perform an on-the-fly conversion from `TClonesArray` to a friendlier type such as `RVec<Electron>`. I think that would be a nice improvement – although I am not sure at this point if we could make that happen a) in a backward-compatible way and b) without a copy of the array elements.

As an aside you should be able to use a `static_cast` instead of a `dynamic_cast` for your workaround.

Can you please open a request for improvement at [github.com/root-project/root/issues](http://github.com/root-project/root/issues) ? I will see what we can do about this.

Cheers,  
Enrico

---

_[View the full topic](https://root-forum.cern.ch/t/reading-tclonesarray-in-jitted-rdf/45784)._
