AIDASoft / podio

PODIO
GNU General Public License v3.0
24 stars 59 forks source link

how to retrieve the cell ID encoding from the metadata in the output ROOT file #537

Open atolosadelgado opened 8 months ago

atolosadelgado commented 8 months ago

Hi,

The following piece of code shows how to retrieve the cell ID encoding (as string) from the metadata in the output ROOT file

import podio
podio.root_io.Reader("test.root")
metadata = reader.get("metadata")[0]

cellid_encoding = metadata.get_parameter("ArcCollection__CellIDEncoding")

I think this is missing in the examples/documentation, but Thomas answered promptly. I think it is worth to include it :)

Best, Alvaro

jmcarcell commented 8 months ago

You can make a PR to the key4hep documentation where you consider it would be useful :smiley: ; for the podio documentation you can at most add how to get parameters if it's not already there but the cell encoding being in the metadata category (and the metadata category existing) are conventions from elsewhere.

tmadlener commented 8 months ago

I think this specific bit should / could go to https://github.com/key4hep/key4hep-tutorials/blob/main/edm4hep_analysis/edm4hep_api_intro.md although it does not fit completely there(?)

In general we might want to think about a slightly nicer interface that doesn't depend on too much inside knowledge, e.g. we have the https://github.com/AIDASoft/podio/blob/master/include/podio/FrameCategories.h#L23C20-L23C41 function to stitch together the collection name and the parameter name, and I think also having the [0] index could be improved.