When I draw a branch from a TTree, i.e. : tree->Draw(“myBranch”), I appreciate that the default histogram will have 100 bins in it. And I know that I can do things like tree->Draw(“mybranch>>hnew(nbins,min,max)”). But what I want to know is if there is a way I can have the ttree check what data type the branch that it is drawing is (and even which specific branch I am asking it to draw), and select an appropriate binning convention?
To be incredibly specific, I have a branch in my TTree (call it ‘branch1’) that holds an unsigned int that I know will have values between 0 and 999. What I would like to do is have the default behaviour of tree->Draw(“branch1”) be to do: tree->Draw(“branch1>>htemp(1000,-0.5,999.5)”). This is so that the values in the branch correspond to the bin centers, and I have the full granularity available. If I had another branch, say, branch2, taking integer values between -5 and +5, I would like it equally to do by default tree->Draw(“branch2>>htemp(11,-5.5,5.5)”).
It’s ok if this means I have to load a macro before drawing my branches, essentially I want to be able to specify the number of bins, the min and max values for each branch in my ttree, and have the Draw() method pick that up by default.
Any suggestions of how to move towards what I am describing?