kajal
August 1, 2016, 2:08pm
1
Hello,
I am plotting two erf functions and corresponding histogram by generating random numbers. I want your help to understand if it is possible to know the overlap ratio or value…
I am writing below how I am plotting the erf functions and its histograms:
TF1 f4(“f4”, “975*TMath::Abs(TMath::Erf((x-1.5)/0.197)-TMath::Erf((x-2.3)/0.197))”, 0.0, 5.4);
f4->Draw();
TF1 f5(“f5”, “975*TMath::Abs(TMath::Erf((x-2.3)/0.197)-TMath::Erf((x-3.1)/0.197))”, 0.0, 5.4);
f5->Draw(“same”);
TH1F *h1 = new TH1F(“h1”, “crystal1”, 60, 1.2, 4.2);
h1->FillRandom(“f4”, 20000);
h1->Draw(“same”);
TH1F *h2 = new TH1F(“h2”, “crystal1”, 60, 1.2, 4.2);
h2->FillRandom(“f5”, 20000);
h2->Draw(“same”);
I will be glad to have some suggestions.
Thank you.
Regards,
Kajal
What is an “overlap ratio or value”?
kajal
August 1, 2016, 3:11pm
3
Hello,
I want to know the area between the two functions.
Regards,
Kajal
I don’t really know what you want to achieve, but try: [code] TF1 f45a(“f45a”, “(f4 < f5) ? f4 : f5”, 0.0, 5.4);
std::cout << f45a.Integral(0.0, 5.4) << std::endl;
TF1 f45b(“f45b”, “(f4 > f5) ? f4 : f5”, 0.0, 5.4);
std::cout << f45b.Integral(0.0, 5.4) << std::endl;
std::cout << f4.Integral(0.0, 5.4) + f5.Integral(0.0, 5.4) - f45a.Integral(0.0, 5.4) << std::endl;
TF1 f45c(“f45c”, “f4 * f5”, 0.0, 5.4);
std::cout << f45c.Integral(0.0, 5.4) << std::endl;
TH1F h12 = ((TH1F )(h1->Clone(“h12”)));
h12->Multiply(h2);
std::cout << h12->Integral(“width”) << std::endl;[/code]
kajal
August 2, 2016, 6:53am
5
Hello Pepe Le Pew,
I just want to calculate the area where the two curves overlap.
Thank you.
Regards,
Kajal
plot.ps (7.49 KB)
So, it seems that you want “f45a.Integral(0.0, 5.4)” from my previous post here.
If you want to play the same game with your histograms (i.e. “h1” and “h2”), see: viewtopic.php?f=3&t=22186&p=97166#p97166