Hello,
I am new programmer and have a question about the optimal way to store my data in root. Here is the simplified situation:
I have many events. Each event can have up to N pulses. I would like to store some parameters about each pulse on a “per event” basis, as well as some data about the event as a whole. For example, each event has N pulses that each have an amplitude and time, and each event also has a trigger time.
Right now, the data is stored on a “per pulse” basis in TNuple:
The algorithm then iterates through each event, and for each event, it iterates through the number of pulses in the event.
The result is a repetition of the same event number in the TNtuple. The advantage to this method is that, if I want to see all the pulse data, I can say ntp.Draw(“pulseAmpltiude:pulseTime”). The disadvantage is that the data isn’t stored logically on a per event basis as one would expect.
So I am trying to use a TTree. In this case something like:
[code]struct Data{
int event;
float triggerTime;
std::vector pulseAmp;
std::vector pulseTime;
NtpData() : pulseAmp(5), pulseTime(5) {}
} fDataStruct;
fDataTree = new TTree(“fDataTree”, “fDataTree”);
fDataTree->Branch(“fDataStruct”, &fDataStruct, “event:triggerTime:pulseAmpltidue:pulseTime”);[/code]
The disadvantage to this method is that I can no longer visualize the data with the built-in Draw command from ROOT, since ROOT recognizes the leaves of the TTree as vectors and not the floats that are in the vectors.
I am wondering if there is a way to do what I would like: store all my data per event, but still be able to directly plot something like Draw(“pulseAmpltiude:pulseTime”).
If it matters: I am dealing with ~1e6 events, each with up to 8 pulses.
Thank you for your time.