Remove an entry from an ntuple

Hi,
Can someone tell me how to remove an entry from an ntuple? More specifically, I want to remove those entries, where “shot_n==10”, for example.
Thanks

Hi,

This can only be done by copying the data to a new file. See $ROOTSYS/tutorials/tree/copytree*.C

Cheers,
Philippe.

It’s a petty. This is my attempt to make this. Can you give me a hint why it segfault? If I comment the line …SetBRanchAddress, then it runs without segfault (but of course if doesn’t make the job).
Thanks

Hi,

GetSize() returns the allocated size of the array and not the number of active entries (so from 2 and on you dereference null pointers)
Instead you should use GetEntries().

Humm … Also why did you elected to use Clone rather than the much more efficient CloneTree?

Also you can simplify you code by using TNtuple::GetArgs.

Here is a more efficient version of your code.

[code]

{
TNtuple *ntuple = new TNtuple(“ntuple”,“ntuple”,“x:y”);
ntuple.Fill(1,2);
ntuple.Fill(2,4);
ntuple.Fill(3,9);

TNtuple *ntuple_short = ntuple.CloneTree(0);
Float_t *vars = nuple->GetArgs()

for(int i=0; i<ntuple.GetEntries(); ++i)
{
ntuple.GetEntry(i);
if(fabs(vars[0]-2)>0.1) ntuple_short.Fill(vars);
}

delete ntuple;
ntuple = ntuple_short;
ntuple.Scan("*");
} [/code]

Cheers,
Philippe.