Belle II Software  release-05-01-25
BaseSkim Class Reference

Inherits ABC.

Inherited by B0toD0Kpipi0_pi0, B0toDD_Kpipi_Kspi, B0toDpi_Kpipi, B0toDpi_Kspi, B0toDrho_Kpipi, B0toDrho_Kspi, B0toDstarD, B0toDstarPi_D0pi_Kpi, B0toDstarPi_D0pi_Kpipipi_Kpipi0, B0toDstarRho_D0pi_Kpi, B0toDstarRho_D0pi_Kpipipi_Kpipi0, BtoD0h_hh, BtoD0h_Kpi, BtoD0h_Kpipipi_Kpipi0, BtoD0h_Kshh, BtoD0h_Kspi0, BtoD0h_Kspipipi0, BtoD0rho_Kpi, BtoD0rho_Kpipipi_Kpipi0, BtoHad1Pi0, BtoHad3Tracks1Pi0, BtoHadTracks, BtoPi0Pi0, BtoRhopRhom, DstToD0Pi_D0ToHpHmHpJm, DstToD0Pi_D0ToHpHmPi0, DstToD0Pi_D0ToHpJmEta, DstToD0Pi_D0ToHpJmKs, DstToD0Pi_D0ToHpJmPi0, DstToD0Pi_D0ToKsOmega, DstToD0Pi_D0ToRare, DstToDpPi0_DpToHpPi0, EarlyData_DstToD0Pi_D0ToHpHmPi0, EarlyData_DstToD0Pi_D0ToHpJmPi0, LambdacTopHpJm, XToD0_D0ToHpJm, XToD0_D0ToNeutrals, XToDp_DpToHpHmJp, XToDp_DpToKsHp, ALP3Gamma, DielectronPlusMissingEnergy, DimuonPlusMissingEnergy, EGammaControlDark, ElectronMuonPlusMissingEnergy, GammaGammaControlKLMDark, InelasticDarkMatter, LFVZpVisible, RadBhabhaV0Control, SinglePhotonDark, BtoXgamma, BtoXll, BtoXll_LFV, inclusiveBplusToKplusNuNu, BaseFEISkim, dilepton, LeptonicUntagged, LowMassTwoTrack, SingleTagPseudoScalar, TwoTrackLeptonsForLuminosity, BottomoniumEtabExclusive, BottomoniumUpsilon, CharmoniumPsi, InclusiveLambda, B0toDstarl_Kpi_Kpipi0_Kpipipi, PRsemileptonicUntagged, SLUntagged, Random, Resonance, SystematicsBhabha, SystematicsDstar, SystematicsEELL, SystematicsFourLeptonFromHLTFlag, SystematicsJpsi, SystematicsKshort, SystematicsLambda, SystematicsPhiGamma, SystematicsRadEE, SystematicsRadMuMu, SystematicsRadMuMuFromHLTFlag, SystematicsTracking, TauGeneric, TauLFV, TauThrust, TDCPV_ccs, TDCPV_qqs, and CombinedSkim.

Collaboration diagram for BaseSkim:

Public Member Functions

def __description__ (self)
 
def __category__ (self)
 
def __authors__ (self)
 
def __contact__ (self)
 
def code (self)
 
def __init__ (self, *OutputFileName=None, additionalDataDescription=None, udstOutput=True, validation=False)
 
def load_standard_lists (self, path)
 
def additional_setup (self, path)
 
def build_lists (self, path)
 
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 flag (self)
 
def initialise_skim_flag (self, path)
 
def update_skim_flag (self, path)
 
def get_skim_list_names (self)
 
def __str__ (self)
 
def __name__ (self)
 
def set_skim_logging (self)
 
def output_udst (self, path)
 
def apply_hlt_hadron_cut_if_required (self, path)
 

Public Attributes

 name
 
 OutputFileName
 
 additionalDataDescription
 
 SkimLists
 

Static Public Attributes

 NoisyModules = None
 
list TestFiles = [get_test_file("MC13_mixedBGx1")]
 
dictionary MergeDataStructures = {}
 
bool ApplyHLTHadronCut = False
 
bool produce_on_tau_samples = True
 

Private Member Functions

def _method_unchanged (self, method)
 

Private Attributes

 _udstOutput
 
 _validation
 

Static Private Attributes

 _MainPath = None
 
 _ConditionalPath = None
 

Detailed Description

Base class for skims. Initialises a skim name, and creates template functions
required for each skim.

See `writing-skims` for information on how to use this to define a new skim.

Definition at line 504 of file skimExpertFunctions.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
OutputFileName = None,
  additionalDataDescription = None,
  udstOutput = True,
  validation = False 
)
Initialise the BaseSkim class.

Parameters:
    OutputFileName (str): Name to give output uDST files. If none given, then
defaults to eight-number skim code.
    additionalDataDescription (dict): additional data description to be added to the output file metadata.
    udstOutput (bool): If True, add uDST output to the path.
    validation (bool): If True, build lists and write validation histograms
instead of writing uDSTs.

Definition at line 578 of file skimExpertFunctions.py.

Member Function Documentation

◆ __call__()

def __call__ (   self,
  path,
udstOutput = None,
  validation = None 
)
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.

◆ _method_unchanged()

def _method_unchanged (   self,
  method 
)
private
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.

◆ additional_setup()

def additional_setup (   self,
  path 
)
Perform any setup steps necessary before running the skim. This may include:

* applying event-level cuts using `ifEventPasses`,
* adding the `MCMatcherParticles` module to the path,
* running the FEI.

Warning:
    Standard particle lists should *not* be loaded in here. This should be done
    by overriding the method `BaseSkim.load_standard_lists`. This is crucial for
    avoiding loading lists twice when combining skims for production.

Parameters:
    path (basf2.Path): Skim path to be processed.

Reimplemented in CombinedSkim, Random, TauThrust, TDCPV_ccs, TauGeneric, BaseFEISkim, ALP3Gamma, and TDCPV_qqs.

Definition at line 612 of file skimExpertFunctions.py.

◆ apply_hlt_hadron_cut_if_required()

def apply_hlt_hadron_cut_if_required (   self,
  path 
)
Apply the ``hlt_hadron`` selection if the property ``ApplyHLTHadronCut`` is True.

Parameters:
    path (basf2.Path): Skim path to be processed.

Reimplemented in CombinedSkim.

Definition at line 883 of file skimExpertFunctions.py.

◆ build_lists()

def build_lists (   self,
  path 
)
Create the skim lists to be saved in the output uDST. This function is where
the main skim cuts should be applied. At the end of this method, the attribute
``SkimLists`` must be set so it can be used by `output_udst`.

Parameters:
    path (basf2.Path): Skim path to be processed.

Reimplemented in EarlyData_DstToD0Pi_D0ToHpHmPi0, CombinedSkim, EarlyData_DstToD0Pi_D0ToHpJmPi0, B0toD0Kpipi0_pi0, DstToD0Pi_D0ToHpJmKs, B0toDstarD, DstToD0Pi_D0ToNeutrals, B0toDD_Kpipi_Kspi, DstToD0Pi_D0ToHpJmEta, BtoD0rho_Kpipipi_Kpipi0, DstToD0Pi_D0ToHpHmHpJm, BtoD0rho_Kpi, SystematicsBhabha, DstToD0Pi_D0ToKsOmega, SystematicsKshort, BtoD0h_Kshh, DstToD0Pi_D0ToHpHmPi0, feiSL, DstToD0Pi_D0ToHpJmPi0, SystematicsJpsi, BtoD0h_Kpipipi_Kpipi0, feiHadronic, SystematicsRadMuMuFromHLTFlag, SystematicsFourLeptonFromHLTFlag, BtoD0h_Kpi, Random, DstToD0Pi_D0ToHpJm, feiSLBplus, SystematicsPhiGamma, BtoD0h_hh, InelasticDarkMatter, DstToDpPi0_DpToHpPi0, SystematicsLambda, RadBhabhaV0Control, B0toDstarRho_D0pi_Kpipipi_Kpipi0, feiSLB0, LambdacTopHpJm, DielectronPlusMissingEnergy, SystematicsRadEE, B0toDstarRho_D0pi_Kpi, TauThrust, B0toDrho_Kspi, feiHadronicBplus, SystematicsEELL, XToDp_DpToHpHmJp, GammaGammaControlKLMDark, B0toDrho_Kpipi, SystematicsRadMuMu, B0toDstarl_Kpi_Kpipi0_Kpipipi, feiHadronicB0, XToDp_DpToKsHp, B0toDstarPi_D0pi_Kpipipi_Kpipi0, EGammaControlDark, inclusiveBplusToKplusNuNu, TauGeneric, BtoRhopRhom, B0toDstarPi_D0pi_Kpi, TDCPV_ccs, LFVZpVisible, BtoHad3Tracks1Pi0, InclusiveLambda, DstToD0Pi_D0ToRare, B0toDpi_Kspi, BtoXll_LFV, ElectronMuonPlusMissingEnergy, SLUntagged, SingleTagPseudoScalar, B0toDpi_Kpipi, BtoHad1Pi0, Resonance, XToD0_D0ToNeutrals, DimuonPlusMissingEnergy, CharmoniumPsi, ALP3Gamma, BtoD0h_Kspipipi0, dilepton, BtoXll, LowMassTwoTrack, TDCPV_qqs, BtoHadTracks, BottomoniumUpsilon, XToD0_D0ToHpJm, SystematicsTracking, BtoD0h_Kspi0, PRsemileptonicUntagged, TauLFV, BtoXgamma, BtoPi0Pi0, LeptonicUntagged, SystematicsDstar, BottomoniumEtabExclusive, SinglePhotonDark, and TwoTrackLeptonsForLuminosity.

Definition at line 631 of file skimExpertFunctions.py.

◆ code()

def code (   self)
Eight-digit code assigned to this skim in the registry.

Definition at line 574 of file skimExpertFunctions.py.

◆ flag()

def flag (   self)
Event-level variable indicating whether an event passes the skim or not. To use
the skim flag without writing uDST output, use the argument ``udstOutput=False``
when instantiating the skim class.

Reimplemented in CombinedSkim.

Definition at line 768 of file skimExpertFunctions.py.

◆ get_skim_list_names()

def get_skim_list_names (   self)
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.

◆ initialise_skim_flag()

def initialise_skim_flag (   self,
  path 
)
Add the module `skimExpertFunctions.InitialiseSkimFlag` to the path, which
initialises flag for this skim to zero.

Reimplemented in CombinedSkim.

Definition at line 776 of file skimExpertFunctions.py.

◆ load_standard_lists()

def load_standard_lists (   self,
  path 
)
Load any standard lists. This code will be run before any
`BaseSkim.additional_setup` and `BaseSkim.build_lists`.

Note:
    This is separated into its own function so that when skims are combined, any
    standard lists used by two skims can be loaded just once.

Parameters:
    path (basf2.Path): Skim path to be processed.

Reimplemented in EarlyData_DstToD0Pi_D0ToHpHmPi0, EarlyData_DstToD0Pi_D0ToHpJmPi0, B0toD0Kpipi0_pi0, CombinedSkim, DstToD0Pi_D0ToHpJmKs, B0toDstarD, DstToD0Pi_D0ToNeutrals, B0toDD_Kpipi_Kspi, DstToD0Pi_D0ToHpJmEta, BtoD0rho_Kpipipi_Kpipi0, DstToD0Pi_D0ToHpHmHpJm, BtoD0rho_Kpi, SystematicsBhabha, DstToD0Pi_D0ToKsOmega, SystematicsKshort, BtoD0h_Kshh, DstToD0Pi_D0ToHpHmPi0, DstToD0Pi_D0ToHpJmPi0, SystematicsJpsi, BtoD0h_Kpipipi_Kpipi0, SystematicsRadMuMuFromHLTFlag, SystematicsFourLeptonFromHLTFlag, BtoD0h_Kpi, Random, DstToD0Pi_D0ToHpJm, SystematicsPhiGamma, BtoD0h_hh, InelasticDarkMatter, DstToDpPi0_DpToHpPi0, SystematicsLambda, RadBhabhaV0Control, B0toDstarRho_D0pi_Kpipipi_Kpipi0, LambdacTopHpJm, DielectronPlusMissingEnergy, B0toDstarRho_D0pi_Kpi, SystematicsRadEE, SystematicsEELL, B0toDrho_Kspi, XToDp_DpToHpHmJp, TauThrust, GammaGammaControlKLMDark, SystematicsRadMuMu, B0toDrho_Kpipi, B0toDstarl_Kpi_Kpipi0_Kpipipi, XToDp_DpToKsHp, EGammaControlDark, B0toDstarPi_D0pi_Kpipipi_Kpipi0, BtoRhopRhom, B0toDstarPi_D0pi_Kpi, LFVZpVisible, TDCPV_ccs, TauGeneric, InclusiveLambda, BtoHad3Tracks1Pi0, DstToD0Pi_D0ToRare, B0toDpi_Kspi, BtoXll_LFV, ElectronMuonPlusMissingEnergy, SingleTagPseudoScalar, B0toDpi_Kpipi, Resonance, BtoHad1Pi0, SLUntagged, DimuonPlusMissingEnergy, CharmoniumPsi, XToD0_D0ToNeutrals, BtoD0h_Kspipipi0, dilepton, BtoXll, BtoHadTracks, BottomoniumUpsilon, TDCPV_qqs, SystematicsTracking, PRsemileptonicUntagged, BtoD0h_Kspi0, BtoPi0Pi0, BtoXgamma, LeptonicUntagged, TauLFV, BottomoniumEtabExclusive, SinglePhotonDark, and SystematicsDstar.

Definition at line 599 of file skimExpertFunctions.py.

◆ output_udst()

def output_udst (   self,
  path 
)
Write the skim particle lists to an output uDST and print a summary of the
skim list statistics.

Parameters:
    path (basf2.Path): Skim path to be processed.

Reimplemented in CombinedSkim.

Definition at line 860 of file skimExpertFunctions.py.

◆ postskim_path()

def postskim_path (   self)
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.

◆ set_skim_logging()

def set_skim_logging (   self)
Turns the log level to ERROR for selected modules to decrease the total size
of the skim log files. Additional modules can be silenced by setting the attribute
`NoisyModules` for an individual skim.

Parameters:
    path (basf2.Path): Skim path to be processed.

.. warning::

    This method works by inspecting the modules added to the path, and setting
    the log level to ERROR. This method should be called *after* all
    skim-related modules are added to the path.

Reimplemented in CombinedSkim.

Definition at line 834 of file skimExpertFunctions.py.

◆ skim_event_cuts()

def skim_event_cuts (   self,
  cut,
path 
)
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.

◆ update_skim_flag()

def update_skim_flag (   self,
  path 
)
Add the module `skimExpertFunctions.InitialiseSkimFlag` to the path, which
initialises flag for this skim to zero.

.. Warning::

    If a conditional path has been created before this, then this function
    *must* run on the conditional path, since the skim lists are not guaranteed
    to exist for all events on the main path.

Reimplemented in CombinedSkim.

Definition at line 783 of file skimExpertFunctions.py.

◆ validation_histograms()

def validation_histograms (   self,
  path 
)

The documentation for this class was generated from the following file: