ATLAS Offline Software
Loading...
Searching...
No Matches
python.D3PDObject Namespace Reference

Classes

class  D3PDObject
class  DeferArg

Functions

 _make_name (name, prefix, name_prefix, parent_prefix, default_prefix)
 _testLOD (lod, reqlev, args, hookargs)
 make_Void_D3PDObject (default_prefix='', default_object_name='', default_name=None, allow_args=[])
 make_SG_D3PDObject (default_typeName, default_sgkey, default_prefix, default_object_name=None, default_allowMissing=False, default_getterClass=D3PD.SGObjGetterTool, allow_args=[])
 make_SGDataVector_D3PDObject (default_typeName, default_sgkey, default_prefix, default_object_name=None, default_allowMissing=False, default_getterFilter=None, default_label=None, default_getterClass=\ D3PD.SGDataVectorGetterTool, allow_args=[], **other_defaults)

Variables

 D3PD = CompFactory.D3PD

Function Documentation

◆ _make_name()

python.D3PDObject._make_name ( name,
prefix,
name_prefix,
parent_prefix,
default_prefix )
protected
Helper to form the name for object filler tools.

Definition at line 19 of file D3PDObject.py.

19def _make_name (name, prefix, name_prefix, parent_prefix, default_prefix):
20 """Helper to form the name for object filler tools."""
21 if name is None:
22 pref = prefix + name_prefix
23 if len (pref) == 0: pref = default_prefix
24 if len (pref) == 0:
25 pref = 'Unnamed_'
26 name = parent_prefix + pref + 'Filler'
27 return name
28
29

◆ _testLOD()

python.D3PDObject._testLOD ( lod,
reqlev,
args,
hookargs )
protected
Helper to perform LOD test.

lod: The level-of-detail to test.  Either an integer or a callable.
reqlev: Requested level of detail for this object.  An integer.
args: Arguments to be passed to the block.
hookargs: Arguments passed to the D3PD object, to be passed
          on to LOD functions.

Definition at line 30 of file D3PDObject.py.

30def _testLOD (lod, reqlev, args, hookargs):
31 """Helper to perform LOD test.
32
33 lod: The level-of-detail to test. Either an integer or a callable.
34 reqlev: Requested level of detail for this object. An integer.
35 args: Arguments to be passed to the block.
36 hookargs: Arguments passed to the D3PD object, to be passed
37 on to LOD functions.
38"""
39 # Decide whether to include this block.
40 # If the block's LOD is callable, call it.
41 # Otherwise, just compare.
42 if callable (lod):
43 # Allow for an optional third hookargs argument.
44 try:
45 doblock = lod (reqlev, args, hookargs)
46 except TypeError as exc:
47 if (len(exc.args) > 0 and
48 (exc.args[0].find ('takes exactly 2 arguments') >= 0 or
49 exc.args[0].find ('takes 2 positional') >= 0)):
50 doblock = lod (reqlev, args)
51 else:
52 raise
53 else:
54 doblock = (lod <= reqlev)
55
56 return doblock
57
58

◆ make_SG_D3PDObject()

python.D3PDObject.make_SG_D3PDObject ( default_typeName,
default_sgkey,
default_prefix,
default_object_name = None,
default_allowMissing = False,
default_getterClass = D3PD.SGObjGetterTool,
allow_args = [] )
Helper to make a D3PDObject for the common case where the default
input source is a single object from StoreGate.

    Arguments:
      default_typeName: The default name of the type being
                        fetched from StoreGate.
      default_sgkey: The default value for the StoreGate key.
      default_prefix: The default prefix to put in front of variables.
      default_object_name: The name of the D3PDObject which is created,
                           like 'EventInfoD3PDObject'
      default_allowMissing: The default value for the AllowMissing
        property (defaults to False).
      default_getterClass: Default value to use for the getter class,
        when we create the getter.  Defaults to SGObjGetterTool.
      allow_args: Additional arguments that may be passed in when
                  instantiating the D3PDObject, but which are not
                  to be passed to the maker function.  This can be
                  used to allow for additional arguments to hook
                  or level-of-detail functions.

    Typical usage would be something like this:

       METD3PDObject = \
          make_SG_D3PDObject ('MissingET',
                              D3PDMakerFlags.MissingETSGKey,
                              'met_', 'METD3PDObject')

Definition at line 646 of file D3PDObject.py.

652 allow_args = []):
653 """Helper to make a D3PDObject for the common case where the default
654input source is a single object from StoreGate.
655
656 Arguments:
657 default_typeName: The default name of the type being
658 fetched from StoreGate.
659 default_sgkey: The default value for the StoreGate key.
660 default_prefix: The default prefix to put in front of variables.
661 default_object_name: The name of the D3PDObject which is created,
662 like 'EventInfoD3PDObject'
663 default_allowMissing: The default value for the AllowMissing
664 property (defaults to False).
665 default_getterClass: Default value to use for the getter class,
666 when we create the getter. Defaults to SGObjGetterTool.
667 allow_args: Additional arguments that may be passed in when
668 instantiating the D3PDObject, but which are not
669 to be passed to the maker function. This can be
670 used to allow for additional arguments to hook
671 or level-of-detail functions.
672
673 Typical usage would be something like this:
674
675 METD3PDObject = \
676 make_SG_D3PDObject ('MissingET',
677 D3PDMakerFlags.MissingETSGKey,
678 'met_', 'METD3PDObject')
679
680"""
681 def make_obj (name, prefix, object_name,
682 getter = None,
683 sgkey = None,
684 allowMissing = default_allowMissing,
685 typeName = default_typeName,
686 getterClass = default_getterClass):
687 if sgkey is None: sgkey = default_sgkey
688 if not getter:
689 getter = getterClass (name + '_Getter',
690 TypeName = typeName,
691 SGKey = sgkey)
692 from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
693 return D3PD.ObjFillerTool (name,
694 Prefix = prefix,
695 Getter = getter,
696 ObjectName = object_name,
697 AllowMissing=allowMissing,
698 SaveMetadata = \
699 D3PDMakerFlags.SaveObjectMetadata)
700
701 if default_object_name is None:
702 default_object_name = default_typeName
703 default_object_name = default_object_name.split('::')[-1]
704
705 return D3PDObject (make_obj, default_prefix, default_object_name,
706 sgkey = default_sgkey,
707 typeName = default_typeName,
708 allow_args = allow_args)
709
710
711
Object filler tool for a single object.

◆ make_SGDataVector_D3PDObject()

python.D3PDObject.make_SGDataVector_D3PDObject ( default_typeName,
default_sgkey,
default_prefix,
default_object_name = None,
default_allowMissing = False,
default_getterFilter = None,
default_label = None,
default_getterClass = \                                     D3PD.SGDataVectorGetterTool,
allow_args = [],
** other_defaults )
Helper to make a D3PDObject for the common case where the default
input source is a DataVector container from StoreGate.

    Arguments:
      default_typeName: The default name of the type being
                        fetched from StoreGate.
      default_sgkey: The default value for the StoreGate key.
      default_prefix: The default prefix to put in front of variables.
      default_object_name: The name of the D3PDObject which is created,
                           like 'EventInfoD3PDObject'
      default_allowMissing: The default value for the AllowMissing
        property (defaults to False).
      default_label: The default value to use for the collection label
        (default to the prefix).
      default_getterFilter: A collection getter filter to wrap
        around the primary getter (defaults to no filter).
        If this is a string, then it is interpreted as the
        StoreGate key of a SelectedParticles object to use
        to do the filtering.
      default_getterClass: Default value to use for the getter class,
        when we create the getter.  Defaults to SGDataVectorGetterTool,
        which is appropriate for iterating over a DataVector.
      allow_args: Additional arguments that may be passed in when
                  instantiating the D3PDObject, but which are not
                  to be passed to the maker function.  This can be
                  used to allow for additional arguments to hook
                  or level-of-detail functions.

    Typical usage would be something like this:

       JetD3PDObject = \
          make_SGDataVector_D3PDObject ('JetCollection',
                                        D3PDMakerFlags.JetSGKey,
                                        'jet_', 'JetD3PDObject')

    In addition, each object has automatically defined a
    ContainerFlagFillerTool block named `SelectionFlags'.
    This means that you can pass in an argument like

      SelectionFlags_FlagNames [ 'selected@MyContainerType/mine:Objects in mine' ]

    This will create a flag variable `selected' which will be true if
    the object contained in the SG container MyContainerType/mine.
    The string after the colon is used for documentation.

Definition at line 712 of file D3PDObject.py.

722 **other_defaults):
723 """Helper to make a D3PDObject for the common case where the default
724input source is a DataVector container from StoreGate.
725
726 Arguments:
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
741 to do the filtering.
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.
750
751 Typical usage would be something like this:
752
753 JetD3PDObject = \
754 make_SGDataVector_D3PDObject ('JetCollection',
755 D3PDMakerFlags.JetSGKey,
756 'jet_', 'JetD3PDObject')
757
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
761
762 SelectionFlags_FlagNames [ 'selected@MyContainerType/mine:Objects in mine' ]
763
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.
767"""
768 def make_obj (name, prefix, object_name,
769 getter = None,
770 sgkey = None,
771 label = default_label,
772 allowMissing = default_allowMissing,
773 getterFilter = default_getterFilter,
774 typeName = default_typeName,
775 getterClass = default_getterClass,
776 **kw):
777 if sgkey is None: sgkey = default_sgkey
778 if label is None: label = prefix
779 if not getter:
780 getter = getterClass (name + '_Getter',
781 TypeName = typeName,
782 SGKey = sgkey,
783 Label = label)
784 if getterFilter:
785 if isinstance(getterFilter, str):
786 selgetter = D3PD.SGObjGetterTool \
787 (name + '_SelectionGetter',
788 TypeName = 'SelectedParticles',
789 SGKey = getterFilter)
791 (name + '_GetterFilter',
792 Getter = getter,
793 SelectionGetter = selgetter)
794 else:
795 getter = getterFilter (name + '_GetterFilter',
796 Getter = getter)
797 defs = other_defaults.copy()
798 defs.update (kw)
799 from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
800 return D3PD.VectorFillerTool (name,
801 Prefix = prefix,
802 Getter = getter,
803 ObjectName = object_name,
804 AllowMissing=allowMissing,
805 SaveMetadata = \
806 D3PDMakerFlags.SaveObjectMetadata,
807 **defs)
808
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]
816
817 ret = D3PDObject (make_obj, default_prefix, default_object_name,
818 sgkey = default_sgkey,
819 typeName = default_typeName,
820 allow_args = allow_args)
821
822 # Automatically add SelectionFlags to each object.
823 # It won't actually create any variables unless the Flags property is set.
824 ret.defineBlock (0, 'SelectionFlags',
826
827 return ret
828
Flag objects that are present in other containers.
Getter tool to retrieve single objects from StoreGate.
A collection getter that filters the results of another based on the contents of a SelectedParticles ...
Object filler tool for a collection of objects, saved as vectors.

◆ make_Void_D3PDObject()

python.D3PDObject.make_Void_D3PDObject ( default_prefix = '',
default_object_name = '',
default_name = None,
allow_args = [] )
Helper to make a D3PDObject for the case where no explicit
input object is being used.    

    Arguments:
      default_prefix: The default prefix to put in front of variables.
      default_object_name: The name of the D3PDObject which is created,
                           like 'EventInfoD3PDObject'
      default_name: If specified, the default tool name to use
                    for these objects.
      allow_args: Additional arguments that may be passed in when
                  instantiating the D3PDObject, but which are not
                  to be passed to the maker function.  This can be
                  used to allow for additional arguments to hook
                  or level-of-detail functions.

    Typical usage would be something like this:

       METD3PDObject = \
          make_Void_D3PDObject ('trig_', 'METD3PDObject')

Definition at line 608 of file D3PDObject.py.

611 allow_args = []):
612 """Helper to make a D3PDObject for the case where no explicit
613input object is being used.
614
615 Arguments:
616 default_prefix: The default prefix to put in front of variables.
617 default_object_name: The name of the D3PDObject which is created,
618 like 'EventInfoD3PDObject'
619 default_name: If specified, the default tool name to use
620 for these objects.
621 allow_args: Additional arguments that may be passed in when
622 instantiating the D3PDObject, but which are not
623 to be passed to the maker function. This can be
624 used to allow for additional arguments to hook
625 or level-of-detail functions.
626
627 Typical usage would be something like this:
628
629 METD3PDObject = \
630 make_Void_D3PDObject ('trig_', 'METD3PDObject')
631
632"""
633 def make_obj (name, prefix, object_name):
634 from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
635 return D3PD.VoidObjFillerTool (name,
636 Prefix = prefix,
637 ObjectName = object_name,
638 SaveMetadata = \
639 D3PDMakerFlags.SaveObjectMetadata)
640 return D3PDObject (make_obj, default_prefix, default_object_name,
641 default_name = default_name,
642 allow_args = allow_args)
643
644
645
Object filler tool for tools taking no input.

Variable Documentation

◆ D3PD

python.D3PDObject.D3PD = CompFactory.D3PD

Definition at line 16 of file D3PDObject.py.