I have a TTree in a file which contains signals obtained from an oscilloscope.
I can draw traces with
for example, since the events have a unique index stored in the tree. The signals are stored as [1024]/F in the tree.
I would like to be able to draw what I mean when I try:
mytree->Draw("TMath::Mean(1024,V3)"),
namely, draw the histogram of the average voltage per event. But I get an error:
Any ideas about how to use the very nice tree drawing function to do this (or other TMath functions that operate on arrays)?
Incidentally, why is there no TMath::Sum() function to return the sum of all values in an array? I’ll need to use TMath::Mean(1024,V4)*1024. Given the plethora of convenience functions in TMath, I expected a Sum().
Thanks, that’s exactly what I was looking for. Is there a good reference page for examples of TTreeFormula usage? The page at http://root.cern.ch/root/html/TTreeFormula.html is not very pedagogical.
For the use of objects of type TTreeFormula, there is no specific documentation, looking at the implementation of root.cern.ch/root/html/TTreePlay … layer:Scan is usually a good start.
A more advanced usage question now. I might be pushing the limits of TTree->Draw()'s abilities.
I have a branch in a tree which is an array of integers, represending the wires hit by particle showers, with -1 being a default value meaning no wire hit. In particular, the numbers are a wire ID number, the array index itself would be the particle shower ID number.
I would like to draw a histogram of the number of hits on a particular wire number, event-by-event. E.g., for each entry in the tree, how many times does ‘15’ show up in the array.
I tried doing:
but I’m pretty sure that doesn’t do what I actually want, given that the x axis ends up going way past typical wire ID numbers. Any idea what it’s doing in this case? How is wire_hit == 15 not giving an error, what is it comparing exactly?
Then I tried:
as per the recommendation for implementing a ternary operator deep in the bowels of the TTree:Draw%2 page that you linked. It appears to do what I want, but I was hoping to have a second opinion, since this looks extremely easy to mess up, given the other example above.