Skip to content

Commit

Permalink
fix cast in newer cppyy included in e.g. ROOT 6.32.08. See wlav/cppyy…
Browse files Browse the repository at this point in the history
  • Loading branch information
cozzyd committed Dec 5, 2024
1 parent 4eb8761 commit 07c2fcb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions py/mattak/backends/pyroot/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@

cppyy.cppdef(" bool is_nully(void *p) { return !p; }")

# this is needed for newer versions of cppyy to remain backwards compatible, due to changes in uint8_t handling
cppyy.cppdef(" uint8_t* cast_uint8_t(void * x) { return (uint8_t*) x; }")
cast_uint8_t = cppyy.gbl.cast_uint8_t

def isNully(p):
return p is None or ROOT.AddressOf(p) == 0 or cppyy.gbl.is_nully(p)

Expand Down Expand Up @@ -164,8 +168,9 @@ def _eventInfo(self, i : int) -> Optional[mattak.Dataset.EventInfo]:
# The `numpy.copy(...)`` is strictly necessary. Otherwise group access via `dataset.eventInfo()`
# results in the same `radiantStartWindows` for each event (only for the last event it is correct)
radiantStartWindows = numpy.copy(numpy.frombuffer(
cppyy.ll.cast['uint8_t*'](hdr.trigger_info.radiant_info.start_windows),
dtype='uint8', count=self.NUM_CHANNELS * 2).reshape(self.NUM_CHANNELS, 2))
cast_uint8_t(hdr.trigger_info.radiant_info.start_windows),
dtype='uint8', count=self.NUM_CHANNELS * 2).reshape(self.NUM_CHANNELS, 2))


readout_delay = numpy.copy(numpy.around(numpy.frombuffer(
cppyy.ll.reinterpret_cast['float*'](self.ds.radiantReadoutDelays()),
Expand Down

0 comments on commit 07c2fcb

Please sign in to comment.