Multiple projections to a 1D histogram from multiple files

I’m trying to project into a histogram (from a Tree) multiple times from different files.
It does not work, but seems to erase the histogram add each Project. Why?

It (re)creates an automatic temporary histogram called “htemp” (which is usually owned by the current canvas / pad).
You need to draw your projections in different canvases / pads or you need to “save” your projections in histograms with different names.

Thanks! You mean there is no way to actually add to a an existing histogram by projecting? I have to add up many histograms, one for each projection?

You can do it using, for example, something like this:

some_tree_1->Draw("some_leaf >> my_histo"); // (re)creates "my_histo"
some_tree_2->Draw("some_leaf >>+ my_histo"); // adds entries to "my_histo"
some_tree_3->Draw("some_leaf >>+ my_histo"); // adds entries to "my_histo"

Thanks. That way is more practical.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.