Getting raw data from the histograms

I have generated several different histograms to get a general feel for the data that I am working with. I an unfortunitly not seeing certain characteristics in the histogram that I tought would be there. In a desperit attempt to see if the events are there but are just hidden in the scale I would like to get the value of the frequency for a given bin in the histogram. I have done some looking for stuff like this and have come up, not empty handed, but pretty close. Can somebody give me a quick hand here and point me in the right direction.

Hi prophecy,
Try calling the Print(“all”) method of the histogram - it prints the bin center and bin contents for all bins. Or try displaying the histogram with the TCanvas set to logy - that should tell if events are hidden in scale…

If you know which bin you are interested in, you can also use the TH1::GetBinContent(int bin_no) method.


The following is the output of ROOT trying these techniques.


  •                                     *
  •    W E L C O M E  to  R O O T       *
  •                                     *
  • Version 3.05/07 14 September 2003 *
  •                                     *
  • You are welcome to visit our Web site *
  •      [](            *
  •                                     *

FreeType Engine v2.1.3 used to render TrueType fonts.
Compiled for linux with thread support.

CINT/ROOT C/C++ Interpreter version 5.15.94, June 30 2003
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] TFile data = new TFile(“F_Wedge_Histograms.root”, “READ”);
root [1] TH1F histogram = (TH1F) data->Get(“SMT_F-Disk_Total_N”);
root [2] delete data;
root [3]
root [3] histogram->Print()
OBJ: TObject TObject Basic ROOT object
root [4] histogram->Print(“all”)
OBJ: TObject TObject Basic ROOT object
root [5]
root [5] histogram
(class TH1F
root [6]
root [6] int tmp_value = histogram->GetBin(1)

*** Break *** segmentation violation
Generating stack trace…
/usr/bin/c++filt: unknown demangling style `gnu-new-abi’
Root >


I created the ROOT file with the following code block.

TH1F *all_histogram_n = new TH1F(“SMT_F-Disk_Total_N”, “Total Population (N Side);ADC Counts from SVXII;Frequency of Occurance”, 260, 0, 260);

// Fill the histogram here

TFile *output = new TFile(“F_Wedge_Histograms.root”, “recreate”, “F_Wedge_Histograms”);


 Is there something that I am doing wrong on a more fundamental level here?



After doing some more goffing with it I got it to work.  Thank you guys for the quick help.  It is nice to see what you expected to see isn't it.   :smiley: