715 default_object_name = None,
716 default_allowMissing = False,
717 default_getterFilter = None,
718 default_label = None,
719 default_getterClass = \
720 D3PD.SGDataVectorGetterTool,
723 """Helper to make a D3PDObject for the common case where the default
724 input source is a DataVector container from StoreGate.
727 default_typeName: The default name of the type being
728 fetched from StoreGate.
729 default_sgkey: The default value for the StoreGate key.
730 default_prefix: The default prefix to put in front of variables.
731 default_object_name: The name of the D3PDObject which is created,
732 like 'EventInfoD3PDObject'
733 default_allowMissing: The default value for the AllowMissing
734 property (defaults to False).
735 default_label: The default value to use for the collection label
736 (default to the prefix).
737 default_getterFilter: A collection getter filter to wrap
738 around the primary getter (defaults to no filter).
739 If this is a string, then it is interpreted as the
740 StoreGate key of a SelectedParticles object to use
742 default_getterClass: Default value to use for the getter class,
743 when we create the getter. Defaults to SGDataVectorGetterTool,
744 which is appropriate for iterating over a DataVector.
745 allow_args: Additional arguments that may be passed in when
746 instantiating the D3PDObject, but which are not
747 to be passed to the maker function. This can be
748 used to allow for additional arguments to hook
749 or level-of-detail functions.
751 Typical usage would be something like this:
754 make_SGDataVector_D3PDObject ('JetCollection',
755 D3PDMakerFlags.JetSGKey,
756 'jet_', 'JetD3PDObject')
758 In addition, each object has automatically defined a
759 ContainerFlagFillerTool block named `SelectionFlags'.
760 This means that you can pass in an argument like
762 SelectionFlags_FlagNames [ 'selected@MyContainerType/mine:Objects in mine' ]
764 This will create a flag variable `selected' which will be true if
765 the object contained in the SG container MyContainerType/mine.
766 The string after the colon is used for documentation.
768 def make_obj (name, prefix, object_name,
771 label = default_label,
772 allowMissing = default_allowMissing,
773 getterFilter = default_getterFilter,
774 typeName = default_typeName,
775 getterClass = default_getterClass,
777 if sgkey
is None: sgkey = default_sgkey
778 if label
is None: label = prefix
780 getter = getterClass (name +
'_Getter',
785 if isinstance(getterFilter, str):
787 (name +
'_SelectionGetter',
788 TypeName =
'SelectedParticles',
789 SGKey = getterFilter)
791 (name +
'_GetterFilter',
793 SelectionGetter = selgetter)
795 getter = getterFilter (name +
'_GetterFilter',
797 defs = other_defaults.copy()
799 from D3PDMakerConfig.D3PDMakerFlags
import D3PDMakerFlags
803 ObjectName = object_name,
804 AllowMissing=allowMissing,
806 D3PDMakerFlags.SaveObjectMetadata,
809 if default_object_name
is None:
810 default_object_name = default_typeName
811 if default_object_name.endswith (
'Collection'):
812 default_object_name = default_object_name[:-10]
813 if default_object_name.endswith (
'Container'):
814 default_object_name = default_object_name[:-9]
815 default_object_name = default_object_name.split(
'::')[-1]
817 ret = D3PDObject (make_obj, default_prefix, default_object_name,
818 sgkey = default_sgkey,
819 typeName = default_typeName,
820 allow_args = allow_args)
824 ret.defineBlock (0,
'SelectionFlags',