I am trying to Project one branch to a histogram. And also need to set nbins for histogram.
Is there any easy way to get nbins when I just know the branch name? I tried the T->GetEntry()
, but it’s too slow.
Histogram: htemp=new TH1F(“bla”, nbins, 0, nbins);
Thanks in advance.
Could you explain precisely what you want?
When using TTree::Draw you can specify the number of bins and limits of the output histogram, eg
see doc of TTree::Draw for more details
root.cern.ch/root/html/TTreePlay … DrawSelect
The branch does not record the maximum value of their data set.
So in order to do what you want you will need to process the data twice.
For example something like:
Int_t xmax = htemp->GetXaxis()->GetXmax();
TH1F* htemp=TH1F("name", xmax,0, xmax);
You could also try to default behavior when extending the range of analysis by calling tree->SetEstimate(tree->GetEntries));