void Many3DHistograms(int Nc, int N){ // Nc is the number of histograms I want to make, N is the ammount of bins on each axis per histogram int binsz=10*Nc; TCanvas * c16 = new TCanvas("c16","c16",600,400); gStyle->SetCanvasPreferGL(kTRUE); gStyle->SetOptStat(kFALSE); TH3I * Empty = new TH3I("Empty","Empty", N,0,N, N,0,N, binsz,0,5*Nc-2);//Represents the detector TH3I * h = new TH3I("h","Filled", N,0,N, N,0,N, binsz,0,5*Nc-2);//Represents the particles detected int Z[Nc]; //The distances between histograms for (int cc=0;ccFill(j,k,zc); if ((ii+1)%N==0){ j=j+1; k=0; } else{ k=k+1; } } for (int i=0; iRndm()); yc=N*(gRandom->Rndm()); h->Fill(xc,yc,zc); } } // ZOffset3D(h, 30); TExec *ex1 = new TExec("ex1","gStyle->SetPalette(0);"); TExec *ex2 = new TExec("ex2","gStyle->SetPalette(1);"); Empty->Draw("BOX2"); ex2->Draw(); h->Draw("BOX2Z SAME"); ex1->Draw(); } int N=10; int Nc=1; //Just one pair of histograms Many3DHistograms(Nc,N);