# Best way to get the leading and subleading photons in a prompt photon process

**URL:** <https://root-forum.cern.ch/t/best-way-to-get-the-leading-and-subleading-photons-in-a-prompt-photon-process/53664>\
**Category:** Newbie\
**Tags:** tree, root\
**Created:** [February 17, 2023, 9:03am UTC](https://root-forum.cern.ch/t/best-way-to-get-the-leading-and-subleading-photons-in-a-prompt-photon-process/53664 "2023-02-17T09:03:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raseeb\_Haroon](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/raseeb_haroon/32/30638_2.png) [@Raseeb\_Haroon](https://root-forum.cern.ch/u/Raseeb_Haroon)\
**Post date:** [February 17, 2023, 9:03am UTC](https://root-forum.cern.ch/t/best-way-to-get-the-leading-and-subleading-photons-in-a-prompt-photon-process/53664/1 "2023-02-17T09:03:20Z")

</div>

I am using Pythia8 to generate prompt photon processes. I am sure what is the way and if there are better tools within root itself to sort photons with the 3 highest pT and Energies for each event. Any help in the right direction would be greatly appreciated.

ROOT Version: 6.26/06  
Platform: Ubuntu 22.04.1  
Compiler: g++

* * *

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [February 21, 2023, 2:36pm UTC](https://root-forum.cern.ch/t/best-way-to-get-the-leading-and-subleading-photons-in-a-prompt-photon-process/53664/2 "2023-02-21T14:36:37Z")

</div>

Hi @Raseeb_Haroon ,

the answer depends a bit on what you want to do with the leading and subleading photons (e.g. fill a histogram with their pt?).

In general something like that would be done by writing a program that processes the generated data, for example with [RDataFrame](https://root.cern/doc/master/classROOT_1_1RDataFrame.html) – tutorials can be found [here](https://root.cern/doc/master/group __tutorial__ dataframe.html). Per event, you can specify that you want to `Redefine` the column of photon pts as its sorted version, or `Define` a new column that contains only the 3 highest pts that you can then use to fill a histogram with `Histo1D`.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![Raseeb\_Haroon](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/raseeb_haroon/32/30638_2.png) [@Raseeb\_Haroon](https://root-forum.cern.ch/u/Raseeb_Haroon)\
**Post date:** [February 23, 2023, 4:51am UTC](https://root-forum.cern.ch/t/best-way-to-get-the-leading-and-subleading-photons-in-a-prompt-photon-process/53664/3 "2023-02-23T04:51:54Z")

</div>

Thank you for your reply.
