TH3F help need

Hello, root community

I’m trying to draw momentum “hedgehog” of two body scattering problem.

here is code

[code]#include “TMath.h”

void Gen() {

//define initial 4-momentas
TLorentzVector target(0.0, 0.0, 0.0, 1.8);
TLorentzVector beam(0.0, 0.0, 0.71, 1.18);
TLorentzVector W = beam + target;

//(Momentum, Energy units are Gev/C, GeV)
//Masses of final-state particles
Double_t masses[2] = { 0.938, 1.8 };

//Define Decay for TGenPhaseSpace
TGenPhaseSpace event;
event. SetDecay(W, 2, masses);

TFile *scattering = new TFile(“histograms.root”,“RECREATE”);

TH3F *h5 = new TH3F(“hedgehog”, “Angle”, 1000, 0, 180, 1000, 0, 180, 1000, 0, 180);

for (Int_t n=0;n<100000;n++) {


TLorentzVector *pProton = event.GetDecay(0);
TLorentzVector *dDeuterium =  event.GetDecay(1);




And i’m getting this error

.../test.cpp:30:9: error: 'Fill' is a protected member of 'TH3' h5->Fill(dDeuterium->Mag()); ~~~~^~~~ .../ROOT/root-6.04.00/include/TH3.h:62:13: note: declared protected here Int_t Fill(Double_t); //MayNotUse

Hope someone will help me with this problem.

Thanks in advance

  1. You are trying to create a 3D histogram which will occupy at least 1000x1000x1000x4 bytes, which is about 3.7 GB RAM. That’s insane, if you ask me.
  2. A 3D histogram needs to be filled with 3 variables: “Some3DHisto->Fill(x, y, z);” or 4 variables if “weight” should not always be equal to 1: “Some3DHisto->Fill(x, y, z, weight);”.
  3. If you just want to use 1 variable (“dDeuterium->Mag()”), you need a simple 1D histogram: TH1F *h5 = new TH1F(“hedgehog”, “Angle”, 1000, 0, 180);