Skip to content

Accessing a TMap class #1069

Answered by jpivarski
Renal-Of-Loon asked this question in Q&A
Dec 14, 2023 · 2 comments · 8 replies
Discussion options

You must be logged in to vote

You used

d->WriteObject(parameters_, "parameters");

to write the parameters_ TMap in directory d with name "parameters". If parameters_ were a TObjString, I think you would be able to write that just as easily.

I just checked, and yes you can:

root [0] TFile* d = new TFile("tmp.root", "RECREATE")
(TFile *) 0x55ebe0364bb0
root [1] TObjString* parameters_ = new TObjString("hello")
(TObjString *) 0x55ebe19ad570
root [2] d->WriteObject(parameters_, "parameters")
(int) 95
root [3] d->Close()
>>> import uproot
>>> file = uproot.open("tmp.root")
>>> file["parameters"]
<TObjString 'hello' at 0x7fd911854c80>

So if instead of writing "hello", you wrote a JSON document, you'd be able to load that as…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
6 replies
@Renal-Of-Loon
Comment options

@jpivarski
Comment options

@Renal-Of-Loon
Comment options

@jpivarski
Comment options

Answer selected by Renal-Of-Loon
@Renal-Of-Loon
Comment options

@Renal-Of-Loon
Comment options

Comment options

You must be logged in to vote
2 replies
@jpivarski
Comment options

@JacekHoleczek
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants