Question about TH1F

root [8] TH1F *hist=new TH1F("tt","tt",1000,-1,1);
root [9] tree->Draw("nbdt>>hist","track.rgt2[0]/rich.beta*::TMath::Sqrt(1-rich.beta*rich.beta)<-1.5&&track.rgt2[0]/rich.beta*::TMath::Sqrt(1-rich.beta*rich.beta)>-2&&nbdt>-8")
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
(long long) 36313
root [10] hist->Draw()
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1

I redirect the drawing to hist, however, hist is empty, why?

Hello,

Can you try to repeat the operation with no selection, and then incrementally add cuts?
Moreover, please consider using RDataFrame for this kind of operations: it is intuitive, performant and well supported and your productivity might increase!

Cheers,
D

Hi,
I repeat it with no selection:
root [7] TH1F *hist=new TH1F()
(TH1F *) 0x4b14c40
root [8] Int_t a=tree->Draw(“nbdt>>hist”,“”,“goff”)
(int) 6940509
root [9] hist->GetEntries()
(double) 0.0000000
root [10]
There is still something wrong.

Try with:

   TH1F *hist=new TH1F("tt","tt",1000,-1,1);
   tree->Draw("nbdt>>tt","","goff")

Or:

   TH1F *hist=new TH1F("hist","tt",1000,-1,1);
   tree->Draw("nbdt>>hist","","goff")

Thank you, it works. It seems that the redirect method looking forward to the name of hist instead of the pointer :smiley:

1 Like

Thanks @bellenot ! I did not see that, my bad. Indeed it cannot see the name of the C++ variable, however, the name of the ROOT object yes, it’s registered.

Glad to see you can move forward!

2 Likes