Hi Ida,
Try this:
// Start at 1 (not 0) as bin 0 is the underflow, you probably don't need it
for (Int_t i=1; i<myHist->GetNbinsX();i++) {
cout << i << " " << myHist->GetBinContent(i) << endl; }
If you need not the bin number but the value, replace 'i' with myHist->GetBinCenter(i).
Cheers
Eduard
On Tue, 27 Sep 2011, Ida Häggström wrote:
> Dear Rooters,
>
> I'm making a little script that stores data in a histogram. Now I want to
> save this data as a text file (to open in another program, e.g. Matlab) with
> bin in one column and number in a second column. I cannot really find any
> examples of this in the users guide... Is there a good way to do this? Below
> are some relevant pieces of my code. Thanks!
> /Ida
>
> ----------------------
> TH1F *myHist= new TH1F("myHist","Sensitivity",100,-200.,+200.);
>
> for (Int_t i=0; i<nentries;i++) {
> //Long loop...
> myHist->Fill(z);
> }
> ----------------------
>
Received on Tue Sep 27 2011 - 09:45:05 CEST
This archive was generated by hypermail 2.2.0 : Tue Sep 27 2011 - 17:50:02 CEST