FunTuple

Submodules

Classes

FunctorCollection

Class to hold the functor/variable dictionary.

Functions

FunTuple_Particles(*args, **kwargs)

Wrapper function for FunTupleBase_Particles

FunTuple_MCParticles(*args, **kwargs)

Wrapper function for FunTupleBase_MCParticles

FunTuple_Composites(*args, **kwargs)

Wrapper function for FunTupleBase_Composites

FunTuple_ChargedBasics(*args, **kwargs)

Wrapper function for FunTupleBase_Composites

FunTuple_Event(name, tuple_name[, variables, ...])

Wrapper function for FunTupleEventBase.

Package Contents

class FunctorCollection(functor_dict: Type_FunctorDict = {})[source]

Class to hold the functor/variable dictionary.

functor_dict

dictionary of functors/variables, whose key is the field (branch) name suffix and value is the Functor code.

Methods are largely the same as for a dict class with specific requirements:

update : extends a given dictionary of functors to the collection, throwing a warning about overwriting an entry if it already exists. pop : given a name or list of names it removes the functors from the collection, raising an error if the entry(ies) does(do) not exist. add operator (+) : adds two FunctorCollection, for common entries warns the user about picking the entry from “base” FunctorCollection instance. sub operator (-) : returns a FunctorCollection that contains unique entries between two FunctorCollections. get_loki_functors(self): returns dictionary of loki functors get_thor_functors(self): returns dictionary of thor functors

__slots__ = 'functor_dict'
functor_dict
update(functor_dict_new: Type_FunctorDict)[source]

Add new entries to the FunctorCollection given a dictionary. Raises a user warning about overwriting an entry if it already exists.

pop(functor_names: str | list[str])[source]

Remove an entry or a list of entries from the FunctorCollection.

Parameters:

functor_names (str or list) – entries to be removed.

Raises:
  • AttributeError – if the input is not adequate.

  • KeyError – if an entry to be removed does not exist.

__repr__() str[source]

Representation as a string in the common ‘<…>’ format, providing the number of ThOr and LoKi functors stored.

__str__() str[source]

print(FunctorCollection) gives all the entries inside the FunctorCollection.

__add__(other: Self_FunctorCollection) Self_FunctorCollection[source]

Return all entries from two FunctorCollection e.g. FunctorCollection_1(A,B) + FuntorCollection_2(B,C) gives FunctorCollection(A,B,C) where B is from FunctorCollection_1. Raises a user warning about common entries (this should rather be an error, I think)

__iadd__(other: Self_FunctorCollection) Self_FunctorCollection[source]

Return self adding the entries in FunctorCollection ‘other’.

Raises:

TypeError – if the input type is not adequate, i.e a FunctorCollection instance.

__sub__(other: Self_FunctorCollection) Self_FunctorCollection[source]

Return unique entries from two FunctorCollections, e.g. FunctorCollection_1(A,B) - FuntorCollection_2(B,C) gives FunctorCollection(A,C)

Raises:

RuntimeError – if the two functors do not have any unique entries.

__isub__(other: Self_FunctorCollection) Self_FunctorCollection[source]

Return self subtraction of the entries in FunctorCollection ‘other’.

See __sub__ for a description of the behaviour.

__contains__(key: str) bool[source]

Check for key containment.

Example

>>> c = FunctorCollection({"PT": F.PT})
>>> "PT" in c
True
>>> "Nope" in c
False
get_loki_functors() dict[str, str][source]

Return dictionary of loki functors (checking if the values are strings or not).

get_thor_functors() dict[str, Functors.grammar.FunctorBase][source]

Return dictionary of thor functors (checking if the values are not strings). Explicitly type checking for ThOr needed here are they always of type ‘Functors.grammar.BoundFunctor’(?)

__setitem__(key: str, value: Functors.grammar.FunctorBase | str) None[source]

Add an item to the dictionary.

__getitem__(key: str) Functors.grammar.FunctorBase | str[source]

Get an item to the dictionary.

__eq__(other: Self_FunctorCollection) bool[source]

Equality purely on the contents of the collections, i.e. the pairs (keys, values) of both dicts stored.

__len__() int[source]

Implement len(FunctorCollection).

FunTuple_Particles(*args, **kwargs)[source]
Wrapper function for FunTupleBase_Particles
Parameters:

name (string): Name of Algorithm tuple_name (string): Name of the TTree. fields (dict): Dictionary of {field (branch) name : decay descriptor}. The field name is used in naming the variable in the ntuple and decay descriptor in finding the candidates. variables (dict): Dictionary of {variable name: Functor code}. The variable name is used in naming the variable in nTuple (for a given field) and functor code used to retrieve LoKi or ThOr functors. event_variables (FunctorCollection): FunctorCollection of {variable name: Functor code} for event quantities to be added to every candidate. inputs (PyConf DataHandle): Input location of LHCb::Particles to run over. loki_preamble (string): A LoKi preamble that renames a complex functor built out of base functors that could be used as Functor code in “variables” dictionary above. run_full_counter_mode (bool): A boolean to set counters and monitor each of the fields. use_loki_decay_finder (bool): A boolean to use the LoKi DecayFinder to find the candidates instead of the new run-3 DecayFinder. store_run_event_numbers (bool): A boolean to store the runnumber and evtnumber in the ntuple. Default is True. **kwargs: extra arguments like OutputLevel (inherited from Gaudi Algorithms) or thor_preamble (which is list of extra header files to be included when instantiating ThOr functors, usage need to be known)

Returns:

FunTuple PyConf algorithm corresponding to LHCb::Particles as input

FunTuple_MCParticles(*args, **kwargs)[source]
Wrapper function for FunTupleBase_MCParticles
Parameters:

name (string): Name of Algorithm tuple_name (string): Name of the TTree. fields (dict): Dictionary of {field (branch) name : decay descriptor}. The field name is used in naming the variable in the ntuple and decay descriptor in finding the candidates. variables (dict): Dictionary of {variable name: Functor code}. The variable name is used in naming the variable in nTuple (for a given field) and functor code used to retrieve LoKi or ThOr functors. event_variables (FunctorCollection): FunctorCollection of {variable name: Functor code} for event quantities to be added to every candidate. inputs (PyConf DataHandle): Input location of LHCb::MCParticles to run over. loki_preamble (string): A LoKi preamble that renames a complex functor built out of base functors that could be used as Functor code in “variables” dictionary above. run_full_counter_mode (bool): A boolean to set counters and monitor each of the fields. use_loki_decay_finder (bool): A boolean to use the LoKi DecayFinder to find the candidates instead of the new run-3 DecayFinder. **kwargs: extra arguments like OutputLevel (inherited from Gaudi Algorithms) or thor_preamble (which is list of extra header files to be included when instantiating ThOr functors, usage need to be known)

Returns:

FunTuple PyConf algorithm corresponding to LHCb::MCParticles as input

FunTuple_Composites(*args, **kwargs)[source]
Wrapper function for FunTupleBase_Composites
Parameters:

name (string): Name of Algorithm tuple_name (string): Name of the TTree. fields (dict): Dictionary of {field (branch) name : decay descriptor}. The field name is used in naming the variable in the ntuple and decay descriptor in finding the candidates. variables (dict): Dictionary of {variable name: Functor code}. The variable name is used in naming the variable in nTuple (for a given field) and functor code used to retrieve ThOr functors. event_variables (FunctorCollection): FunctorCollection of {variable name: Functor code} for event quantities to be added to every candidate. inputs (PyConf DataHandle): Input location of LHCb::Event::Composites to run over. run_full_counter_mode (bool): A boolean to set counters and monitor each of the fields. store_run_event_numbers (bool): A boolean to store the runnumber and evtnumber in the ntuple. Default is True. **kwargs: extra arguments like OutputLevel (inherited from Gaudi Algorithms) or thor_preamble (which is list of extra header files to be included when instantiating ThOr functors, usage need to be known)

Returns:

FunTuple PyConf algorithm corresponding to LHCb::Event::Composites as input

FunTuple_ChargedBasics(*args, **kwargs)[source]
Wrapper function for FunTupleBase_Composites
Parameters:

tuple_name (string): Name of the TTree. fields (dict): Dictionary of {field (branch) name : decay descriptor}. The field name is used in naming the variable in the ntuple and decay descriptor in finding the candidates. variables (dict): Dictionary of {variable name: Functor code}. The variable name is used in naming the variable in nTuple (for a given field) and functor code used to retrieve ThOr functors. event_variables (FunctorCollection): FunctorCollection of {variable name: Functor code} for event quantities to be added to every candidate. inputs (PyConf DataHandle): Input location of LHCb::Event::Composites to run over. run_full_counter_mode (bool): A boolean to set counters and monitor each of the fields. store_run_event_numbers (bool): A boolean to store the runnumber and evtnumber in the ntuple. Default is True. **kwargs: extra arguments like OutputLevel (inherited from Gaudi Algorithms) or thor_preamble (which is list of extra header files to be included when instantiating ThOr functors, usage need to be known)

Returns:

FunTuple PyConf algorithm corresponding to LHCb::Event::Composites as input

FunTuple_Event(name, tuple_name, variables=None, store_run_event_numbers=True, **kwargs)[source]
Wrapper function for FunTupleEventBase.
Parameters:

name (string): Name of Algorithm tuple_name (string): Name of the TTree. variables (dict, optional): Dictionary of {variable name: Event-level functor code}.

The variable name is used in naming the variable in the nTuple and event-level functor code used to retrieve ThOr functors. Defaults to None.

store_run_event_numbers (bool, optional): A boolean to store the run and event numbers in the ntuple.

Defaults to True.

**kwargs: extra arguments like OutputLevel (inherited from Gaudi Algorithms).

Returns:

FunTupleEvent PyConf algorithm.