mRDF: extend the RDF object#
- class mkShapesRDF.processor.framework.mRDF.mRDF[source][source]#
Bases:
objectPrivate version of RDataFrame that allows to define new columns, drop columns, and use Vary together with Snapshot.
Methods
Copy()Copy the
mRDFobjectCount()Count the number of events
Define(a, b[, excludeVariations])Define a new column, if the column already exists redefine it.
DropColumns(pattern[, includeVariations])Drop columns that match the given pattern
Filter(string)Filter the mRDF, the filter is sensitive to Variations through the use of
CUT, see the notes.GetVariationsForCol(column)Get the list of variations for a given column
GetVariedColumns(columns)Given a list of columns, return the varied columns for all variations and tags
GetVariedColumns_oneVariation(columns, ...)Given a list of columns, return the varied columns for a given variation and tag
Snapshot(*args, **kwargs)Produce a Snapshot of the mRDF and return it
Sum(string)Sum the values of a column
Vary(colName, expression[, variationTags, ...])Define variations for an existing column, given an expression
readRDF(*ar, **kw)Read the RDataFrame object and create the special column
CUTused to hold the different FilterssetNode(dfNode, cols, cols_d, variations)Set internal variables of an
mRDFobject to the provided onesvariationNaming(variationName, variationTag)Naming convention for variations.
GetColumnNames
GetVariations
Redefine
- df#
df stores the RDataFrame object
- cols#
cols stores the list of columns
- cols_d#
cols_d stores the list of columns that were dropped
- variations#
variations stores the list of variations
- static variationNaming(variationName, variationTag, col='')[source][source]#
Naming convention for variations.
Given a variation name and a tag it will return
variationName_variationTag. If a column name is provided, it will returncol__variationName_variationTag.
- setNode(dfNode, cols, cols_d, variations)[source][source]#
Set internal variables of an
mRDFobject to the provided ones
- readRDF(*ar, **kw)[source][source]#
Read the RDataFrame object and create the special column
CUTused to hold the different Filters
- Define(a, b, excludeVariations=[])[source][source]#
Define a new column, if the column already exists redefine it.
- Parameters:
- Returns:
mRDFThe
mRDFobject with the new column defined
Notes
If
excludeVariationsis[], the define expression (b) will be checked for all possible variations. If variations of the define expression are found, they will be defined for the new column as well (i.e. variedbwill be defined as variations ofa).
- Vary(colName, expression, variationTags=['down', 'up'], variationName='')[source][source]#
Define variations for an existing column, given an expression
- Parameters:
- Returns:
mRDFThe
mRDFobject with the variations defined
Notes
Varywill callDefineinternally to define a temporary variable that contains the varied expression. Since alsoDefinewill callVaryinternally, the user should be careful to not end up in an infinite loop!References
See the official
RDataFrame::Vary()documentation even if not used here (not compatible withSnapshot).Examples
When defining the same variation twice for different nominal variables, the tags must be the same (order does not matter)
>>> df = df.Vary("var", "var + 1", ["down", "up"], "var_JER_0") >>> df = df.Vary("var2", "var2 + 2", [ "up", "down"], "var_JER_0")
- Filter(string)[source][source]#
Filter the mRDF, the filter is sensitive to Variations through the use of
CUT, see the notes.Notes
If the filter expression contains a variable for which variation are already defined, the
CUTwill be varied accordingly. Only events that pass at least one of the variedCUT(or the nominal) will be considered.
- GetVariedColumns_oneVariation(columns, variationName, tag)[source][source]#
Given a list of columns, return the varied columns for a given variation and tag
- GetVariedColumns(columns)[source][source]#
Given a list of columns, return the varied columns for all variations and tags
- Parameters:
- columnslist of str
list of columns to search variations for
- Returns:
- list of str
List of varied columns for all variations and tags
- DropColumns(pattern, includeVariations=True)[source][source]#
Drop columns that match the given pattern
- Parameters:
- Returns:
mRDFThe
mRDFobject with the columns dropped
Notes
The columns from
self.colsmatching the pattern will be dropped and added toself.cols_d. IfincludeVariationsisTrue, the variations of the dropped columns will be dropped as well.
- Count()[source][source]#
Count the number of events
- Returns:
- Proxy<Long64_t>
The number of events (need to apply
GetValue()to get the actual value)
- Sum(string)[source][source]#
Sum the values of a column
- Parameters:
- string
str the column name
- string
- Returns:
- Proxy<Float_t>
The sum of the values of the column (need to apply
GetValue()to get the actual value)