I wrote a small toy montecarlo in order to estimate a solid angle. Everything works fine. But if I increase the number of simulation points to more than 10’000000 (takes 3min calculation time) root crashes and I always get the same error message:

Error: malloc failed for ptdir[anzahl][6]

Ptdir is a matrix: Float_t ptdir[anzahl][6];
Anzahl denotes the number of simulation points (rows) and 6 is the number of columns (3 for particle coordinates and 3 for particle direction) of the matrix ptdir.

How can I use more than these 10’000000 simulation points (I don’t want to take 10’000000 simulation points and then make a loop)

You need to allocate that memory on the heap instead of the stack.
So either use an stl container (for std::vector) or new you array:

Float_t *m = new Float_t[large_number];
std::vector<Float_t> m;Or look at the matrix package (in particular if your matrix is sparse).
Cheers,
Philippe

I also have another question:
How can I set the user range in x-direction?
More precisely: Let’s say I have data with x-values in the interval [3,10].
If I want to zoom in, for example from 5 to 7 then I can simply use

graph->GetXaxis()->SetRangeUser(5,7);

But how do I do it, if I want the Canvas to reach from let’s say 0 to 15?
SetRangeUser only works to zoom in. In y-direction the command:

graph->SetMinimum(…);
graph->SetMaximum(…);

works fine even if I want to have a Canvas reaching from 0 to 15 with data in the range [3,10].