Hi All,

```
TNtuple *ntuple = new TNtuple("basic","data from ascii","x:y:z");
ntuple->Fill(x,y,z)
```

filling in 1D, OK.

But, How might i fill (not Draw!) Ntuple in 2D ?

For example, I tried this one,

Of course, I got an error.

Cheers,

Ersel

Hi All,

```
TNtuple *ntuple = new TNtuple("basic","data from ascii","x:y:z");
ntuple->Fill(x,y,z)
```

filling in 1D, OK.

But, How might i fill (not Draw!) Ntuple in 2D ?

For example, I tried this one,

Of course, I got an error.

Cheers,

Ersel

TNtuple *ntuple = new TNtuple(â€śbasicâ€ť, â€śdata from asciiâ€ť, â€śx:zâ€ť);

ntuple->Fill(x, z);

No, your code shows two branches in 1D ntuple, being separated from each other, doesnâ€™t it ?

For example, for drawing ntuple, in 2D,

But i want to learn,in 2D, how to â€śfillâ€ť a branch of a ntuple !

Cheers,

Ersel

â€śx:y:zâ€ť is 3D (3 variables)

â€śx:zâ€ť is 2D (2 variables)

ok iâ€™ll try it. wait for itâ€¦

Is there an option to fill first x ,then y according to ntuple->Fill(x,y) ?

For example, I tried to fill ntuple for implementing the option above ;

```
if (hv==0) { ntuple->Fill(x);}
if(hv==1) {ntuple->Fill(x,y);}
```

but here filled x twice!

â€¦and also tried this one;

```
if (hv==0) { ntuple->Fill(x);}
if (hv==1) { ntuple->Fill(" ",y); }
```

of course, i got an error

I mean that, i look at option for TNtuple::Fill() Options, but i didnâ€™t found anything about what i mention above, Is there an option to provide a facility ?

If you have two completely independent variables then you should create two TNtuple objects (so, a â€ś1Dâ€ť TNtuple for each variable).

Or you could create a single â€ś2Dâ€ť TNtuple:

TNtuple *ntuple = new TNtuple(â€śntupleâ€ť, â€śHV and X/Yâ€ť, â€śhv:xyâ€ť);

if (hv==0) ntuple->Fill(hv, x);

if (hv==1) ntuple->Fill(hv, y);

1 Like