Why can't I save this 3D histograms?

There is this 3 dimensional quantity that I want to see, so I decided to use 3D histograms, looked up some examples and wrote what I needed, there’s no problem getting the data in the histograms, but when I try to save them, I get a single message:

Segmentation fault (core dumped)

which isn’t much to go on to fin d out what is the problem.

I stripped my code of everything, and I get the same message:

#include <iostream>

#include "TH3D.h"
#include "TFile.h"
//

using namespace std;

int main() 
{
  TFile* histos = new TFile("histos.root","recreate");

  int r = 1000;
  double limit = 10000;
  TH3D *hist_leading_position = new TH3D("hist_leading_position", "Position", r, -limit, limit, r, -limit, limit, r, -limit, limit);

  hist_leading_position->Fill(0.0,0.0,0.0);

cout<<"This will be printed, no problem so far"<<endl;
  
  histos->cd();
  hist_leading_position->Write();
  histos->Close();

cout<<"This won't be printed, the problem is in the previous lines"<<endl;

  return 0;
}

What is the problem?, what am I missing here?.

Thanks

The problem is the size of your histogram. Its size is 1GB . Histogram are memory resident objects. May be you should consider using THnSparse .

1 Like

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