Removing outliers using residuals


I am having a set of data not very clean, despite all cuts I made, there are stil few remaining which are ruining my fit.
Here is what I am doing, I set different cuts and produce a a first set of clean tree set of data.
I want to do the fit, do the residuals, and if the residuals are too big, remove those data from the tree and re-run the fit of the second clean data.
Is this possible? Does anyone has an example or a link to an already solved case?


You cannot remove data from an existing tree. You can add new “strict” / “tight” cuts in the “selection” (when creating your histograms) and then redo the fit.

Hmm, yes I can do more strict cut and create a new root tree file, but the problem is that those out liars are coming randomly.
I was wondering if one can just choose the good fit interval, and disregard the bad out liars after visual inspections, without having to create a new root tree.
Looks complicated my question?
thanks for any help

You do not need to create any new trees. Each Draw, Project, and some Fit methods provide a “selection” parameter.

If the problem is just to shrink the fit function’s range then, use e.g. TF1::SetRange and the “R” fit option.