I have a desktop digitizer system whose software (CoMPASS) produces ROOT files containing a TTree with a TArrayS branch for the waveform. I would like to draw and perform basic operations (e.g. integrals, smoothing) on these waveforms which, as far as I can tell, is best done using a histogram (TH1S).
So far I am filling the histogram using a loop over all elements of the TArray, code snippet below.
TArrayS *samples = new TArrayS();
Data_R->SetBranchAddress("Samples", &samples);
Data_R->GetEntry(0);
Int_t nsamples = samples->GetSize(); // all waveforms in file have the same length
TH1S *waveform = new TH1S("waveform", "waveform", nsamples, 0, nsamples);
for (int i==0; i<nsamples; i++){
waveform->SetBinContent(i, samples->GetAt(i));
}
My questions are:
- Can I visualize the waveforms directly from the TArray using a TTree->Draw() command?
- Is there a more straightforward or efficient way of filling the histograms from the TArrays?
- In general, does it make sense to store waveforms in a TArray instead of e.g. a TH1? I could see that for an acquisition software performance is more important than making the subsequent analysis easier.
A very similar question was posed previously (see TTree::Draw with TArrayS) but the workaround mentioned was never provided.
I’ve attached a short run file in case it is useful.
DataR_run_28.root (33.8 KB)
Thanks
Alan