# Get() on lxplus

**URL:** <https://root-forum.cern.ch/t/get-on-lxplus/49035>\
**Category:** Newbie\
**Created:** [March 4, 2022, 5:29pm UTC](https://root-forum.cern.ch/t/get-on-lxplus/49035 "2022-03-04T17:29:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wurzel](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/e9a140/32.png) [@Wurzel](https://root-forum.cern.ch/u/Wurzel)\
**Post date:** [March 4, 2022, 5:29pm UTC](https://root-forum.cern.ch/t/get-on-lxplus/49035/1 "2022-03-04T17:29:24Z")

</div>

Hello,  
after writing a script with pyroot that runs as intended on my local machine, I have problems running it on lxplus. I essentially want to draw all histograms in a given directory inside a file. To get the `name`s of the histograms inside the given path I use and then accessing these histograms I do:

```auto
for key in file.Get(path).GetListOfKeys():
        complete_path = path+"/"+key.GetName()
        hist = file.Get(complete_path)

```

As I said, this works on my local machine, but on lxplus the first usage of `Get()` results in an error: `AttributeError: 'TObject' object has no attribute 'GetListOfKeys'`. I can prevent that by using `GetDirectory()` instead of `Get()`, however than the second usage of `Get()` only gives me a null pointer for `hist`. The histogram I am trying to access exists, so I am not sure why I get a null pointer.  
I am thankful for any advice. Below you find the information of the used root versions as shown on the opening message.  
Cheers!

* * *

**On lxplus:**  
ROOT 6.24/06  
Built for linuxx8664gcc on Sep 02 2021, 14:20:23  
From tags/v6-24-06@v6-24-06  
With c++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)

**Local:**  
ROOT 6.24/06  
Built for linuxx8664gcc on Sep 03 2021, 23:37:00  
From tag , 1 September 2021  
With

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [March 7, 2022, 9:06am UTC](https://root-forum.cern.ch/t/get-on-lxplus/49035/2 "2022-03-07T09:06:04Z")

</div>

Hello,

I believe the error you get means that `file.Get(path)` is not a valid path in the file. Can you double check the path with which the file is created is correct and that the path you want to get in the file is also correct?

Cheers,  
Enric

---

<div class="post-metadata">

**Author:** ![Wurzel](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/e9a140/32.png) [@Wurzel](https://root-forum.cern.ch/u/Wurzel)\
**Post date:** [March 7, 2022, 11:32am UTC](https://root-forum.cern.ch/t/get-on-lxplus/49035/3 "2022-03-07T11:32:53Z")

</div>

Hello Enric,

using `for key in file.GetDirectory(path).GetListOfKeys():` I can extract the correct names of the histograms I want to get, so my script seems to be able to see these. I also double checked manually using a TBrowser that the path/histograms exist. What is weird to me is, that the script runs fine on my local machine. I only get this strange behaviour when I copy all the files on lxplus and run the script.

Cheers!

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [March 7, 2022, 12:13pm UTC](https://root-forum.cern.ch/t/get-on-lxplus/49035/4 "2022-03-07T12:13:49Z")

</div>

When you are on lxplus, can you run:

```auto
file = ROOT.TFile(...)
d = file.GetDirectory(path)
print(d)

```

What does it print?

---

<div class="post-metadata">

**Author:** ![Wurzel](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/e9a140/32.png) [@Wurzel](https://root-forum.cern.ch/u/Wurzel)\
**Post date:** [March 7, 2022, 12:19pm UTC](https://root-forum.cern.ch/t/get-on-lxplus/49035/5 "2022-03-07T12:19:50Z")

</div>

With `path = "TrigTauRecMerged_TauCaloOnlyMVA"` it prints:  
Name: TrigTauRecMerged\_TauCaloOnlyMVA Title: TrigTauRecMerged\_TauCaloOnlyMVA  
So the path is valid, right?

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [March 8, 2022, 5:29pm UTC](https://root-forum.cern.ch/t/get-on-lxplus/49035/6 "2022-03-08T17:29:27Z")

</div>

It seems ok, then after `print(d)`, can you run `print(d.GetListOfKeys())`?

---

<div class="post-metadata">

**Author:** ![Wurzel](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/e9a140/32.png) [@Wurzel](https://root-forum.cern.ch/u/Wurzel)\
**Post date:** [March 8, 2022, 7:57pm UTC](https://root-forum.cern.ch/t/get-on-lxplus/49035/7 "2022-03-08T19:57:39Z")

</div>

A THashList gets printed:

{ @0x7fffdefa7950, @0x7fffdefa7940, … }

It is of length 35, the number of histograms in this path. It continues with the repetition of the second hash 0x7fffdefa7940. Since I can’t “@” more than two people in a post I was not able to include the whole output. But again, it is just a repetition of the second hash.

---

<div class="post-metadata">

**Author:** ![Wurzel](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/e9a140/32.png) [@Wurzel](https://root-forum.cern.ch/u/Wurzel)\
**Post date:** [March 8, 2022, 11:40pm UTC](https://root-forum.cern.ch/t/get-on-lxplus/49035/8 "2022-03-08T23:40:30Z")

</div>

Thank you for your ideas and your time @etejedor. While my local machine uses python 3.9.10, lxplus uses 2.7.5. The variable `complete_path` I showed in my original post is of type string on my local machine, but of type unicode on lxplus. This seemed to be the problem. So after conversion to string: `complete_path = str(path+"/"+key.GetName())` my script finally runs on lxplus as well.
