-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.
tree_reduce
: allow redefininition of existing variables (very …
…useful for `tmva/chopping`) (only for 6.26<=ROOT
- Loading branch information
1 parent
fca086c
commit 0f9bfcc
Showing
2 changed files
with
12 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
# @author Vanya BELYAEV [email protected] | ||
# @date 2018-06-16 | ||
# ============================================================================= | ||
"""Helper module to ``reduce'' tree using frames | ||
"""Helper module to `reduce' tree using frames | ||
- see Ostap.DataFrame | ||
- see ROOT.ROOT.RDataFrame | ||
""" | ||
|
@@ -34,7 +34,7 @@ | |
if '__main__' == __name__ : logger = getLogger( 'ostap.frames.tree_reduce' ) | ||
else : logger = getLogger( __name__ ) | ||
# ============================================================================= | ||
logger.debug ( "``Reduce'' TTree using ROOT::RDataFrame object") | ||
logger.debug ( "`Reduce' TTree using ROOT::RDataFrame object") | ||
# ============================================================================= | ||
## @class ReduceTree | ||
# Reduce TTree object using intermediate (temporary | ||
|
@@ -63,7 +63,7 @@ def __init__ ( self , | |
tmp_keep = False , ## keep the temporary file | ||
silent = False ): ## silent processing | ||
|
||
from ostap.frames.frames import DataFrame, frame_prescale | ||
from ostap.frames.frames import DataFrame, frame_prescale, frame_columns | ||
frame = DataFrame ( chain ) | ||
report = None | ||
|
||
|
@@ -80,13 +80,18 @@ def __init__ ( self , | |
## add overall prescale (if requested) | ||
if 1 != prescale : | ||
frame = frame_prescale ( frame , prescale ) | ||
|
||
|
||
avars = set ( frame_columns ( frame ) ) | ||
nvars = [] | ||
## new variables | ||
for nv in new_vars : | ||
frame = frame.Define ( nv , new_vars [ nv ] ) | ||
if ( 6 , 26 ) <= root_info and nv in avars : | ||
frame = frame.Redefine ( nv , new_vars [ nv ] ) ## REDEFINE!!! | ||
else : | ||
frame = frame.Define ( nv , new_vars [ nv ] ) | ||
nvars.append ( nv ) | ||
|
||
avars.add ( nv ) | ||
|
||
from ostap.core.ostap_types import ( string_types , | ||
listlike_types , | ||
dictlike_types ) | ||
|