How to apply Heavviside function

Dear Experts,

We are using one function Z= (1/N!)*(nV- (nv0)N)^N * H (V - Nv0).
where this Z is calculated for charge multiplicity, N

whose root form is “[0] * TMath::Power(([1] - [2] * x), x) / TMath::Gamma(x + 1.0)”.
We want to apply Heaviside function, H( V- Nv0) with condition that V> Nv0. Condition should be in such a way that when above situation ( V > N*v0) is true then answer should be 1 otherwise 0.
P. S : One another constraint we need is both V and v0 should have positive value.

Full program for the above situation with data file are attached:

ts.cxx (1.0 KB)
op161.dat (589 Bytes)

May be the solution of your problem is to use a function described by a piece of C++ code in which you will be able to apply the constraints you need. As illustrated here.

Thanks , i have tried this but purpose is still unsolved. Can anyone help in simpler way???

Can you post what you end up with ?


You can try something like (if using ROOT 6) :

auto myfunc = [](double *x, double *p){ return (p[1] > p[2]*x[0]) ? p[0] * TMath::Power((p[1] - p[root [5] ), x[0] )  / TMath::Gamma(x[0] + 1.0) : 0.0; };
TF1 f("f",myfunc, 8, 56,3);
  f.SetParNames("c", "nV", "nV0");
  f.SetParameter(0, 2.6e-7); // c (normalization constant)
  f.SetParameter(1, 10); // nV (= n * V)
  f.SetParameter(2, -0.25); // nV0 (= n * V0)
  f.SetLineColor(kRed); f.SetLineStyle(9);
  graph2.Fit(&f, "ME");


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.