# GetEntries selection string help

**URL:** <https://root-forum.cern.ch/t/getentries-selection-string-help/40191>\
**Category:** Newbie\
**Created:** [July 2, 2020, 1:28am UTC](https://root-forum.cern.ch/t/getentries-selection-string-help/40191 "2020-07-02T01:28:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![asanch25](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/asanch25/32/20206_2.png) [@asanch25](https://root-forum.cern.ch/u/asanch25)\
**Post date:** [July 2, 2020, 1:28am UTC](https://root-forum.cern.ch/t/getentries-selection-string-help/40191/1 "2020-07-02T01:28:51Z")

</div>

I need some help using the GetEntries command in root. I have a root file with 3 million entries in a tree named “store” and I know that by using the command

```auto
store->GetEntries(“x_det>-100”)

```

Root will return the number of entries that fit these criteria. But with the data set I have I need to put this statement in a loop so that I have something like

```auto
store->GetEntries(“x_det>-100 && x_det <10”)
store->GetEntries(“x_det>-100 && x_det <9.5”)
etc.

```

So my first test was to see if I could define a string, named “selection”, that is defined as follows

```auto
string str = "\"x_det>-"+to_string(100)+"\"";
const char* selection = str.c_str();

```

And then have selection be the argument in GetEntries(). I’ve printed the selection string to the terminal and confirmed that it is “x\_det\>-100”, but putting it in the GetEntries just returns the number of entries in the whole tree, as opposed to the 2.4 million or so entries that fit the constraint that x\_det\>-100. So I was wondering if my approach was correct, or if there is an easier way to accomplish what I need.

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

* * *

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [July 2, 2020, 4:19am UTC](https://root-forum.cern.ch/t/getentries-selection-string-help/40191/2 "2020-07-02T04:19:51Z")

</div>

You can do it on different ways, but to keep your method, just don’t explicitly inlcude the quotes (\") in str.

---

<div class="post-metadata">

**Author:** ![asanch25](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/asanch25/32/20206_2.png) [@asanch25](https://root-forum.cern.ch/u/asanch25)\
**Post date:** [July 2, 2020, 5:08am UTC](https://root-forum.cern.ch/t/getentries-selection-string-help/40191/3 "2020-07-02T05:08:10Z")

</div>

That worked, thank you!
