Skip to content

Addition of CellIDDecoder utility #462

@tmadlener

Description

@tmadlener

This is a discussion topic to figure out what we want to do in this area, and eventually also how we would go about that.

Introduction

In LCIO there is the CellIDDecoder utility that allows to easily retrieve the encoded values from the cellID. This utility handles

  • Retrieving the cell id encoding string from the collection (stored via parameters)
  • parsing the string and splitting it into the different bits
  • retrieving the specific value for one of the encoded cells, e.g.
const auto& fields = decoder(hit);
const auto layer = fields["layer"];

Very similar functionality is available from DD4hep, with the BitFieldCoder.

Current status in EDM4hep

The LCIO CellIDDecoder is very much geared towards LCIO, as it relies on the fact that collection parameters are direcly attached to the collection. The DD4hep BitFieldCoder instead can be constructed from the encoding string.

The following is currently possible (using python here, but c++ works very much the same)

from podio.reading import get_reader
from dd4hep.core.DDSegmentation import BitFieldCoder

reader = get_reader("<input-file>")
metadata = reader.get("metadata")
metadata = metadata[0]  # Working around https://github.com/AIDASoft/podio/issues/642
cell_id_encoding = metadata.get_parameter(f"{collection_name}__CellIDEncoding")

decoder = BitFieldCoder(cell_id_encoding)

events = reader.get("events")
event = events[0]
hits = event.get("hits")

layer = decoder.get(hits[0].getCellID(), "layer")

# or slightly more performant in tight loops
layer_index = decoder.index("layer")
layer = decoder.get(hits[0].getCellID(), layer_index)

Things that should / could be improved

The following is a preliminarly list of things that could or maybe should be improved. IMO, some of them should definitely happen, others are much more open for discussion.

Finally, one thing that is not yet clear to me: How should all of this work inside the framework?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions