All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
galleryUtils.HandleMaker Class Reference

gallery More...

Classes

class  ManyByTypeProc
 

Public Member Functions

def validHandle
 
def manyByType
 
def __call__
 
def __call__
 

Static Public Member Functions

def make
 

Static Public Attributes

tuple AlreadyMade = set()
 

Detailed Description

gallery

Make the ROOT C++ jit compiler instantiate the
Event::getValidHandle member template for template parameter klass.

Needs to keep track of what was done already, because Cling will protest if
the same class is asked twice.

See the documentation of `__call__` for examples of usage of instances of
this class.
Make the ROOT C++ jit compiler instantiate the
Event::getValidHandle member template for template parameter klass.

Needs to keep track of what was done already, because Cling will protest if
the same class is asked twice.

Definition at line 68 of file icarusalg/icarusalg/gallery/helpers/python/galleryUtils.py.

Member Function Documentation

def galleryUtils.HandleMaker.__call__ (   self,
  klass 
)

Definition at line 52 of file sbndcode/sbndcode/gallery/python/galleryUtils.py.

52 
53  def __call__(self, klass):
54  if klass in HandleMaker.AlreadyMade: return
55  res = HandleMaker.make(klass)
56  if res != ROOT.TInterpreter.kNoError:
57  raise RuntimeError(
58  "Could not create `ROOT.gallery.Event.getValidHandle` for '%s' (code: %d)"
59  % (klass, res)
60  )
61  # if
62  HandleMaker.AlreadyMade.add(klass)
63  # if already there
64  return event.getValidHandle[klass] if event \
else ROOT.gallery.Event.getValidHandle[klass]
def galleryUtils.HandleMaker.__call__ (   self,
  klass 
)

Definition at line 110 of file icarusalg/icarusalg/gallery/helpers/python/galleryUtils.py.

111  klass: "data product class to prepare for (as a C++ class name string)",
112  event: "(optional) the event object to retrieve the data products from " = None,
113  ) -> "if `event` is specified, bound `getValidHandle<klass>`, unbound otherwise":
114  """Prepares for reading data products of the specified class.
115 
116  This function causes the instantiation of the `gallery::Event::getValidHandle()`
117  method specialized to read the specified `klass`.
118  It also returns a bound or unbound function to actually retrieve data products.
119 
120  If an `event` instance is specified, the returned value is a bound function
121  that can be used directly.
122 
123  from galleryUtils import makeEvent, make_getValidHandle
124  import ROOT
125 
126  event = makeEvent("test.root")
127  inputTag = ROOT.art.InputTag("largeant")
128 
129  getParticlesFrom = make_getValidHandle("std::vector<simb::MCParticle>")
130  # note: the following is curretly mostly broken (see below)
131  particles1 = getParticlesFrom(event, inputTag).product()
132 
133  getParticles = make_getValidHandle("std::vector<simb::MCParticle>", event)
134  particles2 = getParticles(inputTag).product()
135 
136  Both `particles1` and `particles2` point to the same data product.
137 
138  Exception (`RuntimeError`) is raised on error.
139  """
return self.validHandle(klass, event)
def galleryUtils.HandleMaker.make (   klass)
static

Definition at line 68 of file sbndcode/sbndcode/gallery/python/galleryUtils.py.

68 
69  def make(klass):
70  ROOT.gROOT.ProcessLine('template gallery::ValidHandle<%(name)s> gallery::Event::getValidHandle<%(name)s>(art::InputTag const&) const;' % {'name' : klass})
71 
# class HandleMaker
def galleryUtils.HandleMaker.manyByType (   self,
  klass 
)

Definition at line 101 of file icarusalg/icarusalg/gallery/helpers/python/galleryUtils.py.

102  klass: "data product class to prepare for (as a C++ class name string)",
103  event: "(optional) the event object to retrieve the data products from " = None,
104  ) -> """if `event` is specified, a list (std::vector) of handles,
105  otherwise a callable that when called on an event returns such list""":
106  getManyByType = HandleMaker.ManyByTypeProc(klass)
return getManyByType(event) if event else (lambda event: getManyByType(event))
def galleryUtils.HandleMaker.validHandle (   self,
  klass 
)

Definition at line 91 of file icarusalg/icarusalg/gallery/helpers/python/galleryUtils.py.

91 
92  klass: "data product class to prepare for (as a C++ class name string)",
93  event: "(optional) the event object to retrieve the data products from " = None,
94  ) -> "if `event` is specified, bound `getValidHandle<klass>`, unbound otherwise":
95  # this has been tested with ROOT 6.22;
96  # big improvements in cppyy make this **way** simpler than it used to be
97  getHandle = ROOT.gallery.Event.getValidHandle[klass]
return (lambda tag: getHandle(event, tag)) if event else getHandle

Member Data Documentation

tuple galleryUtils.HandleMaker.AlreadyMade = set()
static

Definition at line 50 of file sbndcode/sbndcode/gallery/python/galleryUtils.py.


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