Filling TTree in object loop with RDataFrame?


ROOT Version: 6.18
Platform: lxplus
Compiler: Not Provided


Hi,

I am wondering if there is a way to fill the tree object by object instead of event by event in RDataFrame.

For example, in “normal” ROOT, we used to fill in object loop before as follows:

for(int i = 0 ; i < jets.size(); i++){

tree.fill();
}

I am making a combination with RDataFrame.

Thank you very much for any help.

Regards,
Jieun

Hi,
please check this post about posting code.

You can Define, event by event, a column that is a vector of objects. Would that work?

Cheers,
Enrico

I mean, I already got the objects as a vector with Define and filled the tree using Snapshot event by event as a vector of objects.

If I print out the tree with Snaphot, I got this:

root [2] tree->Scan()
***********************************************
*    Row   * Instance *    signal *       mbb *
***********************************************
*        0 *        0 *         0 * 283.59848 * 
*        0 *        1 *         1 * 184.48533 * 
*        0 *        2 *         0 * 181.59184 * 
*        1 *        0 *         0 * 421.54138 * 
*        1 *        1 *         0 * 469.25665 * 
*        1 *        2 *         0 * 91.167800 * 
*        2 *        0 *         0 * 83.889991 * 

In this case, Row is the event.
But I would like to fill the tree object by object like this:

root [2] tree->Scan()
************************************************
*    Row   *    signal *     event *    nbjets *
************************************************
*        0 *         0 *       409 *         4 * 
*        1 *         0 *       409 *         4 *         
*        2 *         1 *       409 *         4 *        
*        3 *         0 *       409 *         4 *     
*        4 *         0 *       409 *         4 *         
*        5 *         0 *       409 *         4 *        
*        6 *         0 *       564 *         3 *     
*        7 *         0 *       564 *         3 * 
*        8 *         1 *       564 *         3 *      
*        9 *         0 *       646 *         3 *     
*       10 *         0 *       646 *         3 *      
*       11 *         0 *       646 *         3 *       
*       12 *         0 *       890 *         3 *        

Here, Row is the combination.

Do you have any good ideas?

Thank you very much,

Regards,
Jieun

Ah I see, that would require this feature, that has been proposed a few times and allows processing vector elements one after another disregarding event boundaries.

In the meantime, I think something like that is better done with the classic TTree interfaces.

Cheers,
Enrico

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.