diff options
author | Stan Seibert <stan@mtrr.org> | 2011-08-14 21:00:36 -0400 |
---|---|---|
committer | Stan Seibert <stan@mtrr.org> | 2011-08-14 21:00:36 -0400 |
commit | 9d61786d403a340d5ceb88b1c565cf0362c00580 (patch) | |
tree | d98e25d59c96cb2a4408beaaee17e287c9b080b5 /fileio | |
parent | 41dd4d2c85bb10f7fa17909709df6bccfe052340 (diff) | |
download | chroma-9d61786d403a340d5ceb88b1c565cf0362c00580.tar.gz chroma-9d61786d403a340d5ceb88b1c565cf0362c00580.tar.bz2 chroma-9d61786d403a340d5ceb88b1c565cf0362c00580.zip |
Add a helper function to the ROOT Channel class that will populate 3
arrays with hit information: hit or not, time and charge. Handy for
fetching all the hits in an event into numpy arrays.
Diffstat (limited to 'fileio')
-rw-r--r-- | fileio/root.C | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/fileio/root.C b/fileio/root.C index 24ed09a..9a959f5 100644 --- a/fileio/root.C +++ b/fileio/root.C @@ -48,6 +48,28 @@ struct Event { int nhit; std::vector<Channel> channel; + // Populate arrays of length nentries with hit, time, and charge + // information, indexed by channel ID + void get_channels(unsigned int nentries, int *hit, float *time, + float *charge) + { + for (unsigned int i=0; i < nentries; i++) { + hit[i] = 0; + time[i] = -1e9f; + charge[i] = -1e9f; + } + + for (unsigned int i=0; i < channel.size(); i++) { + unsigned int channel_id = channel[i].channel_id; + + if (channel_id < nentries) { + hit[channel_id] = 1; + time[channel_id] = channel[i].t; + charge[channel_id] = channel[i].q; + } + } + } + }; void fill_photons(Event *ev, bool start, |