Step function

Hello,

I would like to define a TF1 with a step function inside, like:
TF1 *f = new TF1(“f”, " sin(x)*theta(x-2)", -10, 10);
where theta is the typical step function: it returns 0 if (x-2)<0 and it returns 1 if (x-2)>0.

Unfortunately I have not found any step function in TMath neither in other libraries, but only TMath::Floor() and TMath:.Ceil().

Could you help me?

Many thanks

TF1 *f = new TF1(“f”, “((x > 2) ? sin(x) : 0)”, -10, 10);
TF1 *f = new TF1(“f”, “sin(x) * ((x > 2) ? 1 : 0)”, -10, 10); // safe in ROOT 6 only

Thanks! :slight_smile: