# How to calculate efficiency at a specific energy

**URL:** <https://root-forum.cern.ch/t/how-to-calculate-efficiency-at-a-specific-energy/39117>\
**Category:** Newbie\
**Tags:** root\
**Created:** [April 27, 2020, 9:40am UTC](https://root-forum.cern.ch/t/how-to-calculate-efficiency-at-a-specific-energy/39117 "2020-04-27T09:40:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [April 27, 2020, 9:40am UTC](https://root-forum.cern.ch/t/how-to-calculate-efficiency-at-a-specific-energy/39117/1 "2020-04-27T09:40:33Z")

</div>

I plotted the efficiency vs energy curve using a user defined function.  
Now, I am trying to calculate efficiency at specific values e.g. 200kev, 500kev, 700kev.  
How should I proceed further??  
I also tried tooltip Info but it only shows near values i.e. (198.91…)  
[efficiency\_R.C](https://root-forum.cern.ch/uploads/short-url/6Wykt2uXNd4WTjEwYwiA1mGrp77.C) (1.1 KB) [effvsE.txt](https://root-forum.cern.ch/uploads/short-url/lV2aHyEDVxzGSbyAPKZSrCMiFzP.txt) (219 Bytes)

 ![Efficiency](https://root-forum.cern.ch/uploads/default/original/3X/1/7/1741083fcc42cc59668fef2f73a55335ead61faf.png)

_ROOT Version:_ Not Provided  
_Platform:_ Not Provided  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [April 27, 2020, 9:43am UTC](https://root-forum.cern.ch/t/how-to-calculate-efficiency-at-a-specific-energy/39117/2 "2020-04-27T09:43:13Z")

</div>

[TF1::Eval](https://root.cern/doc/master/classTF1.html#ada14729afe8e4d63d07c28a71e0585d4)

---

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [April 27, 2020, 10:15am UTC](https://root-forum.cern.ch/t/how-to-calculate-efficiency-at-a-specific-energy/39117/3 "2020-04-27T10:15:05Z")

</div>

Thanks for responding @Wile_E_Coyote  
But I don’t know how to use it.  
Please help me!!

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [April 27, 2020, 10:31am UTC](https://root-forum.cern.ch/t/how-to-calculate-efficiency-at-a-specific-energy/39117/4 "2020-04-27T10:31:05Z")

</div>

[cplusplus.com -\> Tutorials -\> C++ Language -\> Classes (I)](https://www.cplusplus.com/doc/tutorial/classes/)

[LearnCpp.com -\> Basic object-oriented programming -\> Classes and class members](https://www.learncpp.com/cpp-tutorial/82-classes-and-class-members/)

---

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [April 27, 2020, 11:11am UTC](https://root-forum.cern.ch/t/how-to-calculate-efficiency-at-a-specific-energy/39117/5 "2020-04-27T11:11:49Z")

</div>

@Wile_E_Coyote  
I used this in my code to evaluate y at x = 500.  
But it is not giving the correct result.  
float a = 500., y;  
y=RT-\>Eval(a);  
cout \<\< "y = "\<\<y\<\<endl;

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [April 27, 2020, 1:05pm UTC](https://root-forum.cern.ch/t/how-to-calculate-efficiency-at-a-specific-energy/39117/6 "2020-04-27T13:05:58Z")

</div>

And what is your “correct result” because for me it prints “450.046” which looks fine (btw. use “double”, not “float”).

---

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [April 27, 2020, 1:20pm UTC](https://root-forum.cern.ch/t/how-to-calculate-efficiency-at-a-specific-energy/39117/7 "2020-04-27T13:20:15Z")

</div>

@Wile_E_Coyote Also after using double it prints y = 0.566104 at x = 500.  
which I don’t understand but your result is fine.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [April 27, 2020, 1:33pm UTC](https://root-forum.cern.ch/t/how-to-calculate-efficiency-at-a-specific-energy/39117/8 "2020-04-27T13:33:34Z")

</div>

But you do evaluate it after fitting?

---

<div class="post-metadata">

**Author:** ![robertfroast](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/robertfroast/32/21121_2.png) [@robertfroast](https://root-forum.cern.ch/u/robertfroast)\
**Post date:** [April 27, 2020, 1:56pm UTC](https://root-forum.cern.ch/t/how-to-calculate-efficiency-at-a-specific-energy/39117/9 "2020-04-27T13:56:24Z")

</div>

Thanks @Wile_E_Coyote.  
I got it correctly when I place it after fitting.
