Drawing the histogram

Hello there.
I tried to drawing the histogram from ROOT file by this code:

myFile = ROOT.TFile.Open(“/home/erg/po_1_event/Oct13070311.root”)
Tree = myFile.Get(“FADCData 882”)
ch0 = Tree.GetBranch(“Channel0”)
ch0.Draw()

But it causes a message:
Info in TCanvas::MakeDefCanvas: created default TCanvas with name c1

_ROOT Version: 6.26/10
_Platform: Ubuntu
_Compiler: Pycharm community


This message if fine.
You should see the “c1” canvas displayed.

Hi @Fredrih ,

Your question is ambiguous as I do not understand what you expect to happen.

1

The message you report

Info in TCanvas::MakeDefCanvas: created default TCanvas with name c1

Is not worrying at all. In fact, this is what happens everytime the default canvas is drawn. Info is different from Error. So, what is your problem with this message?

2

ch0 = Tree.GetBranch(“Channel0”)
ch0.Draw()

What do you expect this function to do?

3

I am going to guess from the overall look of your message that you would like to fill a histogram with the contents of the branch Channel0, create a canvas and draw that histogram on the canvas.

If this is correct, isn’t rootbrowse a faster alternative for you?

  1. Open the browser with rootbrowse on the command line
  2. Double click on the root file you want to open
  3. Double click on the branch you want to draw
1 Like

An other way …

File ch0Draw.C

void ch0Draw() {
   auto C = new TCanvas();
   auto myFile = new TFile("/home/erg/po_1_event/Oct13070311.root");
   TTree  *Tree = (TTree*) myFile.Get("FADCData 882");
   if (Tree) Tree->Draw("Channel0");
   else      cout << "unknown TTree" << endl;
}
$ root ch0Draw.C
1 Like
  1. It just seemed like it meant an error in the code.

  2. I expect to see the histogram of Channel0 content.

  3. I’ve already used rootbrowse, but I can’t make a fit there. We need to make a Gauss fit.

I do not have your root file so lets try with the hsimple.root file automatically attached in my rootlogon.C:

root [0] ntuple->Draw("px")
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
root [1] htemp->Fit("gaus")
 FCN=71.4322 FROM MIGRAD    STATUS=CONVERGED      62 CALLS          63 TOTAL
                     EDM=2.96417e-12    STRATEGY= 1      ERROR MATRIX ACCURATE 
  EXT PARAMETER                                   STEP         FIRST   
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE 
   1  Constant     1.02100e+03   7.91385e+00   2.68728e-02  -3.03194e-07
   2  Mean        -3.32122e-03   6.30168e-03   2.61872e-05   1.08727e-04
   3  Sigma        9.93715e-01   4.45079e-03   5.05416e-06  -1.78161e-03
(TFitResultPtr) <nullptr TFitResult>
root [2] 

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