I have an XY map of event positions in a particle detector, and those events have dozens of variables which characterize them. Take energy, for instance: I can find the average energy of an event in a small region of the detector by making three TH2F's in ROOT:
TH2F* h_xy = new TH2F("h_xy","h_xy",100,-10,10,100,-10,10);
TH2F* h_xyw = new TH2F("h_xyw","h_xyw",100,-10,10,100,-10,10);
TH2F* h_avg = new TH2F("h_avg","h_avg",100,-10,10,100,-10,10);
I fill h_xy
with all of my events, distributed over xy. Each entry in the histogram is weighted to 1. Then, I fill h_xyw
with all of my events, weighted by the energy. Dividing h_xyw
by h_xy
gives the average energy per bin, which I put into h_avg
. I do all of this on the ROOT command line, so it's really easy to just:
tree->Draw("energy>>h_xy","","colz")
And then pull the information right out of the histograms. Next, I'd like to be able to plot the standard deviation of the weights in each bin, in addition to the average. I know I can do this by writing a compiled script, but I'm wondering if there's an easy way to do this command-line that I just haven't thought of.