![]() |
Belle II Software
release-05-02-19
|


Public Member Functions | |
| def | __init__ (self, *skims, NoisyModules=None, additionalDataDescription=None, udstOutput=None, mdstOutput=False, mdst_kwargs=None, CombinedSkimName="CombinedSkim", OutputFileName=None) |
| def | __str__ (self) |
| def | __name__ (self) |
| def | __call__ (self, path) |
| def | __iter__ (self) |
| def | load_standard_lists (self, path) |
| def | additional_setup (self, path) |
| def | build_lists (self, path) |
| def | output_udst (self, path) |
| def | output_mdst_if_any_flag_passes (self, *path, **kwargs) |
| def | apply_hlt_hadron_cut_if_required (self, path) |
| def | set_skim_logging (self) |
| def | flags (self) |
| def | flag (self) |
| def | initialise_skim_flag (self, path) |
| def | update_skim_flag (self, path) |
| def | produce_on_tau_samples (self) |
| def | merge_data_structures (self) |
| def | __description__ (self) |
| def | __category__ (self) |
| def | __authors__ (self) |
| def | __contact__ (self) |
| def | code (self) |
| def | validation_histograms (self, path) |
| def | __call__ (self, path, *udstOutput=None, validation=None) |
| def | postskim_path (self) |
| def | skim_event_cuts (self, cut, *path) |
| def | get_skim_list_names (self) |
Public Attributes | |
| Skims | |
| name | |
| TestFiles | |
| SkimLists | |
| mdst_kwargs | |
| OutputFileName | |
| additionalDataDescription | |
Static Public Attributes | |
| NoisyModules = None | |
| dictionary | MergeDataStructures = {} |
| bool | ApplyHLTHadronCut = False |
| bool | produce_on_tau_samples = True |
Private Member Functions | |
| def | _check_duplicate_list_names (self) |
| def | _method_unchanged (self, method) |
Private Attributes | |
| _udstOutput | |
| _mdstOutput | |
| _validation | |
Static Private Attributes | |
| list | __authors__ = ["Phil Grace"] |
| __description__ = None | |
| string | __category__ = "combined" |
| __contact__ = None | |
| _MainPath = None | |
| _ConditionalPath = None | |
Class for creating combined skims which can be run using similar-looking methods
to `BaseSkim` objects.
A steering file which combines skims can be as simple as the following:
.. code-block:: python
import basf2 as b2
import modularAnalysis as ma
from skim.foo import OneSkim, TwoSkim, RedSkim, BlueSkim
path = b2.Path()
ma.inputMdstList("default", [], path=path)
skims = CombinedSkim(OneSkim(), TwoSkim(), RedSkim(), BlueSkim())
skims(path) # load standard lists, create skim lists, and save to uDST
path.process()
When skims are combined using this class, the `BaseSkim.NoisyModules` lists of each
skim are combined and all silenced.
The heavy-lifting functions `additional_setup`, `build_lists` and `output_udst` are
modified to loop over the corresponding functions of each invididual skim. The
`load_standard_lists` method is also modified to load all required lists, without
accidentally loading a list twice.
Calling an instance of the `CombinedSkim` class will load all the required particle
lists, then run all the setup steps, then the list building functions, and then all
the output steps.
Definition at line 895 of file skimExpertFunctions.py.
| def __init__ | ( | self, | |
| * | skims, | ||
NoisyModules = None, |
|||
additionalDataDescription = None, |
|||
udstOutput = None, |
|||
mdstOutput = False, |
|||
mdst_kwargs = None, |
|||
CombinedSkimName = "CombinedSkim", |
|||
OutputFileName = None |
|||
| ) |
Initialise the CombinedSkim class.
Parameters:
*skims (BaseSkim): One or more (instantiated) skim objects.
NoisyModules (list(str)): Additional modules to silence.
additionalDataDescription (dict): Overrides corresponding setting of all individual skims.
udstOutput (bool): Overrides corresponding setting of all individual skims.
mdstOutput (bool): Write a single MDST output file containing events which
pass any of the skims in this combined skim.
mdst_kwargs (dict): kwargs to be passed to `mdst.add_mdst_output`. Only used
if ``mdstOutput`` is True.
CombinedSkimName (str): Sets output of ``__str__`` method of this combined skim.
OutputFileName (str): If mdstOutput=True, this option sets the name of the combined output file.
If mdstOutput=False, this option does nothing.
Definition at line 931 of file skimExpertFunctions.py.
|
inherited |
Produce the skim particle lists and write uDST file.
Parameters:
path (basf2.Path): Skim path to be processed.
udstOutput (bool): [DEPRECATED ARGUMENT] If True, add uDST output to the path.
validation (bool): [DEPRECATED ARGUMENT] If True, build lists and write
validation histograms instead of writing uDSTs.
Definition at line 648 of file skimExpertFunctions.py.
|
private |
Check for duplicate particle list names.
.. Note::
Skims cannot be relied on to define their particle list names in advance, so
this function can only be run after `build_lists` is run.
Definition at line 1225 of file skimExpertFunctions.py.
|
privateinherited |
Check if the method of the class is the same as in its parent class, or if it has been overridden. Useful for determining if *e.g.* `validation_histograms` has been defined for a particular skim.
Definition at line 810 of file skimExpertFunctions.py.
| def additional_setup | ( | self, | |
| path | |||
| ) |
Run the `BaseSkim.additional_setup` function of each skim.
Parameters:
path (basf2.Path): Skim path to be processed.
Reimplemented from BaseSkim.
Definition at line 1052 of file skimExpertFunctions.py.
| def apply_hlt_hadron_cut_if_required | ( | self, | |
| path | |||
| ) |
Run the `BaseSkim.apply_hlt_hadron_cut_if_required` function for each skim.
Parameters:
path (basf2.Path): Skim path to be processed.
Reimplemented from BaseSkim.
Definition at line 1136 of file skimExpertFunctions.py.
| def build_lists | ( | self, | |
| path | |||
| ) |
Run the `BaseSkim.build_lists` function of each skim.
Parameters:
path (basf2.Path): Skim path to be processed.
Reimplemented from BaseSkim.
Definition at line 1061 of file skimExpertFunctions.py.
|
inherited |
Eight-digit code assigned to this skim in the registry.
Definition at line 574 of file skimExpertFunctions.py.
| def flag | ( | self | ) |
Event-level variable indicating whether an event passes the combinedSkim or not.
Reimplemented from BaseSkim.
Definition at line 1158 of file skimExpertFunctions.py.
| def flags | ( | self | ) |
List of flags for each skim in combined skim.
Definition at line 1151 of file skimExpertFunctions.py.
|
inherited |
Get the list of skim particle list names, without creating the particle lists on the current path.
Definition at line 796 of file skimExpertFunctions.py.
| def initialise_skim_flag | ( | self, | |
| path | |||
| ) |
Add the module `skimExpertFunctions.InitialiseSkimFlag` to the path, to initialise flags for each skim.
Reimplemented from BaseSkim.
Definition at line 1164 of file skimExpertFunctions.py.
| def load_standard_lists | ( | self, | |
| path | |||
| ) |
Add all required standard list loading to the path.
Note:
To avoid loading standard lists twice, this function creates dummy paths
that are passed through ``load_standard_lists`` for each skim. These dummy
paths are then inspected, and a list of unique module-parameter combinations
is added to the main skim path.
Parameters:
path (basf2.Path): Skim path to be processed.
Reimplemented from BaseSkim.
Definition at line 1014 of file skimExpertFunctions.py.
| def merge_data_structures | ( | self | ) |
Read the values of `BaseSkim.MergeDataStructures` and merge data structures
accordingly.
For example, if ``MergeDataStructures`` has the value ``{"FEIChannelArgs":
_merge_boolean_dicts.__func__}``, then ``_merge_boolean_dicts`` is run on all
input skims with the attribute ``FEIChannelArgs``, and the value of
``FEIChannelArgs`` for that skim is set to the result.
In the FEI skims, this is used to merge configs which are passed to a cached
function, thus allowing us to apply the FEI once with all the required particles
available.
Definition at line 1203 of file skimExpertFunctions.py.
| def output_mdst_if_any_flag_passes | ( | self, | |
| * | path, | ||
| ** | kwargs | ||
| ) |
Add MDST output to the path if the event passes any of the skim flags.
EventExtraInfo is included in the MDST output so that the flags are available in
the output.
The ``CombinedSkimName`` parameter in the `CombinedSkim` initialisation is used
for the output filename if ``filename`` is not included in kwargs.
Parameters:
path (basf2.Path): Skim path to be processed.
**kwargs: Passed on to `mdst.add_mdst_output`.
Definition at line 1080 of file skimExpertFunctions.py.
| def output_udst | ( | self, | |
| path | |||
| ) |
Run the `BaseSkim.output_udst` function of each skim.
Parameters:
path (basf2.Path): Skim path to be processed.
Reimplemented from BaseSkim.
Definition at line 1070 of file skimExpertFunctions.py.
|
inherited |
Return the skim path. * If `BaseSkim.skim_event_cuts` has been run, then the skim lists will only be created on a conditional path, so subsequent modules should be added to the conditional path. * If `BaseSkim.skim_event_cuts` has not been run, then the main analysis path is returned.
Definition at line 694 of file skimExpertFunctions.py.
| def produce_on_tau_samples | ( | self | ) |
Corresponding value of this attribute for each individual skim.
Raises:
RuntimeError: Raised if the individual skims in combined skim contain a mix
of True and False for this property.
Definition at line 1180 of file skimExpertFunctions.py.
| def set_skim_logging | ( | self | ) |
Run `BaseSkim.set_skim_logging` for each skim.
Reimplemented from BaseSkim.
Definition at line 1145 of file skimExpertFunctions.py.
|
inherited |
Apply event-level cuts in a skim-safe way.
Parameters:
cut (str): Event-level cut to be applied.
path (basf2.Path): Skim path to be processed.
Returns:
ConditionalPath (basf2.Path): Path on which the rest of this skim should be
processed. On this path, only events which passed the event-level cut
will be processed further.
.. Tip::
If running this function in `BaseSkim.additional_setup` or
`BaseSkim.build_lists`, redefine the ``path`` to the path returned by
`BaseSkim.skim_event_cuts`, *e.g.*
.. code-block:: python
def build_lists(self, path):
path = self.skim_event_cuts("nTracks>4", path=path)
# rest of skim list building...
.. Note::
The motivation for using this function over `applyEventCuts` is that
`applyEventCuts` completely removes events from processing. If we combine
multiple skims in a single steering file (which is done in production), and
the first has a set of event-level cuts, then all the remaining skims will
never even see those events.
Internally, this function creates a new path, which is only processed for
events passing the event-level cut. To avoid issues around particles not
being available on the main path (leading to noisy error logs), we need to
add the rest of the skim to this path. So this new path is assigned to the
attribute ``BaseSkim._ConditionalPath``, and ``BaseSkim.__call__`` will run
all remaining methods on this path.
Definition at line 716 of file skimExpertFunctions.py.
| def update_skim_flag | ( | self, | |
| path | |||
| ) |
Add the module `skimExpertFunctions.InitialiseSkimFlag` to the conditional path of each skims.
Reimplemented from BaseSkim.
Definition at line 1171 of file skimExpertFunctions.py.
|
inherited |
Create validation histograms for the skim.
Parameters:
path (basf2.Path): Skim path to be processed.
Reimplemented in BtoD0h_Kshh, DstToD0Pi_D0ToHpJm, feiSLBplus, BtoD0h_hh, feiSLB0, LambdacTopHpJm, TauThrust, feiHadronicBplus, XToDp_DpToHpHmJp, TDCPV_ccs, XToDp_DpToKsHp, feiHadronicB0, TauGeneric, DstToD0Pi_D0ToRare, SLUntagged, TauLFV, TDCPV_qqs, XToD0_D0ToNeutrals, BtoD0h_Kspipipi0, PRsemileptonicUntagged, XToD0_D0ToHpJm, BtoD0h_Kspi0, and LeptonicUntagged.
Definition at line 640 of file skimExpertFunctions.py.