# Look at every n-th event

**URL:** <https://root-forum.cern.ch/t/look-at-every-n-th-event/53798>\
**Category:** Newbie\
**Created:** [February 27, 2023, 10:50am UTC](https://root-forum.cern.ch/t/look-at-every-n-th-event/53798 "2023-02-27T10:50:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![beg1nner](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/d26b3c/32.png) [@beg1nner](https://root-forum.cern.ch/u/beg1nner)\
**Post date:** [February 27, 2023, 10:50am UTC](https://root-forum.cern.ch/t/look-at-every-n-th-event/53798/1 "2023-02-27T10:50:25Z")

</div>

Dear experts,  
I am wondering if it is possible to somehow look at every 10th event after particular cut using RDataFrame?  
What I basically want to happen is having some pT cut and if pT is more than 45, then look at only every 10th event with pT \> 45. And if the pT is less than 45, then I look at every event.  
Thank you!

---

<div class="post-metadata">

**Author:** ![beg1nner](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/d26b3c/32.png) [@beg1nner](https://root-forum.cern.ch/u/beg1nner)\
**Post date:** [February 27, 2023, 12:05pm UTC](https://root-forum.cern.ch/t/look-at-every-n-th-event/53798/2 "2023-02-27T12:05:10Z")

</div>

I got an advice from C++ experts to include event adapter, however this seems to be too much complicated. Maybe there is some easier way together with ROOT? You usually helped me out, @eguiraud or @vpadulan, maybe you have some advice regarding this? Sorry for tagging you here. Thanks!

---

<div class="post-metadata">

**Author:** ![vpadulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/vpadulan/32/25315_2.png) [@vpadulan](https://root-forum.cern.ch/u/vpadulan)\
**Post date:** [February 27, 2023, 7:12pm UTC](https://root-forum.cern.ch/t/look-at-every-n-th-event/53798/3 "2023-02-27T19:12:17Z")

</div>

Hi @beg1nner ,

My personal opinion is that your case does not really fit in the columnar logic that should be adopted with RDataFrame. Nonetheless, I think a starting point for you could be leveraging [ROOT::RDF::RResultPtr::OnPartialResult](https://root.cern/doc/master/classROOT_1_1RDF_1_1RResultPtr.html#a2c6dac921e5423de9d3583215cee7de9), which allows you to pass a callable that gets executed every N events while computing a particular result.

I’m attaching the following example that might give you some inspiration:  
[test.cpp](https://root-forum.cern.ch/uploads/short-url/y1fwv9yMRu8oz5PU5cECgehg4cd.cpp) (1.5 KB)

There might be other ways, this is the fastest that came to mind.  
Cheers,  
Vincenzo
