# ROOT 2D Plot Problems

**URL:** <https://allpix-squared-forum.web.cern.ch/t/root-2d-plot-problems/737>\
**Category:** Uncategorized\
**Created:** [May 12, 2025, 11:40pm UTC](https://allpix-squared-forum.web.cern.ch/t/root-2d-plot-problems/737 "2025-05-12T23:40:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oobie2142](https://allpix-squared-forum.web.cern.ch/letter_avatar_proxy/v4/letter/o/7ab992/32.png) [@oobie2142](https://allpix-squared-forum.web.cern.ch/u/oobie2142)\
**Post date:** [May 12, 2025, 11:40pm UTC](https://allpix-squared-forum.web.cern.ch/t/root-2d-plot-problems/737/1 "2025-05-12T23:40:10Z")

</div>

Hello I am looking to plot the global\_end\_points from the MCParticle Tree at the anode side of the detector. Is there anyway to parse data outside of ROOT? Or if someone could give me an example of their workflow to extract the data to export to Python or a plain text file that would be great!

Or if anyone can help me understand how to use the TBrowser to get useful plots, I would greatly appreciate it! Attached is the \*.root file.

[output\_source\_measurement\_122keV.root](https://allpix-squared-forum.web.cern.ch/uploads/short-url/nB6AXXNpn8JZOFmPDZuNLiSpvts.root) (25.1 MB)

I am using root 6.32.02 with python 3.12

---

<div class="post-metadata">

**Author:** ![oobie2142](https://allpix-squared-forum.web.cern.ch/letter_avatar_proxy/v4/letter/o/7ab992/32.png) [@oobie2142](https://allpix-squared-forum.web.cern.ch/u/oobie2142)\
**Post date:** [May 13, 2025, 3:02am UTC](https://allpix-squared-forum.web.cern.ch/t/root-2d-plot-problems/737/2 "2025-05-13T03:02:54Z")

</div>

For anyone interested I had to retro fit the analysisExample.C to output the global endpoints of MCParticle. Not sure if this is correct, but I got a 2D histogram.

---

<div class="post-metadata">

**Author:** ![pschutze](https://allpix-squared-forum.web.cern.ch/letter_avatar_proxy/v4/letter/p/45deac/32.png) [@pschutze](https://allpix-squared-forum.web.cern.ch/u/pschutze)\
**Post date:** [May 13, 2025, 9:54am UTC](https://allpix-squared-forum.web.cern.ch/t/root-2d-plot-problems/737/3 "2025-05-13T09:54:26Z")

</div>

Hi @oobie2142 ,

the easiest way to do this is to use the `TextWriter` module instead of the `ROOTObjectWriter`. This will generate a plain text file, among others listing the global end point of the `MCParticle`. See the following example:

```auto
--- telescope0 ---

--- Printing MCParticle information (0x77e7946a5860) --------------------
Particle type (PDG ID): 211
Local start point: 6.21875 mm | 5.01963 mm | -0.15 mm  
Global start point: 0.902269 mm | 1.93853 mm | 0.0432881 mm  
Local end point: 6.17053 mm | 5.06812 mm | 0.15 mm  
Global end point: 0.902269 mm | 1.93853 mm | 0.350983 mm  
Local time: 0 ns 
Global time: 0.66729 ns 
Linked parent: <nullptr>
Linked track: 0x77e7946acca0
-------------------------------------------------------------------------

```

It is of course also possible to extract this from the ROOT file, in case e.g. you rely on a correlation to the rest of the dataset.

Does this help you?

Cheers  
Paul

---

<div class="post-metadata">

**Author:** ![oobie2142](https://allpix-squared-forum.web.cern.ch/letter_avatar_proxy/v4/letter/o/7ab992/32.png) [@oobie2142](https://allpix-squared-forum.web.cern.ch/u/oobie2142)\
**Post date:** [May 13, 2025, 4:20pm UTC](https://allpix-squared-forum.web.cern.ch/t/root-2d-plot-problems/737/4 "2025-05-13T16:20:51Z")

</div>

Thank you @pschutze I was able to retrofit the the example root script to my needs luckily it was well structured. I will try the TextWriter Module as well to add to the toolbox for future simulations. Thanks!
