# Count of data points greater than a threshold

**URL:** <https://root-forum.cern.ch/t/count-of-data-points-greater-than-a-threshold/44245>\
**Category:** Newbie\
**Created:** [March 31, 2021, 7:04pm UTC](https://root-forum.cern.ch/t/count-of-data-points-greater-than-a-threshold/44245 "2021-03-31T19:04:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rootNewbie](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rootnewbie/32/25428_2.png) [@rootNewbie](https://root-forum.cern.ch/u/rootNewbie)\
**Post date:** [March 31, 2021, 7:04pm UTC](https://root-forum.cern.ch/t/count-of-data-points-greater-than-a-threshold/44245/1 "2021-03-31T19:04:56Z")

</div>

I have a .root file where I have written the energy deposited in an ntuple but i need to know how many data points are greater than a specific value. How can I determine this?

---

<div class="post-metadata">

**Author:** ![rootNewbie](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rootnewbie/32/25428_2.png) [@rootNewbie](https://root-forum.cern.ch/u/rootNewbie)\
**Post date:** [March 31, 2021, 7:34pm UTC](https://root-forum.cern.ch/t/count-of-data-points-greater-than-a-threshold/44245/2 "2021-03-31T19:34:12Z")

</div>

I apologize if this question seem very basic. I tried various methods but didn’t find a solution with ROOT. Perhaps the only way is to use g4csv method to output a csv file instead of a root file?

---

<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:** [March 31, 2021, 7:34pm UTC](https://root-forum.cern.ch/t/count-of-data-points-greater-than-a-threshold/44245/3 "2021-03-31T19:34:52Z")

</div>

Maybe something like this (assuming “Energy” is the leaf that keeps the “energy deposited”):

```cpp
Double_t thr = 100.; // set to whatever value you need
Long64_t n = YourTTree->GetEntries(TString::Format("Energy > %.17g", thr));

```

or simply:

```cpp
Long64_t n = YourTTree->GetEntries("Energy > 100."); // any value you need

```

---

<div class="post-metadata">

**Author:** ![rootNewbie](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rootnewbie/32/25428_2.png) [@rootNewbie](https://root-forum.cern.ch/u/rootNewbie)\
**Post date:** [March 31, 2021, 7:58pm UTC](https://root-forum.cern.ch/t/count-of-data-points-greater-than-a-threshold/44245/4 "2021-03-31T19:58:25Z")

</div>

Thank you so much! This worked easily!!
